Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/net: unify sendmsg setup with zc

io_sendmsg_zc_setup() duplicates parts of io_sendmsg_setup(), and the
only difference between them is that the former support vectored
registered buffers with nothing zerocopy specific. Merge them together,
we want regular sendmsg to eventually support fixed buffers either way.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/7e5ec40f9dc93355399dc6fa0cbc8b31f0b20ac5.1743202294.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
63b16e4f c55e2845

+6 -22
+6 -22
io_uring/net.c
··· 377 377 /* save msg_control as sys_sendmsg() overwrites it */ 378 378 sr->msg_control = kmsg->msg.msg_control_user; 379 379 380 + if (sr->flags & IORING_RECVSEND_FIXED_BUF) { 381 + kmsg->msg.msg_iter.nr_segs = msg.msg_iovlen; 382 + return io_prep_reg_iovec(req, &kmsg->vec, msg.msg_iov, 383 + msg.msg_iovlen); 384 + } 380 385 if (req->flags & REQ_F_BUFFER_SELECT) 381 386 return 0; 382 387 return io_net_import_vec(req, kmsg, msg.msg_iov, msg.msg_iovlen, ITER_SOURCE); 383 - } 384 - 385 - static int io_sendmsg_zc_setup(struct io_kiocb *req, const struct io_uring_sqe *sqe) 386 - { 387 - struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); 388 - struct io_async_msghdr *kmsg = req->async_data; 389 - struct user_msghdr msg; 390 - int ret; 391 - 392 - if (!(sr->flags & IORING_RECVSEND_FIXED_BUF)) 393 - return io_sendmsg_setup(req, sqe); 394 - 395 - sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr)); 396 - 397 - ret = io_msg_copy_hdr(req, kmsg, &msg, ITER_SOURCE, NULL); 398 - if (unlikely(ret)) 399 - return ret; 400 - sr->msg_control = kmsg->msg.msg_control_user; 401 - kmsg->msg.msg_iter.nr_segs = msg.msg_iovlen; 402 - 403 - return io_prep_reg_iovec(req, &kmsg->vec, msg.msg_iov, msg.msg_iovlen); 404 388 } 405 389 406 390 #define SENDMSG_FLAGS (IORING_RECVSEND_POLL_FIRST | IORING_RECVSEND_BUNDLE) ··· 1323 1339 req->flags |= REQ_F_IMPORT_BUFFER; 1324 1340 return io_send_setup(req, sqe); 1325 1341 } 1326 - ret = io_sendmsg_zc_setup(req, sqe); 1342 + ret = io_sendmsg_setup(req, sqe); 1327 1343 if (unlikely(ret)) 1328 1344 return ret; 1329 1345