aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2024-04-05 03:10:14 +0200
committerDavid Sterba <dsterba@suse.com>2024-04-30 19:34:52 +0200
commit331e61646ebf2379de7b9ab0949366a5ee3998af (patch)
tree64e9dd32853e8596592e5e4c4b22142ba86e6154
parented21179c98a9fe51d4d682136cbf42dd46df3479 (diff)
downloadbtrfs-progs-331e61646ebf2379de7b9ab0949366a5ee3998af.tar.gz
btrfs-progs: check: print separate messages for damaged critical roots
There's an early check of some critical roots right after opening the filesystem but there's only one message. Check the same roots but print message for each so it's more specific. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--check/main.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/check/main.c b/check/main.c
index a1080319..7df4c4ea 100644
--- a/check/main.c
+++ b/check/main.c
@@ -10055,6 +10055,31 @@ static int check_global_roots_uptodate(void)
return ret;
}
+/*
+ * Check the bare minimum before starting anything else that could rely on it,
+ * namely the tree roots, any local consistency checks
+ */
+static bool check_early_critical_roots(void)
+{
+ const char msg[] = "critical root %s corrupted, unable to continue";
+ bool ret = false;
+
+ if (!extent_buffer_uptodate(gfs_info->tree_root->node)) {
+ error(msg, "tree_root");
+ ret = true;
+ }
+
+ if (!extent_buffer_uptodate(gfs_info->dev_root->node)) {
+ error(msg, "dev_root");
+ ret = true;
+ }
+ if (!extent_buffer_uptodate(gfs_info->chunk_root->node)) {
+ error(msg, "chunk_root");
+ ret = true;
+ }
+ return ret;
+}
+
static const char * const cmd_check_usage[] = {
"btrfs check [options] <device>",
"Check structural integrity of a filesystem (unmounted).",
@@ -10332,16 +10357,8 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf);
- /*
- * Check the bare minimum before starting anything else that could rely
- * on it, namely the tree roots, any local consistency checks
- */
- if (!extent_buffer_uptodate(gfs_info->tree_root->node) ||
- !extent_buffer_uptodate(gfs_info->dev_root->node) ||
- !extent_buffer_uptodate(gfs_info->chunk_root->node)) {
- error("critical roots corrupted, unable to check the filesystem");
- err |= !!ret;
- ret = -EIO;
+ if (check_early_critical_roots()) {
+ err |= 1;
goto close_out;
}