요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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!
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.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
metadata_csum 도입과 기존 filesystem 갱신
1-252012년 초부터 모든 주요 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으로 보호되지 않습니다.
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만 저장합니다.
원문 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.
요약·해설
checksums.rst:1-73`metadata_csum`은 ext4와 jbd2 주요 metadata에 보통 crc32c checksum을 추가합니다. UUID를 공통 seed 성분으로 사용하고 metadata 종류에 따라 block number, inode number·generation, group number와 structure 전체를 결합합니다.
metadata 종류에 맞는 identity와 content를 결합합니다.