]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Fix another blkback kernel thread I introduced. :-( The kernel thread
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 17:34:32 +0000 (18:34 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 17:34:32 +0000 (18:34 +0100)
is created before we are fully connected to the front end, so before
entering the main loop we must make sure that the shared ring is
mapped, otherwise we can fault.

This patch is an essential companion to the other two blkback
patches I committed earlier today. Hopefully this ends the saga.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c

index 477cab4bc60bcffa288476b4931ad99923f93d89..6e2b9102ad6389d5405374131bf65a3c1732ee98 100644 (file)
@@ -222,6 +222,14 @@ 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(
                        blkif->wq,
index 502a02c6b893a8c421383bc39a4f412aa49aa153..6b4647a679f1f01a38508c1cc8c62bade109c253 100644 (file)
@@ -135,6 +135,8 @@ int blkif_schedule(void *arg);
 
 void update_blkif_status(blkif_t *blkif); 
 
+int blkif_connected(blkif_t *blkif);
+
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
 
 /*
index 636caefdd8340377f4586863f2446c82360fb4fc..4a9eb3dc778dae4bcf89f63a597f44c95498734b 100644 (file)
@@ -47,6 +47,10 @@ static int connect_ring(struct backend_info *);
 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)
 {