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

Bart Van Assche
2025-07-28T15:35:15Z

On 7/27/25 11:06 AM, Kurt Garloff wrote:
> 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!

Please use git format-patch --cover-letter ... and git send-email ... to
publish a patch series. Nobody looks at patches included in email
attachments. Please also make sure that your ~/.gitconfig settings match
what is expected for posting patches on Linux kernel mailing lists.

Thanks,

Bart.