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 * for more info. 968 */ 969 if (ata_spindown_compat && 970 (system_state == SYSTEM_HALT || 971 system_state == SYSTEM_POWER_OFF)) { 972 static unsigned long warned = 0; ··· 1394 ata_gen_ata_sense(qc); 1395 } 1396 } 1397 1398 if (need_sense && !ap->ops->error_handler) 1399 ata_dump_status(ap->print_id, &qc->result_tf);
··· 967 * for more info. 968 */ 969 if (ata_spindown_compat && 970 + (qc->dev->flags & ATA_DFLAG_SPUNDOWN) && 971 (system_state == SYSTEM_HALT || 972 system_state == SYSTEM_POWER_OFF)) { 973 static unsigned long warned = 0; ··· 1393 ata_gen_ata_sense(qc); 1394 } 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; 1404 1405 if (need_sense && !ap->ops->error_handler) 1406 ata_dump_status(ap->print_id, &qc->result_tf);
+1
include/linux/libata.h
··· 140 141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ 143 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 144 145 ATA_DFLAG_DETACH = (1 << 16),
··· 140 141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ 143 + ATA_DFLAG_SPUNDOWN = (1 << 10), /* XXX: for spindown_compat */ 144 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 145 146 ATA_DFLAG_DETACH = (1 << 16),