storaged-project / udisks

The UDisks project provides a daemon, tools and libraries to access and manipulate disks, storage devices and technologies.
http://storaged.org/doc/udisks2-api/latest/
Other
339 stars 142 forks source link

10 Minute housekeeping_timeout keeps Western Digital Drives awake. #892

Open reidjr opened 3 years ago

reidjr commented 3 years ago

Western Digital Hard drives have a minimum 10 min sleep idle timer. If they are polled for SMART status, they will reset that timer, and wait another 10 mins before spinning down.

Where udisks2 is used, the default housekeeping timer of 10 mins means that the drive never sleeps, as the timer is always reset.

If the drive is spun down manually, then it is not woken by polling.

I have 3 different western digital hard drive models , all exhibit this behaviour.

Simply changing the housekeeping timer to 15 mins stops this issue. With this small change the WD drives spindown when Idle and stay down.

udisks2-2.8.4/src/udiskslinuxprovider.c udisks2-2.8.4.new/src/udiskslinuxprovider.c
691,692c691,692
<   /* schedule housekeeping for every 10 minutes */
<   provider->housekeeping_timeout = g_timeout_add_seconds `(10*60,`
---
>   /* schedule housekeeping for every 15 minutes */
>   provider->housekeeping_timeout = g_timeout_add_seconds (15*60,
1479c1479
< /* called from the main thread on start-up and every 10 minutes or so */
---
> /* called from the main thread on start-up and every 15 minutes or so *
stheid commented 2 years ago

image image

on my NAS it even wakes up my sleeping drive (hdparm -Y /dev/sda) as very evident in the power consumption and the dmesg logs

The problem is also described here 1 but the solution does not work on my machine.

systemctl stop udisks2 "solves" the issue, therefore i am sure it is udisks related

stheid commented 2 years ago

Even though it is somewhat an issue of udisks it seems to be caused by using setting powercontrol of the device to "auto" of the device. When i re-enable power control for the device in question stays spinned down and even the dmesg mesages disappear.

Therefore my workarround is

  powertop --auto-tune
  echo 'on' > '/sys/block/sda/device/power/control'

and the device stays quiet (with udisks2.service being active): image

That being said, i would still argue, that the issue is not solved, because udisks should in no case cause a disk to spin up just to read smart data or whatever.

bughunter2 commented 2 years ago

I can confirm this problem, even with disks from other brands such as Toshiba.

As mentioned by @stheid, I agree that udisks should NOT wake up disks to do 'housekeeping' every few minutes.

reidjr commented 2 years ago

Is there a reason why setting the housekeeping timers to 15 mins isn't the right answer ? or making it user configurable ? It is a problem that cannot be worked around because its disk firmware dependent ( I assume).

Or do all the Devs not spin down their drives or use another brand :-) :-) :-)

bughunter2 commented 2 years ago

There seem to be at least 2 cases where udisks can wake up disks or keep them awake.

For one, drives that are in sleep/standby mode seem to be woken up just to read smart data or such. That should not happen, I hope everyone agrees on that. So, changing that behavior would at least be a partial fix.

If you put a drive in sleep mode via hdparm -Y /dev/sdxxx and wait ~10 minutes, you can observe that udisks is waking up the disk. This can be observed by tracing the I/O: $ sudo blktrace -d /dev/sdxxx -a pc -o - | blkparse -i -

Aside from that, making the housekeeping timer configurable may also be helpful, as mentioned by @reidjr Also, I think udisks should strive to have defaults that at least work for, say, 80% to 99% of the users. Thus, increasing the default housekeeping timeout to 15 or 30 minutes may help reduce the number of users that experience this problem.

To sum the proposed ideas from this thread up:

Together, such changes could at least partially solve the problem and give users control to at least solve it for themselves.

jeffr1975 commented 2 years ago

I am also impacted by this issue. Stopping udisks2 stops the 4 western digital drives from spinning up. That is the only workaround I have found. I am running Ubuntu 21.10. I can't seem to get any of the suggested workarounds to stop this behavior.

reidjr commented 2 years ago

just patching this again for Ubuntu 22.04 :-( same hack fixes it.

MrDach commented 1 year ago

I am also experiencing this issue on Ubuntu 22.04 LTS server. I found a comment suggesting that disabling "Smart function" in some Gnome disks GUI should stop the polling through udisks, but since I'm running a headless version on my NAS I'm not really sure how to do so. Has anyone come up with a good way to solve this issue?

reidjr commented 1 year ago

Patch and recompile the source as per my first post is the fix without changing anything else, or turning off functionality.

Bit of googling will show this is not the first time this has come up, looks like it will never be picked up or fixed by the devs. https://github.com/storaged-project/udisks/issues/407 etc

Turning off udisk SMART should be (?) possible through /etc/udisks2/[diskidentifier].conf but you will need to search for the format, as I didnt try this myself.

MrDach commented 1 year ago

Guess I'll have to look into how you compile in Linux 😅 Always something new to learn..

chwiede commented 1 year ago

I'm affected by the same problem. Honestly, to patch the source after every upgrade can't be the solution. This hard coded 10-minute value should be configurable. Come on udisks devs, let's save some energy!

raspberryfan commented 1 year ago

I was facing the same issue with Kubuntu 22.04 LTS with udisks2, smartd and an external USB3 Seagate HDD. After trying lots of tweaks I found on the internet - without success - I came to the following solution (the drive in question is constantly connected to the host - I assume most drives affected are, only then one would want to make them go into standby): I have disabled smartd and now mount the USB drive in fstab instead of letting udisks2 do the job and set the spindown time in /etc/hdparm.conf. That way udisks2 is not involved thus does not do householding and also smartd does not bother the drive. I have not tested if I might re-enable smartd now using fstab because I am fine with the current configuration. I do check the smart status every now and then when upgrading the system. Disable smartd: ~$ sudo systemctl disable smartd Since device names can easily change with external drives it makes sense to use the UUID at least for the affected drive(s) in fstab and the /dev/disk/by-id in hdparm.conf. Find the current device name and the UUID for the HDD:

~$ lsblk -f
NAME  FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
[...]
sdc
└─sdc1
      ext4   1.0   Backup
                         cd9939ee-65dc-4567-8efe-0c146dfe8a6b    1,7T    46% /mnt/backup
[...]

Find the related /dev/disk/by-id:

~$ udevadm info --query=all --name=sdc
[...]
S: disk/by-id/wwn-0x5000c500e4f3f868
[...]

My fstab:

~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
UUID=aefa4062-0355-481a-90b2-b0e50d478b9c /                   ext4    errors=remount-ro         0       1
[...]
UUID=cd9939ee-65dc-4567-8efe-0c146dfe8a6b /mnt/backup         ext4    defaults,nofail,discard   0       0

My hdparm.conf

~$ cat /etc/hdparm.conf
# 72 = 6 minutes, two partitions are incrementally backed up to the drive, time between backups is 5 minutes,
# drive is spinning for about 10 minutes per day 
[...]
/dev/disk/by-id/wwn-0x5000c500e4f3f868 {
spindown_time = 72
}

If you want to go this way please make sure you adapt the device values when editing /etc/fstab and /etc/hdparm.conf according to your drive(s).

kub3let commented 1 year ago

Wasted 3 hours today figuring out what kept my drives from spinning down.

Really weird since I only installed udisks2 to setup the spin down.

Switching to hdparm fixed it.

CalebCZ commented 5 months ago

Hi guys, any news? I have same issue with Seagate Ironwolf 4TB NAS drive. Would it be possible to provide a patch (with timeout set to at least to 1 hour) until the release 2.11 is done, please?

lilydjwg commented 5 months ago

I have a patch to completely disable it: dont-spin-up.txt

MarkusEh commented 4 months ago

I uninstalled udisks on my server.

soxhi8 commented 1 month ago

Found this to be the cause for my issues with getting disks (HGST-made) in a file-server to spin down. Setting the interval to 15 minutes would not be a fix for my use case, since the timeout is 2 hours for this application, to minimize on spin-ups/-downs.