Commit 2494a44d authored by Matthew Dharm's avatar Matthew Dharm Committed by Linus Torvalds

[PATCH] test for media-change like "popular" OSes..

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.
parent cc1741c0
...@@ -700,15 +700,17 @@ static int check_scsidisk_media_change(struct gendisk *disk) ...@@ -700,15 +700,17 @@ static int check_scsidisk_media_change(struct gendisk *disk)
* check_disk_change */ * 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 - * no cartridge loaded - NOT READY, drive with changed cartridge -
* UNIT ATTENTION, or with same cartridge - GOOD STATUS. * 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; retval = -ENODEV;
if (scsi_block_when_processing_errors(sdp)) 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. if (retval) { /* Unable to test, unit probably not ready.
* This usually means there is no disc in the * This usually means there is no disc in the
...@@ -794,10 +796,9 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, ...@@ -794,10 +796,9 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
if (sd_media_not_present(sdkp, SRpnt)) if (sd_media_not_present(sdkp, SRpnt))
return; 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. */ * Issue command to spin up drive for these cases. */
if (the_result && !sdp->removable && if (the_result && SRpnt->sr_sense_buffer[2] == NOT_READY) {
SRpnt->sr_sense_buffer[2] == NOT_READY) {
unsigned long time1; unsigned long time1;
if (!spintime) { if (!spintime) {
printk(KERN_NOTICE "%s: Spinning up disk...", printk(KERN_NOTICE "%s: Spinning up disk...",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment