]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: add xfs_agbno_to_fsb and xfs_agbno_to_daddr helpers
authorChristoph Hellwig <hch@lst.de>
Mon, 4 Nov 2024 04:18:28 +0000 (20:18 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 5 Nov 2024 21:38:24 +0000 (13:38 -0800)
Add helpers to convert an agbno to a daddr or fsbno based on a pag
structure.

This provides a simpler conversion and better type safety compared to the
existing code that passes the mount structure and the agno separately.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
21 files changed:
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_btree.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_refcount.c
fs/xfs/libxfs/xfs_refcount_btree.c
fs/xfs/scrub/bmap.c
fs/xfs/scrub/bmap_repair.c
fs/xfs/scrub/cow_repair.c
fs/xfs/scrub/ialloc.c
fs/xfs/scrub/ialloc_repair.c
fs/xfs/scrub/newbt.c
fs/xfs/scrub/reap.c
fs/xfs/scrub/refcount_repair.c
fs/xfs/scrub/repair.c
fs/xfs/scrub/rmap_repair.c
fs/xfs/xfs_filestream.c
fs/xfs/xfs_fsmap.c
fs/xfs/xfs_iwalk.c

index b9677abee70fd66e6aee41d9b1ef8a397f818ee5..9de48f3c71235dff797b20e381453c7d382b59f4 100644 (file)
@@ -869,7 +869,7 @@ xfs_ag_shrink_space(
 
        /* internal log shouldn't also show up in the free space btrees */
        error = xfs_alloc_vextent_exact_bno(&args,
-                       XFS_AGB_TO_FSB(mp, pag->pag_agno, aglen - delta));
+                       xfs_agbno_to_fsb(pag, aglen - delta));
        if (!error && args.agbno == NULLAGBLOCK)
                error = -ENOSPC;
 
index 958ca82524292ff88ec592157e52ca8d66111d39..c0a30141ddc330ed20e74350c2cc0e6e6fd91475 100644 (file)
@@ -330,4 +330,20 @@ int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp,
                        xfs_extlen_t len);
 int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
 
+static inline xfs_fsblock_t
+xfs_agbno_to_fsb(
+       struct xfs_perag        *pag,
+       xfs_agblock_t           agbno)
+{
+       return XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, agbno);
+}
+
+static inline xfs_daddr_t
+xfs_agbno_to_daddr(
+       struct xfs_perag        *pag,
+       xfs_agblock_t           agbno)
+{
+       return XFS_AGB_TO_DADDR(pag->pag_mount, pag->pag_agno, agbno);
+}
+
 #endif /* __LIBXFS_AG_H */
index 59a240b946284474fbca3bd2c933d7ad5cafd87c..847a028a6206fca22dfd949ecd6a65ac5783d9cd 100644 (file)
@@ -1259,7 +1259,7 @@ xfs_alloc_ag_vextent_small(
                struct xfs_buf  *bp;
 
                error = xfs_trans_get_buf(args->tp, args->mp->m_ddev_targp,
-                               XFS_AGB_TO_DADDR(args->mp, args->agno, fbno),
+                               xfs_agbno_to_daddr(args->pag, fbno),
                                args->mp->m_bsize, 0, &bp);
                if (error)
                        goto error;
@@ -2933,9 +2933,8 @@ xfs_alloc_fix_freelist(
                 * Deferring the free disconnects freeing up the AGFL slot from
                 * freeing the block.
                 */
-               error = xfs_free_extent_later(tp,
-                               XFS_AGB_TO_FSB(mp, args->agno, bno), 1,
-                               &targs.oinfo, XFS_AG_RESV_AGFL, 0);
+               error = xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, bno),
+                               1, &targs.oinfo, XFS_AG_RESV_AGFL, 0);
                if (error)
                        goto out_agbp_relse;
        }
@@ -3596,7 +3595,7 @@ xfs_alloc_vextent_finish(
                goto out_drop_perag;
        }
 
-       args->fsbno = XFS_AGB_TO_FSB(mp, args->agno, args->agbno);
+       args->fsbno = xfs_agbno_to_fsb(args->pag, args->agbno);
 
        ASSERT(args->len >= args->minlen);
        ASSERT(args->len <= args->maxlen);
@@ -3648,7 +3647,6 @@ xfs_alloc_vextent_this_ag(
        struct xfs_alloc_arg    *args,
        xfs_agnumber_t          agno)
 {
-       struct xfs_mount        *mp = args->mp;
        xfs_agnumber_t          minimum_agno;
        uint32_t                alloc_flags = 0;
        int                     error;
@@ -3661,8 +3659,8 @@ xfs_alloc_vextent_this_ag(
 
        trace_xfs_alloc_vextent_this_ag(args);
 
-       error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0),
-                       &minimum_agno);
+       error = xfs_alloc_vextent_check_args(args,
+                       xfs_agbno_to_fsb(args->pag, 0), &minimum_agno);
        if (error) {
                if (error == -ENOSPC)
                        return 0;
index a5c4af148853f8276d7c10cb67ad5286e9acb72f..804a1c96941127497ffad3b3101d78e8dadb3329 100644 (file)
@@ -1017,21 +1017,20 @@ xfs_btree_readahead_agblock(
        struct xfs_btree_block  *block)
 {
        struct xfs_mount        *mp = cur->bc_mp;
-       xfs_agnumber_t          agno = cur->bc_ag.pag->pag_agno;
        xfs_agblock_t           left = be32_to_cpu(block->bb_u.s.bb_leftsib);
        xfs_agblock_t           right = be32_to_cpu(block->bb_u.s.bb_rightsib);
        int                     rval = 0;
 
        if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) {
                xfs_buf_readahead(mp->m_ddev_targp,
-                               XFS_AGB_TO_DADDR(mp, agno, left),
+                               xfs_agbno_to_daddr(cur->bc_ag.pag, left),
                                mp->m_bsize, cur->bc_ops->buf_ops);
                rval++;
        }
 
        if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) {
                xfs_buf_readahead(mp->m_ddev_targp,
-                               XFS_AGB_TO_DADDR(mp, agno, right),
+                               xfs_agbno_to_daddr(cur->bc_ag.pag, right),
                                mp->m_bsize, cur->bc_ops->buf_ops);
                rval++;
        }
@@ -1091,7 +1090,7 @@ xfs_btree_ptr_to_daddr(
 
        switch (cur->bc_ops->type) {
        case XFS_BTREE_TYPE_AG:
-               *daddr = XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_ag.pag->pag_agno,
+               *daddr = xfs_agbno_to_daddr(cur->bc_ag.pag,
                                be32_to_cpu(ptr->s));
                break;
        case XFS_BTREE_TYPE_INODE:
index a58a66a77155c67b49552171b88999246c77ac4d..6deb8346d1c34b09bf9c4c25be4b5e18567cccf2 100644 (file)
@@ -768,8 +768,7 @@ xfs_ialloc_ag_alloc(
                /* Allow space for the inode btree to split. */
                args.minleft = igeo->inobt_maxlevels;
                error = xfs_alloc_vextent_exact_bno(&args,
-                               XFS_AGB_TO_FSB(args.mp, pag->pag_agno,
-                                               args.agbno));
+                               xfs_agbno_to_fsb(pag, args.agbno));
                if (error)
                        return error;
 
@@ -811,8 +810,8 @@ xfs_ialloc_ag_alloc(
                 */
                args.minleft = igeo->inobt_maxlevels;
                error = xfs_alloc_vextent_near_bno(&args,
-                               XFS_AGB_TO_FSB(args.mp, pag->pag_agno,
-                                               be32_to_cpu(agi->agi_root)));
+                               xfs_agbno_to_fsb(pag,
+                                       be32_to_cpu(agi->agi_root)));
                if (error)
                        return error;
        }
@@ -824,8 +823,8 @@ xfs_ialloc_ag_alloc(
        if (isaligned && args.fsbno == NULLFSBLOCK) {
                args.alignment = igeo->cluster_align;
                error = xfs_alloc_vextent_near_bno(&args,
-                               XFS_AGB_TO_FSB(args.mp, pag->pag_agno,
-                                               be32_to_cpu(agi->agi_root)));
+                               xfs_agbno_to_fsb(pag,
+                                       be32_to_cpu(agi->agi_root)));
                if (error)
                        return error;
        }
@@ -860,8 +859,8 @@ sparse_alloc:
                                 igeo->ialloc_blks;
 
                error = xfs_alloc_vextent_near_bno(&args,
-                               XFS_AGB_TO_FSB(args.mp, pag->pag_agno,
-                                               be32_to_cpu(agi->agi_root)));
+                               xfs_agbno_to_fsb(pag,
+                                       be32_to_cpu(agi->agi_root)));
                if (error)
                        return error;
 
@@ -1978,7 +1977,6 @@ xfs_difree_inode_chunk(
        struct xfs_inobt_rec_incore     *rec)
 {
        struct xfs_mount                *mp = tp->t_mountp;
-       xfs_agnumber_t                  agno = pag->pag_agno;
        xfs_agblock_t                   sagbno = XFS_AGINO_TO_AGBNO(mp,
                                                        rec->ir_startino);
        int                             startidx, endidx;
@@ -1989,8 +1987,7 @@ xfs_difree_inode_chunk(
 
        if (!xfs_inobt_issparse(rec->ir_holemask)) {
                /* not sparse, calculate extent info directly */
-               return xfs_free_extent_later(tp,
-                               XFS_AGB_TO_FSB(mp, agno, sagbno),
+               return xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, sagbno),
                                M_IGEO(mp)->ialloc_blks, &XFS_RMAP_OINFO_INODES,
                                XFS_AG_RESV_NONE, 0);
        }
@@ -2036,9 +2033,9 @@ xfs_difree_inode_chunk(
 
                ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
                ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
-               error = xfs_free_extent_later(tp,
-                               XFS_AGB_TO_FSB(mp, agno, agbno), contigblk,
-                               &XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE, 0);
+               error = xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, agbno),
+                               contigblk, &XFS_RMAP_OINFO_INODES,
+                               XFS_AG_RESV_NONE, 0);
                if (error)
                        return error;
 
@@ -2508,7 +2505,7 @@ xfs_imap(
                offset = XFS_INO_TO_OFFSET(mp, ino);
                ASSERT(offset < mp->m_sb.sb_inopblock);
 
-               imap->im_blkno = XFS_AGB_TO_DADDR(mp, pag->pag_agno, agbno);
+               imap->im_blkno = xfs_agbno_to_daddr(pag, agbno);
                imap->im_len = XFS_FSB_TO_BB(mp, 1);
                imap->im_boffset = (unsigned short)(offset <<
                                                        mp->m_sb.sb_inodelog);
@@ -2538,7 +2535,7 @@ out_map:
        offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
                XFS_INO_TO_OFFSET(mp, ino);
 
-       imap->im_blkno = XFS_AGB_TO_DADDR(mp, pag->pag_agno, cluster_agbno);
+       imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno);
        imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
        imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
 
index 401b42d52af6861237270d3397770a6550ad29d5..3291541ae9665af0a94c535e19e49685e929c6fc 100644 (file)
@@ -120,7 +120,7 @@ __xfs_inobt_alloc_block(
        args.resv = resv;
 
        error = xfs_alloc_vextent_near_bno(&args,
-                       XFS_AGB_TO_FSB(args.mp, args.pag->pag_agno, sbno));
+                       xfs_agbno_to_fsb(args.pag, sbno));
        if (error)
                return error;
 
index 198b84117df138a6b4a75274ac241198aa5cfac7..5e166553a7a6e99d59aadefce0864b3d5f7057b7 100644 (file)
@@ -1154,8 +1154,7 @@ xfs_refcount_adjust_extents(
                                        goto out_error;
                                }
                        } else {
-                               fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
-                                               cur->bc_ag.pag->pag_agno,
+                               fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag,
                                                tmp.rc_startblock);
                                error = xfs_free_extent_later(cur->bc_tp, fsbno,
                                                  tmp.rc_blockcount, NULL,
@@ -1217,8 +1216,7 @@ xfs_refcount_adjust_extents(
                        }
                        goto advloop;
                } else {
-                       fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
-                                       cur->bc_ag.pag->pag_agno,
+                       fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag,
                                        ext.rc_startblock);
                        error = xfs_free_extent_later(cur->bc_tp, fsbno,
                                        ext.rc_blockcount, NULL,
@@ -1320,7 +1318,7 @@ xfs_refcount_continue_op(
                return -EFSCORRUPTED;
        }
 
-       ri->ri_startblock = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);
+       ri->ri_startblock = xfs_agbno_to_fsb(pag, new_agbno);
 
        ASSERT(xfs_verify_fsbext(mp, ri->ri_startblock, ri->ri_blockcount));
        ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, ri->ri_startblock));
@@ -1956,8 +1954,7 @@ xfs_refcount_recover_cow_leftovers(
                        goto out_free;
 
                /* Free the orphan record */
-               fsb = XFS_AGB_TO_FSB(mp, pag->pag_agno,
-                               rr->rr_rrec.rc_startblock);
+               fsb = xfs_agbno_to_fsb(pag, rr->rr_rrec.rc_startblock);
                xfs_refcount_free_cow_extent(tp, fsb,
                                rr->rr_rrec.rc_blockcount);
 
index 795928d1a66d8885a733227e37e05f7361b0cdf1..c4b10fbf8892a16e4ae082a037e56085acda1d5e 100644 (file)
@@ -74,8 +74,7 @@ xfs_refcountbt_alloc_block(
        args.resv = XFS_AG_RESV_METADATA;
 
        error = xfs_alloc_vextent_near_bno(&args,
-                       XFS_AGB_TO_FSB(args.mp, args.pag->pag_agno,
-                                       xfs_refc_block(args.mp)));
+                       xfs_agbno_to_fsb(args.pag, xfs_refc_block(args.mp)));
        if (error)
                goto out_error;
        if (args.fsbno == NULLFSBLOCK) {
index 5ab2ac53c920020816b39d93562fa819454a72b2..a43912227dd478ae9afc54f8164c6465585d276f 100644 (file)
@@ -600,9 +600,8 @@ xchk_bmap_check_rmap(
                if (irec.br_startoff != check_rec.rm_offset)
                        xchk_fblock_set_corrupt(sc, sbcri->whichfork,
                                        check_rec.rm_offset);
-               if (irec.br_startblock != XFS_AGB_TO_FSB(sc->mp,
-                               cur->bc_ag.pag->pag_agno,
-                               check_rec.rm_startblock))
+               if (irec.br_startblock !=
+                   xfs_agbno_to_fsb(cur->bc_ag.pag, check_rec.rm_startblock))
                        xchk_fblock_set_corrupt(sc, sbcri->whichfork,
                                        check_rec.rm_offset);
                if (irec.br_blockcount > check_rec.rm_blockcount)
index 4505f4829d53f1f4e4024f533f45a71d90265ca8..dc8fdd2da174ed303dc23f17c79e4e6e73805585 100644 (file)
@@ -237,7 +237,6 @@ xrep_bmap_walk_rmap(
        void                            *priv)
 {
        struct xrep_bmap                *rb = priv;
-       struct xfs_mount                *mp = cur->bc_mp;
        xfs_fsblock_t                   fsbno;
        int                             error = 0;
 
@@ -269,8 +268,7 @@ xrep_bmap_walk_rmap(
        if ((rec->rm_flags & XFS_RMAP_UNWRITTEN) && !rb->allow_unwritten)
                return -EFSCORRUPTED;
 
-       fsbno = XFS_AGB_TO_FSB(mp, cur->bc_ag.pag->pag_agno,
-                       rec->rm_startblock);
+       fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rec->rm_startblock);
 
        if (rec->rm_flags & XFS_RMAP_BMBT_BLOCK) {
                rb->old_bmbt_block_count += rec->rm_blockcount;
index 4de3f0f40f486c887c2b8787dd8d17fe40f328ed..19bded43c4fe1e5dc65c0351e6cd92192a20efee 100644 (file)
@@ -137,7 +137,6 @@ xrep_cow_mark_shared_staging(
 {
        struct xrep_cow                 *xc = priv;
        struct xfs_refcount_irec        rrec;
-       xfs_fsblock_t                   fsbno;
 
        if (!xfs_refcount_check_domain(rec) ||
            rec->rc_domain != XFS_REFC_DOMAIN_SHARED)
@@ -145,9 +144,9 @@ xrep_cow_mark_shared_staging(
 
        xrep_cow_trim_refcount(xc, &rrec, rec);
 
-       fsbno = XFS_AGB_TO_FSB(xc->sc->mp, cur->bc_ag.pag->pag_agno,
-                       rrec.rc_startblock);
-       return xrep_cow_mark_file_range(xc, fsbno, rrec.rc_blockcount);
+       return xrep_cow_mark_file_range(xc,
+                       xfs_agbno_to_fsb(cur->bc_ag.pag, rrec.rc_startblock),
+                       rrec.rc_blockcount);
 }
 
 /*
@@ -178,8 +177,7 @@ xrep_cow_mark_missing_staging(
                goto next;
 
        error = xrep_cow_mark_file_range(xc,
-                       XFS_AGB_TO_FSB(xc->sc->mp, cur->bc_ag.pag->pag_agno,
-                                      xc->next_bno),
+                       xfs_agbno_to_fsb(cur->bc_ag.pag, xc->next_bno),
                        rrec.rc_startblock - xc->next_bno);
        if (error)
                return error;
@@ -200,7 +198,6 @@ xrep_cow_mark_missing_staging_rmap(
        void                            *priv)
 {
        struct xrep_cow                 *xc = priv;
-       xfs_fsblock_t                   fsbno;
        xfs_agblock_t                   rec_bno;
        xfs_extlen_t                    rec_len;
        unsigned int                    adj;
@@ -222,8 +219,8 @@ xrep_cow_mark_missing_staging_rmap(
                rec_len -= adj;
        }
 
-       fsbno = XFS_AGB_TO_FSB(xc->sc->mp, cur->bc_ag.pag->pag_agno, rec_bno);
-       return xrep_cow_mark_file_range(xc, fsbno, rec_len);
+       return xrep_cow_mark_file_range(xc,
+                       xfs_agbno_to_fsb(cur->bc_ag.pag, rec_bno), rec_len);
 }
 
 /*
@@ -275,8 +272,7 @@ xrep_cow_find_bad(
 
        if (xc->next_bno < xc->irec_startbno + xc->irec.br_blockcount) {
                error = xrep_cow_mark_file_range(xc,
-                               XFS_AGB_TO_FSB(sc->mp, pag->pag_agno,
-                                              xc->next_bno),
+                               xfs_agbno_to_fsb(pag, xc->next_bno),
                                xc->irec_startbno + xc->irec.br_blockcount -
                                xc->next_bno);
                if (error)
index 750d7b0cd25a78c3d6ac0f8630c56cc4e6012a8b..26938b90d22efc7b32b126699ecfa98b995620aa 100644 (file)
@@ -396,7 +396,7 @@ xchk_iallocbt_check_cluster(
         * ir_startino can be large enough to make im_boffset nonzero.
         */
        ir_holemask = (irec->ir_holemask & cluster_mask);
-       imap.im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno);
+       imap.im_blkno = xfs_agbno_to_daddr(bs->cur->bc_ag.pag, agbno);
        imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
        imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) <<
                        mp->m_sb.sb_inodelog;
index c8d2196a04e15bd8a8348c2a51acb5e94b28189c..ff1a5952a9e7d0d67f0f9a0b370d43459081546c 100644 (file)
@@ -307,7 +307,7 @@ xrep_ibt_process_cluster(
         * inobt because imap_to_bp directly maps the buffer without touching
         * either inode btree.
         */
-       imap.im_blkno = XFS_AGB_TO_DADDR(mp, sc->sa.pag->pag_agno, cluster_bno);
+       imap.im_blkno = xfs_agbno_to_daddr(sc->sa.pag, cluster_bno);
        imap.im_len = XFS_FSB_TO_BB(mp, igeo->blocks_per_cluster);
        imap.im_boffset = 0;
        error = xfs_imap_to_bp(mp, sc->tp, &imap, &cluster_bp);
@@ -634,7 +634,6 @@ xrep_ibt_build_new_trees(
        struct xfs_scrub        *sc = ri->sc;
        struct xfs_btree_cur    *ino_cur;
        struct xfs_btree_cur    *fino_cur = NULL;
-       xfs_fsblock_t           fsbno;
        bool                    need_finobt;
        int                     error;
 
@@ -656,9 +655,8 @@ xrep_ibt_build_new_trees(
         *
         * Start by setting up the inobt staging cursor.
         */
-       fsbno = XFS_AGB_TO_FSB(sc->mp, sc->sa.pag->pag_agno,
-                       XFS_IBT_BLOCK(sc->mp));
-       xrep_newbt_init_ag(&ri->new_inobt, sc, &XFS_RMAP_OINFO_INOBT, fsbno,
+       xrep_newbt_init_ag(&ri->new_inobt, sc, &XFS_RMAP_OINFO_INOBT,
+                       xfs_agbno_to_fsb(sc->sa.pag, XFS_IBT_BLOCK(sc->mp)),
                        XFS_AG_RESV_NONE);
        ri->new_inobt.bload.claim_block = xrep_ibt_claim_block;
        ri->new_inobt.bload.get_records = xrep_ibt_get_records;
@@ -677,10 +675,9 @@ xrep_ibt_build_new_trees(
                if (sc->mp->m_finobt_nores)
                        resv = XFS_AG_RESV_NONE;
 
-               fsbno = XFS_AGB_TO_FSB(sc->mp, sc->sa.pag->pag_agno,
-                               XFS_FIBT_BLOCK(sc->mp));
                xrep_newbt_init_ag(&ri->new_finobt, sc, &XFS_RMAP_OINFO_INOBT,
-                               fsbno, resv);
+                               xfs_agbno_to_fsb(sc->sa.pag, XFS_FIBT_BLOCK(sc->mp)),
+                               resv);
                ri->new_finobt.bload.claim_block = xrep_fibt_claim_block;
                ri->new_finobt.bload.get_records = xrep_fibt_get_records;
 
index 2aa14b7ab6306021c9a06bb2d507558b58711b93..baa00e1cf81ab2b917810cc2f2d913142b6e8269 100644 (file)
@@ -186,11 +186,10 @@ xrep_newbt_add_extent(
        xfs_agblock_t           agbno,
        xfs_extlen_t            len)
 {
-       struct xfs_mount        *mp = xnr->sc->mp;
        struct xfs_alloc_arg    args = {
                .tp             = NULL, /* no autoreap */
                .oinfo          = xnr->oinfo,
-               .fsbno          = XFS_AGB_TO_FSB(mp, pag->pag_agno, agbno),
+               .fsbno          = xfs_agbno_to_fsb(pag, agbno),
                .len            = len,
                .resv           = xnr->resv,
        };
@@ -210,8 +209,8 @@ xrep_newbt_validate_ag_alloc_hint(
            xfs_verify_fsbno(sc->mp, xnr->alloc_hint))
                return;
 
-       xnr->alloc_hint = XFS_AGB_TO_FSB(sc->mp, sc->sa.pag->pag_agno,
-                                        XFS_AGFL_BLOCK(sc->mp) + 1);
+       xnr->alloc_hint =
+               xfs_agbno_to_fsb(sc->sa.pag, XFS_AGFL_BLOCK(sc->mp) + 1);
 }
 
 /* Allocate disk space for a new per-AG btree. */
@@ -376,7 +375,6 @@ xrep_newbt_free_extent(
        struct xfs_scrub        *sc = xnr->sc;
        xfs_agblock_t           free_agbno = resv->agbno;
        xfs_extlen_t            free_aglen = resv->len;
-       xfs_fsblock_t           fsbno;
        int                     error;
 
        if (!btree_committed || resv->used == 0) {
@@ -413,9 +411,9 @@ xrep_newbt_free_extent(
         * Use EFIs to free the reservations.  This reduces the chance
         * that we leak blocks if the system goes down.
         */
-       fsbno = XFS_AGB_TO_FSB(sc->mp, resv->pag->pag_agno, free_agbno);
-       error = xfs_free_extent_later(sc->tp, fsbno, free_aglen, &xnr->oinfo,
-                       xnr->resv, XFS_FREE_EXTENT_SKIP_DISCARD);
+       error = xfs_free_extent_later(sc->tp,
+                       xfs_agbno_to_fsb(resv->pag, free_agbno), free_aglen,
+                       &xnr->oinfo, xnr->resv, XFS_FREE_EXTENT_SKIP_DISCARD);
        if (error)
                return error;
 
@@ -545,8 +543,7 @@ xrep_newbt_claim_block(
                        xnr->oinfo.oi_owner);
 
        if (cur->bc_ops->ptr_len == XFS_BTREE_LONG_PTR_LEN)
-               ptr->l = cpu_to_be64(XFS_AGB_TO_FSB(mp, resv->pag->pag_agno,
-                                                               agbno));
+               ptr->l = cpu_to_be64(xfs_agbno_to_fsb(resv->pag, agbno));
        else
                ptr->s = cpu_to_be32(agbno);
 
index 53697f3c5e1b0b4ce78f8ab55806ff635d6e0b52..d65ad6aa856f4d805451d0a88e618c7c651b2e3a 100644 (file)
@@ -263,7 +263,6 @@ xreap_agextent_binval(
        struct xfs_scrub        *sc = rs->sc;
        struct xfs_perag        *pag = sc->sa.pag;
        struct xfs_mount        *mp = sc->mp;
-       xfs_agnumber_t          agno = sc->sa.pag->pag_agno;
        xfs_agblock_t           agbno_next = agbno + *aglenp;
        xfs_agblock_t           bno = agbno;
 
@@ -284,7 +283,7 @@ xreap_agextent_binval(
         */
        while (bno < agbno_next) {
                struct xrep_bufscan     scan = {
-                       .daddr          = XFS_AGB_TO_DADDR(mp, agno, bno),
+                       .daddr          = xfs_agbno_to_daddr(pag, bno),
                        .max_sectors    = xrep_bufscan_max_sectors(mp,
                                                        agbno_next - bno),
                        .daddr_step     = XFS_FSB_TO_BB(mp, 1),
@@ -391,7 +390,7 @@ xreap_agextent_iter(
        xfs_fsblock_t           fsbno;
        int                     error = 0;
 
-       fsbno = XFS_AGB_TO_FSB(sc->mp, sc->sa.pag->pag_agno, agbno);
+       fsbno = xfs_agbno_to_fsb(sc->sa.pag, agbno);
 
        /*
         * If there are other rmappings, this block is cross linked and must
@@ -780,7 +779,6 @@ xreap_bmapi_binval(
        xfs_fileoff_t           off;
        xfs_fileoff_t           max_off;
        xfs_extlen_t            scan_blocks;
-       xfs_agnumber_t          agno = sc->sa.pag->pag_agno;
        xfs_agblock_t           bno;
        xfs_agblock_t           agbno;
        xfs_agblock_t           agbno_next;
@@ -837,7 +835,7 @@ xreap_bmapi_binval(
         */
        while (bno < agbno_next) {
                struct xrep_bufscan     scan = {
-                       .daddr          = XFS_AGB_TO_DADDR(mp, agno, bno),
+                       .daddr          = xfs_agbno_to_daddr(pag, bno),
                        .max_sectors    = xrep_bufscan_max_sectors(mp,
                                                                scan_blocks),
                        .daddr_step     = XFS_FSB_TO_BB(mp, 1),
index a00d7ce7ae5b876f28f72f7639f65977f58c9cd8..4240fff459cb1d4f837b5ae5842f8b5b86b3d64e 100644 (file)
@@ -590,7 +590,6 @@ xrep_refc_build_new_tree(
        struct xfs_scrub        *sc = rr->sc;
        struct xfs_btree_cur    *refc_cur;
        struct xfs_perag        *pag = sc->sa.pag;
-       xfs_fsblock_t           fsbno;
        int                     error;
 
        error = xrep_refc_sort_records(rr);
@@ -603,8 +602,8 @@ xrep_refc_build_new_tree(
         * to root the new btree while it's under construction and before we
         * attach it to the AG header.
         */
-       fsbno = XFS_AGB_TO_FSB(sc->mp, pag->pag_agno, xfs_refc_block(sc->mp));
-       xrep_newbt_init_ag(&rr->new_btree, sc, &XFS_RMAP_OINFO_REFC, fsbno,
+       xrep_newbt_init_ag(&rr->new_btree, sc, &XFS_RMAP_OINFO_REFC,
+                       xfs_agbno_to_fsb(pag, xfs_refc_block(sc->mp)),
                        XFS_AG_RESV_METADATA);
        rr->new_btree.bload.get_records = xrep_refc_get_records;
        rr->new_btree.bload.claim_block = xrep_refc_claim_block;
index 155bbaaa496e44236a108128c4e7e69ed998dfd3..382092a6ea641057baa38833c499faa69cc2cf07 100644 (file)
@@ -483,7 +483,7 @@ xrep_findroot_block(
        int                             block_level;
        int                             error = 0;
 
-       daddr = XFS_AGB_TO_DADDR(mp, ri->sc->sa.pag->pag_agno, agbno);
+       daddr = xfs_agbno_to_daddr(ri->sc->sa.pag, agbno);
 
        /*
         * Blocks in the AGFL have stale contents that might just happen to
index e8080eba37d29bf5a854e51547d6a2501d21bef6..f99849ae8f67e286742caaec638384c60ced1fd2 100644 (file)
@@ -1272,7 +1272,6 @@ xrep_rmap_build_new_tree(
        struct xfs_perag        *pag = sc->sa.pag;
        struct xfs_agf          *agf = sc->sa.agf_bp->b_addr;
        struct xfs_btree_cur    *rmap_cur;
-       xfs_fsblock_t           fsbno;
        int                     error;
 
        /*
@@ -1290,9 +1289,9 @@ xrep_rmap_build_new_tree(
         * rmapbt per-AG reservation, which we will adjust further after
         * committing the new btree.
         */
-       fsbno = XFS_AGB_TO_FSB(sc->mp, pag->pag_agno, XFS_RMAP_BLOCK(sc->mp));
        xrep_newbt_init_ag(&rr->new_btree, sc, &XFS_RMAP_OINFO_SKIP_UPDATE,
-                       fsbno, XFS_AG_RESV_RMAPBT);
+                       xfs_agbno_to_fsb(pag, XFS_RMAP_BLOCK(sc->mp)),
+                       XFS_AG_RESV_RMAPBT);
        rr->new_btree.bload.get_records = xrep_rmap_get_records;
        rr->new_btree.bload.claim_block = xrep_rmap_claim_block;
        rr->new_btree.alloc_vextent = xrep_rmap_alloc_vextent;
index 290ba8887d29e9b73fc535a872ed374b3ee69af8..f2caebb78dd25d0179d18c5cfaf391ddc1d65e9e 100644 (file)
@@ -227,7 +227,7 @@ xfs_filestream_lookup_association(
 
        trace_xfs_filestream_lookup(pag, ap->ip->i_ino);
 
-       ap->blkno = XFS_AGB_TO_FSB(args->mp, pag->pag_agno, 0);
+       ap->blkno = xfs_agbno_to_fsb(pag, 0);
        xfs_bmap_adjacent(ap);
 
        /*
@@ -344,7 +344,6 @@ xfs_filestream_select_ag(
        struct xfs_alloc_arg    *args,
        xfs_extlen_t            *longest)
 {
-       struct xfs_mount        *mp = args->mp;
        struct xfs_inode        *pip;
        xfs_ino_t               ino = 0;
        int                     error = 0;
@@ -370,7 +369,7 @@ xfs_filestream_select_ag(
                return error;
 
 out_select:
-       ap->blkno = XFS_AGB_TO_FSB(mp, args->pag->pag_agno, 0);
+       ap->blkno = xfs_agbno_to_fsb(args->pag, 0);
        return 0;
 }
 
index 67140ef8c3232cd146f104470bb7554081b75944..eff198ae1ce33a69b959ca79ec2d7bae3ea6b3ae 100644 (file)
@@ -391,15 +391,11 @@ xfs_getfsmap_datadev_helper(
        const struct xfs_rmap_irec      *rec,
        void                            *priv)
 {
-       struct xfs_mount                *mp = cur->bc_mp;
        struct xfs_getfsmap_info        *info = priv;
-       xfs_fsblock_t                   fsb;
-       xfs_daddr_t                     rec_daddr;
 
-       fsb = XFS_AGB_TO_FSB(mp, cur->bc_ag.pag->pag_agno, rec->rm_startblock);
-       rec_daddr = XFS_FSB_TO_DADDR(mp, fsb);
-
-       return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr, 0);
+       return xfs_getfsmap_helper(cur->bc_tp, info, rec,
+                       xfs_agbno_to_daddr(cur->bc_ag.pag, rec->rm_startblock),
+                       0);
 }
 
 /* Transform a bnobt irec into a fsmap */
@@ -409,13 +405,8 @@ xfs_getfsmap_datadev_bnobt_helper(
        const struct xfs_alloc_rec_incore *rec,
        void                            *priv)
 {
-       struct xfs_mount                *mp = cur->bc_mp;
        struct xfs_getfsmap_info        *info = priv;
        struct xfs_rmap_irec            irec;
-       xfs_daddr_t                     rec_daddr;
-
-       rec_daddr = XFS_AGB_TO_DADDR(mp, cur->bc_ag.pag->pag_agno,
-                       rec->ar_startblock);
 
        irec.rm_startblock = rec->ar_startblock;
        irec.rm_blockcount = rec->ar_blockcount;
@@ -423,7 +414,9 @@ xfs_getfsmap_datadev_bnobt_helper(
        irec.rm_offset = 0;
        irec.rm_flags = 0;
 
-       return xfs_getfsmap_helper(cur->bc_tp, info, &irec, rec_daddr, 0);
+       return xfs_getfsmap_helper(cur->bc_tp, info, &irec,
+                       xfs_agbno_to_daddr(cur->bc_ag.pag, rec->ar_startblock),
+                       0);
 }
 
 /* Set rmap flags based on the getfsmap flags */
index 86f14ec7c31fede6fc22d9b9d7a5eec26b34a79f..894318886a56704023207008406f6599b6fda404 100644 (file)
@@ -100,7 +100,6 @@ xfs_iwalk_ichunk_ra(
        struct xfs_inobt_rec_incore     *irec)
 {
        struct xfs_ino_geometry         *igeo = M_IGEO(mp);
-       xfs_agnumber_t                  agno = pag->pag_agno;
        xfs_agblock_t                   agbno;
        struct blk_plug                 plug;
        int                             i;      /* inode chunk index */
@@ -114,7 +113,7 @@ xfs_iwalk_ichunk_ra(
                imask = xfs_inobt_maskn(i, igeo->inodes_per_cluster);
                if (imask & ~irec->ir_free) {
                        xfs_buf_readahead(mp->m_ddev_targp,
-                                       XFS_AGB_TO_DADDR(mp, agno, agbno),
+                                       xfs_agbno_to_daddr(pag, agbno),
                                        igeo->blocks_per_cluster * mp->m_bsize,
                                        &xfs_inode_buf_ops);
                }