Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10628448rwp; Fri, 21 Jul 2023 02:14:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGq2pV6phec9s0ulxWQYPnNMXURwDtd15jd3mNrYqRclmEJkY20AuMh0nsluMbZFt0rOO89 X-Received: by 2002:a05:6402:d0:b0:51d:91ef:c836 with SMTP id i16-20020a05640200d000b0051d91efc836mr857538edu.32.1689930859954; Fri, 21 Jul 2023 02:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689930859; cv=none; d=google.com; s=arc-20160816; b=eqdL0lvXQrFaa1/NyE33CJcbgn08wvpShcimevVHrH+NmmR6hS2NsNfm1uopaujk45 ygLaG/y/QR0QLyZFlBp9ZWdicRpsUuFRqlaGPphDHjhDJmMGjVq4dKxjOLF3thKMfH4+ Oy/dVlbbGYKmbhpG1YQBj+uxc9JqUprSQjR6P2yt2vYlyMXh9aPS+TSpx12JBFmxd1D/ papqZMOiBiv4tWP3Mky8tX/poEjsYPY645jnQ+tSr0jXdqNrOMO3HiBgLs5EWVhVwwx8 /XZSCfVXCK9WOmMX/Z3kf6ktD3lhJJLtOU9Udxnr9fyHrwNdFQrmTG1wXaSr7+3+FIl1 qIdg== 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=a6rlyf5OsSn4vMohd9fdFn0hbfv0Ek+BXiN5b1akbWI=; fh=MlGqaUnvBjpXmiP990bdf+mzv9VjPrVaE5OVdv29XYE=; b=Ge3GVf2PdsI9Eu0J43jwcyTjWcO9mIDghh/57SFCbxc+4KZrdJrEts87OTdfIoHuX8 WjqzOsFDE1ke0ExsAA3SmJ0r9NElidmqAqIv7joZYbht182n4CTR8XLSaXlMK+TuhbPt VXLhwEdqGd1G9UElVgWhl4SsHCazCDdvG5HTrYv1R/YTEI/1Uekv1yDebK3RwIPfJ8Vz HNbwmOwEl98VwaMp2pCxOc27fXuUAE778ojzYA2rwMllUzrunfCDGVX9qvORQX75p1/A CtV8EfgVtAnJp0+ny4H6o9idReiNjVmj1xW0VmDEvKJmvWBtah/2M8/UMTpfoNFu+qFg mTYw== 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 v25-20020a056402185900b0051d9246f95csi2081710edy.174.2023.07.21.02.13.56; Fri, 21 Jul 2023 02:14:19 -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 S231596AbjGUJJu (ORCPT + 99 others); Fri, 21 Jul 2023 05:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbjGUJJn (ORCPT ); Fri, 21 Jul 2023 05:09:43 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70EE01984; Fri, 21 Jul 2023 02:09:42 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4R6kJx2ck9z4f3q35; Fri, 21 Jul 2023 17:09:37 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgAHvrFPS7pkqi7fOQ--.527S11; Fri, 21 Jul 2023 17:09:39 +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 09/10] ext4: return found group directly in ext4_mb_choose_next_group_best_avail Date: Sat, 22 Jul 2023 01:10:06 +0800 Message-Id: <20230721171007.2065423-10-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230721171007.2065423-1-shikemeng@huaweicloud.com> References: <20230721171007.2065423-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAHvrFPS7pkqi7fOQ--.527S11 X-Coremail-Antispam: 1UD129KBjvJXoW7ArykJw1DKF4DJr45ZF4kXrb_yoW8JFWrpr n3WF1I9Fn7W3W5JFsrGaykW3WIkw4xKFy8tryrZw1rJFy3JFWkGanrta40vF97CrWkCFn8 Zw4ktrySkF17u3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw 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 --- 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 6f8e804905d5..b04eceeab967 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1043,18 +1043,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