Skip to content

Commit 6cfeadb

Browse files
Ming Leiaxboe
Ming Lei
authored andcommitted
blk-mq: don't clear flush_rq from tags->rqs[]
commit 364b618 ("blk-mq: clearing flush request reference in tags->rqs[]") is added to clear the to-be-free flush request from tags->rqs[] for avoiding use-after-free on the flush rq. Yu Kuai reported that blk_mq_clear_flush_rq_mapping() slows down boot time by ~8s because running scsi probe which may create and remove lots of unpresent LUNs on megaraid-sas which uses BLK_MQ_F_TAG_HCTX_SHARED and each request queue has lots of hw queues. Improve the situation by not running blk_mq_clear_flush_rq_mapping if disk isn't added when there can't be any flush request issued. Reviewed-by: Christoph Hellwig <[email protected]> Reported-by: Yu Kuai <[email protected]> Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4d337ce commit 6cfeadb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: block/blk-mq.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3431,8 +3431,9 @@ static void blk_mq_exit_hctx(struct request_queue *q,
34313431
if (blk_mq_hw_queue_mapped(hctx))
34323432
blk_mq_tag_idle(hctx);
34333433

3434-
blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx],
3435-
set->queue_depth, flush_rq);
3434+
if (blk_queue_init_done(q))
3435+
blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx],
3436+
set->queue_depth, flush_rq);
34363437
if (set->ops->exit_request)
34373438
set->ops->exit_request(set, flush_rq, hctx_idx);
34383439

0 commit comments

Comments
 (0)