diff options
| author | Jens Axboe <axboe@kernel.dk> | 2024-10-26 10:41:51 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2024-11-02 15:44:30 -0600 |
| commit | 0701db7439208951c8a7d8600668e5cfdd5f63d2 (patch) | |
| tree | da619885e5375a534c829a3ca613e8e0b9320060 /io_uring/rsrc.h | |
| parent | fbbb8e991d86bb7539de6161746b6c747f93f533 (diff) | |
io_uring/rsrc: add an empty io_rsrc_node for sparse buffer entries
Rather than allocate an io_rsrc_node for an empty/sparse buffer entry,
add a const entry that can be used for that. This just needs checking
for writing the tag, and the put check needs to check for that sparse
node rather than NULL for validity.
This avoids allocating rsrc nodes for sparse buffer entries.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
| -rw-r--r-- | io_uring/rsrc.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h index 20a316854238..323c3e78b864 100644 --- a/io_uring/rsrc.h +++ b/io_uring/rsrc.h @@ -70,9 +70,12 @@ int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg, int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg, unsigned int size, unsigned int type); +extern const struct io_rsrc_node empty_node; +#define rsrc_empty_node (struct io_rsrc_node *) &empty_node + static inline void io_put_rsrc_node(struct io_rsrc_node *node) { - if (node && !--node->refs) + if (node != rsrc_empty_node && !--node->refs) io_free_rsrc_node(node); } @@ -85,8 +88,10 @@ static inline void io_req_put_rsrc_nodes(struct io_kiocb *req) static inline void io_req_assign_rsrc_node(struct io_kiocb *req, struct io_rsrc_node *node) { - node->refs++; - req->rsrc_nodes[node->type] = node; + if (node != rsrc_empty_node) { + node->refs++; + req->rsrc_nodes[node->type] = node; + } } int io_files_update(struct io_kiocb *req, unsigned int issue_flags); |