Commit 7e4756d8 authored by Ming Lei's avatar Ming Lei Committed by Zheng Zengkai
Browse files

blk-mq: don't clear flush_rq from tags->rqs[]

mainline inclusion
from mainline-v5.19
commit 6cfeadbf
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EKM7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6cfeadbff3f8905f2854735ebb88e581402c16c4



--------------------------------

commit 364b6181 ("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: default avatarChristoph Hellwig <hch@lst.de>
Reported-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220616014401.817001-4-ming.lei@redhat.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>

Conflicts:
	block/blk-mq.c
Signed-off-by: default avatarLuo Meng <luomeng12@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent b5f5d3d0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2737,6 +2737,7 @@ static void blk_mq_exit_hctx(struct request_queue *q,
		blk_mq_dtag_idle(hctx, true);
	}

	if (blk_queue_init_done(q))
		blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx],
				set->queue_depth, flush_rq);
	if (set->ops->exit_request)