From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 1/2] io_uring: restructure io_timeout_cancel()
Date: Sun, 29 Nov 2020 17:12:05 +0000 [thread overview]
Message-ID: <fd52cfd984a41b35537bc89f425913f6af993c21.1606669225.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Add io_timeout_extract() helper, which searches and disarms timeouts,
but doesn't complete them. No functional changes.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 12e641c61708..bffcbec6c9be 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5639,24 +5639,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;
@@ -5668,9 +5654,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,
--
2.24.0
next prev parent reply other threads:[~2020-11-29 17:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-29 17:12 [PATCH 0/2] implement timeout update Pavel Begunkov
2020-11-29 17:12 ` Pavel Begunkov [this message]
2020-11-29 17:12 ` [PATCH 2/2] io_uring: add " Pavel Begunkov
2020-11-30 18:15 ` Jens Axboe
2020-11-30 18:27 ` Pavel Begunkov
2020-11-30 18:40 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd52cfd984a41b35537bc89f425913f6af993c21.1606669225.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox