mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-20 22:15:59 +00:00
io_uring/net: improve zc addr import error handling
We may account memory to a memcg of a request that didn't even got to the network layer. It's not a bug as it'll be routinely cleaned up on flush, but it might be confusing for the userspace. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/b8aae61f4c3ddc4da97c1da876bb73871f352d50.1660566179.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
063604265f
commit
86dc8f23bb
1 changed files with 8 additions and 8 deletions
|
@ -977,6 +977,14 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
msg.msg_controllen = 0;
|
msg.msg_controllen = 0;
|
||||||
msg.msg_namelen = 0;
|
msg.msg_namelen = 0;
|
||||||
|
|
||||||
|
if (zc->addr) {
|
||||||
|
ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
|
||||||
|
if (unlikely(ret < 0))
|
||||||
|
return ret;
|
||||||
|
msg.msg_name = (struct sockaddr *)&address;
|
||||||
|
msg.msg_namelen = zc->addr_len;
|
||||||
|
}
|
||||||
|
|
||||||
if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
|
if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
|
||||||
ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
|
ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
|
||||||
(u64)(uintptr_t)zc->buf, zc->len);
|
(u64)(uintptr_t)zc->buf, zc->len);
|
||||||
|
@ -992,14 +1000,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zc->addr) {
|
|
||||||
ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
|
|
||||||
if (unlikely(ret < 0))
|
|
||||||
return ret;
|
|
||||||
msg.msg_name = (struct sockaddr *)&address;
|
|
||||||
msg.msg_namelen = zc->addr_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_flags = zc->msg_flags | MSG_ZEROCOPY;
|
msg_flags = zc->msg_flags | MSG_ZEROCOPY;
|
||||||
if (issue_flags & IO_URING_F_NONBLOCK)
|
if (issue_flags & IO_URING_F_NONBLOCK)
|
||||||
msg_flags |= MSG_DONTWAIT;
|
msg_flags |= MSG_DONTWAIT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue