io-wq: fix lack of acct->nr_workers < acct->max_workers judgement
authorHao Xu <haoxu@linux.alibaba.com>
Thu, 5 Aug 2021 10:05:38 +0000 (18:05 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 6 Aug 2021 14:28:18 +0000 (08:28 -0600)
There should be this judgement before we create an io-worker

Fixes: 685fe7feedb9 ("io-wq: eliminate the need for a manager thread")
Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c

index 64d904c..12fc193 100644 (file)
@@ -280,9 +280,17 @@ static void create_worker_cb(struct callback_head *cb)
 {
        struct create_worker_data *cwd;
        struct io_wq *wq;
+       struct io_wqe *wqe;
+       struct io_wqe_acct *acct;
 
        cwd = container_of(cb, struct create_worker_data, work);
-       wq = cwd->wqe->wq;
+       wqe = cwd->wqe;
+       wq = wqe->wq;
+       acct = &wqe->acct[cwd->index];
+       raw_spin_lock_irq(&wqe->lock);
+       if (acct->nr_workers < acct->max_workers)
+               acct->nr_workers++;
+       raw_spin_unlock_irq(&wqe->lock);
        create_io_worker(wq, cwd->wqe, cwd->index);
        kfree(cwd);
 }