summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorBixuan Cui <cuibixuan@huawei.com>2021-09-11 11:58:47 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-18 21:16:34 +0300
commit4eac23d60cbc105b5991e4341d09d165c21145f8 (patch)
treeeba9dc4e3dae2c17850a8f1ef435b23e06cc6f6e /fs
parentc8dccb28c3291b31ebae55cf6e783f3b5d2c9a56 (diff)
downloadlinux-4eac23d60cbc105b5991e4341d09d165c21145f8.tar.xz
io-wq: Remove duplicate code in io_workqueue_create()
[ Upstream commit 71e1cef2d794338cc7b979d4c6144e1dc12718b5 ] While task_work_add() in io_workqueue_create() is true, then duplicate code is executed: -> clear_bit_unlock(0, &worker->create_state); -> io_worker_release(worker); -> atomic_dec(&acct->nr_running); -> io_worker_ref_put(wq); -> return false; -> clear_bit_unlock(0, &worker->create_state); // back to io_workqueue_create() -> io_worker_release(worker); -> kfree(worker); The io_worker_release() and clear_bit_unlock() are executed twice. Fixes: 3146cba99aa2 ("io-wq: make worker creation resilient against signals") Signed-off-by: Bixuan Cui <cuibixuan@huawei.com> Link: https://lore.kernel.org/r/20210911085847.34849-1-cuibixuan@huawei.com Reviwed-by: Hao Xu <haoxu@linux.alibaba.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/io-wq.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 203c0e2a5dfa..5d189b24a8d4 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -359,8 +359,10 @@ static bool io_queue_worker_create(struct io_worker *worker,
init_task_work(&worker->create_work, func);
worker->create_index = acct->index;
- if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL))
+ if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) {
+ clear_bit_unlock(0, &worker->create_state);
return true;
+ }
clear_bit_unlock(0, &worker->create_state);
fail_release:
io_worker_release(worker);
@@ -765,11 +767,8 @@ static void io_workqueue_create(struct work_struct *work)
struct io_worker *worker = container_of(work, struct io_worker, work);
struct io_wqe_acct *acct = io_wqe_get_acct(worker);
- if (!io_queue_worker_create(worker, acct, create_worker_cont)) {
- clear_bit_unlock(0, &worker->create_state);
- io_worker_release(worker);
+ if (!io_queue_worker_create(worker, acct, create_worker_cont))
kfree(worker);
- }
}
static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)