]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Fix the blkif_schedule() kthread loop. Much simpler; much more correct.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 09:21:04 +0000 (10:21 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 09:21:04 +0000 (10:21 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c

index 2de5f1c60c459e17dabfc16969be1b8076336296..587f49f0f2bb9c7bc3dd30aadbb826356da2da32 100644 (file)
@@ -215,49 +215,20 @@ static void print_stats(blkif_t *blkif)
 
 int blkif_schedule(void *arg)
 {
-       blkif_t          *blkif = arg;
+       blkif_t *blkif = arg;
 
        blkif_get(blkif);
+
        if (debug_lvl)
                printk(KERN_DEBUG "%s: started\n", current->comm);
-       for (;;) {
-               if (kthread_should_stop()) {
-                       /* asked to quit? */
-                       if (!atomic_read(&blkif->io_pending))
-                               break;
-                       if (debug_lvl)
-                               printk(KERN_DEBUG "%s: I/O pending, "
-                                      "delaying exit\n", current->comm);
-               }
-
-               if (!atomic_read(&blkif->io_pending)) {
-                       /* Wait for work to do. */
-                       wait_event_interruptible(
-                               blkif->wq,
-                               (atomic_read(&blkif->io_pending) ||
-                                kthread_should_stop()));
-               } else if (list_empty(&pending_free)) {
-                       /* Wait for pending_req becoming available. */
-                       wait_event_interruptible(
-                               pending_free_wq,
-                               !list_empty(&pending_free));
-               }
 
-               if (blkif->status != CONNECTED) {
-                       /* make sure we are connected */
-                       if (debug_lvl)
-                               printk(KERN_DEBUG "%s: not connected "
-                                      "(%d pending)\n",
-                                      current->comm,
-                                      atomic_read(&blkif->io_pending));
-                       wait_event_interruptible(
-                               blkif->wq,
-                               (blkif->status == CONNECTED ||
-                                kthread_should_stop()));
-                       continue;
-               }
+       while (!kthread_should_stop()) {
+               wait_event_interruptible(
+                       blkif->wq,
+                       (atomic_read(&blkif->io_pending) &&
+                        !list_empty(&pending_free)) ||
+                       kthread_should_stop());
 
-               /* Schedule I/O */
                atomic_set(&blkif->io_pending, 0);
                if (do_block_io_op(blkif))
                        atomic_inc(&blkif->io_pending);
@@ -271,8 +242,10 @@ int blkif_schedule(void *arg)
                print_stats(blkif);
        if (debug_lvl)
                printk(KERN_DEBUG "%s: exiting\n", current->comm);
+
        blkif->xenblkd = NULL;
        blkif_put(blkif);
+
        return 0;
 }