Subject: retrying SCSI commands
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 12/01/2001 01:41:35
Hi,
While working on ATAPI tape support I've been annoyed by
the device reporting sense/ASC/ASQ "not ready, logical unit in
process of becoming ready".
I commited code to the tape interpret_sense routine to retry this command:

 	st->asc = sense->add_sense_code;
 	st->ascq = sense->add_sense_code_qual;
 	st->mt_resid = (short) info;
+
+	if (key == SKEY_NOT_READY && st->asc == 0x4 && st->ascq == 0x1) {
+		/* Not Ready, Logical Unit Is in Process Of Becoming Ready */
+		scsipi_periph_freeze(periph, 1);
+		callout_reset(&periph->periph_callout,
+		    hz, scsipi_periph_timed_thaw, periph);
+		return (ERESTART);
+	}
 
 	/*
 	 * If the device is not open yet, let generic handle

This is mandatory for the onstream, for always return status for some
commands (e.g. rewind) before it completed. Anyway I don't think it can hurt
for other drives, and I remember hacking amanda changer scripts to wait long
enouth after a chio op, otherwise access to the drive would fail with
"Not Ready, Logical Unit Is in Process Of Becoming Ready" printed on console.
Dammit, if it's going to be ready why doesn't the driver wait for it :)

I wonder if this could also be added to the generic sense handled - or
maybe add more private sense handlers with this code. In fact all removable
media devices could benefit from this.

Does someone think this can cause problems ?

--
Manuel Bouyer <bouyer@antioche.eu.org>
--