summaryrefslogtreecommitdiffstats
path: root/io_uring/rsrc.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-10-29 16:02:38 +0100
committerJens Axboe <axboe@kernel.dk>2024-11-02 22:45:30 +0100
commit4007c3d8c22a2025367953f4ee36ae106a69d855 (patch)
tree4180ac98a9b7f3ffbcc3d7a424a06f3147c67750 /io_uring/rsrc.h
parentio_uring/filetable: kill io_reset_alloc_hint() helper (diff)
downloadlinux-4007c3d8c22a2025367953f4ee36ae106a69d855.tar.xz
linux-4007c3d8c22a2025367953f4ee36ae106a69d855.zip
io_uring/rsrc: add io_reset_rsrc_node() helper
Puts and reset an existing node in a slot, if one exists. Returns true if a node was there, false if not. This helps cleanup some of the code that does a lookup just to clear an existing node. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
-rw-r--r--io_uring/rsrc.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 82e08cbba02e..43b19e516f5f 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -84,6 +84,17 @@ static inline void io_put_rsrc_node(struct io_rsrc_node *node)
io_free_rsrc_node(node);
}
+static inline bool io_reset_rsrc_node(struct io_rsrc_data *data, int index)
+{
+ struct io_rsrc_node *node = data->nodes[index];
+
+ if (!node)
+ return false;
+ io_put_rsrc_node(node);
+ data->nodes[index] = NULL;
+ return true;
+}
+
static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
{
if (req->rsrc_nodes[IORING_RSRC_FILE] != rsrc_empty_node) {