summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-11-30 20:11:15 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-09 20:04:01 +0100
commitfbd15848f3c13506253b6c5de0077a603947cb67 (patch)
tree3deac9cefdb459fc9193bdaa612a6dfef8071d50 /fs
parentio_uring: fix files cancellation (diff)
downloadlinux-fbd15848f3c13506253b6c5de0077a603947cb67.tar.xz
linux-fbd15848f3c13506253b6c5de0077a603947cb67.zip
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: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index f47de27e5125..3930b11dcd58 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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,