diff mbox series

[15/35] xfs: create rt extent rounding helpers for realtime extent blocks

Message ID 20240215120907.1542854-16-cem@kernel.org (mailing list archive)
State Accepted, archived
Headers show
Series xfsprogs: libxfs-sync for 6.7 | expand

Commit Message

Carlos Maiolino Feb. 15, 2024, 12:08 p.m. UTC
From: "Darrick J. Wong" <djwong@kernel.org>

Source kernel commit: 5f57f7309d9ab9d24d50c5707472b1ed8af4eabc

Create a pair of functions to round rtblock numbers up or down to the
nearest rt extent.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
 libxfs/xfs_rtbitmap.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h
index ff901bf3d..ecf5645dd 100644
--- a/libxfs/xfs_rtbitmap.h
+++ b/libxfs/xfs_rtbitmap.h
@@ -84,6 +84,24 @@  xfs_rtb_to_rtxup(
 	return rtbno;
 }
 
+/* Round this rtblock up to the nearest rt extent size. */
+static inline xfs_rtblock_t
+xfs_rtb_roundup_rtx(
+	struct xfs_mount	*mp,
+	xfs_rtblock_t		rtbno)
+{
+	return roundup_64(rtbno, mp->m_sb.sb_rextsize);
+}
+
+/* Round this rtblock down to the nearest rt extent size. */
+static inline xfs_rtblock_t
+xfs_rtb_rounddown_rtx(
+	struct xfs_mount	*mp,
+	xfs_rtblock_t		rtbno)
+{
+	return rounddown_64(rtbno, mp->m_sb.sb_rextsize);
+}
+
 /*
  * Functions for walking free space rtextents in the realtime bitmap.
  */