redhat-performance / tuned

Tuning Profile Delivery Mechanism for Linux
GNU General Public License v2.0
809 stars 177 forks source link

Not seeing hdd spindown #1

Closed jflorian closed 7 years ago

jflorian commented 7 years ago

My understanding is that hdd spindown should occur automatically with the balanced profile, right? I have a simple setup where CentOS 7 is installed on sda and sdb/sdc are joined with LVM to make an iSCSI target (using tgtd). To rule out disk activity keeping sd[bc] spun up, I've stopped the tgtd service so these two drives should be completely idle. Yet, whenever I query them:

$ sudo smartctl --nocheck standby -i /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-514.2.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Caviar Black
Device Model:     WDC WD1502FAEX-007BA0
Serial Number:    WD-WMAY03425998
LU WWN Device Id: 5 0014ee 0584b74fe
Firmware Version: 05.01D05
User Capacity:    1,500,301,910,016 bytes [1.50 TB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 2.6, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Sat Jan 21 13:43:44 2017 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Power mode is:    ACTIVE or IDLE

$ sudo smartctl --nocheck standby -i /dev/sdc
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-514.2.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Caviar Green (AF, SATA 6Gb/s)
Device Model:     WDC WD20EZRX-00D8PB0
Serial Number:    WD-WMC4M2715769
LU WWN Device Id: 5 0014ee 6aef40058
Firmware Version: 80.00A80
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is:    Sat Jan 21 13:43:45 2017 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Power mode is:    ACTIVE or IDLE

With tuned, I shouldn't need to set spindown with hdparm myself, correct? I've only started digging into the code, but something tells me I missed something essential and basic.

jeremyeder commented 7 years ago

Personally do not have experience with desktop use-cases for Tuned. My team's focus is on the server profiles. Perhaps @yarda could take a peek?

jflorian commented 7 years ago

I'd like this for desktop use also, but this case is actually for a Bacula server. Most of the day it's dormant so I'd like the drives to spin down until the backups are to be run again. Here the iSCSI target provides the Bacula server with its storage pool for the disk-based backup volumes. This particular example may be moot because the iSCSI target also provides storage for Bacula's PostgreSQL database and that service seems to keept the drive awake regardless.

Nevertheless, I'm still very curious for the more typical desktop case if/how tuned can help.

olysonek commented 7 years ago

I ran into this bug myself. At least in my case, it is caused by the fact that every time 'hdparm -S' is run on the drive, the drive spins up. And because tuned, with dynamic tunings enabled, updates the tuning and runs hdparm every couple of seconds, the drive actually keeps spinning up and down.

I worked around this by creating my own tuned profile, where I manualy set the spindown time, and then I globally disabled dynamic tuning (/etc/tuned/tuned-main.conf). This works for me, as I want the drive in standby mode all the time. But I guess this might not be appropriate in your case.

Maybe we could "solve" this by providing less power levels in the disk plugin, so that tuned runs hdparm less frequently: https://github.com/redhat-performance/tuned/blob/master/tuned/plugins/plugin_disk.py#L20

yarda commented 7 years ago

Unfortunately I do not have rotary disk handy to check it, but if hdparm -S is always waking up the drive we should probably:

olysonek commented 7 years ago

@yarda, I put up PR#31 dealing with the last point you mentioned.

@jflorian, Can you test this? It does fix the issue for me, but there might be another problem, because even without this change you should see the spindown after at most 10 minutes (when tuned reaches the most powersaving level), if the drive is completely idle.

olysonek commented 7 years ago

@jflorian Okay, I guess I should have asked about the more obvious things, before associating this with a different issue I found (but hey, at least I helped myself :)).

Yarda told me yesterday, that dynamic tuning is disabled by default in RHEL. Also, there's nothing in the default balanced profile, that should cause the disk to spindown. So two questions:

  1. Do you have dynamic tuning enabled? Check /etc/tuned/tuned-main.conf. If you enable this, tuned should change the power management levels according to the current disk activity. However it currently doesn't work very well in my experience - it tends to get stuck in a power saving setting even if the drive is relatively busy.
  2. Did you make any modifications to the balanced profile? You could manually set the spindown time there.

If you're using the default configuration, there's no reason the drive should spin down. Where did you learn the information that it should?