]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: fix FITRIM reporting again
authorDarrick J. Wong <djwong@kernel.org>
Fri, 30 Aug 2024 22:37:19 +0000 (15:37 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:20 +0000 (08:58 -0700)
Don't report FITRIMming more bytes than possibly exist in the
filesystem.

Fixes: 410e8a18f8e93 ("xfs: don't bother reporting blocks trimmed via FITRIM")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_discard.c

index bf1e3f330018d9694f678a922e678f5b45ec14f0..d8c4a5dcca7aea34daad4dd5381d689b4a73238d 100644 (file)
@@ -707,7 +707,7 @@ xfs_ioc_trim(
                return last_error;
 
        range.len = min_t(unsigned long long, range.len,
-                         XFS_FSB_TO_B(mp, max_blocks));
+                         XFS_FSB_TO_B(mp, max_blocks) - range.start);
        if (copy_to_user(urange, &range, sizeof(range)))
                return -EFAULT;
        return 0;