← Documents Documentation/filesystems/ext4/group_descr.rst GitHub 원문 ↗

Linux 6.18.37 · Filesystems

Block Group Descriptors

ext4 블록 그룹 디스크립터의 배치, 32/64비트 필드, 체크섬과 상태 플래그의 전문 번역입니다.

Source pathDocumentation/filesystems/ext4/group_descr.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

group_descr.rst:1-173

블록 그룹 디스크립터는 비트맵과 inode 테이블의 위치, 자원 개수, 초기화 상태와 체크섬을 기록합니다.

`64bit` 기능을 켜면 32바이트 기본 형식 뒤에 상위 비트 필드가 추가되어 최소 64바이트가 됩니다.

요약·해설 핵심 흐름
그룹 번호로 descriptor 선택lo/hi 필드를 결합해 메타데이터 위치 확인`bg_flags`로 초기화 상태 판단CRC16 또는 CRC32C 하위 16비트로 무결성 검증

문서의 핵심 관계를 짧게 정리합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 Block Group Descriptors
4 -----------------------
5
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
11 is set.
12
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.
20
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
25 group.
26
27 flex_bg and meta_bg do not appear to be mutually exclusive features.
28
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.
34
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
41 entire bitmap.
42
43 The block group descriptor is laid out in ``struct ext4_group_desc``.
44
45 .. list-table::
46 :widths: 8 8 24 40
47 :header-rows: 1
48
49 * - Offset
50 - Size
51 - Name
52 - Description
53 * - 0x0
54 - __le32
55 - bg_block_bitmap_lo
56 - Lower 32-bits of location of block bitmap.
57 * - 0x4
58 - __le32
59 - bg_inode_bitmap_lo
60 - Lower 32-bits of location of inode bitmap.
61 * - 0x8
62 - __le32
63 - bg_inode_table_lo
64 - Lower 32-bits of location of inode table.
65 * - 0xC
66 - __le16
67 - bg_free_blocks_count_lo
68 - Lower 16-bits of free block count.
69 * - 0xE
70 - __le16
71 - bg_free_inodes_count_lo
72 - Lower 16-bits of free inode count.
73 * - 0x10
74 - __le16
75 - bg_used_dirs_count_lo
76 - Lower 16-bits of directory count.
77 * - 0x12
78 - __le16
79 - bg_flags
80 - Block group flags. See the bgflags_ table below.
81 * - 0x14
82 - __le32
83 - bg_exclude_bitmap_lo
84 - Lower 32-bits of location of snapshot exclusion bitmap.
85 * - 0x18
86 - __le16
87 - bg_block_bitmap_csum_lo
88 - Lower 16-bits of the block bitmap checksum.
89 * - 0x1A
90 - __le16
91 - bg_inode_bitmap_csum_lo
92 - Lower 16-bits of the inode bitmap checksum.
93 * - 0x1C
94 - __le16
95 - bg_itable_unused_lo
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.
99 * - 0x1E
100 - __le16
101 - bg_checksum
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.
108 * -
109 -
110 -
111 - These fields only exist if the 64bit feature is enabled and s_desc_size
112 > 32.
113 * - 0x20
114 - __le32
115 - bg_block_bitmap_hi
116 - Upper 32-bits of location of block bitmap.
117 * - 0x24
118 - __le32
119 - bg_inode_bitmap_hi
120 - Upper 32-bits of location of inodes bitmap.
121 * - 0x28
122 - __le32
123 - bg_inode_table_hi
124 - Upper 32-bits of location of inodes table.
125 * - 0x2C
126 - __le16
127 - bg_free_blocks_count_hi
128 - Upper 16-bits of free block count.
129 * - 0x2E
130 - __le16
131 - bg_free_inodes_count_hi
132 - Upper 16-bits of free inode count.
133 * - 0x30
134 - __le16
135 - bg_used_dirs_count_hi
136 - Upper 16-bits of directory count.
137 * - 0x32
138 - __le16
139 - bg_itable_unused_hi
140 - Upper 16-bits of unused inode count.
141 * - 0x34
142 - __le32
143 - bg_exclude_bitmap_hi
144 - Upper 32-bits of location of snapshot exclusion bitmap.
145 * - 0x38
146 - __le16
147 - bg_block_bitmap_csum_hi
148 - Upper 16-bits of the block bitmap checksum.
149 * - 0x3A
150 - __le16
151 - bg_inode_bitmap_csum_hi
152 - Upper 16-bits of the inode bitmap checksum.
153 * - 0x3C
154 - __u32
155 - bg_reserved
156 - Padding to 64 bytes.
157
158 .. _bgflags:
159
160 Block group flags can be any combination of the following:
161
162 .. list-table::
163 :widths: 16 64
164 :header-rows: 1
165
166 * - Value
167 - Description
168 * - 0x1
169 - inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
170 * - 0x2
171 - block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
172 * - 0x4
173 - inode table is zeroed (EXT4_BG_INODE_ZEROED).
174

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

블록 그룹 디스크립터 배치

1-43

파일시스템의 각 블록 그룹에는 블록 그룹 디스크립터 하나가 연결됩니다. 앞의 Layout 절에서 설명했듯이 디스크립터가 존재하는 경우 블록 그룹의 두 번째 항목입니다. 표준 구성에서는 `sparse_super` 기능 플래그가 설정되지 않은 한 모든 블록 그룹에 블록 그룹 디스크립터 테이블의 전체 사본이 들어갑니다.

그룹 디스크립터는 블록 비트맵과 inode 비트맵, inode 테이블의 위치를 기록하므로 이 구조들은 그룹 안에서 이동할 수 있습니다. 따라서 블록 그룹에서 위치가 고정된 구조는 superblock과 group descriptor table뿐입니다. `flex_bg`는 이 특성을 이용해 여러 블록 그룹을 flex group으로 묶고, 모든 그룹의 비트맵과 inode 테이블을 flex group의 첫 그룹에 하나의 긴 연속 영역으로 배치합니다.

`meta_bg` 기능 플래그가 설정되면 여러 블록 그룹을 meta group으로 묶습니다. 다만 meta group에서는 더 큰 meta group 안의 첫 번째 블록 그룹과 마지막 두 블록 그룹이 그 meta group 내부 그룹들의 디스크립터만 담습니다.

`flex_bg`와 `meta_bg`는 서로 배타적인 기능으로 보이지 않으므로 함께 사용될 수 있습니다.

ext2, ext3 및 `64bit` 기능을 켜지 않은 ext4에서 블록 그룹 디스크립터는 32바이트이며 `bg_checksum`에서 끝납니다. `64bit` 기능을 켠 ext4에서는 아래에 설명한 최소 64바이트로 확장되고, 실제 크기는 superblock에 저장됩니다.

`gdt_csum`이 설정되고 `metadata_csum`은 설정되지 않은 경우 그룹 디스크립터 체크섬은 FS UUID, 그룹 번호, 그룹 디스크립터 구조에 대한 CRC16입니다. `metadata_csum`이 설정된 경우에는 같은 입력에 대한 체크섬의 하위 16비트를 사용합니다. 블록 및 inode 비트맵 체크섬은 FS UUID, 그룹 번호, 비트맵 전체를 입력으로 계산합니다.

블록 그룹 디스크립터의 디스크 형식은 `struct ext4_group_desc`입니다.

그룹 디스크립터 체크섬 선택
`gdt_csum` 설정 여부 확인`metadata_csum`이 없으면 UUID + group_num + bg_desc의 CRC16`metadata_csum`이 있으면 UUID + group_num + bg_desc의 CRC32C 하위 16비트블록 및 inode 비트맵은 UUID + group_num + 전체 bitmap으로 검증

기능 플래그에 따라 그룹 디스크립터 검증 방식이 달라집니다.

.. SPDX-License-Identifier: GPL-2.0

Block Group Descriptors
-----------------------

Each block group on the filesystem has one of these descriptors
associated with it. As noted in the Layout section above, the group
descriptors (if present) are the second item in the block group. The
standard configuration is for each block group to contain a full copy of
the block group descriptor table unless the sparse_super feature flag
is set.

Notice how the group descriptor records the location of both bitmaps and
the inode table (i.e. they can float). This means that within a block
group, the only data structures with fixed locations are the superblock
and the group descriptor table. The flex_bg mechanism uses this
property to group several block groups into a flex group and lay out all
of the groups' bitmaps and inode tables into one long run in the first
group of the flex group.

If the meta_bg feature flag is set, then several block groups are
grouped together into a meta group. Note that in the meta_bg case,
however, the first and last two block groups within the larger meta
group contain only group descriptors for the groups inside the meta
group.

flex_bg and meta_bg do not appear to be mutually exclusive features.

In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the
block group descriptor was only 32 bytes long and therefore ends at
bg_checksum. On an ext4 filesystem with the 64bit feature enabled, the
block group descriptor expands to at least the 64 bytes described below;
the size is stored in the superblock.

If gdt_csum is set and metadata_csum is not set, the block group
checksum is the crc16 of the FS UUID, the group number, and the group
descriptor structure. If metadata_csum is set, then the block group
checksum is the lower 16 bits of the checksum of the FS UUID, the group
number, and the group descriptor structure. Both block and inode bitmap
checksums are calculated against the FS UUID, the group number, and the
entire bitmap.

The block group descriptor is laid out in ``struct ext4_group_desc``.

32바이트 기본 필드

44-107

기본 32바이트 디스크립터는 각 비트맵과 inode 테이블 위치의 하위 32비트, 그룹별 개수의 하위 16비트, 상태 플래그, 비트맵 체크섬의 하위 16비트, 사용하지 않은 inode 수, 그룹 디스크립터 체크섬을 저장합니다.

`bg_itable_unused_lo`가 설정되어 있으면 이 그룹의 inode 테이블에서 `(sb.s_inodes_per_group - gdt.bg_itable_unused)`번째 엔트리를 넘어서 스캔할 필요가 없습니다.

`RO_COMPAT_GDT_CSUM`을 사용하면 `bg_checksum`은 `crc16(sb_uuid+group_num+bg_desc)`입니다. CRC16 계산에서는 `bg_desc`의 `bg_checksum` 필드를 건너뜁니다. `RO_COMPAT_METADATA_CSUM`을 사용하면 `crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF`이며, 계산할 때 `bg_checksum` 필드를 0으로 둡니다.

`struct ext4_group_desc` 기본 32바이트
OffsetTypeName설명
`0x0``__le32``bg_block_bitmap_lo`블록 비트맵 위치의 하위 32비트
`0x4``__le32``bg_inode_bitmap_lo`inode 비트맵 위치의 하위 32비트
`0x8``__le32``bg_inode_table_lo`inode 테이블 위치의 하위 32비트
`0xC``__le16``bg_free_blocks_count_lo`빈 블록 수의 하위 16비트
`0xE``__le16``bg_free_inodes_count_lo`빈 inode 수의 하위 16비트
`0x10``__le16``bg_used_dirs_count_lo`디렉터리 수의 하위 16비트
`0x12``__le16``bg_flags`블록 그룹 플래그
`0x14``__le32``bg_exclude_bitmap_lo`snapshot exclusion bitmap 위치의 하위 32비트
`0x18``__le16``bg_block_bitmap_csum_lo`블록 비트맵 체크섬의 하위 16비트
`0x1A``__le16``bg_inode_bitmap_csum_lo`inode 비트맵 체크섬의 하위 16비트
`0x1C``__le16``bg_itable_unused_lo`사용하지 않은 inode 수의 하위 16비트
`0x1E``__le16``bg_checksum`그룹 디스크립터 체크섬

모든 지원 형식에 존재하는 하위 필드입니다.


.. list-table::
   :widths: 8 8 24 40
   :header-rows: 1

   * - Offset
     - Size
     - Name
     - Description
   * - 0x0
     - __le32
     - bg_block_bitmap_lo
     - Lower 32-bits of location of block bitmap.
   * - 0x4
     - __le32
     - bg_inode_bitmap_lo
     - Lower 32-bits of location of inode bitmap.
   * - 0x8
     - __le32
     - bg_inode_table_lo
     - Lower 32-bits of location of inode table.
   * - 0xC
     - __le16
     - bg_free_blocks_count_lo
     - Lower 16-bits of free block count.
   * - 0xE
     - __le16
     - bg_free_inodes_count_lo
     - Lower 16-bits of free inode count.
   * - 0x10
     - __le16
     - bg_used_dirs_count_lo
     - Lower 16-bits of directory count.
   * - 0x12
     - __le16
     - bg_flags
     - Block group flags. See the bgflags_ table below.
   * - 0x14
     - __le32
     - bg_exclude_bitmap_lo
     - Lower 32-bits of location of snapshot exclusion bitmap.
   * - 0x18
     - __le16
     - bg_block_bitmap_csum_lo
     - Lower 16-bits of the block bitmap checksum.
   * - 0x1A
     - __le16
     - bg_inode_bitmap_csum_lo
     - Lower 16-bits of the inode bitmap checksum.
   * - 0x1C
     - __le16
     - bg_itable_unused_lo
     - Lower 16-bits of unused inode count. If set, we needn't scan past the
       ``(sb.s_inodes_per_group - gdt.bg_itable_unused)`` th entry in the
       inode table for this group.
   * - 0x1E
     - __le16
     - bg_checksum
     - Group descriptor checksum; crc16(sb_uuid+group_num+bg_desc) if the
       RO_COMPAT_GDT_CSUM feature is set, or
       crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the
       RO_COMPAT_METADATA_CSUM feature is set.  The bg_checksum
       field in bg_desc is skipped when calculating crc16 checksum,
       and set to zero if crc32c checksum is used.

`64bit` 확장 필드

108-157

아래 필드는 `64bit` 기능이 설정되고 `s_desc_size > 32`인 경우에만 존재합니다. 위치 필드의 상위 32비트와 개수 필드의 상위 16비트를 기본 필드에 결합해 더 큰 파일시스템과 그룹 통계를 표현합니다.

확장 부분의 끝에는 64바이트 경계를 맞추는 `bg_reserved`가 있습니다.

`struct ext4_group_desc` 64비트 확장
OffsetTypeName설명
`0x20``__le32``bg_block_bitmap_hi`블록 비트맵 위치의 상위 32비트
`0x24``__le32``bg_inode_bitmap_hi`inode 비트맵 위치의 상위 32비트
`0x28``__le32``bg_inode_table_hi`inode 테이블 위치의 상위 32비트
`0x2C``__le16``bg_free_blocks_count_hi`빈 블록 수의 상위 16비트
`0x2E``__le16``bg_free_inodes_count_hi`빈 inode 수의 상위 16비트
`0x30``__le16``bg_used_dirs_count_hi`디렉터리 수의 상위 16비트
`0x32``__le16``bg_itable_unused_hi`사용하지 않은 inode 수의 상위 16비트
`0x34``__le32``bg_exclude_bitmap_hi`snapshot exclusion bitmap 위치의 상위 32비트
`0x38``__le16``bg_block_bitmap_csum_hi`블록 비트맵 체크섬의 상위 16비트
`0x3A``__le16``bg_inode_bitmap_csum_hi`inode 비트맵 체크섬의 상위 16비트
`0x3C``__u32``bg_reserved`64바이트까지 채우는 패딩

`0x20` 이후에 추가되는 상위 필드입니다.

   * -
     -
     -
     - These fields only exist if the 64bit feature is enabled and s_desc_size
       > 32.
   * - 0x20
     - __le32
     - bg_block_bitmap_hi
     - Upper 32-bits of location of block bitmap.
   * - 0x24
     - __le32
     - bg_inode_bitmap_hi
     - Upper 32-bits of location of inodes bitmap.
   * - 0x28
     - __le32
     - bg_inode_table_hi
     - Upper 32-bits of location of inodes table.
   * - 0x2C
     - __le16
     - bg_free_blocks_count_hi
     - Upper 16-bits of free block count.
   * - 0x2E
     - __le16
     - bg_free_inodes_count_hi
     - Upper 16-bits of free inode count.
   * - 0x30
     - __le16
     - bg_used_dirs_count_hi
     - Upper 16-bits of directory count.
   * - 0x32
     - __le16
     - bg_itable_unused_hi
     - Upper 16-bits of unused inode count.
   * - 0x34
     - __le32
     - bg_exclude_bitmap_hi
     - Upper 32-bits of location of snapshot exclusion bitmap.
   * - 0x38
     - __le16
     - bg_block_bitmap_csum_hi
     - Upper 16-bits of the block bitmap checksum.
   * - 0x3A
     - __le16
     - bg_inode_bitmap_csum_hi
     - Upper 16-bits of the inode bitmap checksum.
   * - 0x3C
     - __u32
     - bg_reserved
     - Padding to 64 bytes.

블록 그룹 플래그

158-173

블록 그룹 플래그는 다음 값을 조합해 설정할 수 있습니다. 이 플래그들은 inode 테이블과 비트맵의 초기화 상태를 나타내며, 지연 초기화와 마운트 시 작업량 최적화에 사용됩니다.

블록 그룹 플래그
ValueSymbol설명
`0x1``EXT4_BG_INODE_UNINIT`inode 테이블과 inode 비트맵이 초기화되지 않음
`0x2``EXT4_BG_BLOCK_UNINIT`블록 비트맵이 초기화되지 않음
`0x4``EXT4_BG_INODE_ZEROED`inode 테이블이 0으로 초기화됨

`bg_flags`에 기록되는 비트와 의미입니다.

.. _bgflags:

Block group flags can be any combination of the following:

.. list-table::
   :widths: 16 64
   :header-rows: 1

   * - Value
     - Description
   * - 0x1
     - inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
   * - 0x2
     - block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
   * - 0x4
     - inode table is zeroed (EXT4_BG_INODE_ZEROED).