Skip to content

Commit 4f17b3a

Browse files
committed
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>
1 parent f66b33f commit 4f17b3a

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

check/main.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10055,6 +10055,31 @@ static int check_global_roots_uptodate(void)
1005510055
return ret;
1005610056
}
1005710057

10058+
/*
10059+
* Check the bare minimum before starting anything else that could rely on it,
10060+
* namely the tree roots, any local consistency checks
10061+
*/
10062+
static bool check_early_critical_roots(void)
10063+
{
10064+
const char msg[] = "critical root %s corrupted, unable to continue";
10065+
bool ret = false;
10066+
10067+
if (!extent_buffer_uptodate(gfs_info->tree_root->node)) {
10068+
error(msg, "tree_root");
10069+
ret = true;
10070+
}
10071+
10072+
if (!extent_buffer_uptodate(gfs_info->dev_root->node)) {
10073+
error(msg, "dev_root");
10074+
ret = true;
10075+
}
10076+
if (!extent_buffer_uptodate(gfs_info->chunk_root->node)) {
10077+
error(msg, "chunk_root");
10078+
ret = true;
10079+
}
10080+
return ret;
10081+
}
10082+
1005810083
static const char * const cmd_check_usage[] = {
1005910084
"btrfs check [options] <device>",
1006010085
"Check structural integrity of a filesystem (unmounted).",
@@ -10325,16 +10350,8 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
1032510350

1032610351
printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf);
1032710352

10328-
/*
10329-
* Check the bare minimum before starting anything else that could rely
10330-
* on it, namely the tree roots, any local consistency checks
10331-
*/
10332-
if (!extent_buffer_uptodate(gfs_info->tree_root->node) ||
10333-
!extent_buffer_uptodate(gfs_info->dev_root->node) ||
10334-
!extent_buffer_uptodate(gfs_info->chunk_root->node)) {
10335-
error("critical roots corrupted, unable to check the filesystem");
10336-
err |= !!ret;
10337-
ret = -EIO;
10353+
if (check_early_critical_roots()) {
10354+
err |= 1;
1033810355
goto close_out;
1033910356
}
1034010357

0 commit comments

Comments
 (0)