]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ext4: simplify mballoc preallocation size rounding for small files
authorWeixie Cui <cuiweixie@gmail.com>
Wed, 25 Feb 2026 05:02:31 +0000 (13:02 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 9 Apr 2026 14:43:06 +0000 (10:43 -0400)
commitaf1502f98e2cdd43504596cd438f3aa6d0be8712
tree046214c2075d1fbf9875f95ae0c9b6bd755cd3d8
parenta804ecc399d91a529726fa1b10ff699bb531253d
ext4: simplify mballoc preallocation size rounding for small files

The if-else ladder in ext4_mb_normalize_request() manually rounds up
the preallocation size to the next power of two for files up to 1MB,
enumerating each step from 16KB to 1MB individually. Replace this with
a single roundup_pow_of_two() call clamped to a 16KB minimum, which
is functionally equivalent but much more concise.

Also replace raw byte constants with SZ_1M and SZ_16K from
<linux/sizes.h> for clarity, and remove the stale "XXX: should this
table be tunable?" comment that has been there since the original
mballoc code.

No functional change.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
Link: https://patch.msgid.link/tencent_E9C5F1B2E9939B3037501FD04A7E9CF0C407@qq.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c