public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sd: retry read_capacity on UNIT_ATTENTION
@ 2010-04-01 13:44 Hannes Reinecke
  2010-04-01 14:30 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2010-04-01 13:44 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi


Hazard testing uncovered yet another bug in sd. Under heavy
reset activity the retry counter might be exhausted and
the command will be returned with sense UNIT_ATTENTION/0x29/00
(POWER ON, RESET, OR BUS DEVICE RESET OCCURRED). In those
cases we should just increase the retry counter again,
retrying one more to clear up this Unit Attention state.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1962bea..7d75a21 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1454,8 +1454,15 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 		if (media_not_present(sdkp, &sshdr))
 			return -ENODEV;
 
-		if (the_result)
+		if (the_result) {
 			sense_valid = scsi_sense_valid(&sshdr);
+			if (sense_valid &&
+			    sshdr.sense_key == UNIT_ATTENTION &&
+			    sshdr.asc = 0x29 && sshdr.asq == 0x00)
+			    /* Device reset might occur several times,
+			     * give it one more chance */
+			    retries++;
+		}
 		retries--;
 
 	} while (the_result && retries);

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

end of thread, other threads:[~2010-04-08 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-01 13:44 [PATCH] sd: retry read_capacity on UNIT_ATTENTION Hannes Reinecke
2010-04-01 14:30 ` James Bottomley
2010-04-08  7:36   ` Hannes Reinecke
2010-04-08 13:48     ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox