Fix sense key MEDIUM ERROR processing and retry
PATCH 1/1 Fix sense key MEDIUM ERROR processing and retry
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 <[email protected]>
--- drivers/scsi/scsi_error.c | 5 +++++ drivers/scsi/scsi_lib.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletions(-)
drivers/scsi/scsi_error.c +5 -0
@@ -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 :
drivers/scsi/scsi_lib.c +2 -1
@@ -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
Signature · 1 line
1.4.4.1.g7a0e