Skip to content

ata: DSM TRIM fix and improvements

Niklas Cassel linux-ide stable 3 versions – Applied

Status from this message: Applied to for-7.3. Thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesApplied
  2. v22 patches 1 replySuperseded
  3. v12 patches 3 repliesSuperseded

Changes in v3 from the cover letter

-Use min_not_zero() instead of min() to guard against a device reporting
an invalid sector size.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/2ata: libata-scsi: fix DSM TRIM for sector sizes larger than 2048 bytesdrivers/ata/libata-scsi.c+14 -140 replies
2/2ata: libata-scsi: scale DSM TRIM payload by MAX PAGES PER DSM COMMANDdrivers/ata/libata-scsi.c include/linux/ata.h+107 -411 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchHannes Reinecke
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] ata: DSM TRIM fix and improvements

Hello all,

This fixes DSM TRIM for 4Kn devices, which has ironically been broken since commit ef2d7392c4ec ("libata: SCT Write Same / DSM Trim"), which claimed to correct the DSM TRIM handling for 4Kn devices.

The first commit is a small fix that can be backported, which limits the DSM TRIM to what we currently report in the Block Limits VPD page. We currently report a single 512 byte page of entries, i.e. 64 Entries, where each entry has a maximum of U16_MAX logical blocks.

The second commit:
-Improves the support by reading the MAX PAGES PER DSM COMMAND limit and
populates the Block Limits VPD page accordingly.
-Modifies ata_scsi_write_same_xlat() to properly support up to this amount
of pages.
-Removed the intermediate copying to ata_scsi_rbuf, writes to the scsi
buffer directly.

Practically, sd still caps n_block at SD_MAX_WS16_BLOCKS (~3 pages actually used on 4Kn), so while removing the limit on ATA_SCSI_RBUF_SIZE (2048) - i.e. 4 pages), we will still be limited by SD_MAX_WS16_BLOCKS. The main improvement is not longer taking the ata_scsi_rbuf_lock and doing and extra copy from ata_scsi_rbuf.

Changes since v2:
-Use min_not_zero() instead of min() to guard against a device reporting
an invalid sector size.

Niklas Cassel (2):
ata: libata-scsi: fix DSM TRIM for sector sizes larger than 2048 bytes
ata: libata-scsi: scale DSM TRIM payload by MAX PAGES PER DSM COMMAND

 drivers/ata/libata-scsi.c | 137 ++++++++++++++++++++++++++------------
 include/linux/ata.h       |  13 ++++
 2 files changed, 108 insertions(+), 42 deletions(-)
Signature · 1 line
2.55.0