Commit 3a450589 authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: blkvsc: Fix bugs in the module unload path

Fix bugs in the module unload path for the blkvsc driver.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarAbhishek Kane <v-abkane@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9d7b18d1
......@@ -518,22 +518,18 @@ static int blkvsc_remove(struct hv_device *dev)
blkvsc_do_operation(blkdev, DO_FLUSH);
if (blkdev->users == 0) {
del_gendisk(blkdev->gd);
put_disk(blkdev->gd);
blk_cleanup_queue(blkdev->gd->queue);
/*
* Call to the vsc driver to let it know that the device is being
* removed
*/
storvsc_dev_remove(dev);
del_gendisk(blkdev->gd);
storvsc_dev_remove(blkdev->device_ctx);
kmem_cache_destroy(blkdev->request_pool);
kfree(blkdev);
}
return 0;
}
static void blkvsc_shutdown(struct hv_device *dev)
......@@ -568,12 +564,22 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
struct block_device_context *blkdev = disk->private_data;
unsigned long flags;
if (blkdev->users == 1) {
spin_lock_irqsave(&blkdev->lock, flags);
if ((--blkdev->users == 0) && (blkdev->shutting_down)) {
blk_stop_queue(blkdev->gd->queue);
spin_unlock_irqrestore(&blkdev->lock, flags);
blkvsc_do_operation(blkdev, DO_FLUSH);
}
del_gendisk(blkdev->gd);
put_disk(blkdev->gd);
blk_cleanup_queue(blkdev->gd->queue);
spin_lock_irqsave(&blkdev->lock, flags);
blkdev->users--;
storvsc_dev_remove(blkdev->device_ctx);
kmem_cache_destroy(blkdev->request_pool);
kfree(blkdev);
} else
spin_unlock_irqrestore(&blkdev->lock, flags);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment