Skip to content

Commit

Permalink
io_uring: reuse io_req_task_complete for timeouts
Browse files Browse the repository at this point in the history
With kbuf unification io_req_task_complete() is now a generic function,
use it for timeout's tw completions.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/7142fa3cbaf3a4140d59bcba45cbe168cf40fac2.1638714983.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed Dec 5, 2021
1 parent 83a13a4 commit a90c8bf
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -5953,15 +5953,6 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)
return 0;
}

static void io_req_task_timeout(struct io_kiocb *req, bool *locked)
{
struct io_timeout_data *data = req->async_data;

if (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))
req_set_fail(req);
io_req_complete_post(req, -ETIME, 0);
}

static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
{
struct io_timeout_data *data = container_of(timer,
Expand All @@ -5976,7 +5967,11 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
atomic_read(&req->ctx->cq_timeouts) + 1);
spin_unlock_irqrestore(&ctx->timeout_lock, flags);

req->io_task_work.func = io_req_task_timeout;
if (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))
req_set_fail(req);

req->result = -ETIME;
req->io_task_work.func = io_req_task_complete;
io_req_task_work_add(req);
return HRTIMER_NORESTART;
}
Expand Down

0 comments on commit a90c8bf

Please sign in to comment.