diff mbox series

[3/3] io_uring/net: add IORING_SEND_IGNORE_INLINE support to zerocopy send

Message ID 20241014205416.456078-4-axboe@kernel.dk (mailing list archive)
State New
Headers show
Series Add ability to ignore inline completions | expand

Commit Message

Jens Axboe Oct. 14, 2024, 8:49 p.m. UTC
If IORING_SEND_IGNORE_INLINE is set for a send zerocopy request, then a
successful inline completion of such a request will be ignored for a
submit_and_wait() type of submissions. In other words, if an application
submits a send for socketA with a recv for socketB, it can now do:

io_uring_submit_and_wait(ring, 1);

and have the inline send completion be ignored from the number of items
to wait for. Note that this only applies to the direct zerocopy send
completion, it does not include the notification when it's safe to reuse
the buffer. Those happen out-of-line anyway.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 io_uring/net.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/io_uring/net.c b/io_uring/net.c
index 11ff58a5c145..79f980182a10 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1223,7 +1223,8 @@  void io_send_zc_cleanup(struct io_kiocb *req)
 }
 
 #define IO_ZC_FLAGS_COMMON (IORING_RECVSEND_POLL_FIRST | IORING_RECVSEND_FIXED_BUF)
-#define IO_ZC_FLAGS_VALID  (IO_ZC_FLAGS_COMMON | IORING_SEND_ZC_REPORT_USAGE)
+#define IO_ZC_FLAGS_VALID  (IO_ZC_FLAGS_COMMON | IORING_SEND_ZC_REPORT_USAGE | \
+				IORING_SEND_IGNORE_INLINE)
 
 int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
@@ -1259,6 +1260,8 @@  int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 			nd->zc_used = false;
 			nd->zc_copied = false;
 		}
+		if (zc->flags & IORING_SEND_IGNORE_INLINE)
+			req->flags |= REQ_F_IGNORE_INLINE;
 	}
 
 	if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
@@ -1406,6 +1409,8 @@  int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
 	ret = sock_sendmsg(sock, &kmsg->msg);
 
 	if (unlikely(ret < min_ret)) {
+		req->flags &= ~REQ_F_IGNORE_INLINE;
+
 		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
 			return -EAGAIN;