[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/51252: SATA disk not powered off before shutdown
>Synopsis: SATA disk not powered off before shutdown
>Arrival-Date: Fri Jun 17 21:25:00 +0000 2016
>Originator: Anindya Mukherjee
>Release: NetBSD 7.0.1_PATCH (GENERIC)
NetBSD functor 7.0.1_PATCH NetBSD 7.0.1_PATCH (GENERIC) #0: Wed Jun 8 22:32:47 PDT 2016 anindya@functor:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
I'm running NetBSD 7.0.1_PATCH (GENERIC) amd64 on a Dell laptop. Almost everything is working perfectly, except the fact that every time I shutdown using the -p switch, the hard drive makes a loud click sound as the system powers off. I checked the SMART status (atactl and smartctl) and after every poweroff the Power_Off-Retract-Count parameter increases by 1.
I did some searching on the web and came across PR #21531 where this issue was discussed from 2003-2008 and finally a patch was committed which resolved the issue by sending the STANDBY_IMMEDIATE command to the disk before powering off. Since then the code has been refactored, but it is present in src/sys/dev/ata/wd.c line 1970 (wd_shutdown) which calls line 1848 (wd_standby). This seemed strange since the disk was definitely not being spun down.
I attached a remote gdb instance and stepped through the code during shutdown, breaking on wd_flushcache() which is always called. The code path taken is wdclose()->wdlastclose() (lines 1029, 1014). I can see that the cache is flushed but then the device is deleted in line 1023. Subsequently, power is cut off during shutdown, causing an emergency retract. So, it seems at least for newer sata disks the spindown code is not being called. I'm fairly new to NetBSD code so there is a chance I read this wrong, so feel free to correct me.
Ideally I'd like the disk to spin down during poweroff (-p) and halt (-h), perhaps settable using a sysctl, but not during a reboot (-r).
There is a discussion on this at:
Install NetBSD 7.0.1_PATCH (GENERIC) amd64 on a laptop
shutdown -p now
disk makes a loud click before poweroff
Main Index |
Thread Index |