diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2025-03-08 18:21:15 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2025-03-10 07:14:27 -0600 |
commit | d291fb65202051e996cd983b29dce3e390421bc6 (patch) | |
tree | b123bfa5630d496b8699cd4e499d7f2f8d67b9fb /io_uring/net.c | |
parent | 5027d02452c982bdc7b36205c66466ebd7e6ee17 (diff) |
io_uring: introduce io_prep_reg_iovec()
iovecs that are turned into registered buffers are imported in a special
way with an offset, so that later we can do an in place translation. Add
a helper function taking care of it.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/7de2ecb9ed5efc3c5cf320232236966da5ad4ccc.1741457480.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/net.c')
-rw-r--r-- | io_uring/net.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/io_uring/net.c b/io_uring/net.c index 9fa5c9570875..6b8dbadf445f 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -403,9 +403,7 @@ static int io_sendmsg_zc_setup(struct io_kiocb *req, const struct io_uring_sqe * struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); struct io_async_msghdr *kmsg = req->async_data; struct user_msghdr msg; - int ret, iovec_off; - struct iovec *iov; - void *res; + int ret; if (!(sr->flags & IORING_RECVSEND_FIXED_BUF)) return io_sendmsg_setup(req, sqe); @@ -416,24 +414,9 @@ static int io_sendmsg_zc_setup(struct io_kiocb *req, const struct io_uring_sqe * if (unlikely(ret)) return ret; sr->msg_control = kmsg->msg.msg_control_user; - - if (msg.msg_iovlen > kmsg->vec.nr || WARN_ON_ONCE(!kmsg->vec.iovec)) { - ret = io_vec_realloc(&kmsg->vec, msg.msg_iovlen); - if (ret) - return ret; - req->flags |= REQ_F_NEED_CLEANUP; - } - iovec_off = kmsg->vec.nr - msg.msg_iovlen; - iov = kmsg->vec.iovec + iovec_off; - - res = iovec_from_user(msg.msg_iov, msg.msg_iovlen, kmsg->vec.nr, iov, - io_is_compat(req->ctx)); - if (IS_ERR(res)) - return PTR_ERR(res); - kmsg->msg.msg_iter.nr_segs = msg.msg_iovlen; - req->flags |= REQ_F_IMPORT_BUFFER; - return ret; + + return io_prep_reg_iovec(req, &kmsg->vec, msg.msg_iov, msg.msg_iovlen); } #define SENDMSG_FLAGS (IORING_RECVSEND_POLL_FIRST | IORING_RECVSEND_BUNDLE) |