Btrfs: fix small race with delalloc flushing waitqueue's
diff mbox

Message ID 20100312192817.GA2332@localhost.localdomain
State New, archived
Headers show

Commit Message

Josef Bacik March 12, 2010, 7:28 p.m. UTC
None

Patch
diff mbox

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9c6fbd0..73ac69b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2678,6 +2678,8 @@  static int update_space_info(struct btrfs_fs_info *info, u64 flags,
 	INIT_LIST_HEAD(&found->block_groups);
 	init_waitqueue_head(&found->flush_wait);
 	init_rwsem(&found->groups_sem);
+	init_waitqueue_head(&found->flush_wait);
+	init_waitqueue_head(&found->allocate_wait);
 	spin_lock_init(&found->lock);
 	found->flags = flags;
 	found->total_bytes = total_bytes;
@@ -2929,12 +2931,10 @@  static void flush_delalloc(struct btrfs_root *root,
 
 	spin_lock(&info->lock);
 
-	if (!info->flushing) {
+	if (!info->flushing)
 		info->flushing = 1;
-		init_waitqueue_head(&info->flush_wait);
-	} else {
+	else
 		wait = true;
-	}
 
 	spin_unlock(&info->lock);
 
@@ -2997,7 +2997,6 @@  static int maybe_allocate_chunk(struct btrfs_root *root,
 	if (!info->allocating_chunk) {
 		info->force_alloc = 1;
 		info->allocating_chunk = 1;
-		init_waitqueue_head(&info->allocate_wait);
 	} else {
 		wait = true;
 	}