libata: track spindown status and skip spindown_compat if possible

Our assumption that most distros issue STANDBYNOW seems wrong. The
upstream sysvinit and thus many distros including gentoo and opensuse
don't take any action for libata disks on spindown. We can skip
compat handling for these distros so that they don't need to update
anything to take advantage of kernel-side shutdown.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik 13b8d09f da071b42

+10
+9
drivers/ata/libata-scsi.c
··· 967 967 * for more info. 968 968 */ 969 969 if (ata_spindown_compat && 970 + (qc->dev->flags & ATA_DFLAG_SPUNDOWN) && 970 971 (system_state == SYSTEM_HALT || 971 972 system_state == SYSTEM_POWER_OFF)) { 972 973 static unsigned long warned = 0; ··· 1394 1393 ata_gen_ata_sense(qc); 1395 1394 } 1396 1395 } 1396 + 1397 + /* XXX: track spindown state for spindown_compat */ 1398 + if (unlikely(qc->tf.command == ATA_CMD_STANDBY || 1399 + qc->tf.command == ATA_CMD_STANDBYNOW1)) 1400 + qc->dev->flags |= ATA_DFLAG_SPUNDOWN; 1401 + else if (likely(system_state != SYSTEM_HALT && 1402 + system_state != SYSTEM_POWER_OFF)) 1403 + qc->dev->flags &= ~ATA_DFLAG_SPUNDOWN; 1397 1404 1398 1405 if (need_sense && !ap->ops->error_handler) 1399 1406 ata_dump_status(ap->print_id, &qc->result_tf);
+1
include/linux/libata.h
··· 140 140 141 141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 142 142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ 143 + ATA_DFLAG_SPUNDOWN = (1 << 10), /* XXX: for spindown_compat */ 143 144 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 144 145 145 146 ATA_DFLAG_DETACH = (1 << 16),