# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 9e19dcb05f56ca7cc91ccd0dff847da5f21d868a
# Parent c8c0f99193d4e4272c7d0ad08c72af2572efd2fd
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@xxxxxxxxxxxxx>
diff -r c8c0f99193d4 -r 9e19dcb05f56
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:41:56 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Fri Mar 3
14:56:03 2006
@@ -884,9 +884,36 @@
EXPORT_SYMBOL(unregister_xenstore_notifier);
+static int all_devices_ready_(struct device *dev, void *data)
+{
+ 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) {
+ result = 0;
+ return 1;
+ }
+
+ return 1;
+}
+
+
+static int all_devices_ready(void)
+{
+ int ready = 1;
+ bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
+ all_devices_ready_);
+ return ready;
+}
+
void xenbus_probe(void *unused)
{
+ int i;
+
BUG_ON((xenstored_ready <= 0));
/* Enumerate devices in xenstore. */
@@ -899,6 +926,28 @@
/* Notify others that xenstore is up */
notifier_call_chain(&xenstore_chain, 0, NULL);
+
+ /* On a 10 second timeout, waiting for all devices currently
+ configured. We need to do this to guarantee that the filesystems
+ and / or network devices needed for boot are available, before we
+ can allow the boot to proceed.
+
+ A possible improvement here would be to have the tools add a
+ per-device flag to the store entry, indicating whether it is needed
+ at boot time. This would allow people who knew what they were
+ doing to accelerate their boot slightly, but of course needs tools
+ or manual intervention to set up those flags correctly.
+ */
+ for (i = 0; i < 10 * HZ; i++) {
+ if (all_devices_ready())
+ return;
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+ }
+
+ printk(KERN_WARNING
+ "XENBUS: Timeout connecting to devices!\n");
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|