Commit 7b13c515 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: use perag for ialloc btree cursors

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 289d38d2
This diff is collapsed.
...@@ -35,8 +35,7 @@ xfs_inobt_dup_cursor( ...@@ -35,8 +35,7 @@ xfs_inobt_dup_cursor(
struct xfs_btree_cur *cur) struct xfs_btree_cur *cur)
{ {
return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp, return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp,
cur->bc_ag.agbp, cur->bc_ag.agno, cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum);
cur->bc_ag.pag, cur->bc_btnum);
} }
STATIC void STATIC void
...@@ -428,7 +427,6 @@ static struct xfs_btree_cur * ...@@ -428,7 +427,6 @@ static struct xfs_btree_cur *
xfs_inobt_init_common( xfs_inobt_init_common(
struct xfs_mount *mp, /* file system mount point */ struct xfs_mount *mp, /* file system mount point */
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
xfs_agnumber_t agno, /* allocation group number */
struct xfs_perag *pag, struct xfs_perag *pag,
xfs_btnum_t btnum) /* ialloc or free ino btree */ xfs_btnum_t btnum) /* ialloc or free ino btree */
{ {
...@@ -451,12 +449,10 @@ xfs_inobt_init_common( ...@@ -451,12 +449,10 @@ xfs_inobt_init_common(
if (xfs_sb_version_hascrc(&mp->m_sb)) if (xfs_sb_version_hascrc(&mp->m_sb))
cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
cur->bc_ag.agno = agno;
if (pag) {
/* take a reference for the cursor */ /* take a reference for the cursor */
atomic_inc(&pag->pag_ref); atomic_inc(&pag->pag_ref);
}
cur->bc_ag.pag = pag; cur->bc_ag.pag = pag;
cur->bc_ag.agno = pag->pag_agno;
return cur; return cur;
} }
...@@ -466,14 +462,13 @@ xfs_inobt_init_cursor( ...@@ -466,14 +462,13 @@ xfs_inobt_init_cursor(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_buf *agbp, struct xfs_buf *agbp,
xfs_agnumber_t agno,
struct xfs_perag *pag, struct xfs_perag *pag,
xfs_btnum_t btnum) xfs_btnum_t btnum)
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
struct xfs_agi *agi = agbp->b_addr; 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) if (btnum == XFS_BTNUM_INO)
cur->bc_nlevels = be32_to_cpu(agi->agi_level); cur->bc_nlevels = be32_to_cpu(agi->agi_level);
else else
...@@ -487,12 +482,12 @@ struct xfs_btree_cur * ...@@ -487,12 +482,12 @@ struct xfs_btree_cur *
xfs_inobt_stage_cursor( xfs_inobt_stage_cursor(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xbtree_afakeroot *afake, struct xbtree_afakeroot *afake,
xfs_agnumber_t agno, struct xfs_perag *pag,
xfs_btnum_t btnum) xfs_btnum_t btnum)
{ {
struct xfs_btree_cur *cur; 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); xfs_btree_stage_afakeroot(cur, afake);
return cur; return cur;
} }
...@@ -664,7 +659,7 @@ int ...@@ -664,7 +659,7 @@ int
xfs_inobt_cur( xfs_inobt_cur(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_agnumber_t agno, struct xfs_perag *pag,
xfs_btnum_t which, xfs_btnum_t which,
struct xfs_btree_cur **curpp, struct xfs_btree_cur **curpp,
struct xfs_buf **agi_bpp) struct xfs_buf **agi_bpp)
...@@ -675,11 +670,11 @@ xfs_inobt_cur( ...@@ -675,11 +670,11 @@ xfs_inobt_cur(
ASSERT(*agi_bpp == NULL); ASSERT(*agi_bpp == NULL);
ASSERT(*curpp == 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) if (error)
return 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; *curpp = cur;
return 0; return 0;
} }
...@@ -696,7 +691,7 @@ xfs_inobt_count_blocks( ...@@ -696,7 +691,7 @@ xfs_inobt_count_blocks(
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
int error; 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) if (error)
return error; return error;
......
...@@ -47,10 +47,10 @@ struct xfs_perag; ...@@ -47,10 +47,10 @@ struct xfs_perag;
((index) - 1) * sizeof(xfs_inobt_ptr_t))) ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *mp, 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_perag *pag, xfs_btnum_t btnum);
struct xfs_btree_cur *xfs_inobt_stage_cursor(struct xfs_mount *mp, 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); xfs_btnum_t btnum);
extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int); 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, ...@@ -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, extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
unsigned long long len); unsigned long long len);
int xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp, 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); struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp);
void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur, void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,
......
...@@ -806,7 +806,7 @@ xrep_agi_calc_from_btrees( ...@@ -806,7 +806,7 @@ xrep_agi_calc_from_btrees(
xfs_agino_t freecount; xfs_agino_t freecount;
int error; 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); sc->sa.pag, XFS_BTNUM_INO);
error = xfs_ialloc_count_inodes(cur, &count, &freecount); error = xfs_ialloc_count_inodes(cur, &count, &freecount);
if (error) if (error)
...@@ -828,7 +828,7 @@ xrep_agi_calc_from_btrees( ...@@ -828,7 +828,7 @@ xrep_agi_calc_from_btrees(
xfs_sb_version_hasinobtcounts(&mp->m_sb)) { xfs_sb_version_hasinobtcounts(&mp->m_sb)) {
xfs_agblock_t blocks; 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); sc->sa.pag, XFS_BTNUM_FINO);
error = xfs_btree_count_blocks(cur, &blocks); error = xfs_btree_count_blocks(cur, &blocks);
if (error) if (error)
......
...@@ -458,7 +458,6 @@ xchk_ag_btcur_init( ...@@ -458,7 +458,6 @@ xchk_ag_btcur_init(
struct xchk_ag *sa) struct xchk_ag *sa)
{ {
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
xfs_agnumber_t agno = sa->agno;
xchk_perag_get(sc->mp, sa); xchk_perag_get(sc->mp, sa);
if (sa->agf_bp && if (sa->agf_bp &&
...@@ -479,14 +478,14 @@ xchk_ag_btcur_init( ...@@ -479,14 +478,14 @@ xchk_ag_btcur_init(
if (sa->agi_bp && if (sa->agi_bp &&
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_INO)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_INO)) {
sa->ino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp, 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. */ /* Set up a finobt cursor for cross-referencing. */
if (sa->agi_bp && xfs_sb_version_hasfinobt(&mp->m_sb) && if (sa->agi_bp && xfs_sb_version_hasfinobt(&mp->m_sb) &&
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_FINO)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_FINO)) {
sa->fino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp, 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. */ /* Set up a rmapbt cursor for cross-referencing. */
......
...@@ -272,8 +272,7 @@ xfs_iwalk_ag_start( ...@@ -272,8 +272,7 @@ xfs_iwalk_ag_start(
/* Set up a fresh cursor and empty the inobt cache. */ /* Set up a fresh cursor and empty the inobt cache. */
iwag->nr_recs = 0; iwag->nr_recs = 0;
error = xfs_inobt_cur(mp, tp, pag->pag_agno, XFS_BTNUM_INO, error = xfs_inobt_cur(mp, tp, pag, XFS_BTNUM_INO, curpp, agi_bpp);
curpp, agi_bpp);
if (error) if (error)
return error; return error;
...@@ -378,8 +377,7 @@ xfs_iwalk_run_callbacks( ...@@ -378,8 +377,7 @@ xfs_iwalk_run_callbacks(
return 0; return 0;
/* ...and recreate the cursor just past where we left off. */ /* ...and recreate the cursor just past where we left off. */
error = xfs_inobt_cur(mp, tp, iwag->pag->pag_agno, XFS_BTNUM_INO, error = xfs_inobt_cur(mp, tp, iwag->pag, XFS_BTNUM_INO, curpp, agi_bpp);
curpp, agi_bpp);
if (error) if (error)
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment