struct xfs_fsmap_head *head;
struct fsmap *fsmap_recs; /* mapping records */
struct xfs_buf *agf_bp; /* AGF, for refcount queries */
- struct xfs_perag *pag; /* AG info, if applicable */
- struct xfs_rtgroup *rtg; /* rtgroup, if applicable */
+ struct xfs_group *group; /* group info, if applicable */
xfs_daddr_t next_daddr; /* next daddr we expect */
/* daddr of low fsmap key when we're using the rtbitmap */
xfs_daddr_t low_daddr;
*stat = false;
if (!xfs_has_reflink(mp))
return 0;
-
- if (info->rtg)
- cur = xfs_rtrefcountbt_init_cursor(tp, info->rtg);
- else if (info->pag)
- cur = xfs_refcountbt_init_cursor(mp, tp, info->agf_bp,
- info->pag);
- else
+ if (!info->group)
return 0;
+ 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? */
flen = 0;
if (info->head->fmh_entries >= info->head->fmh_count)
return -ECANCELED;
- if (info->pag)
- trace_xfs_fsmap_mapping(mp, info->dev, pag_agno(info->pag),
- frec);
- else if (info->rtg)
- trace_xfs_fsmap_mapping(mp, info->dev, rtg_rgno(info->rtg),
- frec);
- else
- trace_xfs_fsmap_mapping(mp, info->dev, NULLAGNUMBER, frec);
+ trace_xfs_fsmap_mapping(mp, info->dev,
+ info->group ? info->group->xg_index : NULLAGNUMBER, frec);
fmr.fmr_device = info->dev;
fmr.fmr_physical = frec->start_daddr;
* Set the AG high key from the fsmap high key if this
* is the last AG that we're querying.
*/
- info->pag = pag;
+ info->group = &pag->pag_group;
if (pag_agno(pag) == end_ag) {
info->high.rm_startblock = XFS_FSB_TO_AGBNO(mp,
end_fsb);
if (error)
break;
}
- info->pag = NULL;
+ info->group = NULL;
}
if (bt_cur)
xfs_trans_brelse(tp, info->agf_bp);
info->agf_bp = NULL;
}
- if (info->pag) {
- xfs_perag_rele(info->pag);
- info->pag = NULL;
+ if (info->group) {
+ xfs_perag_rele(pag);
+ info->group = NULL;
} else if (pag) {
/* loop termination case */
xfs_perag_rele(pag);
/* Allocate cursor for this AG and query_range it. */
*curpp = xfs_rmapbt_init_cursor(tp->t_mountp, tp, info->agf_bp,
- info->pag);
+ to_perag(info->group));
return xfs_rmap_query_range(*curpp, &info->low, &info->high,
xfs_getfsmap_rmapbt_helper, info);
}
/* Allocate cursor for this AG and query_range it. */
*curpp = xfs_bnobt_init_cursor(tp->t_mountp, tp, info->agf_bp,
- info->pag);
+ to_perag(info->group));
key->ar_startblock = info->low.rm_startblock;
key[1].ar_startblock = info->high.rm_startblock;
return xfs_alloc_query_range(*curpp, key, &key[1],
end_rtx = xfs_rtb_to_rtx(mp,
end_rtbno + mp->m_sb.sb_rextsize - 1);
- info->rtg = rtg;
+ info->group = &rtg->rtg_group;
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_BITMAP_SHARED);
error = xfs_rtalloc_query_range(rtg, tp, start_rtx, end_rtx,
xfs_getfsmap_rtdev_rtbitmap_helper, info);
}
xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_BITMAP_SHARED);
- info->rtg = NULL;
+ info->group = NULL;
start_rtx = 0;
}
- if (info->rtg) {
- xfs_rtgroup_unlock(info->rtg, XFS_RTGLOCK_BITMAP_SHARED);
- xfs_rtgroup_rele(info->rtg);
- info->rtg = NULL;
+ if (info->group) {
+ xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_BITMAP_SHARED);
+ xfs_rtgroup_rele(rtg);
+ info->group = NULL;
} else if (rtg) {
/* loop termination case */
xfs_rtgroup_rele(rtg);
struct xfs_getfsmap_info *info,
struct xfs_btree_cur **curpp)
{
+ struct xfs_rtgroup *rtg = to_rtg(info->group);
+
/* Report any gap at the end of the last rtgroup. */
if (info->last)
return xfs_getfsmap_rmapbt_helper(*curpp, &info->high, info);
/* Query the rtrmapbt */
- xfs_rtgroup_lock(info->rtg, XFS_RTGLOCK_RMAP | XFS_RTGLOCK_REFCOUNT);
- *curpp = xfs_rtrmapbt_init_cursor(tp, info->rtg);
+ xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP | XFS_RTGLOCK_REFCOUNT);
+ *curpp = xfs_rtrmapbt_init_cursor(tp, rtg);
return xfs_rmap_query_range(*curpp, &info->low, &info->high,
xfs_getfsmap_rmapbt_helper, info);
}
* Set the rtgroup high key from the fsmap high key if this
* is the last rtgroup that we're querying.
*/
- info->rtg = rtg;
+ info->group = &rtg->rtg_group;
if (rtg_rgno(rtg) == end_rg) {
info->high.rm_startblock =
xfs_rtb_to_rgbno(mp, end_rtb);
if (error)
break;
}
- info->rtg = NULL;
+ info->group = NULL;
}
if (bt_cur) {
xfs_btree_del_cursor(bt_cur, error < 0 ? XFS_BTREE_ERROR :
XFS_BTREE_NOERROR);
}
- if (info->rtg) {
- xfs_rtgroup_rele(info->rtg);
- info->rtg = NULL;
+ if (info->group) {
+ xfs_rtgroup_rele(rtg);
+ info->group = NULL;
} else if (rtg) {
/* loop termination case */
xfs_rtgroup_rele(rtg);
info.dev = handlers[i].dev;
info.last = false;
- info.pag = NULL;
- info.rtg = NULL;
+ info.group = NULL;
info.low_daddr = XFS_BUF_DADDR_NULL;
info.low.rm_blockcount = 0;
error = handlers[i].fn(tp, dkeys, &info);