Seagate / openSeaChest

Cross platform utilities useful for performing various operations on SATA, SAS, NVMe, and USB storage devices.
Other
479 stars 61 forks source link

openSeaChest_PowerControl.exe --standby 1200000 instant spindown #107

Closed dabugen closed 1 year ago

dabugen commented 1 year ago

Hello,

I hope this message finds you well. I wanted to thank you for providing such great software that is a great alternative to older programs like HDPARM, especially with its EPC support.

I have been running some tests with openSeaChest_PowerControl.exe on my Windows Server 2022, and overall it seems to be working well. However, when I use the "--standby" command to set a 20-minute sleep/standby/spin-down time for my old (non-EPC) hard drives (the full command line I used was "openSeaChest_PowerControl.exe -d all --standby 1200000"), all of the drives spin-down/go to standby instantly after the command is issued.

Although the drives spin back up again when I provoke disk activity, and go to standby again after 20 minutes (which shows that it was set all fine), this behavior does not occur with any of the EPC idle modes nor standby_y or standby_z. I believe this to be a bug, as HDPARM (which also sets the legacy standby time) does not exhibit this behavior.

Thank you for your attention to this matter. I appreciate your efforts in resolving this issue and continuing to provide excellent software.

dabugen commented 1 year ago

I´ve tested it extensively today and it´s pretty clear, each time the "--standby" switch is used with a timer value, the drive is put to instant standby after it´s been set, regardless of the timer value. Clearly a bug in my opinion.

vonericsen commented 1 year ago

@dabugen,

Thanks for reporting this.

One funky thing about the old ATA standby timer is it can be set by either a standby command or a idle command according to the spec. The openSeaChest code is using the standby command to do this right now, but I will investigate switching to the idle command instead, or at least something to detect the drive's state and choose the command based on that...like if already in standby change using standby, otherwise use the idle command to set it.

The reason the standby command is used to set this timer is because I used the SAT (SCSI to ATA translation) spec as a reference which uses the standby command on non-EPC drives to configure this timer. There may be a reason for the spec to have chosen the standby command instead of idle; like some drives did not set the timer properly from idle or something else. I will see if I can find out more and whether there was some other issue the spec committee was working around, at the very least so I can be aware of some other funky behavior that could happen using idle instead.

vonericsen commented 1 year ago

@dabugen,

I have pushed a fix for this on our opensea-operations submodule. After checking with the spec committee representatives there doesn't seem to be a case for not using idle to set the timer on old drives. So now the behavior will be: take the timer value, convert it with the SAT spec formula, then if not in standby, use the idle command to set the timer (which will keep the drive spinning, but may cause it to move to idle from active). If it is in standby already, it will set the timer using the standby command so it will not cause the drive to move to a spinning state either. There is no way to keep the drive in "active" mode with these old timers, so idle is the closest I can get with this, but will prevent the drive from spinning up and down immediately when using this option.

dabugen commented 1 year ago

Very interesting read, thanks for the explanation and fix. I´ll test it as soon as there is a release with the commit for Windows. Or is there a way to download a pre-release with the fix for testing? Thanks again for taking the time to look into this, explain it, and fix it, it´s much appreciated!

vonericsen commented 1 year ago

Hmm, I can click the green checkmark from my commit to get to the CI and download the artifact (but it is not the most intuitive), but IDK if others can do this or not....

So I downloaded it and am attaching the Windows build here so you can try it out. Let me know if you run into any issues with it 😃 openSeaChest-develop-win-x64.zip

I do not have a release timeline yet since we just did one recently, but if we do an update (v23.03.01 for example) I would include this commit into that build. I figure it is best to share this artifact for now until we decide when to do a new build.

dabugen commented 1 year ago

Thanks a lot, that´s appreciated! I´ll test it soon :-)

vonericsen commented 1 year ago

I have included this change as part of v23.03.1.

I'm closing this for now, but please feel free to reopen this issue if you need me to look at this some more. Also feel free to create a new issue for anything else you find.

dabugen commented 1 year ago

Perfect, thanks a lot, it works without issues now.