diff options
author | Josef Bacik <josef@toxicpanda.com> | 2022-07-15 22:45:23 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-09-26 13:27:54 +0300 |
commit | 723de71d41f50709eaf2eef1b08aa409687a3c97 (patch) | |
tree | 3353865eb66ededaa5cd2d1986ae9e8f54c07978 | |
parent | 9d4b0a129a0d081821f21edccad154f8e2a1b747 (diff) | |
download | linux-723de71d41f50709eaf2eef1b08aa409687a3c97.tar.xz |
btrfs: handle space_info setting of bg in btrfs_add_bg_to_space_info
We previously had the pattern of
btrfs_update_space_info(all, the, bg, fields, &space_info);
link_block_group(bg);
bg->space_info = space_info;
Now that we're passing the bg into btrfs_add_bg_to_space_info we can do
the linking in that function, transforming this to simply
btrfs_add_bg_to_space_info(fs_info, bg);
and put the link_block_group() and bg->space_info assignment directly in
btrfs_add_bg_to_space_info.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/block-group.c | 25 | ||||
-rw-r--r-- | fs/btrfs/space-info.c | 13 | ||||
-rw-r--r-- | fs/btrfs/space-info.h | 3 |
3 files changed, 13 insertions, 28 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index a6ecf3f87fc3..d83c044d3003 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1896,16 +1896,6 @@ static int exclude_super_stripes(struct btrfs_block_group *cache) return 0; } -static void link_block_group(struct btrfs_block_group *cache) -{ - struct btrfs_space_info *space_info = cache->space_info; - int index = btrfs_bg_flags_to_raid_index(cache->flags); - - down_write(&space_info->groups_sem); - list_add_tail(&cache->list, &space_info->block_groups[index]); - up_write(&space_info->groups_sem); -} - static struct btrfs_block_group *btrfs_create_block_group_cache( struct btrfs_fs_info *fs_info, u64 start) { @@ -2008,7 +1998,6 @@ static int read_one_block_group(struct btrfs_fs_info *info, int need_clear) { struct btrfs_block_group *cache; - struct btrfs_space_info *space_info; const bool mixed = btrfs_fs_incompat(info, MIXED_GROUPS); int ret; @@ -2101,11 +2090,7 @@ static int read_one_block_group(struct btrfs_fs_info *info, goto error; } trace_btrfs_add_block_group(info, cache, 0); - btrfs_add_bg_to_space_info(info, cache, &space_info); - - cache->space_info = space_info; - - link_block_group(cache); + btrfs_add_bg_to_space_info(info, cache); set_avail_alloc_bits(info, cache->flags); if (btrfs_chunk_writeable(info, cache->start)) { @@ -2129,7 +2114,6 @@ error: static int fill_dummy_bgs(struct btrfs_fs_info *fs_info) { struct extent_map_tree *em_tree = &fs_info->mapping_tree; - struct btrfs_space_info *space_info; struct rb_node *node; int ret = 0; @@ -2170,9 +2154,7 @@ static int fill_dummy_bgs(struct btrfs_fs_info *fs_info) break; } - btrfs_add_bg_to_space_info(fs_info, bg, &space_info); - bg->space_info = space_info; - link_block_group(bg); + btrfs_add_bg_to_space_info(fs_info, bg); set_avail_alloc_bits(fs_info, bg->flags); } @@ -2541,7 +2523,7 @@ 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_add_bg_to_space_info(fs_info, cache, &cache->space_info); + btrfs_add_bg_to_space_info(fs_info, cache); btrfs_update_global_block_rsv(fs_info); #ifdef CONFIG_BTRFS_DEBUG @@ -2552,7 +2534,6 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran fragment_free_space(cache); } #endif - link_block_group(cache); list_add_tail(&cache->bg_list, &trans->new_bgs); trans->delayed_ref_updates++; diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 6974bbef0fea..6260e52d76f4 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -294,11 +294,10 @@ out: } void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info, - struct btrfs_block_group *block_group, - struct btrfs_space_info **space_info) + struct btrfs_block_group *block_group) { struct btrfs_space_info *found; - int factor; + int factor, index; factor = btrfs_bg_type_to_factor(block_group->flags); @@ -317,7 +316,13 @@ void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info, found->full = 0; btrfs_try_granting_tickets(info, found); spin_unlock(&found->lock); - *space_info = found; + + block_group->space_info = found; + + index = btrfs_bg_flags_to_raid_index(block_group->flags); + down_write(&found->groups_sem); + list_add_tail(&block_group->list, &found->block_groups[index]); + up_write(&found->groups_sem); } struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info, diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 101e83828ee5..2039096803ed 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -124,8 +124,7 @@ DECLARE_SPACE_INFO_UPDATE(bytes_pinned, "pinned"); int btrfs_init_space_info(struct btrfs_fs_info *fs_info); void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info, - struct btrfs_block_group *block_group, - struct btrfs_space_info **space_info); + struct btrfs_block_group *block_group); void btrfs_update_space_info_chunk_size(struct btrfs_space_info *space_info, u64 chunk_size); struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info, |