Skip to content

Commit c6b7a3a

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: fix two misuses on RQF_USE_SCHED
Request allocated from sched tags can't be issued via ->queue_rqs() directly, since driver tag isn't allocated yet. This is the 1st misuse of RQF_USE_SCHED for figuring out plug->has_elevator. Request allocated from sched tags can't be ended by blk_mq_end_request_batch() too, fix the 2nd RQF_USE_SCHED misuse in blk_mq_add_to_batch(). Without this patch, NVMe uring cmd passthrough IO workload can run into hang easily with real io scheduler. Fixes: dd6216b ("blk-mq: make sure elevator callbacks aren't called for passthrough request") Reported-by: Guangwu Zhang <guazhang@redhat.com> Closes: https://lore.kernel.org/linux-block/CAGS2=YrBjpLPOKa-gzcKuuOG60AGth5794PNCDwatdnnscB9ug@mail.gmail.com/ Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20230624130105.1443879-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent ad7c3b4 commit c6b7a3a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

block/blk-mq.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,11 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
12801280

12811281
if (!plug->multiple_queues && last && last->q != rq->q)
12821282
plug->multiple_queues = true;
1283-
if (!plug->has_elevator && (rq->rq_flags & RQF_USE_SCHED))
1283+
/*
1284+
* Any request allocated from sched tags can't be issued to
1285+
* ->queue_rqs() directly
1286+
*/
1287+
if (!plug->has_elevator && (rq->rq_flags & RQF_SCHED_TAGS))
12841288
plug->has_elevator = true;
12851289
rq->rq_next = NULL;
12861290
rq_list_add(&plug->mq_list, rq);

include/linux/blk-mq.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ static inline bool blk_mq_add_to_batch(struct request *req,
852852
struct io_comp_batch *iob, int ioerror,
853853
void (*complete)(struct io_comp_batch *))
854854
{
855-
if (!iob || (req->rq_flags & RQF_USE_SCHED) || ioerror ||
855+
/*
856+
* blk_mq_end_request_batch() can't end request allocated from
857+
* sched tags
858+
*/
859+
if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
856860
(req->end_io && !blk_rq_is_passthrough(req)))
857861
return false;
858862

0 commit comments

Comments
 (0)