The mount structure and inode can be derived from the rtg.
Signed-off-by: Christoph Hellwig <hch@lst.de>
if (rcur == NULL) {
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_REFCOUNT);
xfs_rtgroup_trans_join(tp, rtg, XFS_RTGLOCK_REFCOUNT);
- *pcur = rcur = xfs_rtrefcountbt_init_cursor(mp, tp, rtg,
- rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
-
+ *pcur = rcur = xfs_rtrefcountbt_init_cursor(tp, rtg);
rcur->bc_refc.nr_ops = nr_ops;
rcur->bc_refc.shape_changes = shape_changes;
}
if (isrt) {
xfs_rtgroup_lock(to_rtg(xg), XFS_RTGLOCK_REFCOUNT);
- cur = xfs_rtrefcountbt_init_cursor(mp, tp, to_rtg(xg),
- to_rtg(xg)->rtg_inodes[XFS_RTGI_REFCOUNT]);
+ cur = xfs_rtrefcountbt_init_cursor(tp, to_rtg(xg));
} else {
error = xfs_alloc_read_agf(to_perag(xg), tp, 0, &agbp);
if (error)
xfs_rtrefcountbt_dup_cursor(
struct xfs_btree_cur *cur)
{
- struct xfs_btree_cur *new;
-
- new = xfs_rtrefcountbt_init_cursor(cur->bc_mp, cur->bc_tp,
- to_rtg(cur->bc_group), cur->bc_ino.ip);
-
- return new;
+ return xfs_rtrefcountbt_init_cursor(cur->bc_tp, to_rtg(cur->bc_group));
}
STATIC int
/* Allocate a new rt refcount btree cursor. */
struct xfs_btree_cur *
xfs_rtrefcountbt_init_cursor(
- struct xfs_mount *mp,
struct xfs_trans *tp,
- struct xfs_rtgroup *rtg,
- struct xfs_inode *ip)
+ struct xfs_rtgroup *rtg)
{
+ struct xfs_inode *ip = rtg->rtg_inodes[XFS_RTGI_REFCOUNT];
+ struct xfs_mount *mp = rtg_mount(rtg);
struct xfs_btree_cur *cur;
- struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
xfs_assert_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL);
cur->bc_refc.nr_ops = 0;
cur->bc_refc.shape_changes = 0;
cur->bc_group = xfs_group_hold(&rtg->rtg_group);
- cur->bc_nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1;
+ cur->bc_nlevels = be16_to_cpu(ip->i_df.if_broot->bb_level) + 1;
cur->bc_ino.forksize = xfs_inode_fork_size(ip, XFS_DATA_FORK);
cur->bc_ino.whichfork = XFS_DATA_FORK;
return cur;
/* refcounts only exist on crc enabled filesystems */
#define XFS_RTREFCOUNT_BLOCK_LEN XFS_BTREE_LBLOCK_CRC_LEN
-struct xfs_btree_cur *xfs_rtrefcountbt_init_cursor(struct xfs_mount *mp,
- struct xfs_trans *tp, struct xfs_rtgroup *rtg,
- struct xfs_inode *ip);
+struct xfs_btree_cur *xfs_rtrefcountbt_init_cursor(struct xfs_trans *tp,
+ struct xfs_rtgroup *rtg);
struct xfs_btree_cur *xfs_rtrefcountbt_stage_cursor(struct xfs_mount *mp,
struct xfs_rtgroup *rtg, struct xfs_inode *ip,
struct xbtree_ifakeroot *ifake);
sr->rmap_cur = xfs_rtrmapbt_init_cursor(sc->tp, sr->rtg);
if (xfs_has_rtreflink(sc->mp) && (rtglock_flags & XFS_RTGLOCK_REFCOUNT))
- sr->refc_cur = xfs_rtrefcountbt_init_cursor(sc->mp, sc->tp,
- sr->rtg, sr->rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
+ sr->refc_cur = xfs_rtrefcountbt_init_cursor(sc->tp, sr->rtg);
return 0;
}
ASSERT(0);
return -EFSCORRUPTED;
}
- cur = xfs_rtrefcountbt_init_cursor(sc->mp, sc->tp, sc->sr.rtg,
- sc->ip);
+ cur = xfs_rtrefcountbt_init_cursor(sc->tp, sc->sr.rtg);
goto meta_btree;
}
if (sc->sm->sm_type != XFS_SCRUB_TYPE_RTREFCBT &&
(sr->rtlock_flags & XFS_RTGLOCK_REFCOUNT) &&
xfs_has_rtreflink(mp))
- sr->refc_cur = xfs_rtrefcountbt_init_cursor(mp, sc->tp,
- sr->rtg,
- sr->rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
+ sr->refc_cur = xfs_rtrefcountbt_init_cursor(sc->tp, sr->rtg);
}
/*
while ((rtg = xfs_rtgroup_next(sc->mp, rtg))) {
if (ip == rtg->rtg_inodes[XFS_RTGI_REFCOUNT]) {
- cur = xfs_rtrefcountbt_init_cursor(sc->mp, sc->tp, rtg,
- ip);
+ cur = xfs_rtrefcountbt_init_cursor(sc->tp, rtg);
error = xrep_rmap_scan_iroot_btree(rf, cur);
xfs_btree_del_cursor(cur, error);
xfs_rtgroup_rele(rtg);
rr->new_btree.bload.claim_block = xrep_rtrefc_claim_block;
rr->new_btree.bload.iroot_size = xrep_rtrefc_iroot_size;
- refc_cur = xfs_rtrefcountbt_init_cursor(sc->mp, NULL, rtg,
- rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
+ refc_cur = xfs_rtrefcountbt_init_cursor(NULL, rtg);
xfs_btree_stage_ifakeroot(refc_cur, &rr->new_btree.ifake);
/* Compute how many blocks we'll need. */
if (!xfs_has_reflink(mp) || !info->group)
return 0;
- if (info->group->xg_type == XG_TYPE_RTG) {
- struct xfs_rtgroup *rtg = to_rtg(info->group);
-
- cur = xfs_rtrefcountbt_init_cursor(mp, tp, rtg,
- rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
- } else {
+ if (info->group->xg_type == XG_TYPE_RTG)
+ cur = xfs_rtrefcountbt_init_cursor(tp, to_rtg(info->group));
+ else
cur = xfs_refcountbt_init_cursor(mp, tp, info->agf_bp,
to_perag(info->group));
- }
/* Are there any shared blocks here? */
error = xfs_refcount_find_shared(cur, frec->rec_key,
rtg = xfs_rtgroup_get(mp, xfs_rtb_to_rgno(mp, irec->br_startblock));
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_REFCOUNT);
- cur = xfs_rtrefcountbt_init_cursor(mp, tp, rtg,
- rtg->rtg_inodes[XFS_RTGI_REFCOUNT]);
+ cur = xfs_rtrefcountbt_init_cursor(tp, rtg);
error = xfs_refcount_find_shared(cur, orig_bno, irec->br_blockcount,
&found_bno, shared_len, find_end_of_shared);
xfs_btree_del_cursor(cur, error);