mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: check: check all of the csum roots
Use the global roots tree to find all of the csum roots in the system and check all of them as appropriate. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d26c0b4414
commit
bb575e3818
26
check/main.c
26
check/main.c
@ -5977,7 +5977,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_csums(struct btrfs_root *root)
|
||||
static int check_csum_root(struct btrfs_root *root)
|
||||
{
|
||||
struct btrfs_path path;
|
||||
struct extent_buffer *leaf;
|
||||
@ -5995,7 +5995,6 @@ static int check_csums(struct btrfs_root *root)
|
||||
max_entries = ((BTRFS_LEAF_DATA_SIZE(gfs_info) -
|
||||
(sizeof(struct btrfs_item) * 2)) / csum_size) - 1;
|
||||
|
||||
root = btrfs_csum_root(gfs_info, 0);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
fprintf(stderr, "No valid csum tree found\n");
|
||||
return -ENOENT;
|
||||
@ -6100,6 +6099,27 @@ skip_csum_check:
|
||||
return errors;
|
||||
}
|
||||
|
||||
static int check_csums(void)
|
||||
{
|
||||
struct rb_node *n;
|
||||
struct btrfs_root *root;
|
||||
int ret;
|
||||
|
||||
root = btrfs_csum_root(gfs_info, 0);
|
||||
while (1) {
|
||||
ret = check_csum_root(root);
|
||||
if (ret)
|
||||
break;
|
||||
n = rb_next(&root->rb_node);
|
||||
if (!n)
|
||||
break;
|
||||
root = rb_entry(n, struct btrfs_root, rb_node);
|
||||
if (root->root_key.objectid != BTRFS_CSUM_TREE_OBJECTID)
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int is_dropped_key(struct btrfs_key *key,
|
||||
struct btrfs_key *drop_key)
|
||||
{
|
||||
@ -10912,7 +10932,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
task_start(ctx.info, &ctx.start_time, &ctx.item_count);
|
||||
}
|
||||
|
||||
ret = check_csums(root);
|
||||
ret = check_csums();
|
||||
task_stop(ctx.info);
|
||||
/*
|
||||
* Data csum error is not fatal, and it may indicate more serious
|
||||
|
Loading…
Reference in New Issue
Block a user