Al pointed out that if we fail to start a worker for whatever reason (ENOMEM basically), we could leak our count for num_start_workers, and so we'd think we had more workers than we actually do. This could cause us to shrink workers when we shouldn't or not start workers when we should. So check the return value and if we failed fix num_start_workers and fallback. Thanks,
Signed-off-by: Josef Bacik <jo...@redhat.com> --- fs/btrfs/async-thread.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 7ec1409..09ef1b0 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -568,6 +568,7 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers) struct btrfs_worker_thread *worker; unsigned long flags; struct list_head *fallback; + int ret; again: spin_lock_irqsave(&workers->lock, flags); @@ -584,7 +585,13 @@ again: workers->num_workers_starting++; spin_unlock_irqrestore(&workers->lock, flags); /* we're below the limit, start another worker */ - __btrfs_start_workers(workers, 1); + ret = __btrfs_start_workers(workers, 1); + if (ret) { + spin_lock_irqsave(&workers->lock, flags); + workers->num_workers_starting--; + spin_unlock_irqrestore(&workers->lock, flags); + goto fallback; + } goto again; } } -- 1.7.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html