요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
Multiple Mount Protection
-------------------------
Multiple mount protection (MMP) is a feature that protects the
filesystem against multiple hosts trying to use the filesystem
simultaneously. When a filesystem is opened (for mounting, or fsck,
etc.), the MMP code running on the node (call it node A) checks a
sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the
open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then
fsck is (hopefully) running, and open fails immediately. Otherwise, the
open code will wait for twice the specified MMP check interval and check
the sequence number again. If the sequence number has changed, then the
filesystem is active on another machine and the open fails. If the MMP
code passes all of those checks, a new MMP sequence number is generated
and written to the MMP block, and the mount proceeds.
While the filesystem is live, the kernel sets up a timer to re-check the
MMP block at the specified MMP check interval. To perform the re-check,
the MMP sequence number is re-read; if it does not match the in-memory
MMP sequence number, then another node (node B) has mounted the
filesystem, and node A remounts the filesystem read-only. If the
sequence numbers match, the sequence number is incremented both in
memory and on disk, and the re-check is complete.
The hostname and device filename are written into the MMP block whenever
an open operation succeeds. The MMP code does not use these values; they
are provided purely for informational purposes.
The checksum is calculated against the FS UUID and the MMP structure.
The MMP structure (``struct mmp_struct``) is as follows:
.. list-table::
:widths: 8 12 20 40
:header-rows: 1
* - Offset
- Type
- Name
- Description
* - 0x0
- __le32
- mmp_magic
- Magic number for MMP, 0x004D4D50 (“MMP”).
* - 0x4
- __le32
- mmp_seq
- Sequence number, updated periodically.
* - 0x8
- __le64
- mmp_time
- Time that the MMP block was last updated.
* - 0x10
- char[64]
- mmp_nodename
- Hostname of the node that opened the filesystem.
* - 0x50
- char[32]
- mmp_bdevname
- Block device name of the filesystem.
* - 0x70
- __le16
- mmp_check_interval
- The MMP re-check interval, in seconds.
* - 0x72
- __le16
- mmp_pad1
- Zero.
* - 0x74
- __le32[226]
- mmp_pad2
- Zero.
* - 0x3FC
- __le32
- mmp_checksum
- Checksum of the MMP block.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Multiple Mount Protection 동작
1-31Multiple Mount Protection, 즉 MMP는 여러 host가 같은 filesystem을 동시에 사용하려는 상황을 막습니다.
mount나 `fsck`를 위해 filesystem을 열 때 node A의 MMP code는 sequence number를 확인합니다. 값이 `EXT4_MMP_SEQ_CLEAN`이면 open을 계속합니다. `EXT4_MMP_SEQ_FSCK`이면 `fsck`가 실행 중인 것으로 보고 즉시 실패합니다.
그 밖의 값이면 설정된 MMP check interval의 두 배를 기다린 뒤 sequence를 다시 읽습니다. 값이 바뀌었으면 다른 machine에서 filesystem이 active하므로 open에 실패합니다. 모든 검사를 통과하면 새 sequence number를 생성해 MMP block에 기록하고 mount를 진행합니다.
filesystem이 활성 상태인 동안 kernel은 지정된 check interval마다 MMP block을 다시 읽는 timer를 둡니다. disk sequence가 memory의 sequence와 다르면 node B가 mount한 것이므로 node A는 filesystem을 read-only로 remount합니다.
두 sequence가 같으면 memory와 disk의 값을 모두 증가시키고 재검사를 끝냅니다.
open 성공 때 hostname과 device filename을 MMP block에 기록하지만 MMP 판단에는 사용하지 않으며 정보 제공용입니다.
초기 open 검사와 mount 후 주기적 검사를 함께 보여줍니다.
.. SPDX-License-Identifier: GPL-2.0
Multiple Mount Protection
-------------------------
Multiple mount protection (MMP) is a feature that protects the
filesystem against multiple hosts trying to use the filesystem
simultaneously. When a filesystem is opened (for mounting, or fsck,
etc.), the MMP code running on the node (call it node A) checks a
sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the
open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then
fsck is (hopefully) running, and open fails immediately. Otherwise, the
open code will wait for twice the specified MMP check interval and check
the sequence number again. If the sequence number has changed, then the
filesystem is active on another machine and the open fails. If the MMP
code passes all of those checks, a new MMP sequence number is generated
and written to the MMP block, and the mount proceeds.
While the filesystem is live, the kernel sets up a timer to re-check the
MMP block at the specified MMP check interval. To perform the re-check,
the MMP sequence number is re-read; if it does not match the in-memory
MMP sequence number, then another node (node B) has mounted the
filesystem, and node A remounts the filesystem read-only. If the
sequence numbers match, the sequence number is incremented both in
memory and on disk, and the re-check is complete.
The hostname and device filename are written into the MMP block whenever
an open operation succeeds. The MMP code does not use these values; they
are provided purely for informational purposes.
The checksum is calculated against the FS UUID and the MMP structure.
`struct mmp_struct`
32-77MMP checksum은 FS UUID와 MMP structure를 입력으로 계산합니다. `struct mmp_struct`는 1024바이트이며 magic, sequence, 마지막 update 시각, node·device 이름, check interval, padding, checksum을 저장합니다.
MMP block의 on-disk 필드입니다.
The MMP structure (``struct mmp_struct``) is as follows:
.. list-table::
:widths: 8 12 20 40
:header-rows: 1
* - Offset
- Type
- Name
- Description
* - 0x0
- __le32
- mmp_magic
- Magic number for MMP, 0x004D4D50 (“MMP”).
* - 0x4
- __le32
- mmp_seq
- Sequence number, updated periodically.
* - 0x8
- __le64
- mmp_time
- Time that the MMP block was last updated.
* - 0x10
- char[64]
- mmp_nodename
- Hostname of the node that opened the filesystem.
* - 0x50
- char[32]
- mmp_bdevname
- Block device name of the filesystem.
* - 0x70
- __le16
- mmp_check_interval
- The MMP re-check interval, in seconds.
* - 0x72
- __le16
- mmp_pad1
- Zero.
* - 0x74
- __le32[226]
- mmp_pad2
- Zero.
* - 0x3FC
- __le32
- mmp_checksum
- Checksum of the MMP block.
요약·해설
mmp.rst:1-77MMP는 주기적으로 갱신되는 sequence number를 비교해 두 host의 동시 writable mount를 감지하고 기존 mount를 read-only로 전환합니다.
문서의 핵심 관계를 짧게 정리합니다.