From d71f1d398b5f33d096adb84dbe651484b74b3635 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 19 Sep 2024 08:32:26 +0200 Subject: [PATCH] xfs: pass the rtg to xfs_rgbno_to_rtb Convert from a rgbno to a rtbno based on the rtgroup struture instead of passing a [mp,rgno] tuple. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 8 +++----- fs/xfs/libxfs/xfs_rtgroup.h | 5 ++--- fs/xfs/scrub/bmap.c | 3 +-- fs/xfs/scrub/bmap_repair.c | 6 ++---- fs/xfs/scrub/cow_repair.c | 12 ++++-------- fs/xfs/scrub/reap.c | 2 +- fs/xfs/scrub/rgsuper.c | 7 +------ fs/xfs/scrub/rtrefcount.c | 8 +++----- fs/xfs/scrub/rtrmap.c | 9 +++------ fs/xfs/xfs_fsmap.c | 11 ++++------- 10 files changed, 24 insertions(+), 47 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 60d149983602..2aca105fe54f 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1146,8 +1146,7 @@ xrefc_free_extent( if (xfs_btree_is_rtrefcount(cur->bc_ops)) { flags |= XFS_FREE_EXTENT_REALTIME; - fsbno = xfs_rgbno_to_rtb(cur->bc_mp, cur->bc_ino.rtg->rtg_rgno, - rec->rc_startblock); + fsbno = xfs_rgbno_to_rtb(cur->bc_ino.rtg, rec->rc_startblock); } else { fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rec->rc_startblock); } @@ -1497,7 +1496,7 @@ xfs_rtrefcount_continue_op( return -EFSCORRUPTED; } - ri->ri_startblock = xfs_rgbno_to_rtb(mp, rtg->rtg_rgno, new_agbno); + ri->ri_startblock = xfs_rgbno_to_rtb(rtg, new_agbno); ASSERT(xfs_verify_rtbext(mp, ri->ri_startblock, ri->ri_blockcount)); ASSERT(rtg->rtg_rgno == xfs_rtb_to_rgno(mp, ri->ri_startblock)); @@ -2146,8 +2145,7 @@ xfs_refcount_recover_group_cow_leftovers( /* Free the orphan record */ if (rtg) - fsb = xfs_rgbno_to_rtb(mp, rtg->rtg_rgno, - rr->rr_rrec.rc_startblock); + fsb = xfs_rgbno_to_rtb(rtg, rr->rr_rrec.rc_startblock); else fsb = xfs_agbno_to_fsb(pag, rr->rr_rrec.rc_startblock); xfs_refcount_free_cow_extent(tp, rtg != NULL, fsb, diff --git a/fs/xfs/libxfs/xfs_rtgroup.h b/fs/xfs/libxfs/xfs_rtgroup.h index 2c3a935dd758..7f28d0e1aa63 100644 --- a/fs/xfs/libxfs/xfs_rtgroup.h +++ b/fs/xfs/libxfs/xfs_rtgroup.h @@ -184,11 +184,10 @@ xfs_rgno_start_rtb( static inline xfs_rtblock_t xfs_rgbno_to_rtb( - struct xfs_mount *mp, - xfs_rgnumber_t rgno, + struct xfs_rtgroup *rtg, xfs_rgblock_t rgbno) { - return xfs_rgno_start_rtb(mp, rgno) + rgbno; + return xfs_rgno_start_rtb(rtg->rtg_mount, rtg->rtg_rgno) + rgbno; } static inline xfs_rgnumber_t diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index abee62b43246..3b0859883950 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -666,8 +666,7 @@ xchk_bmap_check_rmap( startblock = xfs_agbno_to_fsb(cur->bc_ag.pag, check_rec.rm_startblock); else - startblock = xfs_rgbno_to_rtb(sc->mp, - cur->bc_ino.rtg->rtg_rgno, + startblock = xfs_rgbno_to_rtb(cur->bc_ino.rtg, check_rec.rm_startblock); if (irec.br_startblock != startblock) xchk_fblock_set_corrupt(sc, sbcri->whichfork, diff --git a/fs/xfs/scrub/bmap_repair.c b/fs/xfs/scrub/bmap_repair.c index 77d2c8ca8375..ab8444887af5 100644 --- a/fs/xfs/scrub/bmap_repair.c +++ b/fs/xfs/scrub/bmap_repair.c @@ -410,7 +410,6 @@ xrep_bmap_walk_rtrmap( void *priv) { struct xrep_bmap *rb = priv; - xfs_rtblock_t rtbno; int error = 0; if (xchk_should_terminate(rb->sc, &error)) @@ -438,9 +437,8 @@ xrep_bmap_walk_rtrmap( !(rec->rm_flags & XFS_RMAP_ATTR_FORK)) return 0; - rtbno = xfs_rgbno_to_rtb(cur->bc_mp, cur->bc_ino.rtg->rtg_rgno, - rec->rm_startblock); - return xrep_bmap_from_rmap(rb, rec->rm_offset, rtbno, + return xrep_bmap_from_rmap(rb, rec->rm_offset, + xfs_rgbno_to_rtb(cur->bc_ino.rtg, rec->rm_startblock), rec->rm_blockcount, rec->rm_flags & XFS_RMAP_UNWRITTEN); } diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c index 4cdbf4cc3194..6509e07dfc8c 100644 --- a/fs/xfs/scrub/cow_repair.c +++ b/fs/xfs/scrub/cow_repair.c @@ -153,8 +153,7 @@ xrep_cow_mark_shared_staging( xrep_cow_trim_refcount(xc, &rrec, rec); if (XFS_IS_REALTIME_INODE(xc->sc->ip)) - fsbno = xfs_rgbno_to_rtb(xc->sc->mp, cur->bc_ino.rtg->rtg_rgno, - rrec.rc_startblock); + fsbno = xfs_rgbno_to_rtb(cur->bc_ino.rtg, rrec.rc_startblock); else fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rrec.rc_startblock); return xrep_cow_mark_file_range(xc, fsbno, rrec.rc_blockcount); @@ -189,8 +188,7 @@ xrep_cow_mark_missing_staging( goto next; if (XFS_IS_REALTIME_INODE(xc->sc->ip)) - fsbno = xfs_rgbno_to_rtb(xc->sc->mp, cur->bc_ino.rtg->rtg_rgno, - xc->next_bno); + fsbno = xfs_rgbno_to_rtb(cur->bc_ino.rtg, xc->next_bno); else fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, xc->next_bno); error = xrep_cow_mark_file_range(xc, fsbno, @@ -237,8 +235,7 @@ xrep_cow_mark_missing_staging_rmap( } if (XFS_IS_REALTIME_INODE(xc->sc->ip)) - fsbno = xfs_rgbno_to_rtb(xc->sc->mp, cur->bc_ino.rtg->rtg_rgno, - rec_bno); + fsbno = xfs_rgbno_to_rtb(cur->bc_ino.rtg, rec_bno); else fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rec_bno); return xrep_cow_mark_file_range(xc, fsbno, rec_len); @@ -377,8 +374,7 @@ xrep_cow_find_bad_rt( if (xc->next_bno < xc->irec_startbno + xc->irec.br_blockcount) { error = xrep_cow_mark_file_range(xc, - xfs_rgbno_to_rtb(sc->mp, rtg->rtg_rgno, - xc->next_bno), + xfs_rgbno_to_rtb(rtg, xc->next_bno), xc->irec_startbno + xc->irec.br_blockcount - xc->next_bno); if (error) diff --git a/fs/xfs/scrub/reap.c b/fs/xfs/scrub/reap.c index 39364d56fad3..26b66639bbdb 100644 --- a/fs/xfs/scrub/reap.c +++ b/fs/xfs/scrub/reap.c @@ -765,7 +765,7 @@ xreap_rgextent_iter( } ASSERT(rs->resv == XFS_AG_RESV_NONE); - rtbno = xfs_rgbno_to_rtb(sc->mp, sc->sr.rtg->rtg_rgno, rgbno); + rtbno = xfs_rgbno_to_rtb(sc->sr.rtg, rgbno); /* * If there are other rmappings, this block is cross linked and must diff --git a/fs/xfs/scrub/rgsuper.c b/fs/xfs/scrub/rgsuper.c index 43b5b568808e..96ef283cbbe9 100644 --- a/fs/xfs/scrub/rgsuper.c +++ b/fs/xfs/scrub/rgsuper.c @@ -31,15 +31,10 @@ STATIC void xchk_rgsuperblock_xref( struct xfs_scrub *sc) { - struct xfs_mount *mp = sc->mp; - xfs_rgnumber_t rgno = sc->sr.rtg->rtg_rgno; - xfs_rtblock_t rtbno; - if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) return; - rtbno = xfs_rgbno_to_rtb(mp, rgno, 0); - xchk_xref_is_used_rt_space(sc, rtbno, 1); + xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1); xchk_xref_is_only_rt_owned_by(sc, 0, 1, &XFS_RMAP_OINFO_FS); } diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c index c469f82f77fd..e75e5518e2da 100644 --- a/fs/xfs/scrub/rtrefcount.c +++ b/fs/xfs/scrub/rtrefcount.c @@ -346,14 +346,12 @@ xchk_rtrefcountbt_xref( struct xfs_scrub *sc, const struct xfs_refcount_irec *irec) { - xfs_rtblock_t rtbno; - if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) return; - rtbno = xfs_rgbno_to_rtb(sc->mp, sc->sr.rtg->rtg_rgno, - irec->rc_startblock); - xchk_xref_is_used_rt_space(sc, rtbno, irec->rc_blockcount); + xchk_xref_is_used_rt_space(sc, + xfs_rgbno_to_rtb(sc->sr.rtg, irec->rc_startblock), + irec->rc_blockcount); xchk_rtrefcountbt_xref_rmap(sc, irec); } diff --git a/fs/xfs/scrub/rtrmap.c b/fs/xfs/scrub/rtrmap.c index cbd7b13264b8..baf86d2209a1 100644 --- a/fs/xfs/scrub/rtrmap.c +++ b/fs/xfs/scrub/rtrmap.c @@ -203,15 +203,12 @@ xchk_rtrmapbt_xref( struct xfs_scrub *sc, struct xfs_rmap_irec *irec) { - xfs_rtblock_t rtbno; - if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) return; - rtbno = xfs_rgbno_to_rtb(sc->mp, sc->sr.rtg->rtg_rgno, - irec->rm_startblock); - - xchk_xref_is_used_rt_space(sc, rtbno, irec->rm_blockcount); + xchk_xref_is_used_rt_space(sc, + xfs_rgbno_to_rtb(sc->sr.rtg, irec->rm_startblock), + irec->rm_blockcount); if (irec->rm_owner == XFS_RMAP_OWN_COW) xchk_xref_is_cow_staging(sc, irec->rm_startblock, irec->rm_blockcount); diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c index f8bed8dcc66e..17ba65bd2aea 100644 --- a/fs/xfs/xfs_fsmap.c +++ b/fs/xfs/xfs_fsmap.c @@ -867,14 +867,11 @@ xfs_getfsmap_rtgroup_helper( * we calculated from userspace's high key to synthesize the record. * Note that if the btree query found a mapping, there won't be a gap. */ - if (info->last && info->end_daddr != XFS_BUF_DADDR_NULL) { + if (info->last && info->end_daddr != XFS_BUF_DADDR_NULL) frec->start_daddr = info->end_daddr; - } else { - xfs_rtblock_t rtbno; - - rtbno = xfs_rgbno_to_rtb(mp, rtg->rtg_rgno, startblock); - frec->start_daddr = xfs_rtb_to_daddr(mp, rtbno); - } + else + frec->start_daddr = + xfs_rtb_to_daddr(mp, xfs_rgbno_to_rtb(rtg, startblock)); frec->len_daddr = XFS_FSB_TO_BB(mp, blockcount); return xfs_getfsmap_helper(tp, info, frec); -- 2.50.1