Blame SOURCES/xfsprogs-5.7.0-xfs_repair-tag-inobt-vs-finobt-errors-properly.patch

48cf7c
From 08280b4b6efd317c673c6718a27d77e702d0480d Mon Sep 17 00:00:00 2001
48cf7c
From: "Darrick J. Wong" <darrick.wong@oracle.com>
48cf7c
Date: Fri, 10 Jul 2020 15:35:45 -0400
48cf7c
Subject: [PATCH] xfs_repair: tag inobt vs finobt errors properly
48cf7c
48cf7c
Amend the generic inode btree block scanner function to tag correctly
48cf7c
which tree it's complaining about.  Previously, dubious finobt headers
48cf7c
would be attributed to the "inode btree", which is at best ambiguous
48cf7c
and misleading at worst.
48cf7c
48cf7c
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
48cf7c
Reviewed-by: Christoph Hellwig <hch@lst.de>
48cf7c
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
48cf7c
---
48cf7c
 repair/scan.c | 36 ++++++++++++++++++++++++++----------
48cf7c
 1 file changed, 26 insertions(+), 10 deletions(-)
48cf7c
48cf7c
Index: xfsprogs-5.0.0/repair/scan.c
48cf7c
===================================================================
48cf7c
--- xfsprogs-5.0.0.orig/repair/scan.c
48cf7c
+++ xfsprogs-5.0.0/repair/scan.c
48cf7c
@@ -1934,6 +1934,7 @@ scan_inobt(
48cf7c
 	const struct xfs_buf_ops *ops)
48cf7c
 {
48cf7c
 	struct aghdr_cnts	*agcnts = priv;
48cf7c
+	char			*name;
48cf7c
 	int			i;
48cf7c
 	int			numrecs;
48cf7c
 	int			state;
48cf7c
@@ -1944,17 +1945,32 @@ scan_inobt(
48cf7c
 
48cf7c
 	hdr_errors = 0;
48cf7c
 
48cf7c
+	switch (magic) {
48cf7c
+	case XFS_FIBT_MAGIC:
48cf7c
+	case XFS_FIBT_CRC_MAGIC:
48cf7c
+		name = "fino";
48cf7c
+		break;
48cf7c
+	case XFS_IBT_MAGIC:
48cf7c
+	case XFS_IBT_CRC_MAGIC:
48cf7c
+		name = "ino";
48cf7c
+		break;
48cf7c
+	default:
48cf7c
+		name = "(unknown)";
48cf7c
+		assert(0);
48cf7c
+		break;
48cf7c
+	}
48cf7c
+
48cf7c
 	if (be32_to_cpu(block->bb_magic) != magic) {
48cf7c
-		do_warn(_("bad magic # %#x in inobt block %d/%d\n"),
48cf7c
-			be32_to_cpu(block->bb_magic), agno, bno);
48cf7c
+		do_warn(_("bad magic # %#x in %sbt block %d/%d\n"),
48cf7c
+			be32_to_cpu(block->bb_magic), name, agno, bno);
48cf7c
 		hdr_errors++;
48cf7c
 		bad_ino_btree = 1;
48cf7c
 		if (suspect)
48cf7c
 			return;
48cf7c
 	}
48cf7c
 	if (be16_to_cpu(block->bb_level) != level) {
48cf7c
-		do_warn(_("expected level %d got %d in inobt block %d/%d\n"),
48cf7c
-			level, be16_to_cpu(block->bb_level), agno, bno);
48cf7c
+		do_warn(_("expected level %d got %d in %sbt block %d/%d\n"),
48cf7c
+			level, be16_to_cpu(block->bb_level), name, agno, bno);
48cf7c
 		hdr_errors++;
48cf7c
 		bad_ino_btree = 1;
48cf7c
 		if (suspect)
48cf7c
@@ -1976,8 +1992,8 @@ scan_inobt(
48cf7c
 	default:
48cf7c
 		set_bmap(agno, bno, XR_E_MULT);
48cf7c
 		do_warn(
48cf7c
-_("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
48cf7c
-			state, agno, bno, suspect);
48cf7c
+_("%sbt btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
48cf7c
+			name, state, agno, bno, suspect);
48cf7c
 	}
48cf7c
 
48cf7c
 	numrecs = be16_to_cpu(block->bb_numrecs);
48cf7c
@@ -1999,8 +2015,8 @@ _("inode btree block claimed (state %d),
48cf7c
 
48cf7c
 		if (hdr_errors)  {
48cf7c
 			bad_ino_btree = 1;
48cf7c
-			do_warn(_("dubious inode btree block header %d/%d\n"),
48cf7c
-				agno, bno);
48cf7c
+			do_warn(_("dubious %sbt btree block header %d/%d\n"),
48cf7c
+				name, agno, bno);
48cf7c
 			suspect++;
48cf7c
 		}
48cf7c