diff options
| author | Jens Axboe <[email protected]> | 2025-09-18 16:21:14 +0000 |
|---|---|---|
| committer | Jens Axboe <[email protected]> | 2025-09-18 16:24:50 +0000 |
| commit | 3539b1467e94336d5854ebf976d9627bfb65d6c3 (patch) | |
| tree | a6bbcfb9ea4bea836fcfb2a66e94fe0f7f64413b /io_uring/io_uring.c | |
| parent | io_uring/io-wq: fix `max_workers` breakage and `nr_workers` underflow (diff) | |
| download | kernel-3539b1467e94336d5854ebf976d9627bfb65d6c3.tar.gz kernel-3539b1467e94336d5854ebf976d9627bfb65d6c3.zip | |
io_uring: include dying ring in task_work "should cancel" state
When running task_work for an exiting task, rather than perform the
issue retry attempt, the task_work is canceled. However, this isn't
done for a ring that has been closed. This can lead to requests being
successfully completed post the ring being closed, which is somewhat
confusing and surprising to an application.
Rather than just check the task exit state, also include the ring
ref state in deciding whether or not to terminate a given request when
run from task_work.
Cc: [email protected] # 6.1+
Link: https://github.com/axboe/liburing/discussions/1459
Reported-by: Benedek Thaler <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Diffstat (limited to 'io_uring/io_uring.c')
| -rw-r--r-- | io_uring/io_uring.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 93633613a165..bcec12256f34 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1406,8 +1406,10 @@ static void io_req_task_cancel(struct io_kiocb *req, io_tw_token_t tw) void io_req_task_submit(struct io_kiocb *req, io_tw_token_t tw) { - io_tw_lock(req->ctx, tw); - if (unlikely(io_should_terminate_tw())) + struct io_ring_ctx *ctx = req->ctx; + + io_tw_lock(ctx, tw); + if (unlikely(io_should_terminate_tw(ctx))) io_req_defer_failed(req, -EFAULT); else if (req->flags & REQ_F_FORCE_ASYNC) io_queue_iowq(req); |
