linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] scsi: report 'INQUIRY result too short' once per host
@ 2015-10-08 16:54 Vitaly Kuznetsov
  2015-10-12 12:33 ` Hannes Reinecke
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2015-10-08 16:54 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: linux-scsi, linux-kernel, K. Y. Srinivasan, Long Li, Dexuan Cui

Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
INQUIRY result too short (5), using 36' messages on console. This can be
problematic for slow consoles. Introduce short_inquiry flag in struct
Scsi_Host to print the message once per host.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Changes since v2:
- This is a successor of previously sent (and still not merged) "scsi:
  introduce short_inquiry flag for broken host adapters" patch. I'm not
  particularly sure which solution is better but I'm leaning towards this
  one as it doesn't require changes to adapter drivers.
---
 drivers/scsi/scsi_scan.c | 9 ++++++---
 include/scsi/scsi_host.h | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index f9f3f82..cd347e4 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	 * strings.
 	 */
 	if (sdev->inquiry_len < 36) {
-		sdev_printk(KERN_INFO, sdev,
-			    "scsi scan: INQUIRY result too short (%d),"
-			    " using 36\n", sdev->inquiry_len);
+		if (!sdev->host->short_inquiry) {
+			shost_printk(KERN_INFO, sdev->host,
+				    "scsi scan: INQUIRY result too short (%d),"
+				    " using 36\n", sdev->inquiry_len);
+			sdev->host->short_inquiry = 1;
+		}
 		sdev->inquiry_len = 36;
 	}
 
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e113c75..3a22da7 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -673,6 +673,9 @@ struct Scsi_Host {
 	unsigned use_blk_mq:1;
 	unsigned use_cmd_list:1;
 
+	/* Host responded with short (<36 bytes) INQUIRY result */
+	unsigned short_inquiry:1;
+
 	/*
 	 * Optional work queue to be utilized by the transport
 	 */
-- 
2.4.3


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

* Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host
  2015-10-08 16:54 [PATCH v3] scsi: report 'INQUIRY result too short' once per host Vitaly Kuznetsov
@ 2015-10-12 12:33 ` Hannes Reinecke
  2015-10-12 15:16   ` Vitaly Kuznetsov
  0 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2015-10-12 12:33 UTC (permalink / raw)
  To: Vitaly Kuznetsov, James E.J. Bottomley
  Cc: linux-scsi, linux-kernel, K. Y. Srinivasan, Long Li, Dexuan Cui

On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
> INQUIRY result too short (5), using 36' messages on console. This can be
> problematic for slow consoles. Introduce short_inquiry flag in struct
> Scsi_Host to print the message once per host.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> Changes since v2:
> - This is a successor of previously sent (and still not merged) "scsi:
>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>   particularly sure which solution is better but I'm leaning towards this
>   one as it doesn't require changes to adapter drivers.
> ---
>  drivers/scsi/scsi_scan.c | 9 ++++++---
>  include/scsi/scsi_host.h | 3 +++
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index f9f3f82..cd347e4 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
>  	 * strings.
>  	 */
>  	if (sdev->inquiry_len < 36) {
> -		sdev_printk(KERN_INFO, sdev,
> -			    "scsi scan: INQUIRY result too short (%d),"
> -			    " using 36\n", sdev->inquiry_len);
> +		if (!sdev->host->short_inquiry) {
> +			shost_printk(KERN_INFO, sdev->host,
> +				    "scsi scan: INQUIRY result too short (%d),"
> +				    " using 36\n", sdev->inquiry_len);
> +			sdev->host->short_inquiry = 1;
> +		}
>  		sdev->inquiry_len = 36;
>  	}
>  
At least you need to check if you've received any valid data here;
'INQUIRY result too short' is also a common error if the interrupt
is hosed when trying to access the device.
So please check for 'inquiry_len > 4' before setting 'short_inquiry'.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.de			               +49 911 74053 688
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)

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

* Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host
  2015-10-12 12:33 ` Hannes Reinecke
@ 2015-10-12 15:16   ` Vitaly Kuznetsov
  2015-10-13  6:16     ` Hannes Reinecke
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2015-10-12 15:16 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James E.J. Bottomley, linux-scsi, linux-kernel, K. Y. Srinivasan,
	Long Li, Dexuan Cui

Hannes Reinecke <hare@suse.de> writes:

> On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
>> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
>> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
>> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
>> INQUIRY result too short (5), using 36' messages on console. This can be
>> problematic for slow consoles. Introduce short_inquiry flag in struct
>> Scsi_Host to print the message once per host.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> ---
>> Changes since v2:
>> - This is a successor of previously sent (and still not merged) "scsi:
>>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>>   particularly sure which solution is better but I'm leaning towards this
>>   one as it doesn't require changes to adapter drivers.
>> ---
>>  drivers/scsi/scsi_scan.c | 9 ++++++---
>>  include/scsi/scsi_host.h | 3 +++
>>  2 files changed, 9 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index f9f3f82..cd347e4 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
>>  	 * strings.
>>  	 */
>>  	if (sdev->inquiry_len < 36) {
>> -		sdev_printk(KERN_INFO, sdev,
>> -			    "scsi scan: INQUIRY result too short (%d),"
>> -			    " using 36\n", sdev->inquiry_len);
>> +		if (!sdev->host->short_inquiry) {
>> +			shost_printk(KERN_INFO, sdev->host,
>> +				    "scsi scan: INQUIRY result too short (%d),"
>> +				    " using 36\n", sdev->inquiry_len);
>> +			sdev->host->short_inquiry = 1;
>> +		}
>>  		sdev->inquiry_len = 36;
>>  	}
>>  
> At least you need to check if you've received any valid data here;
> 'INQUIRY result too short' is also a common error if the interrupt
> is hosed when trying to access the device.
> So please check for 'inquiry_len > 4' before setting 'short_inquiry'.

Currently we proceed even with a shorter reply... Should we abort the
scan (and return -EOI?) in case we got inquiry_len <= 4?

Thanks,

-- 
  Vitaly

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

* Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host
  2015-10-12 15:16   ` Vitaly Kuznetsov
@ 2015-10-13  6:16     ` Hannes Reinecke
  2015-10-13 11:17       ` Vitaly Kuznetsov
  0 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2015-10-13  6:16 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: James E.J. Bottomley, linux-scsi, linux-kernel, K. Y. Srinivasan,
	Long Li, Dexuan Cui

On 10/12/2015 05:16 PM, Vitaly Kuznetsov wrote:
> Hannes Reinecke <hare@suse.de> writes:
> 
>> On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
>>> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
>>> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
>>> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
>>> INQUIRY result too short (5), using 36' messages on console. This can be
>>> problematic for slow consoles. Introduce short_inquiry flag in struct
>>> Scsi_Host to print the message once per host.
>>>
>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>> ---
>>> Changes since v2:
>>> - This is a successor of previously sent (and still not merged) "scsi:
>>>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>>>   particularly sure which solution is better but I'm leaning towards this
>>>   one as it doesn't require changes to adapter drivers.
>>> ---
>>>  drivers/scsi/scsi_scan.c | 9 ++++++---
>>>  include/scsi/scsi_host.h | 3 +++
>>>  2 files changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>>> index f9f3f82..cd347e4 100644
>>> --- a/drivers/scsi/scsi_scan.c
>>> +++ b/drivers/scsi/scsi_scan.c
>>> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
>>>  	 * strings.
>>>  	 */
>>>  	if (sdev->inquiry_len < 36) {
>>> -		sdev_printk(KERN_INFO, sdev,
>>> -			    "scsi scan: INQUIRY result too short (%d),"
>>> -			    " using 36\n", sdev->inquiry_len);
>>> +		if (!sdev->host->short_inquiry) {
>>> +			shost_printk(KERN_INFO, sdev->host,
>>> +				    "scsi scan: INQUIRY result too short (%d),"
>>> +				    " using 36\n", sdev->inquiry_len);
>>> +			sdev->host->short_inquiry = 1;
>>> +		}
>>>  		sdev->inquiry_len = 36;
>>>  	}
>>>  
>> At least you need to check if you've received any valid data here;
>> 'INQUIRY result too short' is also a common error if the interrupt
>> is hosed when trying to access the device.
>> So please check for 'inquiry_len > 4' before setting 'short_inquiry'.
> 
> Currently we proceed even with a shorter reply... Should we abort the
> scan (and return -EOI?) in case we got inquiry_len <= 4?
> 
Yes please. We need to ensure that we actually received some data,
and not running into an error scenario here.
So we need to read at least five bytes of data, as byte 4 carries
the response length. If we read less than that we have no way of
figuring out if the response data is even remotely sane.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.de			               +49 911 74053 688
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)

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

* Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host
  2015-10-13  6:16     ` Hannes Reinecke
@ 2015-10-13 11:17       ` Vitaly Kuznetsov
  0 siblings, 0 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2015-10-13 11:17 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James E.J. Bottomley, linux-scsi, linux-kernel, K. Y. Srinivasan,
	Long Li, Dexuan Cui

Hannes Reinecke <hare@suse.de> writes:

> On 10/12/2015 05:16 PM, Vitaly Kuznetsov wrote:
>> Hannes Reinecke <hare@suse.de> writes:
>> 
>>> On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
>>>> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
>>>> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
>>>> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
>>>> INQUIRY result too short (5), using 36' messages on console. This can be
>>>> problematic for slow consoles. Introduce short_inquiry flag in struct
>>>> Scsi_Host to print the message once per host.
>>>>
>>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>>> ---
>>>> Changes since v2:
>>>> - This is a successor of previously sent (and still not merged) "scsi:
>>>>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>>>>   particularly sure which solution is better but I'm leaning towards this
>>>>   one as it doesn't require changes to adapter drivers.
>>>> ---
>>>>  drivers/scsi/scsi_scan.c | 9 ++++++---
>>>>  include/scsi/scsi_host.h | 3 +++
>>>>  2 files changed, 9 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>>>> index f9f3f82..cd347e4 100644
>>>> --- a/drivers/scsi/scsi_scan.c
>>>> +++ b/drivers/scsi/scsi_scan.c
>>>> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
>>>>  	 * strings.
>>>>  	 */
>>>>  	if (sdev->inquiry_len < 36) {
>>>> -		sdev_printk(KERN_INFO, sdev,
>>>> -			    "scsi scan: INQUIRY result too short (%d),"
>>>> -			    " using 36\n", sdev->inquiry_len);
>>>> +		if (!sdev->host->short_inquiry) {
>>>> +			shost_printk(KERN_INFO, sdev->host,
>>>> +				    "scsi scan: INQUIRY result too short (%d),"
>>>> +				    " using 36\n", sdev->inquiry_len);
>>>> +			sdev->host->short_inquiry = 1;
>>>> +		}
>>>>  		sdev->inquiry_len = 36;
>>>>  	}
>>>>  
>>> At least you need to check if you've received any valid data here;
>>> 'INQUIRY result too short' is also a common error if the interrupt
>>> is hosed when trying to access the device.
>>> So please check for 'inquiry_len > 4' before setting 'short_inquiry'.
>> 
>> Currently we proceed even with a shorter reply... Should we abort the
>> scan (and return -EOI?) in case we got inquiry_len <= 4?
>> 
> Yes please. We need to ensure that we actually received some data,
> and not running into an error scenario here.
> So we need to read at least five bytes of data, as byte 4 carries
> the response length. If we read less than that we have no way of
> figuring out if the response data is even remotely sane.
>

I just checked and it seems such check would be redundant. inquiry_len
is always >=5 as we have the following code:

response_len = inq_result[4] + 5;

where inq_result is unsigned char *

After that we do:
sdev->inquiry_len = min(try_inquiry_len, response_len);

As far as I can see try_inquiry_len can be lower than 36 only in case
some driver sets it manually. I don't see a '>=5' check for it but I'm
not sure it is needed.

-- 
  Vitaly

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

end of thread, other threads:[~2015-10-13 11:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-08 16:54 [PATCH v3] scsi: report 'INQUIRY result too short' once per host Vitaly Kuznetsov
2015-10-12 12:33 ` Hannes Reinecke
2015-10-12 15:16   ` Vitaly Kuznetsov
2015-10-13  6:16     ` Hannes Reinecke
2015-10-13 11:17       ` 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).