diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-09-01 11:16:54 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-10-22 16:41:02 -0700 |
commit | 3ebe415522f85d2539c9bf419092590391487f27 (patch) | |
tree | 58110e30e14b27efd917a7097554063bbffdd971 | |
parent | b2484d7f1dfe1a07ff58aefb26a469ec2cf832c5 (diff) |
xfs: wire up getfsmap to the realtime reverse mapping btree
Connect the getfsmap ioctl to the realtime rmapbt.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/xfs/xfs_fsmap.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c index bf95e6a89af5..f4c0c57f78b3 100644 --- a/fs/xfs/xfs_fsmap.c +++ b/fs/xfs/xfs_fsmap.c @@ -25,6 +25,7 @@ #include "xfs_alloc_btree.h" #include "xfs_rtalloc.h" #include "xfs_ag.h" +#include "xfs_rtrmap_btree.h" /* Convert an xfs_fsmap to an fsmap. */ static void @@ -765,6 +766,64 @@ xfs_getfsmap_rtdev_rtbitmap( return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query, info); } + +/* Transform a absolute-startblock rmap (rtdev, logdev) into a fsmap */ +STATIC int +xfs_getfsmap_rtdev_helper( + struct xfs_btree_cur *cur, + const struct xfs_rmap_irec *rec, + void *priv) +{ + struct xfs_mount *mp = cur->bc_mp; + struct xfs_getfsmap_info *info = priv; + xfs_daddr_t rec_daddr; + + rec_daddr = XFS_FSB_TO_BB(mp, rec->rm_startblock); + + return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr); +} + +/* Actually query the rtrmap btree. */ +STATIC int +xfs_getfsmap_rtdev_rmapbt_query( + struct xfs_trans *tp, + struct xfs_getfsmap_info *info) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_btree_cur *bt_cur; + int error; + + /* Query the rtrmapbt */ + xfs_rtlock(NULL, tp->t_mountp, XFS_RTLOCK_ALL); + bt_cur = xfs_rtrmapbt_init_cursor(mp, tp, mp->m_rrmapip); + error = xfs_rmap_query_range(bt_cur, &info->low, &info->high, + xfs_getfsmap_rtdev_helper, info); + if (error) + goto err; + + /* Report any gaps at the end of the rtrmapbt */ + info->last = true; + error = xfs_getfsmap_rtdev_helper(bt_cur, &info->high, info); + if (error) + goto err; + +err: + xfs_btree_del_cursor(bt_cur, error); + xfs_rtunlock(tp->t_mountp, XFS_RTLOCK_ALL); + return error; +} + +/* Execute a getfsmap query against the realtime device rmapbt. */ +STATIC int +xfs_getfsmap_rtdev_rmapbt( + struct xfs_trans *tp, + const struct xfs_fsmap *keys, + struct xfs_getfsmap_info *info) +{ + info->missing_owner = XFS_FMR_OWN_FREE; + return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rmapbt_query, + info); +} #endif /* CONFIG_XFS_RT */ /* Do we recognize the device? */ @@ -882,7 +941,10 @@ xfs_getfsmap( #ifdef CONFIG_XFS_RT if (mp->m_rtdev_targp) { handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev); - handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap; + if (use_rmap) + handlers[2].fn = xfs_getfsmap_rtdev_rmapbt; + else + handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap; } #endif /* CONFIG_XFS_RT */ |