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-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Do not create blkback vbd kernel thread until fully connected
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 06 Apr 2006 22:32:14 +0000
Delivery-date: Thu, 06 Apr 2006 15:34:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>