From 221aa92409f945a19ce28c5cb54b4d9957f90715 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Thu, 1 Apr 2021 15:43:41 +0100 Subject: [PATCH] io_uring: simplify io_rsrc_node_ref_zero Replace queue_delayed_work() with mod_delayed_work() in io_rsrc_node_ref_zero() as the later one can schedule a new work, and cleanup it further for better readability. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/3b2b23e3a1ea4bbf789cd61815d33e05d9ff945e.1617287883.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- fs/io_uring.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 938d823..ed7685c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7583,7 +7583,7 @@ static void io_rsrc_node_ref_zero(struct percpu_ref *ref) struct io_rsrc_data *data = node->rsrc_data; struct io_ring_ctx *ctx = data->ctx; bool first_add = false; - int delay = HZ; + int delay; io_rsrc_ref_lock(ctx); node->done = true; @@ -7599,13 +7599,9 @@ static void io_rsrc_node_ref_zero(struct percpu_ref *ref) } io_rsrc_ref_unlock(ctx); - if (percpu_ref_is_dying(&data->refs)) - delay = 0; - - if (!delay) - mod_delayed_work(system_wq, &ctx->rsrc_put_work, 0); - else if (first_add) - queue_delayed_work(system_wq, &ctx->rsrc_put_work, delay); + delay = percpu_ref_is_dying(&data->refs) ? 0 : HZ; + if (first_add || !delay) + mod_delayed_work(system_wq, &ctx->rsrc_put_work, delay); } static struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx) -- 2.7.4