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

[Xen-changelog] Fix the test inside all_devices_ready, and move it from xenbus_probe (a



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 4a5d00175712aead6d768aa0ae1dc3aac5145cee
# Parent  81719c84ed17786e3603f46542de4d68cf46f121
Fix the test inside all_devices_ready, and move it from xenbus_probe (a
postcore_initcall) to a new late_initcall, so that it happens after the
drivers have initialised.

Fixes the reopened bug #549 (I hope).

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

Netfront must switch state using xenbus_switch_state() or this
is not picked up by the waiting code in xenbus_probe.c.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 81719c84ed17 -r 4a5d00175712 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Apr 10 
17:33:04 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Apr 10 
17:57:58 2006
@@ -300,13 +300,6 @@
                goto abort_transaction;
        }
 
-       err = xenbus_printf(xbt, dev->nodename,
-                           "state", "%d", XenbusStateConnected);
-       if (err) {
-               message = "writing frontend XenbusStateConnected";
-               goto abort_transaction;
-       }
-
        err = xenbus_transaction_end(xbt, 0);
        if (err) {
                if (err == -EAGAIN)
@@ -314,6 +307,8 @@
                xenbus_dev_fatal(dev, err, "completing transaction");
                goto destroy_ring;
        }
+
+       xenbus_switch_state(dev, XenbusStateConnected);
 
        return 0;
 
diff -r 81719c84ed17 -r 4a5d00175712 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Mon Apr 10 
17:33:04 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Mon Apr 10 
17:57:58 2006
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2005 Rusty Russell, IBM Corporation
  * Copyright (C) 2005 Mike Wray, Hewlett-Packard
- * Copyright (C) 2005 XenSource Ltd
+ * Copyright (C) 2005, 2006 XenSource Ltd
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
@@ -883,7 +883,7 @@
        int *result = data;
 
        if (xendev->state != XenbusStateConnected) {
-               result = 0;
+               *result = 0;
                return 1;
        }
 
@@ -902,8 +902,6 @@
 
 void xenbus_probe(void *unused)
 {
-       int i;
-
        BUG_ON((xenstored_ready <= 0));
 
        /* Enumerate devices in xenstore. */
@@ -916,28 +914,6 @@
 
        /* 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");
 }
 
 
@@ -1072,6 +1048,38 @@
 
 postcore_initcall(xenbus_probe_init);
 
+
+/*
+ * On a 10 second timeout, wait 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.
+ *
+ * This needs to be on a late_initcall, to happen after the frontend device
+ * drivers have been initialised, but before the root fs is mounted.
+ *
+ * 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.
+ */
+static int __init wait_for_devices(void)
+{
+       unsigned long timeout = jiffies + 10*HZ;
+
+       while (time_before(jiffies, timeout)) {
+               if (all_devices_ready())
+                       return 0;
+               schedule_timeout_interruptible(HZ/10);
+       }
+
+       printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n");
+       return 0;
+}
+
+late_initcall(wait_for_devices);
+
+
 /*
  * Local variables:
  *  c-file-style: "linux"

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