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>
This commit is contained in:
committed by
David Sterba
parent
9d4b0a129a
commit
723de71d41
@@ -1896,16 +1896,6 @@ static int exclude_super_stripes(struct btrfs_block_group *cache)
|
|||||||
return 0;
|
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(
|
static struct btrfs_block_group *btrfs_create_block_group_cache(
|
||||||
struct btrfs_fs_info *fs_info, u64 start)
|
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)
|
int need_clear)
|
||||||
{
|
{
|
||||||
struct btrfs_block_group *cache;
|
struct btrfs_block_group *cache;
|
||||||
struct btrfs_space_info *space_info;
|
|
||||||
const bool mixed = btrfs_fs_incompat(info, MIXED_GROUPS);
|
const bool mixed = btrfs_fs_incompat(info, MIXED_GROUPS);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -2101,11 +2090,7 @@ static int read_one_block_group(struct btrfs_fs_info *info,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
trace_btrfs_add_block_group(info, cache, 0);
|
trace_btrfs_add_block_group(info, cache, 0);
|
||||||
btrfs_add_bg_to_space_info(info, cache, &space_info);
|
btrfs_add_bg_to_space_info(info, cache);
|
||||||
|
|
||||||
cache->space_info = space_info;
|
|
||||||
|
|
||||||
link_block_group(cache);
|
|
||||||
|
|
||||||
set_avail_alloc_bits(info, cache->flags);
|
set_avail_alloc_bits(info, cache->flags);
|
||||||
if (btrfs_chunk_writeable(info, cache->start)) {
|
if (btrfs_chunk_writeable(info, cache->start)) {
|
||||||
@@ -2129,7 +2114,6 @@ error:
|
|||||||
static int fill_dummy_bgs(struct btrfs_fs_info *fs_info)
|
static int fill_dummy_bgs(struct btrfs_fs_info *fs_info)
|
||||||
{
|
{
|
||||||
struct extent_map_tree *em_tree = &fs_info->mapping_tree;
|
struct extent_map_tree *em_tree = &fs_info->mapping_tree;
|
||||||
struct btrfs_space_info *space_info;
|
|
||||||
struct rb_node *node;
|
struct rb_node *node;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@@ -2170,9 +2154,7 @@ static int fill_dummy_bgs(struct btrfs_fs_info *fs_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
btrfs_add_bg_to_space_info(fs_info, bg, &space_info);
|
btrfs_add_bg_to_space_info(fs_info, bg);
|
||||||
bg->space_info = space_info;
|
|
||||||
link_block_group(bg);
|
|
||||||
|
|
||||||
set_avail_alloc_bits(fs_info, bg->flags);
|
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.
|
* the rbtree, update the space info's counters.
|
||||||
*/
|
*/
|
||||||
trace_btrfs_add_block_group(fs_info, cache, 1);
|
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);
|
btrfs_update_global_block_rsv(fs_info);
|
||||||
|
|
||||||
#ifdef CONFIG_BTRFS_DEBUG
|
#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);
|
fragment_free_space(cache);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
link_block_group(cache);
|
|
||||||
|
|
||||||
list_add_tail(&cache->bg_list, &trans->new_bgs);
|
list_add_tail(&cache->bg_list, &trans->new_bgs);
|
||||||
trans->delayed_ref_updates++;
|
trans->delayed_ref_updates++;
|
||||||
|
@@ -294,11 +294,10 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
|
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
|
||||||
struct btrfs_block_group *block_group,
|
struct btrfs_block_group *block_group)
|
||||||
struct btrfs_space_info **space_info)
|
|
||||||
{
|
{
|
||||||
struct btrfs_space_info *found;
|
struct btrfs_space_info *found;
|
||||||
int factor;
|
int factor, index;
|
||||||
|
|
||||||
factor = btrfs_bg_type_to_factor(block_group->flags);
|
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;
|
found->full = 0;
|
||||||
btrfs_try_granting_tickets(info, found);
|
btrfs_try_granting_tickets(info, found);
|
||||||
spin_unlock(&found->lock);
|
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,
|
struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,
|
||||||
|
@@ -124,8 +124,7 @@ DECLARE_SPACE_INFO_UPDATE(bytes_pinned, "pinned");
|
|||||||
|
|
||||||
int btrfs_init_space_info(struct btrfs_fs_info *fs_info);
|
int btrfs_init_space_info(struct btrfs_fs_info *fs_info);
|
||||||
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
|
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
|
||||||
struct btrfs_block_group *block_group,
|
struct btrfs_block_group *block_group);
|
||||||
struct btrfs_space_info **space_info);
|
|
||||||
void btrfs_update_space_info_chunk_size(struct btrfs_space_info *space_info,
|
void btrfs_update_space_info_chunk_size(struct btrfs_space_info *space_info,
|
||||||
u64 chunk_size);
|
u64 chunk_size);
|
||||||
struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,
|
struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,
|
||||||
|
Reference in New Issue
Block a user