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

[Xen-changelog] Added a 'state' field to the xenbus_device structure, which caches the state



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 8853631252d828c0205e4e89c2bc521aa1f34934
# Parent  d088ce2d3528e4014c5f8aca8a261229f2d5465c
Added a 'state' field to the xenbus_device structure, which caches the state
at the local end of the xenbus connection (i.e. that value that is passed
through xenbus_switch_state).  This means that xenbus_probe can wait for all
the boot devices to become ready without having to hurt the store.

Also, fix this probing -- previously, the wrong value was being returned by 
all_devices_ready_, so this polling would only have waited for one device. 

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r d088ce2d3528 -r 8853631252d8 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c   Fri Mar  3 
14:56:34 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c   Sat Mar  4 
18:10:56 2006
@@ -95,18 +95,25 @@
         */
 
        int current_state;
-
-       int err = xenbus_scanf(xbt, dev->nodename, "state", "%d",
+       int err;
+
+       if (state == dev->state)
+               return 0;
+
+       err = xenbus_scanf(xbt, dev->nodename, "state", "%d",
                               &current_state);
-       if ((err == 1 && (XenbusState)current_state == state) ||
-           err == -ENOENT)
+       if (err != 1)
                return 0;
 
        err = xenbus_printf(xbt, dev->nodename, "state", "%d", state);
        if (err) {
-               xenbus_dev_fatal(dev, err, "writing new state");
+               if (state != XenbusStateClosing) /* Avoid looping */
+                       xenbus_dev_fatal(dev, err, "writing new state");
                return err;
        }
+
+       dev->state = state;
+
        return 0;
 }
 EXPORT_SYMBOL(xenbus_switch_state);
@@ -138,7 +145,6 @@
        ret = vsnprintf(printf_buffer+len, PRINTF_BUFFER_SIZE-len, fmt, ap);
 
        BUG_ON(len + ret > PRINTF_BUFFER_SIZE-1);
-       dev->has_error = 1;
 
        dev_err(&dev->dev, "%s\n", printf_buffer);
 
diff -r d088ce2d3528 -r 8853631252d8 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri Mar  3 
14:56:34 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Sat Mar  4 
18:10:56 2006
@@ -888,16 +888,13 @@
 {
        struct xenbus_device *xendev = to_xenbus_device(dev);
        int *result = data;
-       int state;
-
-       int err = xenbus_scanf(XBT_NULL, xendev->nodename, "state", "%d",
-                              &state);
-       if (err != 1 || state != XenbusStateConnected) {
+
+       if (xendev->state != XenbusStateConnected) {
                result = 0;
                return 1;
        }
 
-       return 1;
+       return 0;
 }
 
 
diff -r d088ce2d3528 -r 8853631252d8 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Fri Mar  3 14:56:34 2006
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Sat Mar  4 18:10:56 2006
@@ -63,7 +63,7 @@
        int otherend_id;
        struct xenbus_watch otherend_watch;
        struct device dev;
-       int has_error;
+       XenbusState state;
        void *data;
 };
 

_______________________________________________
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®.