diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-10-26 23:31:27 +0200 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-10-31 16:58:21 +0100 |
commit | f492135df0aa0417337f9b8b1cc6d6a994d61d25 (patch) | |
tree | abcd902f27b79369f061dc278aa150e3d09b18d2 /fs/xfs/libxfs/xfs_refcount.h | |
parent | xfs: report refcount domain in tracepoints (diff) | |
download | linux-f492135df0aa0417337f9b8b1cc6d6a994d61d25.tar.xz linux-f492135df0aa0417337f9b8b1cc6d6a994d61d25.zip |
xfs: refactor domain and refcount checking
Create a helper function to ensure that CoW staging extent records have
a single refcount and that shared extent records have more than 1
refcount. We'll put this to more use 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.h')
-rw-r--r-- | fs/xfs/libxfs/xfs_refcount.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h index 3beb5a30a9c9..ee32e8eb5a99 100644 --- a/fs/xfs/libxfs/xfs_refcount.h +++ b/fs/xfs/libxfs/xfs_refcount.h @@ -55,6 +55,18 @@ struct xfs_refcount_intent { xfs_fsblock_t ri_startblock; }; +/* Check that the refcount is appropriate for the record domain. */ +static inline bool +xfs_refcount_check_domain( + const struct xfs_refcount_irec *irec) +{ + if (irec->rc_domain == XFS_REFC_DOMAIN_COW && irec->rc_refcount != 1) + return false; + if (irec->rc_domain == XFS_REFC_DOMAIN_SHARED && irec->rc_refcount < 2) + return false; + return true; +} + void xfs_refcount_increase_extent(struct xfs_trans *tp, struct xfs_bmbt_irec *irec); void xfs_refcount_decrease_extent(struct xfs_trans *tp, |