public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 09/11] io_uring: don't alter iopoll reissue fail ret code
Date: Mon, 22 Mar 2021 01:58:32 +0000	[thread overview]
Message-ID: <1151b9a8f5a7aee8c93b4c20e7a68f8f22913db2.1616378197.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

When reissue_prep failed in io_complete_rw_iopoll(), we change return
code to -EIO to prevent io_iopoll_complete() from doing resubmission.
Mark requests with a new flag (i.e. REQ_F_DONT_REISSUE) instead and
retain the original return value.

It also removes io_rw_reissue() from io_iopoll_complete() that will be
used later.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index c81f2db0fee5..cccd5fd582f2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -696,6 +696,7 @@ enum {
 	REQ_F_BUFFER_SELECTED_BIT,
 	REQ_F_LTIMEOUT_ACTIVE_BIT,
 	REQ_F_COMPLETE_INLINE_BIT,
+	REQ_F_DONT_REISSUE_BIT,
 	/* keep async read/write and isreg together and in order */
 	REQ_F_ASYNC_READ_BIT,
 	REQ_F_ASYNC_WRITE_BIT,
@@ -739,6 +740,8 @@ enum {
 	REQ_F_LTIMEOUT_ACTIVE	= BIT(REQ_F_LTIMEOUT_ACTIVE_BIT),
 	/* completion is deferred through io_comp_state */
 	REQ_F_COMPLETE_INLINE	= BIT(REQ_F_COMPLETE_INLINE_BIT),
+	/* don't attempt request reissue, see io_rw_reissue() */
+	REQ_F_DONT_REISSUE	= BIT(REQ_F_DONT_REISSUE_BIT),
 	/* supports async reads */
 	REQ_F_ASYNC_READ	= BIT(REQ_F_ASYNC_READ_BIT),
 	/* supports async writes */
@@ -1014,7 +1017,6 @@ static struct fixed_rsrc_ref_node *alloc_fixed_rsrc_ref_node(
 			struct io_ring_ctx *ctx);
 static void io_ring_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc);
 
-static bool io_rw_reissue(struct io_kiocb *req);
 static void io_cqring_fill_event(struct io_kiocb *req, long res);
 static void io_put_req(struct io_kiocb *req);
 static void io_put_req_deferred(struct io_kiocb *req, int nr);
@@ -2283,10 +2285,12 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
 		req = list_first_entry(done, struct io_kiocb, inflight_entry);
 		list_del(&req->inflight_entry);
 
-		if (READ_ONCE(req->result) == -EAGAIN) {
+		if (READ_ONCE(req->result) == -EAGAIN &&
+		    !(req->flags & REQ_F_DONT_REISSUE)) {
 			req->iopoll_completed = 0;
-			if (io_rw_reissue(req))
-				continue;
+			req_ref_get(req);
+			io_queue_async_work(req);
+			continue;
 		}
 
 		if (req->flags & REQ_F_BUFFER_SELECTED)
@@ -2550,15 +2554,17 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
 			iov_iter_revert(&rw->iter,
 					req->result - iov_iter_count(&rw->iter));
 		else if (!io_resubmit_prep(req))
-			res = -EIO;
+			req->flags |= REQ_F_DONT_REISSUE;
 	}
 #endif
 
 	if (kiocb->ki_flags & IOCB_WRITE)
 		kiocb_end_write(req);
 
-	if (res != -EAGAIN && res != req->result)
+	if (res != -EAGAIN && res != req->result) {
+		req->flags |= REQ_F_DONT_REISSUE;
 		req_set_fail_links(req);
+	}
 
 	WRITE_ONCE(req->result, res);
 	/* order with io_iopoll_complete() checking ->result */
-- 
2.24.0


  parent reply	other threads:[~2021-03-22  2:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  1:58 [PATCH 5.13 00/11] yet another series of random 5.13 patches Pavel Begunkov
2021-03-22  1:58 ` [PATCH 01/11] io_uring: don't clear REQ_F_LINK_TIMEOUT Pavel Begunkov
2021-03-22  1:58 ` [PATCH 02/11] io_uring: don't do extra EXITING cancellations Pavel Begunkov
2021-03-22  1:58 ` [PATCH 03/11] io_uring: optimise out task_work checks on enter Pavel Begunkov
2021-03-22 13:45   ` Jens Axboe
2021-03-22 14:53     ` Pavel Begunkov
2021-03-22 14:58       ` Jens Axboe
2021-03-22  1:58 ` [PATCH 04/11] io_uring: remove tctx->sqpoll Pavel Begunkov
2021-03-22  1:58 ` [PATCH 05/11] io-wq: refactor *_get_acct() Pavel Begunkov
2021-03-22  1:58 ` [PATCH 06/11] io_uring: don't init req->work fully in advance Pavel Begunkov
2021-03-22  1:58 ` [PATCH 07/11] io_uring: kill unused REQ_F_NO_FILE_TABLE Pavel Begunkov
2021-03-22  1:58 ` [PATCH 08/11] io_uring: optimise kiocb_end_write for !ISREG Pavel Begunkov
2021-03-22  1:58 ` Pavel Begunkov [this message]
2021-03-22  1:58 ` [PATCH 10/11] io_uring: hide iter revert in resubmit_prep Pavel Begunkov
2021-03-22  1:58 ` [PATCH 11/11] io_uring: optimise rw complete error handling Pavel Begunkov
2021-03-22  2:00 ` [PATCH 5.13 00/11] yet another series of random 5.13 patches Pavel Begunkov
2021-03-22 13:49 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1151b9a8f5a7aee8c93b4c20e7a68f8f22913db2.1616378197.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox