diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2025-03-27 15:02:20 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2025-03-28 16:15:42 -0600 |
commit | 04491732fc996305e1de80255d64ed6d1c472df5 (patch) | |
tree | 59964d331ca4711e57ccef3d82ea4fdb79b13c75 /io_uring | |
parent | eff5f16bfd87ae48c56751741af41a825d5d4618 (diff) |
io_uring/net: account memory for zc sendmsg
Account pinned pages for IORING_OP_SENDMSG_ZC, just as we for
IORING_OP_SEND_ZC and net/ does for MSG_ZEROCOPY.
Fixes: 493108d95f146 ("io_uring/net: zerocopy sendmsg")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/4f00f67ca6ac8e8ed62343ae92b5816b1e0c9c4b.1743086313.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/net.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/io_uring/net.c b/io_uring/net.c index 8944eb679024..228b4f13d34c 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1303,6 +1303,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) struct io_sr_msg *zc = io_kiocb_to_cmd(req, struct io_sr_msg); struct io_ring_ctx *ctx = req->ctx; struct io_kiocb *notif; + int ret; zc->done_io = 0; zc->retry = false; @@ -1355,7 +1356,16 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) req->flags |= REQ_F_IMPORT_BUFFER; return io_send_setup(req, sqe); } - return io_sendmsg_zc_setup(req, sqe); + ret = io_sendmsg_zc_setup(req, sqe); + if (unlikely(ret)) + return ret; + + if (!(zc->flags & IORING_RECVSEND_FIXED_BUF)) { + struct io_async_msghdr *iomsg = req->async_data; + + return io_notif_account_mem(zc->notif, iomsg->msg.msg_iter.count); + } + return 0; } static int io_sg_from_iter_iovec(struct sk_buff *skb, |