summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_rtbitmap.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-10-16 09:44:13 -0700
committerDarrick J. Wong <djwong@kernel.org>2023-10-17 16:26:25 -0700
commit90d98a6ada1da0f8797ff3f5adafd175dd8c0a81 (patch)
treeeb049ef082910ac663b2be0ed7794a59d7723b58 /fs/xfs/libxfs/xfs_rtbitmap.h
parentef5a83b7e597038d1c734ddb4bc00638082c2bf1 (diff)
downloadlinux-90d98a6ada1da0f8797ff3f5adafd175dd8c0a81.tar.gz
linux-90d98a6ada1da0f8797ff3f5adafd175dd8c0a81.tar.bz2
linux-90d98a6ada1da0f8797ff3f5adafd175dd8c0a81.zip
xfs: convert the rtbitmap block and bit macros to static inline functions
Replace these macros with typechecked helper functions. Eventually we're going to add more logic to the helpers and it'll be easier if we don't have to macro it up. 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.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h
index 3686a53e0aed..5c4325702cb1 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.h
+++ b/fs/xfs/libxfs/xfs_rtbitmap.h
@@ -131,6 +131,33 @@ xfs_rtb_rounddown_rtx(
return rounddown_64(rtbno, mp->m_sb.sb_rextsize);
}
+/* Convert an rt extent number to a file block offset in the rt bitmap file. */
+static inline xfs_fileoff_t
+xfs_rtx_to_rbmblock(
+ struct xfs_mount *mp,
+ xfs_rtxnum_t rtx)
+{
+ return rtx >> mp->m_blkbit_log;
+}
+
+/* Convert an rt extent number to a word offset within an rt bitmap block. */
+static inline unsigned int
+xfs_rtx_to_rbmword(
+ struct xfs_mount *mp,
+ xfs_rtxnum_t rtx)
+{
+ return (rtx >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp);
+}
+
+/* Convert a file block offset in the rt bitmap file to an rt extent number. */
+static inline xfs_rtxnum_t
+xfs_rbmblock_to_rtx(
+ struct xfs_mount *mp,
+ xfs_fileoff_t rbmoff)
+{
+ return rbmoff << mp->m_blkbit_log;
+}
+
/*
* Functions for walking free space rtextents in the realtime bitmap.
*/