Skip to content

Commit a71976f

Browse files
isilenceaxboe
authored andcommitted
io_uring: remove timeout.list after hrtimer cancel
Remove timeouts from ctx->timeout_list after hrtimer_try_to_cancel() successfully cancels it. With this we don't need to care whether there was a race and it was removed in io_timeout_fn(), and that will be handy for following patches. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0bdf7a2 commit a71976f

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

fs/io_uring.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,16 +5301,10 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
53015301
unsigned long flags;
53025302

53035303
spin_lock_irqsave(&ctx->completion_lock, flags);
5304+
list_del_init(&req->timeout.list);
53045305
atomic_set(&req->ctx->cq_timeouts,
53055306
atomic_read(&req->ctx->cq_timeouts) + 1);
53065307

5307-
/*
5308-
* We could be racing with timeout deletion. If the list is empty,
5309-
* then timeout lookup already found it and will be handling it.
5310-
*/
5311-
if (!list_empty(&req->timeout.list))
5312-
list_del_init(&req->timeout.list);
5313-
53145308
io_cqring_fill_event(req, -ETIME);
53155309
io_commit_cqring(ctx);
53165310
spin_unlock_irqrestore(&ctx->completion_lock, flags);
@@ -5326,11 +5320,10 @@ static int __io_timeout_cancel(struct io_kiocb *req)
53265320
struct io_timeout_data *io = req->async_data;
53275321
int ret;
53285322

5329-
list_del_init(&req->timeout.list);
5330-
53315323
ret = hrtimer_try_to_cancel(&io->timer);
53325324
if (ret == -1)
53335325
return -EALREADY;
5326+
list_del_init(&req->timeout.list);
53345327

53355328
req_set_fail_links(req);
53365329
req->flags |= REQ_F_COMP_LOCKED;

0 commit comments

Comments
 (0)