diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2024-09-11 18:34:37 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-09-11 18:44:10 +0200 |
commit | 6746ee4c3a189f8b60694f01e7e29bc5ff7972e0 (patch) | |
tree | 6ab9e275c7681d7a8c2d1c9849fc053376a33527 /io_uring/io_uring.c | |
parent | Merge branch 'for-6.12/io_uring' into for-6.12/io_uring-discard (diff) | |
download | linux-6746ee4c3a189f8b60694f01e7e29bc5ff7972e0.tar.xz linux-6746ee4c3a189f8b60694f01e7e29bc5ff7972e0.zip |
io_uring/cmd: expose iowq to cmds
When an io_uring request needs blocking context we offload it to the
io_uring's thread pool called io-wq. We can get there off ->uring_cmd
by returning -EAGAIN, but there is no straightforward way of doing that
from an asynchronous callback. Add a helper that would transfer a
command to a blocking context.
Note, we do an extra hop via task_work before io_queue_iowq(), that's a
limitation of io_uring infra we have that can likely be lifted later
if that would ever become a problem.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/f735f807d7c8ba50c9452c69dfe5d3e9e535037b.1726072086.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r-- | io_uring/io_uring.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 1aca501efaf6..86cf31902841 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -533,6 +533,17 @@ static void io_queue_iowq(struct io_kiocb *req) io_queue_linked_timeout(link); } +static void io_req_queue_iowq_tw(struct io_kiocb *req, struct io_tw_state *ts) +{ + io_queue_iowq(req); +} + +void io_req_queue_iowq(struct io_kiocb *req) +{ + req->io_task_work.func = io_req_queue_iowq_tw; + io_req_task_work_add(req); +} + static __cold void io_queue_deferred(struct io_ring_ctx *ctx) { while (!list_empty(&ctx->defer_list)) { |