@@ -1771,6 +1771,7 @@ static int exclude_super_stripes(struct btrfs_block_group *cache)
static void link_block_group(struct btrfs_block_group *cache)
{
+ struct btrfs_fs_info *fs_info = cache->fs_info;
struct btrfs_space_info *space_info = cache->space_info;
int index = btrfs_bg_flags_to_raid_index(cache->flags);
bool first = false;
@@ -1783,6 +1784,8 @@ static void link_block_group(struct btrfs_block_group *cache)
if (first)
btrfs_sysfs_add_block_group_type(cache);
+
+ set_avail_alloc_bits(fs_info, cache->flags);
}
static struct btrfs_block_group *btrfs_create_block_group_cache(
@@ -1986,7 +1989,6 @@ static int read_one_block_group(struct btrfs_fs_info *info,
link_block_group(cache);
- set_avail_alloc_bits(info, cache->flags);
if (btrfs_chunk_readonly(info, cache->start)) {
inc_block_group_ro(cache, 1);
} else if (cache->used == 0) {
@@ -2196,7 +2198,6 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
trans->delayed_ref_updates++;
btrfs_update_delayed_refs_rsv(trans);
- set_avail_alloc_bits(fs_info, type);
return 0;
}
When we call link_block_group(), we also call set_avail_alloc_bits() after that. Thus we can merge the set_avail_alloc_bits() into link_block_group(). Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/block-group.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)