Skip to content

Commit 13b8d09

Browse files
htejunJeff Garzik
authored andcommitted
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>
1 parent da071b4 commit 13b8d09

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎drivers/ata/libata-scsi.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
967967
* for more info.
968968
*/
969969
if (ata_spindown_compat &&
970+
(qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
970971
(system_state == SYSTEM_HALT ||
971972
system_state == SYSTEM_POWER_OFF)) {
972973
static unsigned long warned = 0;
@@ -1394,6 +1395,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
13941395
}
13951396
}
13961397

1398+
/* XXX: track spindown state for spindown_compat */
1399+
if (unlikely(qc->tf.command == ATA_CMD_STANDBY ||
1400+
qc->tf.command == ATA_CMD_STANDBYNOW1))
1401+
qc->dev->flags |= ATA_DFLAG_SPUNDOWN;
1402+
else if (likely(system_state != SYSTEM_HALT &&
1403+
system_state != SYSTEM_POWER_OFF))
1404+
qc->dev->flags &= ~ATA_DFLAG_SPUNDOWN;
1405+
13971406
if (need_sense && !ap->ops->error_handler)
13981407
ata_dump_status(ap->print_id, &qc->result_tf);
13991408

‎include/linux/libata.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ enum {
140140

141141
ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
142142
ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */
143+
ATA_DFLAG_SPUNDOWN = (1 << 10), /* XXX: for spindown_compat */
143144
ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
144145

145146
ATA_DFLAG_DETACH = (1 << 16),

0 commit comments

Comments
 (0)