diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-12-23 07:53:00 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-12-23 07:53:00 -0500 |
commit | 8d532b2afb2eacc84588db709ec280a3d1219be3 (patch) | |
tree | 27a4353e75d67bc41e9d2172702dbed1109095eb /fs/btrfs/async-thread.c | |
parent | d85c8a6f1bc083279215ff6e79b7c292bf3ec905 (diff) |
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>
Diffstat (limited to 'fs/btrfs/async-thread.c')
-rw-r--r-- | fs/btrfs/async-thread.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index cb97174e2366..0b394580d860 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -563,8 +563,8 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers) | |||
563 | struct list_head *fallback; | 563 | struct list_head *fallback; |
564 | int ret; | 564 | int ret; |
565 | 565 | ||
566 | again: | ||
567 | spin_lock_irqsave(&workers->lock, flags); | 566 | spin_lock_irqsave(&workers->lock, flags); |
567 | again: | ||
568 | worker = next_worker(workers); | 568 | worker = next_worker(workers); |
569 | 569 | ||
570 | if (!worker) { | 570 | if (!worker) { |
@@ -579,6 +579,7 @@ again: | |||
579 | spin_unlock_irqrestore(&workers->lock, flags); | 579 | spin_unlock_irqrestore(&workers->lock, flags); |
580 | /* we're below the limit, start another worker */ | 580 | /* we're below the limit, start another worker */ |
581 | ret = __btrfs_start_workers(workers); | 581 | ret = __btrfs_start_workers(workers); |
582 | spin_lock_irqsave(&workers->lock, flags); | ||
582 | if (ret) | 583 | if (ret) |
583 | goto fallback; | 584 | goto fallback; |
584 | goto again; | 585 | goto again; |