Skip to content

Commit 8d532b2

Browse files
committed
Btrfs: fix worker lock misuse in find_worker
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>
1 parent d85c8a6 commit 8d532b2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/btrfs/async-thread.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
563563
struct list_head *fallback;
564564
int ret;
565565

566-
again:
567566
spin_lock_irqsave(&workers->lock, flags);
567+
again:
568568
worker = next_worker(workers);
569569

570570
if (!worker) {
@@ -579,6 +579,7 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
579579
spin_unlock_irqrestore(&workers->lock, flags);
580580
/* we're below the limit, start another worker */
581581
ret = __btrfs_start_workers(workers);
582+
spin_lock_irqsave(&workers->lock, flags);
582583
if (ret)
583584
goto fallback;
584585
goto again;

0 commit comments

Comments
 (0)