Skip to contentSkip to conversation

scsi: retry MODE SENSE on unit attention

PATCH In review Hannes Reinecke 2 participants 2 messages Jul 6, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: retry MODE SENSE on unit attention

The 'sd' driver is calling scsi_mode_sense() to figure out internal details. But scsi_mode_sense() never checks for any pending unit attentions, leading to incorrect decisions during probing.

---
 drivers/scsi/scsi_lib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +6 -1
index b1a2631..4f3c120 100644
@@ -2423,7 +2423,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 	unsigned char cmd[12];
 	int use_10_for_ms;
 	int header_length;
-	int result;
+	int result, retry_count = retries;
 	struct scsi_sense_hdr my_sshdr;
 
 	memset(data, 0, sizeof(*data));
@@ -2502,6 +2502,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 			data->block_descriptor_length = buffer[3];
 		}
 		data->header_length = header_length;
+	} else if ((status_byte(result) == CHECK_CONDITION) &&
+		   scsi_sense_valid(sshdr) &&
+		   sshdr->sense_key == UNIT_ATTENTION && retry_count) {
+		retry_count--;
+		goto retry;
 	}
 
 	return result;
Signature · 1 line
1.8.5.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Hannes Reinecke

The 'sd' driver is calling scsi_mode_sense() to figure out internal details. But scsi_mode_sense() never checks for any pending unit attentions, leading to incorrect decisions during probing.

---
  drivers/scsi/scsi_lib.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
index b1a2631..4f3c120 100644
@@ -2423,7 +2423,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
  	unsigned char cmd[12];
  	int use_10_for_ms;
  	int header_length;
-	int result;
+	int result, retry_count = retries;
  	struct scsi_sense_hdr my_sshdr;
 
  	memset(data, 0, sizeof(*data));
@@ -2502,6 +2502,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
  			data->block_descriptor_length = buffer[3];

drivers/scsi/scsi_lib.c scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, · line 2512

Quoted 10 lines
drivers/scsi/scsi_lib.c +5 -0
  		}
  		data->header_length = header_length;
+	} else if ((status_byte(result) == CHECK_CONDITION) &&
+		   scsi_sense_valid(sshdr) &&
+		   sshdr->sense_key == UNIT_ATTENTION && retry_count) {
+		retry_count--;
+		goto retry;
  	}
 
  	return result;