Commit b5cb1600 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

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: default avatarJosef Bacik <josef@redhat.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 28ecb609
...@@ -2676,6 +2676,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags, ...@@ -2676,6 +2676,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
INIT_LIST_HEAD(&found->block_groups); INIT_LIST_HEAD(&found->block_groups);
init_rwsem(&found->groups_sem); init_rwsem(&found->groups_sem);
init_waitqueue_head(&found->flush_wait);
init_waitqueue_head(&found->allocate_wait);
spin_lock_init(&found->lock); spin_lock_init(&found->lock);
found->flags = flags; found->flags = flags;
found->total_bytes = total_bytes; found->total_bytes = total_bytes;
...@@ -2944,12 +2946,10 @@ static void flush_delalloc(struct btrfs_root *root, ...@@ -2944,12 +2946,10 @@ static void flush_delalloc(struct btrfs_root *root,
spin_lock(&info->lock); spin_lock(&info->lock);
if (!info->flushing) { if (!info->flushing)
info->flushing = 1; info->flushing = 1;
init_waitqueue_head(&info->flush_wait); else
} else {
wait = true; wait = true;
}
spin_unlock(&info->lock); spin_unlock(&info->lock);
...@@ -3011,7 +3011,6 @@ static int maybe_allocate_chunk(struct btrfs_root *root, ...@@ -3011,7 +3011,6 @@ static int maybe_allocate_chunk(struct btrfs_root *root,
if (!info->allocating_chunk) { if (!info->allocating_chunk) {
info->force_alloc = 1; info->force_alloc = 1;
info->allocating_chunk = 1; info->allocating_chunk = 1;
init_waitqueue_head(&info->allocate_wait);
} else { } else {
wait = true; wait = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment