From patchwork Wed Nov 2 03:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinlong Chen X-Patchwork-Id: 14005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3361569wru; Tue, 1 Nov 2022 20:09:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yfr53z9+WMJ1QZHAl0TeHMa/wC9M8rDNbB7aQ7/EricVAeSbuDMDDTa+KxdXRJ/sjLSmC X-Received: by 2002:a63:7909:0:b0:458:1ba6:ec80 with SMTP id u9-20020a637909000000b004581ba6ec80mr19985452pgc.414.1667358563509; 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=oClaWWECKXLnRwEdJdjvpQQ6p/fN8T4ImelKDr0pYqHaTGwranpzwfeQW1boZpQnqt 0bqqOWXHnuYvhBWvHsUreCNFnoJdYq+UsZxX/+AkNdQ6WoCMD/rvVu66x5TOapAVM3Sg q9SMJGyNXjHPotpvRvaDKJiY2q74DW2gy/MVM7DzmQ4qLAT79SV9aUYGCLouXokcLaja dOPoxQFWpZYJLaSllnYkdBMLl7RKHi4WVsCMNyluUvcLe9iUzt/H2BkvlRcSVBEefmPz OWngyZ4BYNIl4ekRcHVaE8nYCpq3YRCBMRYGRLltzwqJoVADCPIy+70CCwLvRdZmQ0yn daQQ== 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=oJaFX61pFHcWFt+iEveXJVYl24WHCzrlm1We3OXZeEY=; b=CaXyaxQ1LO4Z1Y1HhLkYNE1sNdGxuIsf/gSVWUuWzNjTrX3K2H0l2FKqYZnCrrloGW jbkVEPJXC0LXIfdFhEGir7ju4E1sSCUkYwwf/HFlHDOMiowd6msaiCQeFYVPLAvatwuo 7IRgZB8q0LEEGe3kUbYIjHvdbpXK+lifsD4Q8Xp6UIT1g9lhiFjJ1AZbvntBW5vkv07H bz9J1gL2VB+zMu9LDQ+boQPg5dnkw3cjDN4JREGvvawop9DTtC5raFul9Gas9VIjNiE6 b6wRquDb/urOMi/IvEmA8Z6n5vw7g2/bZJCrCWr1NKoluD3FdB6Y67rHpGuPS9f/4IHh 3Pqw== 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 a9-20020a170902ecc900b00176db576db9si16505986plh.275.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 S230150AbiKBDG4 (ORCPT + 99 others); Tue, 1 Nov 2022 23:06:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbiKBDGY (ORCPT ); Tue, 1 Nov 2022 23:06:24 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EC54123E93; 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--.7456S4; Wed, 02 Nov 2022 11:06:17 +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 2/2] blk-mq: use if-else instead of goto in blk_mq_alloc_cached_request() Date: Wed, 2 Nov 2022 11:06:05 +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--.7456S4 X-Coremail-Antispam: 1UD129KBjvJXoW7AF4Dtw4DWry3ZFW7Cw4xtFb_yoW8Gry5pF sxJa4qvFWFgF1xuF4rAa1fJF4rCF1rGF9rC34fAwn5Z3y5Gr4Utr1fArWFqFWSyFZ3CFWx Kr4DCas5uF18XrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUva1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW0oVCq3wA2z4x0Y4vEx4A2 jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAac4AC62xK8xCEY4 vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0E wIxGrwCF04k20xvE74AGY7Cv6cx26r4fKr1UJr1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2 IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v2 6r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2 IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv 67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyT uYvjfUOlksUUUUU X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgQCB1ZdtcNYxwAAsh 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?1748352173371304027?= X-GMAIL-MSGID: =?utf-8?q?1748352173371304027?= if-else is more readable than goto here. Signed-off-by: Jinlong Chen Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni 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 453ad445a6bd..6ffca7af5b6f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -544,25 +544,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;