btrfs-progs: qgroup-verify: scan extents based on block groups

When we switch to per-block group extent roots we'll need to scan each
individual extent root.  To make this easier in the future go ahead and
use the range of the block groups to scan the extents.

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:53 -05:00 committed by David Sterba
parent 1bbfc9c9a6
commit b4d714a47a

View File

@ -1400,6 +1400,7 @@ static bool is_bad_qgroup(struct qgroup_count *count)
*/
int qgroup_verify_all(struct btrfs_fs_info *info)
{
struct rb_node *n;
int ret;
bool found_err = false;
bool skip_err = false;
@ -1430,10 +1431,17 @@ int qgroup_verify_all(struct btrfs_fs_info *info)
/*
* Put all extent refs into our rbtree
*/
ret = scan_extents(info, 0, ~0ULL);
if (ret) {
fprintf(stderr, "ERROR: while scanning extent tree: %d\n", ret);
goto out;
for (n = rb_first(&info->block_group_cache_tree); n; n = rb_next(n)) {
struct btrfs_block_group *bg;
bg = rb_entry(n, struct btrfs_block_group, cache_node);
ret = scan_extents(info, bg->start,
bg->start + bg->length - 1);
if (ret) {
fprintf(stderr, "ERROR: while scanning extent tree: %d\n",
ret);
goto out;
}
}
ret = map_implied_refs(info);
@ -1507,6 +1515,7 @@ static void print_subvol_info(u64 subvolid, u64 bytenr, u64 num_bytes,
int print_extent_state(struct btrfs_fs_info *info, u64 subvol)
{
struct rb_node *n;
int ret;
tree_blocks = ulist_alloc(0);
@ -1519,10 +1528,17 @@ int print_extent_state(struct btrfs_fs_info *info, u64 subvol)
/*
* Put all extent refs into our rbtree
*/
ret = scan_extents(info, 0, ~0ULL);
if (ret) {
fprintf(stderr, "ERROR: while scanning extent tree: %d\n", ret);
goto out;
for (n = rb_first(&info->block_group_cache_tree); n; n = rb_next(n)) {
struct btrfs_block_group *bg;
bg = rb_entry(n, struct btrfs_block_group, cache_node);
ret = scan_extents(info, bg->start,
bg->start + bg->length - 1);
if (ret) {
fprintf(stderr, "ERROR: while scanning extent tree: %d\n",
ret);
goto out;
}
}
ret = map_implied_refs(info);