Skip to contentSkip to conversation

scsi: ses: Handle positive SCSI error from ses_recv_diag()

PATCH Applied Greg Kroah-Hartman 4 participants 5 messages Feb 23 – Mar 20 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ses: Handle positive SCSI error from ses_recv_diag()

ses_recv_diag() can return a positive value, which also means that an error happened, so do not only test for negative values.

Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc stable <[email protected]>
Assisted-by gkh_clanker_2000
---
 drivers/scsi/ses.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +1 -1
index 35101e9b7ba7..128042c734cc 100644
@@ -215,7 +215,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
 	unsigned char *type_ptr = ses_dev->page1_types;
 	unsigned char *desc_ptr = ses_dev->page2 + 8;
 
-	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0)
+	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len))
 		return NULL;
 
 	for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {
Signature · 1 line
2.53.0
#1 lore raw
Quoted 28 lines · Greg Kroah-Hartman

ses_recv_diag() can return a positive value, which also means that an error happened, so do not only test for negative values.

Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc stable <[email protected]>
Assisted-by gkh_clanker_2000
---
 drivers/scsi/ses.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +1 -1
index 35101e9b7ba7..128042c734cc 100644
@@ -215,7 +215,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
 	unsigned char *type_ptr = ses_dev->page1_types;
 	unsigned char *desc_ptr = ses_dev->page2 + 8;
 
-	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0)
+	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len))
 		return NULL;
 
 	for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {
Signature · 1 line
2.53.0

Along these lines, any specific reason why the following code in ses_enclosure_data_process() doesn't also check the return value of ses_recv_diag():

	/* re-read page 10 */
	if (ses_dev->page10)
		ses_recv_diag(sdev, 10, ses_dev->page10, ses_dev->page10_len);
	/* Page 7 for the descriptors is optional */
	result = ses_recv_diag(sdev, 7, hdr_buf, INIT_ALLOC_SIZE);
	if (result)
		goto simple_populate;

Is that because re-reading always succeeds, or because it can fail and we just want to ignore it? It feels odd that the "optional" read command for page 7 is checked by not page 10. But hey, scsi is odd :)

thank,s

greg k-h

maintainer
#2 lore raw
Quoted 48 lines · Greg Kroah-Hartman
Quoted 26 lines · Greg Kroah-Hartman

ses_recv_diag() can return a positive value, which also means that an
error happened, so do not only test for negative values.

Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc stable <[email protected]>
Assisted-by gkh_clanker_2000

---
 drivers/scsi/ses.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +0 -0
index 35101e9b7ba7..128042c734cc 100644
@@ -215,7 +215,7 @@ static unsigned char
 *ses_get_page2_descriptor(struct enclosure_device *edev,
  	unsigned char *type_ptr = ses_dev->page1_types;
  	unsigned char *desc_ptr = ses_dev->page2 + 8;

drivers/scsi/ses.c +0 -1
-	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev-
Quoted 1 line

page2_len) < 0)

drivers/scsi/ses.c +1 -0
+	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev-
Quoted 1 line

page2_len))

Quoted 7 lines

  return NULL;

  for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr +=
4) {

Signature · 1 line
2.53.0

Along these lines, any specific reason why the following code in ses_enclosure_data_process() doesn't also check the return value of ses_recv_diag():

	/* re-read page 10 */
	if (ses_dev->page10)
		ses_recv_diag(sdev, 10, ses_dev->page10, ses_dev-
Quoted 1 line

page10_len);

	/* Page 7 for the descriptors is optional */
	result = ses_recv_diag(sdev, 7, hdr_buf, INIT_ALLOC_SIZE);
	if (result)
		goto simple_populate;
Quoted 4 lines

Is that because re-reading always succeeds, or because it can fail and we just want to ignore it?  It feels odd that the "optional" read command for page 7 is checked by not page 10.  But hey, scsi is odd :)

Pretty much. The re-read should never fail for SCSI reasons (although there's a remote possibility it could fail for transient reasons) the scsi_execute will already have tried (and logged errors), so there's no further error handling ses can add so the best thing it can do is proceed with stale data.

The reason for the page 7 check is because that will fail if the page does not exist (which is allowed by spec).

Regards,

James

Reviewed-by on v1 1/1
#3 lore raw
In reply to Greg Kroah-Hartman
Quoted 17 lines · Greg Kroah-Hartman

ses_recv_diag() can return a positive value, which also means that an error happened, so do not only test for negative values.

Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc stable <[email protected]>
Assisted-by gkh_clanker_2000
---
  drivers/scsi/ses.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +0 -0
index 35101e9b7ba7..128042c734cc 100644

drivers/scsi/ses.c static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev, · line 221

Quoted 8 lines
drivers/scsi/ses.c +1 -1
@@ -215,7 +215,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
  	unsigned char *type_ptr = ses_dev->page1_types;
  	unsigned char *desc_ptr = ses_dev->page2 + 8;
 
-	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0)
+	if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len))
  		return NULL;
 
  	for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich