[RFC,15/17] btrfs: priority alloc: write bg->priority_groups_sem while waiting reservation
diff mbox series

Message ID 20181128031148.357-16-suy.fnst@cn.fujitsu.com
State New
Headers show
Series
  • btrfs: implementation of priority aware allocator
Related show

Commit Message

Su Yue Nov. 28, 2018, 3:11 a.m. UTC
Since if use priority alloc, we should down/up_write()
bg->priority_groups_sem.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index f530a4344368..6627bbe56ad5 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6425,6 +6425,8 @@  void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info,
 	btrfs_put_block_group(bg);
 }
 
+static inline bool
+is_priority_alloc_enabled(struct btrfs_fs_info *fs_info);
 void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg)
 {
 	struct btrfs_space_info *space_info = bg->space_info;
@@ -6433,7 +6435,11 @@  void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg)
 
 	if (!(bg->flags & BTRFS_BLOCK_GROUP_DATA))
 		return;
-
+	if (is_priority_alloc_enabled(bg->fs_info)) {
+		down_write(&bg->priority_tree->groups_sem);
+		up_write(&bg->priority_tree->groups_sem);
+		goto wait;
+	}
 	/*
 	 * Our block group is read only but before we set it to read only,
 	 * some task might have had allocated an extent from it already, but it
@@ -6446,7 +6452,7 @@  void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg)
 	 */
 	down_write(&space_info->groups_sem);
 	up_write(&space_info->groups_sem);
-
+wait:
 	wait_var_event(&bg->reservations, !atomic_read(&bg->reservations));
 }