Add a helper io_wq_destroy_manager(), for killing an io-wq manager and not repeating it three times. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- fs/io-wq.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index 9828722fdee9..c9d886d1a73c 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -1059,20 +1059,24 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data) return ERR_PTR(ret); } -static void io_wq_destroy(struct io_wq *wq) +static void io_wq_destroy_manager(struct io_wq *wq) { - int node; - - cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); - - set_bit(IO_WQ_BIT_EXIT, &wq->state); if (wq->manager) { wake_up_process(wq->manager); wait_for_completion(&wq->exited); put_task_struct(wq->manager); wq->manager = NULL; } +} + +static void io_wq_destroy(struct io_wq *wq) +{ + int node; + + cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); + set_bit(IO_WQ_BIT_EXIT, &wq->state); + io_wq_destroy_manager(wq); spin_lock_irq(&wq->hash->wait.lock); for_each_node(node) { struct io_wqe *wqe = wq->wqes[node]; @@ -1095,12 +1099,7 @@ void io_wq_put(struct io_wq *wq) void io_wq_put_and_exit(struct io_wq *wq) { set_bit(IO_WQ_BIT_EXIT, &wq->state); - if (wq->manager) { - wake_up_process(wq->manager); - wait_for_completion(&wq->exited); - put_task_struct(wq->manager); - wq->manager = NULL; - } + io_wq_destroy_manager(wq); io_wq_put(wq); } @@ -1146,12 +1145,7 @@ void io_wq_unshare(struct io_wq *wq) { refcount_inc(&wq->refs); set_bit(IO_WQ_BIT_EXIT, &wq->state); - if (wq->manager) { - wake_up_process(wq->manager); - wait_for_completion(&wq->exited); - put_task_struct(wq->manager); - wq->manager = NULL; - } + io_wq_destroy_manager(wq); clear_bit(IO_WQ_BIT_EXIT, &wq->state); io_wq_put(wq); } -- 2.24.0