* [PATCH] ext4: fix avefreec in find_group_orlov
@ 2021-05-25 7:36 Pan Dong
2021-06-17 20:21 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Pan Dong @ 2021-05-25 7:36 UTC (permalink / raw)
To: tytso, adilger.kernel; +Cc: linux-ext4, Pan Dong
The avefreec should be average free clusters instead
of average free blocks, otherwize Orlov's allocator
will not work properly when bigalloc enabled.
Signed-off-by: Pan Dong <pandong.peter@bytedance.com>
---
fs/ext4/ialloc.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 71d321b3b984..6c6b6855e30d 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -400,7 +400,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
*
* We always try to spread first-level directories.
*
- * If there are blockgroups with both free inodes and free blocks counts
+ * If there are blockgroups with both free inodes and free clusters counts
* not worse than average we return one with smallest directory count.
* Otherwise we simply return a random group.
*
@@ -409,7 +409,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
* It's OK to put directory into a group unless
* it has too many directories already (max_dirs) or
* it has too few free inodes left (min_inodes) or
- * it has too few free blocks left (min_blocks) or
+ * it has too few free clusters left (min_clusters) or
* Parent's group is preferred, if it doesn't satisfy these
* conditions we search cyclically through the rest. If none
* of the groups look good we just look for a group with more
@@ -425,7 +425,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
ext4_group_t real_ngroups = ext4_get_groups_count(sb);
int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
unsigned int freei, avefreei, grp_free;
- ext4_fsblk_t freeb, avefreec;
+ ext4_fsblk_t freec, avefreec;
unsigned int ndirs;
int max_dirs, min_inodes;
ext4_grpblk_t min_clusters;
@@ -444,9 +444,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
avefreei = freei / ngroups;
- freeb = EXT4_C2B(sbi,
- percpu_counter_read_positive(&sbi->s_freeclusters_counter));
- avefreec = freeb;
+ freec = percpu_counter_read_positive(&sbi->s_freeclusters_counter);
+ avefreec = freec;
do_div(avefreec, ngroups);
ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: fix avefreec in find_group_orlov
2021-05-25 7:36 [PATCH] ext4: fix avefreec in find_group_orlov Pan Dong
@ 2021-06-17 20:21 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2021-06-17 20:21 UTC (permalink / raw)
To: Pan Dong; +Cc: adilger.kernel, linux-ext4
On Tue, May 25, 2021 at 03:36:56PM +0800, Pan Dong wrote:
> The avefreec should be average free clusters instead
> of average free blocks, otherwize Orlov's allocator
> will not work properly when bigalloc enabled.
>
> Signed-off-by: Pan Dong <pandong.peter@bytedance.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-17 20:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 7:36 [PATCH] ext4: fix avefreec in find_group_orlov Pan Dong
2021-06-17 20:21 ` Theodore Ts'o
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.