From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, axboe@kernel.dk,
Dylan Yudaken <dyudaken@gmail.com>
Subject: [PATCH 2/3] io_uring/zctx: move vec regbuf import into io_send_zc_import
Date: Mon, 16 Feb 2026 11:45:54 +0000 [thread overview]
Message-ID: <a2422664639e10375fc08e949a2ab0fd78d8df2a.1771240334.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1771240334.git.asml.silence@gmail.com>
Unify send and sendmsg zerocopy paths for importing registered buffers
and make io_send_zc_import() responsible for that. It's a preparation
patch making the next change simpler.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/net.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index 5f7f02e2c034..88962b18965e 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1439,17 +1439,34 @@ static int io_sg_from_iter(struct sk_buff *skb,
return ret;
}
-static int io_send_zc_import(struct io_kiocb *req, unsigned int issue_flags)
+static int io_send_zc_import(struct io_kiocb *req,
+ struct io_async_msghdr *kmsg,
+ unsigned int issue_flags)
{
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
- struct io_async_msghdr *kmsg = req->async_data;
+ struct io_kiocb *notif = sr->notif;
+ int ret;
WARN_ON_ONCE(!(sr->flags & IORING_RECVSEND_FIXED_BUF));
- sr->notif->buf_index = req->buf_index;
- return io_import_reg_buf(sr->notif, &kmsg->msg.msg_iter,
- (u64)(uintptr_t)sr->buf, sr->len,
- ITER_SOURCE, issue_flags);
+ notif->buf_index = req->buf_index;
+
+ if (req->opcode == IORING_OP_SEND_ZC) {
+ ret = io_import_reg_buf(notif, &kmsg->msg.msg_iter,
+ (u64)(uintptr_t)sr->buf, sr->len,
+ ITER_SOURCE, issue_flags);
+ } else {
+ unsigned uvec_segs = kmsg->msg.msg_iter.nr_segs;
+
+ ret = io_import_reg_vec(ITER_SOURCE, &kmsg->msg.msg_iter,
+ notif, &kmsg->vec, uvec_segs,
+ issue_flags);
+ }
+
+ if (unlikely(ret))
+ return ret;
+ req->flags &= ~REQ_F_IMPORT_BUFFER;
+ return 0;
}
int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
@@ -1471,8 +1488,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
if (req->flags & REQ_F_IMPORT_BUFFER) {
- req->flags &= ~REQ_F_IMPORT_BUFFER;
- ret = io_send_zc_import(req, issue_flags);
+ ret = io_send_zc_import(req, kmsg, issue_flags);
if (unlikely(ret))
return ret;
}
@@ -1528,16 +1544,9 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
int ret, min_ret = 0;
if (req->flags & REQ_F_IMPORT_BUFFER) {
- unsigned uvec_segs = kmsg->msg.msg_iter.nr_segs;
- int ret;
-
- sr->notif->buf_index = req->buf_index;
- ret = io_import_reg_vec(ITER_SOURCE, &kmsg->msg.msg_iter,
- sr->notif, &kmsg->vec, uvec_segs,
- issue_flags);
+ ret = io_send_zc_import(req, kmsg, issue_flags);
if (unlikely(ret))
return ret;
- req->flags &= ~REQ_F_IMPORT_BUFFER;
}
sock = sock_from_file(req->file);
--
2.52.0
next prev parent reply other threads:[~2026-02-16 11:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 11:45 [PATCH 0/3] deduplicate send and senmsg zc issue handlers Pavel Begunkov
2026-02-16 11:45 ` [PATCH 1/3] io_uring/zctx: rename flags var for more clarity Pavel Begunkov
2026-02-16 11:45 ` Pavel Begunkov [this message]
2026-02-16 11:45 ` [PATCH 3/3] io_uring/zctx: unify zerocopy issue variants Pavel Begunkov
2026-02-16 16:35 ` [PATCH 0/3] deduplicate send and senmsg zc issue handlers 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=a2422664639e10375fc08e949a2ab0fd78d8df2a.1771240334.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=dyudaken@gmail.com \
--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