From patchwork Sun Oct 30 05:26:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 12819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1649083wru; Sat, 29 Oct 2022 22:30:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CFStVewHUyB5jZObnr6pxk5J2AgZCK+VEGzwWsR+TLersgXuV4+ACT0STgQh3r+5NUB8B X-Received: by 2002:a17:90b:3149:b0:213:63d0:88d6 with SMTP id ip9-20020a17090b314900b0021363d088d6mr8043952pjb.145.1667107825556; Sat, 29 Oct 2022 22:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667107825; cv=none; d=google.com; s=arc-20160816; b=clkvMeiqZc18bHU2U7IBqPkmYa1zjkJNndC2aqgXgfkKK2Z7KUgxlIgDoQhosHxxoB H1rJU/1lVnHIkpxvjBcDTXK6m0vbJKC98QCuNA74a2eIeExCnU7yt6JVH9x0kQUcGPKN 9/2+AzuP7Kr5qaEJUZTDTY292Dax+oLIlHMWkFEnzZMtgvvxpLM0WsAAhNZjqNwad6+f FkR+J1jt5N5YTfJ25J5VIOsFTsb0unSbuAeGwtZt2HlErjcqn93h6m/RnTil/uIh7yln tBdP8Sj6thoNV1M1L+hrSpd6vTPUHuM1dTXmnayIdcwk5j71+scsMeEXOTNokYtcNUVd shQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=guU7I8/Fyv1QeTbpUJXYQOQnRCzkJ8Z7VHbjR0OrACg=; b=Ttt21Vdpugb4z1nzEBsTIpb+20Itso1J08QoN2QzXgBVkKsuIadlpMOYmGwpg2eEAO 4RlQW194W4ow1I4H1TvTY1AOr0VgndZyfOs7pWXS0GvDeCQ/9Vw2VqlVxyUQrsyW+6M9 l7hImjBq+hN0wP9xl5/y8/+0fZ9MgvExp1/aG3owBAoqZaV3fKbKt/KeQ5g6b3BzOgs+ nyWOisBpCZVNy5QCqLrP5lHAfXRIp9v70XRCAXf9LZ/3HqE1uHla2E91gNntmJMGBx0u +OezhNzi6v/YTAkNHZQyTipMqc339VYIVDC5DQeO2O0JaNms0qXUW7w1DWEk3mrKDCBA TP0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a170902c9cb00b00186a397324asi3593465pld.373.2022.10.29.22.30.13; Sat, 29 Oct 2022 22:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiJ3F1v (ORCPT + 99 others); Sun, 30 Oct 2022 01:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJ3F1u (ORCPT ); Sun, 30 Oct 2022 01:27:50 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43AC03B97E; Sat, 29 Oct 2022 22:27:47 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app3 (Coremail) with SMTP id cC_KCgBn3qlCC15jnGV2CA--.28011S3; Sun, 30 Oct 2022 13:27:37 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: bvanassche@acm.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, nickyc975@zju.edu.cn Subject: [RESEND PATCH v2 1/3] blk-mq: remove redundant call to blk_freeze_queue_start in blk_mq_destroy_queue Date: Sun, 30 Oct 2022 13:26:44 +0800 Message-Id: <3a6d54a5adc8bd09aab28abfbe5f5b02bb863a8d.1667107410.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cC_KCgBn3qlCC15jnGV2CA--.28011S3 X-Coremail-Antispam: 1UD129KBjvdXoW7JF48AFW3Gw48trW5Aw13Arb_yoWkGrb_Wa y8AF1qyFZ8GF15ur1jkF1rZF1vk3y8JFy7GFWDW3srJwn5Aan8A3y7Cr1rCr4UW3yjk3sr Wr1UG3s7Jr40qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbs8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E 87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6c xK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij 64vIr41l42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43 ZEXa7VUbHa0DUUUUU== X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgcTB1ZdtcKSqgABsU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748089255121249565?= X-GMAIL-MSGID: =?utf-8?q?1748089255121249565?= The calling relationship in blk_mq_destroy_queue() is as follows: blk_mq_destroy_queue() ... -> blk_queue_start_drain() -> blk_freeze_queue_start() <- called ... -> blk_freeze_queue() -> blk_freeze_queue_start() <- called again -> blk_mq_freeze_queue_wait() So there is a redundant call to blk_freeze_queue_start(). Replace blk_freeze_queue() with blk_mq_freeze_queue_wait() to avoid the redundant call. Signed-off-by: Jinlong Chen --- block/blk-mq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 4cecf281123f..14c4165511b9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4005,7 +4005,12 @@ void blk_mq_destroy_queue(struct request_queue *q) blk_queue_flag_set(QUEUE_FLAG_DYING, q); blk_queue_start_drain(q); - blk_freeze_queue(q); + + /* + * blk_freeze_queue_start has been called in blk_queue_start_drain, we just + * need to wait. + */ + blk_mq_freeze_queue_wait(q); blk_sync_queue(q); blk_mq_cancel_work_sync(q); From patchwork Sun Oct 30 05:26:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 12822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1660303wru; Sat, 29 Oct 2022 23:09:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56hg8Eg23YQjUjGc696xu7eyV2txs2ZX6nT2XgoWfVP9w+YYOE1EMKcuTUMo6Gqrsku2/A X-Received: by 2002:a17:902:bc83:b0:187:85a:28b4 with SMTP id bb3-20020a170902bc8300b00187085a28b4mr5815375plb.96.1667110150029; Sat, 29 Oct 2022 23:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667110150; cv=none; d=google.com; s=arc-20160816; b=l6AIdHxzwNnBSs6udsxJQQusBdf70Zjk5bOGzSBOtytLF+rhUdVb0SCPWbVCMxDOjx pt787hdXI1TFMy+Tr4LBACBYlBy7hRjlghcHMzB+8XE5erKMV3hyFwU8ON5XEjROFoXn mrwr3NK6d+Vh5+D87gqhpUri/g7CN5AJSR67rAdYR1V/2Ube17cDFW5/2XLqqh6kFOL7 KX9L2Ayi7Wir/GVxFsRBrBl3QP+shBCFVnYAjBLSQV158+G97W3uxqyfhvLfPVzZHIZv 5hPbGUhx5No4OWqS8xgokE4um8dFlXLnG58dLVCIeIBFR39bJRbQ5ghxtxl+KFZ4k4Xj bywg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Zw9CjljdymJxQA8GSqf36K/IXuBD8Q74dv97X7w68n4=; b=ufSQvDgakWrFn3yH2YmEDKRo+JXEP931gB8AwH+TyBHnm/IzlrJ8YrzSvtMUwE1/6B 0RLczvIQCPhGSJ5WzHjuu8ZMDjiBcSXAykBtB4hEVjYVXTmO+GAo33atNmeXgfoBecjx 7t/kVwiIXO9yOzhK/NlIJBg5T3uIob0ekXCiF8NBnZD/694GZFQmsHtNHmNfBV1iRyEi MNlTSbgdkfHrv7w1KeK3v7m6QUqhYsyr6EnIi77tW4HllVvVWM2nl7IYg5SqKyT5se+t YS54sIKvP361ZOG4f22KzPkJbGtept63K7oZMyzNJwvn9oOCYj6830w+RwIYuRCxVL2J IfVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y24-20020a63e258000000b004525a153e80si4703464pgj.445.2022.10.29.23.08.57; Sat, 29 Oct 2022 23:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbiJ3F17 (ORCPT + 99 others); Sun, 30 Oct 2022 01:27:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJ3F1u (ORCPT ); Sun, 30 Oct 2022 01:27:50 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43BA03B991; Sat, 29 Oct 2022 22:27:47 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app3 (Coremail) with SMTP id cC_KCgBn3qlCC15jnGV2CA--.28011S4; Sun, 30 Oct 2022 13:27:38 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: bvanassche@acm.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, nickyc975@zju.edu.cn Subject: [RESEND PATCH v2 2/3] blk-mq: remove blk_freeze_queue Date: Sun, 30 Oct 2022 13:26:45 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cC_KCgBn3qlCC15jnGV2CA--.28011S4 X-Coremail-Antispam: 1UD129KBjvJXoW7uFy3AF4rXr18ZrWruFyrtFb_yoW8Zr1xpF ZxJF47Cw1Iqr4UXrW8Jw47Xr9Iga18Kry7C3ySy3yYvrnIkFn2vF18A3W8uF40yrZ5JFsr ZrWqgrZxAr18CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI 7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgsTB1ZdtcKSqwAAsY X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748091692534893142?= X-GMAIL-MSGID: =?utf-8?q?1748091692534893142?= Nobody is calling blk_freeze_queue except its alias, so remove it. Signed-off-by: Jinlong Chen --- block/blk-mq.c | 18 +----------------- block/blk.h | 1 - 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 14c4165511b9..e0654a2e80b9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -194,27 +194,11 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait_timeout); * Guarantee no request is in use, so we can change any data structure of * the queue afterward. */ -void blk_freeze_queue(struct request_queue *q) +void blk_mq_freeze_queue(struct request_queue *q) { - /* - * In the !blk_mq case we are only calling this to kill the - * q_usage_counter, otherwise this increases the freeze depth - * and waits for it to return to zero. For this reason there is - * no blk_unfreeze_queue(), and blk_freeze_queue() is not - * exported to drivers as the only user for unfreeze is blk_mq. - */ blk_freeze_queue_start(q); blk_mq_freeze_queue_wait(q); } - -void blk_mq_freeze_queue(struct request_queue *q) -{ - /* - * ...just an alias to keep freeze and unfreeze actions balanced - * in the blk_mq_* namespace - */ - blk_freeze_queue(q); -} EXPORT_SYMBOL_GPL(blk_mq_freeze_queue); void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic) diff --git a/block/blk.h b/block/blk.h index 7f9e089ab1f7..e9addea2838a 100644 --- a/block/blk.h +++ b/block/blk.h @@ -37,7 +37,6 @@ struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, gfp_t flags); void blk_free_flush_queue(struct blk_flush_queue *q); -void blk_freeze_queue(struct request_queue *q); void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic); void blk_queue_start_drain(struct request_queue *q); int __bio_queue_enter(struct request_queue *q, struct bio *bio); From patchwork Sun Oct 30 05:26:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 12821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1659265wru; Sat, 29 Oct 2022 23:06:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6l8YdiESA44gyhBlSGty9pTMxrFFGY+Ls8ZkKbPg9/JLCZcTncdFQVuqWoSvNCODIchz5d X-Received: by 2002:a17:90b:254e:b0:20b:7e26:f0a0 with SMTP id nw14-20020a17090b254e00b0020b7e26f0a0mr24761026pjb.203.1667109976272; Sat, 29 Oct 2022 23:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667109976; cv=none; d=google.com; s=arc-20160816; b=Scnyhs0cqJlbXr7LiqyuqK7QnlkflgAYI+gXQICxTK3gIY/CUFDdRMIvk9oGO2J+WQ 6vFwRJX91R+3iZw1QoufwftXZLEYZMEdAfx3Omjc0CTXj7asXbXZU/r7scnUnn8n6OLr 1jJJIYf+SVDI44J4RiVL+vaVEY3WCAugEMspnL5btI6MlF5wLqoP80RWJcWdpRrtoUUY V1T3JiFfuM8wVtDbaxoA6QoHTO8tGBJN+iSjI85O/IhYWjG+6YEcwVJGCmAYbv3/f0mF lSGTraJTvVfo2iIlKeWYCr/38GUZr1hIEFC9poTkgakJPJ44sYa+deXEsNyU5R4i+mmV 7+Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ayrnYu7xAqKNsYJn/4yLotE7DaelTIhvopEludcEbh0=; b=KYSznBvhN8KMFtQ+oSSX++NGtSkxGKIS8AeuLs94HrOKV+DbrgvXsI+9lTM/6CWFuJ QZ1buASvhE/jmst+dCHhAXHQvJfW/nyG5De8J0Qgj702YH3xnAzrsy2ZKbXr6nUJTMjV rCGw7ns9IpK+QrDEfiPRNLfSTiF79XiZ6XjiwsCWTcOXnydSx+NCCVkW9jDSBsQcRAOY JPKV12x78gRvufBgPJPa5+W666uKx3/JsBbowHWj3/R+V1eUWvOSAydEhI295tVrqTzW g98lNURX0s/YsQerYAmJ6o4CoXwsZTQNfngnSzYzdM3/X0it3+4O3pJXSb/QIRrO9tk/ czkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y24-20020a63e258000000b004525a153e80si4703464pgj.445.2022.10.29.23.05.46; Sat, 29 Oct 2022 23:06:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiJ3F2A (ORCPT + 99 others); Sun, 30 Oct 2022 01:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiJ3F1u (ORCPT ); Sun, 30 Oct 2022 01:27:50 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A92573A14B; Sat, 29 Oct 2022 22:27:47 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app3 (Coremail) with SMTP id cC_KCgBn3qlCC15jnGV2CA--.28011S5; Sun, 30 Oct 2022 13:27:39 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: bvanassche@acm.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, nickyc975@zju.edu.cn Subject: [RESEND PATCH v2 3/3] block: hide back blk_freeze_queue_start and export its blk-mq alias Date: Sun, 30 Oct 2022 13:26:46 +0800 Message-Id: <3f2b51cc7f5c21e49bfa089e594cb203a4015183.1667107410.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cC_KCgBn3qlCC15jnGV2CA--.28011S5 X-Coremail-Antispam: 1UD129KBjvJXoW3Xr1xCw1UZF4rGF45Ary5Arb_yoW7Kry8pF ZxXa13Aw10gr4UXrW8Jw47Zr9xKw4vg347C3yftryYvrn8Kas3ZF17A3W5XF48ArWkCFs8 ArWDKrsrCr18JrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI 7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgcTB1ZdtcKSqgADsW X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748091510432515194?= X-GMAIL-MSGID: =?utf-8?q?1748091510432515194?= blk_freeze_queue_start is used internally for universal queue draining and externally for blk-mq specific queue freezing. Keep the non-blk-mq name private and export a blk-mq alias to users. Signed-off-by: Jinlong Chen --- block/blk-core.c | 13 +++++++++++++ block/blk-mq.c | 27 ++++++++++++++------------- block/blk-pm.c | 2 +- block/blk.h | 1 + drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 2 +- include/linux/blk-mq.h | 2 +- 7 files changed, 32 insertions(+), 17 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 5d50dd16e2a5..d3dd439a8ed4 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -269,6 +269,19 @@ void blk_put_queue(struct request_queue *q) } EXPORT_SYMBOL(blk_put_queue); +void blk_freeze_queue_start(struct request_queue *q) +{ + mutex_lock(&q->mq_freeze_lock); + if (++q->mq_freeze_depth == 1) { + percpu_ref_kill(&q->q_usage_counter); + mutex_unlock(&q->mq_freeze_lock); + if (queue_is_mq(q)) + blk_mq_run_hw_queues(q, false); + } else { + mutex_unlock(&q->mq_freeze_lock); + } +} + void blk_queue_start_drain(struct request_queue *q) { /* diff --git a/block/blk-mq.c b/block/blk-mq.c index e0654a2e80b9..d638bd0fb4d8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -161,19 +161,20 @@ void blk_mq_in_flight_rw(struct request_queue *q, struct block_device *part, inflight[1] = mi.inflight[1]; } -void blk_freeze_queue_start(struct request_queue *q) +void blk_mq_freeze_queue_start(struct request_queue *q) { - mutex_lock(&q->mq_freeze_lock); - if (++q->mq_freeze_depth == 1) { - percpu_ref_kill(&q->q_usage_counter); - mutex_unlock(&q->mq_freeze_lock); - if (queue_is_mq(q)) - blk_mq_run_hw_queues(q, false); - } else { - mutex_unlock(&q->mq_freeze_lock); - } + /* + * Warn on non-blk-mq usages. + */ + WARN_ON_ONCE(!queue_is_mq(q)); + + /* + * Just an alias of blk_freeze_queue_start to keep the consistency of the + * blk_mq_* namespace. + */ + blk_freeze_queue_start(q); } -EXPORT_SYMBOL_GPL(blk_freeze_queue_start); +EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start); void blk_mq_freeze_queue_wait(struct request_queue *q) { @@ -196,7 +197,7 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait_timeout); */ void blk_mq_freeze_queue(struct request_queue *q) { - blk_freeze_queue_start(q); + blk_mq_freeze_queue_start(q); blk_mq_freeze_queue_wait(q); } EXPORT_SYMBOL_GPL(blk_mq_freeze_queue); @@ -1570,7 +1571,7 @@ static void blk_mq_timeout_work(struct work_struct *work) * percpu_ref_tryget directly, because we need to be able to * obtain a reference even in the short window between the queue * starting to freeze, by dropping the first reference in - * blk_freeze_queue_start, and the moment the last request is + * blk_mq_freeze_queue_start, and the moment the last request is * consumed, marked by the instant q_usage_counter reaches * zero. */ diff --git a/block/blk-pm.c b/block/blk-pm.c index 2dad62cc1572..ae2b950ed45d 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -80,7 +80,7 @@ int blk_pre_runtime_suspend(struct request_queue *q) blk_set_pm_only(q); ret = -EBUSY; /* Switch q_usage_counter from per-cpu to atomic mode. */ - blk_freeze_queue_start(q); + blk_mq_freeze_queue_start(q); /* * Wait until atomic mode has been reached. Since that * involves calling call_rcu(), it is guaranteed that later diff --git a/block/blk.h b/block/blk.h index e9addea2838a..ee576bb74382 100644 --- a/block/blk.h +++ b/block/blk.h @@ -37,6 +37,7 @@ struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, gfp_t flags); void blk_free_flush_queue(struct blk_flush_queue *q); +void blk_freeze_queue_start(struct request_queue *q); void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic); void blk_queue_start_drain(struct request_queue *q); int __bio_queue_enter(struct request_queue *q, struct bio *bio); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0090dc0b3ae6..e2d5c54c651a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5199,7 +5199,7 @@ void nvme_start_freeze(struct nvme_ctrl *ctrl) down_read(&ctrl->namespaces_rwsem); list_for_each_entry(ns, &ctrl->namespaces, list) - blk_freeze_queue_start(ns->queue); + blk_mq_freeze_queue_start(ns->queue); up_read(&ctrl->namespaces_rwsem); } EXPORT_SYMBOL_GPL(nvme_start_freeze); diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 0ea7e441e080..3bb358bd0cde 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -77,7 +77,7 @@ void nvme_mpath_start_freeze(struct nvme_subsystem *subsys) lockdep_assert_held(&subsys->lock); list_for_each_entry(h, &subsys->nsheads, entry) if (h->disk) - blk_freeze_queue_start(h->disk->queue); + blk_mq_freeze_queue_start(h->disk->queue); } void nvme_failover_req(struct request *req) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 569053ed959d..8600d4b4aa80 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -887,7 +887,7 @@ void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset); void blk_mq_freeze_queue(struct request_queue *q); void blk_mq_unfreeze_queue(struct request_queue *q); -void blk_freeze_queue_start(struct request_queue *q); +void blk_mq_freeze_queue_start(struct request_queue *q); void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout);