From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH v4 6/9] io_uring/net: pull vec alloc out of msghdr import
Date: Fri,  7 Mar 2025 16:00:34 +0000	[thread overview]
Message-ID: <9600ea6300f620e65d39da481c22605ddc898850.1741362889.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1741362889.git.asml.silence@gmail.com>

I'll need more control over iovec management, move
io_net_import_vec() out of io_msg_copy_hdr().

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/net.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index 33076bd22c16..cbb889b85cfc 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -253,12 +253,8 @@ static int io_compat_msg_copy_hdr(struct io_kiocb *req,
 				return -EFAULT;
 			sr->len = tmp_iov.iov_len;
 		}
-
-		return 0;
 	}
-
-	return io_net_import_vec(req, iomsg, (struct iovec __user *)uiov,
-				 msg->msg_iovlen, ddir);
+	return 0;
 }
 
 static int io_copy_msghdr_from_user(struct user_msghdr *msg,
@@ -328,10 +324,8 @@ static int io_msg_copy_hdr(struct io_kiocb *req, struct io_async_msghdr *iomsg,
 				return -EFAULT;
 			sr->len = tmp_iov.iov_len;
 		}
-		return 0;
 	}
-
-	return io_net_import_vec(req, iomsg, msg->msg_iov, msg->msg_iovlen, ddir);
+	return 0;
 }
 
 static int io_sendmsg_copy_hdr(struct io_kiocb *req,
@@ -342,6 +336,12 @@ static int io_sendmsg_copy_hdr(struct io_kiocb *req,
 	int ret;
 
 	ret = io_msg_copy_hdr(req, iomsg, &msg, ITER_SOURCE, NULL);
+	if (unlikely(ret))
+		return ret;
+
+	if (!(req->flags & REQ_F_BUFFER_SELECT))
+		ret = io_net_import_vec(req, iomsg, msg.msg_iov, msg.msg_iovlen,
+					ITER_SOURCE);
 	/* save msg_control as sys_sendmsg() overwrites it */
 	sr->msg_control = iomsg->msg.msg_control_user;
 	return ret;
@@ -719,6 +719,13 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req,
 	ret = io_msg_copy_hdr(req, iomsg, &msg, ITER_DEST, &iomsg->uaddr);
 	if (unlikely(ret))
 		return ret;
+
+	if (!(req->flags & REQ_F_BUFFER_SELECT)) {
+		ret = io_net_import_vec(req, iomsg, msg.msg_iov, msg.msg_iovlen,
+					ITER_DEST);
+		if (unlikely(ret))
+			return ret;
+	}
 	return io_recvmsg_mshot_prep(req, iomsg, msg.msg_namelen,
 					msg.msg_controllen);
 }
-- 
2.48.1


  parent reply	other threads:[~2025-03-07 15:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 16:00 [PATCH v4 0/9] Add support for vectored registered buffers Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 1/9] io_uring: introduce struct iou_vec Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 2/9] io_uring: add infra for importing vectored reg buffers Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 3/9] io_uring/rw: implement vectored registered rw Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 4/9] io_uring/rw: defer reg buf vec import Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 5/9] io_uring/net: combine msghdr copy Pavel Begunkov
2025-03-07 16:00 ` Pavel Begunkov [this message]
2025-03-07 16:00 ` [PATCH v4 7/9] io_uring/net: convert to struct iou_vec Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 8/9] io_uring/net: implement vectored reg bufs for zctx Pavel Begunkov
2025-03-07 16:00 ` [PATCH v4 9/9] io_uring: cap cached iovec/bvec size Pavel Begunkov
2025-03-07 16:40 ` [PATCH v4 0/9] Add support for vectored registered buffers 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=9600ea6300f620e65d39da481c22605ddc898850.1741362889.git.asml.silence@gmail.com \
    --to=asml.silence@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 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.