Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5300368rwb; Mon, 31 Jul 2023 23:32:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUqMGX+S/CcUjGslejqB357dC/d8RDJ4itDd4eEzvjWYA0OuCFjIAwm4H9zQmIQTjet1t+ X-Received: by 2002:a17:906:5198:b0:973:fd02:a41f with SMTP id y24-20020a170906519800b00973fd02a41fmr1806032ejk.40.1690871568040; Mon, 31 Jul 2023 23:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690871568; cv=none; d=google.com; s=arc-20160816; b=lu0F/gl8D+RTtF+GNC3+58/M2y/ry26wyRXtrC2bHcYTlxhPpCzrBrzG5bi5hrAaKC XXhuJE33qPC5iibSEnY81kDjwiU9AFjs+MkZevL8rlBTY/ciXZThi8phWlN2KkcTxKlF mwQcIBcnrbMrSdDtEwjqHMWRHDYlNhyZOGebNmwgxE/Sptc3AdwcLKhq+oh7jnsOzrQK rDFREaaTYm83/pAHuZx8rhrTsiaTB2COrOXBiRY7ge4szQak0VjlGVTWhriNur+G6m0O sgCa60RoPZtJW0jNfFfdEf3MrkdVZ6Xrl1lyd9hZyBICuSt/yHJdV/mJ4oXXfk+aZb3f 6GkQ== 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=i1X/txTABoQKj6fWYPhF8APANIYmLCU35q/1bqHIjvA=; fh=MlGqaUnvBjpXmiP990bdf+mzv9VjPrVaE5OVdv29XYE=; b=aAmCoa5iziajFcuaQAAJgZctNzMDWianFnKglPKCGfICvYDAc0CQ5hBftbbz86bKrx 33IMCehsumKa06kpEmuOsjkPU7gVP0nKkguxXghL4qRnCSJmx5gOeUW/ZOowKcXePaV4 anI37zsz8DIv3YyrQsanxfSOztEtSK2JxsnxmU/ybOhNgO3a6Vm0ZFn6dxmWzTcMpovv alleak5gnUixfspD7Or1H0gPMjMijBtuCEPSblDzfG9SlbwTavKagdgTW16utxeJQnnr jZjyJyITqveqA9/0F6FBNkLul/aGzNMzfOFbXLkMQaFosdM0cDCvIbPU1B0ITSQQt4vW 9ZFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170906838400b00988b90f50b3si7523389ejx.607.2023.07.31.23.32.24; Mon, 31 Jul 2023 23:32:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231637AbjHAGcB (ORCPT + 99 others); Tue, 1 Aug 2023 02:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbjHAGby (ORCPT ); Tue, 1 Aug 2023 02:31:54 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E38E5F; Mon, 31 Jul 2023 23:31:53 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RFQHn5xJCz4f3nTs; Tue, 1 Aug 2023 14:31:49 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgDnjOrQpshkMcvqPA--.21719S11; Tue, 01 Aug 2023 14:31:50 +0800 (CST) From: Kemeng Shi To: tytso@mit.edu, adilger.kernel@dilger.ca, ritesh.list@gmail.com, ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: shikemeng@huaweicloud.com Subject: [PATCH v3 09/10] ext4: return found group directly in ext4_mb_choose_next_group_best_avail Date: Tue, 1 Aug 2023 22:32:03 +0800 Message-Id: <20230801143204.2284343-10-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230801143204.2284343-1-shikemeng@huaweicloud.com> References: <20230801143204.2284343-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgDnjOrQpshkMcvqPA--.21719S11 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWUJry3GryUJFW7CFyxGrg_yoW8Gry3pw n3WF1xuF1xW3W5JFsrGaykWa18Kw4fKFy8tryrZw1rXFy3JFWkGanrta40vF93CrZrCF15 Zw40yr1Sk3Zru3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org Return good group when it's found in loop to remove futher check if good group is found after loop. Signed-off-by: Kemeng Shi Reviewed-by: Ritesh Harjani (IBM) --- fs/ext4/mballoc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index e9e37ffe5c10..bfaab173a3f4 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1042,18 +1042,16 @@ static void ext4_mb_choose_next_group_best_avail(struct ext4_allocation_context ac->ac_g_ex.fe_len); grp = ext4_mb_find_good_group_avg_frag_lists(ac, frag_order); - if (grp) - break; + if (grp) { + *group = grp->bb_group; + ac->ac_flags |= EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED; + return; + } } - if (grp) { - *group = grp->bb_group; - ac->ac_flags |= EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED; - } else { - /* Reset goal length to original goal length before falling into CR_GOAL_LEN_SLOW */ - ac->ac_g_ex.fe_len = ac->ac_orig_goal_len; - *new_cr = CR_GOAL_LEN_SLOW; - } + /* Reset goal length to original goal length before falling into CR_GOAL_LEN_SLOW */ + ac->ac_g_ex.fe_len = ac->ac_orig_goal_len; + *new_cr = CR_GOAL_LEN_SLOW; } static inline int should_optimize_scan(struct ext4_allocation_context *ac) -- 2.30.0