]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: simplify xfs_rtb_round{up,down}_rtx
authorChristoph Hellwig <hch@lst.de>
Tue, 1 Oct 2024 11:42:39 +0000 (13:42 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 2 Oct 2024 07:15:25 +0000 (09:15 +0200)
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 <hch@lst.de>
fs/xfs/libxfs/xfs_rtbitmap.h

index 90f11de5eccfd95d763668119f96c2033ccfa1aa..821f388b619c067e680883ea1c469e335753533a 100644 (file)
@@ -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. */