From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Subject: [PATCH] io_uring: remove handler-local failing of negative results
Date: Sat, 14 Nov 2026 11:17:05 -0700 [thread overview]
Message-ID: <9efbf0e0-4654-45a9-87e2-1c8bba6016f0@kernel.dk> (raw)
io_issue_sqe() now marks a request as failed if it completes with
IOU_COMPLETE and a negative result. Drop the open-coded versions of
that from the issue handlers.
Handlers that fail a request on something other than a negative result,
may be issued through io_poll_issue() for multishot, or complete through
task_work are left alone.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff --git a/io_uring/advise.c b/io_uring/advise.c
index 0073f74e3658..167abea23457 100644
--- a/io_uring/advise.c
+++ b/io_uring/advise.c
@@ -101,8 +101,6 @@ int io_fadvise(struct io_kiocb *req, unsigned int issue_flags)
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK && io_fadvise_force_async(fa));
ret = vfs_fadvise(req->file, fa->offset, fa->len, fa->advice);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/cancel.c b/io_uring/cancel.c
index e3d9fe8fc982..057dfad46244 100644
--- a/io_uring/cancel.c
+++ b/io_uring/cancel.c
@@ -262,8 +262,6 @@ int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags)
ret = __io_async_cancel(&cd, tctx, issue_flags);
done:
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/epoll.c b/io_uring/epoll.c
index b9db8bde27ec..4fb04d4b9136 100644
--- a/io_uring/epoll.c
+++ b/io_uring/epoll.c
@@ -69,8 +69,6 @@ int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags)
if (force_nonblock && ret == -EAGAIN)
return -EAGAIN;
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
@@ -95,8 +93,6 @@ int io_epoll_wait(struct io_kiocb *req, unsigned int issue_flags)
ret = epoll_sendevents(req->file, iew->events, iew->maxevents);
if (ret == 0)
return -EAGAIN;
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
diff --git a/io_uring/futex.c b/io_uring/futex.c
index 792d37968efc..2d36d6afb9d6 100644
--- a/io_uring/futex.c
+++ b/io_uring/futex.c
@@ -272,12 +272,9 @@ int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags)
ret = futex_wait_multiple_setup(ifd->futexv, iof->futex_nr, &woken);
- /*
- * Error case, ret is < 0. Mark the request as failed.
- */
+ /* Error case, the core marks the request as failed */
if (unlikely(ret < 0)) {
io_ring_submit_unlock(ctx, issue_flags);
- req_set_fail(req);
io_req_set_res(req, ret, 0);
io_req_async_data_free(req);
return IOU_COMPLETE;
@@ -358,8 +355,6 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
done_unlock:
io_ring_submit_unlock(ctx, issue_flags);
done:
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
@@ -375,8 +370,6 @@ int io_futex_wake(struct io_kiocb *req, unsigned int issue_flags)
*/
ret = futex_wake(iof->uaddr, FLAGS_STRICT | iof->futex_flags, NULL,
iof->futex_val, iof->futex_mask);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index abf44f5dba26..6d35fcd45f2b 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -623,8 +623,6 @@ int io_manage_buffers_legacy(struct io_kiocb *req, unsigned int issue_flags)
ret = __io_manage_buffers_legacy(req, bl);
io_ring_submit_unlock(ctx, issue_flags);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index 3067c9343991..3b2192cfac05 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -323,11 +323,8 @@ int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
}
done:
- if (ret < 0) {
- if (ret == -EAGAIN || ret == IOU_ISSUE_SKIP_COMPLETE)
- return ret;
- req_set_fail(req);
- }
+ if (ret == -EAGAIN || ret == IOU_ISSUE_SKIP_COMPLETE)
+ return ret;
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/net.c b/io_uring/net.c
index 183425f28b0c..04927fa5d242 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1824,7 +1824,6 @@ int io_socket(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
if (ret == -ERESTARTSYS)
ret = -EINTR;
- req_set_fail(req);
} else if (!fixed) {
fd_install(fd, file);
ret = fd;
@@ -1910,8 +1909,6 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
if (ret == -ERESTARTSYS)
ret = -EINTR;
out:
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
@@ -1970,10 +1967,8 @@ int io_bind(struct io_kiocb *req, unsigned int issue_flags)
return -ENOTSOCK;
ret = __sys_bind_socket(sock, addr, bind->addr_len);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
- return 0;
+ return IOU_COMPLETE;
}
int io_listen_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
@@ -1998,10 +1993,8 @@ int io_listen(struct io_kiocb *req, unsigned int issue_flags)
return -ENOTSOCK;
ret = __sys_listen_socket(sock, listen->backlog);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
- return 0;
+ return IOU_COMPLETE;
}
void io_netmsg_cache_free(const void *entry)
diff --git a/io_uring/openclose.c b/io_uring/openclose.c
index 24cf3ce2e2bc..71e45fc00abd 100644
--- a/io_uring/openclose.c
+++ b/io_uring/openclose.c
@@ -179,8 +179,6 @@ int io_openat2(struct io_kiocb *req, unsigned int issue_flags)
open->file_slot);
err:
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
@@ -266,8 +264,6 @@ int io_close(struct io_kiocb *req, unsigned int issue_flags)
/* No ->flush() or already async, safely close from here */
ret = filp_close(file, current->files);
err:
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
@@ -309,8 +305,6 @@ int io_install_fixed_fd(struct io_kiocb *req, unsigned int issue_flags)
ifi = io_kiocb_to_cmd(req, struct io_fixed_install);
ret = receive_fd(req->file, NULL, ifi->o_flags);
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 07813d45a1d4..6dc0325b155b 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -641,8 +641,6 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
io_ring_submit_unlock(ctx, issue_flags);
}
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/timeout.c b/io_uring/timeout.c
index fa54846ed4ce..47446900f63e 100644
--- a/io_uring/timeout.c
+++ b/io_uring/timeout.c
@@ -591,8 +591,6 @@ int io_timeout_remove(struct io_kiocb *req, unsigned int issue_flags)
raw_spin_unlock_irq(&ctx->timeout_lock);
}
- if (ret < 0)
- req_set_fail(req);
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
diff --git a/io_uring/waitid.c b/io_uring/waitid.c
index 0d3c248f375c..6e3c397296da 100644
--- a/io_uring/waitid.c
+++ b/io_uring/waitid.c
@@ -376,8 +376,6 @@ int io_waitid(struct io_kiocb *req, unsigned int issue_flags)
io_ring_submit_unlock(ctx, issue_flags);
done:
- if (ret < 0)
- req_set_fail(req);
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=9efbf0e0-4654-45a9-87e2-1c8bba6016f0@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox