Patch [0/3] Support eager_unmap for non ldpme sd devs

Kurt Garloff
2025-07-27T18:06:43Z

Hi,

(Resent, the original message was not text/plain only. It's too long
that I have interacted with linux MLs, sorry.)

I had to do some rearrangement of NVMe drives over several of my
machines recently. I was using a few USB NVMe enclosures for this.
One of the things that was annoying was that I had no way to discard
free space using fstrim (or with blkdiscard or mkfs / mkswap options).

The SCSI disk driver (sd_mod) would just claim that discard is not
supported. It's not true. The NVMes support it as do the enclosures.
I have a few, though all have variants of RTL9210 chips.

But sd was too conservative to let me do it.

Attached series of patches address this. (Patches are against 6.16.0-rc7.)

1/3: Introduces an eager_unmap module parameter which lets the sd driver
unmap/ws16/ws10 capabilities and issue these commands even for
devices without ldpme support (thin provisioning). The VPD pages are
being queried for all devices advertising SBC >= 3 to avoid breaking
old hardware that might barf of being asked for VPDs.
2/3: Makes the approach more conservative by guarding the requesting of
VPD pages also on eager_unmap being set. With this patch, the default
behavior is the same as before the eager_unmap patches unless the
parameter is set to non-zero.
3/3: This changes the default of eager_unmap to 1. It should be safe based
on the SBC >= 3 protection, but it's hard to know for sure with all
the possible broken hardware out there. So leave the parameter for
admins that need to set it to 0. In case we have significant fallout,
this is the one patch that would need to get reverted.

I have been running kernels with variants of these patches for over a year
now.

PS: Please copy me one responses, I have stopped being subscribed to
LKML and linux-scsi a long time ago. Sorry!