]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
SCSI: sr: report more accurate drive status after closing the tray.
authorPeter Jones <pjones@redhat.com>
Tue, 18 Aug 2009 14:18:20 +0000 (10:18 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Sep 2009 03:17:50 +0000 (20:17 -0700)
commit 96bcc722c47d07b6fd05c9d0cb3ab8ea5574c5b1 upstream

[SCSI] sr: report more accurate drive status after closing the tray.

So, what's happening here is that the drive is reporting a sense of
2/4/1 ("logical unit is becoming ready") from sr_test_unit_ready(), and
then we ask for the media event notification before checking that result
at all.  The check_media_event_descriptor() call isn't getting a check
condition, but it's also reporting that the tray is closed and that
there's no media.  In actuality it doesn't yet know if there's media or
not, but there's no way to express that in the media event status field.

My current thought is that if it told us the device isn't yet ready, we
should return that immediately, since there's nothing that'll tell us
any more data than that reliably:

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/sr_ioctl.c

index ae87d08df58832c9d6ce60a091cbb8ace3203d7b..25f20083957f34fd9c926757580389009999efc4 100644 (file)
@@ -309,6 +309,11 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
        if (0 == sr_test_unit_ready(cd->device, &sshdr))
                return CDS_DISC_OK;
 
+       /* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */
+       if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY
+                       && sshdr.asc == 0x04 && sshdr.ascq == 0x01)
+               return CDS_DRIVE_NOT_READY;
+
        if (!cdrom_get_media_event(cdi, &med)) {
                if (med.media_present)
                        return CDS_DISC_OK;