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

[Xen-changelog] Do not create blkback vbd kernel thread until fully connected



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 969b33e87e0a180ca4b2e6513ea1c0d5ccf81c82
# Parent  a8da66acde0c2c06c85476c62e287bd1201a0715
Do not create blkback vbd kernel thread until fully connected
to frontend driver. Otherwise the kernel thread may crash trying
to access the non-existent shared ring.

Replaces xen-3.0-testing cset: 9595:32b22f5286beba94318e60704a8058ac3833d502

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
xen-unstable changeset: 9571:24d25894f071bed67d5547c1790a075271ab1174
xen-unstable date: Thu Apr  6 18:39:00 2006 +0100

diff -r a8da66acde0c -r 969b33e87e0a 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Sat Apr 22 
10:42:34 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Mon Apr 24 
18:06:10 2006 +0100
@@ -221,14 +221,6 @@ int blkif_schedule(void *arg)
 
        if (debug_lvl)
                printk(KERN_DEBUG "%s: started\n", current->comm);
-
-       /*
-        * This thread may start before we are connected to the frontend
-        * driver. In that case we must wait to be fully connected.
-        */
-       wait_event_interruptible(
-               blkif->wq,
-               blkif_connected(blkif) || kthread_should_stop());
 
        while (!kthread_should_stop()) {
                wait_event_interruptible(
diff -r a8da66acde0c -r 969b33e87e0a 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Sat Apr 22 10:42:34 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Mon Apr 24 18:06:10 
2006 +0100
@@ -135,8 +135,6 @@ int blkif_schedule(void *arg);
 
 void update_blkif_status(blkif_t *blkif); 
 
-int blkif_connected(blkif_t *blkif);
-
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
 
 /*
diff -r a8da66acde0c -r 969b33e87e0a 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Sat Apr 22 10:42:34 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Apr 24 18:06:10 
2006 +0100
@@ -47,18 +47,33 @@ static void backend_changed(struct xenbu
 static void backend_changed(struct xenbus_watch *, const char **,
                            unsigned int);
 
-int blkif_connected(blkif_t *blkif)
-{
-       return (blkif->be->dev->state == XenbusStateConnected);
-}
-
-void update_blkif_status(blkif_t *blkif)
+
+static void update_blkif_status(blkif_t *blkif)
 { 
-       if(blkif->irq && blkif->vbd.bdev) {
-               blkif->status = CONNECTED; 
-               (void)blkif_be_int(0, blkif, NULL); 
-       }
-       maybe_connect(blkif->be); 
+       int err;
+
+       /* Not ready to connect? */
+       if (!blkif->irq || !blkif->vbd.bdev)
+               return;
+
+       /* Already connected? */
+       if (blkif->be->dev->state == XenbusStateConnected)
+               return;
+
+       /* Attempt to connect: exit if we fail to. */
+       connect(blkif->be);
+       if (blkif->be->dev->state != XenbusStateConnected)
+               return;
+
+       blkif->xenblkd = kthread_run(blkif_schedule, blkif,
+                                    "xvd %d %02x:%02x",
+                                    blkif->domid,
+                                    blkif->be->major, blkif->be->minor);
+       if (IS_ERR(blkif->xenblkd)) {
+               err = PTR_ERR(blkif->xenblkd);
+               blkif->xenblkd = NULL;
+               xenbus_dev_error(blkif->be->dev, err, "start xenblkd");
+       }
 }
 
 
@@ -224,17 +239,6 @@ static void backend_changed(struct xenbu
                        return;
                }
 
-               be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
-                                                "xvd %d %02x:%02x",
-                                                be->blkif->domid,
-                                                be->major, be->minor);
-               if (IS_ERR(be->blkif->xenblkd)) {
-                       err = PTR_ERR(be->blkif->xenblkd);
-                       be->blkif->xenblkd = NULL;
-                       xenbus_dev_error(dev, err, "start xenblkd");
-                       return;
-               }
-
                device_create_file(&dev->dev, &dev_attr_physical_device);
                device_create_file(&dev->dev, &dev_attr_mode);
 

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