0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 Multiple Mount Protection
0004 -------------------------
0005
0006 Multiple mount protection (MMP) is a feature that protects the
0007 filesystem against multiple hosts trying to use the filesystem
0008 simultaneously. When a filesystem is opened (for mounting, or fsck,
0009 etc.), the MMP code running on the node (call it node A) checks a
0010 sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the
0011 open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then
0012 fsck is (hopefully) running, and open fails immediately. Otherwise, the
0013 open code will wait for twice the specified MMP check interval and check
0014 the sequence number again. If the sequence number has changed, then the
0015 filesystem is active on another machine and the open fails. If the MMP
0016 code passes all of those checks, a new MMP sequence number is generated
0017 and written to the MMP block, and the mount proceeds.
0018
0019 While the filesystem is live, the kernel sets up a timer to re-check the
0020 MMP block at the specified MMP check interval. To perform the re-check,
0021 the MMP sequence number is re-read; if it does not match the in-memory
0022 MMP sequence number, then another node (node B) has mounted the
0023 filesystem, and node A remounts the filesystem read-only. If the
0024 sequence numbers match, the sequence number is incremented both in
0025 memory and on disk, and the re-check is complete.
0026
0027 The hostname and device filename are written into the MMP block whenever
0028 an open operation succeeds. The MMP code does not use these values; they
0029 are provided purely for informational purposes.
0030
0031 The checksum is calculated against the FS UUID and the MMP structure.
0032 The MMP structure (``struct mmp_struct``) is as follows:
0033
0034 .. list-table::
0035 :widths: 8 12 20 40
0036 :header-rows: 1
0037
0038 * - Offset
0039 - Type
0040 - Name
0041 - Description
0042 * - 0x0
0043 - __le32
0044 - mmp_magic
0045 - Magic number for MMP, 0x004D4D50 (“MMP”).
0046 * - 0x4
0047 - __le32
0048 - mmp_seq
0049 - Sequence number, updated periodically.
0050 * - 0x8
0051 - __le64
0052 - mmp_time
0053 - Time that the MMP block was last updated.
0054 * - 0x10
0055 - char[64]
0056 - mmp_nodename
0057 - Hostname of the node that opened the filesystem.
0058 * - 0x50
0059 - char[32]
0060 - mmp_bdevname
0061 - Block device name of the filesystem.
0062 * - 0x70
0063 - __le16
0064 - mmp_check_interval
0065 - The MMP re-check interval, in seconds.
0066 * - 0x72
0067 - __le16
0068 - mmp_pad1
0069 - Zero.
0070 * - 0x74
0071 - __le32[226]
0072 - mmp_pad2
0073 - Zero.
0074 * - 0x3FC
0075 - __le32
0076 - mmp_checksum
0077 - Checksum of the MMP block.