From: Kemeng Shi <shikemeng@huaweicloud.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jack@suse.cz, ojaswin@linux.ibm.com, ritesh.list@gmail.com
Subject: [PATCH 5/5] ext4: expand next_linear_group to remove repeat check for linear scan.
Date: Wed, 27 Mar 2024 05:38:23 +0800 [thread overview]
Message-ID: <20240326213823.528302-6-shikemeng@huaweicloud.com> (raw)
In-Reply-To: <20240326213823.528302-1-shikemeng@huaweicloud.com>
Expand next_linear_group to remove repat check for linear scan.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/ext4/mballoc.c | 37 ++++++-------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 0f8a34513bf6..561780a274cd 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1075,31 +1075,6 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
return 1;
}
-/*
- * Return next linear group for allocation. If linear traversal should not be
- * performed, this function just returns the same group
- */
-static ext4_group_t
-next_linear_group(struct ext4_allocation_context *ac, ext4_group_t group,
- ext4_group_t ngroups)
-{
- if (!should_optimize_scan(ac))
- goto inc_and_return;
-
- if (ac->ac_groups_linear_remaining) {
- ac->ac_groups_linear_remaining--;
- goto inc_and_return;
- }
-
- return group;
-inc_and_return:
- /*
- * Artificially restricted ngroups for non-extent
- * files makes group > ngroups possible on first loop.
- */
- return group + 1 >= ngroups ? 0 : group + 1;
-}
-
/*
* ext4_mb_choose_next_group: choose next group for allocation.
*
@@ -1118,12 +1093,12 @@ static void ext4_mb_choose_next_group(struct ext4_allocation_context *ac,
{
*new_cr = ac->ac_criteria;
- if (!should_optimize_scan(ac) || ac->ac_groups_linear_remaining) {
- *group = next_linear_group(ac, *group, ngroups);
- return;
- }
-
- if (*new_cr == CR_POWER2_ALIGNED) {
+ if (!should_optimize_scan(ac))
+ *group = *group + 1 >= ngroups ? 0 : *group + 1;
+ else if (ac->ac_groups_linear_remaining) {
+ ac->ac_groups_linear_remaining--;
+ *group = *group + 1 >= ngroups ? 0 : *group + 1;
+ } else if (*new_cr == CR_POWER2_ALIGNED) {
ext4_mb_choose_next_group_p2_aligned(ac, new_cr, group);
} else if (*new_cr == CR_GOAL_LEN_FAST) {
ext4_mb_choose_next_group_goal_fast(ac, new_cr, group);
--
2.30.0
next prev parent reply other threads:[~2024-03-26 13:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 21:38 [PATCH 0/5] Minor improvements and cleanups to ext4 mballoc Kemeng Shi
2024-03-26 21:38 ` [PATCH 1/5] ext4: keep "prefetch_grp" and "nr" consistent Kemeng Shi
2024-03-29 7:52 ` Ojaswin Mujoo
2024-04-04 13:22 ` Jan Kara
2024-03-26 21:38 ` [PATCH 2/5] ext4: add test_mb_mark_used_cost to estimate cost of mb_mark_used Kemeng Shi
2024-03-29 7:26 ` kernel test robot
2024-03-26 21:38 ` [PATCH 3/5] ext4: call ext4_mb_mark_free_simple in mb_mark_used to clear bits Kemeng Shi
2024-04-04 14:16 ` Jan Kara
2024-04-07 6:31 ` Kemeng Shi
2024-03-26 21:38 ` [PATCH 4/5] ext4: use correct criteria name instead stale integer number in comment Kemeng Shi
2024-03-29 7:15 ` Ojaswin Mujoo
2024-04-04 14:19 ` Jan Kara
2024-04-07 3:21 ` Kemeng Shi
2024-03-26 21:38 ` Kemeng Shi [this message]
2024-03-29 7:14 ` [PATCH 5/5] ext4: expand next_linear_group to remove repeat check for linear scan Ojaswin Mujoo
2024-04-03 6:57 ` Kemeng Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240326213823.528302-6-shikemeng@huaweicloud.com \
--to=shikemeng@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox