Staging: hv: Cleanup storage drivers - Phase I
Subsystems (2)
cover Staging: hv: Cleanup storage drivers - Phase I
This is first in a series of patch-sets aimed at cleaning up the storage drivers for Hyper-V. Before I get into the details of this patch-set, I think it is useful to give a brief overview of the storage related front-end drivers currently in the tree for Linux on Hyper-V:
On the host side, Windows emulates the standard PC hardware to permit hosting of fully virtualized operating systems. To enhance disk I/O performance, we support a virtual block driver. This block driver currently handles disks that have been setup as IDE disks for the guest - as specified in the guest configuration.
On the SCSI side, we emulate a SCSI HBA. Devices configured under the SCSI controller for the guest are handled via this emulated HBA (SCSI front-end). So, SCSI disks configured for the guest are handled through native SCSI upper-level drivers. If this SCSI front-end driver is not loaded, currently, the guest cannot see devices that have been configured as SCSI devices. So, while the virtual block driver described earlier could potentially handle all block devices, the implementation choices made on the host may not permit it. Also, the only SCSI device that can be currently configured for the guest is a disk device.
Both the block device driver (hv_blkvsc) and the SCSI front-end driver (hv_storvsc) communicate with the host via unique channels that are implemented as bi-directional ring-buffers. Each (storage) channel carries with it enough state to uniquely identify the device on the host side. Microsoft has chosen to use SCSI verbs for this storage channel communication.
In this patch-set I have addressed the following issues in the Hyper-V storage drivers (virtual block and SCSI front-end):
1) Get rid of the inclusion of storvsc.c from blockvsc.c
2) Cleanup storvsc.c
3) Get rid of the file blkvsc.c
4) Cleanup the initialization sequence for both block and SCSI front-end drivers.
Regards,
K. Y
PATCH 1/16 Staging: hv: Add the inclusion guard for vstorage.h
In preparation for getting rid of the inclusion of storvsc.c from blkvsc.c, add inclusion guard to vstorage.h
--- drivers/staging/hv/vstorage.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/staging/hv/vstorage.h +5 -0
@@ -25,6 +25,9 @@/* to alert the user that structure sizes may be mismatched even though the */ /* protocol versions match. */ +#ifndef _VSTORAGE_H_ +#define _VSTORAGE_H_ +#define REVISION_STRING (REVISION_ ) #REVISION_#define FILL_VMSTOR_REVISION (RESULT_LVALUE_ ) \ do { \
@@ -190,3 +193,5 @@ struct vstor_packet {/* This is the set of flags that the vsc can set in any packets it sends */ #define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG) + +#endif /* _VSTORAGE_H_ */
Signature · 1 line
1.7.4.1
PATCH 2/16 Staging: hv: Move the definition of struct storvsc_request_extension
In preparation for getting rid of the inclusion of storvsc.c from blkvsc.c, move the definition of struct storvsc_request_extension from storvsc.c to storvsc_api.h.
--- drivers/staging/hv/blkvsc.c | 1 + drivers/staging/hv/storvsc.c | 13 ------------- drivers/staging/hv/storvsc_api.h | 12 ++++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/staging/hv/blkvsc.c +1 -0
@@ -24,6 +24,7 @@#include <linux/mm.h> #include "hv_api.h" #include "storvsc.c" +#include "storvsc_api.h" static const char *g_blk_driver_name ="blkvsc" ;
drivers/staging/hv/storvsc.c +0 -13
@@ -33,19 +33,6 @@#include "channel.h" -struct storvsc_request_extension { -/* LIST_ENTRY ListEntry; */ - -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;
drivers/staging/hv/storvsc_api.h +12 -0
@@ -25,6 +25,7 @@#ifndef _STORVSC_API_H_#define _STORVSC_API_H_ +#include "vstorage.h" #include "vmbus_api.h" /* Defines */
@@ -102,6 +103,17 @@ 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; +}; +/* Interface */ int stor_vsc_initialize (struct hv_driver *driver);int stor_vsc_on_host_reset (struct hv_device *device);
Signature · 1 line
1.7.4.1
PATCH 4/16 Staging: hv: Cleanup struct storvsc_device
In reply to K. Y. SrinivasanGet rid of some dated comments from struct storvsc_device.
--- drivers/staging/hv/storvsc_api.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -3
@@ -132,9 +132,6 @@ struct storvsc_device {unsigned char path_id;unsigned char target_id; -/* LIST_ENTRY OutstandingRequestList; */ -/* HANDLE OutstandingRequestLock; */ -/* Used for vsc/vsp channel reset process */ struct storvsc_request_extension init_request;struct storvsc_request_extension reset_request;
Signature · 1 line
1.7.4.1
PATCH 7/16 Staging: hv: Move the definition of stor_vsc_initialize()
In reply to K. Y. SrinivasanSince stor_vsc_initialize() is only used in storvs_drv.c, move this function to storvsc_drv.c.
--- drivers/staging/hv/storvsc.c | 64 -------------------------------------- drivers/staging/hv/storvsc_drv.c | 63 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 64 deletions(-)
drivers/staging/hv/storvsc.c +0 -64
@@ -33,18 +33,6 @@#include "channel.h" - -static const char *g_driver_name ="storvsc" ; - -/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const struct hv_guid gStorVscDeviceType = { - .data = { -0xd9 ,0x63 ,0x61 ,0xba ,0xa1 ,0x04 ,0x29 ,0x4d , -0xb6 ,0x05 ,0x72 ,0xe2 ,0xff ,0xb1 ,0xdc ,0x7f - } -}; - -static inline struct storvsc_device *alloc_stor_device (struct hv_device *device) {struct storvsc_device *stor_device;
@@ -711,55 +699,3 @@ void stor_vsc_on_cleanup(struct hv_driver *driver) { } -/* -* stor_vsc_initialize - Main entry point -*/ -int stor_vsc_initialize (struct hv_driver *driver) -{ -struct storvsc_driver_object *stor_driver; - - stor_driver = (struct storvsc_driver_object *)driver; - -DPRINT_DBG (STORVSC ,"sizeof(STORVSC_REQUEST)=%zd " -"sizeof(struct storvsc_request_extension)=%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 )); - -/* Make sure we are at least 2 pages since 1 page is used for control */ - - driver->name = g_driver_name; -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 -* than the ring buffer size since that page is reserved for -* the ring buffer indices) by the max request size (which is -* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64) -*/ - stor_driver->max_outstanding_req_per_channel = - ((stor_driver->ring_buffer_size -PAGE_SIZE ) / -ALIGN (MAX_MULTIPAGE_BUFFER_PACKET + -sizeof (struct vstor_packet ) +sizeof (u64), -sizeof (u64))); - -DPRINT_INFO (STORVSC ,"max io %u, currently %u\n" , - stor_driver->max_outstanding_req_per_channel, -STORVSC_MAX_IO_REQUESTS ); - -/* Setup the dispatch table */ - stor_driver->base.dev_add = stor_vsc_on_device_add; - stor_driver->base.dev_rm = stor_vsc_on_device_remove; - stor_driver->base.cleanup = stor_vsc_on_cleanup; - - stor_driver->on_io_request = stor_vsc_on_io_request; - -return 0 ; -}
drivers/staging/hv/storvsc_drv.c +63 -0
75 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 5/16 Staging: hv: Get rid of the include of storvsc.c from blkvsc.c
In reply to K. Y. SrinivasanNow that all the structure definitions have been moved to a header file, get rid of the inclusion of storvsc.c from blkvsc.c.
--- drivers/staging/hv/Makefile | 2 +- drivers/staging/hv/blkvsc.c | 2 +- drivers/staging/hv/storvsc.c | 8 ++++---- drivers/staging/hv/storvsc_api.h | 9 +++++++++ 4 files changed, 15 insertions(+), 6 deletions(-)
drivers/staging/hv/Makefile +1 -1
@@ -9,6 +9,6 @@ hv_vmbus-y := vmbus_drv.o \ hv.o connection.o channel.o \ channel_mgmt.o ring_buffer.o hv_storvsc-y := storvsc_drv.o storvsc.o -hv_blkvsc-y := blkvsc_drv.o blkvsc.o +hv_blkvsc-y := blkvsc_drv.o blkvsc.o storvsc.o hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o hv_utils-y := hv_util.o hv_kvp.o
drivers/staging/hv/blkvsc.c +1 -1
@@ -22,8 +22,8 @@*/ #include <linux/kernel.h> #include <linux/mm.h> +#include "logging.h" #include "hv_api.h" -#include "storvsc.c" #include "storvsc_api.h" static const char *g_blk_driver_name ="blkvsc" ;
drivers/staging/hv/storvsc.c +4 -4
@@ -504,7 +504,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)* stor_vsc_on_device_add - Callback when the device belonging to this driver * is added */ -static int stor_vsc_on_device_add (struct hv_device *device, +int stor_vsc_on_device_add (struct hv_device *device,void *additional_info) {struct storvsc_device *stor_device;
@@ -553,7 +553,7 @@ cleanup:/* * stor_vsc_on_device_remove - Callback when the our device is being removed */ -static int stor_vsc_on_device_remove (struct hv_device *device) +int stor_vsc_on_device_remove (struct hv_device *device) {struct storvsc_device *stor_device;
@@ -646,7 +646,7 @@ cleanup:/* * stor_vsc_on_io_request - Callback to initiate an I/O request */ -static int stor_vsc_on_io_request (struct hv_device *device, +int stor_vsc_on_io_request (struct hv_device *device,struct hv_storvsc_request *request) {struct storvsc_device *stor_device;
@@ -739,7 +739,7 @@ static int stor_vsc_on_io_request(struct hv_device *device,/* * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed */ -static void stor_vsc_on_cleanup (struct hv_driver *driver) +void stor_vsc_on_cleanup (struct hv_driver *driver) { }
drivers/staging/hv/storvsc_api.h +9 -0
@@ -142,4 +142,13 @@ int stor_vsc_initialize(struct hv_driver *driver);int stor_vsc_on_host_reset (struct hv_device *device);int blk_vsc_initialize (struct hv_driver *driver); +int stor_vsc_on_device_add (struct hv_device *device, +void *additional_info); +int stor_vsc_on_device_remove (struct hv_device *device); + +int stor_vsc_on_io_request (struct hv_device *device, +struct hv_storvsc_request *request); +void stor_vsc_on_cleanup (struct hv_driver *driver); + +#endif /* _STORVSC_API_H_ */
Signature · 1 line
1.7.4.1
PATCH 6/16 Staging: hv: Get rid of dead code in storvsc.c
In reply to K. Y. SrinivasanGet rid of some "dead code" from storvsc.c
--- drivers/staging/hv/storvsc.c | 33 --------------------------------- 1 files changed, 0 insertions(+), 33 deletions(-)
drivers/staging/hv/storvsc.c +0 -33
@@ -65,7 +65,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)static inline void free_stor_device (struct storvsc_device *device) { -/* ASSERT(atomic_read(&device->ref_count) == 0); */ kfree (device); }
@@ -103,10 +102,8 @@ static inline void put_stor_device(struct hv_device *device)struct storvsc_device *stor_device; stor_device = (struct storvsc_device *)device->ext; -/* ASSERT(stor_device); */ atomic_dec (&stor_device->ref_count); -/* ASSERT(atomic_read(&stor_device->ref_count)); */ }/* Drop ref count to 1 to effectively disable get_stor_device() */
@@ -116,7 +113,6 @@ static inline struct storvsc_device *release_stor_device(struct storvsc_device *stor_device; stor_device = (struct storvsc_device *)device->ext; -/* ASSERT(stor_device); */ /* Busy wait until the ref drop to 2, then set it to 1 */ while (atomic_cmpxchg (&stor_device->ref_count,2 ,1 ) !=2 )
@@ -132,7 +128,6 @@ static inline struct storvsc_device *final_release_stor_device(struct storvsc_device *stor_device; stor_device = (struct storvsc_device *)device->ext; -/* ASSERT(stor_device); */ /* Busy wait until the ref drop to 1, then set it to 0 */ while (atomic_cmpxchg (&stor_device->ref_count,1 ,0 ) !=1 )
@@ -341,12 +336,8 @@ static void stor_vsc_on_io_completion(struct hv_device *device,"completed bytes xfer %u" , request_ext, vstor_packet->vm_srb.data_transfer_length); -/* ASSERT(request_ext != NULL); */ -/* ASSERT(request_ext->request != NULL); */ - request = request_ext->request; -/* ASSERT(request->OnIOCompletion != NULL); */ /* Copy over the status...etc */ request->status = vstor_packet->vm_srb.scsi_status;
@@ -366,8 +357,6 @@ static void stor_vsc_on_io_completion(struct hv_device *device,"valid - len %d\n" , request_ext, vstor_packet->vm_srb.sense_info_length); -/* ASSERT(vstor_packet->vm_srb.sense_info_length <= */ -/* request->SenseBufferSize); */ memcpy (request->sense_buffer, vstor_packet->vm_srb.sense_data, vstor_packet->vm_srb.sense_info_length);
@@ -418,7 +407,6 @@ static void stor_vsc_on_channel_callback(void *context)struct storvsc_request_extension *request;int ret; -/* ASSERT(device); */ stor_device =must_get_stor_device (device);if (!stor_device) {
@@ -435,21 +423,12 @@ static void stor_vsc_on_channel_callback(void *context)DPRINT_DBG (STORVSC ,"receive %d bytes - tid %llx" , bytes_recvd, request_id); -/* ASSERT(bytes_recvd == -sizeof(struct vstor_packet)); */ request = (struct storvsc_request_extension *) (unsigned long )request_id; -/* ASSERT(request);c */ -/* if (vstor_packet.Flags & SYNTHETIC_FLAG) */ if ((request == &stor_device->init_request) || (request == &stor_device->reset_request)) { -/* DPRINT_INFO(STORVSC, -* "reset completion - operation " -* "%u status %u", -* vstor_packet.Operation, -* vstor_packet.Status); */ memcpy (&request->vstor_packet, packet,sizeof (struct vstor_packet ));
@@ -461,7 +440,6 @@ static void stor_vsc_on_channel_callback(void *context) request); } }else { -/* DPRINT_DBG(STORVSC, "nothing else to read..."); */ break ; } }while (1 );
@@ -508,7 +486,6 @@ int stor_vsc_on_device_add(struct hv_device *device, void *additional_info) {struct storvsc_device *stor_device; -/* struct vmstorage_channel_properties *props; */ struct storvsc_device_info *device_info;int ret =0 ;
@@ -520,8 +497,6 @@ int stor_vsc_on_device_add(struct hv_device *device, }/* Save the channel properties to our storvsc channel */ -/* props = (struct vmstorage_channel_properties *) -* channel->offerMsg.Offer.u.Standard.UserDefined; */ /* FIXME: */ /*
@@ -530,15 +505,10 @@ int stor_vsc_on_device_add(struct hv_device *device,* scsi channel prior to the bus scan */ -/* storChannel->PortNumber = 0; -storChannel->PathId = props->PathId; -storChannel->TargetId = props->TargetId; */ - stor_device->port_number = device_info->port_number;/* Send it back up */ ret =stor_vsc_connect_to_vsp (device); -/* device_info->PortNumber = stor_device->PortNumber; */ device_info->path_id = stor_device->path_id; device_info->target_id = stor_device->target_id;
@@ -673,8 +643,6 @@ int stor_vsc_on_io_request(struct hv_device *device,return -2 ; } -/* print_hex_dump_bytes("", DUMP_PREFIX_NONE, request->Cdb, -* request->CdbLen); */ request_extension->request = request; request_extension->device = device;
@@ -762,7 +730,6 @@ int stor_vsc_initialize(struct hv_driver *driver) sizeof(struct vmscsi_request));/* Make sure we are at least 2 pages since 1 page is used for control */ -/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */ driver->name = g_driver_name; memcpy(&driver->dev_type, &gStorVscDeviceType,
Signature · 1 line
1.7.4.1
PATCH 3/16 Staging: hv: Move the definition of struct storvsc_device
In reply to K. Y. SrinivasanIn preparation for getting rid of the inclusion of storvsc.c from blkvsc.c, move the definition of struct storvsc_device from storvsc.c to storvsc_api.h.
--- drivers/staging/hv/storvsc.c | 26 -------------------------- drivers/staging/hv/storvsc_api.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-)
drivers/staging/hv/storvsc.c +0 -26
@@ -33,32 +33,6 @@#include "channel.h" -/* A storvsc device is a device object that contains a vmbus channel */ -struct storvsc_device { -struct hv_device *device; - -/* 0 indicates the device is being destroyed */ -atomic_t ref_count; - -atomic_t num_outstanding_req; - -/* -* Each unique Port/Path/Target represents 1 channel ie scsi -* controller. In reality, the pathid, targetid is always 0 -* and the port is set by us -*/ -unsigned int port_number; -unsigned char path_id; -unsigned char target_id; - -/* LIST_ENTRY OutstandingRequestList; */ -/* HANDLE OutstandingRequestLock; */ - -/* Used for vsc/vsp channel reset process */ -struct storvsc_request_extension init_request; -struct storvsc_request_extension reset_request; -}; -static const char *g_driver_name ="storvsc" ;
drivers/staging/hv/storvsc_api.h +26 -0
@@ -114,6 +114,32 @@ struct storvsc_request_extension {struct vstor_packet vstor_packet; }; +/* A storvsc device is a device object that contains a vmbus channel */ +struct storvsc_device { +struct hv_device *device; + +/* 0 indicates the device is being destroyed */ +atomic_t ref_count; + +atomic_t num_outstanding_req; + +/* +* Each unique Port/Path/Target represents 1 channel ie scsi +* controller. In reality, the pathid, targetid is always 0 +* and the port is set by us +*/ +unsigned int port_number; +unsigned char path_id; +unsigned char target_id; + +/* LIST_ENTRY OutstandingRequestList; */ +/* HANDLE OutstandingRequestLock; */ + +/* Used for vsc/vsp channel reset process */ +struct storvsc_request_extension init_request; +struct storvsc_request_extension reset_request; +}; +/* Interface */ int stor_vsc_initialize (struct hv_driver *driver);int stor_vsc_on_host_reset (struct hv_device *device);
Signature · 1 line
1.7.4.1
PATCH 9/16 Staging: hv: Cleanup the initialization of storvsc driver
In reply to K. Y. SrinivasanCleanup the initialization sequence for the storvsc driver.
--- drivers/staging/hv/storvsc_drv.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +3 -3
@@ -191,7 +191,7 @@ static struct scsi_host_template scsi_driver = {/* * storvsc_drv_init - StorVsc driver initialization. */ -static int storvsc_drv_init (int (*drv_init)(struct hv_driver *drv)) +static int storvsc_drv_init (void ) {int ret;struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
@@ -200,7 +200,7 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;/* Callback to client driver to complete the initialization */ -drv_init (&storvsc_drv_obj->base); +stor_vsc_initialize (&storvsc_drv_obj->base); drv->priv = storvsc_drv_obj;
@@ -986,7 +986,7 @@ static int __init storvsc_init(void)int ret;DPRINT_INFO (STORVSC_DRV ,"Storvsc initializing...." ); - ret =storvsc_drv_init (stor_vsc_initialize); + ret =storvsc_drv_init ();return ret; }
Signature · 1 line
1.7.4.1
PATCH 10/16 Staging: hv: Move the contents of blkvsc.c to blkvsc_drv.c
In reply to K. Y. SrinivasanIn preparation for getting rid of the file blkvsc.c, move its contents to the appropriate file.
--- drivers/staging/hv/Makefile | 2 +- drivers/staging/hv/blkvsc_drv.c | 79 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletions(-)
drivers/staging/hv/Makefile +1 -1
@@ -9,6 +9,6 @@ hv_vmbus-y := vmbus_drv.o \ hv.o connection.o channel.o \ channel_mgmt.o ring_buffer.o hv_storvsc-y := storvsc_drv.o storvsc.o -hv_blkvsc-y := blkvsc_drv.o blkvsc.o storvsc.o +hv_blkvsc-y := blkvsc_drv.o storvsc.o hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o hv_utils-y := hv_util.o hv_kvp.o
drivers/staging/hv/blkvsc_drv.c +79 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 12/16 Staging: hv: Cleanup initialization of blkvsc driver
In reply to K. Y. SrinivasanCleanup the initialization sequence for the block driver.
--- drivers/staging/hv/blkvsc_drv.c | 8 ++++---- drivers/staging/hv/storvsc_api.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/staging/hv/blkvsc_drv.c +4 -4
@@ -155,7 +155,7 @@ static int blk_vsc_on_device_add(struct hv_device *device, } -int blk_vsc_initialize (struct hv_driver *driver) +static int blk_vsc_initialize (struct hv_driver *driver) {struct storvsc_driver_object *stor_driver;int ret =0 ;
@@ -243,7 +243,7 @@ static const struct block_device_operations block_ops = {/* * blkvsc_drv_init - BlkVsc driver initialization. */ -static int blkvsc_drv_init (int (*drv_init)(struct hv_driver *drv)) +static int blkvsc_drv_init (void ) {struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv;struct hv_driver *drv = &g_blkvsc_drv.base;
@@ -254,7 +254,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) drv->priv = storvsc_drv_obj;/* Callback to client driver to complete the initialization */ -drv_init (&storvsc_drv_obj->base); +blk_vsc_initialize (&storvsc_drv_obj->base); drv->driver.name = storvsc_drv_obj->base.name;
@@ -1552,7 +1552,7 @@ static int __init blkvsc_init(void)DPRINT_INFO (BLKVSC_DRV ,"Blkvsc initializing...." ); - ret =blkvsc_drv_init (blk_vsc_initialize); + ret =blkvsc_drv_init ();return ret; }
drivers/staging/hv/storvsc_api.h +0 -1
@@ -139,7 +139,6 @@ struct storvsc_device {/* Interface */ int stor_vsc_on_host_reset (struct hv_device *device); -int blk_vsc_initialize (struct hv_driver *driver);int stor_vsc_on_device_add (struct hv_device *device,void *additional_info);
Signature · 1 line
1.7.4.1
PATCH 8/16 Staging: hv: Make the function stor_vsc_initialize() static
In reply to K. Y. SrinivasanMake the function stor_vsc_initialize() a static function.
--- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -1
@@ -138,7 +138,6 @@ struct storvsc_device { };/* Interface */ -int stor_vsc_initialize (struct hv_driver *driver);int stor_vsc_on_host_reset (struct hv_device *device);int blk_vsc_initialize (struct hv_driver *driver);
drivers/staging/hv/storvsc_drv.c +1 -1
@@ -77,7 +77,7 @@ struct storvsc_cmd_request {/* * stor_vsc_initialize - Main entry point */ -int stor_vsc_initialize (struct hv_driver *driver) +static int stor_vsc_initialize (struct hv_driver *driver) {struct storvsc_driver_object *stor_driver;
Signature · 1 line
1.7.4.1
PATCH 13/16 Staging: hv: Move the definition of the function get_stor_device()
In reply to K. Y. SrinivasanIn preparation for further cleaning up storvsc.c move the definition of the inline function get_stor_device() from storvsc.c to storvsc_api.h.
--- drivers/staging/hv/storvsc.c | 14 -------------- drivers/staging/hv/storvsc_api.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-)
drivers/staging/hv/storvsc.c +0 -14
@@ -56,20 +56,6 @@ static inline void free_stor_device(struct storvsc_device *device)kfree (device); } -/* Get the stordevice object iff exists and its refcount > 1 */ -static inline struct storvsc_device *get_stor_device (struct hv_device *device) -{ -struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; -if (stor_device &&atomic_read (&stor_device->ref_count) >1 ) -atomic_inc (&stor_device->ref_count); -else - stor_device =NULL ; - -return stor_device; -} -/* Get the stordevice object iff exists and its refcount > 0 */ static inline struct storvsc_device *must_get_stor_device (struct hv_device *device)
drivers/staging/hv/storvsc_api.h +15 -0
@@ -137,6 +137,21 @@ struct storvsc_device {struct storvsc_request_extension reset_request; }; + +/* Get the stordevice object iff exists and its refcount > 1 */ +static inline struct storvsc_device *get_stor_device (struct hv_device *device) +{ +struct storvsc_device *stor_device; + + stor_device = (struct storvsc_device *)device->ext; +if (stor_device &&atomic_read (&stor_device->ref_count) >1 ) +atomic_inc (&stor_device->ref_count); +else + stor_device =NULL ; + +return stor_device; +} +/* Interface */ int stor_vsc_on_host_reset (struct hv_device *device);
Signature · 1 line
1.7.4.1
PATCH 11/16 Staging: hv: Get rid of the file blkvsc.c
In reply to K. Y. SrinivasanNow delete the file.
--- drivers/staging/hv/blkvsc.c | 103 ------------------------------------------- 1 files changed, 0 insertions(+), 103 deletions(-) delete mode 100644 drivers/staging/hv/blkvsc.c
drivers/staging/hv/blkvsc.c deleted +0 -103
@@ -1,103 +0,0 @@ -/* -* -* Copyright (c) 2009, Microsoft Corporation. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., 59 Temple -* Place - Suite 330, Boston, MA 02111-1307 USA. -* -* Authors: -* Haiyang Zhang <[email protected]> -* Hank Janssen <[email protected]> -* -*/ -#include <linux/kernel.h> -#include <linux/mm.h> -#include "logging.h" -#include "hv_api.h" -#include "storvsc_api.h" - -static const char *g_blk_driver_name ="blkvsc" ; - -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */ -static const struct hv_guid g_blk_device_type = { - .data = { -0x32 ,0x26 ,0x41 ,0x32 ,0xcb ,0x86 ,0xa2 ,0x44 , -0x9b ,0x5c ,0x50 ,0xd1 ,0x41 ,0x73 ,0x54 ,0xf5 - } -}; - -static int blk_vsc_on_device_add (struct hv_device *device,void *additional_info) -{ -struct storvsc_device_info *device_info; -int ret =0 ; - - device_info = (struct storvsc_device_info *)additional_info; - - ret =stor_vsc_on_device_add (device, additional_info); -if (ret !=0 ) -return ret; - -/* -* We need to use the device instance guid to set the path and target -* id. For IDE devices, the device instance id is formatted as -* <bus id> * - <device id> - 8899 - 000000000000. -*/ - device_info->path_id = device->dev_instance.data[3 ] <<24 | - device->dev_instance.data[2 ] <<16 | - device->dev_instance.data[1 ] <<8 | - device->dev_instance.data[0 ]; - - device_info->target_id = device->dev_instance.data[5 ] <<8 | - device->dev_instance.data[4 ]; - -return ret; -} - -int blk_vsc_initialize (struct hv_driver *driver) -{ -struct storvsc_driver_object *stor_driver; -int ret =0 ; - - stor_driver = (struct storvsc_driver_object *)driver; - -/* Make sure we are at least 2 pages since 1 page is used for control */ -/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */ - - 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 -* buffer size since that page is reserved for the ring buffer indices) -* by the max request size (which is -* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64) -*/ - stor_driver->max_outstanding_req_per_channel = - ((stor_driver->ring_buffer_size -PAGE_SIZE ) / -ALIGN (MAX_MULTIPAGE_BUFFER_PACKET + -sizeof (struct vstor_packet ) +sizeof (u64), -sizeof (u64))); - -DPRINT_INFO (BLKVSC ,"max io outstd %u" , - stor_driver->max_outstanding_req_per_channel); - -/* Setup the dispatch table */ - stor_driver->base.dev_add = blk_vsc_on_device_add; - stor_driver->base.dev_rm = stor_vsc_on_device_remove; - stor_driver->base.cleanup = stor_vsc_on_cleanup; - stor_driver->on_io_request = stor_vsc_on_io_request; - -return ret; -}
Signature · 1 line
1.7.4.1
PATCH 14/16 Staging: hv: Move the definition of the function put_stor_device()
In reply to K. Y. SrinivasanIn preparation for further cleaning up storvsc.c move the definition of the inline function put_stor_device() from storvsc.c to storvsc_api.h.
--- drivers/staging/hv/storvsc.c | 9 --------- drivers/staging/hv/storvsc_api.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/staging/hv/storvsc.c +0 -9
@@ -71,15 +71,6 @@ static inline struct storvsc_device *must_get_stor_device(return stor_device; } -static inline void put_stor_device (struct hv_device *device) -{ -struct storvsc_device *stor_device; - - stor_device = (struct storvsc_device *)device->ext; - -atomic_dec (&stor_device->ref_count); -} -/* Drop ref count to 1 to effectively disable get_stor_device() */ static inline struct storvsc_device *release_stor_device (struct hv_device *device)
drivers/staging/hv/storvsc_api.h +10 -0
@@ -152,6 +152,16 @@ static inline struct storvsc_device *get_stor_device(struct hv_device *device)return stor_device; } + +static inline void put_stor_device (struct hv_device *device) +{ +struct storvsc_device *stor_device; + + stor_device = (struct storvsc_device *)device->ext; + +atomic_dec (&stor_device->ref_count); +} +/* Interface */ int stor_vsc_on_host_reset (struct hv_device *device);
Signature · 1 line
1.7.4.1
PATCH 15/16 Staging: hv: Move the definition of the function stor_vsc_on_host_reset()
In reply to K. Y. Srinivasanstor_vsc_on_host_reset() function is only used in storvsc_drv.c. Move this function from storvsc.c to storvsc_drv.c
--- drivers/staging/hv/storvsc.c | 56 ------------------------------------ drivers/staging/hv/storvsc_drv.c | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 56 deletions(-)
drivers/staging/hv/storvsc.c +0 -56
@@ -522,62 +522,6 @@ int stor_vsc_on_device_remove(struct hv_device *device)return 0 ; } -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; - -DPRINT_INFO (STORVSC ,"resetting host adapter..." ); - - stor_device =get_stor_device (device); -if (!stor_device) { -DPRINT_ERR (STORVSC ,"unable to get stor device..." -"device being destroyed?" ); -return -1 ; - } - - request = &stor_device->reset_request; - vstor_packet = &request->vstor_packet; - -init_waitqueue_head (&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, -VM_PKT_DATA_INBAND , -VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); -if (ret !=0 ) { -DPRINT_ERR (STORVSC ,"Unable to send reset packet %p ret %d" , - vstor_packet, ret); - goto cleanup; - } - -wait_event_timeout (request->wait_event, request->wait_condition, -msecs_to_jiffies (1000 )); -if (request->wait_condition ==0 ) { - ret = -ETIMEDOUT ; - goto cleanup; - } - -DPRINT_INFO (STORVSC ,"host adapter reset completed" ); - -/* -* At this point, all outstanding requests in the adapter -* should have been flushed out and return to us -*/ - -cleanup: -put_stor_device (device); -return ret; -} -/* * stor_vsc_on_io_request - Callback to initiate an I/O request */
drivers/staging/hv/storvsc_drv.c +59 -0
71 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 16/16 Staging: hv: Make the function stor_vsc_on_host_reset() static
In reply to K. Y. SrinivasanMake stor_vsc_on_host_reset() a static function.
--- drivers/staging/hv/storvsc_api.h | 1 - drivers/staging/hv/storvsc_drv.c | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -1
@@ -163,7 +163,6 @@ static inline void put_stor_device(struct hv_device *device) }/* Interface */ -int stor_vsc_on_host_reset (struct hv_device *device);int stor_vsc_on_device_add (struct hv_device *device,void *additional_info);
drivers/staging/hv/storvsc_drv.c +1 -1
@@ -233,7 +233,7 @@ static int storvsc_drv_init(void) } -int stor_vsc_on_host_reset (struct hv_device *device) +static int stor_vsc_on_host_reset (struct hv_device *device) {struct storvsc_device *stor_device;struct storvsc_request_extension *request;
Signature · 1 line
1.7.4.1
Re: [PATCH 01/16] Staging: hv: Add the inclusion guard for vstorage.h
In reply to K. Y. SrinivasanQuoted 15 lines · K. Y. Srinivasan
In preparation for getting rid of the inclusion of
storvsc.cfromblkvsc.c, add inclusion guard tovstorage.hSigned-off-by K. Y. Srinivasan <[email protected]>Signed-off-by Haiyang Zhang <[email protected]>Signed-off-by Hank Janssen <[email protected]>--- drivers/staging/hv/vstorage.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)drivers/staging/hv/vstorage.h +0
-0
drivers/staging/hv/vstorage.h line 29
Quoted 5 lines
drivers/staging/hv/vstorage.h +2
-0@@ -25,6 +25,9 @@/* to alert the user that structure sizes may be mismatched even though the */ /* protocol versions match. */ +#ifndef _VSTORAGE_H_ +#define _VSTORAGE_H_
What's with the trailing '_'?
Traditionally we've used __FOO_H for internal kernel header files.
thanks,
greg k-h
Re: [PATCH 01/16] Staging: hv: Add the inclusion guard for vstorage.h
Quoted 19 lines · Greg KH
Quoted 18 lines · K. Y. Srinivasan
In preparation for getting rid of the inclusion of
storvsc.cfromblkvsc.c, add inclusion guard tovstorage.hSigned-off-by K. Y. Srinivasan <[email protected]>Signed-off-by Haiyang Zhang <[email protected]>Signed-off-by Hank Janssen <[email protected]>--- drivers/staging/hv/vstorage.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)drivers/staging/hv/vstorage.h +0
-0@@ -25,6 +25,9 @@/* to alert the user that structure sizes may be mismatched even though the */ /* protocol versions match. */
Quoted 6 lines
drivers/staging/hv/vstorage.h line 29
Quoted 2 lines
drivers/staging/hv/vstorage.h +2
-0+#ifndef _VSTORAGE_H_ +#define _VSTORAGE_H_What's with the trailing '_'?
Traditionally we've used
__FOO_Hfor internal kernel header files.
Oh nevermind, I see that's how the other .h files in this directory work, it's ok for now.
thanks,
greg k-h