Commit fbd15848 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: restructure io_timeout_cancel()

Add io_timeout_extract() helper, which searches and disarms timeouts,
but doesn't complete them. No functional changes.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent bee749b1
......@@ -5633,24 +5633,10 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
return HRTIMER_NORESTART;
}
static int __io_timeout_cancel(struct io_kiocb *req)
{
struct io_timeout_data *io = req->async_data;
int ret;
ret = hrtimer_try_to_cancel(&io->timer);
if (ret == -1)
return -EALREADY;
list_del_init(&req->timeout.list);
req_set_fail_links(req);
io_cqring_fill_event(req, -ECANCELED);
io_put_req_deferred(req, 1);
return 0;
}
static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data)
static struct io_kiocb *io_timeout_extract(struct io_ring_ctx *ctx,
__u64 user_data)
{
struct io_timeout_data *io;
struct io_kiocb *req;
int ret = -ENOENT;
......@@ -5662,9 +5648,27 @@ static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data)
}
if (ret == -ENOENT)
return ret;
return ERR_PTR(ret);
io = req->async_data;
ret = hrtimer_try_to_cancel(&io->timer);
if (ret == -1)
return ERR_PTR(-EALREADY);
list_del_init(&req->timeout.list);
return req;
}
return __io_timeout_cancel(req);
static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data)
{
struct io_kiocb *req = io_timeout_extract(ctx, user_data);
if (IS_ERR(req))
return PTR_ERR(req);
req_set_fail_links(req);
io_cqring_fill_event(req, -ECANCELED);
io_put_req_deferred(req, 1);
return 0;
}
static int io_timeout_remove_prep(struct io_kiocb *req,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment