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

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