public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH v2 09/13] io_uring: highlight read-retry loop
Date: Thu,  4 Feb 2021 13:52:04 +0000	[thread overview]
Message-ID: <18608b73f7f9810a974bf518c07afa4701fdfa17.1612446019.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

We already have implicit do-while for read-retries but with goto in the
end. Convert it to an actual do-while, it highlights it so making a
bit more understandable and is cleaner in general.

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

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 35ad889afaec..bbf8ea8370d6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3566,27 +3566,27 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 	rw = req->async_data;
 	/* now use our persistent iterator, if we aren't already */
 	iter = &rw->iter;
-retry:
-	io_size -= ret;
-	rw->bytes_done += ret;
-	/* if we can retry, do so with the callbacks armed */
-	if (!io_rw_should_retry(req)) {
-		kiocb->ki_flags &= ~IOCB_WAITQ;
-		return -EAGAIN;
-	}
 
-	/*
-	 * Now retry read with the IOCB_WAITQ parts set in the iocb. If we
-	 * get -EIOCBQUEUED, then we'll get a notification when the desired
-	 * page gets unlocked. We can also get a partial read here, and if we
-	 * do, then just retry at the new offset.
-	 */
-	ret = io_iter_do_read(req, iter);
-	if (ret == -EIOCBQUEUED)
-		return 0;
-	/* we got some bytes, but not all. retry. */
-	if (ret > 0 && ret < io_size)
-		goto retry;
+	do {
+		io_size -= ret;
+		rw->bytes_done += ret;
+		/* if we can retry, do so with the callbacks armed */
+		if (!io_rw_should_retry(req)) {
+			kiocb->ki_flags &= ~IOCB_WAITQ;
+			return -EAGAIN;
+		}
+
+		/*
+		 * Now retry read with the IOCB_WAITQ parts set in the iocb. If
+		 * we get -EIOCBQUEUED, then we'll get a notification when the
+		 * desired page gets unlocked. We can also get a partial read
+		 * here, and if we do, then just retry at the new offset.
+		 */
+		ret = io_iter_do_read(req, iter);
+		if (ret == -EIOCBQUEUED)
+			return 0;
+		/* we got some bytes, but not all. retry. */
+	} while (ret > 0 && ret < io_size);
 done:
 	kiocb_done(kiocb, ret, cs);
 	return 0;
-- 
2.24.0


  parent reply	other threads:[~2021-02-04 13:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 13:51 [PATCH v2 5.12 00/13] a second pack of 5.12 cleanups Pavel Begunkov
2021-02-04 13:51 ` [PATCH v2 01/13] io_uring: deduplicate core cancellations sequence Pavel Begunkov
2021-02-04 13:51 ` [PATCH v2 02/13] io_uring: refactor scheduling in io_cqring_wait Pavel Begunkov
2021-02-04 13:51 ` [PATCH v2 03/13] io_uring: refactor io_cqring_wait Pavel Begunkov
2021-02-04 13:51 ` [PATCH v2 04/13] io_uring: refactor io_read for unsupported nowait Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 05/13] io_uring: further simplify do_read error parsing Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 06/13] io_uring: let io_setup_async_rw take care of iovec Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 07/13] io_uring: don't forget to adjust io_size Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 08/13] io_uring: inline io_read()'s iovec freeing Pavel Begunkov
2021-02-04 13:52 ` Pavel Begunkov [this message]
2021-02-04 13:52 ` [PATCH v2 10/13] io_uring: treat NONBLOCK and RWF_NOWAIT similarly Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 11/13] io_uring: io_import_iovec return type cleanup Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 12/13] io_uring: deduplicate file table slot calculation Pavel Begunkov
2021-02-04 13:52 ` [PATCH v2 13/13] io_uring/io-wq: return 2-step work swap scheme Pavel Begunkov
2021-02-04 14:52   ` Jens Axboe
2021-02-04 14:56     ` Pavel Begunkov
2021-02-04 15:05       ` Jens Axboe
2021-02-04 15:07 ` [PATCH v2 5.12 00/13] a second pack of 5.12 cleanups 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=18608b73f7f9810a974bf518c07afa4701fdfa17.1612446019.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