Re: [PATCH v5 2/2] Add support for SCT Write Same
From: Tom Yan
Date: Wed Aug 10 2016 - 16:19:46 EST
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).