From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
linux-mm@kvack.org, linux-xfs@vger.kernel.org,
Changhui Zhong <czhong@redhat.com>
Subject: Re: [PATCH V2] block: avoid io timeout in case of sync polled dio
Date: Fri, 15 Apr 2022 07:18:44 +0200 [thread overview]
Message-ID: <20220415051844.GA22762@lst.de> (raw)
In-Reply-To: <20220415034703.2081695-1-ming.lei@redhat.com>
On Fri, Apr 15, 2022 at 11:47:03AM +0800, Ming Lei wrote:
> + /* make sure the bio is issued before polling */
> + if (bio.bi_opf & REQ_POLLED)
> + blk_flush_plug(current->plug, false);
I still think the core code should handle this. Without that we'd need
to export the blk_flush_plug for anything that would want to poll bios
from modules, in addition to it generally being a mess. See a proposed
patch for that below. I'd also split the flush aspect from the poll
aspect into two patches.
> + if (bio.bi_opf & REQ_POLLED)
> + bio_poll(&bio, NULL, 0);
> + else
> blk_io_schedule();
Instead of this duplicate logic everywhere I'd just make bio_boll
call blk_io_schedule for the !REQ_POLLED case and simplify all the
callers.
> + if (dio->submit.poll_bio &&
> + (dio->submit.poll_bio->bi_opf &
> + REQ_POLLED))
This indentation looks awfull,normal would be:
if (dio->submit.poll_bio &&
(dio->submit.poll_bio->bi_opf & REQ_POLLED))
---
From 08ff61b0142eb708fc384cf867c72175561d974a Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 15 Apr 2022 07:15:42 +0200
Subject: blk-mq: don't plug for synchronously polled requests
For synchronous polling to work, the bio must be issued to the driver from
the submit_bio call, otherwise ->bi_cookie won't be set.
Based on a patch from Ming Lei.
Reported-by: Changhui Zhong <czhong@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-mq.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ed3ed86f7dd24..bcc7e3d11296c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2851,7 +2851,13 @@ void blk_mq_submit_bio(struct bio *bio)
return;
}
- if (plug)
+ /*
+ * We can't plug for synchronously polled submissions, otherwise
+ * bio->bi_cookie won't be set directly after submission, which is the
+ * indicator used by the submitter to check if a bio needs polling.
+ */
+ if (plug &&
+ (rq->bio->bi_opf & (REQ_POLLED | REQ_NOWAIT)) != REQ_POLLED)
blk_add_rq_to_plug(plug, rq);
else if ((rq->rq_flags & RQF_ELV) ||
(rq->mq_hctx->dispatch_busy &&
--
2.30.2
next prev parent reply other threads:[~2022-04-15 5:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 3:47 [PATCH V2] block: avoid io timeout in case of sync polled dio Ming Lei
2022-04-15 5:18 ` Christoph Hellwig [this message]
2022-04-15 11:00 ` Ming Lei
2022-04-16 5:49 ` Christoph Hellwig
2022-04-16 9:03 ` Ming Lei
2022-04-18 5:12 ` Christoph Hellwig
2022-04-18 8:19 ` Ming Lei
2022-04-19 5:39 ` Christoph Hellwig
2022-04-19 7:47 ` Ming Lei
2022-04-19 8:15 ` Christoph Hellwig
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=20220415051844.GA22762@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=czhong@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).