[PATCH] RESEND scsi_lib.c: continue after MEDIUM_ERROR

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>, IDE/ATA development list <linux-ide@...>, James Bottomley <James.Bottomley@...>, <linux-scsi@...>
Date: Tuesday, January 30, 2007 - 9:12 pm

Fixed for 80-columns, and copying linux-scsi this time.

In ancient kernels, the SCSI disk code used to continue after
encountering a MEDIUM_ERROR.  It would "complete" the good
sectors before the error, fail the bad sector/block, and then
continue with the rest of the request.

Kernels since about 2.6.16 or so have been broken in this regard.
They "complete" the good sectors before the error,
and then fail the entire remaining portions of the request.

This is very risky behaviour, as a request is often a merge
of several bios, and just because one application hits a bad sector
is no reason to pretend that (for example) an adjacent directly lookup also failed.

This patch fixes the behaviour to be similar to what we had originally.

When a bad sector is encounted, SCSI will now work around it again,
failing *only* the bad sector itself.

Signed-off-by:  Mark Lord <mlord@pobox.com>
---
--- old/drivers/scsi/scsi_lib.c	2007-01-30 20:06:15.000000000 -0500
+++ linux/drivers/scsi/scsi_lib.c	2007-01-30 20:06:59.000000000 -0500
@@ -865,6 +865,13 @@
 	 */
 	if (sense_valid && !sense_deferred) {
 		switch (sshdr.sense_key) {
+		case MEDIUM_ERROR:
+			/* Bad sector. Fail it, and continue on with the rest */
+			if (scsi_end_request(cmd, 0,
+					cmd->device->sector_size, 1) == NULL) {
+				cmd->retries = 0;	/* go around again.. */
+				return;
+			}
 		case UNIT_ATTENTION:
 			if (cmd->device->removable) {
 				/* Detected disc change.  Set a bit
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Mark Lord, (Tue Jan 30, 8:47 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, James Bottomley, (Tue Jan 30, 9:16 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, James Bottomley, (Thu Feb 1, 5:55 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Ric Wheeler, (Fri Feb 2, 8:20 am)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Mark Lord, (Fri Feb 2, 12:06 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Matt Mackall, (Fri Feb 2, 3:49 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Matt Mackall, (Fri Feb 2, 7:07 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Douglas Gilbert, (Fri Feb 2, 4:16 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, James Bottomley, (Fri Feb 2, 10:53 am)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Ric Wheeler, (Fri Feb 2, 12:16 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Mark Lord, (Thu Feb 1, 10:48 pm)
Re: [PATCH] scsi_lib.c: continue after MEDIUM_ERROR, Mark Lord, (Tue Jan 30, 9:36 pm)
[PATCH] RESEND scsi_lib.c: continue after MEDIUM_ERROR, Mark Lord, (Tue Jan 30, 9:12 pm)