aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-03-12 14:28:18 -0500
committerChris Mason <chris.mason@oracle.com>2010-04-05 14:42:00 -0400
commitb5cb160084fad438c513d0952849e597ffe9e3d9 (patch)
tree91a5a1352cc803695b2ae3b3217c82d423ca5edf /fs
parent28ecb60906e86e74e9ad4ac7e0218d8631e73a94 (diff)
Btrfs: fix small race with delalloc flushing waitqueue's
Everytime we start a new flushing thread, we init the waitqueue if there isn't a flushing thread running. The problem with this is we check space_info->flushing, which we clear right before doing a wake_up on the flushing waitqueue, which causes problems if we init the waitqueue in the middle of clearing the flushing flagh and calling wake_up. This is hard to hit, but the code is wrong anyway, so init the flushing/allocating waitqueue when creating the space info and let it be. I haven't seen the panic since I've been using this patch. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent-tree.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5f6bc283c0c8..101041d4d2b2 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2676,6 +2676,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
2676 2676
2677 INIT_LIST_HEAD(&found->block_groups); 2677 INIT_LIST_HEAD(&found->block_groups);
2678 init_rwsem(&found->groups_sem); 2678 init_rwsem(&found->groups_sem);
2679 init_waitqueue_head(&found->flush_wait);
2680 init_waitqueue_head(&found->allocate_wait);
2679 spin_lock_init(&found->lock); 2681 spin_lock_init(&found->lock);
2680 found->flags = flags; 2682 found->flags = flags;
2681 found->total_bytes = total_bytes; 2683 found->total_bytes = total_bytes;
@@ -2944,12 +2946,10 @@ static void flush_delalloc(struct btrfs_root *root,
2944 2946
2945 spin_lock(&info->lock); 2947 spin_lock(&info->lock);
2946 2948
2947 if (!info->flushing) { 2949 if (!info->flushing)
2948 info->flushing = 1; 2950 info->flushing = 1;
2949 init_waitqueue_head(&info->flush_wait); 2951 else
2950 } else {
2951 wait = true; 2952 wait = true;
2952 }
2953 2953
2954 spin_unlock(&info->lock); 2954 spin_unlock(&info->lock);
2955 2955
@@ -3011,7 +3011,6 @@ static int maybe_allocate_chunk(struct btrfs_root *root,
3011 if (!info->allocating_chunk) { 3011 if (!info->allocating_chunk) {
3012 info->force_alloc = 1; 3012 info->force_alloc = 1;
3013 info->allocating_chunk = 1; 3013 info->allocating_chunk = 1;
3014 init_waitqueue_head(&info->allocate_wait);
3015 } else { 3014 } else {
3016 wait = true; 3015 wait = true;
3017 } 3016 }