@@ -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;
@@ -5991,7 +5991,6 @@ static int check_csums(struct btrfs_root *root)
unsigned long leaf_offset;
bool verify_csum = !!check_data_csum;
- root = btrfs_csum_root(gfs_info, 0);
if (!extent_buffer_uptodate(root->node)) {
fprintf(stderr, "No valid csum tree found\n");
return -ENOENT;
@@ -6087,6 +6086,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)
{
@@ -10899,7 +10919,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
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> --- check/main.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)