From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH v2 4/4] io_uring: batch cancel in io_uring_cancel_files()
Date: Mon, 15 Jun 2020 10:24:05 +0300 [thread overview]
Message-ID: <893d62893aab92d7a2e01e26868230621d265220.1592205754.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Instead of waiting for each request one by one, first try to cancel all
of them in a batched manner, and then go over inflight_list/etc to reap
leftovers.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8bde42775693..5b5cab6691d2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7370,9 +7370,22 @@ static int io_uring_release(struct inode *inode, struct file *file)
return 0;
}
+static bool io_wq_files_match(struct io_wq_work *work, void *data)
+{
+ struct files_struct *files = data;
+
+ return work->files == files;
+}
+
static void io_uring_cancel_files(struct io_ring_ctx *ctx,
struct files_struct *files)
{
+ if (list_empty_careful(&ctx->inflight_list))
+ return;
+
+ /* cancel all at once, should be faster than doing it one by one*/
+ io_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true);
+
while (!list_empty_careful(&ctx->inflight_list)) {
struct io_kiocb *cancel_req = NULL, *req;
DEFINE_WAIT(wait);
--
2.24.0
next prev parent reply other threads:[~2020-06-15 7:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 7:24 [PATCH v2 0/4][RESEND] cancel all reqs of an exiting task Pavel Begunkov
2020-06-15 7:24 ` [PATCH v2 1/4] io-wq: reorder cancellation pending -> running Pavel Begunkov
2020-06-15 7:24 ` [PATCH v2 2/4] io-wq: add an option to cancel all matched reqs Pavel Begunkov
2020-06-15 7:24 ` [PATCH v2 3/4] io_uring: cancel all task's requests on exit Pavel Begunkov
2020-06-15 7:24 ` Pavel Begunkov [this message]
2020-06-15 15:04 ` [PATCH v2 0/4][RESEND] cancel all reqs of an exiting task 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=893d62893aab92d7a2e01e26868230621d265220.1592205754.git.asml.silence@gmail.com \
[email protected] \
[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