diff mbox

[25/29] xfs_repair: collect relatime reverse-mapping data for refcount/rmap tree rebuilding

Message ID 147216968057.7022.6386690839466970601.stgit@birch.djwong.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Darrick J. Wong Aug. 26, 2016, 12:01 a.m. UTC
Collect reverse-mapping data for realtime files so that we can later
check and rebuild the reference count tree and the reverse mapping
tree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/dinode.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/repair/dinode.c b/repair/dinode.c
index f768cdf..04759dc 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -594,6 +594,7 @@  process_bmbt_reclist_int(
 	xfs_agblock_t		ebno;
 	xfs_extlen_t		blen;
 	xfs_agnumber_t		locked_agno = -1;
+	struct aglock		*ag_lock;
 	int			error = 1;
 
 	if (type == XR_INO_RTDATA)
@@ -639,8 +640,20 @@  _("zero length extent (off = %" PRIu64 ", fsbno = %" PRIu64 ") in ino %" PRIu64
 			 */
 			if (process_rt_rec(mp, &irec, ino, tot, check_dups))
 				return 1;
+			/* collect reverse mappings for realtime files */
+			if (collect_rmaps && !check_dups) {
+				ag_lock = &ag_locks[(signed)NULLAGNUMBER];
+				pthread_mutex_lock(&ag_lock->lock);
+				error = rmap_add_rec(mp, ino, whichfork,
+						&irec, true);
+				pthread_mutex_unlock(&ag_lock->lock);
+				if (error)
+					do_error(
+_("couldn't add reverse mapping\n")
+						);
+			}
 			/*
-			 * skip rest of loop processing since that'irec.br_startblock
+			 * skip rest of loop processing since that's
 			 * all for regular file forks and attr forks
 			 */
 			continue;