[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 kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 24d25894f071bed67d5547c1790a075271ab1174
# Parent  388c59fefaa6add89ca38622f2170cb7c98429ba
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.

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

diff -r 388c59fefaa6 -r 24d25894f071 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Thu Apr  6 
16:49:21 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Thu Apr  6 
17:39:00 2006
@@ -287,7 +287,7 @@
  * NOTIFICATION FROM GUEST OS.
  */
 
-void blkif_notify_work(blkif_t *blkif)
+static void blkif_notify_work(blkif_t *blkif)
 {
        blkif->waiting_reqs = 1;
        wake_up(&blkif->wq);
diff -r 388c59fefaa6 -r 24d25894f071 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Thu Apr  6 16:49:21 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Thu Apr  6 17:39:00 2006
@@ -129,7 +129,6 @@
 
 void blkif_xenbus_init(void);
 
-void blkif_notify_work(blkif_t *blkif);
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
 int blkif_schedule(void *arg);
 
diff -r 388c59fefaa6 -r 24d25894f071 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Thu Apr  6 16:49:21 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Thu Apr  6 17:39:00 2006
@@ -46,10 +46,29 @@
 
 static void update_blkif_status(blkif_t *blkif)
 { 
-       if (blkif->irq && blkif->vbd.bdev &&
-           (blkif->be->dev->state != XenbusStateConnected)) {
-               connect(blkif->be);
-               blkif_notify_work(blkif);
+       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");
        }
 }
 
@@ -212,17 +231,6 @@
                        be->major = 0;
                        be->minor = 0;
                        xenbus_dev_fatal(dev, err, "creating vbd structure");
-                       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;
                }
 

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