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] [linux-2.6.18-xen] blktap2: Fix queue restart, racing bl

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] blktap2: Fix queue restart, racing block device removal.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 01 Mar 2010 02:00:12 -0800
Delivery-date: Mon, 01 Mar 2010 02:00:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] blktap2: Fix queue restart, racing block device removal., Xen patchbot-linux-2.6.18-xen <=