diff mbox

[RESEND,V2,3/7] scsi: storvsc: Untangle the storage protocol negotiation from the vmbus protocol negotiation.

Message ID 1439480632-11144-3-git-send-email-kys@microsoft.com (mailing list archive)
State New, archived
Headers show

Commit Message

KY Srinivasan Aug. 13, 2015, 3:43 p.m. UTC
From: Keith Mange <keith.mange@microsoft.com>

Currently we are making decisions based on vmbus protocol versions
that have been negotiated; use storage potocol versions instead.

Tested-by: Alex Ng <alexng@microsoft.com>
Signed-off-by: Keith Mange <keith.mange@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/scsi/storvsc_drv.c |  109 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 87 insertions(+), 22 deletions(-)

Comments

Johannes Thumshirn Aug. 13, 2015, 2:33 p.m. UTC | #1
"K. Y. Srinivasan" <kys@microsoft.com> writes:

> From: Keith Mange <keith.mange@microsoft.com>
>
> Currently we are making decisions based on vmbus protocol versions
> that have been negotiated; use storage potocol versions instead.
>
> Tested-by: Alex Ng <alexng@microsoft.com>
> Signed-off-by: Keith Mange <keith.mange@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  drivers/scsi/storvsc_drv.c |  109 +++++++++++++++++++++++++++++++++++---------
>  1 files changed, 87 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 5f9d133..f29871e 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -56,14 +56,18 @@
>   * V1 RC > 2008/1/31:  2.0
>   * Win7: 4.2
>   * Win8: 5.1
> + * Win8.1: 6.0
> + * Win10: 6.2
>   */
>  
>  #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
>  						(((MINOR_) & 0xff)))
>  
> +#define VMSTOR_PROTO_VERSION_WIN6	VMSTOR_PROTO_VERSION(2, 0)
>  #define VMSTOR_PROTO_VERSION_WIN7	VMSTOR_PROTO_VERSION(4, 2)
>  #define VMSTOR_PROTO_VERSION_WIN8	VMSTOR_PROTO_VERSION(5, 1)
> -
> +#define VMSTOR_PROTO_VERSION_WIN8_1	VMSTOR_PROTO_VERSION(6, 0)
> +#define VMSTOR_PROTO_VERSION_WIN10	VMSTOR_PROTO_VERSION(6, 2)
>  
>  /*  Packet structure describing virtual storage requests. */
>  enum vstor_packet_operation {
> @@ -205,6 +209,46 @@ struct vmscsi_request {
>  
>  
>  /*
> + * The list of storage protocols in order of preference.
> + */
> +struct vmstor_protocol {
> +	int protocol_version;
> +	int sense_buffer_size;
> +	int vmscsi_size_delta;
> +};
> +
> +#define VMSTOR_NUM_PROTOCOLS    5

can't you just use ARRAY_SIZE() here, so you don't have to touch the
constant every time a new protocol is appended to the list?

> +
> +const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {
> +	{
> +		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),
> +	}
> +};
> +

Thanks,
        Johannes
KY Srinivasan Aug. 13, 2015, 3:18 p.m. UTC | #2
> -----Original Message-----

> From: Johannes Thumshirn [mailto:jthumshirn@suse.de]

> Sent: Thursday, August 13, 2015 7:34 AM

> To: KY Srinivasan <kys@microsoft.com>; Keith Mange

> <Keith.Mange@microsoft.com>

> Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org;

> devel@linuxdriverproject.org; ohering@suse.com;

> jbottomley@parallels.com; hch@infradead.org; linux-scsi@vger.kernel.org;

> apw@canonical.com; vkuznets@redhat.com; jasowang@redhat.com

> Subject: Re: [PATCH RESEND V2 3/7] scsi: storvsc: Untangle the storage

> protocol negotiation from the vmbus protocol negotiation.

> 

> "K. Y. Srinivasan" <kys@microsoft.com> writes:

> 

> > From: Keith Mange <keith.mange@microsoft.com>

> >

> > Currently we are making decisions based on vmbus protocol versions

> > that have been negotiated; use storage potocol versions instead.

> >

> > Tested-by: Alex Ng <alexng@microsoft.com>

> > Signed-off-by: Keith Mange <keith.mange@microsoft.com>

> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

> > ---

> >  drivers/scsi/storvsc_drv.c |  109

> +++++++++++++++++++++++++++++++++++---------

> >  1 files changed, 87 insertions(+), 22 deletions(-)

> >

> > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c

> > index 5f9d133..f29871e 100644

> > --- a/drivers/scsi/storvsc_drv.c

> > +++ b/drivers/scsi/storvsc_drv.c

> > @@ -56,14 +56,18 @@

> >   * V1 RC > 2008/1/31:  2.0

> >   * Win7: 4.2

> >   * Win8: 5.1

> > + * Win8.1: 6.0

> > + * Win10: 6.2

> >   */

> >

> >  #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)	((((MAJOR_)

> & 0xff) << 8) | \

> >  						(((MINOR_) & 0xff)))

> >

> > +#define VMSTOR_PROTO_VERSION_WIN6

> 	VMSTOR_PROTO_VERSION(2, 0)

> >  #define VMSTOR_PROTO_VERSION_WIN7

> 	VMSTOR_PROTO_VERSION(4, 2)

> >  #define VMSTOR_PROTO_VERSION_WIN8

> 	VMSTOR_PROTO_VERSION(5, 1)

> > -

> > +#define VMSTOR_PROTO_VERSION_WIN8_1

> 	VMSTOR_PROTO_VERSION(6, 0)

> > +#define VMSTOR_PROTO_VERSION_WIN10

> 	VMSTOR_PROTO_VERSION(6, 2)

> >

> >  /*  Packet structure describing virtual storage requests. */

> >  enum vstor_packet_operation {

> > @@ -205,6 +209,46 @@ struct vmscsi_request {

> >

> >

> >  /*

> > + * The list of storage protocols in order of preference.

> > + */

> > +struct vmstor_protocol {

> > +	int protocol_version;

> > +	int sense_buffer_size;

> > +	int vmscsi_size_delta;

> > +};

> > +

> > +#define VMSTOR_NUM_PROTOCOLS    5

> 

> can't you just use ARRAY_SIZE() here, so you don't have to touch the

> constant every time a new protocol is appended to the list?


Certainly. These patches have been floating around for more than a month now and if it is ok
with you, I will submit a patch on top of this current series to address the concern you have raised.
James, please let me know.

Regards,

K. Y 
> 

> > +

> > +const struct vmstor_protocol

> vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {

> > +	{

> > +		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),

> > +	}

> > +};

> > +

> 

> Thanks,

>         Johannes

> --

> Johannes Thumshirn                                           Storage

> jthumshirn@suse.de                                 +49 911 74053 689

> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg

> GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton

> HRB 21284 (AG Nürnberg)

> Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
Johannes Thumshirn Aug. 14, 2015, 6:45 a.m. UTC | #3
KY Srinivasan <kys@microsoft.com> writes:

>> -----Original Message-----
>> From: Johannes Thumshirn [mailto:jthumshirn@suse.de]
>> Sent: Thursday, August 13, 2015 7:34 AM
>> To: KY Srinivasan <kys@microsoft.com>; Keith Mange
>> <Keith.Mange@microsoft.com>
>> Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org;
>> devel@linuxdriverproject.org; ohering@suse.com;
>> jbottomley@parallels.com; hch@infradead.org; linux-scsi@vger.kernel.org;
>> apw@canonical.com; vkuznets@redhat.com; jasowang@redhat.com
>> Subject: Re: [PATCH RESEND V2 3/7] scsi: storvsc: Untangle the storage
>> protocol negotiation from the vmbus protocol negotiation.
>> 
>> "K. Y. Srinivasan" <kys@microsoft.com> writes:
>> 
>> > From: Keith Mange <keith.mange@microsoft.com>
>> >
>> > Currently we are making decisions based on vmbus protocol versions
>> > that have been negotiated; use storage potocol versions instead.
>> >
>> > Tested-by: Alex Ng <alexng@microsoft.com>
>> > Signed-off-by: Keith Mange <keith.mange@microsoft.com>
>> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
>> > ---
>> >  drivers/scsi/storvsc_drv.c |  109
>> +++++++++++++++++++++++++++++++++++---------
>> >  1 files changed, 87 insertions(+), 22 deletions(-)
>> >
>> > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
>> > index 5f9d133..f29871e 100644
>> > --- a/drivers/scsi/storvsc_drv.c
>> > +++ b/drivers/scsi/storvsc_drv.c
>> > @@ -56,14 +56,18 @@
>> >   * V1 RC > 2008/1/31:  2.0
>> >   * Win7: 4.2
>> >   * Win8: 5.1
>> > + * Win8.1: 6.0
>> > + * Win10: 6.2
>> >   */
>> >
>> >  #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)	((((MAJOR_)
>> & 0xff) << 8) | \
>> >  						(((MINOR_) & 0xff)))
>> >
>> > +#define VMSTOR_PROTO_VERSION_WIN6
>> 	VMSTOR_PROTO_VERSION(2, 0)
>> >  #define VMSTOR_PROTO_VERSION_WIN7
>> 	VMSTOR_PROTO_VERSION(4, 2)
>> >  #define VMSTOR_PROTO_VERSION_WIN8
>> 	VMSTOR_PROTO_VERSION(5, 1)
>> > -
>> > +#define VMSTOR_PROTO_VERSION_WIN8_1
>> 	VMSTOR_PROTO_VERSION(6, 0)
>> > +#define VMSTOR_PROTO_VERSION_WIN10
>> 	VMSTOR_PROTO_VERSION(6, 2)
>> >
>> >  /*  Packet structure describing virtual storage requests. */
>> >  enum vstor_packet_operation {
>> > @@ -205,6 +209,46 @@ struct vmscsi_request {
>> >
>> >
>> >  /*
>> > + * The list of storage protocols in order of preference.
>> > + */
>> > +struct vmstor_protocol {
>> > +	int protocol_version;
>> > +	int sense_buffer_size;
>> > +	int vmscsi_size_delta;
>> > +};
>> > +
>> > +#define VMSTOR_NUM_PROTOCOLS    5
>> 
>> can't you just use ARRAY_SIZE() here, so you don't have to touch the
>> constant every time a new protocol is appended to the list?
>
> Certainly. These patches have been floating around for more than a month now and if it is ok
> with you, I will submit a patch on top of this current series to address the concern you have raised.
> James, please let me know.
>

No objections from my side, but it's up to James to decide what and when
he picks up patches.

Thanks,
        Johannes
KY Srinivasan Aug. 14, 2015, 7:26 p.m. UTC | #4
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogSm9oYW5uZXMgVGh1bXNo
aXJuIFttYWlsdG86anRodW1zaGlybkBzdXNlLmRlXQ0KPiBTZW50OiBUaHVyc2RheSwgQXVndXN0
IDEzLCAyMDE1IDExOjQ2IFBNDQo+IFRvOiBLWSBTcmluaXZhc2FuIDxreXNAbWljcm9zb2Z0LmNv
bT4NCj4gQ2M6IEtlaXRoIE1hbmdlIDxLZWl0aC5NYW5nZUBtaWNyb3NvZnQuY29tPjsNCj4gZ3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UgQVJSQVlfU0laRSgpIGhlcmUsIHNv
IHlvdSBkb24ndCBoYXZlIHRvIHRvdWNoIHRoZQ0KPiA+PiBjb25zdGFudCBldmVyeSB0aW1lIGEg
bmV3IHByb3RvY29sIGlzIGFwcGVuZGVkIHRvIHRoZSBsaXN0Pw0KPiA+DQo+ID4gQ2VydGFpbmx5
LiBUaGVzZSBwYXRjaGVzIGhhdmUgYmVlbiBmbG9hdGluZyBhcm91bmQgZm9yIG1vcmUgdGhhbiBh
IG1vbnRoDQo+IG5vdyBhbmQgaWYgaXQgaXMgb2sNCj4gPiB3aXRoIHlvdSwgSSB3aWxsIHN1Ym1p
dCBhIHBhdGNoIG9uIHRvcCBvZiB0aGlzIGN1cnJlbnQgc2VyaWVzIHRvIGFkZHJlc3MgdGhlDQo+
IGNvbmNlcm4geW91IGhhdmUgcmFpc2VkLg0KPiA+IEphbWVzLCBwbGVhc2UgbGV0IG1lIGtub3cu
DQo+ID4NCj4gDQo+IE5vIG9iamVjdGlvbnMgZnJvbSBteSBzaWRlLCBidXQgaXQncyB1cCB0byBK
YW1lcyB0byBkZWNpZGUgd2hhdCBhbmQgd2hlbg0KPiBoZSBwaWNrcyB1cCBwYXRjaGVzLg0KDQpK
YW1lcywNCg0KSSBoYXZlIHNlbnQgYSBzZXBhcmF0ZSBwYXRjaCBvbiB0b3Agb2YgdGhlIHNldCBJ
IHNlbnQgeWVzdGVyZGF5IHRoYXQgYWRkcmVzc2VzIEpvaGFubmVzJyBjb21tZW50cy4NCg0KUmVn
YXJkcywNCg0KSy4gWQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Bottomley Aug. 27, 2015, 1:40 a.m. UTC | #5
On Thu, 2015-08-13 at 08:43 -0700, K. Y. Srinivasan wrote:
> From: Keith Mange <keith.mange@microsoft.com>
> 
> Currently we are making decisions based on vmbus protocol versions
> that have been negotiated; use storage potocol versions instead.
> 
> Tested-by: Alex Ng <alexng@microsoft.com>
> Signed-off-by: Keith Mange <keith.mange@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  drivers/scsi/storvsc_drv.c |  109 +++++++++++++++++++++++++++++++++++---------
>  1 files changed, 87 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 5f9d133..f29871e 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -56,14 +56,18 @@
>   * V1 RC > 2008/1/31:  2.0
>   * Win7: 4.2
>   * Win8: 5.1
> + * Win8.1: 6.0
> + * Win10: 6.2
>   */
>  
>  #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
>  						(((MINOR_) & 0xff)))
>  
> +#define VMSTOR_PROTO_VERSION_WIN6	VMSTOR_PROTO_VERSION(2, 0)
>  #define VMSTOR_PROTO_VERSION_WIN7	VMSTOR_PROTO_VERSION(4, 2)
>  #define VMSTOR_PROTO_VERSION_WIN8	VMSTOR_PROTO_VERSION(5, 1)
> -
> +#define VMSTOR_PROTO_VERSION_WIN8_1	VMSTOR_PROTO_VERSION(6, 0)
> +#define VMSTOR_PROTO_VERSION_WIN10	VMSTOR_PROTO_VERSION(6, 2)
>  
>  /*  Packet structure describing virtual storage requests. */
>  enum vstor_packet_operation {
> @@ -205,6 +209,46 @@ struct vmscsi_request {
>  
> 
>  /*
> + * The list of storage protocols in order of preference.
> + */
> +struct vmstor_protocol {
> +	int protocol_version;
> +	int sense_buffer_size;
> +	int vmscsi_size_delta;
> +};
> +
> +#define VMSTOR_NUM_PROTOCOLS    5
> +
> +const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {

Sparse doesn't like this not being static:

  CHECK   drivers/scsi/storvsc_drv.c
drivers/scsi/storvsc_drv.c:221:30: warning: symbol 'vmstor_protocols'
was not declared. Should it be static?
 
I fixed it up.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 5f9d133..f29871e 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -56,14 +56,18 @@ 
  * V1 RC > 2008/1/31:  2.0
  * Win7: 4.2
  * Win8: 5.1
+ * Win8.1: 6.0
+ * Win10: 6.2
  */
 
 #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
 						(((MINOR_) & 0xff)))
 
+#define VMSTOR_PROTO_VERSION_WIN6	VMSTOR_PROTO_VERSION(2, 0)
 #define VMSTOR_PROTO_VERSION_WIN7	VMSTOR_PROTO_VERSION(4, 2)
 #define VMSTOR_PROTO_VERSION_WIN8	VMSTOR_PROTO_VERSION(5, 1)
-
+#define VMSTOR_PROTO_VERSION_WIN8_1	VMSTOR_PROTO_VERSION(6, 0)
+#define VMSTOR_PROTO_VERSION_WIN10	VMSTOR_PROTO_VERSION(6, 2)
 
 /*  Packet structure describing virtual storage requests. */
 enum vstor_packet_operation {
@@ -205,6 +209,46 @@  struct vmscsi_request {
 
 
 /*
+ * The list of storage protocols in order of preference.
+ */
+struct vmstor_protocol {
+	int protocol_version;
+	int sense_buffer_size;
+	int vmscsi_size_delta;
+};
+
+#define VMSTOR_NUM_PROTOCOLS    5
+
+const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {
+	{
+		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),
+	}
+};
+
+
+/*
  * This structure is sent during the intialization phase to get the different
  * properties of the channel.
  */
@@ -871,7 +915,7 @@  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 ret, t, i;
 	int max_chns;
 	bool process_sub_channels = false;
 
@@ -911,36 +955,59 @@  static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 
 
-	/* 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->flags = REQUEST_COMPLETION_FLAG;
+	for (i = 0; i < VMSTOR_NUM_PROTOCOLS; 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->flags = REQUEST_COMPLETION_FLAG;
 
-	vstor_packet->version.major_minor = vmstor_proto_version;
+		vstor_packet->version.major_minor =
+			vmstor_protocols[i].protocol_version;
 
-	/*
-	 * The revision number is only used in Windows; set it to 0.
-	 */
-	vstor_packet->version.revision = 0;
+		/*
+		 * The revision number is only used in Windows; set it to 0.
+		 */
+		vstor_packet->version.revision = 0;
 
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
+		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)
-		goto cleanup;
+		if (ret != 0)
+			goto cleanup;
 
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
+		t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+		if (t == 0) {
+			ret = -ETIMEDOUT;
+			goto cleanup;
+		}
+
+		if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO) {
+			ret = -EINVAL;
+			goto cleanup;
+		}
+
+		if (vstor_packet->status == 0) {
+			vmstor_proto_version =
+				vmstor_protocols[i].protocol_version;
+
+			sense_buffer_size =
+				vmstor_protocols[i].sense_buffer_size;
+
+			vmscsi_size_delta =
+				vmstor_protocols[i].vmscsi_size_delta;
+
+			break;
+		}
 	}
 
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
+	if (vstor_packet->status != 0) {
+		ret = -EINVAL;
 		goto cleanup;
+	}
 
 
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
@@ -1745,14 +1812,12 @@  static int storvsc_probe(struct hv_device *device,
 	if (vmbus_proto_version < VERSION_WIN8) {
 		sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
 		vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
-		vmstor_proto_version = VMSTOR_PROTO_VERSION_WIN7;
 		max_luns_per_target = STORVSC_IDE_MAX_LUNS_PER_TARGET;
 		max_targets = STORVSC_IDE_MAX_TARGETS;
 		max_channels = STORVSC_IDE_MAX_CHANNELS;
 	} else {
 		sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
 		vmscsi_size_delta = 0;
-		vmstor_proto_version = VMSTOR_PROTO_VERSION_WIN8;
 		max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET;
 		max_targets = STORVSC_MAX_TARGETS;
 		max_channels = STORVSC_MAX_CHANNELS;