summaryrefslogtreecommitdiff
path: root/io_uring/rsrc.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-10-30 09:51:58 -0600
committerJens Axboe <axboe@kernel.dk>2024-11-02 15:45:30 -0600
commitd50f94d761a5d9a34e03a86e512e19d88cbeaf06 (patch)
tree7b7bc09d5f47e085122e8aa1f9da6c356c7da504 /io_uring/rsrc.h
parent4007c3d8c22a2025367953f4ee36ae106a69d855 (diff)
io_uring/rsrc: get rid of the empty node and dummy_ubuf
The empty node was used as a placeholder for a sparse entry, but it didn't really solve any issues. The caller still has to check for whether it's the empty node or not, it may as well just check for a NULL return instead. The dummy_ubuf was used for a sparse buffer entry, but NULL will serve the same purpose there of ensuring an -EFAULT on attempted import. Just use NULL for a sparse node, regardless of whether or not it's a file or buffer resource. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
-rw-r--r--io_uring/rsrc.h23
1 files changed, 7 insertions, 16 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 43b19e516f5f..a40fad783a69 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -67,9 +67,6 @@ 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 struct io_rsrc_node *io_rsrc_node_lookup(struct io_rsrc_data *data,
int index)
{
@@ -80,7 +77,7 @@ static inline struct io_rsrc_node *io_rsrc_node_lookup(struct io_rsrc_data *data
static inline void io_put_rsrc_node(struct io_rsrc_node *node)
{
- if (node != rsrc_empty_node && !--node->refs)
+ if (node && !--node->refs)
io_free_rsrc_node(node);
}
@@ -97,23 +94,17 @@ static inline bool io_reset_rsrc_node(struct io_rsrc_data *data, int index)
static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
{
- if (req->rsrc_nodes[IORING_RSRC_FILE] != rsrc_empty_node) {
- io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]);
- req->rsrc_nodes[IORING_RSRC_FILE] = rsrc_empty_node;
- }
- if (req->rsrc_nodes[IORING_RSRC_BUFFER] != rsrc_empty_node) {
- io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]);
- req->rsrc_nodes[IORING_RSRC_BUFFER] = rsrc_empty_node;
- }
+ io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]);
+ io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]);
+ req->rsrc_nodes[IORING_RSRC_FILE] = NULL;
+ req->rsrc_nodes[IORING_RSRC_BUFFER] = NULL;
}
static inline void io_req_assign_rsrc_node(struct io_kiocb *req,
struct io_rsrc_node *node)
{
- if (node != rsrc_empty_node) {
- node->refs++;
- req->rsrc_nodes[node->type] = node;
- }
+ node->refs++;
+ req->rsrc_nodes[node->type] = node;
}
int io_files_update(struct io_kiocb *req, unsigned int issue_flags);