Re: [PATCH v1] ntfs: preserve the 64-bit FITRIM minimum length

From: Hyunchul Lee

Date: Mon Sep 21 2026 - 04:04:16 EST


2026년 9월 20일 (일) 오후 3:32, Xuewen Wang <wangxuewen@xxxxxxxxxx>님이 작성:
>
> The minlen member of struct fstrim_range is a 64-bit byte count, but
> ntfs_ioctl_fitrim() uses max_t(u32, ...) to compare it with the device's
> discard granularity. This truncates the requested minimum length before
> passing it to ntfs_trim_fs().
>
> For example, a minimum length of 4 GiB is reduced to the discard
> granularity, allowing smaller free extents to be discarded. The truncated
> minimum length is also copied back to userspace.
>
> Use max_t(u64, ...) to preserve the requested minimum length. The bitmap
> scan already compares the aligned extent length against range->minlen
> using 64-bit values.
>
> Fixes: 9c87959601e8 ("ntfs: update file operations")
> Signed-off-by: Xuewen Wang <wangxuewen@xxxxxxxxxx>
> Reviewed-by: Baolin Liu <liubaolin@xxxxxxxxxx>

Looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>

> ---
> fs/ntfs/file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 8164326b7812..e315fed4d13b 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -866,7 +866,7 @@ static int ntfs_ioctl_fitrim(struct ntfs_volume *vol, unsigned long arg)
> if (range.len < vol->cluster_size)
> return -EINVAL;
>
> - range.minlen = max_t(u32, range.minlen, bdev_discard_granularity(dev));
> + range.minlen = max_t(u64, range.minlen, bdev_discard_granularity(dev));
>
> err = ntfs_trim_fs(vol, &range);
> if (err < 0)
> --
> 2.25.1
>


--
Thanks,
Hyunchul