refcount_t refs;
struct completion started;
+ struct completion exited;
atomic_t worker_refs;
struct completion worker_done;
if (atomic_read(&wq->worker_refs))
wait_for_completion(&wq->worker_done);
wq->manager = NULL;
+ complete(&wq->exited);
io_wq_put(wq);
do_exit(0);
}
wq->task_pid = current->pid;
init_completion(&wq->started);
+ init_completion(&wq->exited);
refcount_set(&wq->refs, 1);
init_completion(&wq->worker_done);
cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node);
set_bit(IO_WQ_BIT_EXIT, &wq->state);
- if (wq->manager)
+ if (wq->manager) {
wake_up_process(wq->manager);
+ wait_for_completion(&wq->exited);
+ }
spin_lock_irq(&wq->hash->wait.lock);
for_each_node(node) {