summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:17:58 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-12-15 17:29:17 -0800
commit09b3c0d5935229e067369692c20a8a57e2581ed4 (patch)
tree901f95452ccd92850b12594ce2235ecb62692e3e /fs/xfs/scrub
parentcb351ea02f1345892ffb86282ddf3341783ed695 (diff)
xfs: walk the rt reverse mapping tree when rebuilding rmap
When we're rebuilding the data device rmap, if we encounter an "rmap" format fork, we have to walk the (realtime) rmap btree inode to build the appropriate mappings. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/scrub')
-rw-r--r--fs/xfs/scrub/rmap_repair.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/xfs/scrub/rmap_repair.c b/fs/xfs/scrub/rmap_repair.c
index b621db1f85c2..2290ff9e3e75 100644
--- a/fs/xfs/scrub/rmap_repair.c
+++ b/fs/xfs/scrub/rmap_repair.c
@@ -28,6 +28,7 @@
#include "xfs_refcount.h"
#include "xfs_refcount_btree.h"
#include "xfs_ag.h"
+#include "xfs_rtrmap_btree.h"
#include "scrub/xfs_scrub.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
@@ -523,6 +524,24 @@ xrep_rmap_scan_iext(
return xrep_rmap_stash_accumulated(rf);
}
+static int
+xrep_rmap_scan_rtrmapbt(
+ struct xrep_rmap_ifork *rf,
+ struct xfs_inode *ip)
+{
+ struct xfs_scrub *sc = rf->rr->sc;
+ struct xfs_btree_cur *cur;
+ int error;
+
+ if (ip != sc->mp->m_rrmapip || rf->whichfork != XFS_DATA_FORK)
+ return -EFSCORRUPTED;
+
+ cur = xfs_rtrmapbt_init_cursor(sc->mp, sc->tp, ip);
+ error = xrep_rmap_scan_iroot_btree(rf, cur);
+ xfs_btree_del_cursor(cur, error);
+ return error;
+}
+
/* Find all the extents from a given AG in an inode fork. */
STATIC int
xrep_rmap_scan_ifork(
@@ -552,6 +571,8 @@ xrep_rmap_scan_ifork(
error = xrep_rmap_scan_bmbt(&rf, ip, &mappings_done);
if (error || mappings_done)
return error;
+ } else if (ifp->if_format == XFS_DINODE_FMT_RMAP) {
+ return xrep_rmap_scan_rtrmapbt(&rf, ip);
} else if (ifp->if_format != XFS_DINODE_FMT_EXTENTS) {
return 0;
}