Skip to content

Commit 0f8da75

Browse files
isilenceaxboe
authored andcommitted
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: 6bf9c47 ("io_uring: defer file assignment") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/0d9b9f37841645518503f6a207e509d14a286aba.1649773463.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 82733d1 commit 0f8da75

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

fs/io_uring.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7277,16 +7277,18 @@ static void io_wq_submit_work(struct io_wq_work *work)
72777277
if (timeout)
72787278
io_queue_linked_timeout(timeout);
72797279

7280-
if (!io_assign_file(req, issue_flags)) {
7281-
err = -EBADF;
7282-
work->flags |= IO_WQ_WORK_CANCEL;
7283-
}
72847280

72857281
/* either cancelled or io-wq is dying, so don't touch tctx->iowq */
72867282
if (work->flags & IO_WQ_WORK_CANCEL) {
7283+
fail:
72877284
io_req_task_queue_fail(req, err);
72887285
return;
72897286
}
7287+
if (!io_assign_file(req, issue_flags)) {
7288+
err = -EBADF;
7289+
work->flags |= IO_WQ_WORK_CANCEL;
7290+
goto fail;
7291+
}
72907292

72917293
if (req->flags & REQ_F_FORCE_ASYNC) {
72927294
bool opcode_poll = def->pollin || def->pollout;

0 commit comments

Comments
 (0)