3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-12 10:15:54 +00:00

78 lines
2.5 KiB
ReStructuredText
Raw Normal View History

2022-04-02 18:12:00 +05:00
.. 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
2022-09-13 23:14:27 +05:00
sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the
open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then
2022-04-02 18:12:00 +05:00
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
2022-09-13 23:14:27 +05:00
- __le32
- mmp_magic
2022-04-02 18:12:00 +05:00
- Magic number for MMP, 0x004D4D50 (“MMP”).
* - 0x4
2022-09-13 23:14:27 +05:00
- __le32
- mmp_seq
2022-04-02 18:12:00 +05:00
- Sequence number, updated periodically.
* - 0x8
2022-09-13 23:14:27 +05:00
- __le64
- mmp_time
2022-04-02 18:12:00 +05:00
- Time that the MMP block was last updated.
* - 0x10
- char[64]
2022-09-13 23:14:27 +05:00
- mmp_nodename
2022-04-02 18:12:00 +05:00
- Hostname of the node that opened the filesystem.
* - 0x50
- char[32]
2022-09-13 23:14:27 +05:00
- mmp_bdevname
2022-04-02 18:12:00 +05:00
- Block device name of the filesystem.
* - 0x70
2022-09-13 23:14:27 +05:00
- __le16
- mmp_check_interval
2022-04-02 18:12:00 +05:00
- The MMP re-check interval, in seconds.
* - 0x72
2022-09-13 23:14:27 +05:00
- __le16
- mmp_pad1
2022-04-02 18:12:00 +05:00
- Zero.
* - 0x74
2022-09-13 23:14:27 +05:00
- __le32[226]
- mmp_pad2
2022-04-02 18:12:00 +05:00
- Zero.
* - 0x3FC
2022-09-13 23:14:27 +05:00
- __le32
- mmp_checksum
2022-04-02 18:12:00 +05:00
- Checksum of the MMP block.