Skip to content

Commit

Permalink
Btrfs: fix worker lock misuse in find_worker
Browse files Browse the repository at this point in the history
Dan Carpenter noticed that we were doing a double unlock on the worker
lock, and sometimes picking a worker thread without the lock held.

This fixes both errors.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
  • Loading branch information
Chris Mason committed Dec 23, 2011
1 parent d85c8a6 commit 8d532b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/async-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
struct list_head *fallback;
int ret;

again:
spin_lock_irqsave(&workers->lock, flags);
again:
worker = next_worker(workers);

if (!worker) {
Expand All @@ -579,6 +579,7 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
spin_unlock_irqrestore(&workers->lock, flags);
/* we're below the limit, start another worker */
ret = __btrfs_start_workers(workers);
spin_lock_irqsave(&workers->lock, flags);
if (ret)
goto fallback;
goto again;
Expand Down

0 comments on commit 8d532b2

Please sign in to comment.