All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Subject: [PATCH] io_uring: fail negative results for multishot issue too
Date: Sat, 14 Nov 2026 11:17:52 -0700	[thread overview]
Message-ID: <e357bc47-4e22-4103-a31e-8b66395338de@kernel.dk> (raw)

Multishot retries are issued through io_poll_issue(), which doesn't
share the IOU_COMPLETE handling in io_issue_sqe(). Move failing of
negative results and the restart code fixup to a helper and use it for
both, and drop the open-coded versions from the accept, multishot read,
and uring_cmd handlers.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index be5a4f9505e0..eba8132d6823 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1526,6 +1526,19 @@ static inline int __io_issue_sqe(struct io_kiocb *req,
 	return ret;
 }
 
+static noinline void __io_req_fail_on_error(struct io_kiocb *req)
+{
+	req->cqe.res = io_fixup_restart_res(req->cqe.res);
+	req_set_fail(req);
+}
+
+/* Fail requests completing with an error, and fix up restart codes */
+static inline void io_req_fail_on_error(struct io_kiocb *req)
+{
+	if (unlikely(req->cqe.res < 0))
+		__io_req_fail_on_error(req);
+}
+
 static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
 {
 	const struct io_issue_def *def = &io_issue_defs[req->opcode];
@@ -1537,11 +1550,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
 	ret = __io_issue_sqe(req, issue_flags, def);
 
 	if (ret == IOU_COMPLETE) {
-		if (unlikely(req->cqe.res < 0)) {
-			if (req->cqe.res <= -ERESTARTSYS)
-				req->cqe.res = io_fixup_restart_res(req->cqe.res);
-			req_set_fail(req);
-		}
+		io_req_fail_on_error(req);
 		if (issue_flags & IO_URING_F_COMPLETE_DEFER)
 			io_req_complete_defer(req);
 		else
@@ -1575,6 +1584,8 @@ int io_poll_issue(struct io_kiocb *req, io_tw_token_t tw)
 		return -EFAULT;
 
 	ret = __io_issue_sqe(req, issue_flags, &io_issue_defs[req->opcode]);
+	if (ret == IOU_COMPLETE)
+		io_req_fail_on_error(req);
 
 	WARN_ON_ONCE(ret == IOU_ISSUE_SKIP_COMPLETE);
 	return ret;
diff --git a/io_uring/net.c b/io_uring/net.c
index 04927fa5d242..cca940b36759 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1727,8 +1727,6 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
 	}
 
 	io_req_set_res(req, ret, cflags);
-	if (ret < 0)
-		req_set_fail(req);
 	return IOU_COMPLETE;
 }
 
diff --git a/io_uring/rw.c b/io_uring/rw.c
index e3a752225dbb..f6849c5ec64a 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -1057,10 +1057,6 @@ 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) {
-			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 {
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index ba2d8c9028eb..4706cf61d37e 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -262,8 +262,6 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
 	}
 	if (ret == -EIOCBQUEUED)
 		return ret;
-	if (ret < 0)
-		req_set_fail(req);
 	io_req_uring_cleanup(req, issue_flags);
 	io_req_set_res(req, ret, 0);
 	return IOU_COMPLETE;

-- 
Jens Axboe


                 reply	other threads:[~2026-11-14 18:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e357bc47-4e22-4103-a31e-8b66395338de@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.