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

From: Xuewen Wang

Date: Sun Sep 20 2026 - 02:32:34 EST


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>
---
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