linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
@ 2015-07-01  9:04 Vitaly Kuznetsov
  2015-07-03 16:19 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Vitaly Kuznetsov @ 2015-07-01  9:04 UTC (permalink / raw)
  To: linux-scsi
  Cc: Long Li, K. Y. Srinivasan, Haiyang Zhang, James E.J. Bottomley,
	devel, linux-kernel

SPC-2/3/4 specs state that "The standard INQUIRY data (see table ...)
shall contain at least 36 bytes". Hyper-V host doesn't always honor this
requirement, e.g. when there is no physical device present at a particular
LUN host sets Peripheral qualifier to 011b and Additional length to 0
(thus making the reply 5-bytes long). Upper level SCSI stack complains
with 'INQUIRY result too short (5), using 36'. Fix the issue by mangling
Additional length field in host's reply at the driver level.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
This is a hack, the proper fix should probably be done in Hyper-V.
---
 drivers/scsi/storvsc_drv.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 3c6584f..bca31af 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1153,6 +1153,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 {
 	struct storvsc_device *stor_device;
 	struct vstor_packet *stor_pkt;
+	struct vmbus_packet_mpb_array *payload = request->payload;
 
 	stor_device = hv_get_drvdata(device);
 	stor_pkt = &request->vstor_packet;
@@ -1174,6 +1175,24 @@ static void storvsc_on_io_completion(struct hv_device *device,
 		vstor_packet->vm_srb.srb_status = SRB_STATUS_SUCCESS;
 	}
 
+	/*
+	 * When there is no physical device attached to a LUN Hyper-V host
+	 * sets Peripheral qualifier to 011b and Additional length to 0. SPC
+	 * spec, however, says that "The standard INQUIRY data ... shall
+	 * contain at least 36 bytes". Upper level SCSI stack complains with
+	 * 'INQUIRY result too short (5), using 36'. Mangle host's reply here.
+	 */
+	if (stor_pkt->vm_srb.cdb[0] == INQUIRY && payload) {
+		u8 *buf, per_qual, data_len;
+		int range_len = payload->range.len;
+
+		buf = phys_to_virt(payload->range.pfn_array[0] << PAGE_SHIFT) +
+			payload->range.offset;
+		per_qual = (buf[0] >> 5) & 7;
+		data_len = buf[4] + 5;
+		if (per_qual == 3 && data_len < min(range_len, 36))
+			buf[4] = min(range_len, 36) - 5;
+	}
 
 	/* Copy over the status...etc */
 	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
  2015-07-01  9:04 [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant Vitaly Kuznetsov
@ 2015-07-03 16:19 ` Christoph Hellwig
  2015-07-03 16:28   ` KY Srinivasan
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2015-07-03 16:19 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: linux-scsi, Long Li, K. Y. Srinivasan, Haiyang Zhang,
	James E.J. Bottomley, devel, linux-kernel

On Wed, Jul 01, 2015 at 11:04:08AM +0200, Vitaly Kuznetsov wrote:
> SPC-2/3/4 specs state that "The standard INQUIRY data (see table ...)
> shall contain at least 36 bytes". Hyper-V host doesn't always honor this
> requirement, e.g. when there is no physical device present at a particular
> LUN host sets Peripheral qualifier to 011b and Additional length to 0
> (thus making the reply 5-bytes long). Upper level SCSI stack complains
> with 'INQUIRY result too short (5), using 36'. Fix the issue by mangling
> Additional length field in host's reply at the driver level.

This looks like a big mess, and usage of phys_to_virt is not generally
safe to start with.

If HyperV really is that broken the warning seems correct, but if you
really have to get rid of it we could add a blist flag to not issue
the warning in the core code instead of hacking around it in the driver.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
  2015-07-03 16:19 ` Christoph Hellwig
@ 2015-07-03 16:28   ` KY Srinivasan
  2015-07-07 15:01     ` Vitaly Kuznetsov
  0 siblings, 1 reply; 4+ messages in thread
From: KY Srinivasan @ 2015-07-03 16:28 UTC (permalink / raw)
  To: Christoph Hellwig, Vitaly Kuznetsov
  Cc: linux-scsi, Long Li, Haiyang Zhang, James E.J. Bottomley, devel,
	linux-kernel



> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Friday, July 3, 2015 9:19 AM
> To: Vitaly Kuznetsov
> Cc: linux-scsi@vger.kernel.org; Long Li; KY Srinivasan; Haiyang Zhang; James
> E.J. Bottomley; devel@linuxdriverproject.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
> 
> On Wed, Jul 01, 2015 at 11:04:08AM +0200, Vitaly Kuznetsov wrote:
> > SPC-2/3/4 specs state that "The standard INQUIRY data (see table ...)
> > shall contain at least 36 bytes". Hyper-V host doesn't always honor this
> > requirement, e.g. when there is no physical device present at a particular
> > LUN host sets Peripheral qualifier to 011b and Additional length to 0
> > (thus making the reply 5-bytes long). Upper level SCSI stack complains
> > with 'INQUIRY result too short (5), using 36'. Fix the issue by mangling
> > Additional length field in host's reply at the driver level.
> 
> This looks like a big mess, and usage of phys_to_virt is not generally
> safe to start with.
> 
> If HyperV really is that broken the warning seems correct, but if you
> really have to get rid of it we could add a blist flag to not issue
> the warning in the core code instead of hacking around it in the driver.

Agreed. We have fixed this issue in win10 and I am trying to get the fix backported.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
  2015-07-03 16:28   ` KY Srinivasan
@ 2015-07-07 15:01     ` Vitaly Kuznetsov
  0 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2015-07-07 15:01 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Christoph Hellwig, linux-scsi, Long Li, Haiyang Zhang,
	James E.J. Bottomley, devel, linux-kernel

KY Srinivasan <kys@microsoft.com> writes:

>> -----Original Message-----
>> From: Christoph Hellwig [mailto:hch@infradead.org]
>> Sent: Friday, July 3, 2015 9:19 AM
>> To: Vitaly Kuznetsov
>> Cc: linux-scsi@vger.kernel.org; Long Li; KY Srinivasan; Haiyang Zhang; James
>> E.J. Bottomley; devel@linuxdriverproject.org; linux-kernel@vger.kernel.org
>> Subject: Re: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant
>> 
>> On Wed, Jul 01, 2015 at 11:04:08AM +0200, Vitaly Kuznetsov wrote:
>> > SPC-2/3/4 specs state that "The standard INQUIRY data (see table ...)
>> > shall contain at least 36 bytes". Hyper-V host doesn't always honor this
>> > requirement, e.g. when there is no physical device present at a particular
>> > LUN host sets Peripheral qualifier to 011b and Additional length to 0
>> > (thus making the reply 5-bytes long). Upper level SCSI stack complains
>> > with 'INQUIRY result too short (5), using 36'. Fix the issue by mangling
>> > Additional length field in host's reply at the driver level.
>> 
>> This looks like a big mess, and usage of phys_to_virt is not generally
>> safe to start with.
>> 
>> If HyperV really is that broken the warning seems correct, but if you
>> really have to get rid of it we could add a blist flag to not issue
>> the warning in the core code instead of hacking around it in the driver.
>
> Agreed. We have fixed this issue in win10 and I am trying to get the fix backported.

In case this is fixed in future Hyper-V versions introducing new blist
flags looks like an overkill, let's leave things as they are.

Thanks,

-- 
  Vitaly

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-07 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01  9:04 [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant Vitaly Kuznetsov
2015-07-03 16:19 ` Christoph Hellwig
2015-07-03 16:28   ` KY Srinivasan
2015-07-07 15:01     ` Vitaly Kuznetsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).