]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/rsrc: remove node assignment helpers
authorJens Axboe <axboe@kernel.dk>
Wed, 16 Apr 2025 19:25:03 +0000 (13:25 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 21 Apr 2025 11:06:58 +0000 (05:06 -0600)
There are two helpers here, one assigns and increments the node ref
count, and the other is simply a wrapper around that for the buffer node
handling.

The buffer node assignment benefits from checking and setting
REQ_F_BUF_NODE together, otherwise stalls have been observed on setting
that flag later in the process. Hence re-do it so that it's set when
checked, and cleared in case of (unlikely) failure. With that, the
buffer node helper can go, and then drop the generic
io_req_assign_rsrc_node() helper as well as there's only a single user
of it left at that point.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c
io_uring/rsrc.c
io_uring/rsrc.h

index 61514b14ee3f4214868d506d02d221a89f856142..75c02252654802ba89dacc1860f6066f9ff1a6dc 100644 (file)
@@ -1912,7 +1912,8 @@ inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
        io_ring_submit_lock(ctx, issue_flags);
        node = io_rsrc_node_lookup(&ctx->file_table.data, fd);
        if (node) {
-               io_req_assign_rsrc_node(&req->file_node, node);
+               node->refs++;
+               req->file_node = node;
                req->flags |= io_slot_flags(node);
                file = io_slot_file(node);
        }
index f80a77c4973f30b87a0c57a364487c61c9f94882..107064c9c6fc2f7a45b21891de566bd1fa95388f 100644 (file)
@@ -1110,13 +1110,19 @@ inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
 
        if (req->flags & REQ_F_BUF_NODE)
                return req->buf_node;
+       req->flags |= REQ_F_BUF_NODE;
 
        io_ring_submit_lock(ctx, issue_flags);
        node = io_rsrc_node_lookup(&ctx->buf_table, req->buf_index);
-       if (node)
-               io_req_assign_buf_node(req, node);
+       if (node) {
+               node->refs++;
+               req->buf_node = node;
+               io_ring_submit_unlock(ctx, issue_flags);
+               return node;
+       }
+       req->flags &= ~REQ_F_BUF_NODE;
        io_ring_submit_unlock(ctx, issue_flags);
-       return node;
+       return NULL;
 }
 
 int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
index b52242852ff342806b6b93791d284222db3137f4..6008ad2e6d9e9c763400a70625a142cd5a5fa9f7 100644 (file)
@@ -127,20 +127,6 @@ static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
        }
 }
 
-static inline void io_req_assign_rsrc_node(struct io_rsrc_node **dst_node,
-                                          struct io_rsrc_node *node)
-{
-       node->refs++;
-       *dst_node = node;
-}
-
-static inline void io_req_assign_buf_node(struct io_kiocb *req,
-                                         struct io_rsrc_node *node)
-{
-       io_req_assign_rsrc_node(&req->buf_node, node);
-       req->flags |= REQ_F_BUF_NODE;
-}
-
 int io_files_update(struct io_kiocb *req, unsigned int issue_flags);
 int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);