Skip to content

Commit a9bddd7

Browse files
committed
[SCSI] fix recovered error handling
We have a problem with recovered error handling in that any command which goes down as BLOCK_PC but which returns a sense code of RECOVERED ERROR gets completed with -EIO. For actual SG_IO commands, this doesn't matter at all, since the error return code gets dropped in favour of req->errors which contain the SCSI completion code. However, if this command is part of the block system, then it will pay attention to the returned error code. In particularly if a SYNCHRONIZE CACHE from a barrier command completes with RECOVERED ERROR, the resulting -EIO on the barrier causes block to error the request and return it to the filesystem. Fix this by converting the -EIO for recovered error to zero, plus remove the printing of this from sd and sr so the message isn't double printed. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
1 parent a2f5bfc commit a9bddd7

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎drivers/scsi/scsi_lib.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,22 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
791791
"%d bytes done.\n",
792792
req->nr_sectors, good_bytes));
793793

794-
/* A number of bytes were successfully read. If there
794+
/*
795+
* Recovered errors need reporting, but they're always treated
796+
* as success, so fiddle the result code here. For BLOCK_PC
797+
* we already took a copy of the original into rq->errors which
798+
* is what gets returned to the user
799+
*/
800+
if (sense_valid && sshdr.sense_key == RECOVERED_ERROR) {
801+
if (!(req->cmd_flags & REQ_QUIET))
802+
scsi_print_sense("", cmd);
803+
result = 0;
804+
/* BLOCK_PC may have set error */
805+
error = 0;
806+
}
807+
808+
/*
809+
* A number of bytes were successfully read. If there
795810
* are leftovers and there is some kind of error
796811
* (result != 0), retry the rest.
797812
*/

‎drivers/scsi/sd.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,6 @@ static int sd_done(struct scsi_cmnd *SCpnt)
10511051
good_bytes = sd_completed_bytes(SCpnt);
10521052
break;
10531053
case RECOVERED_ERROR:
1054-
/* Inform the user, but make sure that it's not treated
1055-
* as a hard error.
1056-
*/
1057-
scsi_print_sense("sd", SCpnt);
1058-
SCpnt->result = 0;
1059-
memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
10601054
good_bytes = scsi_bufflen(SCpnt);
10611055
break;
10621056
case NO_SENSE:

‎drivers/scsi/sr.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,6 @@ static int sr_done(struct scsi_cmnd *SCpnt)
309309
break;
310310

311311
case RECOVERED_ERROR:
312-
313-
/*
314-
* An error occured, but it recovered. Inform the
315-
* user, but make sure that it's not treated as a
316-
* hard error.
317-
*/
318-
scsi_print_sense("sr", SCpnt);
319-
SCpnt->result = 0;
320-
SCpnt->sense_buffer[0] = 0x0;
321312
good_bytes = this_count;
322313
break;
323314

0 commit comments

Comments
 (0)