This is just bd_openers, protected by the bd_mutex. Signed-off-by: Daniel Stodden diff -r 4d4cc7268176 -r 798c5b306104 drivers/block/xen-blkfront.c --- a/drivers/block/xen-blkfront.c Fri Apr 30 14:58:59 2010 -0700 +++ b/drivers/block/xen-blkfront.c Fri Apr 30 14:58:59 2010 -0700 @@ -94,12 +94,6 @@ unsigned long shadow_free; int feature_barrier; int is_ready; - - /** - * The number of people holding this device open. We won't allow a - * hot-unplug unless this is 0. - */ - int users; }; static DEFINE_SPINLOCK(blkif_io_lock); @@ -977,7 +971,7 @@ mutex_lock(&bdev->bd_mutex); - if (info->users) { + if (bdev->bd_openers) { xenbus_dev_error(xbdev, -EBUSY, "Device in use; refusing to close"); xenbus_switch_state(xbdev, XenbusStateClosing); @@ -1128,7 +1122,7 @@ mutex_lock(&bdev->bd_mutex); info = disk->private_data; - if (info && !info->users) { + if (info && !bdev->bd_openers) { xlvbd_release_gendisk(info); disk->private_data = NULL; kfree(info); @@ -1166,9 +1160,6 @@ mutex_unlock(&info->mutex); - if (!err) - ++info->users; - return err; } @@ -1178,12 +1169,12 @@ struct block_device *bdev; struct xenbus_device *xbdev; - if (--info->users) - return 0; - bdev = bdget_disk(disk, 0); bdput(bdev); + if (bdev->bd_openers) + return 0; + /* * Check if we have been instructed to close. We will have * deferred this request, because the bdev was still open.