Skip to content

Commit ae34817

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't do opcode prep twice
Calling into opcode prep handlers may be dangerous, as they re-read SQE but might not re-initialise requests completely. If io_req_defer() passed fast checks and is done with preparations, punt it async. As all other cases are covered with nulling @sqe, this guarantees that io_[opcode]_prep() are visited only once per request. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 23b3628 commit ae34817

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/io_uring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5447,7 +5447,8 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
54475447
if (!req_need_defer(req, seq) && list_empty(&ctx->defer_list)) {
54485448
spin_unlock_irq(&ctx->completion_lock);
54495449
kfree(de);
5450-
return 0;
5450+
io_queue_async_work(req);
5451+
return -EIOCBQUEUED;
54515452
}
54525453

54535454
trace_io_uring_defer(ctx, req, req->user_data);

0 commit comments

Comments
 (0)