Skip to content

Commit 4e43133

Browse files
isilenceaxboe
authored andcommitted
io_uring/rw: don't directly use ki_complete
We want to avoid checking ->ki_complete directly in the io_uring completion path. Fortunately we have only two callback the selection of which depend on the ring constant flags, i.e. IOPOLL, so use that to infer the function. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/4eb4bdab8cbcf5bc87083f7047edc81e920ab83c.1739919038.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 67b0025 commit 4e43133

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

io_uring/rw.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,10 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
563563
smp_store_release(&req->iopoll_completed, 1);
564564
}
565565

566-
static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
566+
static inline void io_rw_done(struct io_kiocb *req, ssize_t ret)
567567
{
568+
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
569+
568570
/* IO was queued async, completion will happen later */
569571
if (ret == -EIOCBQUEUED)
570572
return;
@@ -586,8 +588,10 @@ static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
586588
}
587589
}
588590

589-
INDIRECT_CALL_2(kiocb->ki_complete, io_complete_rw_iopoll,
590-
io_complete_rw, kiocb, ret);
591+
if (req->ctx->flags & IORING_SETUP_IOPOLL)
592+
io_complete_rw_iopoll(&rw->kiocb, ret);
593+
else
594+
io_complete_rw(&rw->kiocb, ret);
591595
}
592596

593597
static int kiocb_done(struct io_kiocb *req, ssize_t ret,
@@ -598,7 +602,7 @@ static int kiocb_done(struct io_kiocb *req, ssize_t ret,
598602

599603
if (ret >= 0 && req->flags & REQ_F_CUR_POS)
600604
req->file->f_pos = rw->kiocb.ki_pos;
601-
if (ret >= 0 && (rw->kiocb.ki_complete == io_complete_rw)) {
605+
if (ret >= 0 && !(req->ctx->flags & IORING_SETUP_IOPOLL)) {
602606
__io_complete_rw_common(req, ret);
603607
/*
604608
* Safe to call io_end from here as we're inline
@@ -609,7 +613,7 @@ static int kiocb_done(struct io_kiocb *req, ssize_t ret,
609613
io_req_rw_cleanup(req, issue_flags);
610614
return IOU_OK;
611615
} else {
612-
io_rw_done(&rw->kiocb, ret);
616+
io_rw_done(req, ret);
613617
}
614618

615619
return IOU_ISSUE_SKIP_COMPLETE;

0 commit comments

Comments
 (0)