]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - fs/ext4/mballoc.c
ext4: optimize mballoc for large allocations
authorTheodore Ts'o <tytso@mit.edu>
Mon, 4 Feb 2013 20:08:40 +0000 (15:08 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 4 Feb 2013 20:08:40 +0000 (15:08 -0500)
commit40ae3487628235e5f1eb27542cca0cdb6e5dbe16
tree205ec6dad9b2d3f41d5a78f4ac2fa071bae14c25
parent8dc0aa8cf0f7b51e6c7c342e6f1e61520fb94222
ext4: optimize mballoc for large allocations

The ext4 block allocator only maintains buddy bitmaps for chunks which
are less than or equal to one quarter of a block group.  That is, for
a file aystem with a 1k blocksize, and where the number of blocks in a
block group is 8192 blocks, the largest chunk size tracked by buddy
bitmaps is 2048 blocks.

For a file system with a 4k blocksize, and where the number of blocks
in a block group is 32768 blocks, the largest chunk size tracked by
buddy bitmaps is 8192 blocks.

To work around this code, mballoc.c before this commit would truncate
allocation requests to the number of blocks in a block group minus 10.
Why 10?  Aside from being a completely arbitrary number, it avoids
block allocation to be a power of two larger than 25% of the block
group.  If you try to explicitly fallocate 50% of the block group
size, this will demonstrate the problem; the block allocation code
will scan the all of the blocks in the file system with cr==0 (since
the request is for a natural power of two), but then completely fail
for all blocks groups, since the buddy bitmaps don't track chunk sizes
of 50% of the block group.

To fix this, in these we use ext4_mb_complex_scan_group() instead of
ext4_mb_simple_scan_group().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger@dilger.ca>
fs/ext4/mballoc.c