[PATCH] [SCSI] Fix sense key MEDIUM ERROR processing and retry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1) If the device reports an uncorrectable MEDIUM ERROR, such
as SK MEDIUM ERROR, ASC UNRECOVERED READ ERR, AMNF DATA
FIELD or RECORD NOT FOUND, then: In scsi_check_sense()
return SUCCESS so as to not retry -- the error is
uncorrectable -- this speeds up total processing time.

2) In scsi_io_completion(), retry if and only if there was
at least one byte completed, i.e. good_bytes != 0.  If
good_bytes == 0, don't try to retry.

Without this patch, SCSI Core gets hung reading sector 0
forever, for example when reading the partition table of a
(newly discovered) device.

Signed-off-by: Luben Tuikov <ltuikov@xxxxxxxxx>
---
 drivers/scsi/scsi_error.c |    5 +++++
 drivers/scsi/scsi_lib.c   |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index aff1b0c..011dd32 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -359,6 +359,11 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		return SUCCESS;
 
 	case MEDIUM_ERROR:
+		if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
+		    sshdr.asc == 0x13 || /* AMNF DATA FIELD */
+		    sshdr.asc == 0x14) { /* RECORD NOT FOUND */
+			return SUCCESS;
+		}
 		return NEEDS_RETRY;
 
 	case HARDWARE_ERROR:
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8b208b4..c5fa329 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -866,7 +866,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	 * are leftovers and there is some kind of error
 	 * (result != 0), retry the rest.
 	 */
-	if (scsi_end_request(cmd, 1, good_bytes, !!result) == NULL)
+	if (good_bytes &&
+	    scsi_end_request(cmd, 1, good_bytes, !!result) == NULL)
 		return;
 
 	/* good_bytes = 0, or (inclusive) there were leftovers and
-- 
1.4.4.1.g7a0e


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux