From a5dc53fefdf8c2517ed472080a118dd05a826853 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 12 Feb 2024 15:23:20 +0100 Subject: [PATCH] xfs: create rt extent rounding helpers for realtime extent blocks 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 Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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. */ -- 2.39.5