diff options
| author | Jens Axboe <axboe@kernel.dk> | 2024-10-26 10:46:10 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2024-11-02 15:44:30 -0600 |
| commit | f38f2847646f8be29a8fcb722e8b1dc8c8cb3924 (patch) | |
| tree | cc7579041ea91589187121ff45cd43977ac79f17 /io_uring/rsrc.h | |
| parent | 0701db7439208951c8a7d8600668e5cfdd5f63d2 (diff) | |
io_uring: only initialize io_kiocb rsrc_nodes when needed
Add the empty node initializing to the preinit part of the io_kiocb
allocation, and reset them if they have been used.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
| -rw-r--r-- | io_uring/rsrc.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h index 323c3e78b864..48f712488f6b 100644 --- a/io_uring/rsrc.h +++ b/io_uring/rsrc.h @@ -81,8 +81,14 @@ static inline void io_put_rsrc_node(struct io_rsrc_node *node) static inline void io_req_put_rsrc_nodes(struct io_kiocb *req) { - io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]); - io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]); + 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; + } } static inline void io_req_assign_rsrc_node(struct io_kiocb *req, |
