summaryrefslogtreecommitdiff
path: root/io_uring/kbuf.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-08-12 09:18:35 -0600
committerJens Axboe <axboe@kernel.dk>2024-08-29 08:44:38 -0600
commitecd5c9b29643f383d39320e30d21b8615bd893da (patch)
tree42df173926bdb439e9c62e129dd0a2d410b10e37 /io_uring/kbuf.h
parent120443321dfaaab8eb9290af617abcc37734c1e2 (diff)
downloadlwn-ecd5c9b29643f383d39320e30d21b8615bd893da.tar.gz
lwn-ecd5c9b29643f383d39320e30d21b8615bd893da.zip
io_uring/kbuf: add io_kbuf_commit() helper
Committing the selected ring buffer is currently done in three different spots, combine it into a helper and just call that. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/kbuf.h')
-rw-r--r--io_uring/kbuf.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/io_uring/kbuf.h b/io_uring/kbuf.h
index ab30aa13fb5e..43c7b18244b3 100644
--- a/io_uring/kbuf.h
+++ b/io_uring/kbuf.h
@@ -121,15 +121,21 @@ static inline bool io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
return false;
}
+static inline void io_kbuf_commit(struct io_kiocb *req,
+ struct io_buffer_list *bl, int nr)
+{
+ if (unlikely(!(req->flags & REQ_F_BUFFERS_COMMIT)))
+ return;
+ bl->head += nr;
+ req->flags &= ~REQ_F_BUFFERS_COMMIT;
+}
+
static inline void __io_put_kbuf_ring(struct io_kiocb *req, int nr)
{
struct io_buffer_list *bl = req->buf_list;
if (bl) {
- if (req->flags & REQ_F_BUFFERS_COMMIT) {
- bl->head += nr;
- req->flags &= ~REQ_F_BUFFERS_COMMIT;
- }
+ io_kbuf_commit(req, bl, nr);
req->buf_index = bl->bgid;
}
req->flags &= ~REQ_F_BUFFER_RING;