Re: Boot failure with block/for-next

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: James Bottomley
Date: Friday, December 24, 2010 - 8:47 am

On Fri, 2010-12-24 at 12:03 +0100, Tejun Heo wrote:

Oh, you didn't put a ->removable check in enough paths.  The setting on
UA was still unconditional, as was the check in sd_prep_fn().


The code can never really be merged.  for CD/DVD, UA pretty much does
mean medium removal.  Discs and arrays emit a panoply of UA events (it's
the SCSI asynchronous event mechanism) if you assume media change on all
of them, there'll be terrible confusion.  We can narrow to 28/00 that
means medium may have changed.  It could really do with checking by
someone who has a removable disc device, though ... it looks like some
of the 3B/xx might be applicable.


Thanks,

James

---

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 7d25746..1995533 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -578,7 +578,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
 		goto out;
 	}
 
-	if (sdp->changed) {
+	if (sdp->removable && sdp->changed) {
 		/*
 		 * quietly refuse to do anything to a changed disc until 
 		 * the changed bit has been reset
@@ -1008,6 +1008,9 @@ static int media_not_present(struct scsi_disk *sdkp,
 	/* not invoked for commands that could return deferred errors */
 	switch (sshdr->sense_key) {
 	case UNIT_ATTENTION:
+		if (sdkp->device->removable && sshdr->asc == 0x28 &&
+		    sshdr->ascq == 0x00)
+			sdkp->device->changed = 1;
 	case NOT_READY:
 		/* medium not present */
 		if (sshdr->asc == 0x3A) {


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Boot failure with block/for-next, James Bottomley, (Wed Dec 22, 10:27 am)
Re: Boot failure with block/for-next, Tejun Heo, (Wed Dec 22, 10:53 am)
Re: Boot failure with block/for-next, James Bottomley, (Wed Dec 22, 9:31 pm)
Re: Boot failure with block/for-next, Tejun Heo, (Thu Dec 23, 3:09 am)
Re: Boot failure with block/for-next, James Bottomley, (Thu Dec 23, 8:27 am)
Re: Boot failure with block/for-next, Tejun Heo, (Thu Dec 23, 8:52 am)
Re: Boot failure with block/for-next, James Bottomley, (Thu Dec 23, 9:10 am)
Re: Boot failure with block/for-next, Tejun Heo, (Thu Dec 23, 9:13 am)
Re: Boot failure with block/for-next, James Bottomley, (Thu Dec 23, 11:25 am)
Re: Boot failure with block/for-next, Tejun Heo, (Fri Dec 24, 4:03 am)
Re: Boot failure with block/for-next, James Bottomley, (Fri Dec 24, 8:47 am)