summaryrefslogtreecommitdiff
path: root/io_uring/rsrc.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-10-29 09:02:38 -0600
committerJens Axboe <axboe@kernel.dk>2024-11-02 15:45:30 -0600
commit4007c3d8c22a2025367953f4ee36ae106a69d855 (patch)
tree4180ac98a9b7f3ffbcc3d7a424a06f3147c67750 /io_uring/rsrc.c
parent5f3829fdd69d746f36a5e87df21ce58470b8e9fa (diff)
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.c')
-rw-r--r--io_uring/rsrc.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 0380b2f4ed8d..378f33746457 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -181,7 +181,6 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
return -EINVAL;
for (done = 0; done < nr_args; done++) {
- struct io_rsrc_node *node;
u64 tag = 0;
if ((tags && copy_from_user(&tag, &tags[done], sizeof(tag))) ||
@@ -197,12 +196,9 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
continue;
i = up->offset + done;
- node = io_rsrc_node_lookup(&ctx->file_table.data, i);
- if (node) {
- io_put_rsrc_node(node);
- ctx->file_table.data.nodes[i] = NULL;
+ if (io_reset_rsrc_node(&ctx->file_table.data, i))
io_file_bitmap_clear(&ctx->file_table, i);
- }
+
if (fd != -1) {
struct file *file = fget(fd);
struct io_rsrc_node *node;
@@ -279,9 +275,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
break;
}
i = array_index_nospec(up->offset + done, ctx->buf_table.nr);
- if (ctx->buf_table.nodes[i])
- io_put_rsrc_node(ctx->buf_table.nodes[i]);
-
+ io_reset_rsrc_node(&ctx->buf_table, i);
ctx->buf_table.nodes[i] = node;
if (tag)
node->tag = tag;