diff mbox series

[RFC,10/17] btrfs: priority alloc: call add_block_group_priority while reading or making block group

Message ID 20181128031148.357-11-suy.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series btrfs: implementation of priority aware allocator | expand

Commit Message

Su Yue Nov. 28, 2018, 3:11 a.m. UTC
Add  block group to priority tree in btrfs_read_block_groups()
and btrfs_make_block_groups().

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2dec02782df1..fc40901b4772 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10117,6 +10117,7 @@  static int check_chunk_block_group_mappings(struct btrfs_fs_info *fs_info)
 }
 
 static long compute_block_group_priority(struct btrfs_block_group_cache *bg);
+static void add_block_group_priority(struct btrfs_block_group_cache *cache);
 int btrfs_read_block_groups(struct btrfs_fs_info *info)
 {
 	struct btrfs_path *path;
@@ -10251,6 +10252,7 @@  int btrfs_read_block_groups(struct btrfs_fs_info *info)
 		link_block_group(cache);
 
 		cache->priority = compute_block_group_priority(cache);
+		add_block_group_priority(cache);
 
 		set_avail_alloc_bits(info, cache->flags);
 		if (btrfs_chunk_readonly(info, cache->key.objectid)) {
@@ -10402,6 +10404,7 @@  int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
 	link_block_group(cache);
 
 	cache->priority = compute_block_group_priority(cache);
+	add_block_group_priority(cache);
 
 	list_add_tail(&cache->bg_list, &trans->new_bgs);