diff mbox series

[9,03/12] btrfs: block-group: make link_block_group() to handle avail alloc bits

Message ID 20201001055744.103261-4-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series Introduce per-profile available space array to avoid over-confident can_overcommit() | expand

Commit Message

Qu Wenruo Oct. 1, 2020, 5:57 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 831855c85419..cb6be9a3d1dc 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -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;
 }