All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Ming Lei <ming.lei@redhat.com>
Cc: linux-block@vger.kernel.org, Guangwu Zhang <guazhang@redhat.com>,
	Yu Kuai <yukuai1@huaweicloud.com>
Subject: [PATCH 1/3] blk-mq: don't queue plugged passthrough requests into scheduler
Date: Thu, 18 May 2023 07:30:59 +0200	[thread overview]
Message-ID: <20230518053101.760632-2-hch@lst.de> (raw)
In-Reply-To: <20230518053101.760632-1-hch@lst.de>

From: Ming Lei <ming.lei@redhat.com>

Passthrough) request should never be queued to the I/O scheduler,
as scheduling these opaque requests doens't make sense, and I/O
schedulers might required req->bio to be always valid.

We never let passthrough request cross scheduler before commit
1c2d2fff6dc0 ("block: wire-up support for passthrough plugging"),
restored this behavior even for passthrough requests issued under
a plug.

Reported-by: Guangwu Zhang <guazhang@redhat.com>
Closes: https://lore.kernel.org/linux-block/CAGS2=YosaYaUTEMU3uaf+y=8MqSrhL7sYsJn8EwbaM=76p_4Qg@mail.gmail.com/
Investigated-by: Yu Kuai <yukuai1@huaweicloud.com>
Fixes: 1c2d2fff6dc0 ("block: wire-up support for passthrough plugging")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
[hch: use blk_mq_insert_requests for passthrough requests,
      fix up the commit message and comments]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f6dad0886a2fa1..8b7e4daaa5b70d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2711,6 +2711,7 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 	struct request *requeue_list = NULL;
 	struct request **requeue_lastp = &requeue_list;
 	unsigned int depth = 0;
+	bool is_passthrough = false;
 	LIST_HEAD(list);
 
 	do {
@@ -2719,7 +2720,9 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 		if (!this_hctx) {
 			this_hctx = rq->mq_hctx;
 			this_ctx = rq->mq_ctx;
-		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) {
+			is_passthrough = blk_rq_is_passthrough(rq);
+		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx ||
+			   is_passthrough != blk_rq_is_passthrough(rq)) {
 			rq_list_add_tail(&requeue_lastp, rq);
 			continue;
 		}
@@ -2731,7 +2734,8 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 	trace_block_unplug(this_hctx->queue, depth, !from_sched);
 
 	percpu_ref_get(&this_hctx->queue->q_usage_counter);
-	if (this_hctx->queue->elevator) {
+	/* passthrough requests should never be issued to the I/O scheduler */
+	if (this_hctx->queue->elevator && !is_passthrough) {
 		this_hctx->queue->elevator->type->ops.insert_requests(this_hctx,
 				&list, 0);
 		blk_mq_run_hw_queue(this_hctx, from_sched);
-- 
2.39.2


  reply	other threads:[~2023-05-18  5:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18  5:30 keep passthrough request out of the I/O schedulers Christoph Hellwig
2023-05-18  5:30 ` Christoph Hellwig [this message]
2023-05-18 17:50   ` [PATCH 1/3] blk-mq: don't queue plugged passthrough requests into scheduler Bart Van Assche
2023-05-19  1:41   ` Jens Axboe
2023-05-18  5:31 ` [PATCH 2/3] blk-mq: remove RQF_ELVPRIV Christoph Hellwig
2023-05-18  7:05   ` Ming Lei
2023-05-18  7:11   ` Ming Lei
2023-05-18 13:06     ` Christoph Hellwig
2023-05-18 13:20       ` Ming Lei
2023-05-19  1:39         ` Jens Axboe
2023-05-18 17:52   ` Bart Van Assche
2023-05-18  5:31 ` [PATCH 3/3] blk-mq: make sure elevator callbacks aren't called for passthrough request Christoph Hellwig
2023-05-18 13:23   ` Ming Lei
2023-05-18 17:58   ` Bart Van Assche
2023-05-19  1:39 ` keep passthrough request out of the I/O schedulers 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=20230518053101.760632-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=guazhang@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yukuai1@huaweicloud.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.