summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_refcount.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-10-29 00:48:58 +0200
committerDarrick J. Wong <djwong@kernel.org>2022-10-31 16:58:20 +0100
commitb65e08f83b119ae9345ed23d4da357a72b3cb55c (patch)
tree5c25440a24f3ed77d51f8401412b939e20f6a8fb /fs/xfs/libxfs/xfs_refcount.c
parentxfs: make sure aglen never goes negative in xfs_refcount_adjust_extents (diff)
downloadlinux-b65e08f83b119ae9345ed23d4da357a72b3cb55c.tar.xz
linux-b65e08f83b119ae9345ed23d4da357a72b3cb55c.zip
xfs: create a predicate to verify per-AG extents
Create a predicate function to verify that a given agbno/blockcount pair fit entirely within a single allocation group and don't suffer mathematical overflows. Refactor the existng open-coded logic; we're going to add more calls to this function in the next patch. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_refcount.c')
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 831353ba96dc..1a50ca53304a 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -135,11 +135,7 @@ xfs_refcount_get_rec(
}
/* check for valid extent range, including overflow */
- if (!xfs_verify_agbno(pag, realstart))
- goto out_bad_rec;
- if (realstart > realstart + irec->rc_blockcount)
- goto out_bad_rec;
- if (!xfs_verify_agbno(pag, realstart + irec->rc_blockcount - 1))
+ if (!xfs_verify_agbext(pag, realstart, irec->rc_blockcount))
goto out_bad_rec;
if (irec->rc_refcount == 0 || irec->rc_refcount > MAXREFCOUNT)