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) {
--