Red Hat Bugzilla – Bug 561876
sdparm --command=stop is ineffective
Last modified: 2010-04-16 15:50:31 EDT
Created attachment 388817 [details]
open the device read only
In fedora 8 the above command would spin down my usb disk immediately.
In F11 with sdparm-1.04-1.fc11.i586 I can here the disk respond with to the command but it seems to spin up again immediately.
I think this is probably the same issue as:
The workaround described there wrt changing the udev rule works for me.
Also sdparm does open the device RDWR as verified by:
# strace -e open sdparm --verbose --command=stop /dev/sdc
open("/dev/sdc", O_RDWR|O_NONBLOCK) = 3
Also sdparm with the attached patch spins down the drive.
The patch makes sense to me, but I talk to the author of sdparm before applying.
Any news from upstream?
yes, we discussed it and it's not so simple due some difference between SCSI and ATA. As a result new command-line switch for opening the device RO is introduced and I have a release candidates of the sdparm/sg3_utils upcoming versions.
Could you expand on that a bit. I really hate unnecessary options, but if it needs to be an option fair enough. Could we try RO then fall back to RW for example?
Also hdparm sets RO by default, so why exactly is sdparm different.
The long answer from Doug:
T10 and T13 have been trying to converge the semantics
of START/STOP for some time. Folks from Seagate are
driving the effort at T10. My guess is that this
problem in some form has bitten them.
The executive summary is that START_STOP_UNIT in SCSI
is state changing in the sense that after a stop both
READ and WRITE will fail (until a start command is
sent). However in the ATA world what SAT maps
START_STOP_INIT(stop) to will not break subsequent
READs and WRITEs, it will just slow the first one
down (while it spins up the media).
A related problem came up in smartmontools recently along
these lines: if a ATA disk (via a SCSI device) is
opened RW to collect some metadata then on close
it will do a SYNCHRONIZE CACHE which will spin up an
ATA disk that had earlier been spun down. Same solution:
open the device RO.
Since sdparm and sg_start were designed for SCSI
devices my preference would be to add a '-r'
(and '--readonly') option to open the given device
I see the issue. So with the above proposed --readonly option:
--command=stop still does nothing on ATA unless it's called. That would need to be documented at least in the stop command section of the man page.
What does --command=stop do in the presence of udev and SCSI. Will that also be ineffective?
Would it be possible to detect if an ATA device is connected and open RO in that case, thus not requiring the -r option and associated documentation.
I think you should discuss it with Doug directly (see http://sg.danny.cz/sg/ for contact info) and as always - patches are welcome.
A new upstream release is available, seems like Doug has implemented the solution in comment #5. Could you please test the updated package:
and see if that helps?
Thanks for the feedback, I have pushed the update to F11, F12 and F13.