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 48FA5C43334 for ; Tue, 21 Jun 2022 21:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355960AbiFUVC5 (ORCPT ); Tue, 21 Jun 2022 17:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355451AbiFUU6J (ORCPT ); Tue, 21 Jun 2022 16:58:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F55832071; Tue, 21 Jun 2022 13:51:05 -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 E8320B81B43; Tue, 21 Jun 2022 20:51:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F56CC3411C; Tue, 21 Jun 2022 20:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655844663; bh=1nCe2vNL3CdFgMlwOCIA5leKZTxpAVMHSxUCBmDJ+8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiO3tQoBYR5UgM1imem2I2fRIRFBYTUDFrrjNzIwm3/fgORD7XS8XCKH1+CIRElJV wIRSvqMuLDBh6PPpdBjyFg8WxMWMXIzRO+NAamghW78+QI/0ieULS94k5i6TYjFPpw IsEQue4YafCMo3IPdXW683a2OFtzbxfmepGhPoc9jgJoMo28vaeCoHWST+9947Iu6C Do0ul3wRfBO9x2uEc4KpPtMQDYGyT90DY/v6cVROJ/kNR5OuPxVnWKpfIY1HwXD0eK lNsV4xyp9NthlE95KuTVcOqjGZPmA+Zvh4dgc2rYlFKeKpCr1yw2Bl6JFcOHpN/Ynl BAIECqqaMRXsA== 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.15 16/17] blk-mq: don't clear flush_rq from tags->rqs[] Date: Tue, 21 Jun 2022 16:50:39 -0400 Message-Id: <20220621205041.250426-16-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220621205041.250426-1-sashal@kernel.org> References: <20220621205041.250426-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 95da44063e65..cc313b364691 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2681,8 +2681,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