ia64/xen-unstable

changeset 9139:8853631252d8

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@xensource.com>
author emellor@leeni.uk.xensource.com
date Sat Mar 04 19:10:56 2006 +0100 (2006-03-04)
parents d088ce2d3528
children 5aae1b1c3098
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/include/xen/xenbus.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Fri Mar 03 15:56:34 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Sat Mar 04 19:10:56 2006 +0100
     1.3 @@ -95,18 +95,25 @@ int xenbus_switch_state(struct xenbus_de
     1.4  	 */
     1.5  
     1.6  	int current_state;
     1.7 +	int err;
     1.8  
     1.9 -	int err = xenbus_scanf(xbt, dev->nodename, "state", "%d",
    1.10 +	if (state == dev->state)
    1.11 +		return 0;
    1.12 +
    1.13 +	err = xenbus_scanf(xbt, dev->nodename, "state", "%d",
    1.14  			       &current_state);
    1.15 -	if ((err == 1 && (XenbusState)current_state == state) ||
    1.16 -	    err == -ENOENT)
    1.17 +	if (err != 1)
    1.18  		return 0;
    1.19  
    1.20  	err = xenbus_printf(xbt, dev->nodename, "state", "%d", state);
    1.21  	if (err) {
    1.22 -		xenbus_dev_fatal(dev, err, "writing new state");
    1.23 +		if (state != XenbusStateClosing) /* Avoid looping */
    1.24 +			xenbus_dev_fatal(dev, err, "writing new state");
    1.25  		return err;
    1.26  	}
    1.27 +
    1.28 +	dev->state = state;
    1.29 +
    1.30  	return 0;
    1.31  }
    1.32  EXPORT_SYMBOL(xenbus_switch_state);
    1.33 @@ -138,7 +145,6 @@ void _dev_error(struct xenbus_device *de
    1.34  	ret = vsnprintf(printf_buffer+len, PRINTF_BUFFER_SIZE-len, fmt, ap);
    1.35  
    1.36  	BUG_ON(len + ret > PRINTF_BUFFER_SIZE-1);
    1.37 -	dev->has_error = 1;
    1.38  
    1.39  	dev_err(&dev->dev, "%s\n", printf_buffer);
    1.40  
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Mar 03 15:56:34 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Sat Mar 04 19:10:56 2006 +0100
     2.3 @@ -888,16 +888,13 @@ static int all_devices_ready_(struct dev
     2.4  {
     2.5  	struct xenbus_device *xendev = to_xenbus_device(dev);
     2.6  	int *result = data;
     2.7 -	int state;
     2.8  
     2.9 -	int err = xenbus_scanf(XBT_NULL, xendev->nodename, "state", "%d",
    2.10 -			       &state);
    2.11 -	if (err != 1 || state != XenbusStateConnected) {
    2.12 +	if (xendev->state != XenbusStateConnected) {
    2.13  		result = 0;
    2.14  		return 1;
    2.15  	}
    2.16  
    2.17 -	return 1;
    2.18 +	return 0;
    2.19  }
    2.20  
    2.21  
     3.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Fri Mar 03 15:56:34 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Sat Mar 04 19:10:56 2006 +0100
     3.3 @@ -63,7 +63,7 @@ struct xenbus_device {
     3.4  	int otherend_id;
     3.5  	struct xenbus_watch otherend_watch;
     3.6  	struct device dev;
     3.7 -	int has_error;
     3.8 +	XenbusState state;
     3.9  	void *data;
    3.10  };
    3.11