summaryrefslogtreecommitdiffstats
path: root/fs/io-wq.c
diff options
context:
space:
mode:
authorHao Xu <haoxu@linux.alibaba.com>2021-08-05 12:05:38 +0200
committerJens Axboe <axboe@kernel.dk>2021-08-06 16:28:18 +0200
commit21698274da5b6fc724b005bc7ec3e6b9fbcfaa06 (patch)
tree5d721629d54c549b8f4d3a5a0fb97c45be228108 /fs/io-wq.c
parentio-wq: fix no lock protection of acct->nr_worker (diff)
downloadlinux-21698274da5b6fc724b005bc7ec3e6b9fbcfaa06.tar.xz
linux-21698274da5b6fc724b005bc7ec3e6b9fbcfaa06.zip
io-wq: fix lack of acct->nr_workers < acct->max_workers judgement
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>
Diffstat (limited to '')
-rw-r--r--fs/io-wq.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 64d904ce4f2d..12fc19353bb0 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -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);
}