[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-btrfs
Subject:    [PATCH] btrfs-progs: check: Don't do early exit if maybe_repair_root_item() can't find needed root e
From:       Qu Wenruo <wqu () suse ! com>
Date:       2020-04-29 10:10:15
Message-ID: 20200429101015.78658-1-wqu () suse ! com
[Download RAW message or body]

The whole maybe_repair_root_item() and repair_root_items() functions are
introduced to handle an ancient bug in v3.17.

However in certain extent tree corruption case, such early exit would
only exit the whole check process early on, preventing user to know
what's really wrong about the fs.

So this patch will allow the check to continue, since the ancient bug is
no long that common.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/check/main.c b/check/main.c
index be980c152274..ac11a35125b8 100644
--- a/check/main.c
+++ b/check/main.c
@@ -10306,20 +10306,28 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
 			err = !!ret;
 			errno = -ret;
 			error("failed to repair root items: %m");
-			goto close_out;
-		}
-		if (repair) {
-			fprintf(stderr, "Fixed %d roots.\n", ret);
-			ret = 0;
-		} else if (ret > 0) {
-			fprintf(stderr,
+			/*
+			 * For repair, if we can't repair root items, it's
+			 * fatal.
+			 * But for non-repair, it's pretty rare to hit such
+			 * v3.17 era bug, we want to continue check.
+			 */
+			if (repair)
+				goto close_out;
+			err |= 1;
+		} else {
+			if (repair) {
+				fprintf(stderr, "Fixed %d roots.\n", ret);
+				ret = 0;
+			} else if (ret > 0) {
+				fprintf(stderr,
 				"Found %d roots with an outdated root item.\n",
-				ret);
-			fprintf(stderr,
+					ret);
+				fprintf(stderr,
 	"Please run a filesystem check with the option --repair to fix them.\n");
-			ret = 1;
-			err |= ret;
-			goto close_out;
+				ret = 1;
+				err |= ret;
+			}
 		}
 	} else {
 		fprintf(stderr, "[1/7] checking root items... skipped\n");
-- 
2.26.2

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic