ia64/xen-unstable

changeset 9131:9e19dcb05f56

Wait for the devices configured at start-up, before allowing the boot to
proceed. This avoids the race (bug #549) that would result in the infamous
VFS: Cannot open root device "sda1" or unknown-block(0,0) message even when
the hotplug layer had succeeded to configure the device.

Note that The Infamous Message has many possible root causes -- this change
only fixes one of them. This particular root cause is characterised by
successful boots interleaved with unsuccessful ones, and diagnose.py showing
both front and backend drivers in the Connected state.

Closes bug #549.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri Mar 03 15:56:03 2006 +0100 (2006-03-03)
parents c8c0f99193d4
children d088ce2d3528
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Mar 03 15:41:56 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Mar 03 15:56:03 2006 +0100
     1.3 @@ -884,9 +884,36 @@ void unregister_xenstore_notifier(struct
     1.4  EXPORT_SYMBOL(unregister_xenstore_notifier);
     1.5  
     1.6  
     1.7 +static int all_devices_ready_(struct device *dev, void *data)
     1.8 +{
     1.9 +	struct xenbus_device *xendev = to_xenbus_device(dev);
    1.10 +	int *result = data;
    1.11 +	int state;
    1.12 +
    1.13 +	int err = xenbus_scanf(XBT_NULL, xendev->nodename, "state", "%d",
    1.14 +			       &state);
    1.15 +	if (err != 1 || state != XenbusStateConnected) {
    1.16 +		result = 0;
    1.17 +		return 1;
    1.18 +	}
    1.19 +
    1.20 +	return 1;
    1.21 +}
    1.22 +
    1.23 +
    1.24 +static int all_devices_ready(void)
    1.25 +{
    1.26 +	int ready = 1;
    1.27 +	bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
    1.28 +			 all_devices_ready_);
    1.29 +	return ready;
    1.30 +}
    1.31 +
    1.32  
    1.33  void xenbus_probe(void *unused)
    1.34  {
    1.35 +	int i;
    1.36 +
    1.37  	BUG_ON((xenstored_ready <= 0));
    1.38  
    1.39  	/* Enumerate devices in xenstore. */
    1.40 @@ -899,6 +926,28 @@ void xenbus_probe(void *unused)
    1.41  
    1.42  	/* Notify others that xenstore is up */
    1.43  	notifier_call_chain(&xenstore_chain, 0, NULL);
    1.44 +
    1.45 +	/* On a 10 second timeout, waiting for all devices currently
    1.46 +	   configured.  We need to do this to guarantee that the filesystems
    1.47 +	   and / or network devices needed for boot are available, before we
    1.48 +	   can allow the boot to proceed.
    1.49 +
    1.50 +	   A possible improvement here would be to have the tools add a
    1.51 +	   per-device flag to the store entry, indicating whether it is needed
    1.52 +	   at boot time.  This would allow people who knew what they were
    1.53 +	   doing to accelerate their boot slightly, but of course needs tools
    1.54 +	   or manual intervention to set up those flags correctly.
    1.55 +	 */
    1.56 +	for (i = 0; i < 10 * HZ; i++) {
    1.57 +		if (all_devices_ready())
    1.58 +			return;
    1.59 +
    1.60 +		set_current_state(TASK_INTERRUPTIBLE);
    1.61 +		schedule_timeout(1);
    1.62 +	}
    1.63 +
    1.64 +	printk(KERN_WARNING
    1.65 +	       "XENBUS: Timeout connecting to devices!\n");
    1.66  }
    1.67  
    1.68