On Wed, Jun 15, 2022 at 10:37:12AM +0800, Ming Lei wrote: > commit 364b61818f65 ("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. This looks ok. Another optimization would be to never do this if we don't have a write cache enabled and thus never ever use the flush_rq. Reviewed-by: Christoph Hellwig <hch@xxxxxx>