summaryrefslogtreecommitdiffstats
path: root/io_uring/rsrc.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-11-03 08:17:28 -0700
committerJens Axboe <axboe@kernel.dk>2024-11-06 13:54:15 -0700
commit6af82f7614a2e31e7ef23e5e160697aef31e8edd (patch)
tree1db4bbe5230113effdbafe0ea4030a67e9aa515e /io_uring/rsrc.c
parent01ee194d1aba1202f0926d5047a2a4cf84d0e45d (diff)
downloadlinux-6af82f7614a2e31e7ef23e5e160697aef31e8edd.tar.gz
linux-6af82f7614a2e31e7ef23e5e160697aef31e8edd.tar.bz2
linux-6af82f7614a2e31e7ef23e5e160697aef31e8edd.zip
io_uring/rsrc: encode node type and ctx together
Rather than keep the type field separate rom ctx, use the fact that we can encode up to 4 types of nodes in the LSB of the ctx pointer. Doesn't reclaim any space right now on 64-bit archs, but it leaves a full int for future use. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.c')
-rw-r--r--io_uring/rsrc.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 60fa857985cb..2fb1791d7255 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -124,9 +124,8 @@ struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx, int type)
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (node) {
- node->ctx = ctx;
+ node->ctx_ptr = (unsigned long) ctx | type;
node->refs = 1;
- node->type = type;
}
return node;
}
@@ -445,21 +444,21 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
void io_free_rsrc_node(struct io_rsrc_node *node)
{
- struct io_ring_ctx *ctx = node->ctx;
+ struct io_ring_ctx *ctx = io_rsrc_node_ctx(node);
lockdep_assert_held(&ctx->uring_lock);
if (node->tag)
- io_post_aux_cqe(node->ctx, node->tag, 0, 0);
+ io_post_aux_cqe(ctx, node->tag, 0, 0);
- switch (node->type) {
+ switch (io_rsrc_node_type(node)) {
case IORING_RSRC_FILE:
if (io_slot_file(node))
fput(io_slot_file(node));
break;
case IORING_RSRC_BUFFER:
if (node->buf)
- io_buffer_unmap(node->ctx, node);
+ io_buffer_unmap(ctx, node);
break;
default:
WARN_ON_ONCE(1);