diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-10-28 15:48:58 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-10-31 08:58:20 -0700 |
commit | b65e08f83b119ae9345ed23d4da357a72b3cb55c (patch) | |
tree | 5c25440a24f3ed77d51f8401412b939e20f6a8fb /fs/xfs/libxfs/xfs_ag.h | |
parent | f850995f60e49818093ef5e477cdb0ff2c11a0a4 (diff) |
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_ag.h')
-rw-r--r-- | fs/xfs/libxfs/xfs_ag.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 517a138faa66..191b22b9a35b 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -133,6 +133,21 @@ xfs_verify_agbno(struct xfs_perag *pag, xfs_agblock_t agbno) return true; } +static inline bool +xfs_verify_agbext( + struct xfs_perag *pag, + xfs_agblock_t agbno, + xfs_agblock_t len) +{ + if (agbno + len <= agbno) + return false; + + if (!xfs_verify_agbno(pag, agbno)) + return false; + + return xfs_verify_agbno(pag, agbno + len - 1); +} + /* * Verify that an AG inode number pointer neither points outside the AG * nor points at static metadata. |