From patchwork Wed Nov 2 03:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 14006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3361571wru; Tue, 1 Nov 2022 20:09:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+klB7uYd/oPjbhUaRwj3Z+V+b+B+J11PYwCeNj/fsHMmJbij+679ZTKpCiBQA0abLvy7t X-Received: by 2002:a63:1861:0:b0:462:4961:9a8f with SMTP id 33-20020a631861000000b0046249619a8fmr20071424pgy.372.1667358563905; Tue, 01 Nov 2022 20:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667358563; cv=none; d=google.com; s=arc-20160816; b=WCrs6LBxkZ4P3x2DUas06oIuucAyoSYwU8Yx6t3j+x2Bozu6ZwYmYa3HAIKSj5s/j7 uVw3gphcd+TVkD5eJAKO7f8+awNE1r6JwxNCoDyCNaSVKokHt6cxco21f2WnrdAh9pIc RoXKnQJysSarMEd47WhYzLjENpQbHDr4yrZK5XQCyDSmCA9HyUKB1x25Jvbs/vjORWpV 8jasOO9Y1sYEZX2rJ2PhZQErheVIkpvFqSlgGXeKbtZpt28IVrFMXpVpif9PZt2cFTtr j426B/mauf7e1nOsOQ2jBMHdcJl4D8Tbwc2/g7XTZFxPPPmc623qvsfr4UQTrYZnWFmI yYNw== 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=suAXK830rUf8u1KXzy+z+6h+5TKjCJJHqaBa3yv7rkk=; b=cVYHgt2j1vOODWRODp6+f5vaSwPRIf/logJ4ZHTL25cyPm1LO5l64sZI3uG++vmMMO 9cqQY7oLJi4YyvMl6GK9o2YNuRikUEdCpGn6afpAHxFhGFLZfYtjo2OT6wW1jP9EFdWX zumHbrSst+ep5UjXGJ8RaQwqmiSVAvH/C+grDlo8QU2cq3uq0VI2j0/1YbZtDmJjfopy TD9MhPpgjafgqrfz6rVSNlkwESG+PE0jVy1jU4Igliqaq2Un2LeTCLrUtck4+gXUrTRU ACqL3J3OFOm8U8jjaSM+/HdDeH2mo4LTg0m2A1NP5F4tMwf8xzYG4XHqQOc3Qz/4Ugh9 wODw== 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 l31-20020a635b5f000000b00460b572d264si14285982pgm.579.2022.11.01.20.09.11; Tue, 01 Nov 2022 20:09:23 -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 S230302AbiKBDGw (ORCPT + 99 others); Tue, 1 Nov 2022 23:06:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbiKBDGX (ORCPT ); Tue, 1 Nov 2022 23:06:23 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EC73E23EB1; Tue, 1 Nov 2022 20:06:22 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app2 (Coremail) with SMTP id by_KCgA3PSGf3mFjz_9cBw--.7456S3; Wed, 02 Nov 2022 11:06:16 +0800 (CST) From: Jinlong Chen To: axboe@kernel.dk Cc: hch@lst.de, chaitanyak@nvidia.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nickyc975@zju.edu.cn Subject: [PATCH v3 1/2] blk-mq: improve error handling in blk_mq_alloc_rq_map() Date: Wed, 2 Nov 2022 11:06:04 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: by_KCgA3PSGf3mFjz_9cBw--.7456S3 X-Coremail-Antispam: 1UD129KBjvdXoW7GF43Gw13Ar1UCw4UuryxGrg_yoWkZwc_Cr y0kw1vvFyUAr1Fkw4q9r15Ar97CanakF40vFWDK3srJ3s7GanrAa9xZrnxJrZ7Ww4xWFWx Gw1kZr1Fkr15tjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb-8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26rxl6s0DM28EF7xvwVC2z280 aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwV AKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v2 6r126r1DMxAIw28IcxkI7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxV CFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r10 6r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxV WUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG 6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr 1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvg4fUUUUU= X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgoCB1ZdtcNVXAAMs1 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?1748352173913436008?= X-GMAIL-MSGID: =?utf-8?q?1748352173913436008?= Use goto-style error handling like we do elsewhere in the kernel. Signed-off-by: Jinlong Chen Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 623e8a506539..453ad445a6bd 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3274,21 +3274,22 @@ static struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, 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); + return NULL; } static int blk_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,