xfs: initial agnumber -> perag conversions for shrink
Re: [PATCH 13/22] xfs: convert refcount btree cursor to use perags
In reply to Dave ChinnerQuoted 45 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_refcount.c | 39 +++++++++++++++++------------- fs/xfs/libxfs/xfs_refcount.h | 9 ++++++- fs/xfs/libxfs/xfs_refcount_btree.c | 22 +++++++---------- fs/xfs/libxfs/xfs_refcount_btree.h | 4 +-- fs/xfs/scrub/agheader_repair.c | 2 +- fs/xfs/scrub/bmap.c | 8 +++--- fs/xfs/scrub/common.c | 2 +- fs/xfs/xfs_fsmap.c | 3 +-- fs/xfs/xfs_reflink.c | 4 +-- 9 files changed, 50 insertions(+), 43 deletions(-)fs/xfs/libxfs/xfs_refcount.c +3
-3@@ -22,6 +22,7 @@#include "xfs_bit.h" #include "xfs_refcount.h" #include "xfs_rmap.h" +#include "xfs_ag.h" /* Allowable refcount adjustment amounts. */ enum xfs_refc_adjust_op {@@ -1142,14 +1143,13 @@ xfs_refcount_finish_one(struct xfs_btree_cur *rcur;struct xfs_buf *agbp =NULL ;int error =0 ; -xfs_agnumber_t agno;xfs_agblock_t bno;xfs_agblock_t new_agbno;unsigned long nr_ops =0 ;int shape_changes =0 ; +struct xfs_perag *pag; - agno =XFS_FSB_TO_AGNO (mp, startblock); -ASSERT (agno !=NULLAGNUMBER ); + pag =xfs_perag_get (mp,XFS_FSB_TO_AGNO (mp, startblock)); bno =XFS_FSB_TO_AGBNO (mp, startblock); trace_xfs_refcount_deferred(mp, XFS_FSB_TO_AGNO(mp, startblock),
fs/xfs/libxfs/xfs_refcount.c xfs_refcount_finish_one( · line 1160
Quoted 6 lines
fs/xfs/libxfs/xfs_refcount.c +1
-2@@ -1157,15 +1157,17 @@ xfs_refcount_finish_one( blockcount);if (XFS_TEST_ERROR (false, mp, -XFS_ERRTAG_REFCOUNT_FINISH_ONE )) -return -EIO ; +XFS_ERRTAG_REFCOUNT_FINISH_ONE )) {
Might as well shorten this into a single line while you're at it.
Same whinging as the last patch about passing agfbp and pag through the xfs_refcount.c functions into the cursor constructor.
--D
Quoted 312 lines
fs/xfs/libxfs/xfs_refcount.c +18
-12+ error = -EIO ; + goto out_drop; + }/* * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ rcur = *pcur; -if (rcur !=NULL && rcur->bc_ag.agno != agno) { +if (rcur !=NULL && rcur->bc_ag.pag != pag) { nr_ops = rcur->bc_ag.refc.nr_ops; shape_changes = rcur->bc_ag.refc.shape_changes;xfs_refcount_finish_one_cleanup (tp, rcur,0 );@@ -1173,12 +1175,12 @@ xfs_refcount_finish_one( *pcur =NULL ; }if (rcur ==NULL ) { - error =xfs_alloc_read_agf (tp->t_mountp, tp, agno, + error =xfs_alloc_read_agf (tp->t_mountp, tp, pag->pag_agno,XFS_ALLOC_FLAG_FREEING , &agbp);if (error) -return error; + goto out_drop; - rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, pag); rcur->bc_ag.refc.nr_ops = nr_ops; rcur->bc_ag.refc.shape_changes = shape_changes; }@@ -1188,12 +1190,12 @@ xfs_refcount_finish_one(case XFS_REFCOUNT_INCREASE : error =xfs_refcount_adjust (rcur, bno, blockcount, &new_agbno, new_len,XFS_REFCOUNT_ADJUST_INCREASE ,NULL ); - *new_fsb =XFS_AGB_TO_FSB (mp, agno, new_agbno); + *new_fsb =XFS_AGB_TO_FSB (mp, pag->pag_agno, new_agbno);break ;case XFS_REFCOUNT_DECREASE : error =xfs_refcount_adjust (rcur, bno, blockcount, &new_agbno, new_len,XFS_REFCOUNT_ADJUST_DECREASE ,NULL ); - *new_fsb =XFS_AGB_TO_FSB (mp, agno, new_agbno); + *new_fsb =XFS_AGB_TO_FSB (mp, pag->pag_agno, new_agbno);break ;case XFS_REFCOUNT_ALLOC_COW : *new_fsb = startblock + blockcount;@@ -1210,8 +1212,10 @@ xfs_refcount_finish_one( error = -EFSCORRUPTED ; }if (!error && *new_len >0 ) -trace_xfs_refcount_finish_one_leftover (mp, agno, type, +trace_xfs_refcount_finish_one_leftover (mp, pag->pag_agno, type, bno, blockcount, new_agbno, *new_len); +out_drop: +xfs_perag_put (pag);return error; }@@ -1672,7 +1676,7 @@ xfs_refcount_recover_extent(int xfs_refcount_recover_cow_leftovers (struct xfs_mount *mp, -xfs_agnumber_t agno) +struct xfs_perag *pag) {struct xfs_trans *tp;struct xfs_btree_cur *cur;@@ -1704,10 +1708,10 @@ xfs_refcount_recover_cow_leftovers(if (error)return error; - error =xfs_alloc_read_agf (mp, tp, agno,0 , &agbp); + error =xfs_alloc_read_agf (mp, tp, pag->pag_agno,0 , &agbp);if (error) goto out_trans; - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, pag);/* Find all the leftover CoW staging extents. */ memset (&low,0 ,sizeof (low));@@ -1729,11 +1733,12 @@ xfs_refcount_recover_cow_leftovers(if (error) goto out_free; -trace_xfs_refcount_recover_extent (mp, agno, &rr->rr_rrec); +trace_xfs_refcount_recover_extent (mp, pag->pag_agno, + &rr->rr_rrec);/* Free the orphan record */ agbno = rr->rr_rrec.rc_startblock -XFS_REFC_COW_START ; - fsb =XFS_AGB_TO_FSB (mp, agno, agbno); + fsb =XFS_AGB_TO_FSB (mp, pag->pag_agno, agbno);xfs_refcount_free_cow_extent (tp, fsb, rr->rr_rrec.rc_blockcount);fs/xfs/libxfs/xfs_refcount.h +8
-1@@ -6,6 +6,13 @@#ifndef __XFS_REFCOUNT_H__#define __XFS_REFCOUNT_H__ +struct xfs_trans ; +struct xfs_mount ; +struct xfs_perag ; +struct xfs_btree_cur ; +struct xfs_bmbt_irec ; +struct xfs_refcount_irec ; +extern int xfs_refcount_lookup_le (struct xfs_btree_cur *cur,xfs_agblock_t bno,int *stat); extern int xfs_refcount_lookup_ge(struct xfs_btree_cur *cur,@@ -50,7 +57,7 @@ void xfs_refcount_alloc_cow_extent(struct xfs_trans *tp, xfs_fsblock_t fsb,void xfs_refcount_free_cow_extent (struct xfs_trans *tp,xfs_fsblock_t fsb,xfs_extlen_t len);extern int xfs_refcount_recover_cow_leftovers (struct xfs_mount *mp, -xfs_agnumber_t agno); +struct xfs_perag *pag);/* * While we're adjusting the refcounts records of an extent, we have fs/xfs/libxfs/xfs_refcount_btree.c +9
-13@@ -26,7 +26,7 @@ xfs_refcountbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_refcountbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, cur->bc_ag.pag); + cur->bc_ag.agbp, cur->bc_ag.pag); }STATIC void@@ -316,13 +316,11 @@ static struct xfs_btree_cur *xfs_refcountbt_init_common ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, struct xfs_perag *pag) { struct xfs_btree_cur *cur; -ASSERT (agno !=NULLAGNUMBER ); -ASSERT (agno < mp->m_sb.sb_agcount); +ASSERT (pag->pag_agno < mp->m_sb.sb_agcount); cur =kmem_cache_zalloc (xfs_btree_cur_zone,GFP_NOFS | __GFP_NOFAIL); cur->bc_tp = tp;@@ -331,13 +329,12 @@ xfs_refcountbt_init_common( cur->bc_blocklog = mp->m_sb.sb_blocklog; cur->bc_statoff =XFS_STATS_CALC_INDEX (xs_refcbt_2); - cur->bc_ag.agno = agno; cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } + +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno; cur->bc_ag.refc.nr_ops =0 ; cur->bc_ag.refc.shape_changes =0 ;@@ -351,13 +348,12 @@ xfs_refcountbt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, struct xfs_perag *pag) { struct xfs_agf *agf = agbp->b_addr;struct xfs_btree_cur *cur; - cur =xfs_refcountbt_init_common (mp, tp, agno, pag); + cur =xfs_refcountbt_init_common (mp, tp, pag); cur->bc_nlevels =be32_to_cpu (agf->agf_refcount_level); cur->bc_ag.agbp = agbp;return cur;@@ -368,11 +364,11 @@ struct xfs_btree_cur *xfs_refcountbt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno) + struct xfs_perag *pag) { struct xfs_btree_cur *cur; - cur =xfs_refcountbt_init_common (mp,NULL , agno,NULL ); + cur =xfs_refcountbt_init_common (mp,NULL , pag);xfs_btree_stage_afakeroot (cur, afake);return cur; }fs/xfs/libxfs/xfs_refcount_btree.h +2
-2@@ -47,9 +47,9 @@ struct xbtree_afakeroot;extern struct xfs_btree_cur *xfs_refcountbt_init_cursor (struct xfs_mount *mp,struct xfs_trans *tp,struct xfs_buf *agbp, -xfs_agnumber_t agno,struct xfs_perag *pag); +struct xfs_perag *pag);struct xfs_btree_cur *xfs_refcountbt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno); +struct xbtree_afakeroot *afake,struct xfs_perag *pag);extern int xfs_refcountbt_maxrecs (int blocklen,bool leaf);extern void xfs_refcountbt_compute_maxlevels (struct xfs_mount *mp);fs/xfs/scrub/agheader_repair.c +1
-1@@ -282,7 +282,7 @@ xrep_agf_calc_from_btrees(/* Update the AGF counters from the refcountbt. */ if (xfs_sb_version_hasreflink (&mp->m_sb)) { cur =xfs_refcountbt_init_cursor (mp, sc->tp, agf_bp, - sc->sa.agno, sc->sa.pag); + sc->sa.pag); error =xfs_btree_count_blocks (cur, &blocks);if (error) goto err;fs/xfs/scrub/bmap.c +4
-4@@ -545,18 +545,18 @@ STATIC intxchk_bmap_check_ag_rmaps ( struct xfs_scrub *sc, int whichfork, - xfs_agnumber_t agno) + struct xfs_perag *pag) { struct xchk_bmap_check_rmap_info sbcri;struct xfs_btree_cur *cur;struct xfs_buf *agf;int error; - error =xfs_alloc_read_agf (sc->mp, sc->tp, agno,0 , &agf); + error =xfs_alloc_read_agf (sc->mp, sc->tp, pag->pag_agno,0 , &agf);if (error)return error; - cur =xfs_rmapbt_init_cursor (sc->mp, sc->tp, agf, sc->sa.pag); + cur =xfs_rmapbt_init_cursor (sc->mp, sc->tp, agf, pag); sbcri.sc = sc; sbcri.whichfork = whichfork;@@ -610,7 +610,7 @@ xchk_bmap_check_rmaps(return 0 ;for_each_perag (sc->mp, agno, pag) { - error =xchk_bmap_check_ag_rmaps (sc, whichfork, pag->pag_agno); + error =xchk_bmap_check_ag_rmaps (sc, whichfork, pag);if (error)return error;if (sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT )fs/xfs/scrub/common.c +1
-1@@ -500,7 +500,7 @@ xchk_ag_btcur_init(if (sa->agf_bp &&xfs_sb_version_hasreflink (&mp->m_sb) &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_REFC )) { sa->refc_cur =xfs_refcountbt_init_cursor (mp, sc->tp, - sa->agf_bp, agno, sa->pag); + sa->agf_bp, sa->pag); } }fs/xfs/xfs_fsmap.c +1
-2@@ -210,8 +210,7 @@ xfs_getfsmap_is_shared(/* Are there any shared blocks here? */ flen =0 ; - cur =xfs_refcountbt_init_cursor (mp, tp, info->agf_bp, - info->pag->pag_agno, info->pag); + cur =xfs_refcountbt_init_cursor (mp, tp, info->agf_bp, info->pag); error =xfs_refcount_find_shared (cur, rec->rm_startblock, rec->rm_blockcount, &fbno, &flen, false);fs/xfs/xfs_reflink.c +2
-2@@ -144,7 +144,7 @@ xfs_reflink_find_shared(if (error)return error; - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agbp->b_pag); error =xfs_refcount_find_shared (cur, agbno, aglen, fbno, flen, find_end_of_shared);@@ -763,7 +763,7 @@ xfs_reflink_recover_cow(return 0 ;for_each_perag (mp, agno, pag) { - error =xfs_refcount_recover_cow_leftovers (mp, pag->pag_agno); + error =xfs_refcount_recover_cow_leftovers (mp, pag);if (error) {xfs_perag_put (pag);break ;Signature · 1 line
2.31.1
PATCH 14/22 xfs: convert allocbt cursors to use perags
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- fs/xfs/libxfs/xfs_alloc.c | 25 ++++++++++--------------- fs/xfs/libxfs/xfs_alloc_btree.c | 26 ++++++++++---------------- fs/xfs/libxfs/xfs_alloc_btree.h | 8 ++++---- fs/xfs/scrub/agheader_repair.c | 8 ++++---- fs/xfs/scrub/common.c | 4 ++-- fs/xfs/xfs_discard.c | 2 +- fs/xfs/xfs_fsmap.c | 2 +- 7 files changed, 32 insertions(+), 43 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +10 -15
@@ -776,8 +776,7 @@ xfs_alloc_cur_setup(*/ if (!acur->cnt) acur->cnt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_CNT ); + args->agbp, args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (acur->cnt,0 , args->maxlen, &i);if (error)return error;
@@ -787,12 +786,10 @@ xfs_alloc_cur_setup(*/ if (!acur->bnolt) acur->bnolt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );if (!acur->bnogt) acur->bnogt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );return i ==1 ?0 : -ENOSPC ; }
@@ -1220,7 +1217,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-number freespace btree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );/* * Lookup bno and minlen in the btree (minlen is irrelevant, really).
@@ -1280,7 +1277,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT );ASSERT (args->agbno + args->len <=be32_to_cpu (agf->agf_length)); error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, args->agbno, args->len,XFSA_FIXUP_BNO_OK );
@@ -1677,7 +1674,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); bno_cur =NULL ; busy = false;
@@ -1840,7 +1837,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-block tree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );if ((error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, rbno, rlen,XFSA_FIXUP_CNT_OK ))) goto error0;
@@ -1913,8 +1910,7 @@ xfs_free_ag_extent(/* * Allocate and initialize a cursor for the by-block btree. */ - bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_BNO ); + bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_BNO );/* * Look for a neighboring block on the left (lower block numbers) * that is contiguous with this space.
@@ -1984,8 +1980,7 @@ xfs_free_ag_extent(/* * Now allocate and initialize a cursor for the by-size tree. */ - cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_CNT ); + cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_CNT );/* * Have both left and right contiguous neighbors. * Merge all three into a single free block.
@@ -2496,7 +2491,7 @@ xfs_exact_minlen_extent_available(int error =0 ; cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (cnt_cur,0 , args->minlen, stat);if (error) goto out;
fs/xfs/libxfs/xfs_alloc_btree.c +10 -16
@@ -26,8 +26,7 @@ xfs_allocbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_allocbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void
@@ -39,13 +38,12 @@ xfs_allocbt_set_root(struct xfs_buf *agbp = cur->bc_ag.agbp;struct xfs_agf *agf = agbp->b_addr;int btnum = cur->bc_btnum; -struct xfs_perag *pag = agbp->b_pag;ASSERT (ptr->s !=0 ); agf->agf_roots[btnum] = ptr->s;be32_add_cpu (&agf->agf_levels[btnum], inc); - pag->pagf_levels[btnum] += inc; + cur->bc_ag.pag->pagf_levels[btnum] += inc;xfs_alloc_log_agf (cur->bc_tp, agbp,XFS_AGF_ROOTS |XFS_AGF_LEVELS ); }
@@ -224,7 +222,7 @@ xfs_allocbt_init_ptr_from_cur( {struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agf->agf_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agf->agf_seqno)); ptr->s = agf->agf_roots[cur->bc_btnum]; }
@@ -472,7 +470,6 @@ STATIC struct xfs_btree_cur *xfs_allocbt_init_common ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) {
@@ -486,6 +483,7 @@ xfs_allocbt_init_common( cur->bc_mp = mp; cur->bc_btnum = btnum; cur->bc_blocklog = mp->m_sb.sb_blocklog; + cur->bc_ag.abt.active = false;if (btnum ==XFS_BTNUM_CNT ) { cur->bc_ops = &xfs_cntbt_ops;
@@ -496,13 +494,10 @@ xfs_allocbt_init_common( cur->bc_statoff =XFS_STATS_CALC_INDEX (xs_abtb_2); } - cur->bc_ag.agno = agno; - cur->bc_ag.abt.active = false; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ;
@@ -518,14 +513,13 @@ xfs_allocbt_init_cursor(struct xfs_mount *mp,/* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ struct xfs_buf *agbp, /* buffer for agf structure */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* btree identifier */ { struct xfs_agf *agf = agbp->b_addr;struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_allocbt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_CNT ) cur->bc_nlevels =be32_to_cpu (agf->agf_levels[XFS_BTNUM_CNT ]);else
@@ -541,12 +535,12 @@ struct xfs_btree_cur *xfs_allocbt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_allocbt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }
fs/xfs/libxfs/xfs_alloc_btree.h +4 -4
@@ -47,11 +47,11 @@ struct xbtree_afakeroot; (maxrecs) * sizeof(xfs_alloc_key_t) + \ ((index) - 1) * sizeof(xfs_alloc_ptr_t))) -extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *, -struct xfs_trans *,struct xfs_buf *, -xfs_agnumber_t ,struct xfs_perag *pag,xfs_btnum_t ); +extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *mp, +struct xfs_trans *tp,struct xfs_buf *bp, +struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_allocbt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_allocbt_maxrecs (struct xfs_mount *,int ,int ); extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
fs/xfs/scrub/agheader_repair.c +4 -4
@@ -246,7 +246,7 @@ xrep_agf_calc_from_btrees(int error;/* Update the AGF counters from the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xfs_alloc_query_all (cur, xrep_agf_walk_allocbt, &raa);if (error)
@@ -260,7 +260,7 @@ xrep_agf_calc_from_btrees( agf->agf_longest =cpu_to_be32 (raa.longest);/* Update the AGF counters from the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xfs_btree_count_blocks (cur, &blocks);if (error)
@@ -497,7 +497,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)
@@ -505,7 +505,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)
fs/xfs/scrub/common.c +2 -2
@@ -465,14 +465,14 @@ xchk_ag_btcur_init( xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) {/* Set up a bnobt cursor for cross-referencing. */ sa->bno_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_BNO ); + sa->pag,XFS_BTNUM_BNO ); }if (sa->agf_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_CNT )) {/* Set up a cntbt cursor for cross-referencing. */ sa->cnt_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_CNT ); + sa->pag,XFS_BTNUM_CNT ); }/* Set up a inobt cursor for cross-referencing. */
fs/xfs/xfs_discard.c +1 -1
@@ -50,7 +50,7 @@ xfs_trim_extents( goto out_put_perag; agf = agbp->b_addr; - cur =xfs_allocbt_init_cursor (mp,NULL , agbp, agno, pag,XFS_BTNUM_CNT ); + cur =xfs_allocbt_init_cursor (mp,NULL , agbp, pag,XFS_BTNUM_CNT );/* * Look up the longest btree in the AGF and start with it.
fs/xfs/xfs_fsmap.c +1 -1
@@ -740,7 +740,7 @@ xfs_getfsmap_datadev_bnobt_query(/* Allocate cursor for this AG and query_range it. */ *curpp =xfs_allocbt_init_cursor (tp->t_mountp, tp, info->agf_bp, - info->pag->pag_agno, info->pag,XFS_BTNUM_BNO ); + info->pag,XFS_BTNUM_BNO ); key->ar_startblock = info->low.rm_startblock; key[1 ].ar_startblock = info->high.rm_startblock; return xfs_alloc_query_range(*curpp, key, &key[1],
Signature · 1 line
2.31.1
Re: [PATCH 14/22] xfs: convert allocbt cursors to use perags
Quoted 4 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>---
Quoted 315 lines
fs/xfs/libxfs/xfs_alloc.c | 25 ++++++++++--------------- fs/xfs/libxfs/xfs_alloc_btree.c | 26 ++++++++++---------------- fs/xfs/libxfs/xfs_alloc_btree.h | 8 ++++---- fs/xfs/scrub/agheader_repair.c | 8 ++++---- fs/xfs/scrub/common.c | 4 ++-- fs/xfs/xfs_discard.c | 2 +- fs/xfs/xfs_fsmap.c | 2 +- 7 files changed, 32 insertions(+), 43 deletions(-)fs/xfs/libxfs/xfs_alloc.c +10
-15@@ -776,8 +776,7 @@ xfs_alloc_cur_setup(*/ if (!acur->cnt) acur->cnt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_CNT ); + args->agbp, args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (acur->cnt,0 , args->maxlen, &i);if (error)return error;@@ -787,12 +786,10 @@ xfs_alloc_cur_setup(*/ if (!acur->bnolt) acur->bnolt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );if (!acur->bnogt) acur->bnogt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );return i ==1 ?0 : -ENOSPC ; }@@ -1220,7 +1217,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-number freespace btree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );/* * Lookup bno and minlen in the btree (minlen is irrelevant, really). @@ -1280,7 +1277,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT );ASSERT (args->agbno + args->len <=be32_to_cpu (agf->agf_length)); error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, args->agbno, args->len,XFSA_FIXUP_BNO_OK );@@ -1677,7 +1674,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); bno_cur =NULL ; busy = false;@@ -1840,7 +1837,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-block tree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );if ((error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, rbno, rlen,XFSA_FIXUP_CNT_OK ))) goto error0;@@ -1913,8 +1910,7 @@ xfs_free_ag_extent(/* * Allocate and initialize a cursor for the by-block btree. */ - bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_BNO ); + bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_BNO );/* * Look for a neighboring block on the left (lower block numbers) * that is contiguous with this space. @@ -1984,8 +1980,7 @@ xfs_free_ag_extent(/* * Now allocate and initialize a cursor for the by-size tree. */ - cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_CNT ); + cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_CNT );/* * Have both left and right contiguous neighbors. * Merge all three into a single free block. @@ -2496,7 +2491,7 @@ xfs_exact_minlen_extent_available(int error =0 ; cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (cnt_cur,0 , args->minlen, stat);if (error) goto out;fs/xfs/libxfs/xfs_alloc_btree.c +10
-16@@ -26,8 +26,7 @@ xfs_allocbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_allocbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void@@ -39,13 +38,12 @@ xfs_allocbt_set_root(struct xfs_buf *agbp = cur->bc_ag.agbp;struct xfs_agf *agf = agbp->b_addr;int btnum = cur->bc_btnum; -struct xfs_perag *pag = agbp->b_pag;ASSERT (ptr->s !=0 ); agf->agf_roots[btnum] = ptr->s;be32_add_cpu (&agf->agf_levels[btnum], inc); - pag->pagf_levels[btnum] += inc; + cur->bc_ag.pag->pagf_levels[btnum] += inc;xfs_alloc_log_agf (cur->bc_tp, agbp,XFS_AGF_ROOTS |XFS_AGF_LEVELS ); }@@ -224,7 +222,7 @@ xfs_allocbt_init_ptr_from_cur( {struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agf->agf_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agf->agf_seqno)); ptr->s = agf->agf_roots[cur->bc_btnum]; }@@ -472,7 +470,6 @@ STATIC struct xfs_btree_cur *xfs_allocbt_init_common ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) {@@ -486,6 +483,7 @@ xfs_allocbt_init_common( cur->bc_mp = mp; cur->bc_btnum = btnum; cur->bc_blocklog = mp->m_sb.sb_blocklog; + cur->bc_ag.abt.active = false;if (btnum ==XFS_BTNUM_CNT ) { cur->bc_ops = &xfs_cntbt_ops;@@ -496,13 +494,10 @@ xfs_allocbt_init_common( cur->bc_statoff =XFS_STATS_CALC_INDEX (xs_abtb_2); } - cur->bc_ag.agno = agno; - cur->bc_ag.abt.active = false; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ;@@ -518,14 +513,13 @@ xfs_allocbt_init_cursor(struct xfs_mount *mp,/* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ struct xfs_buf *agbp, /* buffer for agf structure */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* btree identifier */ { struct xfs_agf *agf = agbp->b_addr;struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_allocbt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_CNT ) cur->bc_nlevels =be32_to_cpu (agf->agf_levels[XFS_BTNUM_CNT ]);else @@ -541,12 +535,12 @@ struct xfs_btree_cur *xfs_allocbt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_allocbt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }fs/xfs/libxfs/xfs_alloc_btree.h +4
-4@@ -47,11 +47,11 @@ struct xbtree_afakeroot; (maxrecs) * sizeof(xfs_alloc_key_t) + \ ((index) - 1) * sizeof(xfs_alloc_ptr_t))) -extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *, -struct xfs_trans *,struct xfs_buf *, -xfs_agnumber_t ,struct xfs_perag *pag,xfs_btnum_t ); +extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *mp, +struct xfs_trans *tp,struct xfs_buf *bp, +struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_allocbt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_allocbt_maxrecs (struct xfs_mount *,int ,int ); extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,fs/xfs/scrub/agheader_repair.c +4
-4@@ -246,7 +246,7 @@ xrep_agf_calc_from_btrees(int error;/* Update the AGF counters from the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xfs_alloc_query_all (cur, xrep_agf_walk_allocbt, &raa);if (error)@@ -260,7 +260,7 @@ xrep_agf_calc_from_btrees( agf->agf_longest =cpu_to_be32 (raa.longest);/* Update the AGF counters from the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xfs_btree_count_blocks (cur, &blocks);if (error)@@ -497,7 +497,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)@@ -505,7 +505,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)fs/xfs/scrub/common.c +2
-2@@ -465,14 +465,14 @@ xchk_ag_btcur_init( xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) {/* Set up a bnobt cursor for cross-referencing. */ sa->bno_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_BNO ); + sa->pag,XFS_BTNUM_BNO ); }if (sa->agf_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_CNT )) {/* Set up a cntbt cursor for cross-referencing. */ sa->cnt_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_CNT ); + sa->pag,XFS_BTNUM_CNT ); }/* Set up a inobt cursor for cross-referencing. */ fs/xfs/xfs_discard.c +1
-1@@ -50,7 +50,7 @@ xfs_trim_extents( goto out_put_perag; agf = agbp->b_addr; - cur =xfs_allocbt_init_cursor (mp,NULL , agbp, agno, pag,XFS_BTNUM_CNT ); + cur =xfs_allocbt_init_cursor (mp,NULL , agbp, pag,XFS_BTNUM_CNT );/* * Look up the longest btree in the AGF and start with it. fs/xfs/xfs_fsmap.c +1
-1@@ -740,7 +740,7 @@ xfs_getfsmap_datadev_bnobt_query(/* Allocate cursor for this AG and query_range it. */ *curpp =xfs_allocbt_init_cursor (tp->t_mountp, tp, info->agf_bp, - info->pag->pag_agno, info->pag,XFS_BTNUM_BNO ); + info->pag,XFS_BTNUM_BNO ); key->ar_startblock = info->low.rm_startblock; key[1 ].ar_startblock = info->high.rm_startblock; return xfs_alloc_query_range(*curpp, key, &key[1],Signature · 1 line
2.31.1
Re: [PATCH 14/22] xfs: convert allocbt cursors to use perags
In reply to Dave ChinnerQuoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Fairly simple mechanical change...
--D
Quoted 316 lines
--- fs/xfs/libxfs/xfs_alloc.c | 25 ++++++++++--------------- fs/xfs/libxfs/xfs_alloc_btree.c | 26 ++++++++++---------------- fs/xfs/libxfs/xfs_alloc_btree.h | 8 ++++---- fs/xfs/scrub/agheader_repair.c | 8 ++++---- fs/xfs/scrub/common.c | 4 ++-- fs/xfs/xfs_discard.c | 2 +- fs/xfs/xfs_fsmap.c | 2 +- 7 files changed, 32 insertions(+), 43 deletions(-)fs/xfs/libxfs/xfs_alloc.c +10
-15@@ -776,8 +776,7 @@ xfs_alloc_cur_setup(*/ if (!acur->cnt) acur->cnt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_CNT ); + args->agbp, args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (acur->cnt,0 , args->maxlen, &i);if (error)return error;@@ -787,12 +786,10 @@ xfs_alloc_cur_setup(*/ if (!acur->bnolt) acur->bnolt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );if (!acur->bnogt) acur->bnogt =xfs_allocbt_init_cursor (args->mp, args->tp, - args->agbp, args->agno, - args->pag,XFS_BTNUM_BNO ); + args->agbp, args->pag,XFS_BTNUM_BNO );return i ==1 ?0 : -ENOSPC ; }@@ -1220,7 +1217,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-number freespace btree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );/* * Lookup bno and minlen in the btree (minlen is irrelevant, really). @@ -1280,7 +1277,7 @@ xfs_alloc_ag_vextent_exact(* Allocate/initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT );ASSERT (args->agbno + args->len <=be32_to_cpu (agf->agf_length)); error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, args->agbno, args->len,XFSA_FIXUP_BNO_OK );@@ -1677,7 +1674,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-size btree. */ cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); bno_cur =NULL ; busy = false;@@ -1840,7 +1837,7 @@ xfs_alloc_ag_vextent_size(* Allocate and initialize a cursor for the by-block tree. */ bno_cur =xfs_allocbt_init_cursor (args->mp, args->tp, args->agbp, - args->agno, args->pag,XFS_BTNUM_BNO ); + args->pag,XFS_BTNUM_BNO );if ((error =xfs_alloc_fixup_trees (cnt_cur, bno_cur, fbno, flen, rbno, rlen,XFSA_FIXUP_CNT_OK ))) goto error0;@@ -1913,8 +1910,7 @@ xfs_free_ag_extent(/* * Allocate and initialize a cursor for the by-block btree. */ - bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_BNO ); + bno_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_BNO );/* * Look for a neighboring block on the left (lower block numbers) * that is contiguous with this space. @@ -1984,8 +1980,7 @@ xfs_free_ag_extent(/* * Now allocate and initialize a cursor for the by-size tree. */ - cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, agno, -NULL ,XFS_BTNUM_CNT ); + cnt_cur =xfs_allocbt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_CNT );/* * Have both left and right contiguous neighbors. * Merge all three into a single free block. @@ -2496,7 +2491,7 @@ xfs_exact_minlen_extent_available(int error =0 ; cnt_cur =xfs_allocbt_init_cursor (args->mp, args->tp, agbp, - args->agno, args->pag,XFS_BTNUM_CNT ); + args->pag,XFS_BTNUM_CNT ); error =xfs_alloc_lookup_ge (cnt_cur,0 , args->minlen, stat);if (error) goto out;fs/xfs/libxfs/xfs_alloc_btree.c +10
-16@@ -26,8 +26,7 @@ xfs_allocbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_allocbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void@@ -39,13 +38,12 @@ xfs_allocbt_set_root(struct xfs_buf *agbp = cur->bc_ag.agbp;struct xfs_agf *agf = agbp->b_addr;int btnum = cur->bc_btnum; -struct xfs_perag *pag = agbp->b_pag;ASSERT (ptr->s !=0 ); agf->agf_roots[btnum] = ptr->s;be32_add_cpu (&agf->agf_levels[btnum], inc); - pag->pagf_levels[btnum] += inc; + cur->bc_ag.pag->pagf_levels[btnum] += inc;xfs_alloc_log_agf (cur->bc_tp, agbp,XFS_AGF_ROOTS |XFS_AGF_LEVELS ); }@@ -224,7 +222,7 @@ xfs_allocbt_init_ptr_from_cur( {struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agf->agf_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agf->agf_seqno)); ptr->s = agf->agf_roots[cur->bc_btnum]; }@@ -472,7 +470,6 @@ STATIC struct xfs_btree_cur *xfs_allocbt_init_common ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) {@@ -486,6 +483,7 @@ xfs_allocbt_init_common( cur->bc_mp = mp; cur->bc_btnum = btnum; cur->bc_blocklog = mp->m_sb.sb_blocklog; + cur->bc_ag.abt.active = false;if (btnum ==XFS_BTNUM_CNT ) { cur->bc_ops = &xfs_cntbt_ops;@@ -496,13 +494,10 @@ xfs_allocbt_init_common( cur->bc_statoff =XFS_STATS_CALC_INDEX (xs_abtb_2); } - cur->bc_ag.agno = agno; - cur->bc_ag.abt.active = false; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ;@@ -518,14 +513,13 @@ xfs_allocbt_init_cursor(struct xfs_mount *mp,/* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ struct xfs_buf *agbp, /* buffer for agf structure */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* btree identifier */ { struct xfs_agf *agf = agbp->b_addr;struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_allocbt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_CNT ) cur->bc_nlevels =be32_to_cpu (agf->agf_levels[XFS_BTNUM_CNT ]);else @@ -541,12 +535,12 @@ struct xfs_btree_cur *xfs_allocbt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_allocbt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_allocbt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }fs/xfs/libxfs/xfs_alloc_btree.h +4
-4@@ -47,11 +47,11 @@ struct xbtree_afakeroot; (maxrecs) * sizeof(xfs_alloc_key_t) + \ ((index) - 1) * sizeof(xfs_alloc_ptr_t))) -extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *, -struct xfs_trans *,struct xfs_buf *, -xfs_agnumber_t ,struct xfs_perag *pag,xfs_btnum_t ); +extern struct xfs_btree_cur *xfs_allocbt_init_cursor (struct xfs_mount *mp, +struct xfs_trans *tp,struct xfs_buf *bp, +struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_allocbt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_allocbt_maxrecs (struct xfs_mount *,int ,int ); extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,fs/xfs/scrub/agheader_repair.c +4
-4@@ -246,7 +246,7 @@ xrep_agf_calc_from_btrees(int error;/* Update the AGF counters from the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xfs_alloc_query_all (cur, xrep_agf_walk_allocbt, &raa);if (error)@@ -260,7 +260,7 @@ xrep_agf_calc_from_btrees( agf->agf_longest =cpu_to_be32 (raa.longest);/* Update the AGF counters from the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xfs_btree_count_blocks (cur, &blocks);if (error)@@ -497,7 +497,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the bnobt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_BNO ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)@@ -505,7 +505,7 @@ xrep_agfl_collect_blocks(xfs_btree_del_cursor (cur, error);/* Find all blocks currently being used by the cntbt. */ - cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.agno, + cur =xfs_allocbt_init_cursor (mp, sc->tp, agf_bp, sc->sa.pag,XFS_BTNUM_CNT ); error =xbitmap_set_btblocks (&ra.agmetablocks, cur);if (error)fs/xfs/scrub/common.c +2
-2@@ -465,14 +465,14 @@ xchk_ag_btcur_init( xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) {/* Set up a bnobt cursor for cross-referencing. */ sa->bno_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_BNO ); + sa->pag,XFS_BTNUM_BNO ); }if (sa->agf_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_CNT )) {/* Set up a cntbt cursor for cross-referencing. */ sa->cnt_cur =xfs_allocbt_init_cursor (mp, sc->tp, sa->agf_bp, - agno, sa->pag,XFS_BTNUM_CNT ); + sa->pag,XFS_BTNUM_CNT ); }/* Set up a inobt cursor for cross-referencing. */ fs/xfs/xfs_discard.c +1
-1@@ -50,7 +50,7 @@ xfs_trim_extents( goto out_put_perag; agf = agbp->b_addr; - cur =xfs_allocbt_init_cursor (mp,NULL , agbp, agno, pag,XFS_BTNUM_CNT ); + cur =xfs_allocbt_init_cursor (mp,NULL , agbp, pag,XFS_BTNUM_CNT );/* * Look up the longest btree in the AGF and start with it. fs/xfs/xfs_fsmap.c +1
-1@@ -740,7 +740,7 @@ xfs_getfsmap_datadev_bnobt_query(/* Allocate cursor for this AG and query_range it. */ *curpp =xfs_allocbt_init_cursor (tp->t_mountp, tp, info->agf_bp, - info->pag->pag_agno, info->pag,XFS_BTNUM_BNO ); + info->pag,XFS_BTNUM_BNO ); key->ar_startblock = info->low.rm_startblock; key[1 ].ar_startblock = info->high.rm_startblock; return xfs_alloc_query_range(*curpp, key, &key[1],Signature · 1 line
2.31.1
PATCH 15/22 xfs: use perag for ialloc btree cursors
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- fs/xfs/libxfs/xfs_ialloc.c | 177 ++++++++++++++++--------------- fs/xfs/libxfs/xfs_ialloc_btree.c | 27 ++--- fs/xfs/libxfs/xfs_ialloc_btree.h | 6 +- fs/xfs/scrub/agheader_repair.c | 4 +- fs/xfs/scrub/common.c | 5 +- fs/xfs/xfs_iwalk.c | 6 +- 6 files changed, 109 insertions(+), 116 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +89 -88
@@ -172,18 +172,17 @@ xfs_inobt_insert(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t newino, xfs_agino_t newlen, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agino_t thisino;int i;int error; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum); for (thisino = newino; thisino < newino + newlen;
@@ -520,18 +519,17 @@ xfs_inobt_insert_sprec(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, int btnum, struct xfs_inobt_rec_incore *nrec, /* in/out: new/merged rec. */ bool merge) /* merge or replace */ { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);int error;int i;struct xfs_inobt_rec_incore rec; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum);/* the new record is pre-aligned so we know where to look */ error =xfs_inobt_lookup (cur, nrec->ir_startino,XFS_LOOKUP_EQ , &i);
@@ -578,14 +576,14 @@ xfs_inobt_insert_sprec( goto error; } -trace_xfs_irec_merge_pre (mp, agno, rec.ir_startino, +trace_xfs_irec_merge_pre (mp, pag->pag_agno, rec.ir_startino, rec.ir_holemask, nrec->ir_startino, nrec->ir_holemask);/* merge to nrec to output the updated record */ __xfs_inobt_rec_merge (nrec, &rec); -trace_xfs_irec_merge_post (mp, agno, nrec->ir_startino, +trace_xfs_irec_merge_post (mp, pag->pag_agno, nrec->ir_startino, nrec->ir_holemask); error =xfs_inobt_rec_check_count (mp, nrec);
@@ -613,21 +611,20 @@ xfs_inobt_insert_sprec( STATIC intxfs_ialloc_ag_alloc (struct xfs_trans *tp, -struct xfs_buf *agbp) +struct xfs_buf *agbp, +struct xfs_perag *pag) {struct xfs_agi *agi;struct xfs_alloc_arg args; -xfs_agnumber_t agno;int error;xfs_agino_t newino;/* new first inode's number */ xfs_agino_t newlen;/* new number of inodes */ int isaligned =0 ;/* inode allocation at stripe */ /* unit boundary */ /* init. to full chunk */ -uint16_t allocmask = (uint16_t )-1 ;struct xfs_inobt_rec_incore rec; -struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (tp->t_mountp); +uint16_t allocmask = (uint16_t )-1 ;int do_sparse =0 ;memset (&args,0 ,sizeof (args));
@@ -660,14 +657,13 @@ xfs_ialloc_ag_alloc(*/ agi = agbp->b_addr; newino =be32_to_cpu (agi->agi_newino); - agno =be32_to_cpu (agi->agi_seqno); args.agbno =XFS_AGINO_TO_AGBNO (args.mp, newino) + igeo->ialloc_blks;if (do_sparse) goto sparse_alloc;if (likely (newino !=NULLAGINO && (args.agbno <be32_to_cpu (agi->agi_length)))) { - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.type =XFS_ALLOCTYPE_THIS_BNO ; args.prod =1 ;
@@ -727,7 +723,7 @@ xfs_ialloc_ag_alloc(* For now, just allocate blocks up front. */ args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno);/* * Allocate a fixed-size extent of inodes. */
@@ -748,7 +744,7 @@ xfs_ialloc_ag_alloc(if (isaligned && args.fsbno ==NULLFSBLOCK ) { args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = igeo->cluster_align;if ((error =xfs_alloc_vextent (&args)))return error;
@@ -764,7 +760,7 @@ xfs_ialloc_ag_alloc( sparse_alloc: args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = args.mp->m_sb.sb_spino_align; args.prod =1 ;
@@ -809,7 +805,7 @@ xfs_ialloc_ag_alloc(* rather than a linear progression to prevent the next generation * number from being easily guessable. */ - error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, agno, + error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, pag->pag_agno, args.agbno, args.len,prandom_u32 ());if (error)
@@ -836,12 +832,12 @@ xfs_ialloc_ag_alloc(* if necessary. If a merge does occur, rec is updated to the * merged record. */ - error =xfs_inobt_insert_sprec (args.mp, tp, agbp,XFS_BTNUM_INO , - &rec, true); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_INO , &rec, true);if (error == -EFSCORRUPTED ) {xfs_alert (args.mp,"invalid sparse inode record: ino 0x%llx holemask 0x%x count %u" , -XFS_AGINO_TO_INO (args.mp, agno, +XFS_AGINO_TO_INO (args.mp, pag->pag_agno, rec.ir_startino), rec.ir_holemask, rec.ir_count);xfs_force_shutdown (args.mp,SHUTDOWN_CORRUPT_INCORE );
@@ -861,21 +857,20 @@ xfs_ialloc_ag_alloc(* existing record with this one. */ if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert_sprec (args.mp, tp, agbp, -XFS_BTNUM_FINO , &rec, - false); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_FINO , &rec, false);if (error)return error; } }else {/* full chunk - insert new records to both btrees */ - error =xfs_inobt_insert (args.mp, tp, agbp, newino, newlen, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_INO );if (error)return error;if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert (args.mp, tp, agbp, newino, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_FINO );if (error)return error;
@@ -887,7 +882,6 @@ xfs_ialloc_ag_alloc(*/ be32_add_cpu (&agi->agi_count, newlen);be32_add_cpu (&agi->agi_freecount, newlen); - pag = agbp->b_pag; pag->pagi_freecount += newlen; pag->pagi_count += newlen; agi->agi_newino =cpu_to_be32 (newino);
@@ -1123,15 +1117,14 @@ STATIC intxfs_dialloc_ag_inobt ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) { struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent); -struct xfs_perag *pag = agbp->b_pag;struct xfs_btree_cur *cur, *tcur;struct xfs_inobt_rec_incore rec, trec;xfs_ino_t ino;
@@ -1145,7 +1138,7 @@ xfs_dialloc_ag_inobt(ASSERT (pag->pagi_freecount >0 ); restart_pagno: - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO );/* * If pagino is 0 (this is the root inode allocation) use newino. * This must work because we've just allocated some.
@@ -1160,7 +1153,7 @@ xfs_dialloc_ag_inobt(/* * If in the same AG as the parent, try to get near the parent. */ -if (pagno == agno) { +if (pagno == pag->pag_agno) {int doneleft;/* done, to the left */ int doneright;/* done, to the right */
@@ -1363,7 +1356,7 @@ xfs_dialloc_ag_inobt(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset); rec.ir_free &= ~XFS_INOBT_MASK (offset); rec.ir_freecount--; error =xfs_inobt_update (cur, &rec);
@@ -1577,7 +1570,6 @@ xfs_dialloc_ag( {struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent);struct xfs_btree_cur *cur;/* finobt cursor */
@@ -1587,9 +1579,10 @@ xfs_dialloc_ag(int error;int offset;int i; +struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb)) -return xfs_dialloc_ag_inobt (tp, agbp, parent, inop); +return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);/* * If pagino is 0 (this is the root inode allocation) use newino.
@@ -1598,7 +1591,7 @@ xfs_dialloc_ag(if (!pagino) pagino =be32_to_cpu (agi->agi_newino); - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_check_agi_freecount (cur, agi);if (error)
@@ -1609,7 +1602,7 @@ xfs_dialloc_ag(* parent. If so, find the closest available inode to the parent. If * not, consider the agi hint or find the first free inode in the AG. */ -if (agno == pagno) +if (pag->pag_agno == pagno) error =xfs_dialloc_ag_finobt_near (pagino, &cur, &rec);else error =xfs_dialloc_ag_finobt_newino (agi, cur, &rec);
@@ -1621,7 +1614,7 @@ xfs_dialloc_ag(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset);/* * Modify or remove the finobt record.
@@ -1641,7 +1634,7 @@ xfs_dialloc_ag(* the original freecount. If all is well, make the equivalent update to * the inobt using the finobt record and offset information. */ - icur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + icur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (icur, agi);if (error)
@@ -1657,7 +1650,7 @@ xfs_dialloc_ag(*/ be32_add_cpu (&agi->agi_freecount,-1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount--; + pag->pagi_freecount--;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,-1 );
@@ -1809,7 +1802,7 @@ xfs_dialloc_select_ag(if (!okalloc) goto nextag_relse_buffer; - error =xfs_ialloc_ag_alloc (*tpp, agbp); + error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp);
@@ -1935,12 +1928,12 @@ xfs_difree_inobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int ilen;
@@ -1954,7 +1947,7 @@ xfs_difree_inobt(/* * Initialize the cursor. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (cur, agi);if (error)
@@ -2005,7 +1998,8 @@ xfs_difree_inobt(struct xfs_perag *pag = agbp->b_pag; xic->deleted = true; - xic->first_ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino); + xic->first_ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, + rec.ir_startino); xic->alloc =xfs_inobt_irec_to_allocmask (&rec);/*
@@ -2028,7 +2022,7 @@ xfs_difree_inobt( goto error0; } -xfs_difree_inode_chunk (tp, agno, &rec); +xfs_difree_inode_chunk (tp, pag->pag_agno, &rec); }else { xic->deleted = false;
@@ -2044,7 +2038,7 @@ xfs_difree_inobt(*/ be32_add_cpu (&agi->agi_freecount,1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount++; + pag->pagi_freecount++;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,1 ); }
@@ -2069,18 +2063,18 @@ xfs_difree_finobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_inobt_rec_incore *ibtrec) /* inobt record */ { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int offset = agino - ibtrec->ir_startino;int error;int i; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_inobt_lookup (cur, ibtrec->ir_startino,XFS_LOOKUP_EQ , &i);if (error)
@@ -2188,16 +2182,15 @@ xfs_difree(xfs_agino_t agino;/* allocation group inode number */ xfs_agnumber_t agno;/* allocation group number */ int error;/* error return value */ -struct xfs_mount *mp;/* mount structure for filesystem */ +struct xfs_mount *mp = tp->t_mountp;struct xfs_inobt_rec_incore rec;/* btree record */ - - mp = tp->t_mountp; +struct xfs_perag *pag;/* * Break up inode number into its components. */ agno =XFS_INO_TO_AGNO (mp, inode); -if (agno >= mp->m_sb.sb_agcount) { +if (agno >= mp->m_sb.sb_agcount) {xfs_warn (mp,"%s: agno >= mp->m_sb.sb_agcount (%d >= %d)." , __func__, agno, mp->m_sb.sb_agcount);ASSERT (0 );
@@ -2231,7 +2224,8 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - error =xfs_difree_inobt (mp, tp, agbp, agino, xic, &rec); + pag = agbp->b_pag; + error =xfs_difree_inobt (mp, tp, agbp, pag, agino, xic, &rec);if (error) goto error0;
@@ -2239,7 +2233,7 @@ xfs_difree(* Fix up the free inode btree. */ if (xfs_sb_version_hasfinobt (&mp->m_sb)) { - error =xfs_difree_finobt (mp, tp, agbp, agino, &rec); + error =xfs_difree_finobt (mp, tp, agbp, pag, agino, &rec);if (error) goto error0; }
@@ -2254,7 +2248,7 @@ STATIC intxfs_imap_lookup ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_agino_t agino, xfs_agblock_t agbno, xfs_agblock_t *chunk_agbno,
@@ -2267,11 +2261,11 @@ xfs_imap_lookup(int error;int i; - error =xfs_ialloc_read_agi (mp, tp, agno, &agbp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, &agbp);if (error) {xfs_alert (mp,"%s: xfs_ialloc_read_agi() returned error %d, agno %d" , - __func__, error, agno); + __func__, error, pag->pag_agno);return error; }
@@ -2281,7 +2275,7 @@ xfs_imap_lookup(* we have a record, we need to ensure it contains the inode number * we are looking up. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_inobt_lookup (cur, agino,XFS_LOOKUP_LE , &i);if (!error) {if (i)
@@ -2315,42 +2309,44 @@ xfs_imap_lookup(*/ int xfs_imap ( -xfs_mount_t *mp,/* file system mount structure */ -xfs_trans_t *tp,/* transaction pointer */ -xfs_ino_t ino,/* inode to locate */ -struct xfs_imap *imap,/* location map structure */ -uint flags)/* flags for inode btree lookup */ +struct xfs_mount *mp,/* file system mount structure */ +struct xfs_trans *tp,/* transaction pointer */ +xfs_ino_t ino,/* inode to locate */ +struct xfs_imap *imap,/* location map structure */ +uint flags)/* flags for inode btree lookup */ { -xfs_agblock_t agbno;/* block number of inode in the alloc group */ -xfs_agino_t agino;/* inode number within alloc group */ -xfs_agnumber_t agno;/* allocation group number */ -xfs_agblock_t chunk_agbno;/* first block in inode chunk */ -xfs_agblock_t cluster_agbno;/* first block in inode cluster */ -int error;/* error code */ -int offset;/* index of inode in its buffer */ -xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +xfs_agblock_t agbno;/* block number of inode in the alloc group */ +xfs_agino_t agino;/* inode number within alloc group */ +xfs_agblock_t chunk_agbno;/* first block in inode chunk */ +xfs_agblock_t cluster_agbno;/* first block in inode cluster */ +int error;/* error code */ +int offset;/* index of inode in its buffer */ +xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +struct xfs_perag *pag;ASSERT (ino !=NULLFSINO );/* * Split up the inode number into its parts. */ - agno =XFS_INO_TO_AGNO (mp, ino); + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ino)); agino =XFS_INO_TO_AGINO (mp, ino); agbno =XFS_AGINO_TO_AGBNO (mp, agino); -if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || - ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (!pag || agbno >= mp->m_sb.sb_agblocks || + ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) { + error = -EINVAL ;#ifdef DEBUG /* * Don't output diagnostic information for untrusted inodes * as they can be invalid without implying corruption. */ if (flags &XFS_IGET_UNTRUSTED ) -return -EINVAL ; -if (agno >= mp->m_sb.sb_agcount) { + goto out_drop; +if (!pag) {xfs_alert (mp,"%s: agno (%d) >= mp->m_sb.sb_agcount (%d)" , - __func__, agno, mp->m_sb.sb_agcount); + __func__,XFS_INO_TO_AGNO (mp, ino), + mp->m_sb.sb_agcount); }if (agbno >= mp->m_sb.sb_agblocks) { xfs_alert(mp,
@@ -2358,15 +2354,15 @@ xfs_imap( __func__, (unsigned long long )agbno, (unsigned long)mp->m_sb.sb_agblocks); } -if (ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (pag && ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) {xfs_alert (mp,"%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)" , __func__, ino, -XFS_AGINO_TO_INO (mp, agno, agino)); +XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)); }xfs_stack_trace ();#endif /* DEBUG */ -return -EINVAL ; + goto out_drop; }/*
@@ -2377,10 +2373,10 @@ xfs_imap(* in all cases where an untrusted inode number is passed. */ if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; goto out_map; }
@@ -2392,11 +2388,12 @@ xfs_imap( offset =XFS_INO_TO_OFFSET (mp, ino);ASSERT (offset < mp->m_sb.sb_inopblock); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, agbno); imap->im_len =XFS_FSB_TO_BB (mp,1 ); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); -return 0 ; + error =0 ; + goto out_drop; }/*
@@ -2408,10 +2405,10 @@ xfs_imap( offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; chunk_agbno = agbno - offset_agbno; }else { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; } out_map:
@@ -2422,7 +2419,7 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, cluster_agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, 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);
@@ -2439,9 +2436,13 @@ xfs_imap( __func__, (unsigned long long ) imap->im_blkno, (unsigned long long ) imap->im_len, XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); -return -EINVAL ; + error = -EINVAL ; + goto out_drop; } -return 0 ; + error =0 ; +out_drop: +xfs_perag_put (pag); +return error; }/*
fs/xfs/libxfs/xfs_ialloc_btree.c +11 -16
@@ -35,8 +35,7 @@ xfs_inobt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_inobt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void
@@ -428,7 +427,6 @@ static struct xfs_btree_cur *xfs_inobt_init_common ( struct xfs_mount *mp, /* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* ialloc or free ino btree */ {
@@ -451,12 +449,10 @@ xfs_inobt_init_common(if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; - cur->bc_ag.agno = agno; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;return cur; }
@@ -466,14 +462,13 @@ xfs_inobt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur;struct xfs_agi *agi = agbp->b_addr; - cur =xfs_inobt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_inobt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_INO ) cur->bc_nlevels =be32_to_cpu (agi->agi_level);else
@@ -487,12 +482,12 @@ struct xfs_btree_cur *xfs_inobt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_inobt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_inobt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }
@@ -664,7 +659,7 @@ intxfs_inobt_cur ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t which, struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp)
@@ -675,11 +670,11 @@ xfs_inobt_cur(ASSERT (*agi_bpp ==NULL );ASSERT (*curpp ==NULL ); - error =xfs_ialloc_read_agi (mp, tp, agno, agi_bpp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, agi_bpp);if (error)return error; - cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, agno,NULL , which); + cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, pag, which); *curpp = cur;return 0 ; }
@@ -696,7 +691,7 @@ xfs_inobt_count_blocks(struct xfs_btree_cur *cur =NULL ;int error; - error =xfs_inobt_cur (mp, tp, pag->pag_agno, btnum, &cur, &agbp); + error =xfs_inobt_cur (mp, tp, pag, btnum, &cur, &agbp);if (error)return error;
fs/xfs/libxfs/xfs_ialloc_btree.h +3 -3
@@ -47,10 +47,10 @@ struct xfs_perag; ((index) - 1) * sizeof(xfs_inobt_ptr_t)))extern struct xfs_btree_cur *xfs_inobt_init_cursor (struct xfs_mount *mp, -struct xfs_trans *tp,struct xfs_buf *agbp,xfs_agnumber_t agno, +struct xfs_trans *tp,struct xfs_buf *agbp,struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_inobt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_inobt_maxrecs (struct xfs_mount *,int ,int );
@@ -69,7 +69,7 @@ int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,extern xfs_extlen_t xfs_iallocbt_calc_size (struct xfs_mount *mp,unsigned long long len);int xfs_inobt_cur (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_agnumber_t agno,xfs_btnum_t btnum, +struct xfs_perag *pag,xfs_btnum_t btnum,struct xfs_btree_cur **curpp,struct xfs_buf **agi_bpp); void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,
fs/xfs/scrub/agheader_repair.c +2 -2
@@ -806,7 +806,7 @@ xrep_agi_calc_from_btrees(xfs_agino_t freecount;int error; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_INO ); error =xfs_ialloc_count_inodes (cur, &count, &freecount);if (error)
@@ -828,7 +828,7 @@ xrep_agi_calc_from_btrees( xfs_sb_version_hasinobtcounts(&mp->m_sb)) {xfs_agblock_t blocks; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_FINO ); error =xfs_btree_count_blocks (cur, &blocks);if (error)
fs/xfs/scrub/common.c +2 -3
@@ -458,7 +458,6 @@ xchk_ag_btcur_init( struct xchk_ag *sa) {struct xfs_mount *mp = sc->mp; -xfs_agnumber_t agno = sa->agno;xchk_perag_get (sc->mp, sa); if (sa->agf_bp &&
@@ -479,14 +478,14 @@ xchk_ag_btcur_init(if (sa->agi_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_INO )) { sa->ino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_INO ); + sa->pag,XFS_BTNUM_INO ); }/* Set up a finobt cursor for cross-referencing. */ if (sa->agi_bp &&xfs_sb_version_hasfinobt (&mp->m_sb) &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_FINO )) { sa->fino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_FINO ); + sa->pag,XFS_BTNUM_FINO ); }/* Set up a rmapbt cursor for cross-referencing. */
fs/xfs/xfs_iwalk.c +2 -4
@@ -272,8 +272,7 @@ xfs_iwalk_ag_start(/* Set up a fresh cursor and empty the inobt cache. */ iwag->nr_recs =0 ; - error =xfs_inobt_cur (mp, tp, pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;
@@ -378,8 +377,7 @@ xfs_iwalk_run_callbacks(return 0 ;/* ...and recreate the cursor just past where we left off. */ - error =xfs_inobt_cur (mp, tp, iwag->pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, iwag->pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;
Signature · 1 line
2.31.1
Re: [PATCH 15/22] xfs: use perag for ialloc btree cursors
Quoted 4 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>---
Quoted 813 lines
fs/xfs/libxfs/xfs_ialloc.c | 177 ++++++++++++++++--------------- fs/xfs/libxfs/xfs_ialloc_btree.c | 27 ++--- fs/xfs/libxfs/xfs_ialloc_btree.h | 6 +- fs/xfs/scrub/agheader_repair.c | 4 +- fs/xfs/scrub/common.c | 5 +- fs/xfs/xfs_iwalk.c | 6 +- 6 files changed, 109 insertions(+), 116 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +89
-88@@ -172,18 +172,17 @@ xfs_inobt_insert(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t newino, xfs_agino_t newlen, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agino_t thisino;int i;int error; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum); for (thisino = newino; thisino < newino + newlen;@@ -520,18 +519,17 @@ xfs_inobt_insert_sprec(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, int btnum, struct xfs_inobt_rec_incore *nrec, /* in/out: new/merged rec. */ bool merge) /* merge or replace */ { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);int error;int i;struct xfs_inobt_rec_incore rec; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum);/* the new record is pre-aligned so we know where to look */ error =xfs_inobt_lookup (cur, nrec->ir_startino,XFS_LOOKUP_EQ , &i);@@ -578,14 +576,14 @@ xfs_inobt_insert_sprec( goto error; } -trace_xfs_irec_merge_pre (mp, agno, rec.ir_startino, +trace_xfs_irec_merge_pre (mp, pag->pag_agno, rec.ir_startino, rec.ir_holemask, nrec->ir_startino, nrec->ir_holemask);/* merge to nrec to output the updated record */ __xfs_inobt_rec_merge (nrec, &rec); -trace_xfs_irec_merge_post (mp, agno, nrec->ir_startino, +trace_xfs_irec_merge_post (mp, pag->pag_agno, nrec->ir_startino, nrec->ir_holemask); error =xfs_inobt_rec_check_count (mp, nrec);@@ -613,21 +611,20 @@ xfs_inobt_insert_sprec( STATIC intxfs_ialloc_ag_alloc (struct xfs_trans *tp, -struct xfs_buf *agbp) +struct xfs_buf *agbp, +struct xfs_perag *pag) {struct xfs_agi *agi;struct xfs_alloc_arg args; -xfs_agnumber_t agno;int error;xfs_agino_t newino;/* new first inode's number */ xfs_agino_t newlen;/* new number of inodes */ int isaligned =0 ;/* inode allocation at stripe */ /* unit boundary */ /* init. to full chunk */ -uint16_t allocmask = (uint16_t )-1 ;struct xfs_inobt_rec_incore rec; -struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (tp->t_mountp); +uint16_t allocmask = (uint16_t )-1 ;int do_sparse =0 ;memset (&args,0 ,sizeof (args));@@ -660,14 +657,13 @@ xfs_ialloc_ag_alloc(*/ agi = agbp->b_addr; newino =be32_to_cpu (agi->agi_newino); - agno =be32_to_cpu (agi->agi_seqno); args.agbno =XFS_AGINO_TO_AGBNO (args.mp, newino) + igeo->ialloc_blks;if (do_sparse) goto sparse_alloc;if (likely (newino !=NULLAGINO && (args.agbno <be32_to_cpu (agi->agi_length)))) { - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.type =XFS_ALLOCTYPE_THIS_BNO ; args.prod =1 ;@@ -727,7 +723,7 @@ xfs_ialloc_ag_alloc(* For now, just allocate blocks up front. */ args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno);/* * Allocate a fixed-size extent of inodes. */ @@ -748,7 +744,7 @@ xfs_ialloc_ag_alloc(if (isaligned && args.fsbno ==NULLFSBLOCK ) { args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = igeo->cluster_align;if ((error =xfs_alloc_vextent (&args)))return error;@@ -764,7 +760,7 @@ xfs_ialloc_ag_alloc( sparse_alloc: args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = args.mp->m_sb.sb_spino_align; args.prod =1 ;@@ -809,7 +805,7 @@ xfs_ialloc_ag_alloc(* rather than a linear progression to prevent the next generation * number from being easily guessable. */ - error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, agno, + error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, pag->pag_agno, args.agbno, args.len,prandom_u32 ());if (error)@@ -836,12 +832,12 @@ xfs_ialloc_ag_alloc(* if necessary. If a merge does occur, rec is updated to the * merged record. */ - error =xfs_inobt_insert_sprec (args.mp, tp, agbp,XFS_BTNUM_INO , - &rec, true); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_INO , &rec, true);if (error == -EFSCORRUPTED ) {xfs_alert (args.mp,"invalid sparse inode record: ino 0x%llx holemask 0x%x count %u" , -XFS_AGINO_TO_INO (args.mp, agno, +XFS_AGINO_TO_INO (args.mp, pag->pag_agno, rec.ir_startino), rec.ir_holemask, rec.ir_count);xfs_force_shutdown (args.mp,SHUTDOWN_CORRUPT_INCORE );@@ -861,21 +857,20 @@ xfs_ialloc_ag_alloc(* existing record with this one. */ if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert_sprec (args.mp, tp, agbp, -XFS_BTNUM_FINO , &rec, - false); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_FINO , &rec, false);if (error)return error; } }else {/* full chunk - insert new records to both btrees */ - error =xfs_inobt_insert (args.mp, tp, agbp, newino, newlen, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_INO );if (error)return error;if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert (args.mp, tp, agbp, newino, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_FINO );if (error)return error;@@ -887,7 +882,6 @@ xfs_ialloc_ag_alloc(*/ be32_add_cpu (&agi->agi_count, newlen);be32_add_cpu (&agi->agi_freecount, newlen); - pag = agbp->b_pag; pag->pagi_freecount += newlen; pag->pagi_count += newlen; agi->agi_newino =cpu_to_be32 (newino);@@ -1123,15 +1117,14 @@ STATIC intxfs_dialloc_ag_inobt ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) { struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent); -struct xfs_perag *pag = agbp->b_pag;struct xfs_btree_cur *cur, *tcur;struct xfs_inobt_rec_incore rec, trec;xfs_ino_t ino;@@ -1145,7 +1138,7 @@ xfs_dialloc_ag_inobt(ASSERT (pag->pagi_freecount >0 ); restart_pagno: - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO );/* * If pagino is 0 (this is the root inode allocation) use newino. * This must work because we've just allocated some. @@ -1160,7 +1153,7 @@ xfs_dialloc_ag_inobt(/* * If in the same AG as the parent, try to get near the parent. */ -if (pagno == agno) { +if (pagno == pag->pag_agno) {int doneleft;/* done, to the left */ int doneright;/* done, to the right */ @@ -1363,7 +1356,7 @@ xfs_dialloc_ag_inobt(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset); rec.ir_free &= ~XFS_INOBT_MASK (offset); rec.ir_freecount--; error =xfs_inobt_update (cur, &rec);@@ -1577,7 +1570,6 @@ xfs_dialloc_ag( {struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent);struct xfs_btree_cur *cur;/* finobt cursor */ @@ -1587,9 +1579,10 @@ xfs_dialloc_ag(int error;int offset;int i; +struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb)) -return xfs_dialloc_ag_inobt (tp, agbp, parent, inop); +return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);/* * If pagino is 0 (this is the root inode allocation) use newino. @@ -1598,7 +1591,7 @@ xfs_dialloc_ag(if (!pagino) pagino =be32_to_cpu (agi->agi_newino); - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_check_agi_freecount (cur, agi);if (error)@@ -1609,7 +1602,7 @@ xfs_dialloc_ag(* parent. If so, find the closest available inode to the parent. If * not, consider the agi hint or find the first free inode in the AG. */ -if (agno == pagno) +if (pag->pag_agno == pagno) error =xfs_dialloc_ag_finobt_near (pagino, &cur, &rec);else error =xfs_dialloc_ag_finobt_newino (agi, cur, &rec);@@ -1621,7 +1614,7 @@ xfs_dialloc_ag(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset);/* * Modify or remove the finobt record. @@ -1641,7 +1634,7 @@ xfs_dialloc_ag(* the original freecount. If all is well, make the equivalent update to * the inobt using the finobt record and offset information. */ - icur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + icur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (icur, agi);if (error)@@ -1657,7 +1650,7 @@ xfs_dialloc_ag(*/ be32_add_cpu (&agi->agi_freecount,-1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount--; + pag->pagi_freecount--;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,-1 );@@ -1809,7 +1802,7 @@ xfs_dialloc_select_ag(if (!okalloc) goto nextag_relse_buffer; - error =xfs_ialloc_ag_alloc (*tpp, agbp); + error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp);@@ -1935,12 +1928,12 @@ xfs_difree_inobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int ilen;@@ -1954,7 +1947,7 @@ xfs_difree_inobt(/* * Initialize the cursor. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (cur, agi);if (error)@@ -2005,7 +1998,8 @@ xfs_difree_inobt(struct xfs_perag *pag = agbp->b_pag; xic->deleted = true; - xic->first_ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino); + xic->first_ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, + rec.ir_startino); xic->alloc =xfs_inobt_irec_to_allocmask (&rec);/* @@ -2028,7 +2022,7 @@ xfs_difree_inobt( goto error0; } -xfs_difree_inode_chunk (tp, agno, &rec); +xfs_difree_inode_chunk (tp, pag->pag_agno, &rec); }else { xic->deleted = false;@@ -2044,7 +2038,7 @@ xfs_difree_inobt(*/ be32_add_cpu (&agi->agi_freecount,1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount++; + pag->pagi_freecount++;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,1 ); }@@ -2069,18 +2063,18 @@ xfs_difree_finobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_inobt_rec_incore *ibtrec) /* inobt record */ { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int offset = agino - ibtrec->ir_startino;int error;int i; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_inobt_lookup (cur, ibtrec->ir_startino,XFS_LOOKUP_EQ , &i);if (error)@@ -2188,16 +2182,15 @@ xfs_difree(xfs_agino_t agino;/* allocation group inode number */ xfs_agnumber_t agno;/* allocation group number */ int error;/* error return value */ -struct xfs_mount *mp;/* mount structure for filesystem */ +struct xfs_mount *mp = tp->t_mountp;struct xfs_inobt_rec_incore rec;/* btree record */ - - mp = tp->t_mountp; +struct xfs_perag *pag;/* * Break up inode number into its components. */ agno =XFS_INO_TO_AGNO (mp, inode); -if (agno >= mp->m_sb.sb_agcount) { +if (agno >= mp->m_sb.sb_agcount) {xfs_warn (mp,"%s: agno >= mp->m_sb.sb_agcount (%d >= %d)." , __func__, agno, mp->m_sb.sb_agcount);ASSERT (0 );@@ -2231,7 +2224,8 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - error =xfs_difree_inobt (mp, tp, agbp, agino, xic, &rec); + pag = agbp->b_pag; + error =xfs_difree_inobt (mp, tp, agbp, pag, agino, xic, &rec);if (error) goto error0;@@ -2239,7 +2233,7 @@ xfs_difree(* Fix up the free inode btree. */ if (xfs_sb_version_hasfinobt (&mp->m_sb)) { - error =xfs_difree_finobt (mp, tp, agbp, agino, &rec); + error =xfs_difree_finobt (mp, tp, agbp, pag, agino, &rec);if (error) goto error0; }@@ -2254,7 +2248,7 @@ STATIC intxfs_imap_lookup ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_agino_t agino, xfs_agblock_t agbno, xfs_agblock_t *chunk_agbno,@@ -2267,11 +2261,11 @@ xfs_imap_lookup(int error;int i; - error =xfs_ialloc_read_agi (mp, tp, agno, &agbp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, &agbp);if (error) {xfs_alert (mp,"%s: xfs_ialloc_read_agi() returned error %d, agno %d" , - __func__, error, agno); + __func__, error, pag->pag_agno);return error; }@@ -2281,7 +2275,7 @@ xfs_imap_lookup(* we have a record, we need to ensure it contains the inode number * we are looking up. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_inobt_lookup (cur, agino,XFS_LOOKUP_LE , &i);if (!error) {if (i)@@ -2315,42 +2309,44 @@ xfs_imap_lookup(*/ int xfs_imap ( -xfs_mount_t *mp,/* file system mount structure */ -xfs_trans_t *tp,/* transaction pointer */ -xfs_ino_t ino,/* inode to locate */ -struct xfs_imap *imap,/* location map structure */ -uint flags)/* flags for inode btree lookup */ +struct xfs_mount *mp,/* file system mount structure */ +struct xfs_trans *tp,/* transaction pointer */ +xfs_ino_t ino,/* inode to locate */ +struct xfs_imap *imap,/* location map structure */ +uint flags)/* flags for inode btree lookup */ { -xfs_agblock_t agbno;/* block number of inode in the alloc group */ -xfs_agino_t agino;/* inode number within alloc group */ -xfs_agnumber_t agno;/* allocation group number */ -xfs_agblock_t chunk_agbno;/* first block in inode chunk */ -xfs_agblock_t cluster_agbno;/* first block in inode cluster */ -int error;/* error code */ -int offset;/* index of inode in its buffer */ -xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +xfs_agblock_t agbno;/* block number of inode in the alloc group */ +xfs_agino_t agino;/* inode number within alloc group */ +xfs_agblock_t chunk_agbno;/* first block in inode chunk */ +xfs_agblock_t cluster_agbno;/* first block in inode cluster */ +int error;/* error code */ +int offset;/* index of inode in its buffer */ +xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +struct xfs_perag *pag;ASSERT (ino !=NULLFSINO );/* * Split up the inode number into its parts. */ - agno =XFS_INO_TO_AGNO (mp, ino); + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ino)); agino =XFS_INO_TO_AGINO (mp, ino); agbno =XFS_AGINO_TO_AGBNO (mp, agino); -if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || - ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (!pag || agbno >= mp->m_sb.sb_agblocks || + ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) { + error = -EINVAL ;#ifdef DEBUG /* * Don't output diagnostic information for untrusted inodes * as they can be invalid without implying corruption. */ if (flags &XFS_IGET_UNTRUSTED ) -return -EINVAL ; -if (agno >= mp->m_sb.sb_agcount) { + goto out_drop; +if (!pag) {xfs_alert (mp,"%s: agno (%d) >= mp->m_sb.sb_agcount (%d)" , - __func__, agno, mp->m_sb.sb_agcount); + __func__,XFS_INO_TO_AGNO (mp, ino), + mp->m_sb.sb_agcount); }if (agbno >= mp->m_sb.sb_agblocks) { xfs_alert(mp,@@ -2358,15 +2354,15 @@ xfs_imap( __func__, (unsigned long long )agbno, (unsigned long)mp->m_sb.sb_agblocks); } -if (ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (pag && ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) {xfs_alert (mp,"%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)" , __func__, ino, -XFS_AGINO_TO_INO (mp, agno, agino)); +XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)); }xfs_stack_trace ();#endif /* DEBUG */ -return -EINVAL ; + goto out_drop; }/* @@ -2377,10 +2373,10 @@ xfs_imap(* in all cases where an untrusted inode number is passed. */ if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; goto out_map; }@@ -2392,11 +2388,12 @@ xfs_imap( offset =XFS_INO_TO_OFFSET (mp, ino);ASSERT (offset < mp->m_sb.sb_inopblock); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, agbno); imap->im_len =XFS_FSB_TO_BB (mp,1 ); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); -return 0 ; + error =0 ; + goto out_drop; }/* @@ -2408,10 +2405,10 @@ xfs_imap( offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; chunk_agbno = agbno - offset_agbno; }else { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; } out_map:@@ -2422,7 +2419,7 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, cluster_agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, 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);@@ -2439,9 +2436,13 @@ xfs_imap( __func__, (unsigned long long ) imap->im_blkno, (unsigned long long ) imap->im_len, XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); -return -EINVAL ; + error = -EINVAL ; + goto out_drop; } -return 0 ; + error =0 ; +out_drop: +xfs_perag_put (pag); +return error; }/* fs/xfs/libxfs/xfs_ialloc_btree.c +11
-16@@ -35,8 +35,7 @@ xfs_inobt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_inobt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void@@ -428,7 +427,6 @@ static struct xfs_btree_cur *xfs_inobt_init_common ( struct xfs_mount *mp, /* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* ialloc or free ino btree */ {@@ -451,12 +449,10 @@ xfs_inobt_init_common(if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; - cur->bc_ag.agno = agno; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;return cur; }@@ -466,14 +462,13 @@ xfs_inobt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur;struct xfs_agi *agi = agbp->b_addr; - cur =xfs_inobt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_inobt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_INO ) cur->bc_nlevels =be32_to_cpu (agi->agi_level);else @@ -487,12 +482,12 @@ struct xfs_btree_cur *xfs_inobt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_inobt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_inobt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }@@ -664,7 +659,7 @@ intxfs_inobt_cur ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t which, struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp)@@ -675,11 +670,11 @@ xfs_inobt_cur(ASSERT (*agi_bpp ==NULL );ASSERT (*curpp ==NULL ); - error =xfs_ialloc_read_agi (mp, tp, agno, agi_bpp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, agi_bpp);if (error)return error; - cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, agno,NULL , which); + cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, pag, which); *curpp = cur;return 0 ; }@@ -696,7 +691,7 @@ xfs_inobt_count_blocks(struct xfs_btree_cur *cur =NULL ;int error; - error =xfs_inobt_cur (mp, tp, pag->pag_agno, btnum, &cur, &agbp); + error =xfs_inobt_cur (mp, tp, pag, btnum, &cur, &agbp);if (error)return error;fs/xfs/libxfs/xfs_ialloc_btree.h +3
-3@@ -47,10 +47,10 @@ struct xfs_perag; ((index) - 1) * sizeof(xfs_inobt_ptr_t)))extern struct xfs_btree_cur *xfs_inobt_init_cursor (struct xfs_mount *mp, -struct xfs_trans *tp,struct xfs_buf *agbp,xfs_agnumber_t agno, +struct xfs_trans *tp,struct xfs_buf *agbp,struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_inobt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_inobt_maxrecs (struct xfs_mount *,int ,int );@@ -69,7 +69,7 @@ int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,extern xfs_extlen_t xfs_iallocbt_calc_size (struct xfs_mount *mp,unsigned long long len);int xfs_inobt_cur (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_agnumber_t agno,xfs_btnum_t btnum, +struct xfs_perag *pag,xfs_btnum_t btnum,struct xfs_btree_cur **curpp,struct xfs_buf **agi_bpp); void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,fs/xfs/scrub/agheader_repair.c +2
-2@@ -806,7 +806,7 @@ xrep_agi_calc_from_btrees(xfs_agino_t freecount;int error; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_INO ); error =xfs_ialloc_count_inodes (cur, &count, &freecount);if (error)@@ -828,7 +828,7 @@ xrep_agi_calc_from_btrees( xfs_sb_version_hasinobtcounts(&mp->m_sb)) {xfs_agblock_t blocks; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_FINO ); error =xfs_btree_count_blocks (cur, &blocks);if (error)fs/xfs/scrub/common.c +2
-3@@ -458,7 +458,6 @@ xchk_ag_btcur_init( struct xchk_ag *sa) {struct xfs_mount *mp = sc->mp; -xfs_agnumber_t agno = sa->agno;xchk_perag_get (sc->mp, sa); if (sa->agf_bp &&@@ -479,14 +478,14 @@ xchk_ag_btcur_init(if (sa->agi_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_INO )) { sa->ino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_INO ); + sa->pag,XFS_BTNUM_INO ); }/* Set up a finobt cursor for cross-referencing. */ if (sa->agi_bp &&xfs_sb_version_hasfinobt (&mp->m_sb) &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_FINO )) { sa->fino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_FINO ); + sa->pag,XFS_BTNUM_FINO ); }/* Set up a rmapbt cursor for cross-referencing. */ fs/xfs/xfs_iwalk.c +2
-4@@ -272,8 +272,7 @@ xfs_iwalk_ag_start(/* Set up a fresh cursor and empty the inobt cache. */ iwag->nr_recs =0 ; - error =xfs_inobt_cur (mp, tp, pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;@@ -378,8 +377,7 @@ xfs_iwalk_run_callbacks(return 0 ;/* ...and recreate the cursor just past where we left off. */ - error =xfs_inobt_cur (mp, tp, iwag->pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, iwag->pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;Signature · 1 line
2.31.1
Re: [PATCH 15/22] xfs: use perag for ialloc btree cursors
In reply to Dave ChinnerQuoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Looks good...
--D
Quoted 814 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 177 ++++++++++++++++--------------- fs/xfs/libxfs/xfs_ialloc_btree.c | 27 ++--- fs/xfs/libxfs/xfs_ialloc_btree.h | 6 +- fs/xfs/scrub/agheader_repair.c | 4 +- fs/xfs/scrub/common.c | 5 +- fs/xfs/xfs_iwalk.c | 6 +- 6 files changed, 109 insertions(+), 116 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +89
-88@@ -172,18 +172,17 @@ xfs_inobt_insert(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t newino, xfs_agino_t newlen, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agino_t thisino;int i;int error; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum); for (thisino = newino; thisino < newino + newlen;@@ -520,18 +519,17 @@ xfs_inobt_insert_sprec(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, int btnum, struct xfs_inobt_rec_incore *nrec, /* in/out: new/merged rec. */ bool merge) /* merge or replace */ { struct xfs_btree_cur *cur; -struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);int error;int i;struct xfs_inobt_rec_incore rec; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL , btnum); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag, btnum);/* the new record is pre-aligned so we know where to look */ error =xfs_inobt_lookup (cur, nrec->ir_startino,XFS_LOOKUP_EQ , &i);@@ -578,14 +576,14 @@ xfs_inobt_insert_sprec( goto error; } -trace_xfs_irec_merge_pre (mp, agno, rec.ir_startino, +trace_xfs_irec_merge_pre (mp, pag->pag_agno, rec.ir_startino, rec.ir_holemask, nrec->ir_startino, nrec->ir_holemask);/* merge to nrec to output the updated record */ __xfs_inobt_rec_merge (nrec, &rec); -trace_xfs_irec_merge_post (mp, agno, nrec->ir_startino, +trace_xfs_irec_merge_post (mp, pag->pag_agno, nrec->ir_startino, nrec->ir_holemask); error =xfs_inobt_rec_check_count (mp, nrec);@@ -613,21 +611,20 @@ xfs_inobt_insert_sprec( STATIC intxfs_ialloc_ag_alloc (struct xfs_trans *tp, -struct xfs_buf *agbp) +struct xfs_buf *agbp, +struct xfs_perag *pag) {struct xfs_agi *agi;struct xfs_alloc_arg args; -xfs_agnumber_t agno;int error;xfs_agino_t newino;/* new first inode's number */ xfs_agino_t newlen;/* new number of inodes */ int isaligned =0 ;/* inode allocation at stripe */ /* unit boundary */ /* init. to full chunk */ -uint16_t allocmask = (uint16_t )-1 ;struct xfs_inobt_rec_incore rec; -struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (tp->t_mountp); +uint16_t allocmask = (uint16_t )-1 ;int do_sparse =0 ;memset (&args,0 ,sizeof (args));@@ -660,14 +657,13 @@ xfs_ialloc_ag_alloc(*/ agi = agbp->b_addr; newino =be32_to_cpu (agi->agi_newino); - agno =be32_to_cpu (agi->agi_seqno); args.agbno =XFS_AGINO_TO_AGBNO (args.mp, newino) + igeo->ialloc_blks;if (do_sparse) goto sparse_alloc;if (likely (newino !=NULLAGINO && (args.agbno <be32_to_cpu (agi->agi_length)))) { - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.type =XFS_ALLOCTYPE_THIS_BNO ; args.prod =1 ;@@ -727,7 +723,7 @@ xfs_ialloc_ag_alloc(* For now, just allocate blocks up front. */ args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno);/* * Allocate a fixed-size extent of inodes. */ @@ -748,7 +744,7 @@ xfs_ialloc_ag_alloc(if (isaligned && args.fsbno ==NULLFSBLOCK ) { args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = igeo->cluster_align;if ((error =xfs_alloc_vextent (&args)))return error;@@ -764,7 +760,7 @@ xfs_ialloc_ag_alloc( sparse_alloc: args.type =XFS_ALLOCTYPE_NEAR_BNO ; args.agbno =be32_to_cpu (agi->agi_root); - args.fsbno =XFS_AGB_TO_FSB (args.mp, agno, args.agbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, pag->pag_agno, args.agbno); args.alignment = args.mp->m_sb.sb_spino_align; args.prod =1 ;@@ -809,7 +805,7 @@ xfs_ialloc_ag_alloc(* rather than a linear progression to prevent the next generation * number from being easily guessable. */ - error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, agno, + error =xfs_ialloc_inode_init (args.mp, tp,NULL , newlen, pag->pag_agno, args.agbno, args.len,prandom_u32 ());if (error)@@ -836,12 +832,12 @@ xfs_ialloc_ag_alloc(* if necessary. If a merge does occur, rec is updated to the * merged record. */ - error =xfs_inobt_insert_sprec (args.mp, tp, agbp,XFS_BTNUM_INO , - &rec, true); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_INO , &rec, true);if (error == -EFSCORRUPTED ) {xfs_alert (args.mp,"invalid sparse inode record: ino 0x%llx holemask 0x%x count %u" , -XFS_AGINO_TO_INO (args.mp, agno, +XFS_AGINO_TO_INO (args.mp, pag->pag_agno, rec.ir_startino), rec.ir_holemask, rec.ir_count);xfs_force_shutdown (args.mp,SHUTDOWN_CORRUPT_INCORE );@@ -861,21 +857,20 @@ xfs_ialloc_ag_alloc(* existing record with this one. */ if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert_sprec (args.mp, tp, agbp, -XFS_BTNUM_FINO , &rec, - false); + error =xfs_inobt_insert_sprec (args.mp, tp, agbp, pag, +XFS_BTNUM_FINO , &rec, false);if (error)return error; } }else {/* full chunk - insert new records to both btrees */ - error =xfs_inobt_insert (args.mp, tp, agbp, newino, newlen, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_INO );if (error)return error;if (xfs_sb_version_hasfinobt (&args.mp->m_sb)) { - error =xfs_inobt_insert (args.mp, tp, agbp, newino, + error =xfs_inobt_insert (args.mp, tp, agbp, pag, newino, newlen,XFS_BTNUM_FINO );if (error)return error;@@ -887,7 +882,6 @@ xfs_ialloc_ag_alloc(*/ be32_add_cpu (&agi->agi_count, newlen);be32_add_cpu (&agi->agi_freecount, newlen); - pag = agbp->b_pag; pag->pagi_freecount += newlen; pag->pagi_count += newlen; agi->agi_newino =cpu_to_be32 (newino);@@ -1123,15 +1117,14 @@ STATIC intxfs_dialloc_ag_inobt ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) { struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent); -struct xfs_perag *pag = agbp->b_pag;struct xfs_btree_cur *cur, *tcur;struct xfs_inobt_rec_incore rec, trec;xfs_ino_t ino;@@ -1145,7 +1138,7 @@ xfs_dialloc_ag_inobt(ASSERT (pag->pagi_freecount >0 ); restart_pagno: - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO );/* * If pagino is 0 (this is the root inode allocation) use newino. * This must work because we've just allocated some. @@ -1160,7 +1153,7 @@ xfs_dialloc_ag_inobt(/* * If in the same AG as the parent, try to get near the parent. */ -if (pagno == agno) { +if (pagno == pag->pag_agno) {int doneleft;/* done, to the left */ int doneright;/* done, to the right */ @@ -1363,7 +1356,7 @@ xfs_dialloc_ag_inobt(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset); rec.ir_free &= ~XFS_INOBT_MASK (offset); rec.ir_freecount--; error =xfs_inobt_update (cur, &rec);@@ -1577,7 +1570,6 @@ xfs_dialloc_ag( {struct xfs_mount *mp = tp->t_mountp;struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);xfs_agnumber_t pagno =XFS_INO_TO_AGNO (mp, parent);xfs_agino_t pagino =XFS_INO_TO_AGINO (mp, parent);struct xfs_btree_cur *cur;/* finobt cursor */ @@ -1587,9 +1579,10 @@ xfs_dialloc_ag(int error;int offset;int i; +struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb)) -return xfs_dialloc_ag_inobt (tp, agbp, parent, inop); +return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);/* * If pagino is 0 (this is the root inode allocation) use newino. @@ -1598,7 +1591,7 @@ xfs_dialloc_ag(if (!pagino) pagino =be32_to_cpu (agi->agi_newino); - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_check_agi_freecount (cur, agi);if (error)@@ -1609,7 +1602,7 @@ xfs_dialloc_ag(* parent. If so, find the closest available inode to the parent. If * not, consider the agi hint or find the first free inode in the AG. */ -if (agno == pagno) +if (pag->pag_agno == pagno) error =xfs_dialloc_ag_finobt_near (pagino, &cur, &rec);else error =xfs_dialloc_ag_finobt_newino (agi, cur, &rec);@@ -1621,7 +1614,7 @@ xfs_dialloc_ag(ASSERT (offset <XFS_INODES_PER_CHUNK );ASSERT ((XFS_AGINO_TO_OFFSET (mp, rec.ir_startino) %XFS_INODES_PER_CHUNK ) ==0 ); - ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino + offset); + ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, rec.ir_startino + offset);/* * Modify or remove the finobt record. @@ -1641,7 +1634,7 @@ xfs_dialloc_ag(* the original freecount. If all is well, make the equivalent update to * the inobt using the finobt record and offset information. */ - icur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + icur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (icur, agi);if (error)@@ -1657,7 +1650,7 @@ xfs_dialloc_ag(*/ be32_add_cpu (&agi->agi_freecount,-1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount--; + pag->pagi_freecount--;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,-1 );@@ -1809,7 +1802,7 @@ xfs_dialloc_select_ag(if (!okalloc) goto nextag_relse_buffer; - error =xfs_ialloc_ag_alloc (*tpp, agbp); + error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp);@@ -1935,12 +1928,12 @@ xfs_difree_inobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int ilen;@@ -1954,7 +1947,7 @@ xfs_difree_inobt(/* * Initialize the cursor. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_check_agi_freecount (cur, agi);if (error)@@ -2005,7 +1998,8 @@ xfs_difree_inobt(struct xfs_perag *pag = agbp->b_pag; xic->deleted = true; - xic->first_ino =XFS_AGINO_TO_INO (mp, agno, rec.ir_startino); + xic->first_ino =XFS_AGINO_TO_INO (mp, pag->pag_agno, + rec.ir_startino); xic->alloc =xfs_inobt_irec_to_allocmask (&rec);/* @@ -2028,7 +2022,7 @@ xfs_difree_inobt( goto error0; } -xfs_difree_inode_chunk (tp, agno, &rec); +xfs_difree_inode_chunk (tp, pag->pag_agno, &rec); }else { xic->deleted = false;@@ -2044,7 +2038,7 @@ xfs_difree_inobt(*/ be32_add_cpu (&agi->agi_freecount,1 );xfs_ialloc_log_agi (tp, agbp,XFS_AGI_FREECOUNT ); - agbp->b_pag->pagi_freecount++; + pag->pagi_freecount++;xfs_trans_mod_sb (tp,XFS_TRANS_SB_IFREE ,1 ); }@@ -2069,18 +2063,18 @@ xfs_difree_finobt(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_inobt_rec_incore *ibtrec) /* inobt record */ { struct xfs_agi *agi = agbp->b_addr; -xfs_agnumber_t agno =be32_to_cpu (agi->agi_seqno);struct xfs_btree_cur *cur;struct xfs_inobt_rec_incore rec;int offset = agino - ibtrec->ir_startino;int error;int i; - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_FINO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_FINO ); error =xfs_inobt_lookup (cur, ibtrec->ir_startino,XFS_LOOKUP_EQ , &i);if (error)@@ -2188,16 +2182,15 @@ xfs_difree(xfs_agino_t agino;/* allocation group inode number */ xfs_agnumber_t agno;/* allocation group number */ int error;/* error return value */ -struct xfs_mount *mp;/* mount structure for filesystem */ +struct xfs_mount *mp = tp->t_mountp;struct xfs_inobt_rec_incore rec;/* btree record */ - - mp = tp->t_mountp; +struct xfs_perag *pag;/* * Break up inode number into its components. */ agno =XFS_INO_TO_AGNO (mp, inode); -if (agno >= mp->m_sb.sb_agcount) { +if (agno >= mp->m_sb.sb_agcount) {xfs_warn (mp,"%s: agno >= mp->m_sb.sb_agcount (%d >= %d)." , __func__, agno, mp->m_sb.sb_agcount);ASSERT (0 );@@ -2231,7 +2224,8 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - error =xfs_difree_inobt (mp, tp, agbp, agino, xic, &rec); + pag = agbp->b_pag; + error =xfs_difree_inobt (mp, tp, agbp, pag, agino, xic, &rec);if (error) goto error0;@@ -2239,7 +2233,7 @@ xfs_difree(* Fix up the free inode btree. */ if (xfs_sb_version_hasfinobt (&mp->m_sb)) { - error =xfs_difree_finobt (mp, tp, agbp, agino, &rec); + error =xfs_difree_finobt (mp, tp, agbp, pag, agino, &rec);if (error) goto error0; }@@ -2254,7 +2248,7 @@ STATIC intxfs_imap_lookup ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_agino_t agino, xfs_agblock_t agbno, xfs_agblock_t *chunk_agbno,@@ -2267,11 +2261,11 @@ xfs_imap_lookup(int error;int i; - error =xfs_ialloc_read_agi (mp, tp, agno, &agbp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, &agbp);if (error) {xfs_alert (mp,"%s: xfs_ialloc_read_agi() returned error %d, agno %d" , - __func__, error, agno); + __func__, error, pag->pag_agno);return error; }@@ -2281,7 +2275,7 @@ xfs_imap_lookup(* we have a record, we need to ensure it contains the inode number * we are looking up. */ - cur =xfs_inobt_init_cursor (mp, tp, agbp, agno,NULL ,XFS_BTNUM_INO ); + cur =xfs_inobt_init_cursor (mp, tp, agbp, pag,XFS_BTNUM_INO ); error =xfs_inobt_lookup (cur, agino,XFS_LOOKUP_LE , &i);if (!error) {if (i)@@ -2315,42 +2309,44 @@ xfs_imap_lookup(*/ int xfs_imap ( -xfs_mount_t *mp,/* file system mount structure */ -xfs_trans_t *tp,/* transaction pointer */ -xfs_ino_t ino,/* inode to locate */ -struct xfs_imap *imap,/* location map structure */ -uint flags)/* flags for inode btree lookup */ +struct xfs_mount *mp,/* file system mount structure */ +struct xfs_trans *tp,/* transaction pointer */ +xfs_ino_t ino,/* inode to locate */ +struct xfs_imap *imap,/* location map structure */ +uint flags)/* flags for inode btree lookup */ { -xfs_agblock_t agbno;/* block number of inode in the alloc group */ -xfs_agino_t agino;/* inode number within alloc group */ -xfs_agnumber_t agno;/* allocation group number */ -xfs_agblock_t chunk_agbno;/* first block in inode chunk */ -xfs_agblock_t cluster_agbno;/* first block in inode cluster */ -int error;/* error code */ -int offset;/* index of inode in its buffer */ -xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +xfs_agblock_t agbno;/* block number of inode in the alloc group */ +xfs_agino_t agino;/* inode number within alloc group */ +xfs_agblock_t chunk_agbno;/* first block in inode chunk */ +xfs_agblock_t cluster_agbno;/* first block in inode cluster */ +int error;/* error code */ +int offset;/* index of inode in its buffer */ +xfs_agblock_t offset_agbno;/* blks from chunk start to inode */ +struct xfs_perag *pag;ASSERT (ino !=NULLFSINO );/* * Split up the inode number into its parts. */ - agno =XFS_INO_TO_AGNO (mp, ino); + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ino)); agino =XFS_INO_TO_AGINO (mp, ino); agbno =XFS_AGINO_TO_AGBNO (mp, agino); -if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || - ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (!pag || agbno >= mp->m_sb.sb_agblocks || + ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) { + error = -EINVAL ;#ifdef DEBUG /* * Don't output diagnostic information for untrusted inodes * as they can be invalid without implying corruption. */ if (flags &XFS_IGET_UNTRUSTED ) -return -EINVAL ; -if (agno >= mp->m_sb.sb_agcount) { + goto out_drop; +if (!pag) {xfs_alert (mp,"%s: agno (%d) >= mp->m_sb.sb_agcount (%d)" , - __func__, agno, mp->m_sb.sb_agcount); + __func__,XFS_INO_TO_AGNO (mp, ino), + mp->m_sb.sb_agcount); }if (agbno >= mp->m_sb.sb_agblocks) { xfs_alert(mp,@@ -2358,15 +2354,15 @@ xfs_imap( __func__, (unsigned long long )agbno, (unsigned long)mp->m_sb.sb_agblocks); } -if (ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (pag && ino !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) {xfs_alert (mp,"%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)" , __func__, ino, -XFS_AGINO_TO_INO (mp, agno, agino)); +XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)); }xfs_stack_trace ();#endif /* DEBUG */ -return -EINVAL ; + goto out_drop; }/* @@ -2377,10 +2373,10 @@ xfs_imap(* in all cases where an untrusted inode number is passed. */ if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; goto out_map; }@@ -2392,11 +2388,12 @@ xfs_imap( offset =XFS_INO_TO_OFFSET (mp, ino);ASSERT (offset < mp->m_sb.sb_inopblock); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, agbno); imap->im_len =XFS_FSB_TO_BB (mp,1 ); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); -return 0 ; + error =0 ; + goto out_drop; }/* @@ -2408,10 +2405,10 @@ xfs_imap( offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; chunk_agbno = agbno - offset_agbno; }else { - error =xfs_imap_lookup (mp, tp, agno, agino, agbno, + error =xfs_imap_lookup (mp, tp, pag, agino, agbno, &chunk_agbno, &offset_agbno, flags);if (error) -return error; + goto out_drop; } out_map:@@ -2422,7 +2419,7 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - imap->im_blkno =XFS_AGB_TO_DADDR (mp, agno, cluster_agbno); + imap->im_blkno =XFS_AGB_TO_DADDR (mp, pag->pag_agno, 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);@@ -2439,9 +2436,13 @@ xfs_imap( __func__, (unsigned long long ) imap->im_blkno, (unsigned long long ) imap->im_len, XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); -return -EINVAL ; + error = -EINVAL ; + goto out_drop; } -return 0 ; + error =0 ; +out_drop: +xfs_perag_put (pag); +return error; }/* fs/xfs/libxfs/xfs_ialloc_btree.c +11
-16@@ -35,8 +35,7 @@ xfs_inobt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_inobt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.agno, - cur->bc_ag.pag, cur->bc_btnum); + cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); }STATIC void@@ -428,7 +427,6 @@ static struct xfs_btree_cur *xfs_inobt_init_common ( struct xfs_mount *mp, /* file system mount point */ struct xfs_trans *tp, /* transaction pointer */ - xfs_agnumber_t agno, /* allocation group number */ struct xfs_perag *pag, xfs_btnum_t btnum) /* ialloc or free ino btree */ {@@ -451,12 +449,10 @@ xfs_inobt_init_common(if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; - cur->bc_ag.agno = agno; -if (pag) { -/* take a reference for the cursor */ -atomic_inc (&pag->pag_ref); - } +/* take a reference for the cursor */ +atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; + cur->bc_ag.agno = pag->pag_agno;return cur; }@@ -466,14 +462,13 @@ xfs_inobt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur;struct xfs_agi *agi = agbp->b_addr; - cur =xfs_inobt_init_common (mp, tp, agno, pag, btnum); + cur =xfs_inobt_init_common (mp, tp, pag, btnum);if (btnum ==XFS_BTNUM_INO ) cur->bc_nlevels =be32_to_cpu (agi->agi_level);else @@ -487,12 +482,12 @@ struct xfs_btree_cur *xfs_inobt_stage_cursor ( struct xfs_mount *mp, struct xbtree_afakeroot *afake, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t btnum) { struct xfs_btree_cur *cur; - cur =xfs_inobt_init_common (mp,NULL , agno,NULL , btnum); + cur =xfs_inobt_init_common (mp,NULL , pag, btnum);xfs_btree_stage_afakeroot (cur, afake);return cur; }@@ -664,7 +659,7 @@ intxfs_inobt_cur ( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_btnum_t which, struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp)@@ -675,11 +670,11 @@ xfs_inobt_cur(ASSERT (*agi_bpp ==NULL );ASSERT (*curpp ==NULL ); - error =xfs_ialloc_read_agi (mp, tp, agno, agi_bpp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, agi_bpp);if (error)return error; - cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, agno,NULL , which); + cur =xfs_inobt_init_cursor (mp, tp, *agi_bpp, pag, which); *curpp = cur;return 0 ; }@@ -696,7 +691,7 @@ xfs_inobt_count_blocks(struct xfs_btree_cur *cur =NULL ;int error; - error =xfs_inobt_cur (mp, tp, pag->pag_agno, btnum, &cur, &agbp); + error =xfs_inobt_cur (mp, tp, pag, btnum, &cur, &agbp);if (error)return error;fs/xfs/libxfs/xfs_ialloc_btree.h +3
-3@@ -47,10 +47,10 @@ struct xfs_perag; ((index) - 1) * sizeof(xfs_inobt_ptr_t)))extern struct xfs_btree_cur *xfs_inobt_init_cursor (struct xfs_mount *mp, -struct xfs_trans *tp,struct xfs_buf *agbp,xfs_agnumber_t agno, +struct xfs_trans *tp,struct xfs_buf *agbp,struct xfs_perag *pag,xfs_btnum_t btnum);struct xfs_btree_cur *xfs_inobt_stage_cursor (struct xfs_mount *mp, -struct xbtree_afakeroot *afake,xfs_agnumber_t agno, +struct xbtree_afakeroot *afake,struct xfs_perag *pag,xfs_btnum_t btnum);extern int xfs_inobt_maxrecs (struct xfs_mount *,int ,int );@@ -69,7 +69,7 @@ int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,extern xfs_extlen_t xfs_iallocbt_calc_size (struct xfs_mount *mp,unsigned long long len);int xfs_inobt_cur (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_agnumber_t agno,xfs_btnum_t btnum, +struct xfs_perag *pag,xfs_btnum_t btnum,struct xfs_btree_cur **curpp,struct xfs_buf **agi_bpp); void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,fs/xfs/scrub/agheader_repair.c +2
-2@@ -806,7 +806,7 @@ xrep_agi_calc_from_btrees(xfs_agino_t freecount;int error; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_INO ); error =xfs_ialloc_count_inodes (cur, &count, &freecount);if (error)@@ -828,7 +828,7 @@ xrep_agi_calc_from_btrees( xfs_sb_version_hasinobtcounts(&mp->m_sb)) {xfs_agblock_t blocks; - cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.agno, + cur =xfs_inobt_init_cursor (mp, sc->tp, agi_bp, sc->sa.pag,XFS_BTNUM_FINO ); error =xfs_btree_count_blocks (cur, &blocks);if (error)fs/xfs/scrub/common.c +2
-3@@ -458,7 +458,6 @@ xchk_ag_btcur_init( struct xchk_ag *sa) {struct xfs_mount *mp = sc->mp; -xfs_agnumber_t agno = sa->agno;xchk_perag_get (sc->mp, sa); if (sa->agf_bp &&@@ -479,14 +478,14 @@ xchk_ag_btcur_init(if (sa->agi_bp &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_INO )) { sa->ino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_INO ); + sa->pag,XFS_BTNUM_INO ); }/* Set up a finobt cursor for cross-referencing. */ if (sa->agi_bp &&xfs_sb_version_hasfinobt (&mp->m_sb) &&xchk_ag_btree_healthy_enough (sc, sa->pag,XFS_BTNUM_FINO )) { sa->fino_cur =xfs_inobt_init_cursor (mp, sc->tp, sa->agi_bp, - agno, sa->pag,XFS_BTNUM_FINO ); + sa->pag,XFS_BTNUM_FINO ); }/* Set up a rmapbt cursor for cross-referencing. */ fs/xfs/xfs_iwalk.c +2
-4@@ -272,8 +272,7 @@ xfs_iwalk_ag_start(/* Set up a fresh cursor and empty the inobt cache. */ iwag->nr_recs =0 ; - error =xfs_inobt_cur (mp, tp, pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;@@ -378,8 +377,7 @@ xfs_iwalk_run_callbacks(return 0 ;/* ...and recreate the cursor just past where we left off. */ - error =xfs_inobt_cur (mp, tp, iwag->pag->pag_agno,XFS_BTNUM_INO , - curpp, agi_bpp); + error =xfs_inobt_cur (mp, tp, iwag->pag,XFS_BTNUM_INO , curpp, agi_bpp);if (error)return error;Signature · 1 line
2.31.1
PATCH 16/22 xfs: remove agno from btree cursor
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Now that everything passes a perag, the agno is not needed anymore. Convert all the users to use pag->pag_agno instead and remove the agno from the cursor. This was largely done as an automated search and replace.
--- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_alloc_btree.c | 1 - fs/xfs/libxfs/xfs_btree.c | 12 ++-- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_ialloc_btree.c | 7 +- fs/xfs/libxfs/xfs_refcount.c | 82 +++++++++++----------- fs/xfs/libxfs/xfs_refcount_btree.c | 11 ++- fs/xfs/libxfs/xfs_rmap.c | 108 ++++++++++++++--------------- fs/xfs/libxfs/xfs_rmap_btree.c | 1 - fs/xfs/scrub/agheader_repair.c | 2 +- fs/xfs/scrub/alloc.c | 3 +- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/ialloc.c | 9 +-- fs/xfs/scrub/refcount.c | 3 +- fs/xfs/scrub/rmap.c | 3 +- fs/xfs/scrub/trace.c | 3 +- fs/xfs/xfs_fsmap.c | 4 +- fs/xfs/xfs_trace.h | 4 +- 19 files changed, 130 insertions(+), 130 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
@@ -230,7 +230,7 @@ xfs_alloc_get_rec( int *stat) /* output: success/failure */ {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;
fs/xfs/libxfs/xfs_alloc_btree.c +0 -1
@@ -497,7 +497,6 @@ xfs_allocbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ;
fs/xfs/libxfs/xfs_btree.c +6 -6
@@ -216,7 +216,7 @@ xfs_btree_check_sptr( {if (level <=0 )return false; -return xfs_verify_agbno (cur->bc_mp, cur->bc_ag.agno, agbno); +return xfs_verify_agbno (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno); }/*
@@ -245,7 +245,7 @@ xfs_btree_check_ptr(return 0 ;xfs_err (cur->bc_mp,"AG %u: Corrupt btree %d pointer at level %d index %d." , - cur->bc_ag.agno, cur->bc_btnum, + cur->bc_ag.pag->pag_agno, cur->bc_btnum, level, index); }
@@ -888,13 +888,13 @@ xfs_btree_readahead_sblock(if ((lr &XFS_BTCUR_LEFTRA ) && left !=NULLAGBLOCK ) { -xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.agno, +xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.pag->pag_agno, left,1 , cur->bc_ops->buf_ops); rval++; }if ((lr &XFS_BTCUR_RIGHTRA ) && right !=NULLAGBLOCK ) { -xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.agno, +xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.pag->pag_agno, right,1 , cur->bc_ops->buf_ops); rval++; }
@@ -952,7 +952,7 @@ xfs_btree_ptr_to_daddr( *daddr =XFS_FSB_TO_DADDR (cur->bc_mp, fsbno); }else { agbno =be32_to_cpu (ptr->s); - *daddr =XFS_AGB_TO_DADDR (cur->bc_mp, cur->bc_ag.agno, + *daddr =XFS_AGB_TO_DADDR (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno); }
@@ -1153,7 +1153,7 @@ xfs_btree_init_block_cur(if (cur->bc_flags &XFS_BTREE_LONG_PTRS ) owner = cur->bc_ino.ip->i_ino;else - owner = cur->bc_ag.agno; + owner = cur->bc_ag.pag->pag_agno; xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, cur->bc_btnum, level, numrecs,
fs/xfs/libxfs/xfs_btree.h +0 -1
@@ -181,7 +181,6 @@ union xfs_btree_irec {/* Per-AG btree information. */ struct xfs_btree_cur_ag { -xfs_agnumber_t agno;struct xfs_perag *pag;union {struct xfs_buf *agbp;
fs/xfs/libxfs/xfs_ialloc.c +1 -1
@@ -105,7 +105,7 @@ xfs_inobt_get_rec( int *stat) {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;uint64_t realfree;
fs/xfs/libxfs/xfs_ialloc_btree.c +3 -4
@@ -102,7 +102,7 @@ __xfs_inobt_alloc_block( args.tp = cur->bc_tp; args.mp = cur->bc_mp; args.oinfo =XFS_RMAP_OINFO_INOBT ; - args.fsbno =XFS_AGB_TO_FSB (args.mp, cur->bc_ag.agno, sbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, cur->bc_ag.pag->pag_agno, sbno); args.minlen =1 ; args.maxlen =1 ; args.prod =1 ;
@@ -235,7 +235,7 @@ xfs_inobt_init_ptr_from_cur( {struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agi->agi_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agi->agi_seqno)); ptr->s = agi->agi_root; }
@@ -247,7 +247,7 @@ xfs_finobt_init_ptr_from_cur( {struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agi->agi_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agi->agi_seqno)); ptr->s = agi->agi_free_root; }
@@ -452,7 +452,6 @@ xfs_inobt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;return cur; }
fs/xfs/libxfs/xfs_refcount.c +41 -41
320 lines not on this page · raw message
fs/xfs/libxfs/xfs_refcount_btree.c +5 -6
@@ -65,7 +65,7 @@ xfs_refcountbt_alloc_block( args.tp = cur->bc_tp; args.mp = cur->bc_mp; args.type =XFS_ALLOCTYPE_NEAR_BNO ; - args.fsbno =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno, + args.fsbno =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno,xfs_refc_block (args.mp)); args.oinfo =XFS_RMAP_OINFO_REFC ; args.minlen = args.maxlen = args.prod =1 ;
@@ -74,13 +74,13 @@ xfs_refcountbt_alloc_block( error =xfs_alloc_vextent (&args);if (error) goto out_error; -trace_xfs_refcountbt_alloc_block (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcountbt_alloc_block (cur->bc_mp, cur->bc_ag.pag->pag_agno, args.agbno,1 );if (args.fsbno ==NULLFSBLOCK ) { *stat =0 ;return 0 ; } -ASSERT (args.agno == cur->bc_ag.agno); +ASSERT (args.agno == cur->bc_ag.pag->pag_agno);ASSERT (args.len ==1 ); new->s =cpu_to_be32 (args.agbno);
@@ -105,7 +105,7 @@ xfs_refcountbt_free_block(xfs_fsblock_t fsbno =XFS_DADDR_TO_FSB (mp,XFS_BUF_ADDR (bp));int error; -trace_xfs_refcountbt_free_block (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcountbt_free_block (cur->bc_mp, cur->bc_ag.pag->pag_agno,XFS_FSB_TO_AGBNO (cur->bc_mp, fsbno),1 );be32_add_cpu (&agf->agf_refcount_blocks,-1 );xfs_alloc_log_agf (cur->bc_tp, agbp,XFS_AGF_REFCOUNT_BLOCKS );
@@ -170,7 +170,7 @@ xfs_refcountbt_init_ptr_from_cur( {struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agf->agf_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agf->agf_seqno)); ptr->s = agf->agf_refcount_root; }
@@ -334,7 +334,6 @@ xfs_refcountbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno; cur->bc_ag.refc.nr_ops =0 ; cur->bc_ag.refc.shape_changes =0 ;
fs/xfs/libxfs/xfs_rmap.c +54 -54
418 lines not on this page · raw message
fs/xfs/libxfs/xfs_rmap_btree.c +0 -1
@@ -464,7 +464,6 @@ xfs_rmapbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;return cur; }
fs/xfs/scrub/agheader_repair.c +1 -1
@@ -454,7 +454,7 @@ xrep_agfl_walk_rmap(/* Record all the OWN_AG blocks. */ if (rec->rm_owner ==XFS_RMAP_OWN_AG ) { - fsb =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno, + fsb =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno, rec->rm_startblock); error =xbitmap_set (ra->freesp, fsb, rec->rm_blockcount);if (error)
fs/xfs/scrub/alloc.c +2 -1
@@ -15,6 +15,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub free space btrees.
@@ -93,7 +94,7 @@ xchk_allocbt_rec( union xfs_btree_rec *rec) {struct xfs_mount *mp = bs->cur->bc_mp; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno;xfs_extlen_t len;
fs/xfs/scrub/bmap.c +1 -1
@@ -515,7 +515,7 @@ xchk_bmap_check_rmap(xchk_fblock_set_corrupt (sc, sbcri->whichfork, rec->rm_offset);if (irec.br_startblock !=XFS_AGB_TO_FSB (sc->mp, - cur->bc_ag.agno, rec->rm_startblock)) + cur->bc_ag.pag->pag_agno, rec->rm_startblock))xchk_fblock_set_corrupt (sc, sbcri->whichfork, rec->rm_offset);if (irec.br_blockcount > rec->rm_blockcount)
fs/xfs/scrub/ialloc.c +5 -4
@@ -21,6 +21,7 @@#include "scrub/common.h" #include "scrub/btree.h" #include "scrub/trace.h" +#include "xfs_ag.h" /* * Set us up to scrub inode btrees.
@@ -103,7 +104,7 @@ xchk_iallocbt_chunk( xfs_extlen_t len) {struct xfs_mount *mp = bs->cur->bc_mp; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno; bno =XFS_AGINO_TO_AGBNO (mp, agino);
@@ -163,7 +164,7 @@ xchk_iallocbt_check_cluster_ifree(* the record, compute which fs inode we're talking about. */ agino = irec->ir_startino + irec_ino; - fsino =XFS_AGINO_TO_INO (mp, bs->cur->bc_ag.agno, agino); + fsino =XFS_AGINO_TO_INO (mp, bs->cur->bc_ag.pag->pag_agno, agino); irec_free = (irec->ir_free &XFS_INOBT_MASK (irec_ino)); if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC ||
@@ -213,7 +214,7 @@ xchk_iallocbt_check_cluster(struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_buf *cluster_bp;unsigned int nr_inodes; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t agbno;unsigned int cluster_index;uint16_t cluster_mask =0 ;
@@ -423,7 +424,7 @@ xchk_iallocbt_rec(struct xchk_iallocbt *iabt = bs->private;struct xfs_inobt_rec_incore irec;uint64_t holes; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agino_t agino;xfs_extlen_t len;int holecount;
fs/xfs/scrub/refcount.c +2 -1
@@ -13,6 +13,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub reference count btrees.
@@ -333,7 +334,7 @@ xchk_refcountbt_rec( {struct xfs_mount *mp = bs->cur->bc_mp;xfs_agblock_t *cow_blocks = bs->private; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno;xfs_extlen_t len;xfs_nlink_t refcount;
fs/xfs/scrub/rmap.c +2 -1
@@ -15,6 +15,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub reverse mapping btrees.
@@ -91,7 +92,7 @@ xchk_rmapbt_rec( {struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_rmap_irec irec; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;bool non_inode;bool is_unwritten;bool is_bmbt;
fs/xfs/scrub/trace.c +2 -1
@@ -13,6 +13,7 @@#include "xfs_inode.h" #include "xfs_btree.h" #include "scrub/scrub.h" +#include "xfs_ag.h" /* Figure out which block the btree cursor was pointing to. */ static inline xfs_fsblock_t
@@ -26,7 +27,7 @@ xchk_btree_cur_fsbno( cur->bc_flags & XFS_BTREE_LONG_PTRS)return XFS_INO_TO_FSB (cur->bc_mp, cur->bc_ino.ip->i_ino); else if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS)) -return XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno,0 ); +return XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno,0 );return NULLFSBLOCK ; }
fs/xfs/xfs_fsmap.c +2 -2
@@ -355,7 +355,7 @@ xfs_getfsmap_datadev_helper(xfs_fsblock_t fsb;xfs_daddr_t rec_daddr; - fsb =XFS_AGB_TO_FSB (mp, cur->bc_ag.agno, rec->rm_startblock); + 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);
@@ -373,7 +373,7 @@ xfs_getfsmap_datadev_bnobt_helper(struct xfs_rmap_irec irec;xfs_daddr_t rec_daddr; - rec_daddr =XFS_AGB_TO_DADDR (mp, cur->bc_ag.agno, + rec_daddr =XFS_AGB_TO_DADDR (mp, cur->bc_ag.pag->pag_agno, rec->ar_startblock); irec.rm_startblock = rec->ar_startblock;
fs/xfs/xfs_trace.h +2 -2
@@ -3730,7 +3730,7 @@ TRACE_EVENT(xfs_btree_commit_afakeroot,TP_fast_assign ( __entry->dev = cur->bc_mp->m_super->s_dev; __entry->btnum = cur->bc_btnum; - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno = cur->bc_ag.afake->af_root; __entry->levels = cur->bc_ag.afake->af_levels; __entry->blocks = cur->bc_ag.afake->af_blocks;
@@ -3845,7 +3845,7 @@ TRACE_EVENT(xfs_btree_bload_block, __entry->agno =XFS_FSB_TO_AGNO (cur->bc_mp, fsb); __entry->agbno =XFS_FSB_TO_AGBNO (cur->bc_mp, fsb); }else { - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno =be32_to_cpu (ptr->s); } __entry->nr_records = nr_records;
Signature · 1 line
2.31.1
Re: [PATCH 16/22] xfs: remove agno from btree cursor
Quoted 30 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that everything passes a perag, the agno is not needed anymore. Convert all the users to use
pag->pag_agnoinstead and remove the agno from the cursor. This was largely done as an automated search and replace.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_alloc_btree.c | 1 - fs/xfs/libxfs/xfs_btree.c | 12 ++-- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_ialloc_btree.c | 7 +- fs/xfs/libxfs/xfs_refcount.c | 82 +++++++++++----------- fs/xfs/libxfs/xfs_refcount_btree.c | 11 ++- fs/xfs/libxfs/xfs_rmap.c | 108 ++++++++++++++--------------- fs/xfs/libxfs/xfs_rmap_btree.c | 1 - fs/xfs/scrub/agheader_repair.c | 2 +- fs/xfs/scrub/alloc.c | 3 +- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/ialloc.c | 9 +-- fs/xfs/scrub/refcount.c | 3 +- fs/xfs/scrub/rmap.c | 3 +- fs/xfs/scrub/trace.c | 3 +- fs/xfs/xfs_fsmap.c | 4 +- fs/xfs/xfs_trace.h | 4 +- 19 files changed, 130 insertions(+), 130 deletions(-)
...
Quoted 4 lines
fs/xfs/libxfs/xfs_rmap.c +0
-0
...
fs/xfs/libxfs/xfs_rmap.c xfs_rmap_finish_one( · line 2392
Quoted 6 lines
fs/xfs/libxfs/xfs_rmap.c +1
-1@@ -2389,7 +2389,7 @@ xfs_rmap_finish_one(* the startblock, get one now. */ rcur = *pcur; -if (rcur !=NULL && rcur->bc_ag.agno != pag->pag_agno) { +if (rcur !=NULL && rcur->bc_ag.pag != pag) {
I wonder a bit about this sort of logic if the goal is to ultimately allow for dynamic instantiation of perag structures, though it's probably not an issue here.
Quoted 3 lines
fs/xfs/libxfs/xfs_rmap.c +0
-0xfs_rmap_finish_one_cleanup (tp, rcur,0 ); rcur =NULL ; *pcur =NULL ;
...
fs/xfs/xfs_trace.h TRACE_EVENT(xfs_btree_commit_afakeroot, · line 3733
Quoted 10 lines
fs/xfs/xfs_trace.h +1
-1@@ -3730,7 +3730,7 @@ TRACE_EVENT(xfs_btree_commit_afakeroot,TP_fast_assign ( __entry->dev = cur->bc_mp->m_super->s_dev; __entry->btnum = cur->bc_btnum; - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno;
It would be nice if we did this with some of the other tracepoints rather than pulling ->pag_agno out at every callsite, but that's probably something for another patch. All in all this looks fine to me:
Quoted 15 lines
fs/xfs/xfs_trace.h +1
-1__entry->agbno = cur->bc_ag.afake->af_root; __entry->levels = cur->bc_ag.afake->af_levels; __entry->blocks = cur->bc_ag.afake->af_blocks;@@ -3845,7 +3845,7 @@ TRACE_EVENT(xfs_btree_bload_block, __entry->agno =XFS_FSB_TO_AGNO (cur->bc_mp, fsb); __entry->agbno =XFS_FSB_TO_AGBNO (cur->bc_mp, fsb); }else { - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno =be32_to_cpu (ptr->s); } __entry->nr_records = nr_records;Signature · 1 line
2.31.1
Re: [PATCH 16/22] xfs: remove agno from btree cursor
Quoted 37 lines · Brian Foster
Quoted 30 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that everything passes a perag, the agno is not needed anymore. Convert all the users to use
pag->pag_agnoinstead and remove the agno from the cursor. This was largely done as an automated search and replace.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_alloc_btree.c | 1 - fs/xfs/libxfs/xfs_btree.c | 12 ++-- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_ialloc_btree.c | 7 +- fs/xfs/libxfs/xfs_refcount.c | 82 +++++++++++----------- fs/xfs/libxfs/xfs_refcount_btree.c | 11 ++- fs/xfs/libxfs/xfs_rmap.c | 108 ++++++++++++++--------------- fs/xfs/libxfs/xfs_rmap_btree.c | 1 - fs/xfs/scrub/agheader_repair.c | 2 +- fs/xfs/scrub/alloc.c | 3 +- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/ialloc.c | 9 +-- fs/xfs/scrub/refcount.c | 3 +- fs/xfs/scrub/rmap.c | 3 +- fs/xfs/scrub/trace.c | 3 +- fs/xfs/xfs_fsmap.c | 4 +- fs/xfs/xfs_trace.h | 4 +- 19 files changed, 130 insertions(+), 130 deletions(-)...
Quoted 4 lines
fs/xfs/libxfs/xfs_rmap.c +0
-0...
Quoted 10 lines
fs/xfs/libxfs/xfs_rmap.c xfs_rmap_finish_one( · line 2392
Quoted 6 lines
fs/xfs/libxfs/xfs_rmap.c +1
-1@@ -2389,7 +2389,7 @@ xfs_rmap_finish_one(* the startblock, get one now. */ rcur = *pcur; -if (rcur !=NULL && rcur->bc_ag.agno != pag->pag_agno) { +if (rcur !=NULL && rcur->bc_ag.pag != pag) {I wonder a bit about this sort of logic if the goal is to ultimately allow for dynamic instantiation of perag structures, though it's probably not an issue here.
The cursor will have an active reference, hence the perag it holds cannot be reclaimed until it drops it's reference. THis is the reason for pushing the perag into the cursor - we can guarantee the existence of the perag for as long as a btree cursor chain (i.e. the original cursor + all it's children that were duplicated from it).
Hence I think that checks that the pag is the same memory address indicate that the perag is still the same.
Quoted 4 lines
Quoted 3 lines
fs/xfs/libxfs/xfs_rmap.c +0
-0xfs_rmap_finish_one_cleanup (tp, rcur,0 ); rcur =NULL ; *pcur =NULL ;...
Quoted 14 lines
fs/xfs/xfs_trace.h TRACE_EVENT(xfs_btree_commit_afakeroot, · line 3733
Quoted 10 lines
fs/xfs/xfs_trace.h +1
-1@@ -3730,7 +3730,7 @@ TRACE_EVENT(xfs_btree_commit_afakeroot,TP_fast_assign ( __entry->dev = cur->bc_mp->m_super->s_dev; __entry->btnum = cur->bc_btnum; - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno;It would be nice if we did this with some of the other tracepoints rather than pulling ->pag_agno out at every callsite, but that's probably something for another patch. All in all this looks fine to me:
Yeah, that's something to clean up down the track. Cleaning up tracepoints have been low on my priority list - just retaining what they capture is sufficient for the initial conversion....
Quoted 1 line
Reviewed-by Brian Foster <[email protected]>
Ta.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 16/22] xfs: remove agno from btree cursor
In reply to Dave ChinnerQuoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that everything passes a perag, the agno is not needed anymore. Convert all the users to use
pag->pag_agnoinstead and remove the agno from the cursor. This was largely done as an automated search and replace.Signed-off-by Dave Chinner <[email protected]>
Yippeeeee!
--D
Quoted 1,268 lines
--- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_alloc_btree.c | 1 - fs/xfs/libxfs/xfs_btree.c | 12 ++-- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_ialloc_btree.c | 7 +- fs/xfs/libxfs/xfs_refcount.c | 82 +++++++++++----------- fs/xfs/libxfs/xfs_refcount_btree.c | 11 ++- fs/xfs/libxfs/xfs_rmap.c | 108 ++++++++++++++--------------- fs/xfs/libxfs/xfs_rmap_btree.c | 1 - fs/xfs/scrub/agheader_repair.c | 2 +- fs/xfs/scrub/alloc.c | 3 +- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/ialloc.c | 9 +-- fs/xfs/scrub/refcount.c | 3 +- fs/xfs/scrub/rmap.c | 3 +- fs/xfs/scrub/trace.c | 3 +- fs/xfs/xfs_fsmap.c | 4 +- fs/xfs/xfs_trace.h | 4 +- 19 files changed, 130 insertions(+), 130 deletions(-)fs/xfs/libxfs/xfs_alloc.c +1
-1@@ -230,7 +230,7 @@ xfs_alloc_get_rec( int *stat) /* output: success/failure */ {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;fs/xfs/libxfs/xfs_alloc_btree.c +0
-1@@ -497,7 +497,6 @@ xfs_allocbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;if (xfs_sb_version_hascrc (&mp->m_sb)) cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ;fs/xfs/libxfs/xfs_btree.c +6
-6@@ -216,7 +216,7 @@ xfs_btree_check_sptr( {if (level <=0 )return false; -return xfs_verify_agbno (cur->bc_mp, cur->bc_ag.agno, agbno); +return xfs_verify_agbno (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno); }/* @@ -245,7 +245,7 @@ xfs_btree_check_ptr(return 0 ;xfs_err (cur->bc_mp,"AG %u: Corrupt btree %d pointer at level %d index %d." , - cur->bc_ag.agno, cur->bc_btnum, + cur->bc_ag.pag->pag_agno, cur->bc_btnum, level, index); }@@ -888,13 +888,13 @@ xfs_btree_readahead_sblock(if ((lr &XFS_BTCUR_LEFTRA ) && left !=NULLAGBLOCK ) { -xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.agno, +xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.pag->pag_agno, left,1 , cur->bc_ops->buf_ops); rval++; }if ((lr &XFS_BTCUR_RIGHTRA ) && right !=NULLAGBLOCK ) { -xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.agno, +xfs_btree_reada_bufs (cur->bc_mp, cur->bc_ag.pag->pag_agno, right,1 , cur->bc_ops->buf_ops); rval++; }@@ -952,7 +952,7 @@ xfs_btree_ptr_to_daddr( *daddr =XFS_FSB_TO_DADDR (cur->bc_mp, fsbno); }else { agbno =be32_to_cpu (ptr->s); - *daddr =XFS_AGB_TO_DADDR (cur->bc_mp, cur->bc_ag.agno, + *daddr =XFS_AGB_TO_DADDR (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno); }@@ -1153,7 +1153,7 @@ xfs_btree_init_block_cur(if (cur->bc_flags &XFS_BTREE_LONG_PTRS ) owner = cur->bc_ino.ip->i_ino;else - owner = cur->bc_ag.agno; + owner = cur->bc_ag.pag->pag_agno; xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, cur->bc_btnum, level, numrecs,fs/xfs/libxfs/xfs_btree.h +0
-1@@ -181,7 +181,6 @@ union xfs_btree_irec {/* Per-AG btree information. */ struct xfs_btree_cur_ag { -xfs_agnumber_t agno;struct xfs_perag *pag;union {struct xfs_buf *agbp;fs/xfs/libxfs/xfs_ialloc.c +1
-1@@ -105,7 +105,7 @@ xfs_inobt_get_rec( int *stat) {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;uint64_t realfree;fs/xfs/libxfs/xfs_ialloc_btree.c +3
-4@@ -102,7 +102,7 @@ __xfs_inobt_alloc_block( args.tp = cur->bc_tp; args.mp = cur->bc_mp; args.oinfo =XFS_RMAP_OINFO_INOBT ; - args.fsbno =XFS_AGB_TO_FSB (args.mp, cur->bc_ag.agno, sbno); + args.fsbno =XFS_AGB_TO_FSB (args.mp, cur->bc_ag.pag->pag_agno, sbno); args.minlen =1 ; args.maxlen =1 ; args.prod =1 ;@@ -235,7 +235,7 @@ xfs_inobt_init_ptr_from_cur( {struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agi->agi_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agi->agi_seqno)); ptr->s = agi->agi_root; }@@ -247,7 +247,7 @@ xfs_finobt_init_ptr_from_cur( {struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agi->agi_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agi->agi_seqno)); ptr->s = agi->agi_free_root; }@@ -452,7 +452,6 @@ xfs_inobt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;return cur; }fs/xfs/libxfs/xfs_refcount.c +41
-41@@ -47,7 +47,7 @@ xfs_refcount_lookup_le(xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.agno, bno, + trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno,XFS_LOOKUP_LE ); cur->bc_rec.rc.rc_startblock = bno; cur->bc_rec.rc.rc_blockcount =0 ;@@ -64,7 +64,7 @@ xfs_refcount_lookup_ge(xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.agno, bno, + trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno,XFS_LOOKUP_GE ); cur->bc_rec.rc.rc_startblock = bno; cur->bc_rec.rc.rc_blockcount =0 ;@@ -81,7 +81,7 @@ xfs_refcount_lookup_eq(xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.agno, bno, + trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno,XFS_LOOKUP_LE ); cur->bc_rec.rc.rc_startblock = bno; cur->bc_rec.rc.rc_blockcount =0 ;@@ -109,7 +109,7 @@ xfs_refcount_get_rec( int *stat) {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;xfs_agblock_t realstart;@@ -120,7 +120,7 @@ xfs_refcount_get_rec(xfs_refcount_btrec_to_irec (rec, irec); - agno = cur->bc_ag.agno; + agno = cur->bc_ag.pag->pag_agno;if (irec->rc_blockcount ==0 || irec->rc_blockcount >MAXREFCEXTLEN ) goto out_bad_rec;@@ -145,7 +145,7 @@ xfs_refcount_get_rec(if (irec->rc_refcount ==0 || irec->rc_refcount >MAXREFCOUNT ) goto out_bad_rec; -trace_xfs_refcount_get (cur->bc_mp, cur->bc_ag.agno, irec); +trace_xfs_refcount_get (cur->bc_mp, cur->bc_ag.pag->pag_agno, irec);return 0 ; out_bad_rec:@@ -170,14 +170,14 @@ xfs_refcount_update(union xfs_btree_rec rec;int error; -trace_xfs_refcount_update (cur->bc_mp, cur->bc_ag.agno, irec); +trace_xfs_refcount_update (cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); rec.refc.rc_startblock =cpu_to_be32 (irec->rc_startblock); rec.refc.rc_blockcount =cpu_to_be32 (irec->rc_blockcount); rec.refc.rc_refcount =cpu_to_be32 (irec->rc_refcount); error =xfs_btree_update (cur, &rec);if (error)trace_xfs_refcount_update_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -194,7 +194,7 @@ xfs_refcount_insert( {int error; -trace_xfs_refcount_insert (cur->bc_mp, cur->bc_ag.agno, irec); +trace_xfs_refcount_insert (cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); cur->bc_rec.rc.rc_startblock = irec->rc_startblock; cur->bc_rec.rc.rc_blockcount = irec->rc_blockcount; cur->bc_rec.rc.rc_refcount = irec->rc_refcount;@@ -209,7 +209,7 @@ xfs_refcount_insert( out_error:if (error)trace_xfs_refcount_insert_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -235,7 +235,7 @@ xfs_refcount_delete( error = -EFSCORRUPTED ; goto out_error; } -trace_xfs_refcount_delete (cur->bc_mp, cur->bc_ag.agno, &irec); +trace_xfs_refcount_delete (cur->bc_mp, cur->bc_ag.pag->pag_agno, &irec); error =xfs_btree_delete (cur, i);if (XFS_IS_CORRUPT (cur->bc_mp, *i !=1 )) { error = -EFSCORRUPTED ;@@ -247,7 +247,7 @@ xfs_refcount_delete( out_error:if (error)trace_xfs_refcount_delete_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -367,7 +367,7 @@ xfs_refcount_split_extent(return 0 ; *shape_changed = true; -trace_xfs_refcount_split_extent (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_split_extent (cur->bc_mp, cur->bc_ag.pag->pag_agno, &rcext, agbno);/* Establish the right extent. */ @@ -392,7 +392,7 @@ xfs_refcount_split_extent( out_error:trace_xfs_refcount_split_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -412,7 +412,7 @@ xfs_refcount_merge_center_extents(int found_rec;trace_xfs_refcount_merge_center_extents (cur->bc_mp, - cur->bc_ag.agno, left, center, right); + cur->bc_ag.pag->pag_agno, left, center, right);/* * Make sure the center and right extents are not in the btree. @@ -469,7 +469,7 @@ xfs_refcount_merge_center_extents( out_error:trace_xfs_refcount_merge_center_extents_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -488,7 +488,7 @@ xfs_refcount_merge_left_extent(int found_rec;trace_xfs_refcount_merge_left_extent (cur->bc_mp, - cur->bc_ag.agno, left, cleft); + cur->bc_ag.pag->pag_agno, left, cleft);/* If the extent at agbno (cleft) wasn't synthesized, remove it. */ if (cleft->rc_refcount >1 ) {@@ -531,7 +531,7 @@ xfs_refcount_merge_left_extent( out_error:trace_xfs_refcount_merge_left_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -549,7 +549,7 @@ xfs_refcount_merge_right_extent(int found_rec;trace_xfs_refcount_merge_right_extent (cur->bc_mp, - cur->bc_ag.agno, cright, right); + cur->bc_ag.pag->pag_agno, cright, right);/* * If the extent ending at agbno+aglen (cright) wasn't synthesized, @@ -595,7 +595,7 @@ xfs_refcount_merge_right_extent( out_error:trace_xfs_refcount_merge_right_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -680,13 +680,13 @@ xfs_refcount_find_left_extents( cleft->rc_blockcount = aglen; cleft->rc_refcount =1 ; } -trace_xfs_refcount_find_left_extent (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_find_left_extent (cur->bc_mp, cur->bc_ag.pag->pag_agno, left, cleft, agbno);return error; out_error:trace_xfs_refcount_find_left_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -769,13 +769,13 @@ xfs_refcount_find_right_extents( cright->rc_blockcount = aglen; cright->rc_refcount =1 ; } -trace_xfs_refcount_find_right_extent (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_find_right_extent (cur->bc_mp, cur->bc_ag.pag->pag_agno, cright, right, agbno + aglen);return error; out_error:trace_xfs_refcount_find_right_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -953,7 +953,7 @@ xfs_refcount_adjust_extents( ext.rc_startblock - *agbno); tmp.rc_refcount =1 + adj;trace_xfs_refcount_modify_extent (cur->bc_mp, - cur->bc_ag.agno, &tmp); + cur->bc_ag.pag->pag_agno, &tmp);/* * Either cover the hole (increment) or @@ -972,7 +972,7 @@ xfs_refcount_adjust_extents( cur->bc_ag.refc.nr_ops++; }else { fsbno =XFS_AGB_TO_FSB (cur->bc_mp, - cur->bc_ag.agno, + cur->bc_ag.pag->pag_agno, tmp.rc_startblock);xfs_bmap_add_free (cur->bc_tp, fsbno, tmp.rc_blockcount, oinfo);@@ -999,7 +999,7 @@ xfs_refcount_adjust_extents( goto skip; ext.rc_refcount += adj;trace_xfs_refcount_modify_extent (cur->bc_mp, - cur->bc_ag.agno, &ext); + cur->bc_ag.pag->pag_agno, &ext);if (ext.rc_refcount >1 ) { error =xfs_refcount_update (cur, &ext);if (error)@@ -1017,7 +1017,7 @@ xfs_refcount_adjust_extents( goto advloop; }else { fsbno =XFS_AGB_TO_FSB (cur->bc_mp, - cur->bc_ag.agno, + cur->bc_ag.pag->pag_agno, ext.rc_startblock);xfs_bmap_add_free (cur->bc_tp, fsbno, ext.rc_blockcount, oinfo);@@ -1036,7 +1036,7 @@ xfs_refcount_adjust_extents(return error; out_error:trace_xfs_refcount_modify_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1058,10 +1058,10 @@ xfs_refcount_adjust( *new_agbno = agbno; *new_aglen = aglen;if (adj ==XFS_REFCOUNT_ADJUST_INCREASE ) -trace_xfs_refcount_increase (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_increase (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno, aglen);else -trace_xfs_refcount_decrease (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_decrease (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno, aglen);/* @@ -1100,7 +1100,7 @@ xfs_refcount_adjust(return 0 ; out_error: -trace_xfs_refcount_adjust_error (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_adjust_error (cur->bc_mp, cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1298,7 +1298,7 @@ xfs_refcount_find_shared(int have;int error; -trace_xfs_refcount_find_shared (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_find_shared (cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno, aglen);/* By default, skip the whole range */ @@ -1378,12 +1378,12 @@ xfs_refcount_find_shared( done:trace_xfs_refcount_find_shared_result (cur->bc_mp, - cur->bc_ag.agno, *fbno, *flen); + cur->bc_ag.pag->pag_agno, *fbno, *flen); out_error:if (error)trace_xfs_refcount_find_shared_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1480,7 +1480,7 @@ xfs_refcount_adjust_cow_extents( tmp.rc_blockcount = aglen; tmp.rc_refcount =1 ;trace_xfs_refcount_modify_extent (cur->bc_mp, - cur->bc_ag.agno, &tmp); + cur->bc_ag.pag->pag_agno, &tmp); error =xfs_refcount_insert (cur, &tmp, &found_tmp);@@ -1508,7 +1508,7 @@ xfs_refcount_adjust_cow_extents( ext.rc_refcount =0 ;trace_xfs_refcount_modify_extent (cur->bc_mp, - cur->bc_ag.agno, &ext); + cur->bc_ag.pag->pag_agno, &ext); error =xfs_refcount_delete (cur, &found_rec);if (error) goto out_error;@@ -1524,7 +1524,7 @@ xfs_refcount_adjust_cow_extents(return error; out_error:trace_xfs_refcount_modify_extent_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1570,7 +1570,7 @@ xfs_refcount_adjust_cow(return 0 ; out_error: -trace_xfs_refcount_adjust_cow_error (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcount_adjust_cow_error (cur->bc_mp, cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1584,7 +1584,7 @@ __xfs_refcount_cow_alloc( xfs_agblock_t agbno, xfs_extlen_t aglen) { -trace_xfs_refcount_cow_increase (rcur->bc_mp, rcur->bc_ag.agno, +trace_xfs_refcount_cow_increase (rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, aglen);/* Add refcount btree reservation */ @@ -1601,7 +1601,7 @@ __xfs_refcount_cow_free( xfs_agblock_t agbno, xfs_extlen_t aglen) { -trace_xfs_refcount_cow_decrease (rcur->bc_mp, rcur->bc_ag.agno, +trace_xfs_refcount_cow_decrease (rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, aglen);/* Remove refcount btree reservation */ fs/xfs/libxfs/xfs_refcount_btree.c +5
-6@@ -65,7 +65,7 @@ xfs_refcountbt_alloc_block( args.tp = cur->bc_tp; args.mp = cur->bc_mp; args.type =XFS_ALLOCTYPE_NEAR_BNO ; - args.fsbno =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno, + args.fsbno =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno,xfs_refc_block (args.mp)); args.oinfo =XFS_RMAP_OINFO_REFC ; args.minlen = args.maxlen = args.prod =1 ;@@ -74,13 +74,13 @@ xfs_refcountbt_alloc_block( error =xfs_alloc_vextent (&args);if (error) goto out_error; -trace_xfs_refcountbt_alloc_block (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcountbt_alloc_block (cur->bc_mp, cur->bc_ag.pag->pag_agno, args.agbno,1 );if (args.fsbno ==NULLFSBLOCK ) { *stat =0 ;return 0 ; } -ASSERT (args.agno == cur->bc_ag.agno); +ASSERT (args.agno == cur->bc_ag.pag->pag_agno);ASSERT (args.len ==1 ); new->s =cpu_to_be32 (args.agbno);@@ -105,7 +105,7 @@ xfs_refcountbt_free_block(xfs_fsblock_t fsbno =XFS_DADDR_TO_FSB (mp,XFS_BUF_ADDR (bp));int error; -trace_xfs_refcountbt_free_block (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_refcountbt_free_block (cur->bc_mp, cur->bc_ag.pag->pag_agno,XFS_FSB_TO_AGBNO (cur->bc_mp, fsbno),1 );be32_add_cpu (&agf->agf_refcount_blocks,-1 );xfs_alloc_log_agf (cur->bc_tp, agbp,XFS_AGF_REFCOUNT_BLOCKS );@@ -170,7 +170,7 @@ xfs_refcountbt_init_ptr_from_cur( {struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; -ASSERT (cur->bc_ag.agno ==be32_to_cpu (agf->agf_seqno)); +ASSERT (cur->bc_ag.pag->pag_agno ==be32_to_cpu (agf->agf_seqno)); ptr->s = agf->agf_refcount_root; }@@ -334,7 +334,6 @@ xfs_refcountbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno; cur->bc_ag.refc.nr_ops =0 ; cur->bc_ag.refc.shape_changes =0 ;fs/xfs/libxfs/xfs_rmap.c +54
-54@@ -81,7 +81,7 @@ xfs_rmap_update(union xfs_btree_rec rec;int error; -trace_xfs_rmap_update (cur->bc_mp, cur->bc_ag.agno, +trace_xfs_rmap_update (cur->bc_mp, cur->bc_ag.pag->pag_agno, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags);@@ -93,7 +93,7 @@ xfs_rmap_update( error =xfs_btree_update (cur, &rec);if (error)trace_xfs_rmap_update_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -109,7 +109,7 @@ xfs_rmap_insert(int i;int error; -trace_xfs_rmap_insert (rcur->bc_mp, rcur->bc_ag.agno, agbno, +trace_xfs_rmap_insert (rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, len, owner, offset, flags); error =xfs_rmap_lookup_eq (rcur, agbno, len, owner, offset, flags, &i);@@ -135,7 +135,7 @@ xfs_rmap_insert( done:if (error)trace_xfs_rmap_insert_error (rcur->bc_mp, - rcur->bc_ag.agno, error, _RET_IP_); + rcur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -151,7 +151,7 @@ xfs_rmap_delete(int i;int error; -trace_xfs_rmap_delete (rcur->bc_mp, rcur->bc_ag.agno, agbno, +trace_xfs_rmap_delete (rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, len, owner, offset, flags); error =xfs_rmap_lookup_eq (rcur, agbno, len, owner, offset, flags, &i);@@ -172,7 +172,7 @@ xfs_rmap_delete( done:if (error)trace_xfs_rmap_delete_error (rcur->bc_mp, - rcur->bc_ag.agno, error, _RET_IP_); + rcur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -199,7 +199,7 @@ xfs_rmap_get_rec( int *stat) {struct xfs_mount *mp = cur->bc_mp; -xfs_agnumber_t agno = cur->bc_ag.agno; +xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno;union xfs_btree_rec *rec;int error;@@ -262,7 +262,7 @@ xfs_rmap_find_left_neighbor_helper(struct xfs_find_left_neighbor_info *info = priv;trace_xfs_rmap_find_left_neighbor_candidate (cur->bc_mp, - cur->bc_ag.agno, rec->rm_startblock, + cur->bc_ag.pag->pag_agno, rec->rm_startblock, rec->rm_blockcount, rec->rm_owner, rec->rm_offset, rec->rm_flags);@@ -314,7 +314,7 @@ xfs_rmap_find_left_neighbor( info.stat = stat;trace_xfs_rmap_find_left_neighbor_query (cur->bc_mp, - cur->bc_ag.agno, bno,0 , owner, offset, flags); + cur->bc_ag.pag->pag_agno, bno,0 , owner, offset, flags); error =xfs_rmap_query_range (cur, &info.high, &info.high, xfs_rmap_find_left_neighbor_helper, &info);@@ -322,7 +322,7 @@ xfs_rmap_find_left_neighbor( error =0 ;if (*stat)trace_xfs_rmap_find_left_neighbor_result (cur->bc_mp, - cur->bc_ag.agno, irec->rm_startblock, + cur->bc_ag.pag->pag_agno, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags);return error;@@ -338,7 +338,7 @@ xfs_rmap_lookup_le_range_helper(struct xfs_find_left_neighbor_info *info = priv;trace_xfs_rmap_lookup_le_range_candidate (cur->bc_mp, - cur->bc_ag.agno, rec->rm_startblock, + cur->bc_ag.pag->pag_agno, rec->rm_startblock, rec->rm_blockcount, rec->rm_owner, rec->rm_offset, rec->rm_flags);@@ -387,14 +387,14 @@ xfs_rmap_lookup_le_range( info.stat = stat;trace_xfs_rmap_lookup_le_range (cur->bc_mp, - cur->bc_ag.agno, bno,0 , owner, offset, flags); + cur->bc_ag.pag->pag_agno, bno,0 , owner, offset, flags); error =xfs_rmap_query_range (cur, &info.high, &info.high, xfs_rmap_lookup_le_range_helper, &info);if (error == -ECANCELED ) error =0 ;if (*stat)trace_xfs_rmap_lookup_le_range_result (cur->bc_mp, - cur->bc_ag.agno, irec->rm_startblock, + cur->bc_ag.pag->pag_agno, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags);return error;@@ -500,7 +500,7 @@ xfs_rmap_unmap( (flags &XFS_RMAP_BMBT_BLOCK );if (unwritten) flags |=XFS_RMAP_UNWRITTEN ; -trace_xfs_rmap_unmap (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_unmap (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);/* @@ -524,7 +524,7 @@ xfs_rmap_unmap( goto out_error; }trace_xfs_rmap_lookup_le_range_result (cur->bc_mp, - cur->bc_ag.agno, ltrec.rm_startblock, + cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, ltrec.rm_blockcount, ltrec.rm_owner, ltrec.rm_offset, ltrec.rm_flags); ltoff = ltrec.rm_offset;@@ -590,7 +590,7 @@ xfs_rmap_unmap(if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) {/* exact match, simply remove the record from rmap tree */ -trace_xfs_rmap_delete (mp, cur->bc_ag.agno, +trace_xfs_rmap_delete (mp, cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, ltrec.rm_blockcount, ltrec.rm_owner, ltrec.rm_offset, ltrec.rm_flags);@@ -668,7 +668,7 @@ xfs_rmap_unmap(else cur->bc_rec.r.rm_offset = offset + len; cur->bc_rec.r.rm_flags = flags; - trace_xfs_rmap_insert(mp, cur->bc_ag.agno, + trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, cur->bc_rec.r.rm_startblock, cur->bc_rec.r.rm_blockcount, cur->bc_rec.r.rm_owner,@@ -680,11 +680,11 @@ xfs_rmap_unmap( } out_done: -trace_xfs_rmap_unmap_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_unmap_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); out_error:if (error) -trace_xfs_rmap_unmap_error (mp, cur->bc_ag.agno, +trace_xfs_rmap_unmap_error (mp, cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -775,7 +775,7 @@ xfs_rmap_map( (flags &XFS_RMAP_BMBT_BLOCK );if (unwritten) flags |=XFS_RMAP_UNWRITTEN ; -trace_xfs_rmap_map (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_map (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);ASSERT (!xfs_rmap_should_skip_owner_update (oinfo));@@ -797,7 +797,7 @@ xfs_rmap_map( goto out_error; }trace_xfs_rmap_lookup_le_range_result (cur->bc_mp, - cur->bc_ag.agno, ltrec.rm_startblock, + cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, ltrec.rm_blockcount, ltrec.rm_owner, ltrec.rm_offset, ltrec.rm_flags);@@ -833,7 +833,7 @@ xfs_rmap_map( goto out_error; }trace_xfs_rmap_find_right_neighbor_result (cur->bc_mp, - cur->bc_ag.agno, gtrec.rm_startblock, + cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, gtrec.rm_blockcount, gtrec.rm_owner, gtrec.rm_offset, gtrec.rm_flags);if (!xfs_rmap_is_mergeable (>rec, owner, flags))@@ -872,7 +872,7 @@ xfs_rmap_map(* result: |rrrrrrrrrrrrrrrrrrrrrrrrrrrrr| */ ltrec.rm_blockcount += gtrec.rm_blockcount; - trace_xfs_rmap_delete(mp, cur->bc_ag.agno, + trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, gtrec.rm_blockcount, gtrec.rm_owner,@@ -923,7 +923,7 @@ xfs_rmap_map( cur->bc_rec.r.rm_owner = owner; cur->bc_rec.r.rm_offset = offset; cur->bc_rec.r.rm_flags = flags; -trace_xfs_rmap_insert (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_insert (mp, cur->bc_ag.pag->pag_agno, bno, len, owner, offset, flags); error =xfs_btree_insert (cur, &i);if (error)@@ -934,11 +934,11 @@ xfs_rmap_map( } } -trace_xfs_rmap_map_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_map_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); out_error:if (error) -trace_xfs_rmap_map_error (mp, cur->bc_ag.agno, +trace_xfs_rmap_map_error (mp, cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1012,7 +1012,7 @@ xfs_rmap_convert( (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); oldext = unwritten ?XFS_RMAP_UNWRITTEN :0 ; new_endoff = offset + len; -trace_xfs_rmap_convert (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_convert (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);/* @@ -1036,7 +1036,7 @@ xfs_rmap_convert( goto done; }trace_xfs_rmap_lookup_le_range_result (cur->bc_mp, - cur->bc_ag.agno,PREV .rm_startblock, + cur->bc_ag.pag->pag_agno,PREV .rm_startblock,PREV .rm_blockcount,PREV .rm_owner,PREV .rm_offset,PREV .rm_flags);@@ -1078,7 +1078,7 @@ xfs_rmap_convert( goto done; }trace_xfs_rmap_find_left_neighbor_result (cur->bc_mp, - cur->bc_ag.agno,LEFT .rm_startblock, + cur->bc_ag.pag->pag_agno,LEFT .rm_startblock,LEFT .rm_blockcount,LEFT .rm_owner,LEFT .rm_offset,LEFT .rm_flags); if (LEFT.rm_startblock + LEFT.rm_blockcount == bno &&@@ -1116,7 +1116,7 @@ xfs_rmap_convert( goto done; }trace_xfs_rmap_find_right_neighbor_result (cur->bc_mp, - cur->bc_ag.agno,RIGHT .rm_startblock, + cur->bc_ag.pag->pag_agno,RIGHT .rm_startblock,RIGHT .rm_blockcount,RIGHT .rm_owner,RIGHT .rm_offset,RIGHT .rm_flags); if (bno + len == RIGHT.rm_startblock &&@@ -1134,7 +1134,7 @@ xfs_rmap_convert( RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) state &= ~RMAP_RIGHT_CONTIG ; -trace_xfs_rmap_convert_state (mp, cur->bc_ag.agno, state, +trace_xfs_rmap_convert_state (mp, cur->bc_ag.pag->pag_agno, state, _RET_IP_);/* reset the cursor back to PREV */ @@ -1164,7 +1164,7 @@ xfs_rmap_convert( error = -EFSCORRUPTED ; goto done; } -trace_xfs_rmap_delete (mp, cur->bc_ag.agno, +trace_xfs_rmap_delete (mp, cur->bc_ag.pag->pag_agno,RIGHT .rm_startblock,RIGHT .rm_blockcount,RIGHT .rm_owner,RIGHT .rm_offset,RIGHT .rm_flags);@@ -1182,7 +1182,7 @@ xfs_rmap_convert( error = -EFSCORRUPTED ; goto done; } -trace_xfs_rmap_delete (mp, cur->bc_ag.agno, +trace_xfs_rmap_delete (mp, cur->bc_ag.pag->pag_agno,PREV .rm_startblock,PREV .rm_blockcount,PREV .rm_owner,PREV .rm_offset,PREV .rm_flags);@@ -1212,7 +1212,7 @@ xfs_rmap_convert(* Setting all of a previous oldext extent to newext. * The left neighbor is contiguous, the right is not. */ -trace_xfs_rmap_delete (mp, cur->bc_ag.agno, +trace_xfs_rmap_delete (mp, cur->bc_ag.pag->pag_agno,PREV .rm_startblock,PREV .rm_blockcount,PREV .rm_owner,PREV .rm_offset,PREV .rm_flags);@@ -1249,7 +1249,7 @@ xfs_rmap_convert( error = -EFSCORRUPTED ; goto done; } -trace_xfs_rmap_delete (mp, cur->bc_ag.agno, +trace_xfs_rmap_delete (mp, cur->bc_ag.pag->pag_agno,RIGHT .rm_startblock,RIGHT .rm_blockcount,RIGHT .rm_owner,RIGHT .rm_offset,RIGHT .rm_flags);@@ -1328,7 +1328,7 @@ xfs_rmap_convert(NEW .rm_blockcount = len;NEW .rm_flags = newext; cur->bc_rec.r =NEW ; -trace_xfs_rmap_insert (mp, cur->bc_ag.agno, bno, +trace_xfs_rmap_insert (mp, cur->bc_ag.pag->pag_agno, bno, len, owner, offset, newext); error =xfs_btree_insert (cur, &i);if (error)@@ -1385,7 +1385,7 @@ xfs_rmap_convert(NEW .rm_blockcount = len;NEW .rm_flags = newext; cur->bc_rec.r =NEW ; -trace_xfs_rmap_insert (mp, cur->bc_ag.agno, bno, +trace_xfs_rmap_insert (mp, cur->bc_ag.pag->pag_agno, bno, len, owner, offset, newext); error =xfs_btree_insert (cur, &i);if (error)@@ -1416,7 +1416,7 @@ xfs_rmap_convert(NEW =PREV ;NEW .rm_blockcount = offset -PREV .rm_offset; cur->bc_rec.r =NEW ; -trace_xfs_rmap_insert (mp, cur->bc_ag.agno, +trace_xfs_rmap_insert (mp, cur->bc_ag.pag->pag_agno,NEW .rm_startblock,NEW .rm_blockcount,NEW .rm_owner,NEW .rm_offset,NEW .rm_flags);@@ -1443,7 +1443,7 @@ xfs_rmap_convert(/* new middle extent - newext */ cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN ; cur->bc_rec.r.rm_flags |= newext; -trace_xfs_rmap_insert (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_insert (mp, cur->bc_ag.pag->pag_agno, bno, len, owner, offset, newext); error =xfs_btree_insert (cur, &i);if (error)@@ -1467,12 +1467,12 @@ xfs_rmap_convert(ASSERT (0 ); } -trace_xfs_rmap_convert_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_convert_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); done:if (error)trace_xfs_rmap_convert_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1508,7 +1508,7 @@ xfs_rmap_convert_shared( (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); oldext = unwritten ?XFS_RMAP_UNWRITTEN :0 ; new_endoff = offset + len; -trace_xfs_rmap_convert (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_convert (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);/* @@ -1575,7 +1575,7 @@ xfs_rmap_convert_shared( goto done; }trace_xfs_rmap_find_right_neighbor_result (cur->bc_mp, - cur->bc_ag.agno,RIGHT .rm_startblock, + cur->bc_ag.pag->pag_agno,RIGHT .rm_startblock,RIGHT .rm_blockcount,RIGHT .rm_owner,RIGHT .rm_offset,RIGHT .rm_flags);if (xfs_rmap_is_mergeable (&RIGHT , owner, newext))@@ -1591,7 +1591,7 @@ xfs_rmap_convert_shared( RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) state &= ~RMAP_RIGHT_CONTIG ; -trace_xfs_rmap_convert_state (mp, cur->bc_ag.agno, state, +trace_xfs_rmap_convert_state (mp, cur->bc_ag.pag->pag_agno, state, _RET_IP_);/* * Switch out based on the FILLING and CONTIG state bits. @@ -1882,12 +1882,12 @@ xfs_rmap_convert_shared(ASSERT (0 ); } -trace_xfs_rmap_convert_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_convert_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); done:if (error)trace_xfs_rmap_convert_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -1925,7 +1925,7 @@ xfs_rmap_unmap_shared(xfs_owner_info_unpack (oinfo, &owner, &offset, &flags);if (unwritten) flags |=XFS_RMAP_UNWRITTEN ; -trace_xfs_rmap_unmap (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_unmap (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);/* @@ -2074,12 +2074,12 @@ xfs_rmap_unmap_shared( goto out_error; } -trace_xfs_rmap_unmap_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_unmap_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); out_error:if (error)trace_xfs_rmap_unmap_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -2114,7 +2114,7 @@ xfs_rmap_map_shared(xfs_owner_info_unpack (oinfo, &owner, &offset, &flags);if (unwritten) flags |=XFS_RMAP_UNWRITTEN ; -trace_xfs_rmap_map (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_map (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo);/* Is there a left record that abuts our range? */ @@ -2140,7 +2140,7 @@ xfs_rmap_map_shared( goto out_error; }trace_xfs_rmap_find_right_neighbor_result (cur->bc_mp, - cur->bc_ag.agno, gtrec.rm_startblock, + cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, gtrec.rm_blockcount, gtrec.rm_owner, gtrec.rm_offset, gtrec.rm_flags);@@ -2233,12 +2233,12 @@ xfs_rmap_map_shared( goto out_error; } -trace_xfs_rmap_map_done (mp, cur->bc_ag.agno, bno, len, +trace_xfs_rmap_map_done (mp, cur->bc_ag.pag->pag_agno, bno, len, unwritten, oinfo); out_error:if (error)trace_xfs_rmap_map_error (cur->bc_mp, - cur->bc_ag.agno, error, _RET_IP_); + cur->bc_ag.pag->pag_agno, error, _RET_IP_);return error; }@@ -2389,7 +2389,7 @@ xfs_rmap_finish_one(* the startblock, get one now. */ rcur = *pcur; -if (rcur !=NULL && rcur->bc_ag.agno != pag->pag_agno) { +if (rcur !=NULL && rcur->bc_ag.pag != pag) {xfs_rmap_finish_one_cleanup (tp, rcur,0 ); rcur =NULL ; *pcur =NULL ;fs/xfs/libxfs/xfs_rmap_btree.c +0
-1@@ -464,7 +464,6 @@ xfs_rmapbt_init_common(/* take a reference for the cursor */ atomic_inc (&pag->pag_ref); cur->bc_ag.pag = pag; - cur->bc_ag.agno = pag->pag_agno;return cur; }fs/xfs/scrub/agheader_repair.c +1
-1@@ -454,7 +454,7 @@ xrep_agfl_walk_rmap(/* Record all the OWN_AG blocks. */ if (rec->rm_owner ==XFS_RMAP_OWN_AG ) { - fsb =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno, + fsb =XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno, rec->rm_startblock); error =xbitmap_set (ra->freesp, fsb, rec->rm_blockcount);if (error)fs/xfs/scrub/alloc.c +2
-1@@ -15,6 +15,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub free space btrees. @@ -93,7 +94,7 @@ xchk_allocbt_rec( union xfs_btree_rec *rec) {struct xfs_mount *mp = bs->cur->bc_mp; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno;xfs_extlen_t len;fs/xfs/scrub/bmap.c +1
-1@@ -515,7 +515,7 @@ xchk_bmap_check_rmap(xchk_fblock_set_corrupt (sc, sbcri->whichfork, rec->rm_offset);if (irec.br_startblock !=XFS_AGB_TO_FSB (sc->mp, - cur->bc_ag.agno, rec->rm_startblock)) + cur->bc_ag.pag->pag_agno, rec->rm_startblock))xchk_fblock_set_corrupt (sc, sbcri->whichfork, rec->rm_offset);if (irec.br_blockcount > rec->rm_blockcount)fs/xfs/scrub/ialloc.c +5
-4@@ -21,6 +21,7 @@#include "scrub/common.h" #include "scrub/btree.h" #include "scrub/trace.h" +#include "xfs_ag.h" /* * Set us up to scrub inode btrees. @@ -103,7 +104,7 @@ xchk_iallocbt_chunk( xfs_extlen_t len) {struct xfs_mount *mp = bs->cur->bc_mp; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno; bno =XFS_AGINO_TO_AGBNO (mp, agino);@@ -163,7 +164,7 @@ xchk_iallocbt_check_cluster_ifree(* the record, compute which fs inode we're talking about. */ agino = irec->ir_startino + irec_ino; - fsino =XFS_AGINO_TO_INO (mp, bs->cur->bc_ag.agno, agino); + fsino =XFS_AGINO_TO_INO (mp, bs->cur->bc_ag.pag->pag_agno, agino); irec_free = (irec->ir_free &XFS_INOBT_MASK (irec_ino)); if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC ||@@ -213,7 +214,7 @@ xchk_iallocbt_check_cluster(struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_buf *cluster_bp;unsigned int nr_inodes; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t agbno;unsigned int cluster_index;uint16_t cluster_mask =0 ;@@ -423,7 +424,7 @@ xchk_iallocbt_rec(struct xchk_iallocbt *iabt = bs->private;struct xfs_inobt_rec_incore irec;uint64_t holes; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agino_t agino;xfs_extlen_t len;int holecount;fs/xfs/scrub/refcount.c +2
-1@@ -13,6 +13,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub reference count btrees. @@ -333,7 +334,7 @@ xchk_refcountbt_rec( {struct xfs_mount *mp = bs->cur->bc_mp;xfs_agblock_t *cow_blocks = bs->private; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;xfs_agblock_t bno;xfs_extlen_t len;xfs_nlink_t refcount;fs/xfs/scrub/rmap.c +2
-1@@ -15,6 +15,7 @@#include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/btree.h" +#include "xfs_ag.h" /* * Set us up to scrub reverse mapping btrees. @@ -91,7 +92,7 @@ xchk_rmapbt_rec( {struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_rmap_irec irec; -xfs_agnumber_t agno = bs->cur->bc_ag.agno; +xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno;bool non_inode;bool is_unwritten;bool is_bmbt;fs/xfs/scrub/trace.c +2
-1@@ -13,6 +13,7 @@#include "xfs_inode.h" #include "xfs_btree.h" #include "scrub/scrub.h" +#include "xfs_ag.h" /* Figure out which block the btree cursor was pointing to. */ static inline xfs_fsblock_t@@ -26,7 +27,7 @@ xchk_btree_cur_fsbno( cur->bc_flags & XFS_BTREE_LONG_PTRS)return XFS_INO_TO_FSB (cur->bc_mp, cur->bc_ino.ip->i_ino); else if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS)) -return XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.agno,0 ); +return XFS_AGB_TO_FSB (cur->bc_mp, cur->bc_ag.pag->pag_agno,0 );return NULLFSBLOCK ; }fs/xfs/xfs_fsmap.c +2
-2@@ -355,7 +355,7 @@ xfs_getfsmap_datadev_helper(xfs_fsblock_t fsb;xfs_daddr_t rec_daddr; - fsb =XFS_AGB_TO_FSB (mp, cur->bc_ag.agno, rec->rm_startblock); + 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);@@ -373,7 +373,7 @@ xfs_getfsmap_datadev_bnobt_helper(struct xfs_rmap_irec irec;xfs_daddr_t rec_daddr; - rec_daddr =XFS_AGB_TO_DADDR (mp, cur->bc_ag.agno, + rec_daddr =XFS_AGB_TO_DADDR (mp, cur->bc_ag.pag->pag_agno, rec->ar_startblock); irec.rm_startblock = rec->ar_startblock;fs/xfs/xfs_trace.h +2
-2@@ -3730,7 +3730,7 @@ TRACE_EVENT(xfs_btree_commit_afakeroot,TP_fast_assign ( __entry->dev = cur->bc_mp->m_super->s_dev; __entry->btnum = cur->bc_btnum; - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno = cur->bc_ag.afake->af_root; __entry->levels = cur->bc_ag.afake->af_levels; __entry->blocks = cur->bc_ag.afake->af_blocks;@@ -3845,7 +3845,7 @@ TRACE_EVENT(xfs_btree_bload_block, __entry->agno =XFS_FSB_TO_AGNO (cur->bc_mp, fsb); __entry->agbno =XFS_FSB_TO_AGBNO (cur->bc_mp, fsb); }else { - __entry->agno = cur->bc_ag.agno; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno =be32_to_cpu (ptr->s); } __entry->nr_records = nr_records;Signature · 1 line
2.31.1
PATCH 17/22 xfs: simplify xfs_dialloc_select_ag() return values
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The only caller of xfs_dialloc_select_ag() will always return -ENOSPC to it's caller if the agbp returned from xfs_dialloc_select_ag() is NULL. IOWs, failure to find a candidate AGI we can allocate inodes from is always an ENOSPC condition, so move this logic up into xfs_dialloc_select_ag() so we can simplify the return logic in this function.
xfs_dialloc_select_ag() now only ever returns 0 with a locked agbp, or an error with no agbp.
--- fs/xfs/libxfs/xfs_ialloc.c | 23 ++++++++--------------- fs/xfs/xfs_inode.c | 3 --- 2 files changed, 8 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +8 -15
@@ -1717,7 +1717,7 @@ xfs_dialloc_roll(* This function will ensure that the selected AG has free inodes available to * allocate from. The selected AGI will be returned locked to the caller, and it * will allocate more free inodes if required. If no free inodes are found or -* can be allocated, no AGI will be returned. +* can be allocated, -ENOSPC be returned. */ int xfs_dialloc_select_ag(
@@ -1730,7 +1730,6 @@ xfs_dialloc_select_ag(struct xfs_buf *agbp;xfs_agnumber_t agno;int error; -bool noroom = false;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);
@@ -1744,7 +1743,7 @@ xfs_dialloc_select_ag(*/ start_agno =xfs_ialloc_ag_select (*tpp, parent, mode);if (start_agno ==NULLAGNUMBER ) -return 0 ; +return -ENOSPC ;/* * If we have already hit the ceiling of inode blocks then clear
@@ -1757,7 +1756,6 @@ xfs_dialloc_select_ag(if (igeo->maxicount &&percpu_counter_read_positive (&mp->m_icount) + igeo->ialloc_inos > igeo->maxicount) { - noroom = true; okalloc = false; }
@@ -1794,10 +1792,8 @@ xfs_dialloc_select_ag(if (error)break ; -if (pag->pagi_freecount) { -xfs_perag_put (pag); +if (pag->pagi_freecount) goto found_ag; - }if (!okalloc) goto nextag_relse_buffer;
@@ -1805,9 +1801,6 @@ xfs_dialloc_select_ag( error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp); - -if (error == -ENOSPC ) - error =0 ;break ; }
@@ -1818,12 +1811,11 @@ xfs_dialloc_select_ag(* allocate one of the new inodes. */ ASSERT (pag->pagi_freecount >0 ); -xfs_perag_put (pag); error =xfs_dialloc_roll (tpp, agbp);if (error) {xfs_buf_relse (agbp); -return error; +break ; } goto found_ag; }
@@ -1831,16 +1823,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -xfs_perag_put (pag);if (++agno == mp->m_sb.sb_agcount) agno =0 ;if (agno == start_agno) -return noroom ? -ENOSPC :0 ; +break ; +xfs_perag_put (pag); }xfs_perag_put (pag); -return error; +return error ? error : -ENOSPC ; found_ag: +xfs_perag_put (pag); *IO_agbp = agbp;return 0 ; }
fs/xfs/xfs_inode.c +0 -3
@@ -923,9 +923,6 @@ xfs_dir_ialloc(if (error)return error; -if (!agibp) -return -ENOSPC ; -/* Allocate an inode from the selected AG */ error =xfs_dialloc_ag (*tpp, agibp, parent_ino, &ino);if (error)
Signature · 1 line
2.31.1
Re: [PATCH 17/22] xfs: simplify xfs_dialloc_select_ag() return values
Quoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The only caller of
xfs_dialloc_select_ag()will always return-ENOSPCto it's caller if the agbp returned fromxfs_dialloc_select_ag()is NULL. IOWs, failure to find a candidate AGI we can allocate inodes from is always an ENOSPC condition, so move this logic up intoxfs_dialloc_select_ag()so we can simplify the return logic in this function.
Quoted 5 lines
xfs_dialloc_select_ag()now only ever returns 0 with a locked agbp, or an error with no agbp.Signed-off-by Dave Chinner <[email protected]>---
Quoted 116 lines
fs/xfs/libxfs/xfs_ialloc.c | 23 ++++++++--------------- fs/xfs/xfs_inode.c | 3 --- 2 files changed, 8 insertions(+), 18 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +8
-15@@ -1717,7 +1717,7 @@ xfs_dialloc_roll(* This function will ensure that the selected AG has free inodes available to * allocate from. The selected AGI will be returned locked to the caller, and it * will allocate more free inodes if required. If no free inodes are found or -* can be allocated, no AGI will be returned. +* can be allocated, -ENOSPC be returned. */ int xfs_dialloc_select_ag(@@ -1730,7 +1730,6 @@ xfs_dialloc_select_ag(struct xfs_buf *agbp;xfs_agnumber_t agno;int error; -bool noroom = false;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);@@ -1744,7 +1743,7 @@ xfs_dialloc_select_ag(*/ start_agno =xfs_ialloc_ag_select (*tpp, parent, mode);if (start_agno ==NULLAGNUMBER ) -return 0 ; +return -ENOSPC ;/* * If we have already hit the ceiling of inode blocks then clear @@ -1757,7 +1756,6 @@ xfs_dialloc_select_ag(if (igeo->maxicount &&percpu_counter_read_positive (&mp->m_icount) + igeo->ialloc_inos > igeo->maxicount) { - noroom = true; okalloc = false; }@@ -1794,10 +1792,8 @@ xfs_dialloc_select_ag(if (error)break ; -if (pag->pagi_freecount) { -xfs_perag_put (pag); +if (pag->pagi_freecount) goto found_ag; - }if (!okalloc) goto nextag_relse_buffer;@@ -1805,9 +1801,6 @@ xfs_dialloc_select_ag( error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp); - -if (error == -ENOSPC ) - error =0 ;break ; }@@ -1818,12 +1811,11 @@ xfs_dialloc_select_ag(* allocate one of the new inodes. */ ASSERT (pag->pagi_freecount >0 ); -xfs_perag_put (pag); error =xfs_dialloc_roll (tpp, agbp);if (error) {xfs_buf_relse (agbp); -return error; +break ; } goto found_ag; }@@ -1831,16 +1823,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -xfs_perag_put (pag);if (++agno == mp->m_sb.sb_agcount) agno =0 ;if (agno == start_agno) -return noroom ? -ENOSPC :0 ; +break ; +xfs_perag_put (pag); }xfs_perag_put (pag); -return error; +return error ? error : -ENOSPC ; found_ag: +xfs_perag_put (pag); *IO_agbp = agbp;return 0 ; }fs/xfs/xfs_inode.c +0
-3@@ -923,9 +923,6 @@ xfs_dir_ialloc(if (error)return error; -if (!agibp) -return -ENOSPC ; -/* Allocate an inode from the selected AG */ error =xfs_dialloc_ag (*tpp, agibp, parent_ino, &ino);if (error)Signature · 1 line
2.31.1
Re: [PATCH 17/22] xfs: simplify xfs_dialloc_select_ag() return values
In reply to Dave ChinnerQuoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The only caller of
xfs_dialloc_select_ag()will always return-ENOSPCto it's caller if the agbp returned fromxfs_dialloc_select_ag()is NULL. IOWs, failure to find a candidate AGI we can allocate inodes from is always an ENOSPC condition, so move this logic up intoxfs_dialloc_select_ag()so we can simplify the return logic in this function.
Quoted 4 lines
xfs_dialloc_select_ag()now only ever returns 0 with a locked agbp, or an error with no agbp.Signed-off-by Dave Chinner <[email protected]>
Woo nice cleanup!
--D
Quoted 117 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 23 ++++++++--------------- fs/xfs/xfs_inode.c | 3 --- 2 files changed, 8 insertions(+), 18 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +8
-15@@ -1717,7 +1717,7 @@ xfs_dialloc_roll(* This function will ensure that the selected AG has free inodes available to * allocate from. The selected AGI will be returned locked to the caller, and it * will allocate more free inodes if required. If no free inodes are found or -* can be allocated, no AGI will be returned. +* can be allocated, -ENOSPC be returned. */ int xfs_dialloc_select_ag(@@ -1730,7 +1730,6 @@ xfs_dialloc_select_ag(struct xfs_buf *agbp;xfs_agnumber_t agno;int error; -bool noroom = false;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);@@ -1744,7 +1743,7 @@ xfs_dialloc_select_ag(*/ start_agno =xfs_ialloc_ag_select (*tpp, parent, mode);if (start_agno ==NULLAGNUMBER ) -return 0 ; +return -ENOSPC ;/* * If we have already hit the ceiling of inode blocks then clear @@ -1757,7 +1756,6 @@ xfs_dialloc_select_ag(if (igeo->maxicount &&percpu_counter_read_positive (&mp->m_icount) + igeo->ialloc_inos > igeo->maxicount) { - noroom = true; okalloc = false; }@@ -1794,10 +1792,8 @@ xfs_dialloc_select_ag(if (error)break ; -if (pag->pagi_freecount) { -xfs_perag_put (pag); +if (pag->pagi_freecount) goto found_ag; - }if (!okalloc) goto nextag_relse_buffer;@@ -1805,9 +1801,6 @@ xfs_dialloc_select_ag( error =xfs_ialloc_ag_alloc (*tpp, agbp, pag);if (error <0 ) {xfs_trans_brelse (*tpp, agbp); - -if (error == -ENOSPC ) - error =0 ;break ; }@@ -1818,12 +1811,11 @@ xfs_dialloc_select_ag(* allocate one of the new inodes. */ ASSERT (pag->pagi_freecount >0 ); -xfs_perag_put (pag); error =xfs_dialloc_roll (tpp, agbp);if (error) {xfs_buf_relse (agbp); -return error; +break ; } goto found_ag; }@@ -1831,16 +1823,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -xfs_perag_put (pag);if (++agno == mp->m_sb.sb_agcount) agno =0 ;if (agno == start_agno) -return noroom ? -ENOSPC :0 ; +break ; +xfs_perag_put (pag); }xfs_perag_put (pag); -return error; +return error ? error : -ENOSPC ; found_ag: +xfs_perag_put (pag); *IO_agbp = agbp;return 0 ; }fs/xfs/xfs_inode.c +0
-3@@ -923,9 +923,6 @@ xfs_dir_ialloc(if (error)return error; -if (!agibp) -return -ENOSPC ; -/* Allocate an inode from the selected AG */ error =xfs_dialloc_ag (*tpp, agibp, parent_ino, &ino);if (error)Signature · 1 line
2.31.1
PATCH 18/22 xfs: collapse AG selection for inode allocation
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
xfs_dialloc_select_ag() does a lot of repetitive work. It first calls xfs_ialloc_ag_select() to select the AG to start allocation attempts in, which can do up to two entire loops across the perags that inodes can be allocated in. This is simply checking if there is spce available to allocate inodes in an AG, and it returns when it finds the first candidate AG.
xfs_dialloc_select_ag() then does it's own iterative walk across all the perags locking the AGIs and trying to allocate inodes from the locked AG. It also doesn't limit the search to mp->m_maxagi, so it will walk all AGs whether they can allocate inodes or not.
Hence if we are really low on inodes, we could do almost 3 entire walks across the whole perag range before we find an allocation group we can allocate inodes in or report ENOSPC.
Because xfs_ialloc_ag_select() returns on the first candidate AG it finds, we can simply do these checks directly in xfs_dialloc_select_ag() before we lock and try to allocate inodes. This reduces the inode allocation pass down to 2 perag sweeps at most - one for aligned inode cluster allocation and if we can't allocate full, aligned inode clusters anywhere we'll do another pass trying to do sparse inode cluster allocation.
This also removes a big chunk of duplicate code.
--- fs/xfs/libxfs/xfs_ialloc.c | 221 +++++++++++++------------------------ 1 file changed, 75 insertions(+), 146 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +75 -146
@@ -899,139 +899,6 @@ xfs_ialloc_ag_alloc(return 0 ; } -STATIC xfs_agnumber_t -xfs_ialloc_next_ag ( -xfs_mount_t *mp) -{ -xfs_agnumber_t agno; - -spin_lock (&mp->m_agirotor_lock); - agno = mp->m_agirotor; -if (++mp->m_agirotor >= mp->m_maxagi) - mp->m_agirotor =0 ; -spin_unlock (&mp->m_agirotor_lock); - -return agno; -} - -/* -* Select an allocation group to look for a free inode in, based on the parent -* inode and the mode. Return the allocation group buffer. -*/ -STATIC xfs_agnumber_t -xfs_ialloc_ag_select ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_ino_t parent,/* parent directory inode number */ -umode_t mode)/* bits set to indicate file type */ -{ -xfs_agnumber_t agcount;/* number of ag's in the filesystem */ -xfs_agnumber_t agno;/* current ag number */ -int flags;/* alloc buffer locking flags */ -xfs_extlen_t ineed;/* blocks needed for inode allocation */ -xfs_extlen_t longest =0 ;/* longest extent available */ -xfs_mount_t *mp;/* mount point structure */ -int needspace;/* file mode implies space allocated */ -xfs_perag_t *pag;/* per allocation group data */ -xfs_agnumber_t pagno;/* parent (starting) ag number */ -int error; - -/* -* Files of these types need at least one block if length > 0 -* (and they won't fit in the inode, but that's hard to figure out). -*/ - needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); - mp = tp->t_mountp; - agcount = mp->m_maxagi; -if (S_ISDIR (mode)) - pagno =xfs_ialloc_next_ag (mp); -else { - pagno =XFS_INO_TO_AGNO (mp, parent); -if (pagno >= agcount) - pagno =0 ; - } - -ASSERT (pagno < agcount); - -/* -* Loop through allocation groups, looking for one with a little -* free space in it. Note we don't look for free inodes, exactly. -* Instead, we include whether there is a need to allocate inodes -* to mean that blocks must be allocated for them, -* if none are currently free. -*/ - agno = pagno; - flags =XFS_ALLOC_FLAG_TRYLOCK ; -for (;;) { - pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) { -xfs_ialloc_next_ag (mp); - goto nextag; - } - -if (!pag->pagi_init) { - error =xfs_ialloc_pagi_init (mp, tp, agno); -if (error) - goto nextag; - } - -if (pag->pagi_freecount) { -xfs_perag_put (pag); -return agno; - } - -if (!pag->pagf_init) { - error =xfs_alloc_pagf_init (mp, tp, agno, flags); -if (error) - goto nextag; - } - -/* -* Check that there is enough free space for the file plus a -* chunk of inodes if we need to allocate some. If this is the -* first pass across the AGs, take into account the potential -* space needed for alignment of inode chunks when checking the -* longest contiguous free space in the AG - this prevents us -* from getting ENOSPC because we have free space larger than -* ialloc_blks but alignment constraints prevent us from using -* it. -* -* If we can't find an AG with space for full alignment slack to -* be taken into account, we must be near ENOSPC in all AGs. -* Hence we don't include alignment for the second pass and so -* if we fail allocation due to alignment issues then it is most -* likely a real ENOSPC condition. -*/ - ineed =M_IGEO (mp)->ialloc_min_blks; -if (flags && ineed >1 ) - ineed +=M_IGEO (mp)->cluster_align; - longest = pag->pagf_longest; -if (!longest) - longest = pag->pagf_flcount >0 ; - -if (pag->pagf_freeblks >= needspace + ineed && - longest >= ineed) { -xfs_perag_put (pag); -return agno; - } -nextag: -xfs_perag_put (pag); -/* -* No point in iterating over the rest, if we're shutting -* down. -*/ -if (XFS_FORCED_SHUTDOWN (mp)) -return NULLAGNUMBER ; - agno++; -if (agno >= agcount) - agno =0 ; -if (agno == pagno) { -if (flags ==0 ) -return NULLAGNUMBER ; - flags =0 ; - } - } -} -/* * Try to retrieve the next record to the left/right from the current one. */
@@ -1708,6 +1575,21 @@ xfs_dialloc_roll(return 0 ; } +STATIC xfs_agnumber_t +xfs_ialloc_next_ag ( +xfs_mount_t *mp) +{ +xfs_agnumber_t agno; + +spin_lock (&mp->m_agirotor_lock); + agno = mp->m_agirotor; +if (++mp->m_agirotor >= mp->m_maxagi) + mp->m_agirotor =0 ; +spin_unlock (&mp->m_agirotor_lock); + +return agno; +} +/* * Select and prepare an AG for inode allocation. *
@@ -1734,16 +1616,23 @@ xfs_dialloc_select_ag(struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true; +int needspace; +int flags; *IO_agbp =NULL ;/* -* We do not have an agbp, so select an initial allocation -* group for inode allocation. +* Files of these types need at least one block if length > 0 +* (and they won't fit in the inode, but that's hard to figure out). */ - start_agno =xfs_ialloc_ag_select (*tpp, parent, mode); -if (start_agno ==NULLAGNUMBER ) -return -ENOSPC ; + needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); +if (S_ISDIR (mode)) + start_agno =xfs_ialloc_next_ag (mp); +else { + start_agno =XFS_INO_TO_AGNO (mp, parent); +if (start_agno >= mp->m_maxagi) + start_agno =0 ; + }/* * If we have already hit the ceiling of inode blocks then clear
@@ -1765,12 +1654,14 @@ xfs_dialloc_select_ag(* allocation groups upward, wrapping at the end. */ agno = start_agno; + flags =XFS_ALLOC_FLAG_TRYLOCK ;for (;;) { +xfs_extlen_t ineed; +xfs_extlen_t longest =0 ; + pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) { -xfs_ialloc_next_ag (mp); +if (!pag->pagi_inodeok) goto nextag; - }if (!pag->pagi_init) { error =xfs_ialloc_pagi_init (mp, *tpp, agno);
@@ -1778,10 +1669,41 @@ xfs_dialloc_select_ag(break ; } +if (!pag->pagi_freecount) + goto nextag; +if (!okalloc) + goto nextag; + +if (!pag->pagf_init) { + error =xfs_alloc_pagf_init (mp, *tpp, agno, flags); +if (error) + goto nextag; + } +/* -* Do a first racy fast path check if this AG is usable. +* Check that there is enough free space for the file plus a +* chunk of inodes if we need to allocate some. If this is the +* first pass across the AGs, take into account the potential +* space needed for alignment of inode chunks when checking the +* longest contiguous free space in the AG - this prevents us +* from getting ENOSPC because we have free space larger than +* ialloc_blks but alignment constraints prevent us from using +* it. +* +* If we can't find an AG with space for full alignment slack to +* be taken into account, we must be near ENOSPC in all AGs. +* Hence we don't include alignment for the second pass and so +* if we fail allocation due to alignment issues then it is most +* likely a real ENOSPC condition. */ -if (!pag->pagi_freecount && !okalloc) + ineed =M_IGEO (mp)->ialloc_min_blks; +if (flags && ineed >1 ) + ineed +=M_IGEO (mp)->cluster_align; + longest = pag->pagf_longest; +if (!longest) + longest = pag->pagf_flcount >0 ; + +if (pag->pagf_freeblks < needspace + ineed || longest < ineed) goto nextag;/*
@@ -1823,10 +1745,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -if (++agno == mp->m_sb.sb_agcount) - agno =0 ; -if (agno == start_agno) +if (XFS_FORCED_SHUTDOWN (mp)) { + error = -EFSCORRUPTED ;break ; + } +if (++agno == mp->m_maxagi) + agno =0 ; +if (agno == start_agno) { +if (!flags) +break ; + flags =0 ; + }xfs_perag_put (pag); }
Signature · 1 line
2.31.1
Re: [PATCH 18/22] xfs: collapse AG selection for inode allocation
Quoted 37 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dialloc_select_ag()does a lot of repetitive work. It first callsxfs_ialloc_ag_select()to select the AG to start allocation attempts in, which can do up to two entire loops across the perags that inodes can be allocated in. This is simply checking if there is spce available to allocate inodes in an AG, and it returns when it finds the first candidate AG.
xfs_dialloc_select_ag()then does it's own iterative walk across all the perags locking the AGIs and trying to allocate inodes from the locked AG. It also doesn't limit the search tomp->m_maxagi, so it will walk all AGs whether they can allocate inodes or not.Hence if we are really low on inodes, we could do almost 3 entire walks across the whole perag range before we find an allocation group we can allocate inodes in or report ENOSPC.
Because
xfs_ialloc_ag_select()returns on the first candidate AG it finds, we can simply do these checks directly inxfs_dialloc_select_ag()before we lock and try to allocate inodes. This reduces the inode allocation pass down to 2 perag sweeps at most - one for aligned inode cluster allocation and if we can't allocate full, aligned inode clusters anywhere we'll do another pass trying to do sparse inode cluster allocation.This also removes a big chunk of duplicate code.
Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 221 +++++++++++++------------------------ 1 file changed, 75 insertions(+), 146 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +0
-0
...
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1673
Quoted 6 lines
fs/xfs/libxfs/xfs_ialloc.c +2
-0@@ -1778,10 +1669,41 @@ xfs_dialloc_select_ag(break ; } +if (!pag->pagi_freecount) + goto nextag;
It looks like this would never allow for allocation of new inode chunks..?
Quoted 26 lines
fs/xfs/libxfs/xfs_ialloc.c +23
-1+if (!okalloc) + goto nextag; + +if (!pag->pagf_init) { + error =xfs_alloc_pagf_init (mp, *tpp, agno, flags); +if (error) + goto nextag; + } +/* -* Do a first racy fast path check if this AG is usable. +* Check that there is enough free space for the file plus a +* chunk of inodes if we need to allocate some. If this is the +* first pass across the AGs, take into account the potential +* space needed for alignment of inode chunks when checking the +* longest contiguous free space in the AG - this prevents us +* from getting ENOSPC because we have free space larger than +* ialloc_blks but alignment constraints prevent us from using +* it. +* +* If we can't find an AG with space for full alignment slack to +* be taken into account, we must be near ENOSPC in all AGs. +* Hence we don't include alignment for the second pass and so +* if we fail allocation due to alignment issues then it is most +* likely a real ENOSPC condition. */
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1707
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c +8
-1-if (!pag->pagi_freecount && !okalloc) + ineed =M_IGEO (mp)->ialloc_min_blks; +if (flags && ineed >1 ) + ineed +=M_IGEO (mp)->cluster_align; + longest = pag->pagf_longest; +if (!longest) + longest = pag->pagf_flcount >0 ; + +if (pag->pagf_freeblks < needspace + ineed || longest < ineed) goto nextag;
... and here we check for enough free space in the AG for chunk allocation purposes. The pagi_freecount check is further down, however, so it looks like we can skip the AG even if pagi_freecount > 0 and allocation is not necessary.
Brian
Quoted 26 lines
fs/xfs/libxfs/xfs_ialloc.c +10
-3/* @@ -1823,10 +1745,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -if (++agno == mp->m_sb.sb_agcount) - agno =0 ; -if (agno == start_agno) +if (XFS_FORCED_SHUTDOWN (mp)) { + error = -EFSCORRUPTED ;break ; + } +if (++agno == mp->m_maxagi) + agno =0 ; +if (agno == start_agno) { +if (!flags) +break ; + flags =0 ; + }xfs_perag_put (pag); }Signature · 1 line
2.31.1
Re: [PATCH 18/22] xfs: collapse AG selection for inode allocation
Quoted 43 lines · Brian Foster
Quoted 37 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dialloc_select_ag()does a lot of repetitive work. It first callsxfs_ialloc_ag_select()to select the AG to start allocation attempts in, which can do up to two entire loops across the perags that inodes can be allocated in. This is simply checking if there is spce available to allocate inodes in an AG, and it returns when it finds the first candidate AG.
xfs_dialloc_select_ag()then does it's own iterative walk across all the perags locking the AGIs and trying to allocate inodes from the locked AG. It also doesn't limit the search tomp->m_maxagi, so it will walk all AGs whether they can allocate inodes or not.Hence if we are really low on inodes, we could do almost 3 entire walks across the whole perag range before we find an allocation group we can allocate inodes in or report ENOSPC.
Because
xfs_ialloc_ag_select()returns on the first candidate AG it finds, we can simply do these checks directly inxfs_dialloc_select_ag()before we lock and try to allocate inodes. This reduces the inode allocation pass down to 2 perag sweeps at most - one for aligned inode cluster allocation and if we can't allocate full, aligned inode clusters anywhere we'll do another pass trying to do sparse inode cluster allocation.This also removes a big chunk of duplicate code.
Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 221 +++++++++++++------------------------ 1 file changed, 75 insertions(+), 146 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +0
-0...
Quoted 4 lines
fs/xfs/libxfs/xfs_ialloc.c +0
-0@@ -1778,10 +1669,41 @@ xfs_dialloc_select_ag(break ; }
Quoted 8 lines
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1673
Quoted 2 lines
fs/xfs/libxfs/xfs_ialloc.c +2
-0+if (!pag->pagi_freecount) + goto nextag;It looks like this would never allow for allocation of new inode chunks..?
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1675
Quoted 2 lines
fs/xfs/libxfs/xfs_ialloc.c +2
-0+if (!okalloc) + goto nextag;
I guess I never tested this patch in isolation, and I fixed the bug in one of the following patches. This should be:
if (!pag->pagi_freecount && !okalloc) goto nextag;
Fixed.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 18/22] xfs: collapse AG selection for inode allocation
In reply to Dave ChinnerQuoted 26 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dialloc_select_ag()does a lot of repetitive work. It first callsxfs_ialloc_ag_select()to select the AG to start allocation attempts in, which can do up to two entire loops across the perags that inodes can be allocated in. This is simply checking if there is spce available to allocate inodes in an AG, and it returns when it finds the first candidate AG.
xfs_dialloc_select_ag()then does it's own iterative walk across all the perags locking the AGIs and trying to allocate inodes from the locked AG. It also doesn't limit the search tomp->m_maxagi, so it will walk all AGs whether they can allocate inodes or not.Hence if we are really low on inodes, we could do almost 3 entire walks across the whole perag range before we find an allocation group we can allocate inodes in or report ENOSPC.
Because
xfs_ialloc_ag_select()returns on the first candidate AG it finds, we can simply do these checks directly inxfs_dialloc_select_ag()before we lock and try to allocate inodes. This reduces the inode allocation pass down to 2 perag sweeps at most - one for aligned inode cluster allocation and if we can't allocate full, aligned inode clusters anywhere we'll do another pass trying to do sparse inode cluster allocation.
Quoted 1 line
This also removes a big chunk of duplicate code.
Soooooo... we did an AG walk to pick the optimal starting point of an AG walk? Heh.
Quoted 176 lines
Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 221 +++++++++++++------------------------ 1 file changed, 75 insertions(+), 146 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +15
-133@@ -899,139 +899,6 @@ xfs_ialloc_ag_alloc(return 0 ; } -STATIC xfs_agnumber_t -xfs_ialloc_next_ag ( -xfs_mount_t *mp) -{ -xfs_agnumber_t agno; - -spin_lock (&mp->m_agirotor_lock); - agno = mp->m_agirotor; -if (++mp->m_agirotor >= mp->m_maxagi) - mp->m_agirotor =0 ; -spin_unlock (&mp->m_agirotor_lock); - -return agno; -} - -/* -* Select an allocation group to look for a free inode in, based on the parent -* inode and the mode. Return the allocation group buffer. -*/ -STATIC xfs_agnumber_t -xfs_ialloc_ag_select ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_ino_t parent,/* parent directory inode number */ -umode_t mode)/* bits set to indicate file type */ -{ -xfs_agnumber_t agcount;/* number of ag's in the filesystem */ -xfs_agnumber_t agno;/* current ag number */ -int flags;/* alloc buffer locking flags */ -xfs_extlen_t ineed;/* blocks needed for inode allocation */ -xfs_extlen_t longest =0 ;/* longest extent available */ -xfs_mount_t *mp;/* mount point structure */ -int needspace;/* file mode implies space allocated */ -xfs_perag_t *pag;/* per allocation group data */ -xfs_agnumber_t pagno;/* parent (starting) ag number */ -int error; - -/* -* Files of these types need at least one block if length > 0 -* (and they won't fit in the inode, but that's hard to figure out). -*/ - needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); - mp = tp->t_mountp; - agcount = mp->m_maxagi; -if (S_ISDIR (mode)) - pagno =xfs_ialloc_next_ag (mp); -else { - pagno =XFS_INO_TO_AGNO (mp, parent); -if (pagno >= agcount) - pagno =0 ; - } - -ASSERT (pagno < agcount); - -/* -* Loop through allocation groups, looking for one with a little -* free space in it. Note we don't look for free inodes, exactly. -* Instead, we include whether there is a need to allocate inodes -* to mean that blocks must be allocated for them, -* if none are currently free. -*/ - agno = pagno; - flags =XFS_ALLOC_FLAG_TRYLOCK ; -for (;;) { - pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) { -xfs_ialloc_next_ag (mp); - goto nextag; - } - -if (!pag->pagi_init) { - error =xfs_ialloc_pagi_init (mp, tp, agno); -if (error) - goto nextag; - } - -if (pag->pagi_freecount) { -xfs_perag_put (pag); -return agno; - } - -if (!pag->pagf_init) { - error =xfs_alloc_pagf_init (mp, tp, agno, flags); -if (error) - goto nextag; - } - -/* -* Check that there is enough free space for the file plus a -* chunk of inodes if we need to allocate some. If this is the -* first pass across the AGs, take into account the potential -* space needed for alignment of inode chunks when checking the -* longest contiguous free space in the AG - this prevents us -* from getting ENOSPC because we have free space larger than -* ialloc_blks but alignment constraints prevent us from using -* it. -* -* If we can't find an AG with space for full alignment slack to -* be taken into account, we must be near ENOSPC in all AGs. -* Hence we don't include alignment for the second pass and so -* if we fail allocation due to alignment issues then it is most -* likely a real ENOSPC condition. -*/ - ineed =M_IGEO (mp)->ialloc_min_blks; -if (flags && ineed >1 ) - ineed +=M_IGEO (mp)->cluster_align; - longest = pag->pagf_longest; -if (!longest) - longest = pag->pagf_flcount >0 ; - -if (pag->pagf_freeblks >= needspace + ineed && - longest >= ineed) { -xfs_perag_put (pag); -return agno; - } -nextag: -xfs_perag_put (pag); -/* -* No point in iterating over the rest, if we're shutting -* down. -*/ -if (XFS_FORCED_SHUTDOWN (mp)) -return NULLAGNUMBER ; - agno++; -if (agno >= agcount) - agno =0 ; -if (agno == pagno) { -if (flags ==0 ) -return NULLAGNUMBER ; - flags =0 ; - } - } -} -/* * Try to retrieve the next record to the left/right from the current one. */ @@ -1708,6 +1575,21 @@ xfs_dialloc_roll(return 0 ; } +STATIC xfs_agnumber_t +xfs_ialloc_next_ag ( +xfs_mount_t *mp) +{ +xfs_agnumber_t agno; + +spin_lock (&mp->m_agirotor_lock); + agno = mp->m_agirotor; +if (++mp->m_agirotor >= mp->m_maxagi) + mp->m_agirotor =0 ; +spin_unlock (&mp->m_agirotor_lock); + +return agno; +} +/* * Select and prepare an AG for inode allocation. * @@ -1734,16 +1616,23 @@ xfs_dialloc_select_ag(struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true;
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1626
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c +4
-2+int needspace; +int flags; *IO_agbp =NULL ;/* -* We do not have an agbp, so select an initial allocation -* group for inode allocation. +* Files of these types need at least one block if length > 0 +* (and they won't fit in the inode, but that's hard to figure out).
Uh, what is length here? Seeing as most directories and symlinks probably end up in local format, is this needspace computation really true?
I guess it doesn't hurt to be cautious and assume that directories can expand and that people are aggressively symlinking. But maybe this comment could be rephrased to something like:
/* * Directories, symlinks, and regular files frequently allocate * at least one block, so factor that potential expansion when * we examine whether an AG has enough space for file creation. */ needspace = S_ISDIR(mode)...;
With that clarified,
--D
Quoted 101 lines
fs/xfs/libxfs/xfs_ialloc.c +56
-11*/ - start_agno =xfs_ialloc_ag_select (*tpp, parent, mode); -if (start_agno ==NULLAGNUMBER ) -return -ENOSPC ; + needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); +if (S_ISDIR (mode)) + start_agno =xfs_ialloc_next_ag (mp); +else { + start_agno =XFS_INO_TO_AGNO (mp, parent); +if (start_agno >= mp->m_maxagi) + start_agno =0 ; + }/* * If we have already hit the ceiling of inode blocks then clear @@ -1765,12 +1654,14 @@ xfs_dialloc_select_ag(* allocation groups upward, wrapping at the end. */ agno = start_agno; + flags =XFS_ALLOC_FLAG_TRYLOCK ;for (;;) { +xfs_extlen_t ineed; +xfs_extlen_t longest =0 ; + pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) { -xfs_ialloc_next_ag (mp); +if (!pag->pagi_inodeok) goto nextag; - }if (!pag->pagi_init) { error =xfs_ialloc_pagi_init (mp, *tpp, agno);@@ -1778,10 +1669,41 @@ xfs_dialloc_select_ag(break ; } +if (!pag->pagi_freecount) + goto nextag; +if (!okalloc) + goto nextag; + +if (!pag->pagf_init) { + error =xfs_alloc_pagf_init (mp, *tpp, agno, flags); +if (error) + goto nextag; + } +/* -* Do a first racy fast path check if this AG is usable. +* Check that there is enough free space for the file plus a +* chunk of inodes if we need to allocate some. If this is the +* first pass across the AGs, take into account the potential +* space needed for alignment of inode chunks when checking the +* longest contiguous free space in the AG - this prevents us +* from getting ENOSPC because we have free space larger than +* ialloc_blks but alignment constraints prevent us from using +* it. +* +* If we can't find an AG with space for full alignment slack to +* be taken into account, we must be near ENOSPC in all AGs. +* Hence we don't include alignment for the second pass and so +* if we fail allocation due to alignment issues then it is most +* likely a real ENOSPC condition. */ -if (!pag->pagi_freecount && !okalloc) + ineed =M_IGEO (mp)->ialloc_min_blks; +if (flags && ineed >1 ) + ineed +=M_IGEO (mp)->cluster_align; + longest = pag->pagf_longest; +if (!longest) + longest = pag->pagf_flcount >0 ; + +if (pag->pagf_freeblks < needspace + ineed || longest < ineed) goto nextag;/* @@ -1823,10 +1745,17 @@ xfs_dialloc_select_ag( nextag_relse_buffer:xfs_trans_brelse (*tpp, agbp); nextag: -if (++agno == mp->m_sb.sb_agcount) - agno =0 ; -if (agno == start_agno) +if (XFS_FORCED_SHUTDOWN (mp)) { + error = -EFSCORRUPTED ;break ; + } +if (++agno == mp->m_maxagi) + agno =0 ; +if (agno == start_agno) { +if (!flags) +break ; + flags =0 ; + }xfs_perag_put (pag); }Signature · 1 line
2.31.1
Re: [PATCH 18/22] xfs: collapse AG selection for inode allocation
Quoted 27 lines · Darrick J. Wong
Quoted 26 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dialloc_select_ag()does a lot of repetitive work. It first callsxfs_ialloc_ag_select()to select the AG to start allocation attempts in, which can do up to two entire loops across the perags that inodes can be allocated in. This is simply checking if there is spce available to allocate inodes in an AG, and it returns when it finds the first candidate AG.
xfs_dialloc_select_ag()then does it's own iterative walk across all the perags locking the AGIs and trying to allocate inodes from the locked AG. It also doesn't limit the search tomp->m_maxagi, so it will walk all AGs whether they can allocate inodes or not.Hence if we are really low on inodes, we could do almost 3 entire walks across the whole perag range before we find an allocation group we can allocate inodes in or report ENOSPC.
Because
xfs_ialloc_ag_select()returns on the first candidate AG it finds, we can simply do these checks directly inxfs_dialloc_select_ag()before we lock and try to allocate inodes. This reduces the inode allocation pass down to 2 perag sweeps at most - one for aligned inode cluster allocation and if we can't allocate full, aligned inode clusters anywhere we'll do another pass trying to do sparse inode cluster allocation.
Quoted 4 lines
Quoted 1 line
This also removes a big chunk of duplicate code.
Soooooo... we did an AG walk to pick the optimal starting point of an AG walk? Heh.
yup.
Quoted 9 lines
Quoted 9 lines
fs/xfs/libxfs/xfs_ialloc.c +2
-0@@ -1734,16 +1616,23 @@ xfs_dialloc_select_ag(struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true; +int needspace; +int flags; *IO_agbp =NULL ;
Quoted 9 lines
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc_select_ag( · line 1626
Quoted 5 lines
fs/xfs/libxfs/xfs_ialloc.c +2
-2/* -* We do not have an agbp, so select an initial allocation -* group for inode allocation. +* Files of these types need at least one block if length > 0 +* (and they won't fit in the inode, but that's hard to figure out). Uh, what is length here? Seeing as most directories and symlinks probably end up in local format, is this needspace computation really true?
Ah, that's the exact text from the comment in xfs_ialloc_ag_select() above the needspace calculation - I didn't actually change it at all. :/
Quoted 11 lines
I guess it doesn't hurt to be cautious and assume that directories can expand and that people are aggressively symlinking. But maybe this comment could be rephrased to something like:
/* * Directories, symlinks, and regular files frequently allocate * at least one block, so factor that potential expansion when * we examine whether an AG has enough space for file creation. */ needspace = S_ISDIR(mode)...;
Quoted 2 lines
With that clarified,
Reviewed-by Darrick J. Wong <[email protected]>
Changed.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 19/22 xfs: get rid of xfs_dir_ialloc()
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
This is just a simple wrapper around the per-ag inode allocation that doesn't need to exist. The internal mechanism to select and allocate within an AG does not need to be exposed outside xfs_ialloc.c, and it being exposed simply makes it harder to follow the code and simplify it.
This is simplified by internalising xf_dialloc_select_ag() and xfs_dialloc_ag() into a single xfs_dialloc() function and then xfs_dir_ialloc() can go away.
--- fs/xfs/libxfs/xfs_ialloc.c | 15 +++++---- fs/xfs/libxfs/xfs_ialloc.h | 27 +++------------- fs/xfs/xfs_inode.c | 66 +++++++------------------------------- fs/xfs/xfs_inode.h | 9 +++--- fs/xfs/xfs_qm.c | 9 ++++-- fs/xfs/xfs_symlink.c | 9 ++++-- 6 files changed, 43 insertions(+), 92 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +9 -6
@@ -1602,24 +1602,23 @@ xfs_ialloc_next_ag(* can be allocated, -ENOSPC be returned. */ int -xfs_dialloc_select_ag ( +xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, -struct xfs_buf **IO_agbp) +xfs_ino_t *new_ino) {struct xfs_mount *mp = (*tpp)->t_mountp;struct xfs_buf *agbp;xfs_agnumber_t agno; -int error; +int error =0 ;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true;int needspace;int flags; - - *IO_agbp =NULL ; +xfs_ino_t ino;/* * Files of these types need at least one block if length > 0
@@ -1763,7 +1762,11 @@ xfs_dialloc_select_ag(return error ? error : -ENOSPC ; found_ag:xfs_perag_put (pag); - *IO_agbp = agbp; +/* Allocate an inode in the found AG */ + error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); +if (error) +return error; + *new_ino = ino;return 0 ; }
fs/xfs/libxfs/xfs_ialloc.h +4 -23
@@ -33,30 +33,11 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) }/* -* Allocate an inode on disk. -* Mode is used to tell whether the new inode will need space, and whether -* it is a directory. -* -* There are two phases to inode allocation: selecting an AG and ensuring -* that it contains free inodes, followed by allocating one of the free -* inodes. xfs_dialloc_select_ag() does the former and returns a locked AGI -* to the caller, ensuring that followup call to xfs_dialloc_ag() will -* have free inodes to allocate from. xfs_dialloc_ag() will return the inode -* number of the free inode we allocated. +* Allocate an inode on disk. Mode is used to tell whether the new inode will +* need space, and whether it is a directory. */ -int /* error */ -xfs_dialloc_select_ag ( -struct xfs_trans **tpp,/* double pointer of transaction */ -xfs_ino_t parent,/* parent inode (directory) */ -umode_t mode,/* mode bits for new inode */ -struct xfs_buf **IO_agbp); - -int -xfs_dialloc_ag ( -struct xfs_trans *tp, -struct xfs_buf *agbp, -xfs_ino_t parent, -xfs_ino_t *inop); +int xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, +xfs_ino_t *new_ino);/* * Free disk inode. Carefully avoids touching the incore inode, all
fs/xfs/xfs_inode.c +12 -54
107 lines not on this page · raw message
fs/xfs/xfs_inode.h +4 -5
@@ -431,11 +431,10 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,xfs_extlen_t xfs_get_extsz_hint (struct xfs_inode *ip);xfs_extlen_t xfs_get_cowextsz_hint (struct xfs_inode *ip); -int xfs_dir_ialloc (struct user_namespace *mnt_userns, -struct xfs_trans **tpp,struct xfs_inode *dp, -umode_t mode,xfs_nlink_t nlink,dev_t dev, -prid_t prid,bool need_xattr, -struct xfs_inode **ipp); +int xfs_init_new_inode (struct user_namespace *mnt_userns,struct xfs_trans *tp, +struct xfs_inode *pip,xfs_ino_t ino,umode_t mode, +xfs_nlink_t nlink,dev_t rdev,prid_t prid,bool init_xattrs, +struct xfs_inode **ipp);static inline int xfs_itruncate_extents(
fs/xfs/xfs_qm.c +7 -2
@@ -24,6 +24,7 @@#include "xfs_icache.h" #include "xfs_error.h" #include "xfs_ag.h" +#include "xfs_ialloc.h" /* * The global quota manager. There is only one of these for the entire
@@ -788,8 +789,12 @@ xfs_qm_qino_alloc(return error;if (need_alloc) { - error =xfs_dir_ialloc (&init_user_ns, &tp,NULL ,S_IFREG ,1 ,0 , -0 , false, ipp); +xfs_ino_t ino; + + error =xfs_dialloc (&tp,0 ,S_IFREG , &ino); +if (!error) + error =xfs_init_new_inode (&init_user_ns, tp,NULL , ino, +S_IFREG ,1 ,0 ,0 , false, ipp);if (error) {xfs_trans_cancel (tp);return error;
fs/xfs/xfs_symlink.c +7 -2
@@ -21,6 +21,7 @@#include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_trans.h" +#include "xfs_ialloc.h" /* ----- Kernel only functions below ----- */ int
@@ -161,6 +162,7 @@ xfs_symlink(struct xfs_dquot *gdqp =NULL ;struct xfs_dquot *pdqp =NULL ;uint resblks; +xfs_ino_t ino; *ipp =NULL ;
@@ -223,8 +225,11 @@ xfs_symlink(/* * Allocate an inode for the symlink. */ - error =xfs_dir_ialloc (mnt_userns, &tp, dp,S_IFLNK | (mode & ~S_IFMT ), -1 ,0 , prid, false, &ip); + error =xfs_dialloc (&tp, dp->i_ino,S_IFLNK , &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, +S_IFLNK | (mode & ~S_IFMT ),1 ,0 , prid, + false, &ip);if (error) goto out_trans_cancel;
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH 19/22] xfs: get rid of xfs_dir_ialloc()
Thank you for the patch! Perhaps something to improve:
Hi Dave,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on next-20210506]
[cannot apply to v5.12]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dave-Chinner/xfs-initial-agnumber-perag-conversions-for-shrink/20210506-154106 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next config: x86_64-randconfig-s021-20210506 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.3-341-g8af24329-dirty # https://github.com/0day-ci/linux/commit/193950fea5de60d6cc113c09886d30f577bfba96 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Dave-Chinner/xfs-initial-agnumber-perag-conversions-for-shrink/20210506-154106 git checkout 193950fea5de60d6cc113c09886d30f577bfba96 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> fs/xfs/libxfs/xfs_ialloc.c:1432:1: sparse: sparse: symbol 'xfs_dialloc_ag' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build bot[RFC PATCH] xfs: xfs_dialloc_ag can be static
In reply to Dave Chinnerfs/xfs/libxfs/xfs_ialloc.c:1432:1: warning: symbol 'xfs_dialloc_ag' was not declared. Should it be static?
fs/xfs/libxfs/xfs_ialloc.c:1432:1: warning: symbol 'xfs_dialloc_ag' was not declared. Should it be static?
--- xfs_ialloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_ialloc.c +1 -1
@@ -1428,7 +1428,7 @@ xfs_dialloc_ag_update_inobt(* The caller selected an AG for us, and made sure that free inodes are * available. */ -int +static int xfs_dialloc_ag( struct xfs_trans *tp, struct xfs_buf *agbp,
Re: [PATCH 19/22] xfs: get rid of xfs_dir_ialloc()
In reply to Dave ChinnerQuoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This is just a simple wrapper around the per-ag inode allocation that doesn't need to exist. The internal mechanism to select and allocate within an AG does not need to be exposed outside
xfs_ialloc.c, and it being exposed simply makes it harder to follow the code and simplify it.
Quoted 6 lines
This is simplified by internalising
xf_dialloc_select_ag()andxfs_dialloc_ag()into a singlexfs_dialloc()function and thenxfs_dir_ialloc()can go away.Signed-off-by Dave Chinner <[email protected]>---
Looks fine to me modulo the kernel robot thing:
Quoted 294 lines
fs/xfs/libxfs/xfs_ialloc.c | 15 +++++---- fs/xfs/libxfs/xfs_ialloc.h | 27 +++------------- fs/xfs/xfs_inode.c | 66 +++++++------------------------------- fs/xfs/xfs_inode.h | 9 +++--- fs/xfs/xfs_qm.c | 9 ++++-- fs/xfs/xfs_symlink.c | 9 ++++-- 6 files changed, 43 insertions(+), 92 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +9
-6@@ -1602,24 +1602,23 @@ xfs_ialloc_next_ag(* can be allocated, -ENOSPC be returned. */ int -xfs_dialloc_select_ag ( +xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, -struct xfs_buf **IO_agbp) +xfs_ino_t *new_ino) {struct xfs_mount *mp = (*tpp)->t_mountp;struct xfs_buf *agbp;xfs_agnumber_t agno; -int error; +int error =0 ;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true;int needspace;int flags; - - *IO_agbp =NULL ; +xfs_ino_t ino;/* * Files of these types need at least one block if length > 0 @@ -1763,7 +1762,11 @@ xfs_dialloc_select_ag(return error ? error : -ENOSPC ; found_ag:xfs_perag_put (pag); - *IO_agbp = agbp; +/* Allocate an inode in the found AG */ + error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); +if (error) +return error; + *new_ino = ino;return 0 ; }fs/xfs/libxfs/xfs_ialloc.h +4
-23@@ -33,30 +33,11 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) }/* -* Allocate an inode on disk. -* Mode is used to tell whether the new inode will need space, and whether -* it is a directory. -* -* There are two phases to inode allocation: selecting an AG and ensuring -* that it contains free inodes, followed by allocating one of the free -* inodes. xfs_dialloc_select_ag() does the former and returns a locked AGI -* to the caller, ensuring that followup call to xfs_dialloc_ag() will -* have free inodes to allocate from. xfs_dialloc_ag() will return the inode -* number of the free inode we allocated. +* Allocate an inode on disk. Mode is used to tell whether the new inode will +* need space, and whether it is a directory. */ -int /* error */ -xfs_dialloc_select_ag ( -struct xfs_trans **tpp,/* double pointer of transaction */ -xfs_ino_t parent,/* parent inode (directory) */ -umode_t mode,/* mode bits for new inode */ -struct xfs_buf **IO_agbp); - -int -xfs_dialloc_ag ( -struct xfs_trans *tp, -struct xfs_buf *agbp, -xfs_ino_t parent, -xfs_ino_t *inop); +int xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, +xfs_ino_t *new_ino);/* * Free disk inode. Carefully avoids touching the incore inode, all fs/xfs/xfs_inode.c +12
-54@@ -749,7 +749,7 @@ xfs_inode_inherit_flags2(* Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. */ -static int +int xfs_init_new_inode( struct user_namespace *mnt_userns, struct xfs_trans *tp,@@ -885,54 +885,6 @@ xfs_init_new_inode(return 0 ; } -/* -* Allocates a new inode from disk and return a pointer to the incore copy. This -* routine will internally commit the current transaction and allocate a new one -* if we needed to allocate more on-disk free inodes to perform the requested -* operation. -* -* If we are allocating quota inodes, we do not have a parent inode to attach to -* or associate with (i.e. dp == NULL) because they are not linked into the -* directory structure - they are attached directly to the superblock - and so -* have no parent. -*/ -int -xfs_dir_ialloc ( -struct user_namespace *mnt_userns, -struct xfs_trans **tpp, -struct xfs_inode *dp, -umode_t mode, -xfs_nlink_t nlink, -dev_t rdev, -prid_t prid, -bool init_xattrs, -struct xfs_inode **ipp) -{ -struct xfs_buf *agibp; -xfs_ino_t parent_ino = dp ? dp->i_ino :0 ; -xfs_ino_t ino; -int error; - -ASSERT ((*tpp)->t_flags &XFS_TRANS_PERM_LOG_RES ); - -/* -* Call the space management code to pick the on-disk inode to be -* allocated. -*/ - error =xfs_dialloc_select_ag (tpp, parent_ino, mode, &agibp); -if (error) -return error; - -/* Allocate an inode from the selected AG */ - error =xfs_dialloc_ag (*tpp, agibp, parent_ino, &ino); -if (error) -return error; -ASSERT (ino !=NULLFSINO ); - -return xfs_init_new_inode (mnt_userns, *tpp, dp, ino, mode, nlink, rdev, - prid, init_xattrs, ipp); -} -/* * Decrement the link count on an inode & log the change. If this causes the * link count to go to zero, move the inode to AGI unlinked list so that it can @@ -990,6 +942,7 @@ xfs_create(struct xfs_dquot *pdqp =NULL ;struct xfs_trans_res *tres;uint resblks; +xfs_ino_t ino;trace_xfs_create (dp, name);@@ -1046,14 +999,16 @@ xfs_create(* entry pointing to them, but a directory also the "." entry * pointing to itself. */ - error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode, is_dir ?2 :1 , rdev, - prid, init_xattrs, &ip); + error =xfs_dialloc (&tp, dp->i_ino, mode, &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, mode, + is_dir ?2 :1 , rdev, prid, init_xattrs, &ip);if (error) goto out_trans_cancel;/* * Now we join the directory inode to the transaction. We do not do it -* earlier because xfs_dir_ialloc might commit the previous transaction +* earlier because xfs_dialloc might commit the previous transaction * (and release all the locks). An error from here on will result in * the transaction cancel unlocking dp so don't do it explicitly in the * error path. @@ -1143,6 +1098,7 @@ xfs_create_tmpfile(struct xfs_dquot *pdqp =NULL ;struct xfs_trans_res *tres;uint resblks; +xfs_ino_t ino;if (XFS_FORCED_SHUTDOWN (mp))return -EIO ;@@ -1167,8 +1123,10 @@ xfs_create_tmpfile(if (error) goto out_release_dquots; - error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode,0 ,0 , prid, - false, &ip); + error =xfs_dialloc (&tp, dp->i_ino, mode, &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, mode, +0 ,0 , prid, false, &ip);if (error) goto out_trans_cancel;fs/xfs/xfs_inode.h +4
-5@@ -431,11 +431,10 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,xfs_extlen_t xfs_get_extsz_hint (struct xfs_inode *ip);xfs_extlen_t xfs_get_cowextsz_hint (struct xfs_inode *ip); -int xfs_dir_ialloc (struct user_namespace *mnt_userns, -struct xfs_trans **tpp,struct xfs_inode *dp, -umode_t mode,xfs_nlink_t nlink,dev_t dev, -prid_t prid,bool need_xattr, -struct xfs_inode **ipp); +int xfs_init_new_inode (struct user_namespace *mnt_userns,struct xfs_trans *tp, +struct xfs_inode *pip,xfs_ino_t ino,umode_t mode, +xfs_nlink_t nlink,dev_t rdev,prid_t prid,bool init_xattrs, +struct xfs_inode **ipp);static inline int xfs_itruncate_extents(fs/xfs/xfs_qm.c +7
-2@@ -24,6 +24,7 @@#include "xfs_icache.h" #include "xfs_error.h" #include "xfs_ag.h" +#include "xfs_ialloc.h" /* * The global quota manager. There is only one of these for the entire @@ -788,8 +789,12 @@ xfs_qm_qino_alloc(return error;if (need_alloc) { - error =xfs_dir_ialloc (&init_user_ns, &tp,NULL ,S_IFREG ,1 ,0 , -0 , false, ipp); +xfs_ino_t ino; + + error =xfs_dialloc (&tp,0 ,S_IFREG , &ino); +if (!error) + error =xfs_init_new_inode (&init_user_ns, tp,NULL , ino, +S_IFREG ,1 ,0 ,0 , false, ipp);if (error) {xfs_trans_cancel (tp);return error;fs/xfs/xfs_symlink.c +7
-2@@ -21,6 +21,7 @@#include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_trans.h" +#include "xfs_ialloc.h" /* ----- Kernel only functions below ----- */ int @@ -161,6 +162,7 @@ xfs_symlink(struct xfs_dquot *gdqp =NULL ;struct xfs_dquot *pdqp =NULL ;uint resblks; +xfs_ino_t ino; *ipp =NULL ;@@ -223,8 +225,11 @@ xfs_symlink(/* * Allocate an inode for the symlink. */ - error =xfs_dir_ialloc (mnt_userns, &tp, dp,S_IFLNK | (mode & ~S_IFMT ), -1 ,0 , prid, false, &ip); + error =xfs_dialloc (&tp, dp->i_ino,S_IFLNK , &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, +S_IFLNK | (mode & ~S_IFMT ),1 ,0 , prid, + false, &ip);if (error) goto out_trans_cancel;Signature · 1 line
2.31.1
Re: [PATCH 19/22] xfs: get rid of xfs_dir_ialloc()
In reply to Dave ChinnerQuoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This is just a simple wrapper around the per-ag inode allocation that doesn't need to exist. The internal mechanism to select and allocate within an AG does not need to be exposed outside
xfs_ialloc.c, and it being exposed simply makes it harder to follow the code and simplify it.
Quoted 5 lines
This is simplified by internalising
xf_dialloc_select_ag()andxfs_dialloc_ag()into a singlexfs_dialloc()function and thenxfs_dir_ialloc()can go away.Signed-off-by Dave Chinner <[email protected]>
Aha, I see what you did here with disappearing xfs_dialloc_select_ag. Ignore my later comments about 5.11 and whatnot.
This'll cause some churn in the metadata directory tree patchset, but it's not like that hasn't happened 5x before. :P
--D
Quoted 295 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 15 +++++---- fs/xfs/libxfs/xfs_ialloc.h | 27 +++------------- fs/xfs/xfs_inode.c | 66 +++++++------------------------------- fs/xfs/xfs_inode.h | 9 +++--- fs/xfs/xfs_qm.c | 9 ++++-- fs/xfs/xfs_symlink.c | 9 ++++-- 6 files changed, 43 insertions(+), 92 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +9
-6@@ -1602,24 +1602,23 @@ xfs_ialloc_next_ag(* can be allocated, -ENOSPC be returned. */ int -xfs_dialloc_select_ag ( +xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, -struct xfs_buf **IO_agbp) +xfs_ino_t *new_ino) {struct xfs_mount *mp = (*tpp)->t_mountp;struct xfs_buf *agbp;xfs_agnumber_t agno; -int error; +int error =0 ;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp);bool okalloc = true;int needspace;int flags; - - *IO_agbp =NULL ; +xfs_ino_t ino;/* * Files of these types need at least one block if length > 0 @@ -1763,7 +1762,11 @@ xfs_dialloc_select_ag(return error ? error : -ENOSPC ; found_ag:xfs_perag_put (pag); - *IO_agbp = agbp; +/* Allocate an inode in the found AG */ + error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); +if (error) +return error; + *new_ino = ino;return 0 ; }fs/xfs/libxfs/xfs_ialloc.h +4
-23@@ -33,30 +33,11 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) }/* -* Allocate an inode on disk. -* Mode is used to tell whether the new inode will need space, and whether -* it is a directory. -* -* There are two phases to inode allocation: selecting an AG and ensuring -* that it contains free inodes, followed by allocating one of the free -* inodes. xfs_dialloc_select_ag() does the former and returns a locked AGI -* to the caller, ensuring that followup call to xfs_dialloc_ag() will -* have free inodes to allocate from. xfs_dialloc_ag() will return the inode -* number of the free inode we allocated. +* Allocate an inode on disk. Mode is used to tell whether the new inode will +* need space, and whether it is a directory. */ -int /* error */ -xfs_dialloc_select_ag ( -struct xfs_trans **tpp,/* double pointer of transaction */ -xfs_ino_t parent,/* parent inode (directory) */ -umode_t mode,/* mode bits for new inode */ -struct xfs_buf **IO_agbp); - -int -xfs_dialloc_ag ( -struct xfs_trans *tp, -struct xfs_buf *agbp, -xfs_ino_t parent, -xfs_ino_t *inop); +int xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode, +xfs_ino_t *new_ino);/* * Free disk inode. Carefully avoids touching the incore inode, all fs/xfs/xfs_inode.c +12
-54@@ -749,7 +749,7 @@ xfs_inode_inherit_flags2(* Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. */ -static int +int xfs_init_new_inode( struct user_namespace *mnt_userns, struct xfs_trans *tp,@@ -885,54 +885,6 @@ xfs_init_new_inode(return 0 ; } -/* -* Allocates a new inode from disk and return a pointer to the incore copy. This -* routine will internally commit the current transaction and allocate a new one -* if we needed to allocate more on-disk free inodes to perform the requested -* operation. -* -* If we are allocating quota inodes, we do not have a parent inode to attach to -* or associate with (i.e. dp == NULL) because they are not linked into the -* directory structure - they are attached directly to the superblock - and so -* have no parent. -*/ -int -xfs_dir_ialloc ( -struct user_namespace *mnt_userns, -struct xfs_trans **tpp, -struct xfs_inode *dp, -umode_t mode, -xfs_nlink_t nlink, -dev_t rdev, -prid_t prid, -bool init_xattrs, -struct xfs_inode **ipp) -{ -struct xfs_buf *agibp; -xfs_ino_t parent_ino = dp ? dp->i_ino :0 ; -xfs_ino_t ino; -int error; - -ASSERT ((*tpp)->t_flags &XFS_TRANS_PERM_LOG_RES ); - -/* -* Call the space management code to pick the on-disk inode to be -* allocated. -*/ - error =xfs_dialloc_select_ag (tpp, parent_ino, mode, &agibp); -if (error) -return error; - -/* Allocate an inode from the selected AG */ - error =xfs_dialloc_ag (*tpp, agibp, parent_ino, &ino); -if (error) -return error; -ASSERT (ino !=NULLFSINO ); - -return xfs_init_new_inode (mnt_userns, *tpp, dp, ino, mode, nlink, rdev, - prid, init_xattrs, ipp); -} -/* * Decrement the link count on an inode & log the change. If this causes the * link count to go to zero, move the inode to AGI unlinked list so that it can @@ -990,6 +942,7 @@ xfs_create(struct xfs_dquot *pdqp =NULL ;struct xfs_trans_res *tres;uint resblks; +xfs_ino_t ino;trace_xfs_create (dp, name);@@ -1046,14 +999,16 @@ xfs_create(* entry pointing to them, but a directory also the "." entry * pointing to itself. */ - error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode, is_dir ?2 :1 , rdev, - prid, init_xattrs, &ip); + error =xfs_dialloc (&tp, dp->i_ino, mode, &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, mode, + is_dir ?2 :1 , rdev, prid, init_xattrs, &ip);if (error) goto out_trans_cancel;/* * Now we join the directory inode to the transaction. We do not do it -* earlier because xfs_dir_ialloc might commit the previous transaction +* earlier because xfs_dialloc might commit the previous transaction * (and release all the locks). An error from here on will result in * the transaction cancel unlocking dp so don't do it explicitly in the * error path. @@ -1143,6 +1098,7 @@ xfs_create_tmpfile(struct xfs_dquot *pdqp =NULL ;struct xfs_trans_res *tres;uint resblks; +xfs_ino_t ino;if (XFS_FORCED_SHUTDOWN (mp))return -EIO ;@@ -1167,8 +1123,10 @@ xfs_create_tmpfile(if (error) goto out_release_dquots; - error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode,0 ,0 , prid, - false, &ip); + error =xfs_dialloc (&tp, dp->i_ino, mode, &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, mode, +0 ,0 , prid, false, &ip);if (error) goto out_trans_cancel;fs/xfs/xfs_inode.h +4
-5@@ -431,11 +431,10 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,xfs_extlen_t xfs_get_extsz_hint (struct xfs_inode *ip);xfs_extlen_t xfs_get_cowextsz_hint (struct xfs_inode *ip); -int xfs_dir_ialloc (struct user_namespace *mnt_userns, -struct xfs_trans **tpp,struct xfs_inode *dp, -umode_t mode,xfs_nlink_t nlink,dev_t dev, -prid_t prid,bool need_xattr, -struct xfs_inode **ipp); +int xfs_init_new_inode (struct user_namespace *mnt_userns,struct xfs_trans *tp, +struct xfs_inode *pip,xfs_ino_t ino,umode_t mode, +xfs_nlink_t nlink,dev_t rdev,prid_t prid,bool init_xattrs, +struct xfs_inode **ipp);static inline int xfs_itruncate_extents(fs/xfs/xfs_qm.c +7
-2@@ -24,6 +24,7 @@#include "xfs_icache.h" #include "xfs_error.h" #include "xfs_ag.h" +#include "xfs_ialloc.h" /* * The global quota manager. There is only one of these for the entire @@ -788,8 +789,12 @@ xfs_qm_qino_alloc(return error;if (need_alloc) { - error =xfs_dir_ialloc (&init_user_ns, &tp,NULL ,S_IFREG ,1 ,0 , -0 , false, ipp); +xfs_ino_t ino; + + error =xfs_dialloc (&tp,0 ,S_IFREG , &ino); +if (!error) + error =xfs_init_new_inode (&init_user_ns, tp,NULL , ino, +S_IFREG ,1 ,0 ,0 , false, ipp);if (error) {xfs_trans_cancel (tp);return error;fs/xfs/xfs_symlink.c +7
-2@@ -21,6 +21,7 @@#include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_trans.h" +#include "xfs_ialloc.h" /* ----- Kernel only functions below ----- */ int @@ -161,6 +162,7 @@ xfs_symlink(struct xfs_dquot *gdqp =NULL ;struct xfs_dquot *pdqp =NULL ;uint resblks; +xfs_ino_t ino; *ipp =NULL ;@@ -223,8 +225,11 @@ xfs_symlink(/* * Allocate an inode for the symlink. */ - error =xfs_dir_ialloc (mnt_userns, &tp, dp,S_IFLNK | (mode & ~S_IFMT ), -1 ,0 , prid, false, &ip); + error =xfs_dialloc (&tp, dp->i_ino,S_IFLNK , &ino); +if (!error) + error =xfs_init_new_inode (mnt_userns, tp, dp, ino, +S_IFLNK | (mode & ~S_IFMT ),1 ,0 , prid, + false, &ip);if (error) goto out_trans_cancel;Signature · 1 line
2.31.1
PATCH 20/22 xfs: inode allocation can use a single perag instance
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Now that we've internalised the two-phase inode allocation, we can now easily make the AG selection and allocation atomic from the perspective of a single perag context. This will ensure AGs going offline/away cannot occur between the selection and allocation steps.
--- fs/xfs/libxfs/xfs_ialloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +3 -3
@@ -1432,6 +1432,7 @@ intxfs_dialloc_ag ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) {
@@ -1446,7 +1447,6 @@ xfs_dialloc_ag(int error;int offset;int i; -struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb))return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);
@@ -1761,9 +1761,9 @@ xfs_dialloc(xfs_perag_put (pag);return error ? error : -ENOSPC ; found_ag: -xfs_perag_put (pag);/* Allocate an inode in the found AG */ - error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); + error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); +xfs_perag_put (pag);if (error)return error; *new_ino = ino;
Signature · 1 line
2.31.1
Re: [PATCH 20/22] xfs: inode allocation can use a single perag instance
Quoted 10 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that we've internalised the two-phase inode allocation, we can now easily make the AG selection and allocation atomic from the perspective of a single perag context. This will ensure AGs going offline/away cannot occur between the selection and allocation steps.
Signed-off-by Dave Chinner <[email protected]>---
Quoted 38 lines
fs/xfs/libxfs/xfs_ialloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +3
-3@@ -1432,6 +1432,7 @@ intxfs_dialloc_ag ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) {@@ -1446,7 +1447,6 @@ xfs_dialloc_ag(int error;int offset;int i; -struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb))return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);@@ -1761,9 +1761,9 @@ xfs_dialloc(xfs_perag_put (pag);return error ? error : -ENOSPC ; found_ag: -xfs_perag_put (pag);/* Allocate an inode in the found AG */ - error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); + error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); +xfs_perag_put (pag);if (error)return error; *new_ino = ino;Signature · 1 line
2.31.1
Re: [PATCH 20/22] xfs: inode allocation can use a single perag instance
In reply to Dave ChinnerQuoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that we've internalised the two-phase inode allocation, we can now easily make the AG selection and allocation atomic from the perspective of a single perag context. This will ensure AGs going offline/away cannot occur between the selection and allocation steps.
Signed-off-by Dave Chinner <[email protected]>
Make sense.
--D
Quoted 39 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +3
-3@@ -1432,6 +1432,7 @@ intxfs_dialloc_ag ( struct xfs_trans *tp, struct xfs_buf *agbp, + struct xfs_perag *pag, xfs_ino_t parent, xfs_ino_t *inop) {@@ -1446,7 +1447,6 @@ xfs_dialloc_ag(int error;int offset;int i; -struct xfs_perag *pag = agbp->b_pag;if (!xfs_sb_version_hasfinobt (&mp->m_sb))return xfs_dialloc_ag_inobt (tp, agbp, pag, parent, inop);@@ -1761,9 +1761,9 @@ xfs_dialloc(xfs_perag_put (pag);return error ? error : -ENOSPC ; found_ag: -xfs_perag_put (pag);/* Allocate an inode in the found AG */ - error =xfs_dialloc_ag (*tpp, agbp, parent, &ino); + error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); +xfs_perag_put (pag);if (error)return error; *new_ino = ino;Signature · 1 line
2.31.1
PATCH 21/22 xfs: clean up and simplify xfs_dialloc()
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Because it's a mess.
--- fs/xfs/libxfs/xfs_ialloc.c | 270 +++++++++++++++++++++---------------- 1 file changed, 153 insertions(+), 117 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +153 -117
@@ -604,9 +604,10 @@ xfs_inobt_insert_sprec( }/* -* Allocate new inodes in the allocation group specified by agbp. -* Returns 0 if inodes were allocated in this AG; 1 if there was no space -* in this AG; or the usual negative error code. +* Allocate new inodes in the allocation group specified by agbp. Returns 0 if +* inodes were allocated in this AG; -EAGAIN if there was no space in this AG so +* the caller knows it can try another AG, a hard -ENOSPC when over the maximum +* inode count threshold, or the usual negative error code for other errors. */ STATIC int xfs_ialloc_ag_alloc(
@@ -792,7 +793,7 @@ xfs_ialloc_ag_alloc( }if (args.fsbno ==NULLFSBLOCK ) -return 1 ; +return -EAGAIN ;ASSERT (args.len == args.minlen);
@@ -1568,14 +1569,17 @@ xfs_dialloc_roll(/* Re-attach the quota info that we detached from prev trx. */ tp->t_dqinfo = dqinfo; - *tpp = tp; -if (error) -return error; +/* +* Join the buffer even on commit error so that the buffer is released +* when the caller cancels the transaction and doesn't have to handle +* this error case specially. +*/ xfs_trans_bjoin (tp, agibp); -return 0 ; + *tpp = tp; +return error; } -STATIC xfs_agnumber_t +static xfs_agnumber_t xfs_ialloc_next_ag (xfs_mount_t *mp) {
@@ -1590,16 +1594,136 @@ xfs_ialloc_next_ag(return agno; } +static bool +xfs_dialloc_good_ag ( +struct xfs_trans *tp, +struct xfs_perag *pag, +umode_t mode, +int flags, +bool ok_alloc) +{ +struct xfs_mount *mp = tp->t_mountp; +xfs_extlen_t ineed; +xfs_extlen_t longest =0 ; +int needspace; +int error; + +if (!pag->pagi_inodeok) +return false; + +if (!pag->pagi_init) { + error =xfs_ialloc_pagi_init (mp, tp, pag->pag_agno); +if (error) +return false; + } + +if (pag->pagi_freecount) +return true; +if (!ok_alloc) +return false; + +if (!pag->pagf_init) { + error =xfs_alloc_pagf_init (mp, tp, pag->pag_agno, flags); +if (error) +return false; + } + +/* +* Check that there is enough free space for the file plus a chunk of +* inodes if we need to allocate some. If this is the first pass across +* the AGs, take into account the potential space needed for alignment +* of inode chunks when checking the longest contiguous free space in +* the AG - this prevents us from getting ENOSPC because we have free +* space larger than ialloc_blks but alignment constraints prevent us +* from using it. +* +* If we can't find an AG with space for full alignment slack to be +* taken into account, we must be near ENOSPC in all AGs. Hence we +* don't include alignment for the second pass and so if we fail +* allocation due to alignment issues then it is most likely a real +* ENOSPC condition. +* +* XXX(dgc): this calculation is now bogus thanks to the per-ag +* reservations that xfs_alloc_fix_freelist() now does via +* xfs_alloc_space_available(). When the AG fills up, pagf_freeblks will +* be more than large enough for the check below to succeed, but +* xfs_alloc_space_available() will fail because of the non-zero +* metadata reservation and hence we won't actually be able to allocate +* more inodes in this AG. We do soooo much unnecessary work near ENOSPC +* because of this. +*/ + ineed =M_IGEO (mp)->ialloc_min_blks; +if (flags && ineed >1 ) + ineed +=M_IGEO (mp)->cluster_align; + longest = pag->pagf_longest; +if (!longest) + longest = pag->pagf_flcount >0 ; + needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); + +if (pag->pagf_freeblks < needspace + ineed || longest < ineed) +return false; +return true; +} + +static int +xfs_dialloc_try_ag ( +struct xfs_trans **tpp, +struct xfs_perag *pag, +xfs_ino_t parent, +xfs_ino_t *new_ino, +bool ok_alloc) +{ +struct xfs_buf *agbp; +xfs_ino_t ino; +int error; + +/* +* Then read in the AGI buffer and recheck with the AGI buffer +* lock held. +*/ + error =xfs_ialloc_read_agi (pag->pag_mount, *tpp, pag->pag_agno, &agbp); +if (error) +return error; + +if (!pag->pagi_freecount) { +if (!ok_alloc) { + error = -EAGAIN ; + goto out_release; + } + + error =xfs_ialloc_ag_alloc (*tpp, agbp, pag); +if (error <0 ) + goto out_release; + +/* +* We successfully allocated space for an inode cluster in this +* AG. Roll the transaction so that we can allocate one of the +* new inodes. +*/ +ASSERT (pag->pagi_freecount >0 ); + error =xfs_dialloc_roll (tpp, agbp); +if (error) + goto out_release; + } + +/* Allocate an inode in the found AG */ + error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); +if (!error) + *new_ino = ino; +return error; + +out_release: +xfs_trans_brelse (*tpp, agbp); +return error; +} +/* -* Select and prepare an AG for inode allocation. +* Allocate an on-disk inode. * * Mode is used to tell whether the new inode is a directory and hence where to -* locate it. -* -* This function will ensure that the selected AG has free inodes available to -* allocate from. The selected AGI will be returned locked to the caller, and it -* will allocate more free inodes if required. If no free inodes are found or -* can be allocated, -ENOSPC be returned. +* locate it. The on-disk inode that is allocated will be returned in @new_ino +* on success, otherwise an error will be set to indicate the failure (e.g. +* -ENOSPC). */ int xfs_dialloc(
@@ -1609,14 +1733,12 @@ xfs_dialloc( xfs_ino_t *new_ino) {struct xfs_mount *mp = (*tpp)->t_mountp; -struct xfs_buf *agbp;xfs_agnumber_t agno;int error =0 ;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp); -bool okalloc = true; -int needspace; +bool ok_alloc = true;int flags;xfs_ino_t ino;
@@ -1624,7 +1746,6 @@ xfs_dialloc(* Files of these types need at least one block if length > 0 * (and they won't fit in the inode, but that's hard to figure out). */ - needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode);if (S_ISDIR (mode)) start_agno =xfs_ialloc_next_ag (mp);else {
@@ -1635,7 +1756,7 @@ xfs_dialloc(/* * If we have already hit the ceiling of inode blocks then clear -* okalloc so we scan all available agi structures for a free +* ok_alloc so we scan all available agi structures for a free * inode. * * Read rough value of mp->m_icount by percpu_counter_read_positive,
@@ -1644,7 +1765,7 @@ xfs_dialloc(if (igeo->maxicount &&percpu_counter_read_positive (&mp->m_icount) + igeo->ialloc_inos > igeo->maxicount) { - okalloc = false; + ok_alloc = false; }/*
@@ -1655,95 +1776,14 @@ xfs_dialloc( agno = start_agno; flags =XFS_ALLOC_FLAG_TRYLOCK ;for (;;) { -xfs_extlen_t ineed; -xfs_extlen_t longest =0 ; - pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) - goto nextag; - -if (!pag->pagi_init) { - error =xfs_ialloc_pagi_init (mp, *tpp, agno); -if (error) -break ; - } - -if (!pag->pagi_freecount) - goto nextag; -if (!okalloc) - goto nextag; - -if (!pag->pagf_init) { - error =xfs_alloc_pagf_init (mp, *tpp, agno, flags); -if (error) - goto nextag; - } - -/* -* Check that there is enough free space for the file plus a -* chunk of inodes if we need to allocate some. If this is the -* first pass across the AGs, take into account the potential -* space needed for alignment of inode chunks when checking the -* longest contiguous free space in the AG - this prevents us -* from getting ENOSPC because we have free space larger than -* ialloc_blks but alignment constraints prevent us from using -* it. -* -* If we can't find an AG with space for full alignment slack to -* be taken into account, we must be near ENOSPC in all AGs. -* Hence we don't include alignment for the second pass and so -* if we fail allocation due to alignment issues then it is most -* likely a real ENOSPC condition. -*/ - ineed =M_IGEO (mp)->ialloc_min_blks; -if (flags && ineed >1 ) - ineed +=M_IGEO (mp)->cluster_align; - longest = pag->pagf_longest; -if (!longest) - longest = pag->pagf_flcount >0 ; - -if (pag->pagf_freeblks < needspace + ineed || longest < ineed) - goto nextag; - -/* -* Then read in the AGI buffer and recheck with the AGI buffer -* lock held. -*/ - error =xfs_ialloc_read_agi (mp, *tpp, agno, &agbp); -if (error) -break ; - -if (pag->pagi_freecount) - goto found_ag; - -if (!okalloc) - goto nextag_relse_buffer; - - error =xfs_ialloc_ag_alloc (*tpp, agbp, pag); -if (error <0 ) { -xfs_trans_brelse (*tpp, agbp); -break ; - } - -if (error ==0 ) { -/* -* We successfully allocated space for an inode cluster -* in this AG. Roll the transaction so that we can -* allocate one of the new inodes. -*/ -ASSERT (pag->pagi_freecount >0 ); - - error =xfs_dialloc_roll (tpp, agbp); -if (error) { -xfs_buf_relse (agbp); +if (xfs_dialloc_good_ag (*tpp, pag, mode, flags, ok_alloc)) { + error =xfs_dialloc_try_ag (tpp, pag, parent, + &ino, ok_alloc); +if (error != -EAGAIN )break ; - } - goto found_ag; } -nextag_relse_buffer: -xfs_trans_brelse (*tpp, agbp); -nextag:if (XFS_FORCED_SHUTDOWN (mp)) { error = -EFSCORRUPTED ;break ;
@@ -1751,23 +1791,19 @@ xfs_dialloc(if (++agno == mp->m_maxagi) agno =0 ;if (agno == start_agno) { -if (!flags) +if (!flags) { + error = -ENOSPC ;break ; + } flags =0 ; }xfs_perag_put (pag); } +if (!error) + *new_ino = ino;xfs_perag_put (pag); -return error ? error : -ENOSPC ; -found_ag: -/* Allocate an inode in the found AG */ - error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); -xfs_perag_put (pag); -if (error) -return error; - *new_ino = ino; -return 0 ; +return error; }/*
Signature · 1 line
2.31.1
Re: [PATCH 21/22] xfs: clean up and simplify xfs_dialloc()
Quoted 110 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Because it's a mess.
Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 270 +++++++++++++++++++++---------------- 1 file changed, 153 insertions(+), 117 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +60
-9@@ -604,9 +604,10 @@ xfs_inobt_insert_sprec( }/* -* Allocate new inodes in the allocation group specified by agbp. -* Returns 0 if inodes were allocated in this AG; 1 if there was no space -* in this AG; or the usual negative error code. +* Allocate new inodes in the allocation group specified by agbp. Returns 0 if +* inodes were allocated in this AG; -EAGAIN if there was no space in this AG so +* the caller knows it can try another AG, a hard -ENOSPC when over the maximum +* inode count threshold, or the usual negative error code for other errors. */ STATIC int xfs_ialloc_ag_alloc(@@ -792,7 +793,7 @@ xfs_ialloc_ag_alloc( }if (args.fsbno ==NULLFSBLOCK ) -return 1 ; +return -EAGAIN ;ASSERT (args.len == args.minlen);@@ -1568,14 +1569,17 @@ xfs_dialloc_roll(/* Re-attach the quota info that we detached from prev trx. */ tp->t_dqinfo = dqinfo; - *tpp = tp; -if (error) -return error; +/* +* Join the buffer even on commit error so that the buffer is released +* when the caller cancels the transaction and doesn't have to handle +* this error case specially. +*/ xfs_trans_bjoin (tp, agibp); -return 0 ; + *tpp = tp; +return error; } -STATIC xfs_agnumber_t +static xfs_agnumber_t xfs_ialloc_next_ag (xfs_mount_t *mp) {@@ -1590,16 +1594,136 @@ xfs_ialloc_next_ag(return agno; } +static bool +xfs_dialloc_good_ag ( +struct xfs_trans *tp, +struct xfs_perag *pag, +umode_t mode, +int flags, +bool ok_alloc) +{ +struct xfs_mount *mp = tp->t_mountp; +xfs_extlen_t ineed; +xfs_extlen_t longest =0 ; +int needspace; +int error; + +if (!pag->pagi_inodeok) +return false; + +if (!pag->pagi_init) { + error =xfs_ialloc_pagi_init (mp, tp, pag->pag_agno); +if (error) +return false; + } + +if (pag->pagi_freecount) +return true; +if (!ok_alloc) +return false; + +if (!pag->pagf_init) { + error =xfs_alloc_pagf_init (mp, tp, pag->pag_agno, flags); +if (error) +return false; + } + +/* +* Check that there is enough free space for the file plus a chunk of +* inodes if we need to allocate some. If this is the first pass across +* the AGs, take into account the potential space needed for alignment +* of inode chunks when checking the longest contiguous free space in +* the AG - this prevents us from getting ENOSPC because we have free +* space larger than ialloc_blks but alignment constraints prevent us +* from using it. +* +* If we can't find an AG with space for full alignment slack to be +* taken into account, we must be near ENOSPC in all AGs. Hence we +* don't include alignment for the second pass and so if we fail +* allocation due to alignment issues then it is most likely a real
fs/xfs/libxfs/xfs_ialloc.c xfs_ialloc_next_ag( · line 1653
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c +10
-0+* ENOSPC condition. +* +* XXX(dgc): this calculation is now bogus thanks to the per-ag +* reservations that xfs_alloc_fix_freelist() now does via +* xfs_alloc_space_available(). When the AG fills up, pagf_freeblks will +* be more than large enough for the check below to succeed, but +* xfs_alloc_space_available() will fail because of the non-zero +* metadata reservation and hence we won't actually be able to allocate +* more inodes in this AG. We do soooo much unnecessary work near ENOSPC +* because of this.
Yuck. Can this be fixed by doing:
really_free = pag->pagf_freeblks - xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE); return really_free >= needspace + ineed && longest >= ineed)
to account for those reservations, perhaps?
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc(
Quoted 117 lines
fs/xfs/libxfs/xfs_ialloc.c +72
-12+*/ + ineed =M_IGEO (mp)->ialloc_min_blks; +if (flags && ineed >1 ) + ineed +=M_IGEO (mp)->cluster_align; + longest = pag->pagf_longest; +if (!longest) + longest = pag->pagf_flcount >0 ; + needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode); + +if (pag->pagf_freeblks < needspace + ineed || longest < ineed) +return false; +return true; +} + +static int +xfs_dialloc_try_ag ( +struct xfs_trans **tpp, +struct xfs_perag *pag, +xfs_ino_t parent, +xfs_ino_t *new_ino, +bool ok_alloc) +{ +struct xfs_buf *agbp; +xfs_ino_t ino; +int error; + +/* +* Then read in the AGI buffer and recheck with the AGI buffer +* lock held. +*/ + error =xfs_ialloc_read_agi (pag->pag_mount, *tpp, pag->pag_agno, &agbp); +if (error) +return error; + +if (!pag->pagi_freecount) { +if (!ok_alloc) { + error = -EAGAIN ; + goto out_release; + } + + error =xfs_ialloc_ag_alloc (*tpp, agbp, pag); +if (error <0 ) + goto out_release; + +/* +* We successfully allocated space for an inode cluster in this +* AG. Roll the transaction so that we can allocate one of the +* new inodes. +*/ +ASSERT (pag->pagi_freecount >0 ); + error =xfs_dialloc_roll (tpp, agbp); +if (error) + goto out_release; + } + +/* Allocate an inode in the found AG */ + error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); +if (!error) + *new_ino = ino; +return error; + +out_release: +xfs_trans_brelse (*tpp, agbp); +return error; +} +/* -* Select and prepare an AG for inode allocation. +* Allocate an on-disk inode. * * Mode is used to tell whether the new inode is a directory and hence where to -* locate it. -* -* This function will ensure that the selected AG has free inodes available to -* allocate from. The selected AGI will be returned locked to the caller, and it -* will allocate more free inodes if required. If no free inodes are found or -* can be allocated, -ENOSPC be returned. +* locate it. The on-disk inode that is allocated will be returned in @new_ino +* on success, otherwise an error will be set to indicate the failure (e.g. +* -ENOSPC). */ int xfs_dialloc(@@ -1609,14 +1733,12 @@ xfs_dialloc( xfs_ino_t *new_ino) {struct xfs_mount *mp = (*tpp)->t_mountp; -struct xfs_buf *agbp;xfs_agnumber_t agno;int error =0 ;xfs_agnumber_t start_agno;struct xfs_perag *pag;struct xfs_ino_geometry *igeo =M_IGEO (mp); -bool okalloc = true; -int needspace; +bool ok_alloc = true;int flags;xfs_ino_t ino;@@ -1624,7 +1746,6 @@ xfs_dialloc(* Files of these types need at least one block if length > 0 * (and they won't fit in the inode, but that's hard to figure out). */ - needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode);if (S_ISDIR (mode)) start_agno =xfs_ialloc_next_ag (mp);else {@@ -1635,7 +1756,7 @@ xfs_dialloc(/* * If we have already hit the ceiling of inode blocks then clear -* okalloc so we scan all available agi structures for a free +* ok_alloc so we scan all available agi structures for a free * inode. * * Read rough value of mp->m_icount by percpu_counter_read_positive, @@ -1644,7 +1765,7 @@ xfs_dialloc(
Er... didn't this logic get split into xfs_dialloc_select_ag in 5.11?
Nice cleanup, at least...
--D
Quoted 141 lines
fs/xfs/libxfs/xfs_ialloc.c +11
-96if (igeo->maxicount &&percpu_counter_read_positive (&mp->m_icount) + igeo->ialloc_inos > igeo->maxicount) { - okalloc = false; + ok_alloc = false; }/* @@ -1655,95 +1776,14 @@ xfs_dialloc( agno = start_agno; flags =XFS_ALLOC_FLAG_TRYLOCK ;for (;;) { -xfs_extlen_t ineed; -xfs_extlen_t longest =0 ; - pag =xfs_perag_get (mp, agno); -if (!pag->pagi_inodeok) - goto nextag; - -if (!pag->pagi_init) { - error =xfs_ialloc_pagi_init (mp, *tpp, agno); -if (error) -break ; - } - -if (!pag->pagi_freecount) - goto nextag; -if (!okalloc) - goto nextag; - -if (!pag->pagf_init) { - error =xfs_alloc_pagf_init (mp, *tpp, agno, flags); -if (error) - goto nextag; - } - -/* -* Check that there is enough free space for the file plus a -* chunk of inodes if we need to allocate some. If this is the -* first pass across the AGs, take into account the potential -* space needed for alignment of inode chunks when checking the -* longest contiguous free space in the AG - this prevents us -* from getting ENOSPC because we have free space larger than -* ialloc_blks but alignment constraints prevent us from using -* it. -* -* If we can't find an AG with space for full alignment slack to -* be taken into account, we must be near ENOSPC in all AGs. -* Hence we don't include alignment for the second pass and so -* if we fail allocation due to alignment issues then it is most -* likely a real ENOSPC condition. -*/ - ineed =M_IGEO (mp)->ialloc_min_blks; -if (flags && ineed >1 ) - ineed +=M_IGEO (mp)->cluster_align; - longest = pag->pagf_longest; -if (!longest) - longest = pag->pagf_flcount >0 ; - -if (pag->pagf_freeblks < needspace + ineed || longest < ineed) - goto nextag; - -/* -* Then read in the AGI buffer and recheck with the AGI buffer -* lock held. -*/ - error =xfs_ialloc_read_agi (mp, *tpp, agno, &agbp); -if (error) -break ; - -if (pag->pagi_freecount) - goto found_ag; - -if (!okalloc) - goto nextag_relse_buffer; - - error =xfs_ialloc_ag_alloc (*tpp, agbp, pag); -if (error <0 ) { -xfs_trans_brelse (*tpp, agbp); -break ; - } - -if (error ==0 ) { -/* -* We successfully allocated space for an inode cluster -* in this AG. Roll the transaction so that we can -* allocate one of the new inodes. -*/ -ASSERT (pag->pagi_freecount >0 ); - - error =xfs_dialloc_roll (tpp, agbp); -if (error) { -xfs_buf_relse (agbp); +if (xfs_dialloc_good_ag (*tpp, pag, mode, flags, ok_alloc)) { + error =xfs_dialloc_try_ag (tpp, pag, parent, + &ino, ok_alloc); +if (error != -EAGAIN )break ; - } - goto found_ag; } -nextag_relse_buffer: -xfs_trans_brelse (*tpp, agbp); -nextag:if (XFS_FORCED_SHUTDOWN (mp)) { error = -EFSCORRUPTED ;break ;@@ -1751,23 +1791,19 @@ xfs_dialloc(if (++agno == mp->m_maxagi) agno =0 ;if (agno == start_agno) { -if (!flags) +if (!flags) { + error = -ENOSPC ;break ; + } flags =0 ; }xfs_perag_put (pag); } +if (!error) + *new_ino = ino;xfs_perag_put (pag); -return error ? error : -ENOSPC ; -found_ag: -/* Allocate an inode in the found AG */ - error =xfs_dialloc_ag (*tpp, agbp, pag, parent, &ino); -xfs_perag_put (pag); -if (error) -return error; - *new_ino = ino; -return 0 ; +return error; }/* Signature · 1 line
2.31.1
Re: [PATCH 21/22] xfs: clean up and simplify xfs_dialloc()
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Because it's a mess.
Signed-off-by Dave Chinner <[email protected]>
.....
Quoted 26 lines
Quoted 13 lines
fs/xfs/libxfs/xfs_ialloc.c +13
-0+/* +* Check that there is enough free space for the file plus a chunk of +* inodes if we need to allocate some. If this is the first pass across +* the AGs, take into account the potential space needed for alignment +* of inode chunks when checking the longest contiguous free space in +* the AG - this prevents us from getting ENOSPC because we have free +* space larger than ialloc_blks but alignment constraints prevent us +* from using it. +* +* If we can't find an AG with space for full alignment slack to be +* taken into account, we must be near ENOSPC in all AGs. Hence we +* don't include alignment for the second pass and so if we fail +* allocation due to alignment issues then it is most likely a real fs/xfs/libxfs/xfs_ialloc.c xfs_ialloc_next_ag( · line 1653
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c +10
-0+* ENOSPC condition. +* +* XXX(dgc): this calculation is now bogus thanks to the per-ag +* reservations that xfs_alloc_fix_freelist() now does via +* xfs_alloc_space_available(). When the AG fills up, pagf_freeblks will +* be more than large enough for the check below to succeed, but +* xfs_alloc_space_available() will fail because of the non-zero +* metadata reservation and hence we won't actually be able to allocate +* more inodes in this AG. We do soooo much unnecessary work near ENOSPC +* because of this. Yuck. Can this be fixed by doing:
Quoted 5 lines
really_free = pag->pagf_freeblks - xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE); return really_free >= needspace + ineed && longest >= ineed)to account for those reservations, perhaps?
Something like that, though I'd much prefer to factor the freelist fixup calculations and use them here so we have a single set of "is there enough space in this AG for allocating X blocks" functions.
It's somewhat outside the scope of this patchset, so I wrote the comment rather than trying to address it here and complicate this patchset....
Quoted 10 lines
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c +0
-1@@ -1624,7 +1746,6 @@ xfs_dialloc(* Files of these types need at least one block if length > 0 * (and they won't fit in the inode, but that's hard to figure out). */ - needspace =S_ISDIR (mode) ||S_ISREG (mode) ||S_ISLNK (mode);if (S_ISDIR (mode)) start_agno =xfs_ialloc_next_ag (mp);else {@@ -1635,7 +1756,7 @@ xfs_dialloc(
Quoted 10 lines
fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc(
Quoted 8 lines
fs/xfs/libxfs/xfs_ialloc.c +1
-1/* * If we have already hit the ceiling of inode blocks then clear -* okalloc so we scan all available agi structures for a free +* ok_alloc so we scan all available agi structures for a free * inode. * * Read rough value of mp->m_icount by percpu_counter_read_positive, @@ -1644,7 +1765,7 @@ xfs_dialloc(Er... didn't this logic get split into
xfs_dialloc_select_agin 5.11?
Yeah, but that was more about cleaning up the code in xfs_inode.c by separating out the inode initialisation from the physical inode allocation. That cleanup and separation is what allows this series to simplify and clean up the inode allocation because it is no longer commingled with the inode initialisation after allocation...
Quoted 3 lines
Nice cleanup, at least...
:)
Yup, along with the 5.11 mods, we've chopped a lot of unnecessary code out of the inode allocation path... :)
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 22/22 xfs: use perag through unlink processing
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Unlinked lists are held in the perag, and freeing of inodes needs to be passed a perag, too, so look up the perag early in the unlink processing and use it throughout.
--- fs/xfs/libxfs/xfs_ialloc.c | 23 +++---- fs/xfs/libxfs/xfs_ialloc.h | 13 +--- fs/xfs/xfs_inode.c | 131 +++++++++++++++++++++---------------- 3 files changed, 87 insertions(+), 80 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +10 -13
@@ -2133,35 +2133,33 @@ xfs_difree_finobt(*/ int xfs_difree ( -struct xfs_trans *tp,/* transaction pointer */ -xfs_ino_t inode,/* inode to be freed */ -struct xfs_icluster *xic)/* cluster info if deleted */ +struct xfs_trans *tp, +struct xfs_perag *pag, +xfs_ino_t inode, +struct xfs_icluster *xic) {/* REFERENCED */ xfs_agblock_t agbno;/* block number containing inode */ struct xfs_buf *agbp;/* buffer for allocation group header */ xfs_agino_t agino;/* allocation group inode number */ -xfs_agnumber_t agno;/* allocation group number */ int error;/* error return value */ struct xfs_mount *mp = tp->t_mountp;struct xfs_inobt_rec_incore rec;/* btree record */ -struct xfs_perag *pag;/* * Break up inode number into its components. */ - agno =XFS_INO_TO_AGNO (mp, inode); -if (agno >= mp->m_sb.sb_agcount) { -xfs_warn (mp,"%s: agno >= mp->m_sb.sb_agcount (%d >= %d)." , - __func__, agno, mp->m_sb.sb_agcount); +if (pag->pag_agno !=XFS_INO_TO_AGNO (mp, inode)) { +xfs_warn (mp,"%s: agno != pag->pag_agno (%d != %d)." , + __func__,XFS_INO_TO_AGNO (mp, inode), pag->pag_agno);ASSERT (0 );return -EINVAL ; } agino =XFS_INO_TO_AGINO (mp, inode); -if (inode !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (inode !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) {xfs_warn (mp,"%s: inode != XFS_AGINO_TO_INO() (%llu != %llu)." , __func__, (unsigned long long )inode, - (unsigned long long )XFS_AGINO_TO_INO (mp, agno, agino)); + (unsigned long long )XFS_AGINO_TO_INO (mp, pag->pag_agno, agino));ASSERT (0 );return -EINVAL ; }
@@ -2175,7 +2173,7 @@ xfs_difree(/* * Get the allocation group header. */ - error =xfs_ialloc_read_agi (mp, tp, agno, &agbp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, &agbp);if (error) {xfs_warn (mp,"%s: xfs_ialloc_read_agi() returned error %d." , __func__, error);
@@ -2185,7 +2183,6 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - pag = agbp->b_pag; error =xfs_difree_inobt (mp, tp, agbp, pag, agino, xic, &rec);if (error) goto error0;
fs/xfs/libxfs/xfs_ialloc.h +2 -11
@@ -39,17 +39,8 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)int xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode,xfs_ino_t *new_ino); -/* -* Free disk inode. Carefully avoids touching the incore inode, all -* manipulations incore are the caller's responsibility. -* The on-disk inode is not changed by this operation, only the -* btree (free inode mask) is changed. -*/ -int /* error */ -xfs_difree ( -struct xfs_trans *tp,/* transaction pointer */ -xfs_ino_t inode,/* inode to be freed */ -struct xfs_icluster *ifree);/* cluster info if deleted */ +int xfs_difree (struct xfs_trans *tp,struct xfs_perag *pag, +xfs_ino_t ino,struct xfs_icluster *ifree);/* * Return the location of the inode in imap, for mapping it into a buffer.
fs/xfs/xfs_inode.c +75 -56
385 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH 22/22] xfs: use perag through unlink processing
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Unlinked lists are held in the perag, and freeing of inodes needs to be passed a perag, too, so look up the perag early in the unlink processing and use it throughout.
Signed-off-by Dave Chinner <[email protected]>
Looks like a fairly straightforward conversion...
--D
Quoted 523 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 23 +++---- fs/xfs/libxfs/xfs_ialloc.h | 13 +--- fs/xfs/xfs_inode.c | 131 +++++++++++++++++++++---------------- 3 files changed, 87 insertions(+), 80 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +10
-13@@ -2133,35 +2133,33 @@ xfs_difree_finobt(*/ int xfs_difree ( -struct xfs_trans *tp,/* transaction pointer */ -xfs_ino_t inode,/* inode to be freed */ -struct xfs_icluster *xic)/* cluster info if deleted */ +struct xfs_trans *tp, +struct xfs_perag *pag, +xfs_ino_t inode, +struct xfs_icluster *xic) {/* REFERENCED */ xfs_agblock_t agbno;/* block number containing inode */ struct xfs_buf *agbp;/* buffer for allocation group header */ xfs_agino_t agino;/* allocation group inode number */ -xfs_agnumber_t agno;/* allocation group number */ int error;/* error return value */ struct xfs_mount *mp = tp->t_mountp;struct xfs_inobt_rec_incore rec;/* btree record */ -struct xfs_perag *pag;/* * Break up inode number into its components. */ - agno =XFS_INO_TO_AGNO (mp, inode); -if (agno >= mp->m_sb.sb_agcount) { -xfs_warn (mp,"%s: agno >= mp->m_sb.sb_agcount (%d >= %d)." , - __func__, agno, mp->m_sb.sb_agcount); +if (pag->pag_agno !=XFS_INO_TO_AGNO (mp, inode)) { +xfs_warn (mp,"%s: agno != pag->pag_agno (%d != %d)." , + __func__,XFS_INO_TO_AGNO (mp, inode), pag->pag_agno);ASSERT (0 );return -EINVAL ; } agino =XFS_INO_TO_AGINO (mp, inode); -if (inode !=XFS_AGINO_TO_INO (mp, agno, agino)) { +if (inode !=XFS_AGINO_TO_INO (mp, pag->pag_agno, agino)) {xfs_warn (mp,"%s: inode != XFS_AGINO_TO_INO() (%llu != %llu)." , __func__, (unsigned long long )inode, - (unsigned long long )XFS_AGINO_TO_INO (mp, agno, agino)); + (unsigned long long )XFS_AGINO_TO_INO (mp, pag->pag_agno, agino));ASSERT (0 );return -EINVAL ; }@@ -2175,7 +2173,7 @@ xfs_difree(/* * Get the allocation group header. */ - error =xfs_ialloc_read_agi (mp, tp, agno, &agbp); + error =xfs_ialloc_read_agi (mp, tp, pag->pag_agno, &agbp);if (error) {xfs_warn (mp,"%s: xfs_ialloc_read_agi() returned error %d." , __func__, error);@@ -2185,7 +2183,6 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - pag = agbp->b_pag; error =xfs_difree_inobt (mp, tp, agbp, pag, agino, xic, &rec);if (error) goto error0;fs/xfs/libxfs/xfs_ialloc.h +2
-11@@ -39,17 +39,8 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)int xfs_dialloc (struct xfs_trans **tpp,xfs_ino_t parent,umode_t mode,xfs_ino_t *new_ino); -/* -* Free disk inode. Carefully avoids touching the incore inode, all -* manipulations incore are the caller's responsibility. -* The on-disk inode is not changed by this operation, only the -* btree (free inode mask) is changed. -*/ -int /* error */ -xfs_difree ( -struct xfs_trans *tp,/* transaction pointer */ -xfs_ino_t inode,/* inode to be freed */ -struct xfs_icluster *ifree);/* cluster info if deleted */ +int xfs_difree (struct xfs_trans *tp,struct xfs_perag *pag, +xfs_ino_t ino,struct xfs_icluster *ifree);/* * Return the location of the inode in imap, for mapping it into a buffer. fs/xfs/xfs_inode.c +75
-56@@ -45,7 +45,8 @@ kmem_zone_t *xfs_inode_zone;#define XFS_ITRUNC_MAX_EXTENTS 2 STATIC int xfs_iunlink(struct xfs_trans *, struct xfs_inode *); -STATIC int xfs_iunlink_remove(struct xfs_trans *, struct xfs_inode *); +STATIC int xfs_iunlink_remove(struct xfs_trans *tp, struct xfs_perag *pag, +struct xfs_inode *);/* * helper function to extract extent size hint from inode @@ -1241,7 +1242,11 @@ xfs_link(* Handle initial link state of O_TMPFILE inode */ if (VFS_I (sip)->i_nlink ==0 ) { - error =xfs_iunlink_remove (tp, sip); +struct xfs_perag *pag; + + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, sip->i_ino)); + error =xfs_iunlink_remove (tp, pag, sip); +xfs_perag_put (pag);if (error) goto error_return; }@@ -1934,7 +1939,7 @@ xfs_iunlink_destroy( STATIC intxfs_iunlink_update_bucket (struct xfs_trans *tp, -xfs_agnumber_t agno, +struct xfs_perag *pag,struct xfs_buf *agibp,unsigned int bucket_index,xfs_agino_t new_agino)@@ -1943,10 +1948,10 @@ xfs_iunlink_update_bucket(xfs_agino_t old_value;int offset; -ASSERT (xfs_verify_agino_or_null (tp->t_mountp, agno, new_agino)); +ASSERT (xfs_verify_agino_or_null (tp->t_mountp, pag->pag_agno, new_agino)); old_value =be32_to_cpu (agi->agi_unlinked[bucket_index]); -trace_xfs_iunlink_update_bucket (tp->t_mountp, agno, bucket_index, +trace_xfs_iunlink_update_bucket (tp->t_mountp, pag->pag_agno, bucket_index, old_value, new_agino);/* @@ -1970,7 +1975,7 @@ xfs_iunlink_update_bucket( STATIC void xfs_iunlink_update_dinode( struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_agino_t agino, struct xfs_buf *ibp, struct xfs_dinode *dip,@@ -1980,9 +1985,9 @@ xfs_iunlink_update_dinode(struct xfs_mount *mp = tp->t_mountp;int offset; -ASSERT (xfs_verify_agino_or_null (mp, agno, next_agino)); +ASSERT (xfs_verify_agino_or_null (mp, pag->pag_agno, next_agino)); -trace_xfs_iunlink_update_dinode (mp, agno, agino, +trace_xfs_iunlink_update_dinode (mp, pag->pag_agno, agino,be32_to_cpu (dip->di_next_unlinked), next_agino); dip->di_next_unlinked =cpu_to_be32 (next_agino);@@ -2000,7 +2005,7 @@ STATIC intxfs_iunlink_update_inode ( struct xfs_trans *tp, struct xfs_inode *ip, - xfs_agnumber_t agno, + struct xfs_perag *pag, xfs_agino_t next_agino, xfs_agino_t *old_next_agino) {@@ -2010,7 +2015,7 @@ xfs_iunlink_update_inode(xfs_agino_t old_value;int error; -ASSERT (xfs_verify_agino_or_null (mp, agno, next_agino)); +ASSERT (xfs_verify_agino_or_null (mp, pag->pag_agno, next_agino)); error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &ibp);if (error)@@ -2019,7 +2024,7 @@ xfs_iunlink_update_inode(/* Make sure the old pointer isn't garbage. */ old_value =be32_to_cpu (dip->di_next_unlinked); -if (!xfs_verify_agino_or_null (mp, agno, old_value)) { +if (!xfs_verify_agino_or_null (mp, pag->pag_agno, old_value)) {xfs_inode_verifier_error (ip, -EFSCORRUPTED , __func__, dip,sizeof (*dip), __this_address); error = -EFSCORRUPTED ;@@ -2042,7 +2047,7 @@ xfs_iunlink_update_inode( }/* Ok, update the new pointer. */ -xfs_iunlink_update_dinode (tp, agno,XFS_INO_TO_AGINO (mp, ip->i_ino), +xfs_iunlink_update_dinode (tp, pag,XFS_INO_TO_AGINO (mp, ip->i_ino), ibp, dip, &ip->i_imap, next_agino);return 0 ; out:@@ -2063,10 +2068,10 @@ xfs_iunlink( struct xfs_inode *ip) {struct xfs_mount *mp = tp->t_mountp; +struct xfs_perag *pag;struct xfs_agi *agi;struct xfs_buf *agibp;xfs_agino_t next_agino; -xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ip->i_ino);xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ip->i_ino);short bucket_index = agino %XFS_AGI_UNLINKED_BUCKETS ;int error;@@ -2075,10 +2080,12 @@ xfs_iunlink(ASSERT (VFS_I (ip)->i_mode !=0 );trace_xfs_iunlink (ip); + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ip->i_ino)); +/* Get the agi buffer first. It ensures lock ordering on the list. */ - error =xfs_read_agi (mp, tp, agno, &agibp); + error =xfs_read_agi (mp, tp, pag->pag_agno, &agibp);if (error) -return error; + goto out; agi = agibp->b_addr;/* @@ -2088,9 +2095,10 @@ xfs_iunlink(*/ next_agino =be32_to_cpu (agi->agi_unlinked[bucket_index]);if (next_agino == agino || - !xfs_verify_agino_or_null (mp, agno, next_agino)) { + !xfs_verify_agino_or_null (mp, pag->pag_agno, next_agino)) {xfs_buf_mark_corrupt (agibp); -return -EFSCORRUPTED ; + error = -EFSCORRUPTED ; + goto out; }if (next_agino !=NULLAGINO ) {@@ -2100,23 +2108,26 @@ xfs_iunlink(* There is already another inode in the bucket, so point this * inode to the current head of the list. */ - error =xfs_iunlink_update_inode (tp, ip, agno, next_agino, + error =xfs_iunlink_update_inode (tp, ip, pag, next_agino, &old_agino);if (error) -return error; + goto out;ASSERT (old_agino ==NULLAGINO );/* * agino has been unlinked, add a backref from the next inode * back to agino. */ - error =xfs_iunlink_add_backref (agibp->b_pag, agino, next_agino); + error =xfs_iunlink_add_backref (pag, agino, next_agino);if (error) -return error; + goto out; }/* Point the head of the list to point to this inode. */ -return xfs_iunlink_update_bucket (tp, agno, agibp, bucket_index, agino); + error =xfs_iunlink_update_bucket (tp, pag, agibp, bucket_index, agino); +out: +xfs_perag_put (pag); +return error; }/* Return the imap, dinode pointer, and buffer for an inode. */ @@ -2164,14 +2175,13 @@ xfs_iunlink_map_ino( STATIC intxfs_iunlink_map_prev (struct xfs_trans *tp, -xfs_agnumber_t agno, +struct xfs_perag *pag,xfs_agino_t head_agino,xfs_agino_t target_agino,xfs_agino_t *agino,struct xfs_imap *imap,struct xfs_dinode **dipp, -struct xfs_buf **bpp, -struct xfs_perag *pag) +struct xfs_buf **bpp) {struct xfs_mount *mp = tp->t_mountp;xfs_agino_t next_agino;@@ -2183,7 +2193,8 @@ xfs_iunlink_map_prev(/* See if our backref cache can find it faster. */ *agino =xfs_iunlink_lookup_backref (pag, target_agino);if (*agino !=NULLAGINO ) { - error =xfs_iunlink_map_ino (tp, agno, *agino, imap, dipp, bpp); + error =xfs_iunlink_map_ino (tp, pag->pag_agno, *agino, imap, + dipp, bpp);if (error)return error;@@ -2199,7 +2210,7 @@ xfs_iunlink_map_prev(WARN_ON_ONCE (1 ); } -trace_xfs_iunlink_map_prev_fallback (mp, agno); +trace_xfs_iunlink_map_prev_fallback (mp, pag->pag_agno);/* Otherwise, walk the entire bucket until we find it. */ next_agino = head_agino;@@ -2210,8 +2221,8 @@ xfs_iunlink_map_prev(xfs_trans_brelse (tp, *bpp); *agino = next_agino; - error =xfs_iunlink_map_ino (tp, agno, next_agino, imap, dipp, - bpp); + error =xfs_iunlink_map_ino (tp, pag->pag_agno, next_agino, imap, + dipp, bpp);if (error)return error;@@ -2220,7 +2231,7 @@ xfs_iunlink_map_prev(* Make sure this pointer is valid and isn't an obvious * infinite loop. */ -if (!xfs_verify_agino (mp, agno, unlinked_agino) || +if (!xfs_verify_agino (mp, pag->pag_agno, unlinked_agino) || next_agino == unlinked_agino) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,@@ -2240,6 +2251,7 @@ xfs_iunlink_map_prev( STATIC intxfs_iunlink_remove (struct xfs_trans *tp, +struct xfs_perag *pag,struct xfs_inode *ip) {struct xfs_mount *mp = tp->t_mountp;@@ -2247,7 +2259,6 @@ xfs_iunlink_remove(struct xfs_buf *agibp;struct xfs_buf *last_ibp;struct xfs_dinode *last_dip =NULL ; -xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ip->i_ino);xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ip->i_ino);xfs_agino_t next_agino;xfs_agino_t head_agino;@@ -2257,7 +2268,7 @@ xfs_iunlink_remove(trace_xfs_iunlink_remove (ip);/* Get the agi buffer first. It ensures lock ordering on the list. */ - error =xfs_read_agi (mp, tp, agno, &agibp); + error =xfs_read_agi (mp, tp, pag->pag_agno, &agibp);if (error)return error; agi = agibp->b_addr;@@ -2267,7 +2278,7 @@ xfs_iunlink_remove(* go on. Make sure the head pointer isn't garbage. */ head_agino =be32_to_cpu (agi->agi_unlinked[bucket_index]); -if (!xfs_verify_agino (mp, agno, head_agino)) { +if (!xfs_verify_agino (mp, pag->pag_agno, head_agino)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, agi,sizeof (*agi));return -EFSCORRUPTED ;@@ -2278,7 +2289,7 @@ xfs_iunlink_remove(* the old pointer value so that we can update whatever was previous * to us in the list to point to whatever was next in the list. */ - error =xfs_iunlink_update_inode (tp, ip, agno,NULLAGINO , &next_agino); + error =xfs_iunlink_update_inode (tp, ip, pag,NULLAGINO , &next_agino);if (error)return error;@@ -2290,8 +2301,7 @@ xfs_iunlink_remove(* this inode's backref to point from the next inode. */ if (next_agino !=NULLAGINO ) { - error =xfs_iunlink_change_backref (agibp->b_pag, next_agino, -NULLAGINO ); + error =xfs_iunlink_change_backref (pag, next_agino,NULLAGINO );if (error)return error; }@@ -2301,14 +2311,13 @@ xfs_iunlink_remove(xfs_agino_t prev_agino;/* We need to search the list for the inode being freed. */ - error =xfs_iunlink_map_prev (tp, agno, head_agino, agino, - &prev_agino, &imap, &last_dip, &last_ibp, - agibp->b_pag); + error =xfs_iunlink_map_prev (tp, pag, head_agino, agino, + &prev_agino, &imap, &last_dip, &last_ibp);if (error)return error;/* Point the previous inode on the list to the next inode. */ -xfs_iunlink_update_dinode (tp, agno, prev_agino, last_ibp, +xfs_iunlink_update_dinode (tp, pag, prev_agino, last_ibp, last_dip, &imap, next_agino);/* @@ -2324,7 +2333,7 @@ xfs_iunlink_remove( }/* Point the head of the list to the next unlinked inode. */ -return xfs_iunlink_update_bucket (tp, agno, agibp, bucket_index, +return xfs_iunlink_update_bucket (tp, pag, agibp, bucket_index, next_agino); }@@ -2335,12 +2344,11 @@ xfs_iunlink_remove(*/ static void xfs_ifree_mark_inode_stale ( -struct xfs_buf *bp, +struct xfs_perag *pag,struct xfs_inode *free_ip,xfs_ino_t inum) { -struct xfs_mount *mp = bp->b_mount; -struct xfs_perag *pag = bp->b_pag; +struct xfs_mount *mp = pag->pag_mount;struct xfs_inode_log_item *iip;struct xfs_inode *ip;@@ -2430,10 +2438,11 @@ xfs_ifree_mark_inode_stale(* inodes that are in memory - they all must be marked stale and attached to * the cluster buffer. */ -STATIC int +static int xfs_ifree_cluster ( -struct xfs_inode *free_ip,struct xfs_trans *tp, +struct xfs_perag *pag, +struct xfs_inode *free_ip,struct xfs_icluster *xic) {struct xfs_mount *mp = free_ip->i_mount;@@ -2495,7 +2504,7 @@ xfs_ifree_cluster(* already marked XFS_ISTALE. */ for (i =0 ; i < igeo->inodes_per_cluster; i++) -xfs_ifree_mark_inode_stale (bp, free_ip, inum + i); +xfs_ifree_mark_inode_stale (pag, free_ip, inum + i);xfs_trans_stale_inode_buf (tp, bp);xfs_trans_binval (tp, bp);@@ -2518,9 +2527,11 @@ xfs_ifree(struct xfs_trans *tp, struct xfs_inode *ip) { - int error; + struct xfs_mount *mp = ip->i_mount; +struct xfs_perag *pag;struct xfs_icluster xic = {0 };struct xfs_inode_log_item *iip = ip->i_itemp; +int error;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));ASSERT (VFS_I (ip)->i_nlink ==0 );@@ -2528,16 +2539,18 @@ xfs_ifree(ASSERT (ip->i_disk_size ==0 || !S_ISREG (VFS_I (ip)->i_mode));ASSERT (ip->i_nblocks ==0 ); + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ip->i_ino)); +/* * Pull the on-disk inode from the AGI unlinked list. */ - error =xfs_iunlink_remove (tp, ip); + error =xfs_iunlink_remove (tp, pag, ip);if (error) -return error; + goto out; - error =xfs_difree (tp, ip->i_ino, &xic); + error =xfs_difree (tp, pag, ip->i_ino, &xic);if (error) -return error; + goto out;/* * Free any local-format data sitting around before we reset the @@ -2552,7 +2565,7 @@ xfs_ifree(VFS_I (ip)->i_mode =0 ;/* mark incore inode as free */ ip->i_diflags =0 ; - ip->i_diflags2 = ip->i_mount->m_ino_geo.new_diflags2; + ip->i_diflags2 = mp->m_ino_geo.new_diflags2; ip->i_forkoff =0 ;/* mark the attr fork not in use */ ip->i_df.if_format =XFS_DINODE_FMT_EXTENTS ;if (xfs_iflags_test (ip,XFS_IPRESERVE_DM_FIELDS ))@@ -2571,8 +2584,9 @@ xfs_ifree(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );if (xic.deleted) - error =xfs_ifree_cluster (ip, tp, &xic); - + error =xfs_ifree_cluster (tp, pag, ip, &xic); +out: +xfs_perag_put (pag);return error; }@@ -3176,8 +3190,13 @@ xfs_rename(* in future. */ if (wip) { +struct xfs_perag *pag; +ASSERT (VFS_I (wip)->i_nlink ==0 ); - error =xfs_iunlink_remove (tp, wip); + + pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, wip->i_ino)); + error =xfs_iunlink_remove (tp, pag, wip); +xfs_perag_put (pag);if (error) goto out_trans_cancel;Signature · 1 line
2.31.1