From 23e7181750e5a7da94b1a6d2a61d81af708b5b2d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 1 Oct 2024 13:42:39 +0200 Subject: [PATCH] xfs: simplify xfs_rtb_round{up,down}_rtx Just mask out the rgbno part to replace it with the rounded version instead of doing the full unpack/repack dance. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_rtbitmap.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h index 90f11de5eccf..821f388b619c 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.h +++ b/fs/xfs/libxfs/xfs_rtbitmap.h @@ -164,12 +164,10 @@ xfs_rtb_roundup_rtx( struct xfs_mount *mp, xfs_rtblock_t rtbno) { - uint64_t old_rgbno = __xfs_rtb_to_rgbno(mp, rtbno); - uint64_t new_rgbno; - xfs_rgnumber_t rgno = xfs_rtb_to_rgno(mp, rtbno); + uint8_t blkmask = mp->m_groups[XG_TYPE_RTG].blkmask; - new_rgbno = roundup_64(old_rgbno, mp->m_sb.sb_rextsize); - return __xfs_rgbno_to_rtb(mp, rgno, new_rgbno); + return (rtbno & ~mp->m_groups[XG_TYPE_RTG].blkmask) + + roundup_64(rtbno & blkmask, mp->m_sb.sb_rextsize); } /* Round this rtblock down to the nearest rt extent size. */ @@ -178,12 +176,10 @@ xfs_rtb_rounddown_rtx( struct xfs_mount *mp, xfs_rtblock_t rtbno) { - uint64_t old_rgbno = __xfs_rtb_to_rgbno(mp, rtbno); - uint64_t new_rgbno; - xfs_rgnumber_t rgno = xfs_rtb_to_rgno(mp, rtbno); + uint8_t blkmask = mp->m_groups[XG_TYPE_RTG].blkmask; - new_rgbno = rounddown_64(old_rgbno, mp->m_sb.sb_rextsize); - return __xfs_rgbno_to_rtb(mp, rgno, new_rgbno); + return (rtbno & ~mp->m_groups[XG_TYPE_RTG].blkmask) + + rounddown_64(rtbno & blkmask, mp->m_sb.sb_rextsize); } /* Round this file block offset up to the nearest rt extent size. */ -- 2.50.1