Created attachment 149433 [details] Patch to spin down scsi attached disks upon power down Shutting down my system with ATA hard drives connected to several mps(4) LSI host bus adapters causes the SMART Power-Off_Retract_Count attribute to increase indicating an unclean power down. Attached is a patch to spin down the discs upon shutdown based on the code in cam/ata/ata_da.c and r203420/r214279. I'm running with this patch for over a year now and it works as intended on my system (Supermicro X9SCM-F with 3 IBM M1015 HBA's flashed with LSI 9210-8i IT firmware and 20 WD SE SATA drives). The patch also fixes a few variable formatting issues in da(4).
I just found out about hw.mps.enable_ssu. When I set this to 3 (MPS_SSU_ENABLE_SSD_ENABLE_HDD) my disks power down cleanly (i.e. no Power-Off_Retract_Count increase). You can close this bug if you want.
At the very least, hw.mps.enable_ssu should be documented in mps(4). There's probably also an argument that the default value of MPS_SSU_ENABLE_SSD_DISABLE_HDD should be changed to MPS_SSU_ENABLE_SSD_ENABLE_HDD. With 512e and SMR, nowadays even HDDs appreciate a chance to quiesce up before they're powered down.
https://reviews.freebsd.org/D4456 is up for review. It both documents the enable_ssu knob, and changes the default value such that SSU is sent to both HDDs and SSDs.
A commit references this bug: Author: rpokala Date: Fri Dec 11 21:51:00 UTC 2015 New revision: 292123 URL: https://svnweb.freebsd.org/changeset/base/292123 Log: [PR 195033] Document mps.enable_ssu mps(4) sends StartStopUnit to SATA direct-access devices during shutdown. Document the tunables which control that behavior. PR: 195033 Reviewed by: scottl Approved by: jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4456 Changes: head/share/man/man4/mps.4
(In reply to Thomas Eberhardt from comment #1) After discussing w/ scottl@, we decided *not* to change the default value of enable_ssu; I just documented it.
There is a commit referencing this PR, but it's still not closed and has been inactive for some time. Closing the PR as fixed but feel free to re-open it if the issue hasn't been completely resolved. Thanks