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

Linux 6.18.37 · Filesystems

Checksums

ext4 metadata_csum 도입, tune2fs 갱신과 metadata별 checksum 입력을 설명하는 전문 번역입니다.

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

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

1. 요약·해설

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

요약·해설

checksums.rst:1-73

`metadata_csum`은 ext4와 jbd2 주요 metadata에 보통 crc32c checksum을 추가합니다. UUID를 공통 seed 성분으로 사용하고 metadata 종류에 따라 block number, inode number·generation, group number와 structure 전체를 결합합니다.

metadata checksum 검증
superblock에서 algorithm과 feature 확인UUID와 metadata 식별자 결합checksum field를 제외하거나 0으로 설정structure 전체에 crc32c 또는 지정 함수 적용저장 폭에 따라 32 bit 또는 하위 16 bit 비교

metadata 종류에 맞는 identity와 content를 결합합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 Checksums
4 ---------
5
6 Starting in early 2012, metadata checksums were added to all major ext4
7 and jbd2 data structures. The associated feature flag is metadata_csum.
8 The desired checksum algorithm is indicated in the superblock, though as
9 of October 2012 the only supported algorithm is crc32c. Some data
10 structures did not have space to fit a full 32-bit checksum, so only the
11 lower 16 bits are stored. Enabling the 64bit feature increases the data
12 structure size so that full 32-bit checksums can be stored for many data
13 structures. However, existing 32-bit filesystems cannot be extended to
14 enable 64bit mode, at least not without the experimental resize2fs
15 patches to do so.
16
17 Existing filesystems can have checksumming added by running
18 ``tune2fs -O metadata_csum`` against the underlying device. If tune2fs
19 encounters directory blocks that lack sufficient empty space to add a
20 checksum, it will request that you run ``e2fsck -D`` to have the
21 directories rebuilt with checksums. This has the added benefit of
22 removing slack space from the directory files and rebalancing the htree
23 indexes. If you _ignore_ this step, your directories will not be
24 protected by a checksum!
25
26 The following table describes the data elements that go into each type
27 of checksum. The checksum function is whatever the superblock describes
28 (crc32c as of October 2013) unless noted otherwise.
29
30 .. list-table::
31 :widths: 20 8 50
32 :header-rows: 1
33
34 * - Metadata
35 - Length
36 - Ingredients
37 * - Superblock
38 - __le32
39 - The entire superblock up to the checksum field. The UUID lives inside
40 the superblock.
41 * - MMP
42 - __le32
43 - UUID + the entire MMP block up to the checksum field.
44 * - Extended Attributes
45 - __le32
46 - UUID + the entire extended attribute block. The checksum field is set to
47 zero.
48 * - Directory Entries
49 - __le32
50 - UUID + inode number + inode generation + the directory block up to the
51 fake entry enclosing the checksum field.
52 * - HTREE Nodes
53 - __le32
54 - UUID + inode number + inode generation + all valid extents + HTREE tail.
55 The checksum field is set to zero.
56 * - Extents
57 - __le32
58 - UUID + inode number + inode generation + the entire extent block up to
59 the checksum field.
60 * - Bitmaps
61 - __le32 or __le16
62 - UUID + the entire bitmap. Checksums are stored in the group descriptor,
63 and truncated if the group descriptor size is 32 bytes (i.e. ^64bit)
64 * - Inodes
65 - __le32
66 - UUID + inode number + inode generation + the entire inode. The checksum
67 field is set to zero. Each inode has its own checksum.
68 * - Group Descriptors
69 - __le16
70 - If metadata_csum, then UUID + group number + the entire descriptor;
71 else if gdt_csum, then crc16(UUID + group number + the entire
72 descriptor). In all cases, only the lower 16 bits are stored.
73
74

3. 한국어 전문 번역

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

metadata_csum 도입과 기존 filesystem 갱신

1-25

2012년 초부터 모든 주요 ext4와 jbd2 data structure에 metadata checksum이 추가됐습니다. 연관 feature flag는 `metadata_csum`입니다.

원하는 checksum algorithm은 superblock에 표시하지만 2012년 10월 시점에 지원하는 것은 `crc32c`뿐입니다. 일부 data structure에는 32-bit checksum 전체를 넣을 공간이 없어 하위 16 bit만 저장합니다.

`64bit` feature를 켜면 data structure가 커져 많은 structure에 full 32-bit checksum을 저장할 수 있습니다. 그러나 기존 32-bit filesystem은 experimental `resize2fs` patch 없이는 64bit mode로 확장할 수 없습니다.

기존 filesystem에는 underlying device에 `tune2fs -O metadata_csum`을 실행해 checksum을 추가할 수 있습니다.

directory block에 checksum을 넣을 빈 공간이 부족하면 `tune2fs`가 `e2fsck -D` 실행을 요청합니다. 이 작업은 directory를 checksum과 함께 다시 만들고 directory file의 slack space를 제거하며 htree index를 rebalance합니다.

이 단계를 무시하면 해당 directory는 checksum으로 보호되지 않습니다.

기존 ext4에 metadata checksum 추가
underlying device에 `tune2fs -O metadata_csum` 실행directory block의 checksum 여유 공간 확인공간 부족 시 `e2fsck -D` 실행directory rebuild·slack 제거·htree rebalancechecksum 보호 상태로 완료

feature 활성화와 directory 재구성 조건을 나타냅니다.

.. SPDX-License-Identifier: GPL-2.0

Checksums
---------

Starting in early 2012, metadata checksums were added to all major ext4
and jbd2 data structures. The associated feature flag is metadata_csum.
The desired checksum algorithm is indicated in the superblock, though as
of October 2012 the only supported algorithm is crc32c. Some data
structures did not have space to fit a full 32-bit checksum, so only the
lower 16 bits are stored. Enabling the 64bit feature increases the data
structure size so that full 32-bit checksums can be stored for many data
structures. However, existing 32-bit filesystems cannot be extended to
enable 64bit mode, at least not without the experimental resize2fs
patches to do so.

Existing filesystems can have checksumming added by running
``tune2fs -O metadata_csum`` against the underlying device. If tune2fs
encounters directory blocks that lack sufficient empty space to add a
checksum, it will request that you run ``e2fsck -D`` to have the
directories rebuilt with checksums. This has the added benefit of
removing slack space from the directory files and rebalancing the htree
indexes. If you _ignore_ this step, your directories will not be
protected by a checksum!

metadata별 checksum 입력

26-73

각 checksum은 별도 표기가 없으면 superblock이 지정한 함수, 2013년 10월 기준 `crc32c`를 사용합니다.

superblock checksum은 checksum field 직전까지의 superblock 전체를 입력으로 사용하며 UUID도 superblock 안에 있습니다. MMP는 UUID와 checksum field 전까지의 MMP block 전체를 사용합니다.

extended attribute는 UUID와 xattr block 전체를 사용하고 checksum field는 0으로 둡니다. directory entry는 UUID, inode number, inode generation, checksum field를 감싼 fake entry 직전까지의 directory block을 사용합니다.

HTREE node는 UUID, inode number, inode generation, 모든 valid extent, HTREE tail을 사용하고 checksum field를 0으로 둡니다. extent는 UUID, inode number, inode generation, checksum field 전까지의 extent block 전체를 사용합니다.

bitmap은 UUID와 bitmap 전체를 사용합니다. checksum은 group descriptor에 저장하며 descriptor size가 32 bytes, 즉 원문의 `^64bit` 조건이면 잘라 저장합니다. 길이는 `__le32` 또는 `__le16`입니다.

inode는 UUID, inode number, inode generation, inode 전체를 사용하며 checksum field는 0으로 둡니다. 각 inode가 자체 checksum을 가집니다.

group descriptor는 `metadata_csum`이면 UUID, group number, descriptor 전체를 사용합니다. `gdt_csum`이면 `crc16(UUID + group number + entire descriptor)`를 사용합니다. 어느 경우든 하위 16 bit만 저장합니다.

ext4 metadata checksum 입력
MetadataLengthIngredients
Superblock`__le32`checksum field 전까지 전체 superblock
MMP`__le32`UUID + checksum field 전까지 MMP block
Extended Attributes`__le32`UUID + 전체 xattr block, checksum field=0
Directory Entries`__le32`UUID + inode number + generation + fake entry 전까지 directory block
HTREE Nodes`__le32`UUID + inode number + generation + valid extents + HTREE tail
Extents`__le32`UUID + inode number + generation + checksum 전까지 extent block
Bitmaps`__le32`/`__le16`UUID + 전체 bitmap, group descriptor에 저장
Inodes`__le32`UUID + inode number + generation + 전체 inode, checksum field=0
Group Descriptors`__le16``metadata_csum` 또는 `crc16` 입력, 하위 16 bit 저장

원문 checksum ingredient 표를 metadata type별로 재구성했습니다.

The following table describes the data elements that go into each type
of checksum. The checksum function is whatever the superblock describes
(crc32c as of October 2013) unless noted otherwise.

.. list-table::
   :widths: 20 8 50
   :header-rows: 1

   * - Metadata
     - Length
     - Ingredients
   * - Superblock
     - __le32
     - The entire superblock up to the checksum field. The UUID lives inside
       the superblock.
   * - MMP
     - __le32
     - UUID + the entire MMP block up to the checksum field.
   * - Extended Attributes
     - __le32
     - UUID + the entire extended attribute block. The checksum field is set to
       zero.
   * - Directory Entries
     - __le32
     - UUID + inode number + inode generation + the directory block up to the
       fake entry enclosing the checksum field.
   * - HTREE Nodes
     - __le32
     - UUID + inode number + inode generation + all valid extents + HTREE tail.
       The checksum field is set to zero.
   * - Extents
     - __le32
     - UUID + inode number + inode generation + the entire extent block up to
       the checksum field.
   * - Bitmaps
     - __le32 or __le16
     - UUID + the entire bitmap. Checksums are stored in the group descriptor,
       and truncated if the group descriptor size is 32 bytes (i.e. ^64bit)
   * - Inodes
     - __le32
     - UUID + inode number + inode generation + the entire inode. The checksum
       field is set to zero. Each inode has its own checksum.
   * - Group Descriptors
     - __le16
     - If metadata_csum, then UUID + group number + the entire descriptor;
       else if gdt_csum, then crc16(UUID + group number + the entire
       descriptor). In all cases, only the lower 16 bits are stored.