Commit 26a19739 authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: Get rid of the function blkvsc_do_flush()

Get rid of the function blkvsc_do_flush() and instead use the common function
to force a device flush.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6c65da76
...@@ -49,6 +49,7 @@ enum blkvsc_device_type { ...@@ -49,6 +49,7 @@ enum blkvsc_device_type {
enum blkvsc_op_type { enum blkvsc_op_type {
DO_INQUIRY, DO_INQUIRY,
DO_CAPACITY, DO_CAPACITY,
DO_FLUSH,
}; };
/* /*
...@@ -451,6 +452,13 @@ static int blkvsc_do_operation(struct block_device_context *blkdev, ...@@ -451,6 +452,13 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
blkvsc_req->cmd_len = 16; blkvsc_req->cmd_len = 16;
blkvsc_req->request.data_buffer.len = 8; blkvsc_req->request.data_buffer.len = 8;
break; break;
case DO_FLUSH:
blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
blkvsc_req->cmd_len = 10;
blkvsc_req->request.data_buffer.pfn_array[0] = 0;
blkvsc_req->request.data_buffer.len = 0;
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
...@@ -502,6 +510,9 @@ static int blkvsc_do_operation(struct block_device_context *blkdev, ...@@ -502,6 +510,9 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
(buf[4] << 24) | (buf[5] << 16) | (buf[4] << 24) | (buf[5] << 16) |
(buf[6] << 8) | buf[7]; (buf[6] << 8) | buf[7];
break; break;
default:
break;
} }
cleanup: cleanup:
...@@ -515,41 +526,6 @@ static int blkvsc_do_operation(struct block_device_context *blkdev, ...@@ -515,41 +526,6 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
return ret; return ret;
} }
static int blkvsc_do_flush(struct block_device_context *blkdev)
{
struct blkvsc_request *blkvsc_req;
DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_flush()\n");
if (blkdev->device_type != HARDDISK_TYPE)
return 0;
blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
if (!blkvsc_req)
return -ENOMEM;
memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
init_completion(&blkvsc_req->request.wait_event);
blkvsc_req->dev = blkdev;
blkvsc_req->req = NULL;
blkvsc_req->write = 0;
blkvsc_req->request.data_buffer.pfn_array[0] = 0;
blkvsc_req->request.data_buffer.offset = 0;
blkvsc_req->request.data_buffer.len = 0;
blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
blkvsc_req->cmd_len = 10;
blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
return 0;
}
static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
{ {
...@@ -676,7 +652,7 @@ static int blkvsc_remove(struct device *device) ...@@ -676,7 +652,7 @@ static int blkvsc_remove(struct device *device)
udelay(100); udelay(100);
} }
blkvsc_do_flush(blkdev); blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock_irqsave(&blkdev->lock, flags); spin_lock_irqsave(&blkdev->lock, flags);
...@@ -720,7 +696,7 @@ static void blkvsc_shutdown(struct device *device) ...@@ -720,7 +696,7 @@ static void blkvsc_shutdown(struct device *device)
udelay(100); udelay(100);
} }
blkvsc_do_flush(blkdev); blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock_irqsave(&blkdev->lock, flags); spin_lock_irqsave(&blkdev->lock, flags);
...@@ -740,7 +716,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) ...@@ -740,7 +716,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
spin_lock(&blkdev->lock); spin_lock(&blkdev->lock);
if (blkdev->users == 1) { if (blkdev->users == 1) {
spin_unlock(&blkdev->lock); spin_unlock(&blkdev->lock);
blkvsc_do_flush(blkdev); blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock(&blkdev->lock); spin_lock(&blkdev->lock);
} }
......
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