Commit d97217e7 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

blk-mq: don't queue plugged passthrough requests into scheduler

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

We never let passthrough requests insert into the scheduler before
commit 1c2d2fff ("block: wire-up support for passthrough plugging"),
restore this behavior even for passthrough requests issued under a plug.

[hch: use blk_mq_insert_requests for passthrough requests,
      fix up the commit message and comments]
Reported-by: default avatarGuangwu Zhang <guazhang@redhat.com>
Closes: https://lore.kernel.org/linux-block/CAGS2=YosaYaUTEMU3uaf+y=8MqSrhL7sYsJn8EwbaM=76p_4Qg@mail.gmail.com/Investigated-by: default avatarYu Kuai <yukuai1@huaweicloud.com>
Fixes: 1c2d2fff ("block: wire-up support for passthrough plugging")
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230518053101.760632-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d5fb8726
...@@ -2711,6 +2711,7 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched) ...@@ -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_list = NULL;
struct request **requeue_lastp = &requeue_list; struct request **requeue_lastp = &requeue_list;
unsigned int depth = 0; unsigned int depth = 0;
bool is_passthrough = false;
LIST_HEAD(list); LIST_HEAD(list);
do { do {
...@@ -2719,7 +2720,9 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched) ...@@ -2719,7 +2720,9 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
if (!this_hctx) { if (!this_hctx) {
this_hctx = rq->mq_hctx; this_hctx = rq->mq_hctx;
this_ctx = rq->mq_ctx; 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); rq_list_add_tail(&requeue_lastp, rq);
continue; continue;
} }
...@@ -2731,7 +2734,8 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched) ...@@ -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); trace_block_unplug(this_hctx->queue, depth, !from_sched);
percpu_ref_get(&this_hctx->queue->q_usage_counter); 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, this_hctx->queue->elevator->type->ops.insert_requests(this_hctx,
&list, 0); &list, 0);
blk_mq_run_hw_queue(this_hctx, from_sched); blk_mq_run_hw_queue(this_hctx, from_sched);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment