[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <PH7PR21MB3263771C4EA7933604EB66E6CED39@PH7PR21MB3263.namprd21.prod.outlook.com>
Date: Fri, 20 May 2022 19:22:35 +0000
From: Long Li <longli@...rosoft.com>
To: Saurabh Sengar <ssengar@...ux.microsoft.com>,
Saurabh Singh Sengar <ssengar@...rosoft.com>,
KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
"wei.liu@...nel.org" <wei.liu@...nel.org>,
Dexuan Cui <decui@...rosoft.com>,
"jejb@...ux.ibm.com" <jejb@...ux.ibm.com>,
"martin.petersen@...cle.com" <martin.petersen@...cle.com>,
"Michael Kelley (LINUX)" <mikelley@...rosoft.com>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] scsi: storvsc: Removing Pre Win8 related logic
> Subject: [PATCH] scsi: storvsc: Removing Pre Win8 related logic
>
> The latest storvsc code has already removed the support for windows 7 and
> earlier. There is still some code logic reamining which is there to support pre
> Windows 8 OS. This patch removes these stale logic.
> This patch majorly does three things :
>
> 1. Removes vmscsi_size_delta and its logic, as the vmscsi_request struct is same
> for all the OS post windows 8 there is no need of delta.
> 2. Simplify sense_buffer_size logic, as there is single buffer size for all the post
> windows 8 OS.
> 3. Embed the vmscsi_win8_extension structure inside the vmscsi_request, as
> there is no separate handling required for different OS.
>
> Signed-off-by: Saurabh Sengar <ssengar@...ux.microsoft.com>
> ---
> drivers/scsi/storvsc_drv.c | 135 +++++++++----------------------------
> 1 file changed, 33 insertions(+), 102 deletions(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index
> 5585e9d30bbf..1b7808e91f0b 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -137,18 +137,16 @@ struct hv_fc_wwn_packet {
> #define STORVSC_MAX_CMD_LEN 0x10
>
> #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. This value will
> - * likely change during protocol negotiation but it is valid
> - * to start by assuming pre-Win8.
> + * Sense buffer size was differnt pre win8 but those OS are not
> + supported any
> + * more starting 5.19 kernel. This results in to supporting a single
> + value from
> + * win8 onwards.
> */
> -static int sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
> +static int sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
>
> /*
> * The storage protocol version is determined during the
> @@ -177,18 +175,6 @@ do {
> \
> dev_warn(&(dev)->device, fmt, ##__VA_ARGS__); \
> } while (0)
>
> -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;
> @@ -214,46 +200,23 @@ struct vmscsi_request {
> /*
> * The following was added in win8.
> */
> - struct vmscsi_win8_extension win8_extension;
> + u16 reserve;
> + u8 queue_tag;
> + u8 queue_action;
> + u32 srb_flags;
> + u32 time_out_value;
> + u32 queue_sort_ey;
>
> } __attribute((packed));
>
> /*
> - * The list of storage protocols in order of preference.
> + * The list of windows version in order of preference.
> */
> -struct vmstor_protocol {
> - int protocol_version;
> - int sense_buffer_size;
> - int vmscsi_size_delta;
> -};
>
> -
> -static const struct vmstor_protocol vmstor_protocols[] = {
> - {
> +static const int protocol_version[] = {
> VMSTOR_PROTO_VERSION_WIN10,
> - POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
> - 0
> - },
> - {
> VMSTOR_PROTO_VERSION_WIN8_1,
> - POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
> - 0
> - },
> - {
> VMSTOR_PROTO_VERSION_WIN8,
> - POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
> - 0
> - },
> - {
> - VMSTOR_PROTO_VERSION_WIN7,
> - PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE,
> - sizeof(struct vmscsi_win8_extension),
> - },
> - {
> - VMSTOR_PROTO_VERSION_WIN6,
> - PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE,
> - sizeof(struct vmscsi_win8_extension),
> - }
> };
>
>
> @@ -409,9 +372,7 @@ static void storvsc_on_channel_callback(void *context);
> #define STORVSC_IDE_MAX_CHANNELS 1
>
> /*
> - * Upper bound on the size of a storvsc packet. vmscsi_size_delta is not
> - * included in the calculation because it is set after STORVSC_MAX_PKT_SIZE
> - * is used in storvsc_connect_to_vsp
> + * Upper bound on the size of a storvsc packet.
> */
> #define STORVSC_MAX_PKT_SIZE (sizeof(struct vmpacket_descriptor) +\
> sizeof(struct vstor_packet))
> @@ -452,17 +413,6 @@ struct storvsc_device {
> unsigned char path_id;
> unsigned char target_id;
>
> - /*
> - * 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. This value
> - * will likely change during protocol negotiation but it is
> - * valid to start by assuming pre-Win8.
> - */
> - int vmscsi_size_delta;
> -
> /*
> * Max I/O, the device can support.
> */
> @@ -795,8 +745,7 @@ static void handle_multichannel_storage(struct
> hv_device *device, int max_chns)
> vstor_packet->sub_channel_count = num_sc;
>
> ret = vmbus_sendpacket(device->channel, vstor_packet,
> - (sizeof(struct vstor_packet) -
> - stor_device->vmscsi_size_delta),
> + sizeof(struct vstor_packet),
> VMBUS_RQST_INIT,
> VM_PKT_DATA_INBAND,
>
> VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> @@ -864,8 +813,7 @@ static int storvsc_execute_vstor_op(struct hv_device
> *device,
> vstor_packet->flags = REQUEST_COMPLETION_FLAG;
>
> ret = vmbus_sendpacket(device->channel, vstor_packet,
> - (sizeof(struct vstor_packet) -
> - stor_device->vmscsi_size_delta),
> + sizeof(struct vstor_packet),
> VMBUS_RQST_INIT,
> VM_PKT_DATA_INBAND,
>
> VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> @@ -915,14 +863,13 @@ static int storvsc_channel_init(struct hv_device
> *device, bool is_fc)
> * Query host supported protocol version.
> */
>
> - for (i = 0; i < ARRAY_SIZE(vmstor_protocols); i++) {
> + for (i = 0; i < ARRAY_SIZE(protocol_version); i++) {
> /* reuse the packet for version range supported */
> memset(vstor_packet, 0, sizeof(struct vstor_packet));
> vstor_packet->operation =
> VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
>
> - vstor_packet->version.major_minor =
> - vmstor_protocols[i].protocol_version;
> + vstor_packet->version.major_minor = protocol_version[i];
>
> /*
> * The revision number is only used in Windows; set it to 0.
> @@ -936,14 +883,7 @@ static int storvsc_channel_init(struct hv_device *device,
> bool is_fc)
> return -EINVAL;
>
> if (vstor_packet->status == 0) {
> - vmstor_proto_version =
> - vmstor_protocols[i].protocol_version;
> -
> - sense_buffer_size =
> - vmstor_protocols[i].sense_buffer_size;
> -
> - stor_device->vmscsi_size_delta =
> - vmstor_protocols[i].vmscsi_size_delta;
> + vmstor_proto_version = protocol_version[i];
>
> break;
> }
Now the code for querying versions will fail on earlier Hyper-V versions, unlike the pre-patch code it will never fail.
Can you use a dev_err() to indicate this failure? This can help customers running into this and they will not call support.
Long
Powered by blists - more mailing lists