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>
This commit is contained in:
Jens Axboe
2024-10-29 09:02:38 -06:00
parent 5f3829fdd6
commit 4007c3d8c2
3 changed files with 17 additions and 16 deletions

View File

@@ -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) {