public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 6/6] io_uring: simplify do_read return parsing
Date: Mon,  1 Feb 2021 18:59:56 +0000	[thread overview]
Message-ID: <65b7ccb995f13ac76af6790d2f22c977ec5effc8.1612205713.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

do_read() returning 0 bytes read (not -EAGAIN/etc.) is too important of
a case to prioritise it. Fold it into ret<0 check, so we get rid of an
extra if and make it a bit more readable.

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

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6834379c208b..6580efeaa18a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3526,7 +3526,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 	else
 		kiocb->ki_flags |= IOCB_NOWAIT;
 
-
 	/* If the file doesn't support async, just async punt */
 	no_async = force_nonblock && !io_file_supports_async(req->file, READ);
 	if (no_async)
@@ -3538,9 +3537,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 
 	ret = io_iter_do_read(req, iter);
 
-	if (!ret) {
-		goto done;
-	} else if (ret == -EIOCBQUEUED) {
+	if (ret == -EIOCBQUEUED) {
 		ret = 0;
 		goto out_free;
 	} else if (ret == -EAGAIN) {
@@ -3554,7 +3551,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 		iov_iter_revert(iter, io_size - iov_iter_count(iter));
 		ret = 0;
 		goto copy_iov;
-	} else if (ret < 0) {
+	} else if (ret <= 0) {
 		/* make sure -ERESTARTSYS -> -EINTR is done */
 		goto done;
 	}
-- 
2.24.0


  parent reply	other threads:[~2021-02-01 19:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 18:59 [PATCH 0/6] for-5.12 stuff Pavel Begunkov
2021-02-01 18:59 ` [PATCH 1/6] io_uring: fix inconsistent lock state Pavel Begunkov
2021-02-01 18:59 ` [PATCH 2/6] io_uring: kill not used needs_file_no_error Pavel Begunkov
2021-02-01 18:59 ` [PATCH 3/6] io_uring: inline io_req_drop_files() Pavel Begunkov
2021-02-01 18:59 ` [PATCH 4/6] io_uring: remove work flags after cleanup Pavel Begunkov
2021-02-01 18:59 ` [PATCH 5/6] io_uring: deduplicate adding to REQ_F_INFLIGHT Pavel Begunkov
2021-02-01 18:59 ` Pavel Begunkov [this message]
2021-02-01 20:11 ` [PATCH 0/6] for-5.12 stuff 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=65b7ccb995f13ac76af6790d2f22c977ec5effc8.1612205713.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