From patchwork Tue Nov 1 15:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 13743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3045484wru; Tue, 1 Nov 2022 08:38:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ke5mMYxAupzguYA8w/WgvmNce7Qd2CV92XzYMqhBLhQteCG8g+vn7wvaaVFmL9AqqT3pM X-Received: by 2002:a05:6402:1cc1:b0:453:1517:94e4 with SMTP id ds1-20020a0564021cc100b00453151794e4mr19771205edb.399.1667317136559; Tue, 01 Nov 2022 08:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667317136; cv=none; d=google.com; s=arc-20160816; b=yGoq22eZ1zbS/BiFk+VXg8ywvSxPs6pwRXPM0WkDqsmRNozpR4suixvTcxhRZp2jMm 9j/+6oljHxzflCc8z8ud8MA6CLtjwjuMezGovhZEJs8HGjKeAHB9WdN01Saiy2Zn1II9 U89sGPJv5FiznHJA7pbAIwBA4Fk4wucTfPaav2ib39+JuNwGahca6oJvXaz52YrOF2WX 0D1iLHpUlTXYMTKx6QGq2N3Jb4lKW3sXWPPV7AGmrDL+wEWiqwnw/Pva2BerWdz4TG0u ZfswNBVTlmU0/dt6t5VFs7CtwTIsZhfQFEIyHDM+ELMyHan/Lw8M164S+qZXYI0pZZIQ hBPA== 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=YJEebztGfhblnOOM5MXmIlHEVRQP9WZmdHxPzcR8pFY=; b=Ri4XZxdQVq99pt93CPYh46RxZnhfC4yVh7wF0b9G/W8d/Jfhd+2CWLekNFHdfseqJF PDThZzeqSMdfckax9Yhzrk3Pcr+ZKKJL7QahyLhadpkxBV+6sJKqZ9bBCjzQSm9STEqx xVPgU8gr5y9NBnquL4DAUSqJxBH91O5wvVy3wicf0LnyOjQT1Sh85Zna4HNFlGWeQaQS MVfVmsTu6w9126/+vGTUml0DiWjEHgzMALnAibhFSqDtQ4jAFRVZK/6taF9HiJtGuS20 4AHdBog5SowK/B8fBtk2vRBAcnTsvZ3ARLrKU9uMbJ0Qjy6gwXqW63vGllJdM3tmBdXy 3Mrg== 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 hq42-20020a1709073f2a00b007a1d4f0e7fcsi13201544ejc.655.2022.11.01.08.38.33; Tue, 01 Nov 2022 08:38:56 -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 S230291AbiKAPPa (ORCPT + 99 others); Tue, 1 Nov 2022 11:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbiKAPPH (ORCPT ); Tue, 1 Nov 2022 11:15:07 -0400 Received: from zju.edu.cn (mail.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E3411BE93; Tue, 1 Nov 2022 08:12:04 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app4 (Coremail) with SMTP id cS_KCgCH_k0qN2FjsHmtBw--.39315S3; Tue, 01 Nov 2022 23:12:02 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk Cc: hch@lst.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nickyc975@zju.edu.cn Subject: [PATCH 1/4] blk-mq: update comment for blk_mq_quiesce_queue_nowait() Date: Tue, 1 Nov 2022 23:11:34 +0800 Message-Id: <489a9322eed1f95f8770752cc715084f1fa961d3.1667314759.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cS_KCgCH_k0qN2FjsHmtBw--.39315S3 X-Coremail-Antispam: 1UD129KBjvdXoWrtFy8Kry7Ww15Xr4xKryUZFb_yoWkCFg_Gw 1qvr10kFs8Gr1a9F4YkFW5ZFWrKay8JF43JFWIg39xX3s2yFsxA3y29r15CrZ3WanrGa13 Jr4UWa43Ar4SgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbIAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E 87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6c xK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij 64vIr41l42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyT uYvjfUOlksUUUUU X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgIAB1ZdtcLuXwAGsM 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?1748308733687475239?= X-GMAIL-MSGID: =?utf-8?q?1748308733687475239?= blk_mq_quiesce_queue_nowait() is now reasonably used by scsi_host_block() to avoid calling synchronize_rcu() for each LUN. We should not consider to remove it. See commit f983622ae60516d634008c7b1ff9ffff4f7bb8ae ("scsi: core: Avoid calling synchronize_rcu() for each device in scsi_host_block()") Signed-off-by: Jinlong Chen --- block/blk-mq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 623e8a506539..7ceceea91b3b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -237,9 +237,12 @@ void blk_mq_unfreeze_queue(struct request_queue *q) } EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue); -/* - * FIXME: replace the scsi_internal_device_*block_nowait() calls in the - * mpt3sas driver such that this function can be removed. +/** + * blk_mq_quiesce_queue_nowait() - start the quiesce of the queue + * @q: request queue. + * + * Note: synchronize_rcu() or synchronize_srcu(q->srcu) needs to + * be called to ensure the quiesce is done. */ void blk_mq_quiesce_queue_nowait(struct request_queue *q) { From patchwork Tue Nov 1 15:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 13744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3045797wru; Tue, 1 Nov 2022 08:39:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56rsUQyMBZ4dAWakEl2wv1XpqG3kmZN+WyYIpJPCxVxlj6Duger8Cm0RLUYyGQaUaI1TwJ X-Received: by 2002:a17:907:86a4:b0:7ab:afe4:5a94 with SMTP id qa36-20020a17090786a400b007abafe45a94mr18876984ejc.7.1667317177683; Tue, 01 Nov 2022 08:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667317177; cv=none; d=google.com; s=arc-20160816; b=05jJBeA/iSaQAkXGjjAZ+z4CmJH44zZzeCLweDWvttR5il+Ynnk+YFnZKBZ8T43Pwm WLUN7+P2+zGw87ZcB0bLb+ggEV3hIAKK89dp9KiOcLlKS99I9ijqqODAWlwu1AIq3bc7 XLwDIT+7csfVu7qPraEOvaVirObhBdhlxuuUpSpCCFG3gJZQFLMi3RPrBVSzdDt5eoHG vP+8vd/tFiSjBJtfUJMZayKOuf0evrji4KVS0LeNb5coqBvJ6da1oLTVWGLHO51dkMaF 6KeVI7poXYEzBapAUomFrX+F/y0Ds9/qVvTf8xBW3ZKFL+S1oBD8IdqAEQ991boIYH47 lYIA== 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=1dOgVScZPQ/4ypDrcot3WEqiE/bSv0BCIVRn/zF727Q=; b=bubJE0usqPbiZZMREg982YMon6GuneGWpPVnE3KVS1jl/KSRjnrKm5VT9lY+KYAJyZ qM3nphEK48FH47Bd4FLTZCTkUu17WpakWrgqvlNUilOIA3gUeE0vd5NN7mn5c5bxmykS HSXXFYaEWFbZlk5ewaO/tpLSqGqrjGPtWbiV5LAU5M0IddR8sd7tNpgIs/wfvpNrXdO0 INO9nvvDmXaOpGqC+aoV5jlSFi75fWgXYQIYOkf7GBrGyyCOpsjCQjs+fh0dEWhj/YNj sf6h6JTkSoZ0mP+qiX00urc0XEL+K6MOAddKmY2pr1EWHQ/DdpzAU1AZuyeecgfUjDaN fKww== 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 hp38-20020a1709073e2600b00791a41d1b39si14708752ejc.656.2022.11.01.08.39.13; Tue, 01 Nov 2022 08:39:37 -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 S231540AbiKAPPf (ORCPT + 99 others); Tue, 1 Nov 2022 11:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbiKAPPH (ORCPT ); Tue, 1 Nov 2022 11:15:07 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 827B41BE9D; Tue, 1 Nov 2022 08:12:07 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app4 (Coremail) with SMTP id cS_KCgCH_k0qN2FjsHmtBw--.39315S4; Tue, 01 Nov 2022 23:12:02 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk Cc: hch@lst.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nickyc975@zju.edu.cn Subject: [PATCH 2/4] blk-mq: improve error handling in blk_mq_alloc_rq_map() Date: Tue, 1 Nov 2022 23:11:35 +0800 Message-Id: <992db53bdeaba35d37de3784fe6f80879c9bbb35.1667314759.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cS_KCgCH_k0qN2FjsHmtBw--.39315S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw4kKr1rWr4rAr4fKr45Wrg_yoW8Gr13pF 45Ga1DKa43JF17Xan7tay8XF1FkFs2gw4xG3Wft390vrn0kr4IyFn5ZFyjvr1FkrWkCrs3 Cr4DKFyUWF4UJwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI 7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgIAB1ZdtcLuXwAIsC 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?1748308777001369623?= X-GMAIL-MSGID: =?utf-8?q?1748308777001369623?= Use goto-style error handling like we do elsewhere in the kernel. Signed-off-by: Jinlong Chen --- block/blk-mq.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 7ceceea91b3b..408a929be90e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3272,26 +3272,28 @@ static struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, tags = blk_mq_init_tags(nr_tags, reserved_tags, node, BLK_MQ_FLAG_TO_ALLOC_POLICY(set->flags)); if (!tags) - return NULL; + goto err_out; tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *), GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, node); - if (!tags->rqs) { - blk_mq_free_tags(tags); - return NULL; - } + if (!tags->rqs) + goto err_free_tags; tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *), GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, node); - if (!tags->static_rqs) { - kfree(tags->rqs); - blk_mq_free_tags(tags); - return NULL; - } + if (!tags->static_rqs) + goto err_free_rqs; return tags; + +err_free_rqs: + kfree(tags->rqs); +err_free_tags: + blk_mq_free_tags(tags); +err_out: + return NULL; } static int blk_mq_init_request(struct blk_mq_tag_set *set, struct request *rq, From patchwork Tue Nov 1 15:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 13746 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3045847wru; Tue, 1 Nov 2022 08:39:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kGNcOANrI/7IOD3YEeZ/yvnkklUjzMuOkTPz2ODrvvILZAR2WjbJRv9GrlWMLx9QjLYTV X-Received: by 2002:a17:906:1ec5:b0:78d:b3d1:183b with SMTP id m5-20020a1709061ec500b0078db3d1183bmr19084096ejj.709.1667317188523; Tue, 01 Nov 2022 08:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667317188; cv=none; d=google.com; s=arc-20160816; b=xP4nDLhjR0rP/7K53ZGW5JLnlCsnu6lf+ZGXGWbvns0ulEuUz5NChMUCri9liThi5m R08rLmS5lu6MRLYl38aNURyy6jBK4OxitTZyhNf+TSwyPp3Amzq0LrcR7/5Cp8Ht6S7F cY8UrPquVQDzav7KABzZcVB0ayPbPeF5lwhch8B1kCTR58kSlO9OFid374OyfITi4EuS c6jVRitO1YxWqL1wiG+WDGeKMLayfRefgFqMWEIAJz1GjKeGkRsd67LS5bqGb8qiUfjk OSEeB0Aw6bGkRCS/co5Y+Q4K+JuFBKrHcpAKOHeK66TDNqkYIYCQFCQ3jnxuN6NwLAQp qq9A== 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=Q1XFrKt+FHTCBRIgSitMX+MMPz1zZt6Grogp3a9CHHo=; b=Q3jsmtnls9IHman5VCfLEczkyI/nS+ZS0ut7+tBCqkXd5XR2qB3JdgSxCd0kGze8kp YEqZcHQza2Vi4tgKaNXbhIXrEWbq1PAs70HqsHtePOcqGoTWcIgm9nkR/h5Kyw1sa6sF a+6Gswnip4XMGgClJ07XjktvBj1FeD7IXPAiWqveVOegGBuaPAAQ+iEXKLs5M0xWY9u6 Muz/ajwUL6ON7UG1JbswE6h+chLUq/rFGdxAIIxY0clMLO48KZGd1Hw3la2ZA3TarOOy nOvYCtEleTOnpA+5URwEoloOfPUTA+5chRUiT36wBc0meruNBHeqezuQFimje61XjDPi 5u6w== 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 go44-20020a1709070dac00b0073d92f83e06si13847238ejc.887.2022.11.01.08.39.24; Tue, 01 Nov 2022 08:39:48 -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 S231560AbiKAPPj (ORCPT + 99 others); Tue, 1 Nov 2022 11:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiKAPPI (ORCPT ); Tue, 1 Nov 2022 11:15:08 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2390186C6; Tue, 1 Nov 2022 08:12:09 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app4 (Coremail) with SMTP id cS_KCgCH_k0qN2FjsHmtBw--.39315S5; Tue, 01 Nov 2022 23:12:03 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk Cc: hch@lst.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nickyc975@zju.edu.cn Subject: [PATCH 3/4] blk-mq: use if-else instead of goto in blk_mq_alloc_cached_request() Date: Tue, 1 Nov 2022 23:11:36 +0800 Message-Id: <8c2ebea324addffbe799eea1958214f6d89b5aad.1667314759.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cS_KCgCH_k0qN2FjsHmtBw--.39315S5 X-Coremail-Antispam: 1UD129KBjvJXoW7AF4kZF15XFWfWrWkXw45GFg_yoW8Jw15pF sxJa4qvrWFgF1xWa18Aa1fJa1rAF1rGF9rCa43Awn8Zw45Cr4UJrn7ArWFqFWSyFZ5CFWx Krs8Gas5uF48XrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI 7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgcBB1ZdtcNFuAAAsD 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?1748308787900225536?= X-GMAIL-MSGID: =?utf-8?q?1748308787900225536?= if-else is more readable than goto here. Signed-off-by: Jinlong Chen Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 408a929be90e..87a6348a0d0a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -547,25 +547,26 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, if (!plug) return NULL; + if (rq_list_empty(plug->cached_rq)) { if (plug->nr_ios == 1) return NULL; rq = blk_mq_rq_cache_fill(q, plug, opf, flags); - if (rq) - goto got_it; - return NULL; - } - rq = rq_list_peek(&plug->cached_rq); - if (!rq || rq->q != q) - return NULL; + if (!rq) + return NULL; + } else { + rq = rq_list_peek(&plug->cached_rq); + if (!rq || rq->q != q) + return NULL; - if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) - return NULL; - if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) - return NULL; + if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) + return NULL; + if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) + return NULL; + + plug->cached_rq = rq_list_next(rq); + } - plug->cached_rq = rq_list_next(rq); -got_it: rq->cmd_flags = opf; INIT_LIST_HEAD(&rq->queuelist); return rq; From patchwork Tue Nov 1 15:11:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 13745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3045806wru; Tue, 1 Nov 2022 08:39:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ycxzB/fuzJZ7kV8vBDBtvOujaLvl+6tqYPDFrmBsqivEqSp5e7sFUzkEMwB909V02/1Ra X-Received: by 2002:a05:6a00:234d:b0:561:ec04:e77e with SMTP id j13-20020a056a00234d00b00561ec04e77emr20820504pfj.14.1667317179247; Tue, 01 Nov 2022 08:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667317179; cv=none; d=google.com; s=arc-20160816; b=KgZAII/HNpZ4ntRgdFquc42VwKBAYuLuwJ8Bmu5iZmU+y3ZIIV5vZWpkuShVsZf4S2 zs/tK8iUHoWcnEp1rAKNRzoqh4BlLBGoo+4X8TlWNluljz+0ODZ0Itq6Pr1EmEYeIP/G 6KCMLyXY94LWUtmJRn5cEfSyq7jel7e2RiVa4ZOJZIHX9xUFLUbeS8ENGuIOYGIIQfdz XSYm9A/Oe946JzwEe6hVPl+2qm/wmYKZme7J3Wu8f808q92LdfgsthYbPYBwU6Wvwt/Q v3F17FZ2j2dxShNIiWE8sFOUvvg33g1bpIvzLXuyNFMn00ZOr6sdTaQ822YMuPsJOTqz HMkg== 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=y2I8CsF6oRKvuwpfeAw2V4gCxCaX1v7eOTUtF+r2WCI=; b=mWR8pwvK8VqDi0HUz8+vKMWUziM17TRdByuV9jZKyt8Z4Cueb5XTTUZlyvhdCRpwFk ttc+TXUj2sJ+f23KlI3VUEaBBWOC92SZEBVEnygxCF94rJ8geFM+hyzen2TAmBZpxWuV kVMm/Y+Fz0+aW6IOkTmD5hfqqFlMPEaqjdsgdy8f+QsvNp7rszzuDfiWn0b1NvnegZfz STkvdT6TTRq81tT5YBd61VnFrt9UJ/3o1ifwvM46t8tjVZPioPzlk2L+8gm1M3PzS1K9 a2/wPsq30WAR+H+98EdUyPv0RljlBUIGKnAf67ae2MImbEzB8oAIyH0+6WyqoFz3ww3r rDwg== 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 u9-20020a170902e80900b00184306292a5si14574472plg.229.2022.11.01.08.39.26; Tue, 01 Nov 2022 08:39:39 -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 S230465AbiKAPPm (ORCPT + 99 others); Tue, 1 Nov 2022 11:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbiKAPPI (ORCPT ); Tue, 1 Nov 2022 11:15:08 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25EED15829; Tue, 1 Nov 2022 08:12:08 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app4 (Coremail) with SMTP id cS_KCgCH_k0qN2FjsHmtBw--.39315S6; Tue, 01 Nov 2022 23:12:04 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk Cc: hch@lst.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nickyc975@zju.edu.cn Subject: [PATCH 4/4] blk-mq: improve readability of blk_mq_alloc_request() Date: Tue, 1 Nov 2022 23:11:37 +0800 Message-Id: <81fcbc046c9ea96cdfd8e20d1edc8e64c4d08153.1667314759.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: cS_KCgCH_k0qN2FjsHmtBw--.39315S6 X-Coremail-Antispam: 1UD129KBjvJXoW7uw13GF43Zry5WF45ur17Jrb_yoW8ZryfpF WfJayakF90gr1xWFWxJw43Jr1agr4I9Fy7A3W3Jw1Fvr95Kw4kCF18XFW0vrySyrWkCF47 GFn8tryDuF1xZa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24V AvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI 7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgIAB1ZdtcLuXwALsB 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?1748308778689838042?= X-GMAIL-MSGID: =?utf-8?q?1748308778689838042?= Add a helper blk_mq_alloc_request_nocache() to alloc request without cache. This makes blk_mq_alloc_request() more readable. Signed-off-by: Jinlong Chen --- block/blk-mq.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 87a6348a0d0a..2fae111a42c8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -572,36 +572,47 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, return rq; } -struct request *blk_mq_alloc_request(struct request_queue *q, blk_opf_t opf, - blk_mq_req_flags_t flags) +static struct request *blk_mq_alloc_request_nocache(struct request_queue *q, + blk_opf_t opf, blk_mq_req_flags_t flags) { - struct request *rq; - - rq = blk_mq_alloc_cached_request(q, opf, flags); - if (!rq) { - struct blk_mq_alloc_data data = { + struct blk_mq_alloc_data data = { .q = q, .flags = flags, .cmd_flags = opf, .nr_tags = 1, }; - int ret; + struct request *rq; + int ret; - ret = blk_queue_enter(q, flags); - if (ret) - return ERR_PTR(ret); + ret = blk_queue_enter(q, flags); + if (ret) + return ERR_PTR(ret); - rq = __blk_mq_alloc_requests(&data); - if (!rq) - goto out_queue_exit; + rq = __blk_mq_alloc_requests(&data); + if (!rq) { + rq = ERR_PTR(-EWOULDBLOCK); + blk_queue_exit(q); } + + return rq; +} + +struct request *blk_mq_alloc_request(struct request_queue *q, blk_opf_t opf, + blk_mq_req_flags_t flags) +{ + struct request *rq; + + rq = blk_mq_alloc_cached_request(q, opf, flags); + if (!rq) { + rq = blk_mq_alloc_request_nocache(q, opf, flags); + if (IS_ERR(rq)) + return rq; + } + rq->__data_len = 0; rq->__sector = (sector_t) -1; rq->bio = rq->biotail = NULL; - return rq; -out_queue_exit: - blk_queue_exit(q); - return ERR_PTR(-EWOULDBLOCK); + return rq; } EXPORT_SYMBOL(blk_mq_alloc_request);