K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[RESEND PATCH 00/22] Staging: hv: Cleanup-storage-drivers-phase-II
This patch-set restructures and cleans up struct hv_storvsc_request. In the current code, two data structures: struct hv_storvsc_request and struct storvsc_request_extension together are used to carry the I/O state and there are many issues with this current architecture: 1) The memory for extension data structure is allocatted just after the data buffer field in struct hv_storvsc_request resulting in comments such as this in struct blkvsc_request (blkvsc_drv.c): /* * !!!DO NOT ADD ANYTHING BELOW HERE!!! Otherwise, memory can overlap, * because - The extension buffer falls right here and is pointed to by * request.Extension; * Which sounds like a horrible idea, who designed this? */ 2) State is unnecessarily replicated in both struct hv_storvsc_request and the struct vstor_packet that is embedded in struct storvsc_request_extension. This patch-set addresses the above issues by geting rid of replicated state and consolidating all necessary state into a single data structure. We also deal with a range of other cleanups in this patch-set: 1) Use completion primitives to wait for completion. 2) Get rid of the synch primitive in struct blkvsc_request 3) Get rid of the need for struct hv_device to be the first element of struct host_device_context. Regards, K. Y
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 01/22] Staging: hv: Move the definition of struct storvsc_request_extension
In preperation for embedding struct storvsc_request_extension into struct hv_storvsc_request, move the definition of struct storvsc_request_extension. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/storvsc_api.h | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 5f41ef6..800ebbf 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -53,6 +53,18 @@ enum storvsc_request_type{ UNKNOWN_TYPE, }; + +struct storvsc_request_extension { + struct hv_storvsc_request *request; + struct hv_device *device; + + /* Synchronize the request/response if needed */ + int wait_condition; + wait_queue_head_t wait_event; + + struct vstor_packet vstor_packet; +}; + struct hv_storvsc_request { enum storvsc_request_type type; u32 host; @@ -103,17 +115,6 @@ struct storvsc_device_info { unsigned char target_id; }; -struct storvsc_request_extension { - struct hv_storvsc_request *request; - struct hv_device *device; - - /* Synchronize the request/response if needed */ - int wait_condition; - wait_queue_head_t wait_event; - - struct vstor_packet vstor_packet; -}; - /* A storvsc device is a device object that contains a vmbus channel */ struct storvsc_device { struct hv_device *device; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 02/22] Staging: hv: Embed struct storvsc_request_extension into hv_storvsc_request
Embed struct storvsc_request_extension into hv_storvsc_request. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 8 -------- drivers/staging/hv/storvsc.c | 3 +-- drivers/staging/hv/storvsc_api.h | 3 +-- drivers/staging/hv/storvsc_drv.c | 6 ------ 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 824080d..9ceaa99 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -84,12 +84,6 @@ struct blkvsc_request { unsigned char cmnd[MAX_COMMAND_SIZE]; struct hv_storvsc_request request; - /* - * !!!DO NOT ADD ANYTHING BELOW HERE!!! Otherwise, memory can overlap, - * because - The extension buffer falls right here and is pointed to by - * request.Extension; - * Which sounds like a horrible idea, who designed this? - */ }; /* Per device structure */ @@ -942,8 +936,6 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, #endif storvsc_req = &blkvsc_req->request; - storvsc_req->extension = (void *)((unsigned long)blkvsc_req + - sizeof(struct blkvsc_request)); storvsc_req->type = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 6801e37..5cea331 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -533,8 +533,7 @@ int stor_vsc_on_io_request(struct hv_device *device, struct vstor_packet *vstor_packet; int ret = 0; - request_extension - (struct storvsc_request_extension *)request->extension; + request_extension = &request->extension; vstor_packet = &request_extension->vstor_packet; stor_device = get_stor_device(device); diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 800ebbf..e41b68b 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -83,8 +83,7 @@ struct hv_storvsc_request { void (*on_io_completion)(struct hv_storvsc_request *request); - /* This points to the memory after DataBuffer */ - void *extension; + struct storvsc_request_extension extension; struct hv_multipage_buffer data_buffer; }; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 127d122..58d12e0 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -69,10 +69,6 @@ struct storvsc_cmd_request { struct scatterlist *bounce_sgl; struct hv_storvsc_request request; - /* !!!DO NOT ADD ANYTHING BELOW HERE!!! */ - /* The extension buffer falls right here and is pointed to by - * request.Extension; - * Which sounds like a very bad design... */ }; @@ -763,8 +759,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, request = &cmd_request->request; - request->extension - (void *)((unsigned long)cmd_request + request_size); DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size, storvsc_drv_obj->request_ext_size); -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 03/22] Staging: hv: Get rid of request_ext_size from struct storvsc_driver_object
Now that struct storvsc_request_extension is part of struct hv_storvsc_request get rid of the field request_ext_size from struct storvsc_driver_object. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 5 +---- drivers/staging/hv/storvsc_api.h | 3 --- drivers/staging/hv/storvsc_drv.c | 11 +++-------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 9ceaa99..3672e15 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -162,8 +162,6 @@ static int blk_vsc_initialize(struct hv_driver *driver) driver->name = g_blk_driver_name; memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid)); - stor_driver->request_ext_size - sizeof(struct storvsc_request_extension); /* * Divide the ring buffer data size (which is 1 page less than the ring @@ -346,8 +344,7 @@ static int blkvsc_probe(struct device *device) /* sizeof(struct blkvsc_request)); */ blkdev->request_pool = kmem_cache_create(dev_name(&device_obj->device), - sizeof(struct blkvsc_request) + - storvsc_drv_obj->request_ext_size, 0, + sizeof(struct blkvsc_request), 0, SLAB_HWCACHE_ALIGN, NULL); if (!blkdev->request_pool) { ret = -ENOMEM; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index e41b68b..eeaeaef 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -97,9 +97,6 @@ struct storvsc_driver_object { /* Set by caller (in bytes) */ u32 ring_buffer_size; - /* Allocate this much private extension for each I/O request */ - u32 request_ext_size; - /* Maximum # of requests in flight per channel/device */ u32 max_outstanding_req_per_channel; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 58d12e0..1d13f1b 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -96,8 +96,6 @@ static int stor_vsc_initialize(struct hv_driver *driver) memcpy(&driver->dev_type, &gStorVscDeviceType, sizeof(struct hv_guid)); - stor_driver->request_ext_size - sizeof(struct storvsc_request_extension); /* * Divide the ring buffer data size (which is 1 page less @@ -203,8 +201,7 @@ static int storvsc_drv_init(void) drv->priv = storvsc_drv_obj; DPRINT_INFO(STORVSC_DRV, - "request extension size %u, max outstanding reqs %u", - storvsc_drv_obj->request_ext_size, + "max outstanding reqs %u", storvsc_drv_obj->max_outstanding_req_per_channel); if (storvsc_drv_obj->max_outstanding_req_per_channel < @@ -359,8 +356,7 @@ static int storvsc_probe(struct device *device) host_device_ctx->request_pool kmem_cache_create(dev_name(&device_obj->device), - sizeof(struct storvsc_cmd_request) + - storvsc_drv_obj->request_ext_size, 0, + sizeof(struct storvsc_cmd_request), 0, SLAB_HWCACHE_ALIGN, NULL); if (!host_device_ctx->request_pool) { @@ -759,8 +755,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, request = &cmd_request->request; - DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size, - storvsc_drv_obj->request_ext_size); + DPRINT_DBG(STORVSC_DRV, "req %p size %d", request, request_size); /* Build the SRB */ switch (scmnd->sc_data_direction) { -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 04/22] Staging: hv: Add a function to map a hv_driver pointer to storvsc driver
Get rid of the need for struct hv_device to be the first element of struct host_device_context. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc_api.h | 8 ++++++-- drivers/staging/hv/storvsc_drv.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 3672e15..1e5320e 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -154,7 +154,7 @@ static int blk_vsc_initialize(struct hv_driver *driver) struct storvsc_driver_object *stor_driver; int ret = 0; - stor_driver = (struct storvsc_driver_object *)driver; + stor_driver = hvdr_to_stordr(driver); /* Make sure we are at least 2 pages since 1 page is used for control */ /* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */ diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index eeaeaef..5c80cdb 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -25,6 +25,7 @@ #ifndef _STORVSC_API_H_ #define _STORVSC_API_H_ +#include <linux/kernel.h> #include "vstorage.h" #include "vmbus_api.h" @@ -90,8 +91,6 @@ struct hv_storvsc_request { /* Represents the block vsc driver */ struct storvsc_driver_object { - /* Must be the first field */ - /* Which is a bug FIXME! */ struct hv_driver base; /* Set by caller (in bytes) */ @@ -159,6 +158,11 @@ static inline void put_stor_device(struct hv_device *device) atomic_dec(&stor_device->ref_count); } +static inline struct storvsc_driver_object *hvdr_to_stordr(struct hv_driver *d) +{ + return container_of(d, struct storvsc_driver_object, base); +} + /* Interface */ int stor_vsc_on_device_add(struct hv_device *device, diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 1d13f1b..268c607 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -79,7 +79,7 @@ static int stor_vsc_initialize(struct hv_driver *driver) { struct storvsc_driver_object *stor_driver; - stor_driver = (struct storvsc_driver_object *)driver; + stor_driver = hvdr_to_stordr(driver); DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd " "sizeof(struct storvsc_request_extension)=%zd " -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 05/22] Staging: hv: Use struct completion in struct storvsc_request_extension
Get rid of the wait_queue mechanism for synchronization in struct storvsc_request_extension and instead use completion mechanism. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/storvsc.c | 34 ++++++++++++---------------------- drivers/staging/hv/storvsc_api.h | 3 +-- drivers/staging/hv/storvsc_drv.c | 10 ++++------ 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 5cea331..8dc17b9 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -20,7 +20,7 @@ */ #include <linux/kernel.h> #include <linux/sched.h> -#include <linux/wait.h> +#include <linux/completion.h> #include <linux/string.h> #include <linux/slab.h> #include <linux/mm.h> @@ -107,7 +107,7 @@ static int stor_vsc_channel_init(struct hv_device *device) struct storvsc_device *stor_device; struct storvsc_request_extension *request; struct vstor_packet *vstor_packet; - int ret; + int ret, t; stor_device = get_stor_device(device); if (!stor_device) { @@ -124,13 +124,12 @@ static int stor_vsc_channel_init(struct hv_device *device) * channel */ memset(request, 0, sizeof(struct storvsc_request_extension)); - init_waitqueue_head(&request->wait_event); + init_completion(&request->wait_event); vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION..."); - request->wait_condition = 0; ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request, @@ -142,14 +141,12 @@ static int stor_vsc_channel_init(struct hv_device *device) goto cleanup; } - wait_event_timeout(request->wait_event, request->wait_condition, - msecs_to_jiffies(1000)); - if (request->wait_condition == 0) { + t = wait_for_completion_timeout(&request->wait_event, HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } - if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || vstor_packet->status != 0) { DPRINT_ERR(STORVSC, "BEGIN_INITIALIZATION_OPERATION failed " @@ -168,7 +165,6 @@ static int stor_vsc_channel_init(struct hv_device *device) vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT; FILL_VMSTOR_REVISION(vstor_packet->version.revision); - request->wait_condition = 0; ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request, @@ -180,9 +176,8 @@ static int stor_vsc_channel_init(struct hv_device *device) goto cleanup; } - wait_event_timeout(request->wait_event, request->wait_condition, - msecs_to_jiffies(1000)); - if (request->wait_condition == 0) { + t = wait_for_completion_timeout(&request->wait_event, HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } @@ -205,7 +200,6 @@ static int stor_vsc_channel_init(struct hv_device *device) vstor_packet->storage_channel_properties.port_number stor_device->port_number; - request->wait_condition = 0; ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request, @@ -218,9 +212,8 @@ static int stor_vsc_channel_init(struct hv_device *device) goto cleanup; } - wait_event_timeout(request->wait_event, request->wait_condition, - msecs_to_jiffies(1000)); - if (request->wait_condition == 0) { + t = wait_for_completion_timeout(&request->wait_event, HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } @@ -248,7 +241,6 @@ static int stor_vsc_channel_init(struct hv_device *device) vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - request->wait_condition = 0; ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request, @@ -261,9 +253,8 @@ static int stor_vsc_channel_init(struct hv_device *device) goto cleanup; } - wait_event_timeout(request->wait_event, request->wait_condition, - msecs_to_jiffies(1000)); - if (request->wait_condition == 0) { + t = wait_for_completion_timeout(&request->wait_event, HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } @@ -397,8 +388,7 @@ static void stor_vsc_on_channel_callback(void *context) memcpy(&request->vstor_packet, packet, sizeof(struct vstor_packet)); - request->wait_condition = 1; - wake_up(&request->wait_event); + complete(&request->wait_event); } else { stor_vsc_on_receive(device, (struct vstor_packet *)packet, diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 5c80cdb..cdef1c7 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -60,8 +60,7 @@ struct storvsc_request_extension { struct hv_device *device; /* Synchronize the request/response if needed */ - int wait_condition; - wait_queue_head_t wait_event; + struct completion wait_event; struct vstor_packet vstor_packet; }; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 268c607..c2a3a5b 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -231,7 +231,7 @@ static int stor_vsc_on_host_reset(struct hv_device *device) struct storvsc_device *stor_device; struct storvsc_request_extension *request; struct vstor_packet *vstor_packet; - int ret; + int ret, t; DPRINT_INFO(STORVSC, "resetting host adapter..."); @@ -245,13 +245,12 @@ static int stor_vsc_on_host_reset(struct hv_device *device) request = &stor_device->reset_request; vstor_packet = &request->vstor_packet; - init_waitqueue_head(&request->wait_event); + init_completion(&request->wait_event); vstor_packet->operation = VSTOR_OPERATION_RESET_BUS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; vstor_packet->vm_srb.path_id = stor_device->path_id; - request->wait_condition = 0; ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), (unsigned long)&stor_device->reset_request, @@ -263,9 +262,8 @@ static int stor_vsc_on_host_reset(struct hv_device *device) goto cleanup; } - wait_event_timeout(request->wait_event, request->wait_condition, - msecs_to_jiffies(1000)); - if (request->wait_condition == 0) { + t = wait_for_completion_timeout(&request->wait_event, HZ); + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 06/22] Staging: hv: Allocate request structures zeroed out.
In preparation for moving state out of struct hv_storvsc_request, allocate request structures so that they zeroed out to begin with. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 14 ++++++++------ drivers/staging/hv/storvsc.c | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 1e5320e..2661356 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -510,7 +510,7 @@ static int blkvsc_do_flush(struct block_device_context *blkdev) if (blkdev->device_type != HARDDISK_TYPE) return 0; - blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL); + blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL); if (!blkvsc_req) return -ENOMEM; @@ -551,7 +551,7 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_inquiry()\n"); - blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL); + blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL); if (!blkvsc_req) return -ENOMEM; @@ -638,7 +638,7 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) blkdev->capacity = 0; blkdev->media_not_present = 0; /* assume a disk is present */ - blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL); + blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL); if (!blkvsc_req) return -ENOMEM; @@ -715,7 +715,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) blkdev->capacity = 0; blkdev->media_not_present = 0; /* assume a disk is present */ - blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL); + blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL); if (!blkvsc_req) return -ENOMEM; @@ -983,7 +983,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev, (unsigned long)blk_rq_pos(req)); /* Create a group to tie req to list of blkvsc_reqs */ - group = kmem_cache_alloc(blkdev->request_pool, GFP_ATOMIC); + group = kmem_cache_zalloc(blkdev->request_pool, GFP_ATOMIC); if (!group) return -ENOMEM; @@ -1026,7 +1026,9 @@ static int blkvsc_do_request(struct block_device_context *blkdev, * Create new blkvsc_req to represent * the current bvec */ - blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_ATOMIC); + blkvsc_req + kmem_cache_zalloc( + blkdev->request_pool, GFP_ATOMIC); if (!blkvsc_req) { /* free up everything */ list_for_each_entry_safe( diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 8dc17b9..e02622d 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -545,7 +545,6 @@ int stor_vsc_on_io_request(struct hv_device *device, request_extension->request = request; request_extension->device = device; - memset(vstor_packet, 0 , sizeof(struct vstor_packet)); vstor_packet->flags |= REQUEST_COMPLETION_FLAG; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index c2a3a5b..fd1416d 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -735,7 +735,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, request_size = sizeof(struct storvsc_cmd_request); - cmd_request = kmem_cache_alloc(host_device_ctx->request_pool, + cmd_request = kmem_cache_zalloc(host_device_ctx->request_pool, GFP_ATOMIC); if (!cmd_request) { DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate " -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 07/22] Staging: hv: Get rid of the type field from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the type field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - data_in field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 4 +++- drivers/staging/hv/storvsc.c | 1 - drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 2661356..00bc226 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -913,6 +913,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, struct storvsc_driver_object *storvsc_drv_obj drv->priv; struct hv_storvsc_request *storvsc_req; + struct vmscsi_request *vm_srb; int ret; DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - " @@ -933,8 +934,9 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, #endif storvsc_req = &blkvsc_req->request; + vm_srb = &storvsc_req->extension.vstor_packet.vm_srb; - storvsc_req->type = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; + vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; storvsc_req->on_io_completion = request_completion; storvsc_req->context = blkvsc_req; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index e02622d..c1faf46 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -561,7 +561,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.cdb_length = request->cdb_len; memcpy(&vstor_packet->vm_srb.cdb, request->cdb, request->cdb_len); - vstor_packet->vm_srb.data_in = request->type; vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len; vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index cdef1c7..27781f4 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - enum storvsc_request_type type; u32 host; u32 bus; u32 target_id; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index fd1416d..9df723c 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -709,6 +709,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, int i; struct scatterlist *sgl; unsigned int sg_count = 0; + struct vmscsi_request *vm_srb; DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d " "queue depth %d tagged %d", scmnd, scmnd->sc_data_direction, @@ -752,19 +753,20 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, scmnd->host_scribble = (unsigned char *)cmd_request; request = &cmd_request->request; + vm_srb = &request->extension.vstor_packet.vm_srb; DPRINT_DBG(STORVSC_DRV, "req %p size %d", request, request_size); /* Build the SRB */ switch (scmnd->sc_data_direction) { case DMA_TO_DEVICE: - request->type = WRITE_TYPE; + vm_srb->data_in = WRITE_TYPE; break; case DMA_FROM_DEVICE: - request->type = READ_TYPE; + vm_srb->data_in = READ_TYPE; break; default: - request->type = UNKNOWN_TYPE; + vm_srb->data_in = UNKNOWN_TYPE; break; } -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 08/22] Staging: hv: Get rid of the host field from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the host field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - port_number field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 1 - drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 00bc226..eb184ff 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -941,7 +941,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, storvsc_req->on_io_completion = request_completion; storvsc_req->context = blkvsc_req; - storvsc_req->host = blkdev->port; + vm_srb->port_number = blkdev->port; storvsc_req->bus = blkdev->path; storvsc_req->target_id = blkdev->target; storvsc_req->lun_id = 0; /* this is not really used at all */ diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index c1faf46..21ca3db 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -550,7 +550,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); - vstor_packet->vm_srb.port_number = request->host; vstor_packet->vm_srb.path_id = request->bus; vstor_packet->vm_srb.target_id = request->target_id; vstor_packet->vm_srb.lun = request->lun_id; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 27781f4..f9dc4f1 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 host; u32 bus; u32 target_id; u32 lun_id; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 9df723c..e772822 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -774,7 +774,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, request->context = cmd_request;/* scmnd; */ /* request->PortId = scmnd->device->channel; */ - request->host = host_device_ctx->port; + vm_srb->port_number = host_device_ctx->port; request->bus = scmnd->device->channel; request->target_id = scmnd->device->id; request->lun_id = scmnd->device->lun; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 09/22] Staging: hv: Get rid of the bus field from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the bus field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - path_id field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 5 ++--- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index eb184ff..a679e18 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -942,7 +942,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, storvsc_req->context = blkvsc_req; vm_srb->port_number = blkdev->port; - storvsc_req->bus = blkdev->path; + vm_srb->path_id = blkdev->path; storvsc_req->target_id = blkdev->target; storvsc_req->lun_id = 0; /* this is not really used at all */ diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 21ca3db..4d202f6 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -531,8 +531,8 @@ int stor_vsc_on_io_request(struct hv_device *device, "Extension %p", device, stor_device, request, request_extension); - DPRINT_DBG(STORVSC, "req %p len %d bus %d, target %d, lun %d cdblen %d", - request, request->data_buffer.len, request->bus, + DPRINT_DBG(STORVSC, "req %p len %d target %d, lun %d cdblen %d", + request, request->data_buffer.len, request->target_id, request->lun_id, request->cdb_len); if (!stor_device) { @@ -550,7 +550,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); - vstor_packet->vm_srb.path_id = request->bus; vstor_packet->vm_srb.target_id = request->target_id; vstor_packet->vm_srb.lun = request->lun_id; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index f9dc4f1..07a391b 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 bus; u32 target_id; u32 lun_id; u8 *cdb; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e772822..faadc8c 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -775,7 +775,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, /* request->PortId = scmnd->device->channel; */ vm_srb->port_number = host_device_ctx->port; - request->bus = scmnd->device->channel; + vm_srb->path_id = scmnd->device->channel; request->target_id = scmnd->device->id; request->lun_id = scmnd->device->lun; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 10/22] Staging: hv: Get rid of the target_id from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the target_id field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - target_id field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 5 ++--- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index a679e18..ec01662 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -943,7 +943,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->port_number = blkdev->port; vm_srb->path_id = blkdev->path; - storvsc_req->target_id = blkdev->target; + vm_srb->target_id = blkdev->target; storvsc_req->lun_id = 0; /* this is not really used at all */ storvsc_req->cdb_len = blkvsc_req->cmd_len; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 4d202f6..6083cdb 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -531,9 +531,9 @@ int stor_vsc_on_io_request(struct hv_device *device, "Extension %p", device, stor_device, request, request_extension); - DPRINT_DBG(STORVSC, "req %p len %d target %d, lun %d cdblen %d", + DPRINT_DBG(STORVSC, "req %p len %d lun %d cdblen %d", request, request->data_buffer.len, - request->target_id, request->lun_id, request->cdb_len); + request->lun_id, request->cdb_len); if (!stor_device) { DPRINT_ERR(STORVSC, "unable to get stor device..." @@ -550,7 +550,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); - vstor_packet->vm_srb.target_id = request->target_id; vstor_packet->vm_srb.lun = request->lun_id; vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 07a391b..54690ad 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 target_id; u32 lun_id; u8 *cdb; u32 cdb_len; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index faadc8c..aa8496c 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -776,7 +776,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, /* request->PortId = scmnd->device->channel; */ vm_srb->port_number = host_device_ctx->port; vm_srb->path_id = scmnd->device->channel; - request->target_id = scmnd->device->id; + vm_srb->target_id = scmnd->device->id; request->lun_id = scmnd->device->lun; /* ASSERT(scmnd->cmd_len <= 16); */ -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 11/22] Staging: hv: Get rid of lun_id from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the lun_id field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - lun field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 5 ++--- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index ec01662..f440734 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -944,7 +944,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->port_number = blkdev->port; vm_srb->path_id = blkdev->path; vm_srb->target_id = blkdev->target; - storvsc_req->lun_id = 0; /* this is not really used at all */ + vm_srb->lun = 0; /* this is not really used at all */ storvsc_req->cdb_len = blkvsc_req->cmd_len; storvsc_req->cdb = blkvsc_req->cmnd; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 6083cdb..c7d0620 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -531,9 +531,9 @@ int stor_vsc_on_io_request(struct hv_device *device, "Extension %p", device, stor_device, request, request_extension); - DPRINT_DBG(STORVSC, "req %p len %d lun %d cdblen %d", + DPRINT_DBG(STORVSC, "req %p len %d cdblen %d", request, request->data_buffer.len, - request->lun_id, request->cdb_len); + request->cdb_len); if (!stor_device) { DPRINT_ERR(STORVSC, "unable to get stor device..." @@ -550,7 +550,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.length = sizeof(struct vmscsi_request); - vstor_packet->vm_srb.lun = request->lun_id; vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 54690ad..940cf98 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 lun_id; u8 *cdb; u32 cdb_len; u32 status; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index aa8496c..1340b13 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -777,7 +777,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, vm_srb->port_number = host_device_ctx->port; vm_srb->path_id = scmnd->device->channel; vm_srb->target_id = scmnd->device->id; - request->lun_id = scmnd->device->lun; + vm_srb->lun = scmnd->device->lun; /* ASSERT(scmnd->cmd_len <= 16); */ request->cdb_len = scmnd->cmd_len; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 12/22] Staging: hv: Get rid of the cdb_len from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the cdb_len field from struct hv_storvsc_request and instead use the equivalent state in struct vmscsi_request - cdb_length field. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 9 ++++----- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index f440734..3db622d 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -946,7 +946,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->target_id = blkdev->target; vm_srb->lun = 0; /* this is not really used at all */ - storvsc_req->cdb_len = blkvsc_req->cmd_len; + vm_srb->cdb_length = blkvsc_req->cmd_len; storvsc_req->cdb = blkvsc_req->cmnd; storvsc_req->sense_buffer = blkvsc_req->sense_buffer; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index c7d0620..dcfc5c5 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -531,9 +531,8 @@ int stor_vsc_on_io_request(struct hv_device *device, "Extension %p", device, stor_device, request, request_extension); - DPRINT_DBG(STORVSC, "req %p len %d cdblen %d", - request, request->data_buffer.len, - request->cdb_len); + DPRINT_DBG(STORVSC, "req %p len %d", + request, request->data_buffer.len); if (!stor_device) { DPRINT_ERR(STORVSC, "unable to get stor device..." @@ -554,8 +553,8 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; /* Copy over the scsi command descriptor block */ - vstor_packet->vm_srb.cdb_length = request->cdb_len; - memcpy(&vstor_packet->vm_srb.cdb, request->cdb, request->cdb_len); + memcpy(&vstor_packet->vm_srb.cdb, request->cdb, + vstor_packet->vm_srb.cdb_length); vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 940cf98..fd3af2b 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -67,7 +67,6 @@ struct storvsc_request_extension { struct hv_storvsc_request { u8 *cdb; - u32 cdb_len; u32 status; u32 bytes_xfer; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 1340b13..5571fd7 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -780,7 +780,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, vm_srb->lun = scmnd->device->lun; /* ASSERT(scmnd->cmd_len <= 16); */ - request->cdb_len = scmnd->cmd_len; + vm_srb->cdb_length = scmnd->cmd_len; request->cdb = scmnd->cmnd; request->sense_buffer = scmnd->sense_buffer; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 13/22] Staging: hv: Get rid of cdb from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the cdb field from struct hv_storvsc_request and instead directly copy the command into struct vmscsi_request. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 3 ++- drivers/staging/hv/storvsc.c | 6 ++---- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 3db622d..a156930 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -947,7 +947,8 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->lun = 0; /* this is not really used at all */ vm_srb->cdb_length = blkvsc_req->cmd_len; - storvsc_req->cdb = blkvsc_req->cmnd; + + memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length); storvsc_req->sense_buffer = blkvsc_req->sense_buffer; storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index dcfc5c5..c551595 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -301,7 +301,8 @@ static void stor_vsc_on_io_completion(struct hv_device *device, if (request->status != 0 || vstor_packet->vm_srb.srb_status != 1) { DPRINT_WARN(STORVSC, "cmd 0x%x scsi status 0x%x srb status 0x%x\n", - request->cdb[0], vstor_packet->vm_srb.scsi_status, + vstor_packet->vm_srb.cdb[0], + vstor_packet->vm_srb.scsi_status, vstor_packet->vm_srb.srb_status); } @@ -552,9 +553,6 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; - /* Copy over the scsi command descriptor block */ - memcpy(&vstor_packet->vm_srb.cdb, request->cdb, - vstor_packet->vm_srb.cdb_length); vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index fd3af2b..55c5cc6 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -66,7 +66,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u8 *cdb; u32 status; u32 bytes_xfer; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 5571fd7..6bf999d 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -781,7 +781,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, /* ASSERT(scmnd->cmd_len <= 16); */ vm_srb->cdb_length = scmnd->cmd_len; - request->cdb = scmnd->cmnd; + + memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); request->sense_buffer = scmnd->sense_buffer; request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:04 UTC
[PATCH 14/22] Staging: hv: Get rid of sense_buffer_size from struct hv_storvsc_request
In preparation for consolidating all I/O request state, get rid of the sense_buffer_size field from struct hv_storvsc_request and instead hardcode this value as is currently done. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 1 - drivers/staging/hv/storvsc.c | 2 -- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 3 +-- 4 files changed, 1 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index a156930..04117be 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -951,7 +951,6 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length); storvsc_req->sense_buffer = blkvsc_req->sense_buffer; - storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE; ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx, &blkvsc_req->request); diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index c551595..e12a760 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -318,8 +318,6 @@ static void stor_vsc_on_io_completion(struct hv_device *device, vstor_packet->vm_srb.sense_data, vstor_packet->vm_srb.sense_info_length); - request->sense_buffer_size - vstor_packet->vm_srb.sense_info_length; } } diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 55c5cc6..3eccc27 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -70,7 +70,6 @@ struct hv_storvsc_request { u32 bytes_xfer; unsigned char *sense_buffer; - u32 sense_buffer_size; void *context; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 6bf999d..22709a2 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -477,7 +477,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) if (scmnd->result) { if (scsi_normalize_sense(scmnd->sense_buffer, - request->sense_buffer_size, &sense_hdr)) + SCSI_SENSE_BUFFERSIZE, &sense_hdr)) scsi_print_sense_hdr("storvsc", &sense_hdr); } @@ -785,7 +785,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); request->sense_buffer = scmnd->sense_buffer; - request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE; request->data_buffer.len = scsi_bufflen(scmnd); -- 1.7.4.1
In preparation for consolidating all I/O request state, move sense_buffer field from struct hv_storvsc_request to struct storvsc_request_extension. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 2 +- drivers/staging/hv/storvsc_api.h | 4 ++-- drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 04117be..be7fae5 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -950,7 +950,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length); - storvsc_req->sense_buffer = blkvsc_req->sense_buffer; + storvsc_req->extension.sense_buffer = blkvsc_req->sense_buffer; ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx, &blkvsc_req->request); diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index e12a760..e0d635f 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -314,7 +314,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device, "valid - len %d\n", request_ext, vstor_packet->vm_srb.sense_info_length); - memcpy(request->sense_buffer, + memcpy(request->extension.sense_buffer, vstor_packet->vm_srb.sense_data, vstor_packet->vm_srb.sense_info_length); diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 3eccc27..fd9165f 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -62,6 +62,8 @@ struct storvsc_request_extension { /* Synchronize the request/response if needed */ struct completion wait_event; + unsigned char *sense_buffer; + struct vstor_packet vstor_packet; }; @@ -69,8 +71,6 @@ struct hv_storvsc_request { u32 status; u32 bytes_xfer; - unsigned char *sense_buffer; - void *context; void (*on_io_completion)(struct hv_storvsc_request *request); diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 22709a2..df98476 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -784,7 +784,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); - request->sense_buffer = scmnd->sense_buffer; + request->extension.sense_buffer = scmnd->sense_buffer; request->data_buffer.len = scsi_bufflen(scmnd); -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 16/22] Staging: hv: Move the context field from struct hv_storvsc_request
In preparation of consolidating all I/O request state, move the context field from struct hv_storvsc_request to struct storvsc_request_extension. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 6 +++--- drivers/staging/hv/storvsc_api.h | 3 +-- drivers/staging/hv/storvsc_drv.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index be7fae5..83c4ba3 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -939,7 +939,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; storvsc_req->on_io_completion = request_completion; - storvsc_req->context = blkvsc_req; + storvsc_req->extension.context = blkvsc_req; vm_srb->port_number = blkdev->port; vm_srb->path_id = blkdev->path; @@ -1136,7 +1136,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev, static void blkvsc_cmd_completion(struct hv_storvsc_request *request) { struct blkvsc_request *blkvsc_req - (struct blkvsc_request *)request->context; + (struct blkvsc_request *)request->extension.context; struct block_device_context *blkdev (struct block_device_context *)blkvsc_req->dev; struct scsi_sense_hdr sense_hdr; @@ -1158,7 +1158,7 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request) static void blkvsc_request_completion(struct hv_storvsc_request *request) { struct blkvsc_request *blkvsc_req - (struct blkvsc_request *)request->context; + (struct blkvsc_request *)request->extension.context; struct block_device_context *blkdev (struct block_device_context *)blkvsc_req->dev; unsigned long flags; diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index fd9165f..68c5036 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -63,6 +63,7 @@ struct storvsc_request_extension { struct completion wait_event; unsigned char *sense_buffer; + void *context; struct vstor_packet vstor_packet; }; @@ -71,8 +72,6 @@ struct hv_storvsc_request { u32 status; u32 bytes_xfer; - void *context; - void (*on_io_completion)(struct hv_storvsc_request *request); struct storvsc_request_extension extension; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index df98476..e0e349e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -448,7 +448,7 @@ static int storvsc_remove(struct device *device) static void storvsc_commmand_completion(struct hv_storvsc_request *request) { struct storvsc_cmd_request *cmd_request - (struct storvsc_cmd_request *)request->context; + (struct storvsc_cmd_request *)request->extension.context; struct scsi_cmnd *scmnd = cmd_request->cmd; struct host_device_context *host_device_ctx (struct host_device_context *)scmnd->device->host->hostdata; @@ -771,7 +771,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, } request->on_io_completion = storvsc_commmand_completion; - request->context = cmd_request;/* scmnd; */ + request->extension.context = cmd_request;/* scmnd; */ /* request->PortId = scmnd->device->channel; */ vm_srb->port_number = host_device_ctx->port; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 17/22] Staging: hv: Move on_io_completion() from struct hv_storvsc_request
In preparation of consolidating all I/O request state, move the on_io_completion() field from struct hv_storvsc_request to struct storvsc_request_extension. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 2 +- drivers/staging/hv/storvsc.c | 2 +- drivers/staging/hv/storvsc_api.h | 2 +- drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 83c4ba3..0e3b193 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -938,7 +938,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; - storvsc_req->on_io_completion = request_completion; + storvsc_req->extension.on_io_completion = request_completion; storvsc_req->extension.context = blkvsc_req; vm_srb->port_number = blkdev->port; diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index e0d635f..8649044 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -324,7 +324,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device, /* TODO: */ request->bytes_xfer = vstor_packet->vm_srb.data_transfer_length; - request->on_io_completion(request); + request->extension.on_io_completion(request); atomic_dec(&stor_device->num_outstanding_req); diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 68c5036..89fa155 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -64,6 +64,7 @@ struct storvsc_request_extension { unsigned char *sense_buffer; void *context; + void (*on_io_completion)(struct hv_storvsc_request *request); struct vstor_packet vstor_packet; }; @@ -72,7 +73,6 @@ struct hv_storvsc_request { u32 status; u32 bytes_xfer; - void (*on_io_completion)(struct hv_storvsc_request *request); struct storvsc_request_extension extension; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e0e349e..25b25b3 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -770,7 +770,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, break; } - request->on_io_completion = storvsc_commmand_completion; + request->extension.on_io_completion = storvsc_commmand_completion; request->extension.context = cmd_request;/* scmnd; */ /* request->PortId = scmnd->device->channel; */ -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 18/22] Staging: hv: Get rid of the status field from struct hv_storvsc_request
In preparation of consolidating all I/O request state, get rid of the status field from struct hv_storvsc_request and instead use the state in the struct vmscsi_request directly. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 23 ++++++++++++++++++----- drivers/staging/hv/storvsc.c | 14 ++++++++++---- drivers/staging/hv/storvsc_api.h | 2 -- drivers/staging/hv/storvsc_drv.c | 4 +++- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 0e3b193..c05a242 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -631,6 +631,7 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) struct page *page_buf; unsigned char *buf; struct scsi_sense_hdr sense_hdr; + struct vmscsi_request *vm_srb; DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity()\n"); @@ -649,6 +650,7 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) return -ENOMEM; } + vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; init_waitqueue_head(&blkvsc_req->wevent); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; @@ -675,7 +677,7 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); /* check error */ - if (blkvsc_req->request.status) { + if (vm_srb->scsi_status) { scsi_normalize_sense(blkvsc_req->sense_buffer, SCSI_SENSE_BUFFERSIZE, &sense_hdr); @@ -708,6 +710,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) struct page *page_buf; unsigned char *buf; struct scsi_sense_hdr sense_hdr; + struct vmscsi_request *vm_srb; DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity16()\n"); @@ -720,6 +723,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) return -ENOMEM; memset(blkvsc_req, 0, sizeof(struct blkvsc_request)); + vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; page_buf = alloc_page(GFP_KERNEL); if (!page_buf) { kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req); @@ -752,7 +756,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); /* check error */ - if (blkvsc_req->request.status) { + if (vm_srb->scsi_status) { scsi_normalize_sense(blkvsc_req->sense_buffer, SCSI_SENSE_BUFFERSIZE, &sense_hdr); if (sense_hdr.asc == 0x3A) { @@ -1140,13 +1144,15 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request) struct block_device_context *blkdev (struct block_device_context *)blkvsc_req->dev; struct scsi_sense_hdr sense_hdr; + struct vmscsi_request *vm_srb; DPRINT_DBG(BLKVSC_DRV, "blkvsc_cmd_completion() - req %p\n", blkvsc_req); + vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; blkdev->num_outstanding_reqs--; - if (blkvsc_req->request.status) + if (vm_srb->scsi_status) if (scsi_normalize_sense(blkvsc_req->sense_buffer, SCSI_SENSE_BUFFERSIZE, &sense_hdr)) scsi_print_sense_hdr("blkvsc", &sense_hdr); @@ -1163,6 +1169,7 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) (struct block_device_context *)blkvsc_req->dev; unsigned long flags; struct blkvsc_request *comp_req, *tmp; + struct vmscsi_request *vm_srb; /* ASSERT(blkvsc_req->group); */ @@ -1199,8 +1206,10 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) list_del(&comp_req->req_entry); + vm_srb + &comp_req->request.extension.vstor_packet.vm_srb; if (!__blk_end_request(comp_req->req, - (!comp_req->request.status ? 0 : -EIO), + (!vm_srb->scsi_status ? 0 : -EIO), comp_req->sector_count * blkdev->sector_size)) { /* * All the sectors have been xferred ie the @@ -1229,6 +1238,7 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) { struct blkvsc_request *pend_req, *tmp; struct blkvsc_request *comp_req, *tmp2; + struct vmscsi_request *vm_srb; int ret = 0; @@ -1257,8 +1267,11 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) list_del(&comp_req->req_entry); if (comp_req->req) { + vm_srb + &comp_req->request.extension.vstor_packet. + vm_srb; ret = __blk_end_request(comp_req->req, - (!comp_req->request.status ? 0 : -EIO), + (!vm_srb->scsi_status ? 0 : -EIO), comp_req->sector_count * blkdev->sector_size); diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 8649044..cee1fe9 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -280,6 +280,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device, { struct hv_storvsc_request *request; struct storvsc_device *stor_device; + struct vstor_packet *stor_pkt; stor_device = must_get_stor_device(device); if (!stor_device) { @@ -293,20 +294,25 @@ static void stor_vsc_on_io_completion(struct hv_device *device, vstor_packet->vm_srb.data_transfer_length); request = request_ext->request; + stor_pkt = &request_ext->vstor_packet; /* Copy over the status...etc */ - request->status = vstor_packet->vm_srb.scsi_status; + stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; + stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status; + stor_pkt->vm_srb.sense_info_length + vstor_packet->vm_srb.sense_info_length; - if (request->status != 0 || vstor_packet->vm_srb.srb_status != 1) { + if (vstor_packet->vm_srb.scsi_status != 0 || + vstor_packet->vm_srb.srb_status != 1) { DPRINT_WARN(STORVSC, "cmd 0x%x scsi status 0x%x srb status 0x%x\n", - vstor_packet->vm_srb.cdb[0], + stor_pkt->vm_srb.cdb[0], vstor_packet->vm_srb.scsi_status, vstor_packet->vm_srb.srb_status); } - if ((request->status & 0xFF) == 0x02) { + if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { /* CHECK_CONDITION */ if (vstor_packet->vm_srb.srb_status & 0x80) { /* autosense data available */ diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 89fa155..3cfae2d 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -70,10 +70,8 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 status; u32 bytes_xfer; - struct storvsc_request_extension extension; struct hv_multipage_buffer data_buffer; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 25b25b3..05ff110 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -454,6 +454,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) (struct host_device_context *)scmnd->device->host->hostdata; void (*scsi_done_fn)(struct scsi_cmnd *); struct scsi_sense_hdr sense_hdr; + struct vmscsi_request *vm_srb; /* ASSERT(request == &cmd_request->request); */ /* ASSERT(scmnd); */ @@ -473,7 +474,8 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) cmd_request->bounce_sgl_count); } - scmnd->result = request->status; + vm_srb = &request->extension.vstor_packet.vm_srb; + scmnd->result = vm_srb->scsi_status; if (scmnd->result) { if (scsi_normalize_sense(scmnd->sense_buffer, -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 19/22] Staging: hv: Get rid of the bytes_xfer field from struct hv_storvsc_request
In preparation of consolidating all I/O request state, get rid of the bytes_xfer field from struct hv_storvsc_request and instead use the state in the struct vmscsi_request directly. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/storvsc.c | 4 ++-- drivers/staging/hv/storvsc_api.h | 2 -- drivers/staging/hv/storvsc_drv.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index cee1fe9..c71481f 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -327,8 +327,8 @@ static void stor_vsc_on_io_completion(struct hv_device *device, } } - /* TODO: */ - request->bytes_xfer = vstor_packet->vm_srb.data_transfer_length; + stor_pkt->vm_srb.data_transfer_length + vstor_packet->vm_srb.data_transfer_length; request->extension.on_io_completion(request); diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 3cfae2d..738627c 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -70,8 +70,6 @@ struct storvsc_request_extension { }; struct hv_storvsc_request { - u32 bytes_xfer; - struct storvsc_request_extension extension; struct hv_multipage_buffer data_buffer; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 05ff110..fbeec70 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -485,7 +485,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) /* ASSERT(request->BytesXfer <= request->data_buffer.Length); */ scsi_set_resid(scmnd, - request->data_buffer.len - request->bytes_xfer); + request->data_buffer.len - vm_srb->data_transfer_length); scsi_done_fn = scmnd->scsi_done; -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 20/22] Staging: hv: Move the data_buffer field from struct hv_storvsc_request
In preparation of consolidating all I/O request state, move the data_buffer field from struct hv_storvsc_request struct storvsc_request_extension. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 46 ++++++++++++++++++++----------------- drivers/staging/hv/storvsc.c | 10 +++++--- drivers/staging/hv/storvsc_api.h | 2 +- drivers/staging/hv/storvsc_drv.c | 13 +++++----- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index c05a242..782441d 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -520,9 +520,9 @@ static int blkvsc_do_flush(struct block_device_context *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->request.extension.data_buffer.pfn_array[0] = 0; + blkvsc_req->request.extension.data_buffer.offset = 0; + blkvsc_req->request.extension.data_buffer.len = 0; blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE; blkvsc_req->cmd_len = 10; @@ -567,9 +567,10 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf); - blkvsc_req->request.data_buffer.offset = 0; - blkvsc_req->request.data_buffer.len = 64; + blkvsc_req->request.extension.data_buffer.pfn_array[0] + page_to_pfn(page_buf); + blkvsc_req->request.extension.data_buffer.offset = 0; + blkvsc_req->request.extension.data_buffer.len = 64; blkvsc_req->cmnd[0] = INQUIRY; blkvsc_req->cmnd[1] = 0x1; /* Get product data */ @@ -656,9 +657,10 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf); - blkvsc_req->request.data_buffer.offset = 0; - blkvsc_req->request.data_buffer.len = 8; + blkvsc_req->request.extension.data_buffer.pfn_array[0] + page_to_pfn(page_buf); + blkvsc_req->request.extension.data_buffer.offset = 0; + blkvsc_req->request.extension.data_buffer.len = 8; blkvsc_req->cmnd[0] = READ_CAPACITY; blkvsc_req->cmd_len = 16; @@ -735,9 +737,10 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf); - blkvsc_req->request.data_buffer.offset = 0; - blkvsc_req->request.data_buffer.len = 12; + blkvsc_req->request.extension.data_buffer.pfn_array[0] + page_to_pfn(page_buf); + blkvsc_req->request.extension.data_buffer.offset = 0; + blkvsc_req->request.extension.data_buffer.len = 12; blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */ blkvsc_req->cmd_len = 16; @@ -926,8 +929,8 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, (blkvsc_req->write) ? "WRITE" : "READ", (unsigned long) blkvsc_req->sector_start, blkvsc_req->sector_count, - blkvsc_req->request.data_buffer.offset, - blkvsc_req->request.data_buffer.len); + blkvsc_req->request.extension.data_buffer.offset, + blkvsc_req->request.extension.data_buffer.len); #if 0 for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) { DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - " @@ -1054,10 +1057,11 @@ static int blkvsc_do_request(struct block_device_context *blkdev, blkvsc_req->dev = blkdev; blkvsc_req->req = req; - blkvsc_req->request.data_buffer.offset - = bvec->bv_offset; - blkvsc_req->request.data_buffer.len - = 0; + blkvsc_req->request.extension. + data_buffer.offset + = bvec->bv_offset; + blkvsc_req->request.extension. + data_buffer.len = 0; /* Add to the group */ blkvsc_req->group = group; @@ -1071,10 +1075,10 @@ static int blkvsc_do_request(struct block_device_context *blkdev, } /* Add the curr bvec/segment to the curr blkvsc_req */ - blkvsc_req->request.data_buffer. + blkvsc_req->request.extension.data_buffer. pfn_array[databuf_idx] = page_to_pfn(bvec->bv_page); - blkvsc_req->request.data_buffer.len + blkvsc_req->request.extension.data_buffer.len += bvec->bv_len; prev_bvec = bvec; @@ -1180,7 +1184,7 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) (blkvsc_req->write) ? "WRITE" : "READ", (unsigned long)blkvsc_req->sector_start, blkvsc_req->sector_count, - blkvsc_req->request.data_buffer.len, + blkvsc_req->request.extension.data_buffer.len, blkvsc_req->group->outstanding, blkdev->num_outstanding_reqs); diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index c71481f..374de74 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -537,7 +537,7 @@ int stor_vsc_on_io_request(struct hv_device *device, request_extension); DPRINT_DBG(STORVSC, "req %p len %d", - request, request->data_buffer.len); + request, request->extension.data_buffer.len); if (!stor_device) { DPRINT_ERR(STORVSC, "unable to get stor device..." @@ -558,7 +558,8 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE; - vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len; + vstor_packet->vm_srb.data_transfer_length + request->extension.data_buffer.len; vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; @@ -572,9 +573,10 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.sense_info_length, vstor_packet->vm_srb.cdb_length); - if (request_extension->request->data_buffer.len) { + if (request_extension->request->extension.data_buffer.len) { ret = vmbus_sendpacket_multipagebuffer(device->channel, - &request_extension->request->data_buffer, + &request_extension->request->extension. + data_buffer, vstor_packet, sizeof(struct vstor_packet), (unsigned long)request_extension); diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 738627c..0c0bbf6 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -65,6 +65,7 @@ struct storvsc_request_extension { unsigned char *sense_buffer; void *context; void (*on_io_completion)(struct hv_storvsc_request *request); + struct hv_multipage_buffer data_buffer; struct vstor_packet vstor_packet; }; @@ -72,7 +73,6 @@ struct storvsc_request_extension { struct hv_storvsc_request { struct storvsc_request_extension extension; - struct hv_multipage_buffer data_buffer; }; /* Represents the block vsc driver */ diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index fbeec70..e7005d9 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -485,7 +485,8 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) /* ASSERT(request->BytesXfer <= request->data_buffer.Length); */ scsi_set_resid(scmnd, - request->data_buffer.len - vm_srb->data_transfer_length); + request->extension.data_buffer.len - + vm_srb->data_transfer_length); scsi_done_fn = scmnd->scsi_done; @@ -789,7 +790,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, request->extension.sense_buffer = scmnd->sense_buffer; - request->data_buffer.len = scsi_bufflen(scmnd); + request->extension.data_buffer.len = scsi_bufflen(scmnd); if (scsi_sg_count(scmnd)) { sgl = (struct scatterlist *)scsi_sglist(scmnd); sg_count = scsi_sg_count(scmnd); @@ -830,19 +831,19 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, sg_count = cmd_request->bounce_sgl_count; } - request->data_buffer.offset = sgl[0].offset; + request->extension.data_buffer.offset = sgl[0].offset; for (i = 0; i < sg_count; i++) { DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n", i, sgl[i].length, sgl[i].offset); - request->data_buffer.pfn_array[i] + request->extension.data_buffer.pfn_array[i] page_to_pfn(sg_page((&sgl[i]))); } } else if (scsi_sglist(scmnd)) { /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */ - request->data_buffer.offset + request->extension.data_buffer.offset virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1); - request->data_buffer.pfn_array[0] + request->extension.data_buffer.pfn_array[0] virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT; } -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 21/22] Staging: hv: Rename struct storvsc_request_extension
Now that all duplicate state has been eliminated from struct hv_storvsc_request and all needed state has been moved to struct storvsc_request_extension, get rid of struct hv_storvsc_request and rename struct storvsc_request_extension as struct hv_storvsc_request. Cleanup and consolidation of I/O request state is now complete. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 60 +++++++++++++++++++------------------- drivers/staging/hv/storvsc.c | 51 ++++++++++++++------------------ drivers/staging/hv/storvsc_api.h | 11 ++----- drivers/staging/hv/storvsc_drv.c | 31 +++++++++---------- 4 files changed, 70 insertions(+), 83 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 782441d..86e0506 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -520,9 +520,9 @@ static int blkvsc_do_flush(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.extension.data_buffer.pfn_array[0] = 0; - blkvsc_req->request.extension.data_buffer.offset = 0; - blkvsc_req->request.extension.data_buffer.len = 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; @@ -567,10 +567,10 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.extension.data_buffer.pfn_array[0] + blkvsc_req->request.data_buffer.pfn_array[0] page_to_pfn(page_buf); - blkvsc_req->request.extension.data_buffer.offset = 0; - blkvsc_req->request.extension.data_buffer.len = 64; + blkvsc_req->request.data_buffer.offset = 0; + blkvsc_req->request.data_buffer.len = 64; blkvsc_req->cmnd[0] = INQUIRY; blkvsc_req->cmnd[1] = 0x1; /* Get product data */ @@ -651,16 +651,16 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) return -ENOMEM; } - vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; + vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; init_waitqueue_head(&blkvsc_req->wevent); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.extension.data_buffer.pfn_array[0] + blkvsc_req->request.data_buffer.pfn_array[0] page_to_pfn(page_buf); - blkvsc_req->request.extension.data_buffer.offset = 0; - blkvsc_req->request.extension.data_buffer.len = 8; + blkvsc_req->request.data_buffer.offset = 0; + blkvsc_req->request.data_buffer.len = 8; blkvsc_req->cmnd[0] = READ_CAPACITY; blkvsc_req->cmd_len = 16; @@ -725,7 +725,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) return -ENOMEM; memset(blkvsc_req, 0, sizeof(struct blkvsc_request)); - vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; + vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; page_buf = alloc_page(GFP_KERNEL); if (!page_buf) { kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req); @@ -737,10 +737,10 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) blkvsc_req->req = NULL; blkvsc_req->write = 0; - blkvsc_req->request.extension.data_buffer.pfn_array[0] + blkvsc_req->request.data_buffer.pfn_array[0] page_to_pfn(page_buf); - blkvsc_req->request.extension.data_buffer.offset = 0; - blkvsc_req->request.extension.data_buffer.len = 12; + blkvsc_req->request.data_buffer.offset = 0; + blkvsc_req->request.data_buffer.len = 12; blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */ blkvsc_req->cmd_len = 16; @@ -929,8 +929,8 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, (blkvsc_req->write) ? "WRITE" : "READ", (unsigned long) blkvsc_req->sector_start, blkvsc_req->sector_count, - blkvsc_req->request.extension.data_buffer.offset, - blkvsc_req->request.extension.data_buffer.len); + blkvsc_req->request.data_buffer.offset, + blkvsc_req->request.data_buffer.len); #if 0 for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) { DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - " @@ -941,12 +941,12 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, #endif storvsc_req = &blkvsc_req->request; - vm_srb = &storvsc_req->extension.vstor_packet.vm_srb; + vm_srb = &storvsc_req->vstor_packet.vm_srb; vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE; - storvsc_req->extension.on_io_completion = request_completion; - storvsc_req->extension.context = blkvsc_req; + storvsc_req->on_io_completion = request_completion; + storvsc_req->context = blkvsc_req; vm_srb->port_number = blkdev->port; vm_srb->path_id = blkdev->path; @@ -957,7 +957,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length); - storvsc_req->extension.sense_buffer = blkvsc_req->sense_buffer; + storvsc_req->sense_buffer = blkvsc_req->sense_buffer; ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx, &blkvsc_req->request); @@ -1057,10 +1057,10 @@ static int blkvsc_do_request(struct block_device_context *blkdev, blkvsc_req->dev = blkdev; blkvsc_req->req = req; - blkvsc_req->request.extension. + blkvsc_req->request. data_buffer.offset = bvec->bv_offset; - blkvsc_req->request.extension. + blkvsc_req->request. data_buffer.len = 0; /* Add to the group */ @@ -1075,10 +1075,10 @@ static int blkvsc_do_request(struct block_device_context *blkdev, } /* Add the curr bvec/segment to the curr blkvsc_req */ - blkvsc_req->request.extension.data_buffer. + blkvsc_req->request.data_buffer. pfn_array[databuf_idx] = page_to_pfn(bvec->bv_page); - blkvsc_req->request.extension.data_buffer.len + blkvsc_req->request.data_buffer.len += bvec->bv_len; prev_bvec = bvec; @@ -1144,7 +1144,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev, static void blkvsc_cmd_completion(struct hv_storvsc_request *request) { struct blkvsc_request *blkvsc_req - (struct blkvsc_request *)request->extension.context; + (struct blkvsc_request *)request->context; struct block_device_context *blkdev (struct block_device_context *)blkvsc_req->dev; struct scsi_sense_hdr sense_hdr; @@ -1153,7 +1153,7 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request) DPRINT_DBG(BLKVSC_DRV, "blkvsc_cmd_completion() - req %p\n", blkvsc_req); - vm_srb = &blkvsc_req->request.extension.vstor_packet.vm_srb; + vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; blkdev->num_outstanding_reqs--; if (vm_srb->scsi_status) @@ -1168,7 +1168,7 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request) static void blkvsc_request_completion(struct hv_storvsc_request *request) { struct blkvsc_request *blkvsc_req - (struct blkvsc_request *)request->extension.context; + (struct blkvsc_request *)request->context; struct block_device_context *blkdev (struct block_device_context *)blkvsc_req->dev; unsigned long flags; @@ -1184,7 +1184,7 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) (blkvsc_req->write) ? "WRITE" : "READ", (unsigned long)blkvsc_req->sector_start, blkvsc_req->sector_count, - blkvsc_req->request.extension.data_buffer.len, + blkvsc_req->request.data_buffer.len, blkvsc_req->group->outstanding, blkdev->num_outstanding_reqs); @@ -1211,7 +1211,7 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) list_del(&comp_req->req_entry); vm_srb - &comp_req->request.extension.vstor_packet.vm_srb; + &comp_req->request.vstor_packet.vm_srb; if (!__blk_end_request(comp_req->req, (!vm_srb->scsi_status ? 0 : -EIO), comp_req->sector_count * blkdev->sector_size)) { @@ -1272,7 +1272,7 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) if (comp_req->req) { vm_srb - &comp_req->request.extension.vstor_packet. + &comp_req->request.vstor_packet. vm_srb; ret = __blk_end_request(comp_req->req, (!vm_srb->scsi_status ? 0 : -EIO), diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index 374de74..d7ce393 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -105,7 +105,7 @@ static inline struct storvsc_device *final_release_stor_device( static int stor_vsc_channel_init(struct hv_device *device) { struct storvsc_device *stor_device; - struct storvsc_request_extension *request; + struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; int ret, t; @@ -123,7 +123,7 @@ static int stor_vsc_channel_init(struct hv_device *device) * Now, initiate the vsc/vsp initialization protocol on the open * channel */ - memset(request, 0, sizeof(struct storvsc_request_extension)); + memset(request, 0, sizeof(struct hv_storvsc_request)); init_completion(&request->wait_event); vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; @@ -276,9 +276,8 @@ cleanup: static void stor_vsc_on_io_completion(struct hv_device *device, struct vstor_packet *vstor_packet, - struct storvsc_request_extension *request_ext) + struct hv_storvsc_request *request) { - struct hv_storvsc_request *request; struct storvsc_device *stor_device; struct vstor_packet *stor_pkt; @@ -289,12 +288,11 @@ static void stor_vsc_on_io_completion(struct hv_device *device, return; } - DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request extension %p " - "completed bytes xfer %u", request_ext, + DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request %p " + "completed bytes xfer %u", request, vstor_packet->vm_srb.data_transfer_length); - request = request_ext->request; - stor_pkt = &request_ext->vstor_packet; + stor_pkt = &request->vstor_packet; /* Copy over the status...etc */ @@ -317,10 +315,10 @@ static void stor_vsc_on_io_completion(struct hv_device *device, if (vstor_packet->vm_srb.srb_status & 0x80) { /* autosense data available */ DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data " - "valid - len %d\n", request_ext, + "valid - len %d\n", request, vstor_packet->vm_srb.sense_info_length); - memcpy(request->extension.sense_buffer, + memcpy(request->sense_buffer, vstor_packet->vm_srb.sense_data, vstor_packet->vm_srb.sense_info_length); @@ -330,7 +328,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device, stor_pkt->vm_srb.data_transfer_length vstor_packet->vm_srb.data_transfer_length; - request->extension.on_io_completion(request); + request->on_io_completion(request); atomic_dec(&stor_device->num_outstanding_req); @@ -339,12 +337,12 @@ static void stor_vsc_on_io_completion(struct hv_device *device, static void stor_vsc_on_receive(struct hv_device *device, struct vstor_packet *vstor_packet, - struct storvsc_request_extension *request_ext) + struct hv_storvsc_request *request) { switch (vstor_packet->operation) { case VSTOR_OPERATION_COMPLETE_IO: DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION"); - stor_vsc_on_io_completion(device, vstor_packet, request_ext); + stor_vsc_on_io_completion(device, vstor_packet, request); break; case VSTOR_OPERATION_REMOVE_DEVICE: DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION"); @@ -365,7 +363,7 @@ static void stor_vsc_on_channel_callback(void *context) u32 bytes_recvd; u64 request_id; unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)]; - struct storvsc_request_extension *request; + struct hv_storvsc_request *request; int ret; @@ -385,7 +383,7 @@ static void stor_vsc_on_channel_callback(void *context) bytes_recvd, request_id); - request = (struct storvsc_request_extension *) + request = (struct hv_storvsc_request *) (unsigned long)request_id; if ((request == &stor_device->init_request) || @@ -524,20 +522,17 @@ int stor_vsc_on_io_request(struct hv_device *device, struct hv_storvsc_request *request) { struct storvsc_device *stor_device; - struct storvsc_request_extension *request_extension; struct vstor_packet *vstor_packet; int ret = 0; - request_extension = &request->extension; - vstor_packet = &request_extension->vstor_packet; + vstor_packet = &request->vstor_packet; stor_device = get_stor_device(device); DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, " - "Extension %p", device, stor_device, request, - request_extension); + , device, stor_device, request); DPRINT_DBG(STORVSC, "req %p len %d", - request, request->extension.data_buffer.len); + request, request->data_buffer.len); if (!stor_device) { DPRINT_ERR(STORVSC, "unable to get stor device..." @@ -546,8 +541,7 @@ int stor_vsc_on_io_request(struct hv_device *device, } - request_extension->request = request; - request_extension->device = device; + request->device = device; vstor_packet->flags |= REQUEST_COMPLETION_FLAG; @@ -559,7 +553,7 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.data_transfer_length - request->extension.data_buffer.len; + request->data_buffer.len; vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; @@ -573,17 +567,16 @@ int stor_vsc_on_io_request(struct hv_device *device, vstor_packet->vm_srb.sense_info_length, vstor_packet->vm_srb.cdb_length); - if (request_extension->request->extension.data_buffer.len) { + if (request->data_buffer.len) { ret = vmbus_sendpacket_multipagebuffer(device->channel, - &request_extension->request->extension. - data_buffer, + &request->data_buffer, vstor_packet, sizeof(struct vstor_packet), - (unsigned long)request_extension); + (unsigned long)request); } else { ret = vmbus_sendpacket(device->channel, vstor_packet, sizeof(struct vstor_packet), - (unsigned long)request_extension, + (unsigned long)request, VM_PKT_DATA_INBAND, VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); } diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index 0c0bbf6..f6b7cde 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -55,7 +55,7 @@ enum storvsc_request_type{ }; -struct storvsc_request_extension { +struct hv_storvsc_request { struct hv_storvsc_request *request; struct hv_device *device; @@ -70,11 +70,6 @@ struct storvsc_request_extension { struct vstor_packet vstor_packet; }; -struct hv_storvsc_request { - struct storvsc_request_extension extension; - -}; - /* Represents the block vsc driver */ struct storvsc_driver_object { struct hv_driver base; @@ -115,8 +110,8 @@ struct storvsc_device { unsigned char target_id; /* Used for vsc/vsp channel reset process */ - struct storvsc_request_extension init_request; - struct storvsc_request_extension reset_request; + struct hv_storvsc_request init_request; + struct hv_storvsc_request reset_request; }; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e7005d9..ae61735 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -81,12 +81,11 @@ static int stor_vsc_initialize(struct hv_driver *driver) stor_driver = hvdr_to_stordr(driver); - DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd " - "sizeof(struct storvsc_request_extension)=%zd " + DPRINT_DBG(STORVSC, + "sizeof(struct hv_storvsc_request)=%zd " "sizeof(struct vstor_packet)=%zd, " "sizeof(struct vmscsi_request)=%zd", sizeof(struct hv_storvsc_request), - sizeof(struct storvsc_request_extension), sizeof(struct vstor_packet), sizeof(struct vmscsi_request)); @@ -229,7 +228,7 @@ static int storvsc_drv_init(void) static int stor_vsc_on_host_reset(struct hv_device *device) { struct storvsc_device *stor_device; - struct storvsc_request_extension *request; + struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; int ret, t; @@ -448,7 +447,7 @@ static int storvsc_remove(struct device *device) static void storvsc_commmand_completion(struct hv_storvsc_request *request) { struct storvsc_cmd_request *cmd_request - (struct storvsc_cmd_request *)request->extension.context; + (struct storvsc_cmd_request *)request->context; struct scsi_cmnd *scmnd = cmd_request->cmd; struct host_device_context *host_device_ctx (struct host_device_context *)scmnd->device->host->hostdata; @@ -474,7 +473,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) cmd_request->bounce_sgl_count); } - vm_srb = &request->extension.vstor_packet.vm_srb; + vm_srb = &request->vstor_packet.vm_srb; scmnd->result = vm_srb->scsi_status; if (scmnd->result) { @@ -485,7 +484,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) /* ASSERT(request->BytesXfer <= request->data_buffer.Length); */ scsi_set_resid(scmnd, - request->extension.data_buffer.len - + request->data_buffer.len - vm_srb->data_transfer_length); scsi_done_fn = scmnd->scsi_done; @@ -756,7 +755,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, scmnd->host_scribble = (unsigned char *)cmd_request; request = &cmd_request->request; - vm_srb = &request->extension.vstor_packet.vm_srb; + vm_srb = &request->vstor_packet.vm_srb; DPRINT_DBG(STORVSC_DRV, "req %p size %d", request, request_size); @@ -773,8 +772,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, break; } - request->extension.on_io_completion = storvsc_commmand_completion; - request->extension.context = cmd_request;/* scmnd; */ + request->on_io_completion = storvsc_commmand_completion; + request->context = cmd_request;/* scmnd; */ /* request->PortId = scmnd->device->channel; */ vm_srb->port_number = host_device_ctx->port; @@ -787,10 +786,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); - request->extension.sense_buffer = scmnd->sense_buffer; + request->sense_buffer = scmnd->sense_buffer; - request->extension.data_buffer.len = scsi_bufflen(scmnd); + request->data_buffer.len = scsi_bufflen(scmnd); if (scsi_sg_count(scmnd)) { sgl = (struct scatterlist *)scsi_sglist(scmnd); sg_count = scsi_sg_count(scmnd); @@ -831,19 +830,19 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, sg_count = cmd_request->bounce_sgl_count; } - request->extension.data_buffer.offset = sgl[0].offset; + request->data_buffer.offset = sgl[0].offset; for (i = 0; i < sg_count; i++) { DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n", i, sgl[i].length, sgl[i].offset); - request->extension.data_buffer.pfn_array[i] + request->data_buffer.pfn_array[i] page_to_pfn(sg_page((&sgl[i]))); } } else if (scsi_sglist(scmnd)) { /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */ - request->extension.data_buffer.offset + request->data_buffer.offset virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1); - request->extension.data_buffer.pfn_array[0] + request->data_buffer.pfn_array[0] virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT; } -- 1.7.4.1
K. Y. Srinivasan
2011-Apr-05 14:05 UTC
[PATCH 22/22] Staging: hv: Get rid of synch primitive in struct blkvsc_request
Get rid of synch primitive in struct blkvsc_request and instead use the synch primitive already embedded in the struct hv_storvsc_request structure. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 52 +++++++++++--------------------------- 1 files changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 86e0506..9af5347 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -72,9 +72,6 @@ struct blkvsc_request { /* The group this request is part of. Maybe null */ struct blkvsc_request_group *group; - wait_queue_head_t wevent; - int cond; - int write; sector_t sector_start; unsigned long sector_count; @@ -515,7 +512,7 @@ static int blkvsc_do_flush(struct block_device_context *blkdev) return -ENOMEM; memset(blkvsc_req, 0, sizeof(struct blkvsc_request)); - init_waitqueue_head(&blkvsc_req->wevent); + init_completion(&blkvsc_req->request.wait_event); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; blkvsc_req->write = 0; @@ -527,14 +524,9 @@ static int blkvsc_do_flush(struct block_device_context *blkdev) blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE; blkvsc_req->cmd_len = 10; - /* - * Set this here since the completion routine may be invoked and - * completed before we return - */ - blkvsc_req->cond = 0; blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion); - wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); + wait_for_completion_interruptible(&blkvsc_req->request.wait_event); kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req); @@ -562,7 +554,7 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) return -ENOMEM; } - init_waitqueue_head(&blkvsc_req->wevent); + init_completion(&blkvsc_req->request.wait_event); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; blkvsc_req->write = 0; @@ -578,18 +570,12 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) blkvsc_req->cmnd[4] = 64; blkvsc_req->cmd_len = 6; - /* - * Set this here since the completion routine may be invoked and - * completed before we return - */ - blkvsc_req->cond = 0; - blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion); - DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n", - blkvsc_req, blkvsc_req->cond); + DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n", + blkvsc_req); - wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); + wait_for_completion_interruptible(&blkvsc_req->request.wait_event); buf = kmap(page_buf); @@ -652,7 +638,7 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) } vm_srb = &blkvsc_req->request.vstor_packet.vm_srb; - init_waitqueue_head(&blkvsc_req->wevent); + init_completion(&blkvsc_req->request.wait_event); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; blkvsc_req->write = 0; @@ -665,18 +651,12 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev) blkvsc_req->cmnd[0] = READ_CAPACITY; blkvsc_req->cmd_len = 16; - /* - * Set this here since the completion routine may be invoked - * and completed before we return - */ - blkvsc_req->cond = 0; - blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion); - DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n", - blkvsc_req, blkvsc_req->cond); + DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n", + blkvsc_req); - wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); + wait_for_completion_interruptible(&blkvsc_req->request.wait_event); /* check error */ if (vm_srb->scsi_status) { @@ -732,7 +712,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) return -ENOMEM; } - init_waitqueue_head(&blkvsc_req->wevent); + init_completion(&blkvsc_req->request.wait_event); blkvsc_req->dev = blkdev; blkvsc_req->req = NULL; blkvsc_req->write = 0; @@ -749,14 +729,13 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) * Set this here since the completion routine may be invoked * and completed before we return */ - blkvsc_req->cond = 0; blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion); - DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n", - blkvsc_req, blkvsc_req->cond); + DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n", + blkvsc_req); - wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond); + wait_for_completion_interruptible(&blkvsc_req->request.wait_event); /* check error */ if (vm_srb->scsi_status) { @@ -1161,8 +1140,7 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request) SCSI_SENSE_BUFFERSIZE, &sense_hdr)) scsi_print_sense_hdr("blkvsc", &sense_hdr); - blkvsc_req->cond = 1; - wake_up_interruptible(&blkvsc_req->wevent); + complete(&blkvsc_req->request.wait_event); } static void blkvsc_request_completion(struct hv_storvsc_request *request) -- 1.7.4.1