linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi_lib.c: continue after MEDIUM_ERROR
@ 2007-01-31  0:47 Mark Lord
  2007-01-31  1:12 ` [PATCH] RESEND " Mark Lord
  2007-01-31  1:16 ` [PATCH] " James Bottomley
  0 siblings, 2 replies; 34+ messages in thread
From: Mark Lord @ 2007-01-31  0:47 UTC (permalink / raw)
  To: linux-kernel, IDE/ATA development list, James Bottomley

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>
---
diff -u --recursive --new-file --exclude-from=linux_17//Documentation/dontdiff old/drivers/scsi/scsi_lib.c linux/drivers/scsi/scsi_lib.c
--- old/drivers/scsi/scsi_lib.c	2007-01-30 13:58:05.000000000 -0500
+++ linux/drivers/scsi/scsi_lib.c	2007-01-30 18:30:01.000000000 -0500
@@ -865,6 +865,12 @@
 	 */
 	if (sense_valid && !sense_deferred) {
 		switch (sshdr.sense_key) {
+		case MEDIUM_ERROR:
+			// Bad sector.  Fail it, and then continue the rest of the request:
+			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

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2007-02-02 23:07 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-31  0:47 [PATCH] scsi_lib.c: continue after MEDIUM_ERROR Mark Lord
2007-01-31  1:12 ` [PATCH] RESEND " Mark Lord
2007-01-31  1:16 ` [PATCH] " James Bottomley
2007-01-31  1:36   ` Mark Lord
     [not found]   ` <311601c90701301725n53d25a74g652b7ca3bfc64c56@mail.gmail.com>
2007-01-31  1:41     ` Mark Lord
2007-01-31  3:20       ` Ric Wheeler
2007-01-31  4:21         ` James Bottomley
2007-01-31 15:13           ` Mark Lord
2007-01-31 15:22             ` Mark Lord
2007-01-31 15:24             ` James Bottomley
2007-01-31  5:09         ` Douglas Gilbert
2007-01-31 15:08         ` Mark Lord
2007-01-31 15:23           ` Alan
2007-01-31 16:35             ` Ric Wheeler
2007-01-31 17:57             ` Mark Lord
2007-01-31 18:13               ` James Bottomley
2007-01-31 18:37                 ` Mark Lord
2007-01-31  9:30       ` Jeff Garzik
2007-01-31 14:36         ` Ric Wheeler
2007-01-31 15:28           ` Douglas Gilbert
2007-01-31 15:38             ` Mark Lord
2007-02-01 20:02   ` Mark Lord
2007-02-01 21:55     ` James Bottomley
2007-02-02  2:48       ` Mark Lord
2007-02-02 12:20       ` Ric Wheeler
2007-02-02 14:42         ` Alan
2007-02-02 14:53           ` James Bottomley
2007-02-02 16:16             ` Ric Wheeler
2007-02-02 20:16           ` Douglas Gilbert
2007-02-02 14:50         ` Alan
2007-02-02 16:06           ` Mark Lord
2007-02-02 19:49             ` Matt Mackall
2007-02-02 22:58               ` Mark Lord
2007-02-02 23:07                 ` Matt Mackall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).