Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4287584rwo; Tue, 25 Jul 2023 03:57:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCnKT8LY9Ih8d6df4UpFtbN1zqObUkO0WsDOqFVEM4K21kSqTkW5s2FQkp6+YH9oFpIiEX X-Received: by 2002:a17:902:ef8b:b0:1bb:8be1:a82 with SMTP id iz11-20020a170902ef8b00b001bb8be10a82mr7217988plb.14.1690282644642; Tue, 25 Jul 2023 03:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690282644; cv=none; d=google.com; s=arc-20160816; b=NYGf+X0ru6iDdcNytOphzXM9ZK6YhzDvdjAD4pP8PsTg04mNAdOKvWEYOX+D4FaWKJ N3cW51kVBkQtdF+PXoOOKFxh9Od2Q6LpQ/nwxu7iXVGvwWvkzaQE1+izvnA0oVXOkNpy EI5AA6agx9alSyPDXnNb4WiY7GtCwNA0m66fev7FoaAp/6/91dJniOKrOxCDxuC2wCPL 4tn3VmZfiPb9zF7FyQkIhBoZ4lQ9firVKu8j3nDE7JzvnPlYt20H8JtLQ3hw5+XFSTow ibAcduWN8ibV5cMx+k5HmoABmo1UC5WsuSk6dEp7kA8lA7gfzSKsAUwndqbLo+qsKbQw nldQ== 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=k7/2ubdFQ9/pnyAefA9DS+vcEc5ph07bynv3BDRRNlw=; fh=MlGqaUnvBjpXmiP990bdf+mzv9VjPrVaE5OVdv29XYE=; b=pOVzVt06DcjGjZV5gbBrx7BLzP/7OFpi8ZUW2CoX67XD/JXu+bTwE/QaqmMIOf8c8S VPBn5sMge6zAaJ0MZpAqEeFAAYhHBq6KpCrDUtdq2wYbeGNkOnfndxTuYT4Ma5y3OQcp gop3r+ZGBxhCmRmW6cgepQoWeQaB6Yoc/gTJQA/08No3dbd1EzqPZMQ6xWGW8TpHawm2 HXXiBM/hO9NeWxP9YIszXJtxVRlPL9ZDq6ScvAOrYxerr5chCNATMQPdkBP4gvu2+TOp FX75wwqMnYCWWSslveo/itouGvfN9Szwwt7VNNayiEFIoLinz7xTRd5i87U1Dtxe2Wdr onag== 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 d18-20020a170902ced200b001bb7906cf34si8177597plg.261.2023.07.25.03.57.10; Tue, 25 Jul 2023 03:57:24 -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 S233392AbjGYKwI (ORCPT + 99 others); Tue, 25 Jul 2023 06:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233804AbjGYKvQ (ORCPT ); Tue, 25 Jul 2023 06:51:16 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77AC01FEB; Tue, 25 Jul 2023 03:50:46 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R9DMk5SpJz4f4VkH; Tue, 25 Jul 2023 18:50:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgC3quj+qL9kl7XQOg--.17520S11; Tue, 25 Jul 2023 18:50:43 +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 v2 09/10] ext4: return found group directly in ext4_mb_choose_next_group_best_avail Date: Wed, 26 Jul 2023 02:51:05 +0800 Message-Id: <20230725185106.2147273-10-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230725185106.2147273-1-shikemeng@huaweicloud.com> References: <20230725185106.2147273-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgC3quj+qL9kl7XQOg--.17520S11 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWUJry3GryUJFW7CFyxGrg_yoW8Gry3pw nxWF18uF1xWF15JFsrGaykW3WrKw4xKFy8tryfZw1rXFy3JFWkGa1Dta40vF97CFWDGFn8 Zw4vyrySk3W7u3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7sRiVb yDUUUUU== 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, KHOP_HELO_FCRDNS,MAY_BE_FORGED,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 88a3c00e484f..36eea63eaace 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