^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) High Level Design
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) An ext4 file system is split into a series of block groups. To reduce
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) performance difficulties due to fragmentation, the block allocator tries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) very hard to keep each file's blocks within the same group, thereby
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) reducing seek times. The size of a block group is specified in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ``sb.s_blocks_per_group`` blocks, though it can also calculated as 8 \*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ``block_size_in_bytes``. With the default block size of 4KiB, each group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) will contain 32,768 blocks, for a length of 128MiB. The number of block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) groups is the size of the device divided by the size of a block group.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) All fields in ext4 are written to disk in little-endian order. HOWEVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) all fields in jbd2 (the journal) are written to disk in big-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) .. include:: blocks.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) .. include:: blockgroup.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) .. include:: special_inodes.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. include:: allocators.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) .. include:: checksums.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) .. include:: bigalloc.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .. include:: inlinedata.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) .. include:: eainode.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) .. include:: verity.rst