Skip to content

Commit 860e1c7

Browse files
Ming Leiaxboe
authored andcommitted
io_uring: complete request via task work in case of DEFER_TASKRUN
So far io_req_complete_post() only covers DEFER_TASKRUN by completing request via task work when the request is completed from IOWQ. However, uring command could be completed from any context, and if io uring is setup with DEFER_TASKRUN, the command is required to be completed from current context, otherwise wait on IORING_ENTER_GETEVENTS can't be wakeup, and may hang forever. The issue can be observed on removing ublk device, but turns out it is one generic issue for uring command & DEFER_TASKRUN, so solve it in io_uring core code. Fixes: e6aeb27 ("io_uring: complete all requests in task context") Cc: [email protected] Link: https://lore.kernel.org/linux-block/[email protected]/ Reported-by: Jens Axboe <[email protected]> Cc: Kanchan Joshi <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b4a72c0 commit 860e1c7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

io_uring/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ static void __io_req_complete_post(struct io_kiocb *req)
998998

999999
void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
10001000
{
1001-
if (req->ctx->task_complete && (issue_flags & IO_URING_F_IOWQ)) {
1001+
if (req->ctx->task_complete && req->ctx->submitter_task != current) {
10021002
req->io_task_work.func = io_req_task_complete;
10031003
io_req_task_work_add(req);
10041004
} else if (!(issue_flags & IO_URING_F_UNLOCKED) ||

0 commit comments

Comments
 (0)