]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: add a xfs_fsb_to_gbno helper
authorChristoph Hellwig <hch@lst.de>
Tue, 1 Oct 2024 11:54:34 +0000 (13:54 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 2 Oct 2024 07:15:06 +0000 (09:15 +0200)
Just one more generic group helper to fold.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_group.h
fs/xfs/libxfs/xfs_rmap.c
fs/xfs/libxfs/xfs_rtbitmap.h
fs/xfs/libxfs/xfs_rtgroup.h

index fc32a3b269e25766ccb62a7a54865f8503b32459..9cbc7038149808194541daedc3d1e600c01c85f0 100644 (file)
@@ -106,4 +106,10 @@ static inline uint32_t xfs_fsb_to_gno(struct xfs_mount *mp, xfs_fsblock_t fsbno,
        return fsbno >> mp->m_groups[type].blklog;
 }
 
+static inline xfs_agblock_t xfs_fsb_to_gbno(struct xfs_mount *mp,
+               xfs_fsblock_t fsbno, enum xfs_group_type type)
+{
+       return fsbno & mp->m_groups[type].blkmask;
+}
+
 #endif /* __LIBXFS_GROUP_H */
index a8004bdcbda98ce3ab26882a5993bd0903cfee4e..1d373be1786353ae3ea9f3fd5af4b6617f3567ad 100644 (file)
@@ -2721,11 +2721,8 @@ xfs_rmap_finish_one(
                        ri->ri_bmap.br_startoff);
        unwritten = ri->ri_bmap.br_state == XFS_EXT_UNWRITTEN;
 
-       if (ri->ri_group->xg_type == XG_TYPE_RTG)
-               bno = xfs_rtb_to_rgbno(mp, ri->ri_bmap.br_startblock);
-       else
-               bno = XFS_FSB_TO_AGBNO(mp, ri->ri_bmap.br_startblock);
-
+       bno = xfs_fsb_to_gbno(mp, ri->ri_bmap.br_startblock,
+                       ri->ri_group->xg_type);
        error = __xfs_rmap_finish_intent(*pcur, ri->ri_type, bno,
                        ri->ri_bmap.br_blockcount, &oinfo, unwritten);
        if (error)
index 024c631a2c286aed42eef3c8bbaf0de3ab66b404..90f11de5eccfd95d763668119f96c2033ccfa1aa 100644 (file)
@@ -25,8 +25,8 @@ xfs_rtx_to_rtb(
        struct xfs_rtgroup      *rtg,
        xfs_rtxnum_t            rtx)
 {
+       xfs_rtblock_t           start = xfs_group_start_fsb(&rtg->rtg_group);
        struct xfs_mount        *mp = rtg_mount(rtg);
-       xfs_rtblock_t           start = xfs_rgno_start_rtb(mp, rtg_rgno(rtg));
 
        if (mp->m_rtxblklog >= 0)
                return start + (rtx << mp->m_rtxblklog);
index 5489ded1695687e190ce44c87c6c3a06e28ac4f6..e2793ac012dd80a14a0345e803aa1cf5aa7a6411 100644 (file)
@@ -177,7 +177,7 @@ xfs_rgbno_to_rtb(
        struct xfs_rtgroup      *rtg,
        xfs_rgblock_t           rgbno)
 {
-       return __xfs_rgbno_to_rtb(rtg_mount(rtg), rtg_rgno(rtg), rgbno);
+       return xfs_gbno_to_fsb(&rtg->rtg_group, rgbno);
 }
 
 static inline xfs_rgnumber_t
@@ -185,10 +185,7 @@ xfs_rtb_to_rgno(
        struct xfs_mount        *mp,
        xfs_rtblock_t           rtbno)
 {
-       if (!xfs_has_rtgroups(mp))
-               return 0;
-
-       return rtbno >> mp->m_sb.sb_rgblklog;
+       return xfs_fsb_to_gno(mp, rtbno, XG_TYPE_RTG);
 }
 
 static inline uint64_t
@@ -207,7 +204,7 @@ xfs_rtb_to_rgbno(
        struct xfs_mount        *mp,
        xfs_rtblock_t           rtbno)
 {
-       return __xfs_rtb_to_rgbno(mp, rtbno);
+       return xfs_fsb_to_gbno(mp, rtbno, XG_TYPE_RTG);
 }
 
 /*