[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] merge.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 5e8123554d158af331c65dfd5a93981f54b54196
# Parent  fd28bf8825a86d79a42703fa48ed751c7c2ebef4
# Parent  1872e09bfba38eb573515599248ef2ef3ee2dc97
merge.

diff -r fd28bf8825a8 -r 5e8123554d15 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Aug 19 17:56:20 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Aug 19 17:57:00 2005
@@ -182,14 +182,18 @@
                            "frontend-id", "%li", &be->frontend_id,
                            "frontend", NULL, &frontend,
                            NULL);
-       if (err == -ENOENT || err == -ERANGE ||
+       if (XENBUS_EXIST_ERR(err) ||
            strlen(frontend) == 0 || !xenbus_exists(frontend, "")) {
-               if (frontend)
-                       kfree(frontend);
                /* If we can't get a frontend path and a frontend-id,
                 * then our bus-id is no longer valid and we need to
                 * destroy the backend device.
                 */
+               goto device_fail;
+       }
+       if (err < 0) {
+               xenbus_dev_error(dev, err,
+                                "reading %s/frontend or frontend-id",
+                                dev->nodename);
                goto device_fail;
        }
 
@@ -199,6 +203,7 @@
                if (be->frontpath)
                        kfree(be->frontpath);
                be->frontpath = frontend;
+               frontend = NULL;
                be->watch.node = be->frontpath;
                be->watch.callback = frontend_changed;
                err = register_xenbus_watch(&be->watch);
@@ -206,14 +211,13 @@
                        be->watch.node = NULL;
                        goto device_fail;
                }
-       } else
-               kfree(frontend);
+       }
 
        err = xenbus_scanf(dev->nodename, "physical-device", "%li", &pdev);
-       if (err == -ENOENT || err == -ERANGE)
+       if (XENBUS_EXIST_ERR(err))
                goto out;
        if (err < 0) {
-               xenbus_dev_error(dev, err, "Reading physical-device");
+               xenbus_dev_error(dev, err, "reading physical-device");
                goto device_fail;
        }
        if (be->pdev && be->pdev != pdev) {
@@ -253,12 +257,14 @@
                frontend_changed(&be->watch, be->frontpath);
        }
 
+ out:
+       if (frontend)
+               kfree(frontend);
        return;
 
  device_fail:
        device_unregister(&be->dev->dev);
- out:
-       return;
+       goto out;
 }
 
 static int blkback_probe(struct xenbus_device *dev,
diff -r fd28bf8825a8 -r 5e8123554d15 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Aug 19 
17:56:20 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Aug 19 
17:57:00 2005
@@ -1134,25 +1134,24 @@
                            "info", "%u", &binfo,
                            "sector-size", "%lu", &sector_size,
                            NULL);
-
-       if (err)
+       if (err) {
                xenbus_dev_error(info->dev, err, "reading backend fields");
-       else {
-               xlvbd_add(sectors, info->vdevice, info->handle, binfo,
-                         sector_size);
-               info->connected = 1;
-
-               /* First to connect?  blkif is now connected. */
-               if (blkif_vbds_connected++ == 0)
-                       blkif_state = BLKIF_STATE_CONNECTED;
-
-               xenbus_dev_ok(info->dev);
-
-               /* Kick pending requests. */
-               spin_lock_irq(&blkif_io_lock);
-               kick_pending_request_queues();
-               spin_unlock_irq(&blkif_io_lock);
-       }
+               return;
+       }
+
+       xlvbd_add(sectors, info->vdevice, info->handle, binfo, sector_size);
+       info->connected = 1;
+
+       /* First to connect?  blkif is now connected. */
+       if (blkif_vbds_connected++ == 0)
+               blkif_state = BLKIF_STATE_CONNECTED;
+
+       xenbus_dev_ok(info->dev);
+
+       /* Kick pending requests. */
+       spin_lock_irq(&blkif_io_lock);
+       kick_pending_request_queues();
+       spin_unlock_irq(&blkif_io_lock);
 }
 
 static int setup_blkring(struct xenbus_device *dev, unsigned int backend_id)
@@ -1199,36 +1198,28 @@
        const char *message;
        int err, backend_id;
 
-       backend = xenbus_read(dev->nodename, "backend", NULL);
-       if (IS_ERR(backend)) {
-               err = PTR_ERR(backend);
-               if (err == -ENOENT)
-                       goto out;
-               xenbus_dev_error(dev, err, "reading %s/backend",
+       backend = NULL;
+       err = xenbus_gather(dev->nodename,
+                           "backend-id", "%i", &backend_id,
+                           "backend", NULL, &backend,
+                           NULL);
+       if (XENBUS_EXIST_ERR(err))
+               goto out;
+       if (backend && strlen(backend) == 0) {
+               err = -ENOENT;
+               goto out;
+       }
+       if (err < 0) {
+               xenbus_dev_error(dev, err, "reading %s/backend or backend-id",
                                 dev->nodename);
                goto out;
        }
-       if (strlen(backend) == 0) {
-               err = -ENOENT;
-               goto free_backend;
-       }
-
-       /* FIXME: This driver can't handle backends on different
-        * domains.  Check and fail gracefully. */
-       err = xenbus_scanf(dev->nodename, "backend-id", "%i", &backend_id);
-       if (err == -ENOENT)
-               goto free_backend;
-       if (err < 0) {
-               xenbus_dev_error(dev, err, "reading %s/backend-id",
-                                dev->nodename);
-               goto free_backend;
-       }
 
        /* First device?  We create shared ring, alloc event channel. */
        if (blkif_vbds == 0) {
                err = setup_blkring(dev, backend_id);
                if (err)
-                       goto free_backend;
+                       goto out;
        }
 
        err = xenbus_transaction_start(dev->nodename);
@@ -1258,9 +1249,11 @@
                goto abort_transaction;
        }
 
-       info->watch.node = info->backend = backend;
+       info->backend = backend;
+       backend = NULL;
+
+       info->watch.node = info->backend;
        info->watch.callback = watch_for_status;
-
        err = register_xenbus_watch(&info->watch);
        if (err) {
                message = "registering watch on backend";
@@ -1272,20 +1265,20 @@
                xenbus_dev_error(dev, err, "completing transaction");
                goto destroy_blkring;
        }
-       return 0;
-
-abort_transaction:
+
+ out:
+       if (backend)
+               kfree(backend);
+       return err;
+
+ abort_transaction:
        xenbus_transaction_end(1);
        /* Have to do this *outside* transaction.  */
        xenbus_dev_error(dev, err, "%s", message);
-destroy_blkring:
+ destroy_blkring:
        if (blkif_vbds == 0)
                blkif_free();
-free_backend:
-       kfree(backend);
-out:
-       printk("%s:%u = %i\n", __FILE__, __LINE__, err);
-       return err;
+       goto out;
 }
 
 /* Setup supplies the backend dir, virtual device.
@@ -1301,7 +1294,7 @@
 
        /* FIXME: Use dynamic device id if this is not set. */
        err = xenbus_scanf(dev->nodename, "virtual-device", "%i", &vdevice);
-       if (err == -ENOENT)
+       if (XENBUS_EXIST_ERR(err))
                return err;
        if (err < 0) {
                xenbus_dev_error(dev, err, "reading virtual-device");
@@ -1316,6 +1309,7 @@
        info->dev = dev;
        info->vdevice = vdevice;
        info->connected = 0;
+
        /* Front end dir is a number, which is used as the id. */
        info->handle = simple_strtoul(strrchr(dev->nodename,'/')+1, NULL, 0);
        dev->data = info;
@@ -1427,8 +1421,8 @@
 
 #ifdef CONFIG_XEN_BLKDEV_GRANT
     /* A grant for every ring slot, plus one for the ring itself. */
-    if ( 0 > gnttab_alloc_grant_references(MAXIMUM_OUTSTANDING_BLOCK_REQS + 1,
-                                           &gref_head, &gref_terminal) )
+    if (gnttab_alloc_grant_references(MAXIMUM_OUTSTANDING_BLOCK_REQS + 1,
+                                     &gref_head, &gref_terminal) < 0)
         return 1;
     printk(KERN_ALERT "Blkif frontend is using grant tables.\n");
 #endif
diff -r fd28bf8825a8 -r 5e8123554d15 
linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Fri Aug 19 17:56:20 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Fri Aug 19 17:57:00 2005
@@ -128,4 +128,14 @@
 void xenbus_suspend(void);
 void xenbus_resume(void);
 
+#define XENBUS_IS_ERR_READ(str) ({                     \
+       if (!IS_ERR(str) && strlen(str) == 0) {         \
+               kfree(str);                             \
+               str = ERR_PTR(-ERANGE);                 \
+       }                                               \
+       IS_ERR(str);                                    \
+})
+
+#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
+
 #endif /* _ASM_XEN_XENBUS_H */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.