diff mbox

[2/3] ses: skip error messages for invalid LUNs

Message ID 1513855354-86603-3-git-send-email-hare@suse.de (mailing list archive)
State Deferred
Headers show

Commit Message

Hannes Reinecke Dec. 21, 2017, 11:22 a.m. UTC
Some storage array set the 'Embedded enclosure' bit even though
no LUN is present, causing the first RECEIVE DIAGNOSTIC call to
be returned with sense code 'LOGICAL UNIT NOT SUPPORTED'.
This patch skips the annoying 'Failed to get diagnostic page 0x1'
messages for those cases.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/ses.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

James Bottomley Dec. 22, 2017, 5:39 p.m. UTC | #1
On Thu, 2017-12-21 at 12:22 +0100, Hannes Reinecke wrote:
> Some storage array set the 'Embedded enclosure' bit even though
> no LUN is present, causing the first RECEIVE DIAGNOSTIC call to
> be returned with sense code 'LOGICAL UNIT NOT SUPPORTED'.
> This patch skips the annoying 'Failed to get diagnostic page 0x1'
> messages for those cases.

What disagnostic pages does this thing support?  Can you do a receive
diagnostic on page 0 to find out?  I suspect a lot of embedded
enclosure services are simple and support page 7 only.  If it really
refuses all diagnostic page requests (which would be a gross standards
violation), then it should probably be blacklisted by inquiry string as
unusable.

James
Hannes Reinecke Dec. 23, 2017, 2:37 p.m. UTC | #2
On 12/22/2017 06:39 PM, James Bottomley wrote:
> On Thu, 2017-12-21 at 12:22 +0100, Hannes Reinecke wrote:
>> Some storage array set the 'Embedded enclosure' bit even though
>> no LUN is present, causing the first RECEIVE DIAGNOSTIC call to
>> be returned with sense code 'LOGICAL UNIT NOT SUPPORTED'.
>> This patch skips the annoying 'Failed to get diagnostic page 0x1'
>> messages for those cases.
> 
> What disagnostic pages does this thing support?  Can you do a receive
> diagnostic on page 0 to find out?  I suspect a lot of embedded
> enclosure services are simple and support page 7 only.  If it really
> refuses all diagnostic page requests (which would be a gross standards
> violation), then it should probably be blacklisted by inquiry string as
> unusable.
> 
If a LUN is connected it'll respond to the usual set (0, 1, 2, und 6).
Sending a RECEIVE DIAGNOSTIC to page 0 will probably yield the same
result (ie being returned with that sense code), but at least we won't
try to access the other pages.
But anyway, yes, the implementation is dodgy.
I'm in contact with the vendor and try to straighten things out.

Cheers,

Hannes
diff mbox

Patch

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index e8ffee1..c1f96b0 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -110,12 +110,17 @@  static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 		0
 	};
 	unsigned char recv_page_code;
+	struct scsi_sense_hdr sshdr;
 
 	ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
-				NULL, SES_TIMEOUT, SES_RETRIES, NULL);
-	if (unlikely(ret))
+				&sshdr, SES_TIMEOUT, SES_RETRIES, NULL);
+	if (unlikely(ret)) {
+		if (status_byte(ret) == CHECK_CONDITION &&
+		    sshdr.asc == 0x25 && sshdr.ascq == 0x00) {
+			ret = -ENODEV;
+		}
 		return ret;
-
+	}
 	recv_page_code = ((unsigned char *)buf)[0];
 
 	if (likely(recv_page_code == page_code))
@@ -674,9 +679,14 @@  static int ses_intf_add(struct device *cdev,
 
 	page = 1;
 	result = ses_recv_diag(sdev, page, hdr_buf, ses_alloc_size);
-	if (result)
+	if (result) {
+		if (result == -ENODEV &&
+		    sdev->inq_periph_qual != 0) {
+			kfree(hdr_buf);
+			return result;
+		}
 		goto recv_failed;
-
+	}
 	len = (hdr_buf[2] << 8) + hdr_buf[3] + 4;
 	buf = kzalloc(len, GFP_KERNEL);
 	if (!buf)