2013-06-04 18:29:29

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH V3 0/5] Drivers: scsi: storvsc

This set adds multi-channel support as well synthetic Fibre Channel support
to storvsc. The multi-channel support depends on infrastructure in the VMBUS
driver. Greg has already checked in the relevant patches to VMBUS.

I had posted an earlier version of this patch-set that included the VMBUS
related changes. I have since separated the VMBUS chages and these have already been
checked in.

In this version, based on comments from James, the timeout is no longer a module
parameter.

K. Y. Srinivasan (5):
Drivers: scsi: storvsc: Increase the value of scsi timeout for
storvsc devices
Drivers: scsi: storvsc: Update the storage protocol to win8 level
Drivers: scsi: storvsc: Implement multi-channel support
Drivers: scsi: storvsc: Support FC devices
Drivers: scsi: storvsc: Increase the value of STORVSC_MAX_IO_REQUESTS

drivers/scsi/storvsc_drv.c | 347 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 308 insertions(+), 39 deletions(-)

--
1.7.4.1


2013-06-04 18:30:14

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH 3/5] Drivers: scsi: storvsc: Implement multi-channel support

Implement multi-channel support for the storage devices.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Reviewed-by: Haiyang Zhang <[email protected]>
---
drivers/scsi/storvsc_drv.c | 131 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 9451989..1d4d425 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -328,6 +328,8 @@ static int storvsc_timeout = 180;

#define STORVSC_MAX_IO_REQUESTS 128

+static void storvsc_on_channel_callback(void *context);
+
/*
* In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
* reality, the path/target is not used (ie always set to 0) so our
@@ -364,6 +366,7 @@ struct storvsc_device {

bool destroy;
bool drain_notify;
+ bool open_sub_channel;
atomic_t num_outstanding_req;
struct Scsi_Host *host;

@@ -755,12 +758,104 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
return total_copied;
}

+static void handle_sc_creation(struct vmbus_channel *new_sc)
+{
+ struct hv_device *device = new_sc->primary_channel->device_obj;
+ struct storvsc_device *stor_device;
+ struct vmstorage_channel_properties props;
+
+ stor_device = get_out_stor_device(device);
+ if (!stor_device)
+ return;
+
+ if (stor_device->open_sub_channel == false)
+ return;
+
+ memset(&props, 0, sizeof(struct vmstorage_channel_properties));
+
+ vmbus_open(new_sc,
+ storvsc_ringbuffer_size,
+ storvsc_ringbuffer_size,
+ (void *)&props,
+ sizeof(struct vmstorage_channel_properties),
+ storvsc_on_channel_callback, new_sc);
+}
+
+static void handle_multichannel_storage(struct hv_device *device, int max_chns)
+{
+ struct storvsc_device *stor_device;
+ int num_cpus = num_online_cpus();
+ int num_sc;
+ struct storvsc_cmd_request *request;
+ struct vstor_packet *vstor_packet;
+ int ret, t;
+
+ num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns);
+ stor_device = get_out_stor_device(device);
+ if (!stor_device)
+ return;
+
+ request = &stor_device->init_request;
+ vstor_packet = &request->vstor_packet;
+
+ stor_device->open_sub_channel = true;
+ /*
+ * Establish a handler for dealing with subchannels.
+ */
+ vmbus_set_sc_create_callback(device->channel, handle_sc_creation);
+
+ /*
+ * Check to see if sub-channels have already been created. This
+ * can happen when this driver is re-loaded after unloading.
+ */
+
+ if (vmbus_are_subchannels_present(device->channel))
+ return;
+
+ stor_device->open_sub_channel = false;
+ /*
+ * Request the host to create sub-channels.
+ */
+ memset(request, 0, sizeof(struct storvsc_cmd_request));
+ init_completion(&request->wait_event);
+ vstor_packet->operation = VSTOR_OPERATION_CREATE_SUB_CHANNELS;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+ vstor_packet->sub_channel_count = num_sc;
+
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
+ (unsigned long)request,
+ VM_PKT_DATA_INBAND,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+ if (ret != 0)
+ return;
+
+ t = wait_for_completion_timeout(&request->wait_event, 10*HZ);
+ if (t == 0)
+ return;
+
+ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+ vstor_packet->status != 0)
+ return;
+
+ /*
+ * Now that we created the sub-channels, invoke the check; this
+ * may trigger the callback.
+ */
+ stor_device->open_sub_channel = true;
+ vmbus_are_subchannels_present(device->channel);
+}
+
static int storvsc_channel_init(struct hv_device *device)
{
struct storvsc_device *stor_device;
struct storvsc_cmd_request *request;
struct vstor_packet *vstor_packet;
int ret, t;
+ int max_chns;
+ bool process_sub_channels = false;

stor_device = get_out_stor_device(device);
if (!stor_device)
@@ -855,6 +950,19 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->status != 0)
goto cleanup;

+ /*
+ * Check to see if multi-channel support is there.
+ * Hosts that implement protocol version of 5.1 and above
+ * support multi-channel.
+ */
+ max_chns = vstor_packet->storage_channel_properties.max_channel_cnt;
+ if ((vmbus_proto_version != VERSION_WIN7) &&
+ (vmbus_proto_version != VERSION_WS2008)) {
+ if (vstor_packet->storage_channel_properties.flags &
+ STORAGE_CHANNEL_SUPPORTS_MULTI_CHANNEL)
+ process_sub_channels = true;
+ }
+
memset(vstor_packet, 0, sizeof(struct vstor_packet));
vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -879,6 +987,9 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->status != 0)
goto cleanup;

+ if (process_sub_channels)
+ handle_multichannel_storage(device, max_chns);
+

cleanup:
return ret;
@@ -1100,7 +1211,8 @@ static void storvsc_on_receive(struct hv_device *device,

static void storvsc_on_channel_callback(void *context)
{
- struct hv_device *device = (struct hv_device *)context;
+ struct vmbus_channel *channel = (struct vmbus_channel *)context;
+ struct hv_device *device;
struct storvsc_device *stor_device;
u32 bytes_recvd;
u64 request_id;
@@ -1108,13 +1220,17 @@ static void storvsc_on_channel_callback(void *context)
struct storvsc_cmd_request *request;
int ret;

+ if (channel->primary_channel != NULL)
+ device = channel->primary_channel->device_obj;
+ else
+ device = channel->device_obj;

stor_device = get_in_stor_device(device);
if (!stor_device)
return;

do {
- ret = vmbus_recvpacket(device->channel, packet,
+ ret = vmbus_recvpacket(channel, packet,
ALIGN((sizeof(struct vstor_packet) -
vmscsi_size_delta), 8),
&bytes_recvd, &request_id);
@@ -1155,7 +1271,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
ring_size,
(void *)&props,
sizeof(struct vmstorage_channel_properties),
- storvsc_on_channel_callback, device);
+ storvsc_on_channel_callback, device->channel);

if (ret != 0)
return ret;
@@ -1207,6 +1323,7 @@ static int storvsc_do_io(struct hv_device *device,
{
struct storvsc_device *stor_device;
struct vstor_packet *vstor_packet;
+ struct vmbus_channel *outgoing_channel;
int ret = 0;

vstor_packet = &request->vstor_packet;
@@ -1217,6 +1334,11 @@ static int storvsc_do_io(struct hv_device *device,


request->device = device;
+ /*
+ * Select an an appropriate channel to send the request out.
+ */
+
+ outgoing_channel = vmbus_get_outgoing_channel(device->channel);


vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
@@ -1234,7 +1356,7 @@ static int storvsc_do_io(struct hv_device *device,
vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;

if (request->data_buffer.len) {
- ret = vmbus_sendpacket_multipagebuffer(device->channel,
+ ret = vmbus_sendpacket_multipagebuffer(outgoing_channel,
&request->data_buffer,
vstor_packet,
(sizeof(struct vstor_packet) -
@@ -1643,6 +1765,7 @@ static int storvsc_probe(struct hv_device *device,
}

stor_device->destroy = false;
+ stor_device->open_sub_channel = false;
init_waitqueue_head(&stor_device->waiting_to_drain);
stor_device->device = device;
stor_device->host = host;
--
1.7.4.1

2013-06-04 18:30:10

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH 1/5] Drivers: scsi: storvsc: Increase the value of scsi timeout for storvsc devices

The standard scsi timeout is not appropriate in some of the environments where
Hyper-V is deployed. Set this timeout appropriately for all devices managed
by this driver.

On cloud environments where storage latencies may be unbounded, having the scsi
layer initiating recovery can be problematic since (a) the host is already
implementing a variety of recovery strategies and (b) implementing a recovery
strategy at the VM level may be more appropriate in cases where storage latencies
exceed a certain threshold.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Reviewed-by: Haiyang Zhang <[email protected]>
---
drivers/scsi/storvsc_drv.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 16a3a0c..ede8694 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -221,6 +221,11 @@ static int storvsc_ringbuffer_size = (20 * PAGE_SIZE);
module_param(storvsc_ringbuffer_size, int, S_IRUGO);
MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");

+/*
+ * Timeout in seconds for all devices managed by this driver.
+ */
+static int storvsc_timeout = 180;
+
#define STORVSC_MAX_IO_REQUESTS 128

/*
@@ -1204,6 +1209,8 @@ static int storvsc_device_configure(struct scsi_device *sdevice)

blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);

+ blk_queue_rq_timeout(sdevice->request_queue, (storvsc_timeout * HZ));
+
sdevice->no_write_same = 1;

return 0;
--
1.7.4.1

2013-06-04 18:30:07

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH 4/5] Drivers: scsi: storvsc: Support FC devices

Add support for synthetic Fibre Channel devices.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Reviewed-by: Haiyang Zhang <[email protected]>
---
drivers/scsi/storvsc_drv.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 1d4d425..b864e7c 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1702,6 +1702,7 @@ static struct scsi_host_template scsi_driver = {
enum {
SCSI_GUID,
IDE_GUID,
+ SFC_GUID,
};

static const struct hv_vmbus_device_id id_table[] = {
@@ -1713,6 +1714,11 @@ static const struct hv_vmbus_device_id id_table[] = {
{ HV_IDE_GUID,
.driver_data = IDE_GUID
},
+ /* Fibre Channel GUID */
+ {
+ HV_SYNTHFC_GUID,
+ .driver_data = SFC_GUID
+ },
{ },
};

--
1.7.4.1

2013-06-04 18:30:05

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH 5/5] Drivers: scsi: storvsc: Increase the value of STORVSC_MAX_IO_REQUESTS

Increase the value of STORVSC_MAX_IO_REQUESTS to 200 requests. The current
ringbuffer size can support this higher value.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Reviewed-by: Haiyang Zhang <[email protected]>
---
drivers/scsi/storvsc_drv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index b864e7c..83ec1aa 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -326,7 +326,7 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
*/
static int storvsc_timeout = 180;

-#define STORVSC_MAX_IO_REQUESTS 128
+#define STORVSC_MAX_IO_REQUESTS 200

static void storvsc_on_channel_callback(void *context);

--
1.7.4.1

2013-06-04 18:31:32

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH 2/5] Drivers: scsi: storvsc: Update the storage protocol to win8 level

Update the storage protocol to the win8 level.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Reviewed-by: Haiyang Zhang <[email protected]>
---
drivers/scsi/storvsc_drv.c | 203 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 168 insertions(+), 35 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index ede8694..9451989 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -55,10 +55,15 @@
* V1 RC < 2008/1/31: 1.0
* V1 RC > 2008/1/31: 2.0
* Win7: 4.2
+ * Win8: 5.1
*/

-#define VMSTOR_CURRENT_MAJOR 4
-#define VMSTOR_CURRENT_MINOR 2
+
+#define VMSTOR_WIN7_MAJOR 4
+#define VMSTOR_WIN7_MINOR 2
+
+#define VMSTOR_WIN8_MAJOR 5
+#define VMSTOR_WIN8_MINOR 1


/* Packet structure describing virtual storage requests. */
@@ -74,18 +79,103 @@ enum vstor_packet_operation {
VSTOR_OPERATION_QUERY_PROTOCOL_VERSION = 9,
VSTOR_OPERATION_QUERY_PROPERTIES = 10,
VSTOR_OPERATION_ENUMERATE_BUS = 11,
- VSTOR_OPERATION_MAXIMUM = 11
+ VSTOR_OPERATION_FCHBA_DATA = 12,
+ VSTOR_OPERATION_CREATE_SUB_CHANNELS = 13,
+ VSTOR_OPERATION_MAXIMUM = 13
+};
+
+/*
+ * WWN packet for Fibre Channel HBA
+ */
+
+struct hv_fc_wwn_packet {
+ bool primary_active;
+ u8 reserved1;
+ u8 reserved2;
+ u8 primary_port_wwn[8];
+ u8 primary_node_wwn[8];
+ u8 secondary_port_wwn[8];
+ u8 secondary_node_wwn[8];
};

+
+
+/*
+ * SRB Flag Bits
+ */
+
+#define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002
+#define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004
+#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008
+#define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010
+#define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020
+#define SRB_FLAGS_DATA_IN 0x00000040
+#define SRB_FLAGS_DATA_OUT 0x00000080
+#define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
+#define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
+#define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100
+#define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200
+#define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400
+
+/*
+ * This flag indicates the request is part of the workflow for processing a D3.
+ */
+#define SRB_FLAGS_D3_PROCESSING 0x00000800
+#define SRB_FLAGS_IS_ACTIVE 0x00010000
+#define SRB_FLAGS_ALLOCATED_FROM_ZONE 0x00020000
+#define SRB_FLAGS_SGLIST_FROM_POOL 0x00040000
+#define SRB_FLAGS_BYPASS_LOCKED_QUEUE 0x00080000
+#define SRB_FLAGS_NO_KEEP_AWAKE 0x00100000
+#define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE 0x00200000
+#define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT 0x00400000
+#define SRB_FLAGS_DONT_START_NEXT_PACKET 0x00800000
+#define SRB_FLAGS_PORT_DRIVER_RESERVED 0x0F000000
+#define SRB_FLAGS_CLASS_DRIVER_RESERVED 0xF0000000
+
+
/*
* Platform neutral description of a scsi request -
* this remains the same across the write regardless of 32/64 bit
* note: it's patterned off the SCSI_PASS_THROUGH structure
*/
#define STORVSC_MAX_CMD_LEN 0x10
-#define STORVSC_SENSE_BUFFER_SIZE 0x12
+
+#define POST_WIN7_STORVSC_SENSE_BUFFER_SIZE 0x14
+#define PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE 0x12
+
+#define STORVSC_SENSE_BUFFER_SIZE 0x14
#define STORVSC_MAX_BUF_LEN_WITH_PADDING 0x14

+/*
+ * Sense buffer size changed in win8; have a run-time
+ * variable to track the size we should use.
+ */
+static int sense_buffer_size;
+
+/*
+ * The size of the vmscsi_request has changed in win8. The
+ * additional size is because of new elements added to the
+ * structure. These elements are valid only when we are talking
+ * to a win8 host.
+ * Track the correction to size we need to apply.
+ */
+
+static int vmscsi_size_delta;
+static int vmstor_current_major;
+static int vmstor_current_minor;
+
+struct vmscsi_win8_extension {
+ /*
+ * The following were added in Windows 8
+ */
+ u16 reserve;
+ u8 queue_tag;
+ u8 queue_action;
+ u32 srb_flags;
+ u32 time_out_value;
+ u32 queue_sort_ey;
+} __packed;
+
struct vmscsi_request {
u16 length;
u8 srb_status;
@@ -108,6 +198,11 @@ struct vmscsi_request {
u8 sense_data[STORVSC_SENSE_BUFFER_SIZE];
u8 reserved_array[STORVSC_MAX_BUF_LEN_WITH_PADDING];
};
+ /*
+ * The following was added in win8.
+ */
+ struct vmscsi_win8_extension win8_extension;
+
} __attribute((packed));


@@ -115,22 +210,18 @@ struct vmscsi_request {
* This structure is sent during the intialization phase to get the different
* properties of the channel.
*/
+
+#define STORAGE_CHANNEL_SUPPORTS_MULTI_CHANNEL 0x1
+
struct vmstorage_channel_properties {
- u16 protocol_version;
- u8 path_id;
- u8 target_id;
+ u32 reserved;
+ u16 max_channel_cnt;
+ u16 reserved1;

- /* Note: port number is only really known on the client side */
- u32 port_number;
- u32 flags;
+ u32 flags;
u32 max_transfer_bytes;

- /*
- * This id is unique for each channel and will correspond with
- * vendor specific data in the inquiry data.
- */
-
- u64 unique_id;
+ u64 reserved2;
} __packed;

/* This structure is sent during the storage protocol negotiations. */
@@ -175,6 +266,15 @@ struct vstor_packet {

/* Used during version negotiations. */
struct vmstorage_protocol_version version;
+
+ /* Fibre channel address packet */
+ struct hv_fc_wwn_packet wwn_packet;
+
+ /* Number of sub-channels to create */
+ u16 sub_channel_count;
+
+ /* This will be the maximum of the union members */
+ u8 buffer[0x34];
};
} __packed;

@@ -679,7 +779,8 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->flags = REQUEST_COMPLETION_FLAG;

ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -703,7 +804,7 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->flags = REQUEST_COMPLETION_FLAG;

vstor_packet->version.major_minor =
- storvsc_get_version(VMSTOR_CURRENT_MAJOR, VMSTOR_CURRENT_MINOR);
+ storvsc_get_version(vmstor_current_major, vmstor_current_minor);

/*
* The revision number is only used in Windows; set it to 0.
@@ -711,7 +812,8 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->version.revision = 0;

ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -732,11 +834,10 @@ static int storvsc_channel_init(struct hv_device *device)
memset(vstor_packet, 0, sizeof(struct vstor_packet));
vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
- vstor_packet->storage_channel_properties.port_number =
- stor_device->port_number;

ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -754,16 +855,13 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->status != 0)
goto cleanup;

- stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
- stor_device->target_id
- = vstor_packet->storage_channel_properties.target_id;
-
memset(vstor_packet, 0, sizeof(struct vstor_packet));
vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
vstor_packet->flags = REQUEST_COMPLETION_FLAG;

ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -1017,7 +1115,8 @@ static void storvsc_on_channel_callback(void *context)

do {
ret = vmbus_recvpacket(device->channel, packet,
- ALIGN(sizeof(struct vstor_packet), 8),
+ ALIGN((sizeof(struct vstor_packet) -
+ vmscsi_size_delta), 8),
&bytes_recvd, &request_id);
if (ret == 0 && bytes_recvd > 0) {

@@ -1028,7 +1127,8 @@ static void storvsc_on_channel_callback(void *context)
(request == &stor_device->reset_request)) {

memcpy(&request->vstor_packet, packet,
- sizeof(struct vstor_packet));
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta));
complete(&request->wait_event);
} else {
storvsc_on_receive(device,
@@ -1121,10 +1221,11 @@ static int storvsc_do_io(struct hv_device *device,

vstor_packet->flags |= REQUEST_COMPLETION_FLAG;

- vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
+ vstor_packet->vm_srb.length = (sizeof(struct vmscsi_request) -
+ vmscsi_size_delta);


- vstor_packet->vm_srb.sense_info_length = STORVSC_SENSE_BUFFER_SIZE;
+ vstor_packet->vm_srb.sense_info_length = sense_buffer_size;


vstor_packet->vm_srb.data_transfer_length =
@@ -1136,11 +1237,13 @@ static int storvsc_do_io(struct hv_device *device,
ret = vmbus_sendpacket_multipagebuffer(device->channel,
&request->data_buffer,
vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request);
} else {
ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -1264,7 +1367,8 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
vstor_packet->vm_srb.path_id = stor_device->path_id;

ret = vmbus_sendpacket(device->channel, vstor_packet,
- sizeof(struct vstor_packet),
+ (sizeof(struct vstor_packet) -
+ vmscsi_size_delta),
(unsigned long)&stor_device->reset_request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -1349,18 +1453,28 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
scmnd->host_scribble = (unsigned char *)cmd_request;

vm_srb = &cmd_request->vstor_packet.vm_srb;
+ vm_srb->win8_extension.time_out_value = 60;


/* Build the SRB */
switch (scmnd->sc_data_direction) {
case DMA_TO_DEVICE:
vm_srb->data_in = WRITE_TYPE;
+ vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_OUT;
+ vm_srb->win8_extension.srb_flags |=
+ (SRB_FLAGS_QUEUE_ACTION_ENABLE |
+ SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
break;
case DMA_FROM_DEVICE:
vm_srb->data_in = READ_TYPE;
+ vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_IN;
+ vm_srb->win8_extension.srb_flags |=
+ (SRB_FLAGS_QUEUE_ACTION_ENABLE |
+ SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
break;
default:
vm_srb->data_in = UNKNOWN_TYPE;
+ vm_srb->win8_extension.srb_flags = 0;
break;
}

@@ -1492,6 +1606,24 @@ static int storvsc_probe(struct hv_device *device,
int target = 0;
struct storvsc_device *stor_device;

+ /*
+ * Based on the windows host we are running on,
+ * set state to properly communicate with the host.
+ */
+
+ if (vmbus_proto_version == VERSION_WIN8) {
+ sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
+ vmscsi_size_delta = 0;
+ vmstor_current_major = VMSTOR_WIN8_MAJOR;
+ vmstor_current_minor = VMSTOR_WIN8_MINOR;
+ } else {
+ sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
+ vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
+ vmstor_current_major = VMSTOR_WIN7_MAJOR;
+ vmstor_current_minor = VMSTOR_WIN7_MINOR;
+ }
+
+
host = scsi_host_alloc(&scsi_driver,
sizeof(struct hv_host_device));
if (!host)
@@ -1601,7 +1733,8 @@ static int __init storvsc_drv_init(void)
max_outstanding_req_per_channel =
((storvsc_ringbuffer_size - PAGE_SIZE) /
ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
- sizeof(struct vstor_packet) + sizeof(u64),
+ sizeof(struct vstor_packet) + sizeof(u64) -
+ vmscsi_size_delta,
sizeof(u64)));

if (max_outstanding_req_per_channel <
--
1.7.4.1

2013-06-11 13:03:12

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc



> -----Original Message-----
> From: K. Y. Srinivasan [mailto:[email protected]]
> Sent: Tuesday, June 04, 2013 3:05 PM
> To: [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Cc: KY Srinivasan
> Subject: [PATCH V3 0/5] Drivers: scsi: storvsc
>
> This set adds multi-channel support as well synthetic Fibre Channel support
> to storvsc. The multi-channel support depends on infrastructure in the VMBUS
> driver. Greg has already checked in the relevant patches to VMBUS.
>
> I had posted an earlier version of this patch-set that included the VMBUS
> related changes. I have since separated the VMBUS chages and these have
> already been
> checked in.
>
> In this version, based on comments from James, the timeout is no longer a
> module
> parameter.

James,

I think I have addressed all the comments that you had; if not, please let me know.

Regards,

K. Y
>
> K. Y. Srinivasan (5):
> Drivers: scsi: storvsc: Increase the value of scsi timeout for
> storvsc devices
> Drivers: scsi: storvsc: Update the storage protocol to win8 level
> Drivers: scsi: storvsc: Implement multi-channel support
> Drivers: scsi: storvsc: Support FC devices
> Drivers: scsi: storvsc: Increase the value of STORVSC_MAX_IO_REQUESTS
>
> drivers/scsi/storvsc_drv.c | 347
> +++++++++++++++++++++++++++++++++++++++-----
> 1 files changed, 308 insertions(+), 39 deletions(-)
>
> --
> 1.7.4.1
>
>

2013-06-17 13:33:33

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc



> -----Original Message-----
> From: KY Srinivasan
> Sent: Tuesday, June 11, 2013 9:02 AM
> To: KY Srinivasan; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc
>
>
>
> > -----Original Message-----
> > From: K. Y. Srinivasan [mailto:[email protected]]
> > Sent: Tuesday, June 04, 2013 3:05 PM
> > To: [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]
> > Cc: KY Srinivasan
> > Subject: [PATCH V3 0/5] Drivers: scsi: storvsc
> >
> > This set adds multi-channel support as well synthetic Fibre Channel support
> > to storvsc. The multi-channel support depends on infrastructure in the VMBUS
> > driver. Greg has already checked in the relevant patches to VMBUS.
> >
> > I had posted an earlier version of this patch-set that included the VMBUS
> > related changes. I have since separated the VMBUS chages and these have
> > already been
> > checked in.
> >
> > In this version, based on comments from James, the timeout is no longer a
> > module
> > parameter.
>
> James,
>
> I think I have addressed all the comments that you had; if not, please let me
> know.

Ping.

Regards,

K. Y

2013-06-26 12:59:29

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc



> -----Original Message-----
> From: KY Srinivasan
> Sent: Monday, June 17, 2013 9:32 AM
> To: [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc
>
>
>
> > -----Original Message-----
> > From: KY Srinivasan
> > Sent: Tuesday, June 11, 2013 9:02 AM
> > To: KY Srinivasan; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]
> > Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc
> >
> >
> >
> > > -----Original Message-----
> > > From: K. Y. Srinivasan [mailto:[email protected]]
> > > Sent: Tuesday, June 04, 2013 3:05 PM
> > > To: [email protected]; [email protected];
> > > [email protected]; [email protected];
> [email protected];
> > > [email protected]; [email protected]
> > > Cc: KY Srinivasan
> > > Subject: [PATCH V3 0/5] Drivers: scsi: storvsc
> > >
> > > This set adds multi-channel support as well synthetic Fibre Channel support
> > > to storvsc. The multi-channel support depends on infrastructure in the
> VMBUS
> > > driver. Greg has already checked in the relevant patches to VMBUS.
> > >
> > > I had posted an earlier version of this patch-set that included the VMBUS
> > > related changes. I have since separated the VMBUS chages and these have
> > > already been
> > > checked in.
> > >
> > > In this version, based on comments from James, the timeout is no longer a
> > > module
> > > parameter.
> >
> > James,
> >
> > I think I have addressed all the comments that you had; if not, please let me
> > know.
>
> Ping.

James,

Let me know if I should re-send the patches.

Thanks,

K. Y

2013-06-27 03:22:29

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH 3/5] Drivers: scsi: storvsc: Implement multi-channel support

On Tue, 2013-06-04 at 12:05 -0700, K. Y. Srinivasan wrote:
> Implement multi-channel support for the storage devices.

This doesn't compile:

CC [M] drivers/scsi/storvsc_drv.o
drivers/scsi/storvsc_drv.c: In function ‘handle_sc_creation’:
drivers/scsi/storvsc_drv.c:763:35: error: ‘struct vmbus_channel’ has no
member named ‘primary_channel’
drivers/scsi/storvsc_drv.c: In function ‘handle_multichannel_storage’:
drivers/scsi/storvsc_drv.c:805:2: error: implicit declaration of
function
‘vmbus_set_sc_create_callback’ [-Werror=implicit-function-declaration]
drivers/scsi/storvsc_drv.c:812:2: error: implicit declaration of
function
‘vmbus_are_subchannels_present’ [-Werror=implicit-function-declaration]
drivers/scsi/storvsc_drv.c: In function ‘storvsc_on_channel_callback’:
drivers/scsi/storvsc_drv.c:1223:13: error: ‘struct vmbus_channel’ has no
member named ‘primary_channel’
drivers/scsi/storvsc_drv.c:1224:19: error: ‘struct vmbus_channel’ has no
member named ‘primary_channel’
drivers/scsi/storvsc_drv.c: In function ‘storvsc_do_io’:
drivers/scsi/storvsc_drv.c:1341:2: error: implicit declaration of
function
‘vmbus_get_outgoing_channel’ [-Werror=implicit-function-declaration]
drivers/scsi/storvsc_drv.c:1341:19: warning: assignment makes pointer
from integer without a cast [enabled by default]
cc1: some warnings being treated as errors
make[2]: *** [drivers/scsi/storvsc_drv.o] Error 1

I assume this is a cross tree dependency? What's the relevant branch I
need?

James

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-06-27 03:39:13

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH V3 0/5] Drivers: scsi: storvsc

On Wed, 2013-06-26 at 12:58 +0000, KY Srinivasan wrote:
>
> > -----Original Message-----
> > From: KY Srinivasan
> > Sent: Monday, June 17, 2013 9:32 AM
> > To: [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]
> > Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc
> >
> >
> >
> > > -----Original Message-----
> > > From: KY Srinivasan
> > > Sent: Tuesday, June 11, 2013 9:02 AM
> > > To: KY Srinivasan; [email protected]; [email protected];
> > > [email protected]; [email protected]; [email protected];
> > > [email protected]; [email protected]
> > > Subject: RE: [PATCH V3 0/5] Drivers: scsi: storvsc
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: K. Y. Srinivasan [mailto:[email protected]]
> > > > Sent: Tuesday, June 04, 2013 3:05 PM
> > > > To: [email protected]; [email protected];
> > > > [email protected]; [email protected];
> > [email protected];
> > > > [email protected]; [email protected]
> > > > Cc: KY Srinivasan
> > > > Subject: [PATCH V3 0/5] Drivers: scsi: storvsc
> > > >
> > > > This set adds multi-channel support as well synthetic Fibre Channel support
> > > > to storvsc. The multi-channel support depends on infrastructure in the
> > VMBUS
> > > > driver. Greg has already checked in the relevant patches to VMBUS.
> > > >
> > > > I had posted an earlier version of this patch-set that included the VMBUS
> > > > related changes. I have since separated the VMBUS chages and these have
> > > > already been
> > > > checked in.
> > > >
> > > > In this version, based on comments from James, the timeout is no longer a
> > > > module
> > > > parameter.
> > >
> > > James,
> > >
> > > I think I have addressed all the comments that you had; if not, please let me
> > > know.
> >
> > Ping.
>
> James,
>
> Let me know if I should re-send the patches.

Just FYI, my workflow involves using imap flags to tag stuff for actions
and then using a set of date sorted evolution search folders to
translate the flags into work queues. The search folders are by flag
and thread, so a side effect of the way evolution does date ordering is
that it's ordered by the most recent last, so the date it takes for
thread ordering is the most recent email in the thread. Originally, I
thought of this as an annyoing evolution bug because I wanted the folder
ordered by date of the patch submission. However, later I came to
appreciate that it meant currently actively discussed patches moved down
in my workqueue automatically, so now I quite like it as a feature. It
does mean, however, that the net effect of sending very frequent pings
about a patch set is to cause that patch set to move down in my work
queue and, unfortunately, even coming from a domain that habitually
breaks threading doesn't save you because evolution helpfully has a set
of heuristic rules to rethread outlook breakage.

James

2013-06-27 11:50:34

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH 3/5] Drivers: scsi: storvsc: Implement multi-channel support



> -----Original Message-----
> From: James Bottomley [mailto:[email protected]]
> Sent: Wednesday, June 26, 2013 11:22 PM
> To: KY Srinivasan
> Cc: [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; linux-
> [email protected]
> Subject: Re: [PATCH 3/5] Drivers: scsi: storvsc: Implement multi-channel support
>
> On Tue, 2013-06-04 at 12:05 -0700, K. Y. Srinivasan wrote:
> > Implement multi-channel support for the storage devices.
>
> This doesn't compile:
>
> CC [M] drivers/scsi/storvsc_drv.o
> drivers/scsi/storvsc_drv.c: In function ‘handle_sc_creation’:
> drivers/scsi/storvsc_drv.c:763:35: error: ‘struct vmbus_channel’ has no
> member named ‘primary_channel’
> drivers/scsi/storvsc_drv.c: In function ‘handle_multichannel_storage’:
> drivers/scsi/storvsc_drv.c:805:2: error: implicit declaration of
> function
> ‘vmbus_set_sc_create_callback’ [-Werror=implicit-function-declaration]
> drivers/scsi/storvsc_drv.c:812:2: error: implicit declaration of
> function
> ‘vmbus_are_subchannels_present’ [-Werror=implicit-function-declaration]
> drivers/scsi/storvsc_drv.c: In function ‘storvsc_on_channel_callback’:
> drivers/scsi/storvsc_drv.c:1223:13: error: ‘struct vmbus_channel’ has no
> member named ‘primary_channel’
> drivers/scsi/storvsc_drv.c:1224:19: error: ‘struct vmbus_channel’ has no
> member named ‘primary_channel’
> drivers/scsi/storvsc_drv.c: In function ‘storvsc_do_io’:
> drivers/scsi/storvsc_drv.c:1341:2: error: implicit declaration of
> function
> ‘vmbus_get_outgoing_channel’ [-Werror=implicit-function-declaration]
> drivers/scsi/storvsc_drv.c:1341:19: warning: assignment makes pointer
> from integer without a cast [enabled by default]
> cc1: some warnings being treated as errors
> make[2]: *** [drivers/scsi/storvsc_drv.o] Error 1
>
> I assume this is a cross tree dependency? What's the relevant branch I
> need?

You are right; Greg checked in the relevant patch sometime back:

git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.


Regards,

K. Y

>
> James

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?