1 .. SPDX-License-Identifier: GPL-2.0
3 Block Group Descriptors
4 -----------------------
6 Each block group on the filesystem has one of these descriptors
7 associated with it. As noted in the Layout section above, the group
8 descriptors (if present) are the second item in the block group. The
9 standard configuration is for each block group to contain a full copy of
10 the block group descriptor table unless the sparse_super feature flag
13 Notice how the group descriptor records the location of both bitmaps and
14 the inode table (i.e. they can float). This means that within a block
15 group, the only data structures with fixed locations are the superblock
16 and the group descriptor table. The flex_bg mechanism uses this
17 property to group several block groups into a flex group and lay out all
18 of the groups' bitmaps and inode tables into one long run in the first
19 group of the flex group.
21 If the meta_bg feature flag is set, then several block groups are
22 grouped together into a meta group. Note that in the meta_bg case,
23 however, the first and last two block groups within the larger meta
24 group contain only group descriptors for the groups inside the meta
27 flex_bg and meta_bg do not appear to be mutually exclusive features.
29 In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the
30 block group descriptor was only 32 bytes long and therefore ends at
31 bg_checksum. On an ext4 filesystem with the 64bit feature enabled, the
32 block group descriptor expands to at least the 64 bytes described below;
33 the size is stored in the superblock.
35 If gdt_csum is set and metadata_csum is not set, the block group
36 checksum is the crc16 of the FS UUID, the group number, and the group
37 descriptor structure. If metadata_csum is set, then the block group
38 checksum is the lower 16 bits of the checksum of the FS UUID, the group
39 number, and the group descriptor structure. Both block and inode bitmap
40 checksums are calculated against the FS UUID, the group number, and the
43 The block group descriptor is laid out in ``struct ext4_group_desc``.
56 - Lower 32-bits of location of block bitmap.
60 - Lower 32-bits of location of inode bitmap.
64 - Lower 32-bits of location of inode table.
67 - bg_free_blocks_count_lo
68 - Lower 16-bits of free block count.
71 - bg_free_inodes_count_lo
72 - Lower 16-bits of free inode count.
75 - bg_used_dirs_count_lo
76 - Lower 16-bits of directory count.
80 - Block group flags. See the bgflags_ table below.
83 - bg_exclude_bitmap_lo
84 - Lower 32-bits of location of snapshot exclusion bitmap.
87 - bg_block_bitmap_csum_lo
88 - Lower 16-bits of the block bitmap checksum.
91 - bg_inode_bitmap_csum_lo
92 - Lower 16-bits of the inode bitmap checksum.
96 - Lower 16-bits of unused inode count. If set, we needn't scan past the
97 ``(sb.s_inodes_per_group - gdt.bg_itable_unused)`` th entry in the
98 inode table for this group.
102 - Group descriptor checksum; crc16(sb_uuid+group_num+bg_desc) if the
103 RO_COMPAT_GDT_CSUM feature is set, or
104 crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the
105 RO_COMPAT_METADATA_CSUM feature is set. The bg_checksum
106 field in bg_desc is skipped when calculating crc16 checksum,
107 and set to zero if crc32c checksum is used.
111 - These fields only exist if the 64bit feature is enabled and s_desc_size
116 - Upper 32-bits of location of block bitmap.
120 - Upper 32-bits of location of inodes bitmap.
124 - Upper 32-bits of location of inodes table.
127 - bg_free_blocks_count_hi
128 - Upper 16-bits of free block count.
131 - bg_free_inodes_count_hi
132 - Upper 16-bits of free inode count.
135 - bg_used_dirs_count_hi
136 - Upper 16-bits of directory count.
139 - bg_itable_unused_hi
140 - Upper 16-bits of unused inode count.
143 - bg_exclude_bitmap_hi
144 - Upper 32-bits of location of snapshot exclusion bitmap.
147 - bg_block_bitmap_csum_hi
148 - Upper 16-bits of the block bitmap checksum.
151 - bg_inode_bitmap_csum_hi
152 - Upper 16-bits of the inode bitmap checksum.
156 - Padding to 64 bytes.
160 Block group flags can be any combination of the following:
169 - inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
171 - block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
173 - inode table is zeroed (EXT4_BG_INODE_ZEROED).