[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] blktap2: Fix queue restart, racing block device removal.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1267437375 0 # Node ID 2fc782287952cc8ee6f7c0768970d96fb566eef5 # Parent 46c3ae66c32b97bc66f2ed13a715839712972659 blktap2: Fix queue restart, racing block device removal. Makes tapdisk context test dev->gd before attempting a queue restart, with the device lock held. Fixes a race lost against device destruction, which may issued anywhere on the control path. Signed-off-by: Daniel Stodden <daniel.stodden@xxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> --- drivers/xen/blktap2/device.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff -r 46c3ae66c32b -r 2fc782287952 drivers/xen/blktap2/device.c --- a/drivers/xen/blktap2/device.c Mon Mar 01 09:55:54 2010 +0000 +++ b/drivers/xen/blktap2/device.c Mon Mar 01 09:56:15 2010 +0000 @@ -951,8 +951,6 @@ blktap_device_restart(struct blktap *tap struct blktap_device *dev; dev = &tap->device; - if (!dev->gd || !dev->gd->queue) - return; if (blktap_active(tap) && RING_FULL(&tap->ring.ring)) { blktap_defer(tap); @@ -968,11 +966,15 @@ blktap_device_restart(struct blktap *tap spin_lock_irq(&dev->lock); /* Re-enable calldowns. */ - if (blk_queue_stopped(dev->gd->queue)) - blk_start_queue(dev->gd->queue); - - /* Kick things off immediately. */ - blktap_device_do_request(dev->gd->queue); + if (dev->gd) { + struct request_queue *rq = dev->gd->queue; + + if (blk_queue_stopped(rq)) + blk_start_queue(rq); + + /* Kick things off immediately. */ + blktap_device_do_request(rq); + } spin_unlock_irq(&dev->lock); } @@ -1061,6 +1063,7 @@ blktap_device_destroy(struct blktap *tap blktap_device_destroy(struct blktap *tap) { struct blktap_device *dev = &tap->device; + struct gendisk *gd = dev->gd; if (!test_bit(BLKTAP_DEVICE, &tap->dev_inuse)) return 0; @@ -1072,8 +1075,9 @@ blktap_device_destroy(struct blktap *tap spin_lock_irq(&dev->lock); /* No more blktap_device_do_request(). */ - blk_stop_queue(dev->gd->queue); + blk_stop_queue(gd->queue); clear_bit(BLKTAP_DEVICE, &tap->dev_inuse); + dev->gd = NULL; spin_unlock_irq(&dev->lock); #ifdef ENABLE_PASSTHROUGH @@ -1081,11 +1085,9 @@ blktap_device_destroy(struct blktap *tap blktap_device_close_bdev(tap); #endif - del_gendisk(dev->gd); - blk_cleanup_queue(dev->gd->queue); - put_disk(dev->gd); - - dev->gd = NULL; + del_gendisk(gd); + blk_cleanup_queue(gd->queue); + put_disk(gd); wake_up(&tap->wq); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |