btrfs-progs: check: handle the block group tree properly

We need to make sure we process the block group root, and mark its
blocks as used for the free space tree checking.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2022-03-07 17:10:56 -05:00 committed by David Sterba
parent 37d05e9b1e
commit c36d8ea235
2 changed files with 20 additions and 10 deletions

View File

@ -8947,6 +8947,18 @@ out:
return ret; return ret;
} }
static int load_super_root(struct list_head *head, struct btrfs_root *root)
{
u8 level;
if (!root)
return 0;
level = btrfs_header_level(root->node);
return add_root_item_to_list(head, root->root_key.objectid,
root->node->start, 0, level, 0, NULL);
}
static int check_chunks_and_extents(void) static int check_chunks_and_extents(void)
{ {
struct rb_root dev_cache; struct rb_root dev_cache;
@ -8965,9 +8977,7 @@ static int check_chunks_and_extents(void)
int bits_nr; int bits_nr;
struct list_head dropping_trees; struct list_head dropping_trees;
struct list_head normal_trees; struct list_head normal_trees;
struct btrfs_root *root1;
struct btrfs_root *root; struct btrfs_root *root;
u8 level;
root = gfs_info->fs_root; root = gfs_info->fs_root;
dev_cache = RB_ROOT; dev_cache = RB_ROOT;
@ -9000,16 +9010,13 @@ static int check_chunks_and_extents(void)
} }
again: again:
root1 = gfs_info->tree_root; ret = load_super_root(&normal_trees, gfs_info->tree_root);
level = btrfs_header_level(root1->node);
ret = add_root_item_to_list(&normal_trees, root1->root_key.objectid,
root1->node->start, 0, level, 0, NULL);
if (ret < 0) if (ret < 0)
goto out; goto out;
root1 = gfs_info->chunk_root; ret = load_super_root(&normal_trees, gfs_info->chunk_root);
level = btrfs_header_level(root1->node); if (ret < 0)
ret = add_root_item_to_list(&normal_trees, root1->root_key.objectid, goto out;
root1->node->start, 0, level, 0, NULL); ret = load_super_root(&normal_trees, gfs_info->block_group_root);
if (ret < 0) if (ret < 0)
goto out; goto out;

View File

@ -149,6 +149,9 @@ int btrfs_mark_used_tree_blocks(struct btrfs_fs_info *fs_info,
ret = traverse_tree_blocks(tree, fs_info->chunk_root->node, 0); ret = traverse_tree_blocks(tree, fs_info->chunk_root->node, 0);
if (!ret) if (!ret)
ret = traverse_tree_blocks(tree, fs_info->tree_root->node, 1); ret = traverse_tree_blocks(tree, fs_info->tree_root->node, 1);
if (!ret && fs_info->block_group_root)
ret = traverse_tree_blocks(tree,
fs_info->block_group_root->node, 0);
return ret; return ret;
} }