Move io_rw_should_reissue() check into io_resubmit_prep(), so we don't need, so we can remove it from io_rw_reissue() and io_complete_rw_iopoll(). Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- fs/io_uring.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index e8d95feed75f..e9bfe137270c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2441,17 +2441,6 @@ static void kiocb_end_write(struct io_kiocb *req) } #ifdef CONFIG_BLOCK -static bool io_resubmit_prep(struct io_kiocb *req) -{ - struct io_async_rw *rw = req->async_data; - - if (!rw) - return !io_req_prep_async(req); - /* may have left rw->iter inconsistent on -EIOCBQUEUED */ - iov_iter_revert(&rw->iter, req->result - iov_iter_count(&rw->iter)); - return true; -} - static bool io_rw_should_reissue(struct io_kiocb *req) { umode_t mode = file_inode(req->file)->i_mode; @@ -2467,26 +2456,34 @@ static bool io_rw_should_reissue(struct io_kiocb *req) * Don't attempt to reissue from that path, just let it fail with * -EAGAIN. */ - if (percpu_ref_is_dying(&ctx->refs)) - return false; - return true; + return !percpu_ref_is_dying(&ctx->refs); } -#endif -static bool io_rw_reissue(struct io_kiocb *req) +static bool io_resubmit_prep(struct io_kiocb *req) { -#ifdef CONFIG_BLOCK + struct io_async_rw *rw = req->async_data; + if (!io_rw_should_reissue(req)) return false; lockdep_assert_held(&req->ctx->uring_lock); + if (!rw) + return !io_req_prep_async(req); + /* may have left rw->iter inconsistent on -EIOCBQUEUED */ + iov_iter_revert(&rw->iter, req->result - iov_iter_count(&rw->iter)); + return true; +} +#endif + +static bool io_rw_reissue(struct io_kiocb *req) +{ +#ifdef CONFIG_BLOCK if (io_resubmit_prep(req)) { req_ref_get(req); io_queue_async_work(req); return true; } - req_set_fail_links(req); #endif return false; } @@ -2525,9 +2522,7 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) bool fail = true; #ifdef CONFIG_BLOCK - if (res == -EAGAIN && io_rw_should_reissue(req) && - io_resubmit_prep(req)) - fail = false; + fail = res != -EAGAIN || !io_resubmit_prep(req); #endif if (fail) { req_set_fail_links(req); -- 2.24.0