tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ATA TRIM?



On Sat, 10 Dec 2022, Mouse wrote:

OK, so any requests >4K will have to be packaged into further range
requests [...]

This isn't right.  Bytes 7 & 8 of a TRIM range request form a
counter.  So, a counter of 1 = (1 x max_dsm_blocks); 2 = (2 x
max_dsm_blocks) up to 0xFFFF counts.

So is max_dsm_blocks misnamed, or is it just being abused as a
dsm_granularity value by TRIM, whereas other DSM commands do use it as
a maximum?  If the former, I'd like to rename it in my tree....


OK, I've now actually looked at what the spec[1] says instead of relying
on my faulty recall of stuff I read on lwn.net years ago.

So:

A single range is 8 bytes: 6 bytes for LBA start + 2 for the count of
sectors (logical, so 512 bytes). This makes 512 * 65535 bytes that can
be trimmed by a single range.

You can have 64 ranges in a 512-byte DSM packet. This makes
64 * 512 * 65535 bytes.

max_dsm_blocks is the maximum no. of 512-byte DSM packets which the drive
will accept. In your case, 8 blocks = 4K. Therefore your drive can trim,
in a single DSM request, a maximum of

8 * 64 * 512 * 65535 = ~16 GB

You clearly know a lot more about the relevant commands than I do,


Clearly not :-(

-RVP

[1]: https://ata.wiki.kernel.org/index.php/Developer_Resources

and

https://web.archive.org/web/20200616054353if_/http://t13.org/Documents/UploadedDocuments/docs2017/di529r18-ATAATAPI_Command_Set_-_4.pdf


Home | Main Index | Thread Index | Old Index