]> git.hungrycats.org Git - linux/commitdiff
[PATCH] test for media-change like "popular" OSes..
authorMatthew Dharm <mdharm-scsi@one-eyed-alien.net>
Sun, 3 Nov 2002 08:43:08 +0000 (00:43 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 3 Nov 2002 08:43:08 +0000 (00:43 -0800)
This patch changes how media-change is detected to use a mechanism more
similar to what 'popular' OSes use.

The motive for this change is that more and more emulated-SCSI devices
(sbp2, usb-storage, etc) don't support START_STOP unless they need it.
Other OSes won't send a START_STOP unless the device reports NOT_READY,
indicating that it needs an explicit command to start up.

One could argue that these devices are out-of-spec, but they are so common
that they basically define the de facto spec.

Basically, any device that needs a START_STOP should still get it, but ones
that don't need it won't.

drivers/scsi/sd.c

index 10c72cd77c16be16574402c6d8d8417637075ec1..cd2a0e4daa83495dec0948156e5ee702686291f5 100644 (file)
@@ -700,15 +700,17 @@ static int check_scsidisk_media_change(struct gendisk *disk)
                                 * check_disk_change */
        }
 
-       /* Using Start/Stop enables differentiation between drive with
+       /* Using TEST_UNIT_READY enables differentiation between drive with
         * no cartridge loaded - NOT READY, drive with changed cartridge -
         * UNIT ATTENTION, or with same cartridge - GOOD STATUS.
-        * This also handles drives that auto spin down. eg iomega jaz 1GB
-        * as this will spin up the drive.
+        *
+        * Drives that auto spin down. eg iomega jaz 1G, will be started
+        * by sd_spinup_disk() from sd_init_onedisk(), which happens whenever
+        * sd_revalidate() is called.
         */
        retval = -ENODEV;
        if (scsi_block_when_processing_errors(sdp))
-               retval = scsi_ioctl(sdp, SCSI_IOCTL_START_UNIT, NULL);
+               retval = scsi_ioctl(sdp, SCSI_IOCTL_TEST_UNIT_READY, NULL);
 
        if (retval) {           /* Unable to test, unit probably not ready.
                                 * This usually means there is no disc in the
@@ -794,10 +796,9 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
                if (sd_media_not_present(sdkp, SRpnt))
                        return;
 
-               /* Look for non-removable devices that return NOT_READY.
+               /* Look for devices that return NOT_READY.
                 * Issue command to spin up drive for these cases. */
-               if (the_result && !sdp->removable &&
-                   SRpnt->sr_sense_buffer[2] == NOT_READY) {
+               if (the_result && SRpnt->sr_sense_buffer[2] == NOT_READY) {
                        unsigned long time1;
                        if (!spintime) {
                                printk(KERN_NOTICE "%s: Spinning up disk...",