mmp.rst 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. .. SPDX-License-Identifier: GPL-2.0
  2. Multiple Mount Protection
  3. -------------------------
  4. Multiple mount protection (MMP) is a feature that protects the
  5. filesystem against multiple hosts trying to use the filesystem
  6. simultaneously. When a filesystem is opened (for mounting, or fsck,
  7. etc.), the MMP code running on the node (call it node A) checks a
  8. sequence number. If the sequence number is EXT4\_MMP\_SEQ\_CLEAN, the
  9. open continues. If the sequence number is EXT4\_MMP\_SEQ\_FSCK, then
  10. fsck is (hopefully) running, and open fails immediately. Otherwise, the
  11. open code will wait for twice the specified MMP check interval and check
  12. the sequence number again. If the sequence number has changed, then the
  13. filesystem is active on another machine and the open fails. If the MMP
  14. code passes all of those checks, a new MMP sequence number is generated
  15. and written to the MMP block, and the mount proceeds.
  16. While the filesystem is live, the kernel sets up a timer to re-check the
  17. MMP block at the specified MMP check interval. To perform the re-check,
  18. the MMP sequence number is re-read; if it does not match the in-memory
  19. MMP sequence number, then another node (node B) has mounted the
  20. filesystem, and node A remounts the filesystem read-only. If the
  21. sequence numbers match, the sequence number is incremented both in
  22. memory and on disk, and the re-check is complete.
  23. The hostname and device filename are written into the MMP block whenever
  24. an open operation succeeds. The MMP code does not use these values; they
  25. are provided purely for informational purposes.
  26. The checksum is calculated against the FS UUID and the MMP structure.
  27. The MMP structure (``struct mmp_struct``) is as follows:
  28. .. list-table::
  29. :widths: 8 12 20 40
  30. :header-rows: 1
  31. * - Offset
  32. - Type
  33. - Name
  34. - Description
  35. * - 0x0
  36. - \_\_le32
  37. - mmp\_magic
  38. - Magic number for MMP, 0x004D4D50 (“MMP”).
  39. * - 0x4
  40. - \_\_le32
  41. - mmp\_seq
  42. - Sequence number, updated periodically.
  43. * - 0x8
  44. - \_\_le64
  45. - mmp\_time
  46. - Time that the MMP block was last updated.
  47. * - 0x10
  48. - char[64]
  49. - mmp\_nodename
  50. - Hostname of the node that opened the filesystem.
  51. * - 0x50
  52. - char[32]
  53. - mmp\_bdevname
  54. - Block device name of the filesystem.
  55. * - 0x70
  56. - \_\_le16
  57. - mmp\_check\_interval
  58. - The MMP re-check interval, in seconds.
  59. * - 0x72
  60. - \_\_le16
  61. - mmp\_pad1
  62. - Zero.
  63. * - 0x74
  64. - \_\_le32[226]
  65. - mmp\_pad2
  66. - Zero.
  67. * - 0x3FC
  68. - \_\_le32
  69. - mmp\_checksum
  70. - Checksum of the MMP block.