From 28a9fe2521348ee350b65ae89e63c1def87b0cb6 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Thu, 1 Apr 2021 15:43:47 +0100 Subject: [PATCH] io_uring: reuse io_rsrc_node_destroy() Reuse io_rsrc_node_destroy() in __io_rsrc_put_work(). Also move it to a more appropriate place -- to the other node routines, and remove forward declaration. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/cccafba41aee1e5bb59988704885b1340aef3a27.1617287883.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- fs/io_uring.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 81298999fd937..59e666151754a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1028,7 +1028,6 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx, struct task_struct *task, struct files_struct *files); static void io_uring_cancel_sqpoll(struct io_ring_ctx *ctx); -static void io_rsrc_node_destroy(struct io_rsrc_node *ref_node); static struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx); static void io_ring_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc); @@ -7093,6 +7092,12 @@ static inline void io_rsrc_ref_unlock(struct io_ring_ctx *ctx) spin_unlock_bh(&ctx->rsrc_ref_lock); } +static void io_rsrc_node_destroy(struct io_rsrc_node *ref_node) +{ + percpu_ref_exit(&ref_node->refs); + kfree(ref_node); +} + static void io_rsrc_node_switch(struct io_ring_ctx *ctx, struct io_rsrc_data *data_to_kill) { @@ -7538,8 +7543,7 @@ static void __io_rsrc_put_work(struct io_rsrc_node *ref_node) kfree(prsrc); } - percpu_ref_exit(&ref_node->refs); - kfree(ref_node); + io_rsrc_node_destroy(ref_node); percpu_ref_put(&rsrc_data->refs); } @@ -7607,12 +7611,6 @@ static struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx) return ref_node; } -static void io_rsrc_node_destroy(struct io_rsrc_node *ref_node) -{ - percpu_ref_exit(&ref_node->refs); - kfree(ref_node); -} - static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args) { -- 2.30.2