Skip to content

Commit b66ceaf

Browse files
isilenceaxboe
authored andcommitted
io_uring: move iopoll reissue into regular IO path
230d50d ("io_uring: move reissue into regular IO path") made non-IOPOLL I/O to not retry from ki_complete handler. Follow it steps and do the same for IOPOLL. Same problems, same implementation, same -EAGAIN assumptions. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/f80dfee2d5fa7678f0052a8ab3cfca9496a112ca.1631699928.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7dedd3e commit b66ceaf

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

fs/io_uring.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ enum {
736736
REQ_F_BUFFER_SELECTED_BIT,
737737
REQ_F_COMPLETE_INLINE_BIT,
738738
REQ_F_REISSUE_BIT,
739-
REQ_F_DONT_REISSUE_BIT,
740739
REQ_F_CREDS_BIT,
741740
REQ_F_REFCOUNT_BIT,
742741
REQ_F_ARM_LTIMEOUT_BIT,
@@ -783,8 +782,6 @@ enum {
783782
REQ_F_COMPLETE_INLINE = BIT(REQ_F_COMPLETE_INLINE_BIT),
784783
/* caller should reissue async */
785784
REQ_F_REISSUE = BIT(REQ_F_REISSUE_BIT),
786-
/* don't attempt request reissue, see io_rw_reissue() */
787-
REQ_F_DONT_REISSUE = BIT(REQ_F_DONT_REISSUE_BIT),
788785
/* supports async reads */
789786
REQ_F_NOWAIT_READ = BIT(REQ_F_NOWAIT_READ_BIT),
790787
/* supports async writes */
@@ -2440,13 +2437,6 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
24402437
req = list_first_entry(done, struct io_kiocb, inflight_entry);
24412438
list_del(&req->inflight_entry);
24422439

2443-
if (READ_ONCE(req->result) == -EAGAIN &&
2444-
!(req->flags & REQ_F_DONT_REISSUE)) {
2445-
req->iopoll_completed = 0;
2446-
io_req_task_queue_reissue(req);
2447-
continue;
2448-
}
2449-
24502440
__io_cqring_fill_event(ctx, req->user_data, req->result,
24512441
io_put_rw_kbuf(req));
24522442
(*nr_events)++;
@@ -2709,10 +2699,9 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
27092699
if (kiocb->ki_flags & IOCB_WRITE)
27102700
kiocb_end_write(req);
27112701
if (unlikely(res != req->result)) {
2712-
if (!(res == -EAGAIN && io_rw_should_reissue(req) &&
2713-
io_resubmit_prep(req))) {
2714-
req_set_fail(req);
2715-
req->flags |= REQ_F_DONT_REISSUE;
2702+
if (res == -EAGAIN && io_rw_should_reissue(req)) {
2703+
req->flags |= REQ_F_REISSUE;
2704+
return;
27162705
}
27172706
}
27182707

@@ -2926,7 +2915,6 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
29262915
{
29272916
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
29282917
struct io_async_rw *io = req->async_data;
2929-
bool check_reissue = kiocb->ki_complete == io_complete_rw;
29302918

29312919
/* add previously done IO, if any */
29322920
if (io && io->bytes_done > 0) {
@@ -2938,19 +2926,27 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
29382926

29392927
if (req->flags & REQ_F_CUR_POS)
29402928
req->file->f_pos = kiocb->ki_pos;
2941-
if (ret >= 0 && check_reissue)
2929+
if (ret >= 0 && (kiocb->ki_complete == io_complete_rw))
29422930
__io_complete_rw(req, ret, 0, issue_flags);
29432931
else
29442932
io_rw_done(kiocb, ret);
29452933

2946-
if (check_reissue && (req->flags & REQ_F_REISSUE)) {
2934+
if (req->flags & REQ_F_REISSUE) {
29472935
req->flags &= ~REQ_F_REISSUE;
29482936
if (io_resubmit_prep(req)) {
29492937
io_req_task_queue_reissue(req);
29502938
} else {
2939+
unsigned int cflags = io_put_rw_kbuf(req);
2940+
struct io_ring_ctx *ctx = req->ctx;
2941+
29512942
req_set_fail(req);
2952-
__io_req_complete(req, issue_flags, ret,
2953-
io_put_rw_kbuf(req));
2943+
if (issue_flags & IO_URING_F_NONBLOCK) {
2944+
mutex_lock(&ctx->uring_lock);
2945+
__io_req_complete(req, issue_flags, ret, cflags);
2946+
mutex_unlock(&ctx->uring_lock);
2947+
} else {
2948+
__io_req_complete(req, issue_flags, ret, cflags);
2949+
}
29542950
}
29552951
}
29562952
}

0 commit comments

Comments
 (0)