From f80a50a632d6f5c64729563892b0deb95d563f6d Mon Sep 17 00:00:00 2001
From: Pavel Begunkov <asml.silence@gmail.com>
Date: Thu, 14 Oct 2021 16:10:13 +0100
Subject: [PATCH] io_uring: prioritise read success path over fails
Git-commit: f80a50a632d6f5c64729563892b0deb95d563f6d
Patch-mainline: v5.16-rc1
References: bsc#1205205
Rearrange io_read return handling so first we expect it completing
successfully and only then checking for errors, which is a colder path.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/c91c7c2da11815ec8b04b5d872f60dc4cde662c5.1634144845.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
fs/io_uring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 094cd5f49214..86ef803db27a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3487,7 +3487,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
ret = 0;
} else if (ret == -EIOCBQUEUED) {
goto out_free;
- } else if (ret <= 0 || ret == req->result || !force_nonblock ||
+ } else if (ret == req->result || ret <= 0 || !force_nonblock ||
(req->flags & REQ_F_NOWAIT) || !need_read_all(req)) {
/* read all, failed, already did sync or don't want to retry */
goto done;
--
2.35.3