summaryrefslogtreecommitdiff
path: root/fs/btrfs/block-group.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2022-07-15 22:45:22 +0300
committerDavid Sterba <dsterba@suse.com>2022-09-26 13:27:54 +0300
commit9d4b0a129a0d081821f21edccad154f8e2a1b747 (patch)
tree57df28bc1d9da0bcfb834002efa489eb6167d8d7 /fs/btrfs/block-group.c
parent2f12741f81af638dfb682dc2f24e6cbb67a37a2e (diff)
downloadlinux-9d4b0a129a0d081821f21edccad154f8e2a1b747.tar.xz
btrfs: simplify arguments of btrfs_update_space_info and rename
This function has grown a bunch of new arguments, and it just boils down to passing in all the block group fields as arguments. Simplify this by passing in the block group itself and updating the space_info fields based on the block group fields directly. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/block-group.c')
-rw-r--r--fs/btrfs/block-group.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 95d65c6bdf20..a6ecf3f87fc3 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2101,10 +2101,7 @@ static int read_one_block_group(struct btrfs_fs_info *info,
goto error;
}
trace_btrfs_add_block_group(info, cache, 0);
- btrfs_update_space_info(info, cache->flags, cache->length,
- cache->used, cache->bytes_super,
- cache->zone_unusable, cache->zone_is_active,
- &space_info);
+ btrfs_add_bg_to_space_info(info, cache, &space_info);
cache->space_info = space_info;
@@ -2173,8 +2170,7 @@ static int fill_dummy_bgs(struct btrfs_fs_info *fs_info)
break;
}
- btrfs_update_space_info(fs_info, bg->flags, em->len, em->len,
- 0, 0, false, &space_info);
+ btrfs_add_bg_to_space_info(fs_info, bg, &space_info);
bg->space_info = space_info;
link_block_group(bg);
@@ -2525,14 +2521,6 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
btrfs_free_excluded_extents(cache);
-#ifdef CONFIG_BTRFS_DEBUG
- if (btrfs_should_fragment_free_space(cache)) {
- u64 new_bytes_used = size - bytes_used;
-
- bytes_used += new_bytes_used >> 1;
- fragment_free_space(cache);
- }
-#endif
/*
* Ensure the corresponding space_info object is created and
* assigned to our block group. We want our bg to be added to the rbtree
@@ -2553,11 +2541,17 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
* the rbtree, update the space info's counters.
*/
trace_btrfs_add_block_group(fs_info, cache, 1);
- btrfs_update_space_info(fs_info, cache->flags, size, bytes_used,
- cache->bytes_super, cache->zone_unusable,
- cache->zone_is_active, &cache->space_info);
+ btrfs_add_bg_to_space_info(fs_info, cache, &cache->space_info);
btrfs_update_global_block_rsv(fs_info);
+#ifdef CONFIG_BTRFS_DEBUG
+ if (btrfs_should_fragment_free_space(cache)) {
+ u64 new_bytes_used = size - bytes_used;
+
+ cache->space_info->bytes_used += new_bytes_used >> 1;
+ fragment_free_space(cache);
+ }
+#endif
link_block_group(cache);
list_add_tail(&cache->bg_list, &trans->new_bgs);