mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user