public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/3] io_uring: cleanup iowq cancellation files matching
Date: Wed, 20 Jan 2021 02:32:24 +0000	[thread overview]
Message-ID: <40dbd3122a332596887a0b1390e85a4c128e497d.1611109718.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Clean up io_cancel_task_cb() and related io-wq cancellation after
renouncing from files cancellations. No need to drag files anymore, just
pass task directly.

io_match_task() guarantees to not walk through linked request when
files==NULL, so we can also get rid of ugly conditional synchronisation
there.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 0c886ef49920..8d181ef44398 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8850,29 +8850,12 @@ static int io_uring_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-struct io_task_cancel {
-	struct task_struct *task;
-	struct files_struct *files;
-};
-
 static bool io_cancel_task_cb(struct io_wq_work *work, void *data)
 {
 	struct io_kiocb *req = container_of(work, struct io_kiocb, work);
-	struct io_task_cancel *cancel = data;
-	bool ret;
-
-	if (cancel->files && (req->flags & REQ_F_LINK_TIMEOUT)) {
-		unsigned long flags;
-		struct io_ring_ctx *ctx = req->ctx;
+	struct task_struct *tsk = data;
 
-		/* protect against races with linked timeouts */
-		spin_lock_irqsave(&ctx->completion_lock, flags);
-		ret = io_match_task(req, cancel->task, cancel->files);
-		spin_unlock_irqrestore(&ctx->completion_lock, flags);
-	} else {
-		ret = io_match_task(req, cancel->task, cancel->files);
-	}
-	return ret;
+	return io_match_task(req, tsk, NULL);
 }
 
 static void io_cancel_defer_files(struct io_ring_ctx *ctx,
@@ -8905,13 +8888,12 @@ static void __io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
 					    struct task_struct *task)
 {
 	while (1) {
-		struct io_task_cancel cancel = { .task = task, .files = NULL, };
 		enum io_wq_cancel cret;
 		bool ret = false;
 
 		if (ctx->io_wq) {
 			cret = io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb,
-					       &cancel, true);
+					       task, true);
 			ret |= (cret != IO_WQ_CANCEL_NOTFOUND);
 		}
 
-- 
2.24.0


  parent reply	other threads:[~2021-01-20  3:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  2:32 [PATCH 0/3] files cancellation cleanup Pavel Begunkov
2021-01-20  2:32 ` [PATCH 1/3] io_uring: remove cancel_files and inflight tracking Pavel Begunkov
2021-01-20  2:32 ` Pavel Begunkov [this message]
2021-01-20  2:32 ` [PATCH 3/3] io_uring: don't pass files for cancellation Pavel Begunkov
2021-01-20  3:13 ` [PATCH 0/3] files cancellation cleanup Jens Axboe
2021-01-22  9:45 ` Joseph Qi
2021-01-22 21:49   ` Pavel Begunkov
2021-01-25  2:14     ` Joseph Qi
2021-01-25 10:48       ` Pavel Begunkov

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=40dbd3122a332596887a0b1390e85a4c128e497d.1611109718.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