]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Btrfs: fix worker lock misuse in find_worker
authorChris Mason <chris.mason@oracle.com>
Fri, 23 Dec 2011 12:53:00 +0000 (07:53 -0500)
committerChris Mason <chris.mason@oracle.com>
Fri, 23 Dec 2011 12:53:00 +0000 (07:53 -0500)
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>
fs/btrfs/async-thread.c

index cb97174e236603edde0a64a8d6f0ffbb07b572f1..0b394580d8603becf8c5c031745687f6ba9e9aeb 100644 (file)
@@ -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) {
@@ -579,6 +579,7 @@ again:
                        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;