Skip to content

Commit 9cb0073

Browse files
isilenceaxboe
authored andcommitted
io_uring: pin ctx on fallback execution
Pin ring in io_fallback_req_func() by briefly elevating ctx->refs in case any task_work handler touches ctx after releasing a request. Fixes: 9011bf9 ("io_uring: fix stuck fallback reqs") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/833a494713d235ec144284a9bbfe418df4f6b61c.1629235576.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 21f9652 commit 9cb0073

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/io_uring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,8 +2477,10 @@ static void io_fallback_req_func(struct work_struct *work)
24772477
struct llist_node *node = llist_del_all(&ctx->fallback_llist);
24782478
struct io_kiocb *req, *tmp;
24792479

2480+
percpu_ref_get(&ctx->refs);
24802481
llist_for_each_entry_safe(req, tmp, node, io_task_work.fallback_node)
24812482
req->io_task_work.func(req);
2483+
percpu_ref_put(&ctx->refs);
24822484
}
24832485

24842486
static void __io_complete_rw(struct io_kiocb *req, long res, long res2,

0 commit comments

Comments
 (0)