diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-04-01 16:43:59 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-12 03:30:34 +0200 |
commit | df9727affa058f4f18e388b30247650f8ae13cd8 (patch) | |
tree | 107c5a4dea2d0d7af8bf12aee6da072a73629fff | |
parent | io_uring: simplify overflow handling (diff) | |
download | linux-df9727affa058f4f18e388b30247650f8ae13cd8.tar.xz linux-df9727affa058f4f18e388b30247650f8ae13cd8.zip |
io_uring: put link timeout req consistently
Don't put linked timeout req in io_async_find_and_cancel() but do it in
io_link_timeout_fn(), so we have only one point for that and won't have
to do it differently as it's now (put vs put_deferred). Btw, improve a
bit io_async_find_and_cancel()'s locking.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d75b70957f245275ab7cba83e0ac9c1b86aae78a.1617287883.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 99f5252ff2dc..d575d0d15df5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5766,12 +5766,9 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx, int ret; ret = io_async_cancel_one(req->task->io_uring, sqe_addr, ctx); - if (ret != -ENOENT) { - spin_lock_irqsave(&ctx->completion_lock, flags); - goto done; - } - spin_lock_irqsave(&ctx->completion_lock, flags); + if (ret != -ENOENT) + goto done; ret = io_timeout_cancel(ctx, sqe_addr); if (ret != -ENOENT) goto done; @@ -5786,7 +5783,6 @@ done: if (ret < 0) req_set_fail_links(req); - io_put_req(req); } static int io_async_cancel_prep(struct io_kiocb *req, @@ -6361,8 +6357,8 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer) io_put_req_deferred(prev, 1); } else { io_req_complete_post(req, -ETIME, 0); - io_put_req_deferred(req, 1); } + io_put_req_deferred(req, 1); return HRTIMER_NORESTART; } |