mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-09 20:28:16 +00:00
btrfs-progs: check: check the global roots for uptodate root nodes
Instead of checking the csum and extent tree individually, walk through the global roots and validate them all. This will work properly if we have extent tree v1 or extent tree v2. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
bf0ce5cb86
commit
d26c0b4414
30
check/main.c
30
check/main.c
@ -10392,6 +10392,23 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_global_roots_uptodate(void)
|
||||
{
|
||||
struct btrfs_root *root;
|
||||
struct rb_node *n;
|
||||
|
||||
for (n = rb_first(&gfs_info->global_roots_tree); n; n = rb_next(n)) {
|
||||
root = rb_entry(n, struct btrfs_root, rb_node);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
error("chritical: global root [%llu %llu] not uptodate, unable to check the file system",
|
||||
root->root_key.objectid, root->root_key.offset);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const cmd_check_usage[] = {
|
||||
"btrfs check [options] <device>",
|
||||
"Check structural integrity of a filesystem (unmounted).",
|
||||
@ -10784,18 +10801,9 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
if (ret)
|
||||
goto close_out;
|
||||
}
|
||||
root = btrfs_extent_root(gfs_info, 0);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
error("critical: extent_root, unable to check the filesystem");
|
||||
ret = -EIO;
|
||||
err |= !!ret;
|
||||
goto close_out;
|
||||
}
|
||||
|
||||
root = btrfs_csum_root(gfs_info, 0);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
error("critical: csum_root, unable to check the filesystem");
|
||||
ret = -EIO;
|
||||
ret = check_global_roots_uptodate();
|
||||
if (ret) {
|
||||
err |= !!ret;
|
||||
goto close_out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user