Skip to contentSkip to conversation

sd: always retry READ CAPACITY for ALUA state transition

PATCH In review Hannes Reinecke 2 participants 3 messages Oct 17, 2017 – Oct 18, 2017 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sd: always retry READ CAPACITY for ALUA state transition

During ALUA state transitions the device might return a sense code 02/04/0a (Logical unit not accessible, asymmetric access state transition). As this is a transient error we should just retry the READ CAPACITY call until the state transition finishes and the correct capacity can be returned.

---
 drivers/scsi/sd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/scsi/sd.c +10 -0
index 37daf9a..b4647f5 100644
@@ -2333,6 +2333,11 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 				 * give it one more chance */
 				if (--reset_retries > 0)
 					continue;
+			if (sense_valid &&
+			    sshdr.sense_key == NOT_READY &&
+			    sshdr.asc == 0x04 && sshdr.ascq == 0x0A)
+				/* ALUA state transition; always retry */
+				continue;
 		}
 		retries--;
 
@@ -2418,6 +2423,11 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 				 * give it one more chance */
 				if (--reset_retries > 0)
 					continue;
+			if (sense_valid &&
+			    sshdr.sense_key == NOT_READY &&
+			    sshdr.asc == 0x04 && sshdr.ascq == 0x0A)
+				/* ALUA state transition; always retry */
+				continue;
 		}
 		retries--;
 
Signature · 1 line
1.8.5.6
maintainer
#1 lore raw
Quoted 6 lines · Hannes Reinecke

During ALUA state transitions the device might return a sense code 02/04/0a (Logical unit not accessible, asymmetric access state transition). As this is a transient error we should just retry the READ CAPACITY call until the state transition finishes and the correct capacity can be returned.

This will lock up the system if some ALUA initiator gets into a state where it always returns transitioning and never completes, which doesn't look like the best way to handle problem devices.

I thought after the ALUA transition the LUN gives a unit attention ... can't you use that some way to trigger the capacity re-read, so do asynchronous event notification instead of polling forever.

James

#2 lore raw
Quoted 8 lines · James Bottomley
Quoted 6 lines · Hannes Reinecke

During ALUA state transitions the device might return a sense code 02/04/0a (Logical unit not accessible, asymmetric access state transition). As this is a transient error we should just retry the READ CAPACITY call until the state transition finishes and the correct capacity can be returned.

Quoted 8 lines

This will lock up the system if some ALUA initiator gets into a state where it always returns transitioning and never completes, which doesn't look like the best way to handle problem devices.

I thought after the ALUA transition the LUN gives a unit attention ... can't you use that some way to trigger the capacity re-read, so do asynchronous event notification instead of polling forever.

Hmm.
Will give it a try.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)