From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C9C3C433EF for ; Tue, 21 Jun 2022 20:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355229AbiFUU5e (ORCPT ); Tue, 21 Jun 2022 16:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354870AbiFUU4e (ORCPT ); Tue, 21 Jun 2022 16:56:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A6D62DD58; Tue, 21 Jun 2022 13:50:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F4227B81A9A; Tue, 21 Jun 2022 20:50:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 051FFC385A9; Tue, 21 Jun 2022 20:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655844607; bh=muuLMwyq22RXpPtWQ8HWF194/A0xd8vK/W1Fo8RCJE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j3YZTplrizLP/1cdM+3t+6QJQby6y8v9hE1iswZ4Prw0Jx/6K8ouNwa6hVPOcz7TX 5yq9H2LdYGXPxDyBddcOByEXpW2L6tplvBpRHedaKoRAkk1Rn7XHaGQ+Jini/KOFv4 5J85DgaXk9Hm6k0Gk6dNZptIHkuI5cbt4BDeEX3H0dLUBBKSmgPeRn+p4WvjHDNN1k GVF3QgSVSF4XBaw9kk2KwUn9o6HwfOQi3KUhAnKXrZiAH7AOmU4JWAn/ryh3aXNnCd kPeXAFPDHgaVysUFSxPh7k3fCt/RQEvaReOHfkDEW81ASim0Ua4WqlsPti5Y6uKMdH 8Dw1ZfreQT4qw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ming Lei , Christoph Hellwig , Yu Kuai , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.18 20/22] blk-mq: don't clear flush_rq from tags->rqs[] Date: Tue, 21 Jun 2022 16:49:26 -0400 Message-Id: <20220621204928.249907-20-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220621204928.249907-1-sashal@kernel.org> References: <20220621204928.249907-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit 6cfeadbff3f8905f2854735ebb88e581402c16c4 ] 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. Reviewed-by: Christoph Hellwig Reported-by: Yu Kuai Signed-off-by: Ming Lei Link: https://lore.kernel.org/r/20220616014401.817001-4-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 78f67bf19564..c9c7bc359c74 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3427,8 +3427,9 @@ static void blk_mq_exit_hctx(struct request_queue *q, if (blk_mq_hw_queue_mapped(hctx)) blk_mq_tag_idle(hctx); - blk_mq_clear_flush_rq_mapping(set->tags[hctx_idx], - set->queue_depth, flush_rq); + 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) set->ops->exit_request(set, flush_rq, hctx_idx); -- 2.35.1