Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torvalds/linux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Yudaken <dylany@fb.com>2022-06-30 12:12:23 +0300
committerJens Axboe <axboe@kernel.dk>2022-07-25 03:39:16 +0300
commitd4e097dae29c24bf33a5056a2a43cff2e45c4978 (patch)
treef7d41b67c60f1670d70149802b7b8a6a2d271299 /io_uring/net.c
parent5702196e7d9d1232c41769e197eb33ba78a9b463 (diff)
io_uring: recycle buffers on error
Rather than passing an error back to the user with a buffer attached, recycle the buffer immediately. Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220630091231.1456789-5-dylany@fb.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/net.c')
-rw-r--r--io_uring/net.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/io_uring/net.c b/io_uring/net.c
index 06eaef9f97be..e4422dff0704 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -481,10 +481,13 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
if (kmsg->free_iov)
kfree(kmsg->free_iov);
req->flags &= ~REQ_F_NEED_CLEANUP;
- if (ret >= 0)
+ if (ret > 0)
ret += sr->done_io;
else if (sr->done_io)
ret = sr->done_io;
+ else
+ io_kbuf_recycle(req, issue_flags);
+
cflags = io_put_kbuf(req, issue_flags);
if (kmsg->msg.msg_inq)
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
@@ -557,10 +560,13 @@ out_free:
req_set_fail(req);
}
- if (ret >= 0)
+ if (ret > 0)
ret += sr->done_io;
else if (sr->done_io)
ret = sr->done_io;
+ else
+ io_kbuf_recycle(req, issue_flags);
+
cflags = io_put_kbuf(req, issue_flags);
if (msg.msg_inq)
cflags |= IORING_CQE_F_SOCK_NONEMPTY;