WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] wait for devices before continuing

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] wait for devices before continuing
From: Rik van Riel <riel@xxxxxxxxxx>
Date: Fri, 11 Aug 2006 16:11:50 -0400
Delivery-date: Fri, 11 Aug 2006 13:12:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Red Hat, Inc
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
This patch fixes the "could not found the root filesystem after
the blkfront driver was loaded" race condition, which can occur
if blkfront does not get the disk hooked up before mount, or the
lvm tools, have already run.

It does this by simply waiting for all xenbus devices (which
have drivers loaded) to be attached to the driver before
continuing after the module initialization.

I have test booted this a number of times and the bootup race
condition appears to be gone.

Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>

--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
--- linux-2.6.17.noarch/drivers/xen/blkfront/blkfront.c.waitforme       
2006-08-11 14:01:58.000000000 -0400
+++ linux-2.6.17.noarch/drivers/xen/blkfront/blkfront.c 2006-08-11 
14:02:27.000000000 -0400
@@ -824,10 +824,17 @@ static struct xenbus_driver blkfront = {
 
 static int __init xlblk_init(void)
 {
+       int ret;
+
        if (!is_running_on_xen())
                return -ENODEV;
 
-       return xenbus_register_frontend(&blkfront);
+       ret = xenbus_register_frontend(&blkfront);
+       if (ret)
+               return ret;
+
+       xenbus_wait_for_devices();
+       return 0;
 }
 module_init(xlblk_init);
 
--- linux-2.6.17.noarch/drivers/xen/netfront/netfront.c.waitforme       
2006-08-11 14:02:41.000000000 -0400
+++ linux-2.6.17.noarch/drivers/xen/netfront/netfront.c 2006-08-11 
14:03:19.000000000 -0400
@@ -1579,6 +1579,8 @@ static struct notifier_block notifier_in
 
 static int __init netif_init(void)
 {
+       int ret;
+
        if (!is_running_on_xen())
                return -ENODEV;
 
@@ -1589,7 +1591,12 @@ static int __init netif_init(void)
 
        (void)register_inetaddr_notifier(&notifier_inetdev);
 
-       return xenbus_register_frontend(&netfront);
+       ret = xenbus_register_frontend(&netfront);
+       if (ret)
+               return ret;
+
+       xenbus_wait_for_devices();
+       return 0;
 }
 module_init(netif_init);
 
--- linux-2.6.17.noarch/drivers/xen/xenbus/xenbus_probe.c.waitforme     
2006-08-11 13:59:37.000000000 -0400
+++ linux-2.6.17.noarch/drivers/xen/xenbus/xenbus_probe.c       2006-08-11 
14:00:35.000000000 -0400
@@ -1067,7 +1067,7 @@ static int print_device_status(struct de
  * boot slightly, but of course needs tools or manual intervention to set up
  * those flags correctly.
  */
-static int __init wait_for_devices(void)
+int xenbus_wait_for_devices(void)
 {
        unsigned long timeout = jiffies + 10*HZ;
 
@@ -1083,4 +1083,5 @@ static int __init wait_for_devices(void)
        return 0;
 }
 
-late_initcall(wait_for_devices);
+EXPORT_SYMBOL(xenbus_wait_for_devices);
+late_initcall(xenbus_wait_for_devices);
--- linux-2.6.17.noarch/include/xen/xenbus.h.waitforme  2006-08-11 
14:00:07.000000000 -0400
+++ linux-2.6.17.noarch/include/xen/xenbus.h    2006-08-11 14:01:31.000000000 
-0400
@@ -157,6 +157,7 @@ int register_xenbus_watch(struct xenbus_
 void unregister_xenbus_watch(struct xenbus_watch *watch);
 void xs_suspend(void);
 void xs_resume(void);
+int xenbus_wait_for_devices(void);
 
 /* Used by xenbus_dev to borrow kernel's store connection. */
 void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] wait for devices before continuing, Rik van Riel <=