brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 174dd65 Raw
78 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3Multiple Mount Protection4-------------------------5 6Multiple mount protection (MMP) is a feature that protects the7filesystem against multiple hosts trying to use the filesystem8simultaneously. When a filesystem is opened (for mounting, or fsck,9etc.), the MMP code running on the node (call it node A) checks a10sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the11open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then12fsck is (hopefully) running, and open fails immediately. Otherwise, the13open code will wait for twice the specified MMP check interval and check14the sequence number again. If the sequence number has changed, then the15filesystem is active on another machine and the open fails. If the MMP16code passes all of those checks, a new MMP sequence number is generated17and written to the MMP block, and the mount proceeds.18 19While the filesystem is live, the kernel sets up a timer to re-check the20MMP block at the specified MMP check interval. To perform the re-check,21the MMP sequence number is re-read; if it does not match the in-memory22MMP sequence number, then another node (node B) has mounted the23filesystem, and node A remounts the filesystem read-only. If the24sequence numbers match, the sequence number is incremented both in25memory and on disk, and the re-check is complete.26 27The hostname and device filename are written into the MMP block whenever28an open operation succeeds. The MMP code does not use these values; they29are provided purely for informational purposes.30 31The checksum is calculated against the FS UUID and the MMP structure.32The MMP structure (``struct mmp_struct``) is as follows:33 34.. list-table::35   :widths: 8 12 20 4036   :header-rows: 137 38   * - Offset39     - Type40     - Name41     - Description42   * - 0x043     - __le3244     - mmp_magic45     - Magic number for MMP, 0x004D4D50 (“MMP”).46   * - 0x447     - __le3248     - mmp_seq49     - Sequence number, updated periodically.50   * - 0x851     - __le6452     - mmp_time53     - Time that the MMP block was last updated.54   * - 0x1055     - char[64]56     - mmp_nodename57     - Hostname of the node that opened the filesystem.58   * - 0x5059     - char[32]60     - mmp_bdevname61     - Block device name of the filesystem.62   * - 0x7063     - __le1664     - mmp_check_interval65     - The MMP re-check interval, in seconds.66   * - 0x7267     - __le1668     - mmp_pad169     - Zero.70   * - 0x7471     - __le32[226]72     - mmp_pad273     - Zero.74   * - 0x3FC75     - __le3276     - mmp_checksum77     - Checksum of the MMP block.78