if (test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state))
return;
down_write(&sqd->rw_lock);
- if (!sqd->thread) {
- up_write(&sqd->rw_lock);
- return;
- }
set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
- wake_up_process(sqd->thread);
+ if (sqd->thread)
+ wake_up_process(sqd->thread);
up_write(&sqd->rw_lock);
wait_for_completion(&sqd->exited);
}
ret = -EINVAL;
if (cpu >= nr_cpu_ids)
- goto err;
+ goto err_sqpoll;
if (!cpu_online(cpu))
- goto err;
+ goto err_sqpoll;
sqd->sq_cpu = cpu;
} else {
tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
if (IS_ERR(tsk)) {
ret = PTR_ERR(tsk);
- goto err;
+ goto err_sqpoll;
}
sqd->thread = tsk;
err:
io_sq_thread_finish(ctx);
return ret;
+err_sqpoll:
+ complete(&ctx->sq_data->exited);
+ goto err;
}
static inline void __io_unaccount_mem(struct user_struct *user,