From: Darrick J. Wong Date: Fri, 30 Aug 2024 22:37:19 +0000 (-0700) Subject: xfs: fix FITRIM reporting again X-Git-Tag: v6.12-rc1~138^2~20^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c460f0f1a2bc219495e19e43daac6f8c902d81d8;p=thirdparty%2Fkernel%2Flinux.git xfs: fix FITRIM reporting again 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 Reviewed-by: Christoph Hellwig --- diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index bf1e3f330018d..d8c4a5dcca7ae 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c @@ -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;