Commit be9fb17d authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: add a perag to the btree cursor

Which will eventually completely replace the agno in it.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 58d43a7e
...@@ -776,7 +776,8 @@ xfs_alloc_cur_setup( ...@@ -776,7 +776,8 @@ xfs_alloc_cur_setup(
*/ */
if (!acur->cnt) if (!acur->cnt)
acur->cnt = xfs_allocbt_init_cursor(args->mp, args->tp, acur->cnt = xfs_allocbt_init_cursor(args->mp, args->tp,
args->agbp, args->agno, XFS_BTNUM_CNT); args->agbp, args->agno,
args->pag, XFS_BTNUM_CNT);
error = xfs_alloc_lookup_ge(acur->cnt, 0, args->maxlen, &i); error = xfs_alloc_lookup_ge(acur->cnt, 0, args->maxlen, &i);
if (error) if (error)
return error; return error;
...@@ -786,10 +787,12 @@ xfs_alloc_cur_setup( ...@@ -786,10 +787,12 @@ xfs_alloc_cur_setup(
*/ */
if (!acur->bnolt) if (!acur->bnolt)
acur->bnolt = xfs_allocbt_init_cursor(args->mp, args->tp, acur->bnolt = xfs_allocbt_init_cursor(args->mp, args->tp,
args->agbp, args->agno, XFS_BTNUM_BNO); args->agbp, args->agno,
args->pag, XFS_BTNUM_BNO);
if (!acur->bnogt) if (!acur->bnogt)
acur->bnogt = xfs_allocbt_init_cursor(args->mp, args->tp, acur->bnogt = xfs_allocbt_init_cursor(args->mp, args->tp,
args->agbp, args->agno, XFS_BTNUM_BNO); args->agbp, args->agno,
args->pag, XFS_BTNUM_BNO);
return i == 1 ? 0 : -ENOSPC; return i == 1 ? 0 : -ENOSPC;
} }
...@@ -1217,7 +1220,7 @@ xfs_alloc_ag_vextent_exact( ...@@ -1217,7 +1220,7 @@ xfs_alloc_ag_vextent_exact(
* Allocate/initialize a cursor for the by-number freespace btree. * Allocate/initialize a cursor for the by-number freespace btree.
*/ */
bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp, bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_BNO); args->agno, args->pag, XFS_BTNUM_BNO);
/* /*
* Lookup bno and minlen in the btree (minlen is irrelevant, really). * Lookup bno and minlen in the btree (minlen is irrelevant, really).
...@@ -1277,7 +1280,7 @@ xfs_alloc_ag_vextent_exact( ...@@ -1277,7 +1280,7 @@ xfs_alloc_ag_vextent_exact(
* Allocate/initialize a cursor for the by-size btree. * Allocate/initialize a cursor for the by-size btree.
*/ */
cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp, cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_CNT); args->agno, args->pag, XFS_BTNUM_CNT);
ASSERT(args->agbno + args->len <= be32_to_cpu(agf->agf_length)); ASSERT(args->agbno + args->len <= be32_to_cpu(agf->agf_length));
error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, args->agbno, error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, args->agbno,
args->len, XFSA_FIXUP_BNO_OK); args->len, XFSA_FIXUP_BNO_OK);
...@@ -1674,7 +1677,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1674,7 +1677,7 @@ xfs_alloc_ag_vextent_size(
* Allocate and initialize a cursor for the by-size btree. * Allocate and initialize a cursor for the by-size btree.
*/ */
cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp, cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_CNT); args->agno, args->pag, XFS_BTNUM_CNT);
bno_cur = NULL; bno_cur = NULL;
busy = false; busy = false;
...@@ -1837,7 +1840,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1837,7 +1840,7 @@ xfs_alloc_ag_vextent_size(
* Allocate and initialize a cursor for the by-block tree. * Allocate and initialize a cursor for the by-block tree.
*/ */
bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp, bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_BNO); args->agno, args->pag, XFS_BTNUM_BNO);
if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
rbno, rlen, XFSA_FIXUP_CNT_OK))) rbno, rlen, XFSA_FIXUP_CNT_OK)))
goto error0; goto error0;
...@@ -1909,7 +1912,8 @@ xfs_free_ag_extent( ...@@ -1909,7 +1912,8 @@ xfs_free_ag_extent(
/* /*
* Allocate and initialize a cursor for the by-block btree. * Allocate and initialize a cursor for the by-block btree.
*/ */
bno_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO); bno_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno,
NULL, XFS_BTNUM_BNO);
/* /*
* Look for a neighboring block on the left (lower block numbers) * Look for a neighboring block on the left (lower block numbers)
* that is contiguous with this space. * that is contiguous with this space.
...@@ -1979,7 +1983,8 @@ xfs_free_ag_extent( ...@@ -1979,7 +1983,8 @@ xfs_free_ag_extent(
/* /*
* Now allocate and initialize a cursor for the by-size tree. * Now allocate and initialize a cursor for the by-size tree.
*/ */
cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT); cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno,
NULL, XFS_BTNUM_CNT);
/* /*
* Have both left and right contiguous neighbors. * Have both left and right contiguous neighbors.
* Merge all three into a single free block. * Merge all three into a single free block.
...@@ -2490,7 +2495,7 @@ xfs_exact_minlen_extent_available( ...@@ -2490,7 +2495,7 @@ xfs_exact_minlen_extent_available(
int error = 0; int error = 0;
cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, agbp, cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, agbp,
args->agno, XFS_BTNUM_CNT); args->agno, args->pag, XFS_BTNUM_CNT);
error = xfs_alloc_lookup_ge(cnt_cur, 0, args->minlen, stat); error = xfs_alloc_lookup_ge(cnt_cur, 0, args->minlen, stat);
if (error) if (error)
goto out; goto out;
......
...@@ -27,7 +27,7 @@ xfs_allocbt_dup_cursor( ...@@ -27,7 +27,7 @@ xfs_allocbt_dup_cursor(
{ {
return xfs_allocbt_init_cursor(cur->bc_mp, cur->bc_tp, return xfs_allocbt_init_cursor(cur->bc_mp, cur->bc_tp,
cur->bc_ag.agbp, cur->bc_ag.agno, cur->bc_ag.agbp, cur->bc_ag.agno,
cur->bc_btnum); cur->bc_ag.pag, cur->bc_btnum);
} }
STATIC void STATIC void
...@@ -473,6 +473,7 @@ xfs_allocbt_init_common( ...@@ -473,6 +473,7 @@ xfs_allocbt_init_common(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_agnumber_t agno, 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;
...@@ -497,6 +498,11 @@ xfs_allocbt_init_common( ...@@ -497,6 +498,11 @@ xfs_allocbt_init_common(
cur->bc_ag.agno = agno; cur->bc_ag.agno = agno;
cur->bc_ag.abt.active = false; cur->bc_ag.abt.active = false;
if (pag) {
/* take a reference for the cursor */
atomic_inc(&pag->pag_ref);
}
cur->bc_ag.pag = pag;
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;
...@@ -513,12 +519,13 @@ xfs_allocbt_init_cursor( ...@@ -513,12 +519,13 @@ xfs_allocbt_init_cursor(
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
struct xfs_buf *agbp, /* buffer for agf structure */ struct xfs_buf *agbp, /* buffer for agf structure */
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
struct xfs_perag *pag,
xfs_btnum_t btnum) /* btree identifier */ xfs_btnum_t btnum) /* btree identifier */
{ {
struct xfs_agf *agf = agbp->b_addr; struct xfs_agf *agf = agbp->b_addr;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_allocbt_init_common(mp, tp, agno, btnum); cur = xfs_allocbt_init_common(mp, tp, agno, pag, btnum);
if (btnum == XFS_BTNUM_CNT) if (btnum == XFS_BTNUM_CNT)
cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]); cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
else else
...@@ -539,7 +546,7 @@ xfs_allocbt_stage_cursor( ...@@ -539,7 +546,7 @@ xfs_allocbt_stage_cursor(
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_allocbt_init_common(mp, NULL, agno, btnum); cur = xfs_allocbt_init_common(mp, NULL, agno, NULL, btnum);
xfs_btree_stage_afakeroot(cur, afake); xfs_btree_stage_afakeroot(cur, afake);
return cur; return cur;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
struct xfs_buf; struct xfs_buf;
struct xfs_btree_cur; struct xfs_btree_cur;
struct xfs_mount; struct xfs_mount;
struct xfs_perag;
struct xbtree_afakeroot; struct xbtree_afakeroot;
/* /*
...@@ -48,7 +49,7 @@ struct xbtree_afakeroot; ...@@ -48,7 +49,7 @@ struct xbtree_afakeroot;
extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
struct xfs_trans *, struct xfs_buf *, struct xfs_trans *, struct xfs_buf *,
xfs_agnumber_t, xfs_btnum_t); xfs_agnumber_t, struct xfs_perag *pag, xfs_btnum_t);
struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp, struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp,
struct xbtree_afakeroot *afake, xfs_agnumber_t agno, struct xbtree_afakeroot *afake, xfs_agnumber_t agno,
xfs_btnum_t btnum); xfs_btnum_t btnum);
......
...@@ -377,6 +377,8 @@ xfs_btree_del_cursor( ...@@ -377,6 +377,8 @@ xfs_btree_del_cursor(
XFS_FORCED_SHUTDOWN(cur->bc_mp)); XFS_FORCED_SHUTDOWN(cur->bc_mp));
if (unlikely(cur->bc_flags & XFS_BTREE_STAGING)) if (unlikely(cur->bc_flags & XFS_BTREE_STAGING))
kmem_free(cur->bc_ops); kmem_free(cur->bc_ops);
if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS) && cur->bc_ag.pag)
xfs_perag_put(cur->bc_ag.pag);
kmem_cache_free(xfs_btree_cur_zone, cur); kmem_cache_free(xfs_btree_cur_zone, cur);
} }
......
...@@ -11,6 +11,7 @@ struct xfs_inode; ...@@ -11,6 +11,7 @@ struct xfs_inode;
struct xfs_mount; struct xfs_mount;
struct xfs_trans; struct xfs_trans;
struct xfs_ifork; struct xfs_ifork;
struct xfs_perag;
extern kmem_zone_t *xfs_btree_cur_zone; extern kmem_zone_t *xfs_btree_cur_zone;
...@@ -180,11 +181,12 @@ union xfs_btree_irec { ...@@ -180,11 +181,12 @@ union xfs_btree_irec {
/* Per-AG btree information. */ /* Per-AG btree information. */
struct xfs_btree_cur_ag { struct xfs_btree_cur_ag {
xfs_agnumber_t agno;
struct xfs_perag *pag;
union { union {
struct xfs_buf *agbp; struct xfs_buf *agbp;
struct xbtree_afakeroot *afake; /* for staging cursor */ struct xbtree_afakeroot *afake; /* for staging cursor */
}; };
xfs_agnumber_t agno;
union { union {
struct { struct {
unsigned long nr_ops; /* # record updates */ unsigned long nr_ops; /* # record updates */
...@@ -231,6 +233,13 @@ typedef struct xfs_btree_cur ...@@ -231,6 +233,13 @@ typedef struct xfs_btree_cur
uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */
xfs_btnum_t bc_btnum; /* identifies which btree type */ xfs_btnum_t bc_btnum; /* identifies which btree type */
int bc_statoff; /* offset of btre stats array */ int bc_statoff; /* offset of btre stats array */
/*
* Short btree pointers need an agno to be able to turn the pointers
* into physical addresses for IO, so the btree cursor switches between
* bc_ino and bc_ag based on whether XFS_BTREE_LONG_PTRS is set for the
* cursor.
*/
union { union {
struct xfs_btree_cur_ag bc_ag; struct xfs_btree_cur_ag bc_ag;
struct xfs_btree_cur_ino bc_ino; struct xfs_btree_cur_ino bc_ino;
......
...@@ -183,7 +183,7 @@ xfs_inobt_insert( ...@@ -183,7 +183,7 @@ xfs_inobt_insert(
int i; int i;
int error; int error;
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, btnum);
for (thisino = newino; for (thisino = newino;
thisino < newino + newlen; thisino < newino + newlen;
...@@ -531,7 +531,7 @@ xfs_inobt_insert_sprec( ...@@ -531,7 +531,7 @@ xfs_inobt_insert_sprec(
int i; int i;
struct xfs_inobt_rec_incore rec; struct xfs_inobt_rec_incore rec;
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, btnum);
/* the new record is pre-aligned so we know where to look */ /* the new record is pre-aligned so we know where to look */
error = xfs_inobt_lookup(cur, nrec->ir_startino, XFS_LOOKUP_EQ, &i); error = xfs_inobt_lookup(cur, nrec->ir_startino, XFS_LOOKUP_EQ, &i);
...@@ -1145,7 +1145,7 @@ xfs_dialloc_ag_inobt( ...@@ -1145,7 +1145,7 @@ xfs_dialloc_ag_inobt(
ASSERT(pag->pagi_freecount > 0); ASSERT(pag->pagi_freecount > 0);
restart_pagno: restart_pagno:
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_INO); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_INO);
/* /*
* If pagino is 0 (this is the root inode allocation) use newino. * If pagino is 0 (this is the root inode allocation) use newino.
* This must work because we've just allocated some. * This must work because we've just allocated some.
...@@ -1598,7 +1598,7 @@ xfs_dialloc_ag( ...@@ -1598,7 +1598,7 @@ xfs_dialloc_ag(
if (!pagino) if (!pagino)
pagino = be32_to_cpu(agi->agi_newino); pagino = be32_to_cpu(agi->agi_newino);
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_FINO); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_FINO);
error = xfs_check_agi_freecount(cur, agi); error = xfs_check_agi_freecount(cur, agi);
if (error) if (error)
...@@ -1641,7 +1641,7 @@ xfs_dialloc_ag( ...@@ -1641,7 +1641,7 @@ xfs_dialloc_ag(
* the original freecount. If all is well, make the equivalent update to * the original freecount. If all is well, make the equivalent update to
* the inobt using the finobt record and offset information. * the inobt using the finobt record and offset information.
*/ */
icur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_INO); icur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_INO);
error = xfs_check_agi_freecount(icur, agi); error = xfs_check_agi_freecount(icur, agi);
if (error) if (error)
...@@ -1954,7 +1954,7 @@ xfs_difree_inobt( ...@@ -1954,7 +1954,7 @@ xfs_difree_inobt(
/* /*
* Initialize the cursor. * Initialize the cursor.
*/ */
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_INO); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_INO);
error = xfs_check_agi_freecount(cur, agi); error = xfs_check_agi_freecount(cur, agi);
if (error) if (error)
...@@ -2080,7 +2080,7 @@ xfs_difree_finobt( ...@@ -2080,7 +2080,7 @@ xfs_difree_finobt(
int error; int error;
int i; int i;
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_FINO); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_FINO);
error = xfs_inobt_lookup(cur, ibtrec->ir_startino, XFS_LOOKUP_EQ, &i); error = xfs_inobt_lookup(cur, ibtrec->ir_startino, XFS_LOOKUP_EQ, &i);
if (error) if (error)
...@@ -2281,7 +2281,7 @@ xfs_imap_lookup( ...@@ -2281,7 +2281,7 @@ xfs_imap_lookup(
* we have a record, we need to ensure it contains the inode number * we have a record, we need to ensure it contains the inode number
* we are looking up. * we are looking up.
*/ */
cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_INO); cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, NULL, XFS_BTNUM_INO);
error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i); error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i);
if (!error) { if (!error) {
if (i) if (i)
......
...@@ -36,7 +36,7 @@ xfs_inobt_dup_cursor( ...@@ -36,7 +36,7 @@ xfs_inobt_dup_cursor(
{ {
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.agno,
cur->bc_btnum); cur->bc_ag.pag, cur->bc_btnum);
} }
STATIC void STATIC void
...@@ -429,6 +429,7 @@ xfs_inobt_init_common( ...@@ -429,6 +429,7 @@ 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 */ xfs_agnumber_t agno, /* allocation group number */
struct xfs_perag *pag,
xfs_btnum_t btnum) /* ialloc or free ino btree */ xfs_btnum_t btnum) /* ialloc or free ino btree */
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
...@@ -451,6 +452,11 @@ xfs_inobt_init_common( ...@@ -451,6 +452,11 @@ xfs_inobt_init_common(
cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
cur->bc_ag.agno = agno; cur->bc_ag.agno = agno;
if (pag) {
/* take a reference for the cursor */
atomic_inc(&pag->pag_ref);
}
cur->bc_ag.pag = pag;
return cur; return cur;
} }
...@@ -461,12 +467,13 @@ xfs_inobt_init_cursor( ...@@ -461,12 +467,13 @@ xfs_inobt_init_cursor(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_buf *agbp, struct xfs_buf *agbp,
xfs_agnumber_t agno, 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;
struct xfs_agi *agi = agbp->b_addr; struct xfs_agi *agi = agbp->b_addr;
cur = xfs_inobt_init_common(mp, tp, agno, btnum); cur = xfs_inobt_init_common(mp, tp, agno, 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
...@@ -485,7 +492,7 @@ xfs_inobt_stage_cursor( ...@@ -485,7 +492,7 @@ xfs_inobt_stage_cursor(
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_inobt_init_common(mp, NULL, agno, btnum); cur = xfs_inobt_init_common(mp, NULL, agno, NULL, btnum);
xfs_btree_stage_afakeroot(cur, afake); xfs_btree_stage_afakeroot(cur, afake);
return cur; return cur;
} }
...@@ -672,7 +679,7 @@ xfs_inobt_cur( ...@@ -672,7 +679,7 @@ xfs_inobt_cur(
if (error) if (error)
return error; return error;
cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, agno, which); cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, agno, NULL, which);
*curpp = cur; *curpp = cur;
return 0; return 0;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
struct xfs_buf; struct xfs_buf;
struct xfs_btree_cur; struct xfs_btree_cur;
struct xfs_mount; struct xfs_mount;
struct xfs_perag;
/* /*
* Btree block header size depends on a superblock flag. * Btree block header size depends on a superblock flag.
...@@ -45,9 +46,9 @@ struct xfs_mount; ...@@ -45,9 +46,9 @@ struct xfs_mount;
(maxrecs) * sizeof(xfs_inobt_key_t) + \ (maxrecs) * sizeof(xfs_inobt_key_t) + \
((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 *, extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *mp,
struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t, struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno,
xfs_btnum_t); 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, xfs_agnumber_t agno,
xfs_btnum_t btnum); xfs_btnum_t btnum);
......
...@@ -1178,7 +1178,7 @@ xfs_refcount_finish_one( ...@@ -1178,7 +1178,7 @@ xfs_refcount_finish_one(
if (error) if (error)
return error; return error;
rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno); rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
rcur->bc_ag.refc.nr_ops = nr_ops; rcur->bc_ag.refc.nr_ops = nr_ops;
rcur->bc_ag.refc.shape_changes = shape_changes; rcur->bc_ag.refc.shape_changes = shape_changes;
} }
...@@ -1707,7 +1707,7 @@ xfs_refcount_recover_cow_leftovers( ...@@ -1707,7 +1707,7 @@ xfs_refcount_recover_cow_leftovers(
error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
if (error) if (error)
goto out_trans; goto out_trans;
cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno); cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
/* Find all the leftover CoW staging extents. */ /* Find all the leftover CoW staging extents. */
memset(&low, 0, sizeof(low)); memset(&low, 0, sizeof(low));
......
...@@ -26,7 +26,7 @@ xfs_refcountbt_dup_cursor( ...@@ -26,7 +26,7 @@ xfs_refcountbt_dup_cursor(
struct xfs_btree_cur *cur) struct xfs_btree_cur *cur)
{ {
return xfs_refcountbt_init_cursor(cur->bc_mp, cur->bc_tp, return xfs_refcountbt_init_cursor(cur->bc_mp, cur->bc_tp,
cur->bc_ag.agbp, cur->bc_ag.agno); cur->bc_ag.agbp, cur->bc_ag.agno, cur->bc_ag.pag);
} }
STATIC void STATIC void
...@@ -316,7 +316,8 @@ static struct xfs_btree_cur * ...@@ -316,7 +316,8 @@ static struct xfs_btree_cur *
xfs_refcountbt_init_common( xfs_refcountbt_init_common(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_agnumber_t agno) xfs_agnumber_t agno,
struct xfs_perag *pag)
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
...@@ -332,6 +333,11 @@ xfs_refcountbt_init_common( ...@@ -332,6 +333,11 @@ xfs_refcountbt_init_common(
cur->bc_ag.agno = agno; cur->bc_ag.agno = agno;
cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
if (pag) {
/* take a reference for the cursor */
atomic_inc(&pag->pag_ref);
}
cur->bc_ag.pag = pag;
cur->bc_ag.refc.nr_ops = 0; cur->bc_ag.refc.nr_ops = 0;
cur->bc_ag.refc.shape_changes = 0; cur->bc_ag.refc.shape_changes = 0;
...@@ -345,12 +351,13 @@ xfs_refcountbt_init_cursor( ...@@ -345,12 +351,13 @@ xfs_refcountbt_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) xfs_agnumber_t agno,
struct xfs_perag *pag)
{ {
struct xfs_agf *agf = agbp->b_addr; struct xfs_agf *agf = agbp->b_addr;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_refcountbt_init_common(mp, tp, agno); cur = xfs_refcountbt_init_common(mp, tp, agno, pag);
cur->bc_nlevels = be32_to_cpu(agf->agf_refcount_level); cur->bc_nlevels = be32_to_cpu(agf->agf_refcount_level);
cur->bc_ag.agbp = agbp; cur->bc_ag.agbp = agbp;
return cur; return cur;
...@@ -365,7 +372,7 @@ xfs_refcountbt_stage_cursor( ...@@ -365,7 +372,7 @@ xfs_refcountbt_stage_cursor(
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_refcountbt_init_common(mp, NULL, agno); cur = xfs_refcountbt_init_common(mp, NULL, agno, NULL);
xfs_btree_stage_afakeroot(cur, afake); xfs_btree_stage_afakeroot(cur, afake);
return cur; return cur;
} }
......
...@@ -47,7 +47,7 @@ struct xbtree_afakeroot; ...@@ -47,7 +47,7 @@ struct xbtree_afakeroot;
extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp, extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_buf *agbp, struct xfs_trans *tp, struct xfs_buf *agbp,
xfs_agnumber_t agno); xfs_agnumber_t agno, struct xfs_perag *pag);
struct xfs_btree_cur *xfs_refcountbt_stage_cursor(struct xfs_mount *mp, struct xfs_btree_cur *xfs_refcountbt_stage_cursor(struct xfs_mount *mp,
struct xbtree_afakeroot *afake, xfs_agnumber_t agno); struct xbtree_afakeroot *afake, xfs_agnumber_t agno);
extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf); extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf);
......
...@@ -708,7 +708,7 @@ xfs_rmap_free( ...@@ -708,7 +708,7 @@ xfs_rmap_free(
if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
return 0; return 0;
cur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno); cur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno, NULL);
error = xfs_rmap_unmap(cur, bno, len, false, oinfo); error = xfs_rmap_unmap(cur, bno, len, false, oinfo);
...@@ -962,7 +962,7 @@ xfs_rmap_alloc( ...@@ -962,7 +962,7 @@ xfs_rmap_alloc(
if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
return 0; return 0;
cur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno); cur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno, NULL);
error = xfs_rmap_map(cur, bno, len, false, oinfo); error = xfs_rmap_map(cur, bno, len, false, oinfo);
xfs_btree_del_cursor(cur, error); xfs_btree_del_cursor(cur, error);
...@@ -2408,7 +2408,7 @@ xfs_rmap_finish_one( ...@@ -2408,7 +2408,7 @@ xfs_rmap_finish_one(
goto out_drop; goto out_drop;
} }
rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag->pag_agno); rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag->pag_agno, pag);
} }
*pcur = rcur; *pcur = rcur;
......
...@@ -52,7 +52,7 @@ xfs_rmapbt_dup_cursor( ...@@ -52,7 +52,7 @@ xfs_rmapbt_dup_cursor(
struct xfs_btree_cur *cur) struct xfs_btree_cur *cur)
{ {
return xfs_rmapbt_init_cursor(cur->bc_mp, cur->bc_tp, return xfs_rmapbt_init_cursor(cur->bc_mp, cur->bc_tp,
cur->bc_ag.agbp, cur->bc_ag.agno); cur->bc_ag.agbp, cur->bc_ag.agno, cur->bc_ag.pag);
} }
STATIC void STATIC void
...@@ -449,7 +449,8 @@ static struct xfs_btree_cur * ...@@ -449,7 +449,8 @@ static struct xfs_btree_cur *
xfs_rmapbt_init_common( xfs_rmapbt_init_common(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_agnumber_t agno) xfs_agnumber_t agno,
struct xfs_perag *pag)
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
...@@ -463,6 +464,11 @@ xfs_rmapbt_init_common( ...@@ -463,6 +464,11 @@ xfs_rmapbt_init_common(
cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_rmap_2); cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_rmap_2);
cur->bc_ag.agno = agno; cur->bc_ag.agno = agno;
cur->bc_ops = &xfs_rmapbt_ops; cur->bc_ops = &xfs_rmapbt_ops;
if (pag) {
/* take a reference for the cursor */
atomic_inc(&pag->pag_ref);
}
cur->bc_ag.pag = pag;
return cur; return cur;
} }
...@@ -473,12 +479,13 @@ xfs_rmapbt_init_cursor( ...@@ -473,12 +479,13 @@ xfs_rmapbt_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) xfs_agnumber_t agno,
struct xfs_perag *pag)
{ {
struct xfs_agf *agf = agbp->b_addr; struct xfs_agf *agf = agbp->b_addr;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_rmapbt_init_common(mp, tp, agno); cur = xfs_rmapbt_init_common(mp, tp, agno, pag);
cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]);
cur->bc_ag.agbp = agbp; cur->bc_ag.agbp = agbp;
return cur; return cur;
...@@ -493,7 +500,7 @@ xfs_rmapbt_stage_cursor( ...@@ -493,7 +500,7 @@ xfs_rmapbt_stage_cursor(
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = xfs_rmapbt_init_common(mp, NULL, agno); cur = xfs_rmapbt_init_common(mp, NULL, agno, NULL);
xfs_btree_stage_afakeroot(cur, afake); xfs_btree_stage_afakeroot(cur, afake);
return cur; return cur;
} }
......
...@@ -43,7 +43,7 @@ struct xbtree_afakeroot; ...@@ -43,7 +43,7 @@ struct xbtree_afakeroot;
struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp, struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_buf *bp, struct xfs_trans *tp, struct xfs_buf *bp,
xfs_agnumber_t agno); xfs_agnumber_t agno, struct xfs_perag *pag);
struct xfs_btree_cur *xfs_rmapbt_stage_cursor(struct xfs_mount *mp, struct xfs_btree_cur *xfs_rmapbt_stage_cursor(struct xfs_mount *mp,
struct xbtree_afakeroot *afake, xfs_agnumber_t agno); struct xbtree_afakeroot *afake, xfs_agnumber_t agno);
void xfs_rmapbt_commit_staged_btree(struct xfs_btree_cur *cur, void xfs_rmapbt_commit_staged_btree(struct xfs_btree_cur *cur,
......
...@@ -247,7 +247,7 @@ xrep_agf_calc_from_btrees( ...@@ -247,7 +247,7 @@ xrep_agf_calc_from_btrees(
/* Update the AGF counters from the bnobt. */ /* 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.agno,
XFS_BTNUM_BNO); sc->sa.pag, XFS_BTNUM_BNO);
error = xfs_alloc_query_all(cur, xrep_agf_walk_allocbt, &raa); error = xfs_alloc_query_all(cur, xrep_agf_walk_allocbt, &raa);
if (error) if (error)
goto err; goto err;
...@@ -261,7 +261,7 @@ xrep_agf_calc_from_btrees( ...@@ -261,7 +261,7 @@ xrep_agf_calc_from_btrees(
/* Update the AGF counters from the cntbt. */ /* 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.agno,
XFS_BTNUM_CNT); sc->sa.pag, XFS_BTNUM_CNT);
error = xfs_btree_count_blocks(cur, &blocks); error = xfs_btree_count_blocks(cur, &blocks);
if (error) if (error)
goto err; goto err;
...@@ -269,7 +269,8 @@ xrep_agf_calc_from_btrees( ...@@ -269,7 +269,8 @@ xrep_agf_calc_from_btrees(
btreeblks += blocks - 1; btreeblks += blocks - 1;
/* Update the AGF counters from the rmapbt. */ /* Update the AGF counters from the rmapbt. */
cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno); cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno,
sc->sa.pag);
error = xfs_btree_count_blocks(cur, &blocks); error = xfs_btree_count_blocks(cur, &blocks);
if (error) if (error)
goto err; goto err;
...@@ -282,7 +283,7 @@ xrep_agf_calc_from_btrees( ...@@ -282,7 +283,7 @@ xrep_agf_calc_from_btrees(
/* Update the AGF counters from the refcountbt. */ /* Update the AGF counters from the refcountbt. */
if (xfs_sb_version_hasreflink(&mp->m_sb)) { if (xfs_sb_version_hasreflink(&mp->m_sb)) {
cur = xfs_refcountbt_init_cursor(mp, sc->tp, agf_bp, cur = xfs_refcountbt_init_cursor(mp, sc->tp, agf_bp,
sc->sa.agno); sc->sa.agno, sc->sa.pag);
error = xfs_btree_count_blocks(cur, &blocks); error = xfs_btree_count_blocks(cur, &blocks);
if (error) if (error)
goto err; goto err;
...@@ -490,7 +491,8 @@ xrep_agfl_collect_blocks( ...@@ -490,7 +491,8 @@ xrep_agfl_collect_blocks(
xbitmap_init(&ra.agmetablocks); xbitmap_init(&ra.agmetablocks);
/* Find all space used by the free space btrees & rmapbt. */ /* Find all space used by the free space btrees & rmapbt. */
cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno); cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno,
sc->sa.pag);
error = xfs_rmap_query_all(cur, xrep_agfl_walk_rmap, &ra); error = xfs_rmap_query_all(cur, xrep_agfl_walk_rmap, &ra);
if (error) if (error)
goto err; goto err;
...@@ -498,7 +500,7 @@ xrep_agfl_collect_blocks( ...@@ -498,7 +500,7 @@ xrep_agfl_collect_blocks(
/* Find all blocks currently being used by the bnobt. */ /* 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.agno,
XFS_BTNUM_BNO); sc->sa.pag, XFS_BTNUM_BNO);
error = xbitmap_set_btblocks(&ra.agmetablocks, cur); error = xbitmap_set_btblocks(&ra.agmetablocks, cur);
if (error) if (error)
goto err; goto err;
...@@ -506,7 +508,7 @@ xrep_agfl_collect_blocks( ...@@ -506,7 +508,7 @@ xrep_agfl_collect_blocks(
/* Find all blocks currently being used by the cntbt. */ /* 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.agno,
XFS_BTNUM_CNT); sc->sa.pag, XFS_BTNUM_CNT);
error = xbitmap_set_btblocks(&ra.agmetablocks, cur); error = xbitmap_set_btblocks(&ra.agmetablocks, cur);
if (error) if (error)
goto err; goto err;
...@@ -807,7 +809,7 @@ xrep_agi_calc_from_btrees( ...@@ -807,7 +809,7 @@ xrep_agi_calc_from_btrees(
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.agno,
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)
goto err; goto err;
...@@ -829,7 +831,7 @@ xrep_agi_calc_from_btrees( ...@@ -829,7 +831,7 @@ xrep_agi_calc_from_btrees(
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.agno,
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)
goto err; goto err;
......
...@@ -556,7 +556,7 @@ xchk_bmap_check_ag_rmaps( ...@@ -556,7 +556,7 @@ xchk_bmap_check_ag_rmaps(
if (error) if (error)
return error; return error;
cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno); cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno, NULL);
sbcri.sc = sc; sbcri.sc = sc;
sbcri.whichfork = whichfork; sbcri.whichfork = whichfork;
......
...@@ -465,42 +465,42 @@ xchk_ag_btcur_init( ...@@ -465,42 +465,42 @@ xchk_ag_btcur_init(
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) {
/* Set up a bnobt cursor for cross-referencing. */ /* Set up a bnobt cursor for cross-referencing. */
sa->bno_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->bno_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno, XFS_BTNUM_BNO); agno, sa->pag, XFS_BTNUM_BNO);
} }
if (sa->agf_bp && if (sa->agf_bp &&
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_CNT)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_CNT)) {
/* Set up a cntbt cursor for cross-referencing. */ /* Set up a cntbt cursor for cross-referencing. */
sa->cnt_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->cnt_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno, XFS_BTNUM_CNT); agno, sa->pag, XFS_BTNUM_CNT);
} }
/* Set up a inobt cursor for cross-referencing. */ /* Set up a inobt cursor for cross-referencing. */
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, XFS_BTNUM_INO); agno, 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, XFS_BTNUM_FINO); agno, sa->pag, XFS_BTNUM_FINO);
} }
/* Set up a rmapbt cursor for cross-referencing. */ /* Set up a rmapbt cursor for cross-referencing. */
if (sa->agf_bp && xfs_sb_version_hasrmapbt(&mp->m_sb) && if (sa->agf_bp && xfs_sb_version_hasrmapbt(&mp->m_sb) &&
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno); agno, sa->pag);
} }
/* Set up a refcountbt cursor for cross-referencing. */ /* Set up a refcountbt cursor for cross-referencing. */
if (sa->agf_bp && xfs_sb_version_hasreflink(&mp->m_sb) && if (sa->agf_bp && xfs_sb_version_hasreflink(&mp->m_sb) &&
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_REFC)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_REFC)) {
sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp, sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp,
sa->agf_bp, agno); sa->agf_bp, agno, sa->pag);
} }
} }
......
...@@ -555,7 +555,7 @@ xrep_reap_block( ...@@ -555,7 +555,7 @@ xrep_reap_block(
} else { } else {
agf_bp = sc->sa.agf_bp; agf_bp = sc->sa.agf_bp;
} }
cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf_bp, agno); cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf_bp, agno, sc->sa.pag);
/* Can we find any other rmappings? */ /* Can we find any other rmappings? */
error = xfs_rmap_has_other_keys(cur, agbno, 1, oinfo, &has_other_rmap); error = xfs_rmap_has_other_keys(cur, agbno, 1, oinfo, &has_other_rmap);
...@@ -892,7 +892,8 @@ xrep_find_ag_btree_roots( ...@@ -892,7 +892,8 @@ xrep_find_ag_btree_roots(
fab->height = 0; fab->height = 0;
} }
cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno); cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.agno,
sc->sa.pag);
error = xfs_rmap_query_all(cur, xrep_findroot_rmap, &ri); error = xfs_rmap_query_all(cur, xrep_findroot_rmap, &ri);
xfs_btree_del_cursor(cur, error); xfs_btree_del_cursor(cur, error);
......
...@@ -50,7 +50,7 @@ xfs_trim_extents( ...@@ -50,7 +50,7 @@ xfs_trim_extents(
goto out_put_perag; goto out_put_perag;
agf = agbp->b_addr; agf = agbp->b_addr;
cur = xfs_allocbt_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_CNT); cur = xfs_allocbt_init_cursor(mp, NULL, agbp, agno, pag, XFS_BTNUM_CNT);
/* /*
* Look up the longest btree in the AGF and start with it. * Look up the longest btree in the AGF and start with it.
......
...@@ -211,7 +211,7 @@ xfs_getfsmap_is_shared( ...@@ -211,7 +211,7 @@ xfs_getfsmap_is_shared(
/* Are there any shared blocks here? */ /* Are there any shared blocks here? */
flen = 0; flen = 0;
cur = xfs_refcountbt_init_cursor(mp, tp, info->agf_bp, cur = xfs_refcountbt_init_cursor(mp, tp, info->agf_bp,
info->pag->pag_agno); info->pag->pag_agno, info->pag);
error = xfs_refcount_find_shared(cur, rec->rm_startblock, error = xfs_refcount_find_shared(cur, rec->rm_startblock,
rec->rm_blockcount, &fbno, &flen, false); rec->rm_blockcount, &fbno, &flen, false);
...@@ -708,7 +708,7 @@ xfs_getfsmap_datadev_rmapbt_query( ...@@ -708,7 +708,7 @@ xfs_getfsmap_datadev_rmapbt_query(
/* Allocate cursor for this AG and query_range it. */ /* Allocate cursor for this AG and query_range it. */
*curpp = xfs_rmapbt_init_cursor(tp->t_mountp, tp, info->agf_bp, *curpp = xfs_rmapbt_init_cursor(tp->t_mountp, tp, info->agf_bp,
info->pag->pag_agno); info->pag->pag_agno, info->pag);
return xfs_rmap_query_range(*curpp, &info->low, &info->high, return xfs_rmap_query_range(*curpp, &info->low, &info->high,
xfs_getfsmap_datadev_helper, info); xfs_getfsmap_datadev_helper, info);
} }
...@@ -741,7 +741,7 @@ xfs_getfsmap_datadev_bnobt_query( ...@@ -741,7 +741,7 @@ xfs_getfsmap_datadev_bnobt_query(
/* Allocate cursor for this AG and query_range it. */ /* Allocate cursor for this AG and query_range it. */
*curpp = xfs_allocbt_init_cursor(tp->t_mountp, tp, info->agf_bp, *curpp = xfs_allocbt_init_cursor(tp->t_mountp, tp, info->agf_bp,
info->pag->pag_agno, XFS_BTNUM_BNO); info->pag->pag_agno, info->pag, XFS_BTNUM_BNO);
key->ar_startblock = info->low.rm_startblock; key->ar_startblock = info->low.rm_startblock;
key[1].ar_startblock = info->high.rm_startblock; key[1].ar_startblock = info->high.rm_startblock;
return xfs_alloc_query_range(*curpp, key, &key[1], return xfs_alloc_query_range(*curpp, key, &key[1],
......
...@@ -144,7 +144,7 @@ xfs_reflink_find_shared( ...@@ -144,7 +144,7 @@ xfs_reflink_find_shared(
if (error) if (error)
return error; return error;
cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno); cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
error = xfs_refcount_find_shared(cur, agbno, aglen, fbno, flen, error = xfs_refcount_find_shared(cur, agbno, aglen, fbno, flen,
find_end_of_shared); find_end_of_shared);
......
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