Skip to content

Commit cca6571

Browse files
committed
io_uring/rw: cleanup retry path
We no longer need to gate a potential retry on whether or not the context matches our original task, as all read/write operations have been fully prepared upfront. This means there's never any re-import needed, and hence we can always retry requests. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0d10bd7 commit cca6571

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

io_uring/rw.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,9 @@ static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req)
369369
return NULL;
370370
}
371371

372-
#ifdef CONFIG_BLOCK
373-
static void io_resubmit_prep(struct io_kiocb *req)
374-
{
375-
struct io_async_rw *io = req->async_data;
376-
377-
iov_iter_restore(&io->iter, &io->iter_state);
378-
}
379-
380372
static bool io_rw_should_reissue(struct io_kiocb *req)
381373
{
374+
#ifdef CONFIG_BLOCK
382375
umode_t mode = file_inode(req->file)->i_mode;
383376
struct io_ring_ctx *ctx = req->ctx;
384377

@@ -394,23 +387,11 @@ static bool io_rw_should_reissue(struct io_kiocb *req)
394387
*/
395388
if (percpu_ref_is_dying(&ctx->refs))
396389
return false;
397-
/*
398-
* Play it safe and assume not safe to re-import and reissue if we're
399-
* not in the original thread group (or in task context).
400-
*/
401-
if (!same_thread_group(req->task, current) || !in_task())
402-
return false;
403390
return true;
404-
}
405391
#else
406-
static void io_resubmit_prep(struct io_kiocb *req)
407-
{
408-
}
409-
static bool io_rw_should_reissue(struct io_kiocb *req)
410-
{
411392
return false;
412-
}
413393
#endif
394+
}
414395

415396
static void io_req_end_write(struct io_kiocb *req)
416397
{
@@ -575,8 +556,10 @@ static int kiocb_done(struct io_kiocb *req, ssize_t ret,
575556
}
576557

577558
if (req->flags & REQ_F_REISSUE) {
559+
struct io_async_rw *io = req->async_data;
560+
578561
req->flags &= ~REQ_F_REISSUE;
579-
io_resubmit_prep(req);
562+
iov_iter_restore(&io->iter, &io->iter_state);
580563
return -EAGAIN;
581564
}
582565
return IOU_ISSUE_SKIP_COMPLETE;
@@ -897,9 +880,8 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
897880
int ret;
898881

899882
ret = __io_read(req, issue_flags);
900-
if (ret >= 0) {
901-
ret = kiocb_done(req, ret, issue_flags);
902-
}
883+
if (ret >= 0)
884+
return kiocb_done(req, ret, issue_flags);
903885

904886
return ret;
905887
}
@@ -1061,15 +1043,14 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
10611043
return -EAGAIN;
10621044
}
10631045
done:
1064-
ret = kiocb_done(req, ret2, issue_flags);
1046+
return kiocb_done(req, ret2, issue_flags);
10651047
} else {
10661048
ret_eagain:
10671049
iov_iter_restore(&io->iter, &io->iter_state);
10681050
if (kiocb->ki_flags & IOCB_WRITE)
10691051
io_req_end_write(req);
10701052
return -EAGAIN;
10711053
}
1072-
return ret;
10731054
}
10741055

10751056
void io_rw_fail(struct io_kiocb *req)

0 commit comments

Comments
 (0)