From: Yitang Yang <yi1tang.yang@gmail.com>
To: axboe@kernel.dk
Cc: krisman@suse.de, io-uring@vger.kernel.org,
Yitang Yang <yi1tang.yang@gmail.com>
Subject: [PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths
Date: Mon, 20 Jul 2026 19:41:16 +0800 [thread overview]
Message-ID: <20260720114116.21830-1-yi1tang.yang@gmail.com> (raw)
Both read and write may receive internal restart error codes from
the filesystem layer and should be converted to -EINTR. However,
when multishot read support was added, the error code normalization
was lost for both io_read() and io_read_mshot().
Extract the conversion into io_fixup_restart_res() and apply it
in all three locations: io_rw_done(), io_read(), and io_read_mshot().
Fixes: a08d195b586a ("io_uring/rw: split io_read() into a helper")
Signed-off-by: Yitang Yang <yi1tang.yang@gmail.com>
---
io_uring/rw.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 63b6519e498c..e505479e3773 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -615,6 +615,24 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
smp_store_release(&req->iopoll_completed, 1);
}
+static inline ssize_t io_fixup_restart_res(ssize_t ret)
+{
+ switch (ret) {
+ case -ERESTARTSYS:
+ case -ERESTARTNOINTR:
+ case -ERESTARTNOHAND:
+ case -ERESTART_RESTARTBLOCK:
+ /*
+ * We can't just restart the syscall, since previously
+ * submitted sqes may already be in progress. Just fail
+ * this IO with EINTR.
+ */
+ return -EINTR;
+ default:
+ return ret;
+ }
+}
+
static inline void io_rw_done(struct io_kiocb *req, ssize_t ret)
{
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
@@ -625,19 +643,7 @@ static inline void io_rw_done(struct io_kiocb *req, ssize_t ret)
/* transform internal restart error codes */
if (unlikely(ret < 0)) {
- switch (ret) {
- case -ERESTARTSYS:
- case -ERESTARTNOINTR:
- case -ERESTARTNOHAND:
- case -ERESTART_RESTARTBLOCK:
- /*
- * We can't just restart the syscall, since previously
- * submitted sqes may already be in progress. Just fail
- * this IO with EINTR.
- */
- ret = -EINTR;
- break;
- }
+ ret = io_fixup_restart_res(ret);
}
if (req->flags & REQ_F_IOPOLL)
@@ -1034,6 +1040,8 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
if (req->flags & REQ_F_BUFFERS_COMMIT)
io_kbuf_recycle(req, sel.buf_list, issue_flags);
+
+ ret = io_fixup_restart_res(ret);
return ret;
}
@@ -1068,8 +1076,10 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
return IOU_RETRY;
} else if (ret <= 0) {
io_kbuf_recycle(req, sel.buf_list, issue_flags);
- if (ret < 0)
+ if (ret < 0) {
+ ret = io_fixup_restart_res(ret);
req_set_fail(req);
+ }
} else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
cflags = io_put_kbuf(req, ret, sel.buf_list);
} else {
--
2.43.0
next reply other threads:[~2026-07-20 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 11:41 Yitang Yang [this message]
2026-07-21 16:32 ` [PATCH] io_uring/rw: fix missing ERESTARTSYS conversion in read paths Jens Axboe
2026-07-22 3:08 ` Yitang Yang
2026-07-22 10:28 ` Jens Axboe
2026-07-22 10:32 ` Jens Axboe
2026-07-22 12:36 ` Yitang Yang
2026-07-22 13:37 ` Jens Axboe
2026-07-23 12:46 ` [PATCH liburing] test: add rw-restart-ret regression test Yitang Yang
2026-07-22 12:45 ` [PATCH v2] io_uring/rw: fix missing ERESTARTSYS conversion in read paths Yitang Yang
2026-07-22 13:37 ` 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=20260720114116.21830-1-yi1tang.yang@gmail.com \
--to=yi1tang.yang@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=krisman@suse.de \
/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