Skip to content

Commit 0449173

Browse files
isilenceaxboe
authored andcommitted
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: 493108d ("io_uring/net: zerocopy sendmsg") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/4f00f67ca6ac8e8ed62343ae92b5816b1e0c9c4b.1743086313.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent eff5f16 commit 0449173

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

io_uring/net.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13031303
struct io_sr_msg *zc = io_kiocb_to_cmd(req, struct io_sr_msg);
13041304
struct io_ring_ctx *ctx = req->ctx;
13051305
struct io_kiocb *notif;
1306+
int ret;
13061307

13071308
zc->done_io = 0;
13081309
zc->retry = false;
@@ -1355,7 +1356,16 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13551356
req->flags |= REQ_F_IMPORT_BUFFER;
13561357
return io_send_setup(req, sqe);
13571358
}
1358-
return io_sendmsg_zc_setup(req, sqe);
1359+
ret = io_sendmsg_zc_setup(req, sqe);
1360+
if (unlikely(ret))
1361+
return ret;
1362+
1363+
if (!(zc->flags & IORING_RECVSEND_FIXED_BUF)) {
1364+
struct io_async_msghdr *iomsg = req->async_data;
1365+
1366+
return io_notif_account_mem(zc->notif, iomsg->msg.msg_iter.count);
1367+
}
1368+
return 0;
13591369
}
13601370

13611371
static int io_sg_from_iter_iovec(struct sk_buff *skb,

0 commit comments

Comments
 (0)