1.. SPDX-License-Identifier: GPL-2.0
2
3Bigalloc
4--------
5
6At the moment, the default size of a block is 4KiB, which is a commonly
7supported page size on most MMU-capable hardware. This is fortunate, as
8ext4 code is not prepared to handle the case where the block size
9exceeds the page size. However, for a filesystem of mostly huge files,
10it is desirable to be able to allocate disk blocks in units of multiple
11blocks to reduce both fragmentation and metadata overhead. The
12bigalloc feature provides exactly this ability.
13
14The bigalloc feature (EXT4_FEATURE_RO_COMPAT_BIGALLOC) changes ext4 to
15use clustered allocation, so that each bit in the ext4 block allocation
16bitmap addresses a power of two number of blocks. For example, if the
17file system is mainly going to be storing large files in the 4-32
18megabyte range, it might make sense to set a cluster size of 1 megabyte.
19This means that each bit in the block allocation bitmap now addresses
20256 4k blocks. This shrinks the total size of the block allocation
21bitmaps for a 2T file system from 64 megabytes to 256 kilobytes. It also
22means that a block group addresses 32 gigabytes instead of 128 megabytes,
23also shrinking the amount of file system overhead for metadata.
24
25The administrator can set a block cluster size at mkfs time (which is
26stored in the s_log_cluster_size field in the superblock); from then
27on, the block bitmaps track clusters, not individual blocks. This means
28that block groups can be several gigabytes in size (instead of just
29128MiB); however, the minimum allocation unit becomes a cluster, not a
30block, even for directories. TaoBao had a patchset to extend the ���use
31units of clusters instead of blocks��� to the extent tree, though it is
32not clear where those patches went-- they eventually morphed into
33���extent tree v2��� but that code has not landed as of May 2015.
34
35