From: Daniel Stodden Subject: [PATCH 6 of 8] blkfront: Move xenstore accesses off the device release path Date: Fri, 26 Feb 2010 16:04:54 -0000 Message-ID: <183cbdaef8d14d863465.1267200294@agari.van.xensource.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8220607934021917766==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen Cc: Jeremy Fitzhardinge List-Id: xen-devel@lists.xenproject.org --===============8220607934021917766== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Not holding the bdev mutex should be slightly more robust. Also helps getting blkfront_closing to complement xlvbd_alloc_gendisk. Signed-off-by: Daniel Stodden --===============8220607934021917766== Content-Type: text/x-patch; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=xs-write-unlocked.diff # HG changeset patch # User Daniel Stodden # Date 1267200019 28800 # Node ID 183cbdaef8d14d863465c18bc06cbc7849c30bbc # Parent 96525ab0393ab7cab181de757a495f57284ccd01 blkfront: Move xenstore accesses off the device release path. Not holding the bdev mutex should be slightly more robust. Also helps getting blkfront_closing to complement xlvbd_alloc_gendisk. Signed-off-by: Daniel Stodden diff -r 96525ab0393a -r 183cbdaef8d1 drivers/block/xen-blkfront.c --- a/drivers/block/xen-blkfront.c Fri Feb 26 07:27:44 2010 -0800 +++ b/drivers/block/xen-blkfront.c Fri Feb 26 08:00:19 2010 -0800 @@ -927,8 +927,8 @@ dev_dbg(&dev->dev, "blkfront_closing: %s removed\n", dev->nodename); - if (info->rq == NULL) - goto out; + if (!info->gd) + return; spin_lock_irqsave(&blkif_io_lock, flags); @@ -949,9 +949,6 @@ put_disk(info->gd); info->gd = NULL; - - out: - xenbus_frontend_closed(dev); } static void blkfront_close(struct blkfront_info *info) @@ -959,6 +956,7 @@ struct xenbus_device *dev = info->xbdev; struct gendisk *gd = info->gd; struct block_device *bd; + int inuse; if (!gd) { xenbus_frontend_closed(dev); @@ -973,14 +971,18 @@ mutex_lock(&bd->bd_mutex); - if (info->users > 0) - xenbus_dev_error(dev, -EBUSY, - "Device in use; refusing to close"); - else + inuse = !!info->users; + if (!inuse) blkfront_closing(dev); mutex_unlock(&bd->bd_mutex); bdput(bd); + + if (inuse) + xenbus_dev_error(dev, -EBUSY, + "Device in use; refusing to close"); + else + xenbus_frontend_closed(dev); } /** @@ -1051,8 +1053,10 @@ struct xenbus_device *dev = info->xbdev; enum xenbus_state state = xenbus_read_driver_state(dev->otherend); - if (state == XenbusStateClosing && info->is_ready) + if (state == XenbusStateClosing && info->is_ready) { blkfront_closing(dev); + xenbus_frontend_closed(dev); + } } return 0; } --===============8220607934021917766== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============8220607934021917766==--