Re: [PATCH v5 2/2] Add support for SCT Write Same
From: Shaun Tancheff
Date: Wed Aug 10 2016 - 17:21:53 EST
On Wed, Aug 10, 2016 at 6:30 AM, Tom Yan <tom.ty89@xxxxxxxxx> wrote:
> On 10 August 2016 at 14:31, Tom Yan <tom.ty89@xxxxxxxxx> wrote:
>> I don't really know about SCT Write Same but there is one concern I
>> could I think of.
>>
>> libata's SATL would report a maximum write same length base on the
>> number of sectors a one-block TRIM payload can describe at most, which
>> is 65535 * 64 = 4194240 (see ata_scsiop_inq_b0 in libata-scsi.c). If
>> the drive does not support TRIM, it will not report such length. That
>> is technically fine, as per SBC standard, and I suppose the SCSI disk
>> driver would use SD_MAX_WS16_BLOCKS = 0x7fffff (8388607).
>
> Actually it will use SD_MAX_WS10_BLOCKS = 0xffff (65535) in such case.
> See sd_config_write_same() in sd.c. So if the device support TRIM,
> each SCT Write Same will cover 4194240 logical sectors; if it does
> not, each will cover 65535 logical sectors. In that case, perhaps we
> should report the same value in the Maximum Write Same Length field
> when (only) SCT Write Same is supported? (Not the Optimal Unmap
> Granularity field though).
You are correct in that we can advertise the larger limit in
ata_scsi_dev_config() when only SCT write same is supported
rather than fall back to WS10.
TRIM is bound by an interface maximum. You can only stuff 64 entries
of a 16 bit length followed by 48 bit lba into a 512 byte block.
SCT is not restricted (you can wipe an entire drive) however there
is a practical limit in that I have coded the SCT to operate
in the foreground so the command could timeout depending
on how fast the media can write.
On my machine the default timeout is 30s so to clear 4194240 (16G):
30s -> 547 MB/s
60s -> 274 MB/s
90s -> 183 MB/s
120s -> 137 MB/s
So for my drives 8G and 30s or 16G and 60s is fine.
For older or slow drives 4G and 30s should be fine.
I really am not sure what would be considered the correct
solution though. I believe that the WRITE SAME defaults
are currently being chosen around physical limits.
We could reduce the trim to 16 entries when SCT is available and
bump SCT to the same 16 * 63335 maximum?
I think we can also bump the command timeout for WRITE SAME?
Suggestions are welcome.
--
Shaun Tancheff