aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/io-wq.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-02-26 09:50:55 -0700
committerJens Axboe <axboe@kernel.dk>2021-03-01 10:21:06 -0700
commit65d43023171edc0d27208f6ac7a1a73732950cf7 (patch)
treebcaa43248f63385b6056fc1fd7ab11e59e7356a7 /fs/io-wq.c
parentLinux 5.12-rc1 (diff)
downloadwireguard-linux-65d43023171edc0d27208f6ac7a1a73732950cf7.tar.xz
wireguard-linux-65d43023171edc0d27208f6ac7a1a73732950cf7.zip
io-wq: wait for worker startup when forking a new one
We need to have our worker count updated before continuing, to avoid cases where we repeatedly think we need a new worker, but a fork is already in progress. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io-wq.c')
-rw-r--r--fs/io-wq.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 44e20248805a..965022fe9961 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -56,6 +56,7 @@ struct io_worker {
const struct cred *saved_creds;
struct completion ref_done;
+ struct completion started;
struct rcu_head rcu;
};
@@ -267,6 +268,7 @@ static void io_worker_start(struct io_worker *worker)
{
worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
io_wqe_inc_running(worker);
+ complete(&worker->started);
}
/*
@@ -644,6 +646,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
worker->wqe = wqe;
spin_lock_init(&worker->lock);
init_completion(&worker->ref_done);
+ init_completion(&worker->started);
refcount_inc(&wq->refs);
@@ -656,6 +659,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
kfree(worker);
return false;
}
+ wait_for_completion(&worker->started);
return true;
}