summaryrefslogtreecommitdiff
path: root/io_uring/kbuf.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-02-05 11:36:48 +0000
committerJens Axboe <axboe@kernel.dk>2025-02-17 05:34:45 -0700
commit54e00d9a612ab93f37f612a5ccd7c0c4f8a31cea (patch)
tree6a9837cdf9c30ccee4e3345b26e9233c9cef3c4a /io_uring/kbuf.h
parente150e70fce425e1cdfc227974893cad9fb90a0d3 (diff)
downloadlwn-54e00d9a612ab93f37f612a5ccd7c0c4f8a31cea.tar.gz
lwn-54e00d9a612ab93f37f612a5ccd7c0c4f8a31cea.zip
io_uring/kbuf: introduce io_kbuf_drop_legacy()
io_kbuf_drop() is only used for legacy provided buffers, and so __io_put_kbuf_list() is never called for REQ_F_BUFFER_RING. Remove the dead branch out of __io_put_kbuf_list(), rename it into io_kbuf_drop_legacy() and use it directly instead of io_kbuf_drop(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/c8cc73e2272f09a86ecbdad9ebdd8304f8e583c0.1738724373.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/kbuf.h')
-rw-r--r--io_uring/kbuf.h24
1 files changed, 2 insertions, 22 deletions
diff --git a/io_uring/kbuf.h b/io_uring/kbuf.h
index 055b7a672f2e..3e18c916afc6 100644
--- a/io_uring/kbuf.h
+++ b/io_uring/kbuf.h
@@ -75,6 +75,7 @@ int io_unregister_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg);
int io_register_pbuf_status(struct io_ring_ctx *ctx, void __user *arg);
bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags);
+void io_kbuf_drop_legacy(struct io_kiocb *req);
struct io_mapped_region *io_pbuf_get_region(struct io_ring_ctx *ctx,
unsigned int bgid);
@@ -158,27 +159,6 @@ static inline bool __io_put_kbuf_ring(struct io_kiocb *req, int len, int nr)
return ret;
}
-static inline void __io_put_kbuf_list(struct io_kiocb *req, int len)
-{
- if (req->flags & REQ_F_BUFFER_RING) {
- __io_put_kbuf_ring(req, len, 1);
- } else {
- req->buf_index = req->kbuf->bgid;
- req->flags &= ~REQ_F_BUFFER_SELECTED;
- kfree(req->kbuf);
- req->kbuf = NULL;
- }
-}
-
-static inline void io_kbuf_drop(struct io_kiocb *req)
-{
- if (!(req->flags & (REQ_F_BUFFER_SELECTED|REQ_F_BUFFER_RING)))
- return;
-
- /* len == 0 is fine here, non-ring will always drop all of it */
- __io_put_kbuf_list(req, 0);
-}
-
static inline unsigned int __io_put_kbufs(struct io_kiocb *req, int len,
int nbufs, unsigned issue_flags)
{
@@ -192,7 +172,7 @@ static inline unsigned int __io_put_kbufs(struct io_kiocb *req, int len,
if (!__io_put_kbuf_ring(req, len, nbufs))
ret |= IORING_CQE_F_BUF_MORE;
} else {
- __io_put_kbuf_list(req, len);
+ io_kbuf_drop_legacy(req);
}
return ret;
}