diff options
author | Darrick J. Wong <djwong@kernel.org> | 2023-10-16 09:47:34 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2023-10-17 17:45:38 -0700 |
commit | 097b4b7b64ef67a4703b89fd4064480b61557fd5 (patch) | |
tree | ef89174ec6a976be4b31c180ffdab24809ac71ed /fs/xfs/libxfs/xfs_rtbitmap.h | |
parent | a9948626849c2c65dfd201b5e9d855e62937de61 (diff) |
xfs: convert rt summary macros to helpers
Convert the realtime summary file macros to helper functions so that we
can improve type checking.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/libxfs/xfs_rtbitmap.h')
-rw-r--r-- | fs/xfs/libxfs/xfs_rtbitmap.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h index 3252ed217a6a..79ade6d2361b 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.h +++ b/fs/xfs/libxfs/xfs_rtbitmap.h @@ -170,6 +170,56 @@ xfs_rbmblock_wordptr( } /* + * Convert a rt extent length and rt bitmap block number to a xfs_suminfo_t + * offset within the rt summary file. + */ +static inline xfs_rtsumoff_t +xfs_rtsumoffs( + struct xfs_mount *mp, + int log2_len, + xfs_fileoff_t rbmoff) +{ + return log2_len * mp->m_sb.sb_rbmblocks + rbmoff; +} + +/* + * Convert an xfs_suminfo_t offset to a file block offset within the rt summary + * file. + */ +static inline xfs_fileoff_t +xfs_rtsumoffs_to_block( + struct xfs_mount *mp, + xfs_rtsumoff_t rsumoff) +{ + return XFS_B_TO_FSBT(mp, rsumoff * sizeof(xfs_suminfo_t)); +} + +/* + * Convert an xfs_suminfo_t offset to an info word offset within an rt summary + * block. + */ +static inline unsigned int +xfs_rtsumoffs_to_infoword( + struct xfs_mount *mp, + xfs_rtsumoff_t rsumoff) +{ + unsigned int mask = mp->m_blockmask >> XFS_SUMINFOLOG; + + return rsumoff & mask; +} + +/* Return a pointer to a summary info word within a rt summary block. */ +static inline xfs_suminfo_t * +xfs_rsumblock_infoptr( + struct xfs_buf *bp, + unsigned int index) +{ + xfs_suminfo_t *info = bp->b_addr; + + return info + index; +} + +/* * Functions for walking free space rtextents in the realtime bitmap. */ struct xfs_rtalloc_rec { |