Block device handling from other module
valdis.kletnieks at vt.edu
valdis.kletnieks at vt.edu
Fri Apr 6 13:38:52 EDT 2018
On Fri, 06 Apr 2018 12:12:31 +0530, Rupesh Kumar said:
> My question is : Can STANDBY IMMEDIATE command be issued directly to
> SSD device ? How can I achieve it in most efficient way ?
In the source tree, see tools/laptop/freefall/freefall.c for how to do the
daemon. The sample code does a read() on a device that blocks until the
accellerometer indicates a freefall condition, after which it does a write to
/sys/block/%s/device/unload_heads to park the heads. You'll need to change
that to wait until a powerfail is indicated.
>From there, you want to chase into ata/libata-scsi.c to see what the
write() triggers - a call to ata_scsu_park_store(). Assuming your SSD acts
like an ata-scsi device, you can probably steal most of that code.
You almost certainly want to do it in two separate parts (detect powerfail
and alert userspace, and userspace drives an ATA UNLOAD command),
because trying to launch an ATA I/O from inside the powerfail interrupt
leads to madness and heavy drinking...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180406/2a49c0bf/attachment.sig>
More information about the Kernelnewbies
mailing list