Commit 0f8da75b authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: fix assign file locking issue

io-wq work cancellation path can't take uring_lock as how it's done on
file assignment, we have to handle IO_WQ_WORK_CANCEL first, this fixes
encountered hangs.

Fixes: 6bf9c47a ("io_uring: defer file assignment")
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/0d9b9f37841645518503f6a207e509d14a286aba.1649773463.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 82733d16
...@@ -7277,16 +7277,18 @@ static void io_wq_submit_work(struct io_wq_work *work) ...@@ -7277,16 +7277,18 @@ static void io_wq_submit_work(struct io_wq_work *work)
if (timeout) if (timeout)
io_queue_linked_timeout(timeout); io_queue_linked_timeout(timeout);
if (!io_assign_file(req, issue_flags)) {
err = -EBADF;
work->flags |= IO_WQ_WORK_CANCEL;
}
/* either cancelled or io-wq is dying, so don't touch tctx->iowq */ /* either cancelled or io-wq is dying, so don't touch tctx->iowq */
if (work->flags & IO_WQ_WORK_CANCEL) { if (work->flags & IO_WQ_WORK_CANCEL) {
fail:
io_req_task_queue_fail(req, err); io_req_task_queue_fail(req, err);
return; return;
} }
if (!io_assign_file(req, issue_flags)) {
err = -EBADF;
work->flags |= IO_WQ_WORK_CANCEL;
goto fail;
}
if (req->flags & REQ_F_FORCE_ASYNC) { if (req->flags & REQ_F_FORCE_ASYNC) {
bool opcode_poll = def->pollin || def->pollout; bool opcode_poll = def->pollin || def->pollout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment