public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
	[email protected], [email protected]
Subject: [PATCH 3/5] io_uring: fix reassigning work.task_pid from io-wq
Date: Tue, 11 Feb 2020 23:01:56 +0300	[thread overview]
Message-ID: <728f583e7835cf0c74b8dc8fbeddb58970f477a5.1581450491.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

If a request got into io-wq context, io_prep_async_work() has already
been called. Most of the stuff there is idempotent with an exception
that it'll set work.task_pid to task_pid_vnr() of an io_wq worker thread

Do only what's needed, that's io_prep_linked_timeout() and setting
IO_WQ_WORK_UNBOUND.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 04680d2c205c..f3108bce4afe 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -948,6 +948,17 @@ static inline void io_req_work_drop_env(struct io_kiocb *req)
 	}
 }
 
+static inline void io_prep_next_work(struct io_kiocb *req,
+				     struct io_kiocb **link)
+{
+	const struct io_op_def *def = &io_op_defs[req->opcode];
+
+	if (!(req->flags & REQ_F_ISREG) && def->unbound_nonreg_file)
+			req->work.flags |= IO_WQ_WORK_UNBOUND;
+
+	*link = io_prep_linked_timeout(req);
+}
+
 static inline bool io_prep_async_work(struct io_kiocb *req,
 				      struct io_kiocb **link)
 {
@@ -2453,7 +2464,7 @@ static void io_wq_assign_next(struct io_wq_work **workptr, struct io_kiocb *nxt)
 {
 	struct io_kiocb *link;
 
-	io_prep_async_work(nxt, &link);
+	io_prep_next_work(nxt, &link);
 	*workptr = &nxt->work;
 	if (link) {
 		nxt->work.flags |= IO_WQ_WORK_CB;
-- 
2.24.0


  parent reply	other threads:[~2020-02-11 20:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 20:01 [PATCH 0/5] async punting improvements for io_uring Pavel Begunkov
2020-02-11 20:01 ` [PATCH 1/5] io_uring: remove REQ_F_MUST_PUNT Pavel Begunkov
2020-02-11 20:01 ` [PATCH 2/5] io_uring: don't call work.func from sync ctx Pavel Begunkov
2020-02-11 20:01 ` Pavel Begunkov [this message]
2020-02-11 20:21   ` [PATCH 3/5] io_uring: fix reassigning work.task_pid from io-wq Jens Axboe
2020-02-11 20:57     ` Pavel Begunkov
2020-02-11 20:59       ` Jens Axboe
2020-02-11 20:01 ` [PATCH 4/5] io_uring: add missing io_req_cancelled() Pavel Begunkov
2020-02-11 20:01 ` [PATCH 5/5] io_uring: purge req->in_async 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=728f583e7835cf0c74b8dc8fbeddb58970f477a5.1581450491.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