ia64/xen-unstable
changeset 9607:937336f98c47
Fix the blkif_schedule() kthread loop. Much simpler; much more correct.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Apr 06 10:20:32 2006 +0100 (2006-04-06) |
parents | 787d946ad457 |
children | 8031bf331472 |
files | linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu Apr 06 09:47:58 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu Apr 06 10:20:32 2006 +0100 1.3 @@ -215,49 +215,20 @@ static void print_stats(blkif_t *blkif) 1.4 1.5 int blkif_schedule(void *arg) 1.6 { 1.7 - blkif_t *blkif = arg; 1.8 + blkif_t *blkif = arg; 1.9 1.10 blkif_get(blkif); 1.11 + 1.12 if (debug_lvl) 1.13 printk(KERN_DEBUG "%s: started\n", current->comm); 1.14 - for (;;) { 1.15 - if (kthread_should_stop()) { 1.16 - /* asked to quit? */ 1.17 - if (!atomic_read(&blkif->io_pending)) 1.18 - break; 1.19 - if (debug_lvl) 1.20 - printk(KERN_DEBUG "%s: I/O pending, " 1.21 - "delaying exit\n", current->comm); 1.22 - } 1.23 1.24 - if (!atomic_read(&blkif->io_pending)) { 1.25 - /* Wait for work to do. */ 1.26 - wait_event_interruptible( 1.27 - blkif->wq, 1.28 - (atomic_read(&blkif->io_pending) || 1.29 - kthread_should_stop())); 1.30 - } else if (list_empty(&pending_free)) { 1.31 - /* Wait for pending_req becoming available. */ 1.32 - wait_event_interruptible( 1.33 - pending_free_wq, 1.34 - !list_empty(&pending_free)); 1.35 - } 1.36 + while (!kthread_should_stop()) { 1.37 + wait_event_interruptible( 1.38 + blkif->wq, 1.39 + (atomic_read(&blkif->io_pending) && 1.40 + !list_empty(&pending_free)) || 1.41 + kthread_should_stop()); 1.42 1.43 - if (blkif->status != CONNECTED) { 1.44 - /* make sure we are connected */ 1.45 - if (debug_lvl) 1.46 - printk(KERN_DEBUG "%s: not connected " 1.47 - "(%d pending)\n", 1.48 - current->comm, 1.49 - atomic_read(&blkif->io_pending)); 1.50 - wait_event_interruptible( 1.51 - blkif->wq, 1.52 - (blkif->status == CONNECTED || 1.53 - kthread_should_stop())); 1.54 - continue; 1.55 - } 1.56 - 1.57 - /* Schedule I/O */ 1.58 atomic_set(&blkif->io_pending, 0); 1.59 if (do_block_io_op(blkif)) 1.60 atomic_inc(&blkif->io_pending); 1.61 @@ -271,8 +242,10 @@ int blkif_schedule(void *arg) 1.62 print_stats(blkif); 1.63 if (debug_lvl) 1.64 printk(KERN_DEBUG "%s: exiting\n", current->comm); 1.65 + 1.66 blkif->xenblkd = NULL; 1.67 blkif_put(blkif); 1.68 + 1.69 return 0; 1.70 } 1.71