Skip to contentSkip to conversation

2.4.20: Handle recovered errors

PATCH Kurt Garloff 1 participant 1 message Feb 8, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

Hi,

When a command returns CHECK_CONDITION and the sense information is retrieved, the scsi block drivers (sd, sr) do not handle the sense key correctly.
The valid bit only tells about validity of the information field (bytes 3 -- 6) of the fixed sense buffer. If it's not set, the sense key and ASC/ASCQ are still valid. [spc3r10, 7.24.2.3]
But sd/sr consider the whole sense key invalid then.
This hits us for a RECOVERED_ERROR sense key that should be reported but considered a success. Currently (2.4.20) sd/sr erroneously do consider it an error, if the valid bit is unset.

Patch against 2.4.20 is attached.
I did not look into 2.5.59, but I guess it has the same problem.

Note that the change to scsi_lib is not strictly required, as with the fixes to sr and sd, one should not get there for recovered errors any more. On the other hand, it's good to have it there for correctness.

Patch has been tested with hacked scsi_debug. (See later mail.)

Regards,

Signature · 3 lines
Kurt Garloff  <[email protected]>                          Eindhoven, NL
GPG key: See mail header, key servers                 SuSE Labs (Head)
SuSE Linux AG, Nuernberg, DE                            SCSI, Security
drivers/scsi/scsi_lib.c +2 -0
diff -uNr linux-2.4.20.orig/drivers/scsi/scsi_lib.c linux-2.4.20.recerr/drivers/scsi/scsi_lib.c
@@ -695,6 +695,8 @@
 		 */
 
 		switch (SCpnt->sense_buffer[2]) {
+		case RECOVERED_ERROR: /* Added, KG, 2003-01-20 */
+			return;
 		case ILLEGAL_REQUEST:
 			if (SCpnt->device->ten && SCSI_RETRY_10(SCpnt->cmnd[0])) {
 				SCpnt->device->ten = 0;
drivers/scsi/sd.c +3 -1
diff -uNr linux-2.4.20.orig/drivers/scsi/sd.c linux-2.4.20.recerr/drivers/scsi/sd.c
@@ -621,9 +621,11 @@
 
 	/* An error occurred */
 	if (driver_byte(result) != 0 && 	/* An error occured */
-	    SCpnt->sense_buffer[0] == 0xF0) {	/* Sense data is valid */
+	    (SCpnt->sense_buffer[0] & 0x7f) == 0x70) {	/* Sense data is valid */
 		switch (SCpnt->sense_buffer[2]) {
 		case MEDIUM_ERROR:
+			if (!(SCpnt->sense_buffer[0] & 0x80))
+				break;
 			error_sector = (SCpnt->sense_buffer[3] << 24) |
 			(SCpnt->sense_buffer[4] << 16) |
 			(SCpnt->sense_buffer[5] << 8) |
drivers/scsi/sr.c +3 -1
diff -uNr linux-2.4.20.orig/drivers/scsi/sr.c linux-2.4.20.recerr/drivers/scsi/sr.c
@@ -211,11 +211,13 @@
 
 
 	if (driver_byte(result) != 0 &&		/* An error occurred */
-	    SCpnt->sense_buffer[0] == 0xF0) {	/* Sense data is valid */
+	    (SCpnt->sense_buffer[0] & 0x7f) == 0x70) {	/* Sense data is valid */
 		switch (SCpnt->sense_buffer[2]) {
 		case MEDIUM_ERROR:
 		case VOLUME_OVERFLOW:
 		case ILLEGAL_REQUEST:
+			if (!(SCpnt->sense_buffer[0] & 0x80))
+				break;
 			error_sector = (SCpnt->sense_buffer[3] << 24) |
 			(SCpnt->sense_buffer[4] << 16) |
 			(SCpnt->sense_buffer[5] << 8) |