Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: fix avefreec in find_group_orlov

The avefreec should be average free clusters instead
of average free blocks, otherwize Orlov's allocator
will not work properly when bigalloc enabled.

Cc: stable@kernel.org
Signed-off-by: Pan Dong <pandong.peter@bytedance.com>
Link: https://lore.kernel.org/r/20210525073656.31594-1-pandong.peter@bytedance.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Pan Dong and committed by
Theodore Ts'o
c89849cc 4fb7c70a

+5 -6
+5 -6
fs/ext4/ialloc.c
··· 402 402 * 403 403 * We always try to spread first-level directories. 404 404 * 405 - * If there are blockgroups with both free inodes and free blocks counts 405 + * If there are blockgroups with both free inodes and free clusters counts 406 406 * not worse than average we return one with smallest directory count. 407 407 * Otherwise we simply return a random group. 408 408 * ··· 411 411 * It's OK to put directory into a group unless 412 412 * it has too many directories already (max_dirs) or 413 413 * it has too few free inodes left (min_inodes) or 414 - * it has too few free blocks left (min_blocks) or 414 + * it has too few free clusters left (min_clusters) or 415 415 * Parent's group is preferred, if it doesn't satisfy these 416 416 * conditions we search cyclically through the rest. If none 417 417 * of the groups look good we just look for a group with more ··· 427 427 ext4_group_t real_ngroups = ext4_get_groups_count(sb); 428 428 int inodes_per_group = EXT4_INODES_PER_GROUP(sb); 429 429 unsigned int freei, avefreei, grp_free; 430 - ext4_fsblk_t freeb, avefreec; 430 + ext4_fsblk_t freec, avefreec; 431 431 unsigned int ndirs; 432 432 int max_dirs, min_inodes; 433 433 ext4_grpblk_t min_clusters; ··· 446 446 447 447 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter); 448 448 avefreei = freei / ngroups; 449 - freeb = EXT4_C2B(sbi, 450 - percpu_counter_read_positive(&sbi->s_freeclusters_counter)); 451 - avefreec = freeb; 449 + freec = percpu_counter_read_positive(&sbi->s_freeclusters_counter); 450 + avefreec = freec; 452 451 do_div(avefreec, ngroups); 453 452 ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter); 454 453