udisks icon indicating copy to clipboard operation
udisks copied to clipboard

SMART polling wakes up not mounted disk disregarding UDISKS_IGNORE

Open maxnikulin opened this issue 3 years ago • 3 comments

I added a Toshiba hard disk drive to my laptop and I noticed heads load/unload clunks every 10 minutes even though I have not created any partitions on the disk. To my surprise even adding udev rule to apply UDISKS_IGNORE hint for the disk did not prevent SMART polling.

My expectations related to udisks that may be considered as 2 independent issues:

  • There is no point in so frequent polling of a disk that is not mounted. Maybe it is OK to do it e.g. once or twice a week.
  • Certainly if UDISKS_IGNORE rule is applied by udev then udisks should stop trying to get SMART state.

Some details:

  • Debian 11 bullseye (current stable)
  • udisks-2.9.2-2+deb11u1
  • udiskctl dump allows to verify that the UDISKS_IGNORE udev rule is correct, value of the related attribute is set to true.

To investigate the issue I added nohdparm kernel command line argument to make hdparm udev rule noop. It sets APM value (hdparm -B) to 254/128 when AC power adapter is plugged/disconnected. I am not sure, but I hope no other utility manages disk parameters. I do not have installed e.g. laptop-mode-tools yet, smartd service is disabled.

It seems with both APM values 128 (default for this disk) and 254 the disk never spins down, though it unloads heads after some quite short pause. hdparm -C reports active/idle. After hdparm -B 127 command disks switches to standby state after some timeout and spinning noise becomes indistinguishable.

If I force standby timeout using hdparm -S command or by adding udisks configuration file for this disk then the disks stops spinning as expected and no heads load/unload sound can be noticed, so I believe udisks at least respect standby state. Such behavior can be observed for both 128 and 254 APM levels.

I have not found a way to read default standby timeout or get/set head unload timeout. I have tried various options of hdparm, smartctl -x, sdparm.

So I believe that SMART polling in udisks is too aggressive by default and not configurable to deal with real world hard drives. I expect that disks are not disturbed by polling if they are not mounted or if ignore hint is explicitly assigned.

maxnikulin avatar Aug 01 '22 10:08 maxnikulin

The UDISKS_IGNORE is just a hint provided for higher layers, e.g. gvfs. It's mostly unused in udisksd itself, except of multipath.

At the moment there's no way to change the SMART polling interval but this is planned to be changed (not for UDisks-2.10.0 though).

tbzatek avatar Aug 01 '22 11:08 tbzatek

The UDISKS_IGNORE is just a hint provided for higher layers, e.g. gvfs. It's mostly unused in udisksd itself, except of multipath.

Thank you for clarification. Perhaps it may be considered as a documentation issue. When man for udisks(8) is running from a terminal, HintIgnore is plain text, but even on the web site info in API docs is too brief to realize its actual role. I have no idea if overview of technical design exists for udisks.

At the moment there's no way to change the SMART polling interval but this is planned to be changed (not for UDisks-2.10.0 though).

It is great. I have seen udisks and distribution specific bugs, but my impression was that it is not considered as a real issue.

However I still believe that in some cases udisks should not poll disks at all either by default or in response to user request. I admit that it is my responsibility to put unused disk in standby state. On the other hand polling of disks that are not mounted has a little sense, but may cause issues related to unexpected behavior of firmware.

Another reason why I consider current behavior as a bug is the following. I have seen a patch that if I understand it purpose correctly, should suppress polling if no I/O has been performed since previous SMART query. Nothing else reads or writes to the disk with no partitions.

One more case when unsolicited disk operations is highly undesirable: consider a system booted from a live image to run ddrescue on a failing disk. A user already aware of the problem and any seek may decrease the fraction of recoverable data.

So if UDISKS_IGNORE controls presentation then there should be a setting to change behavior. Do you assume that infinite polling interval addresses this feature request?

maxnikulin avatar Aug 01 '22 15:08 maxnikulin

I would like to vote for polling time configuration feature as after Fedora 35→37 update, my disk (WDC WD20SPZX-22UA7T0, FwRev=01.01A01) started to spin up every time its status is read. Before update this disk has never slept by itself and I had to use hd-idle on it (and it did not wake up on status read), but now pool-udisksd wakes it up every 5 minutes, which is a bit annoying.

P.S. the disk started to spin up every time because after the update, tlp daemon has SATA AHCI link power management (ALPM) timeout set to 15 seconds, so the whole SATA link goes down in case of inactivity and wakes up (with the disk) on status read.

ValdikSS avatar Dec 26 '22 17:12 ValdikSS