1 ext4: import group descriptors chapter from wiki page
3 From: Darrick J. Wong <darrick.wong@oracle.com>
5 Import the chapter about group descriptors from the on-disk format wiki
6 page into the kernel documentation.
8 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 Documentation/filesystems/ext4/ondisk/globals.rst | 1
12 .../filesystems/ext4/ondisk/group_descr.rst | 170 ++++++++++++++++++++
13 2 files changed, 171 insertions(+)
14 create mode 100644 Documentation/filesystems/ext4/ondisk/group_descr.rst
17 diff --git a/Documentation/filesystems/ext4/ondisk/globals.rst b/Documentation/filesystems/ext4/ondisk/globals.rst
18 index 4a33d0571bf2..c0dea6297e7f 100644
19 --- a/Documentation/filesystems/ext4/ondisk/globals.rst
20 +++ b/Documentation/filesystems/ext4/ondisk/globals.rst
21 @@ -7,3 +7,4 @@ The filesystem is sharded into a number of block groups, each of which
22 have static metadata at fixed locations.
24 .. include:: super.rst
25 +.. include:: group_descr.rst
26 diff --git a/Documentation/filesystems/ext4/ondisk/group_descr.rst b/Documentation/filesystems/ext4/ondisk/group_descr.rst
28 index 000000000000..759827e5d2cf
30 +++ b/Documentation/filesystems/ext4/ondisk/group_descr.rst
32 +.. SPDX-License-Identifier: GPL-2.0
34 +Block Group Descriptors
35 +-----------------------
37 +Each block group on the filesystem has one of these descriptors
38 +associated with it. As noted in the Layout section above, the group
39 +descriptors (if present) are the second item in the block group. The
40 +standard configuration is for each block group to contain a full copy of
41 +the block group descriptor table unless the sparse\_super feature flag
44 +Notice how the group descriptor records the location of both bitmaps and
45 +the inode table (i.e. they can float). This means that within a block
46 +group, the only data structures with fixed locations are the superblock
47 +and the group descriptor table. The flex\_bg mechanism uses this
48 +property to group several block groups into a flex group and lay out all
49 +of the groups' bitmaps and inode tables into one long run in the first
50 +group of the flex group.
52 +If the meta\_bg feature flag is set, then several block groups are
53 +grouped together into a meta group. Note that in the meta\_bg case,
54 +however, the first and last two block groups within the larger meta
55 +group contain only group descriptors for the groups inside the meta
58 +flex\_bg and meta\_bg do not appear to be mutually exclusive features.
60 +In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the
61 +block group descriptor was only 32 bytes long and therefore ends at
62 +bg\_checksum. On an ext4 filesystem with the 64bit feature enabled, the
63 +block group descriptor expands to at least the 64 bytes described below;
64 +the size is stored in the superblock.
66 +If gdt\_csum is set and metadata\_csum is not set, the block group
67 +checksum is the crc16 of the FS UUID, the group number, and the group
68 +descriptor structure. If metadata\_csum is set, then the block group
69 +checksum is the lower 16 bits of the checksum of the FS UUID, the group
70 +number, and the group descriptor structure. Both block and inode bitmap
71 +checksums are calculated against the FS UUID, the group number, and the
74 +The block group descriptor is laid out in ``struct ext4_group_desc``.
86 + - bg\_block\_bitmap\_lo
87 + - Lower 32-bits of location of block bitmap.
90 + - bg\_inode\_bitmap\_lo
91 + - Lower 32-bits of location of inode bitmap.
94 + - bg\_inode\_table\_lo
95 + - Lower 32-bits of location of inode table.
98 + - bg\_free\_blocks\_count\_lo
99 + - Lower 16-bits of free block count.
102 + - bg\_free\_inodes\_count\_lo
103 + - Lower 16-bits of free inode count.
106 + - bg\_used\_dirs\_count\_lo
107 + - Lower 16-bits of directory count.
111 + - Block group flags. See the bgflags_ table below.
114 + - bg\_exclude\_bitmap\_lo
115 + - Lower 32-bits of location of snapshot exclusion bitmap.
118 + - bg\_block\_bitmap\_csum\_lo
119 + - Lower 16-bits of the block bitmap checksum.
122 + - bg\_inode\_bitmap\_csum\_lo
123 + - Lower 16-bits of the inode bitmap checksum.
126 + - bg\_itable\_unused\_lo
127 + - Lower 16-bits of unused inode count. If set, we needn't scan past the
128 + ``(sb.s_inodes_per_group - gdt.bg_itable_unused)``\ th entry in the
129 + inode table for this group.
133 + - Group descriptor checksum; crc16(sb\_uuid+group+desc) if the
134 + RO\_COMPAT\_GDT\_CSUM feature is set, or crc32c(sb\_uuid+group\_desc) &
135 + 0xFFFF if the RO\_COMPAT\_METADATA\_CSUM feature is set.
139 + - These fields only exist if the 64bit feature is enabled and s_desc_size
143 + - bg\_block\_bitmap\_hi
144 + - Upper 32-bits of location of block bitmap.
147 + - bg\_inode\_bitmap\_hi
148 + - Upper 32-bits of location of inodes bitmap.
151 + - bg\_inode\_table\_hi
152 + - Upper 32-bits of location of inodes table.
155 + - bg\_free\_blocks\_count\_hi
156 + - Upper 16-bits of free block count.
159 + - bg\_free\_inodes\_count\_hi
160 + - Upper 16-bits of free inode count.
163 + - bg\_used\_dirs\_count\_hi
164 + - Upper 16-bits of directory count.
167 + - bg\_itable\_unused\_hi
168 + - Upper 16-bits of unused inode count.
171 + - bg\_exclude\_bitmap\_hi
172 + - Upper 32-bits of location of snapshot exclusion bitmap.
175 + - bg\_block\_bitmap\_csum\_hi
176 + - Upper 16-bits of the block bitmap checksum.
179 + - bg\_inode\_bitmap\_csum\_hi
180 + - Upper 16-bits of the inode bitmap checksum.
184 + - Padding to 64 bytes.
188 +Block group flags can be any combination of the following:
197 + - inode table and bitmap are not initialized (EXT4\_BG\_INODE\_UNINIT).
199 + - block bitmap is not initialized (EXT4\_BG\_BLOCK\_UNINIT).
201 + - inode table is zeroed (EXT4\_BG\_INODE\_ZEROED).