mirror_zfs/lib
Brian Behlendorf a65bb7c518 mmp: claim sequence id before final import
As part of SPA_LOAD_IMPORT add an additional activity check to
detect simultaneous imports from different hosts.  This check is
only required when the timing is such that there's no activity
for the the read-only tryimport check to detect.  This extra
safety chceck operates as follows:

1. Repeats the following MMP check 10 times:
  a. Write out an MMP uberblock with the best txg and a random
     sequence id to all primary pool vdevs.
  b. Verify a minimum number of good writes such that even if
     the pool appears degraded on the remote host it will see
     at least one of the updated MMP uberblocks.
  c. Wait for the MMP interval this leaves a window for other
     racing hosts to make similar modifications which can be
     detected.
  d. Call vdev_uberblock_load() to determine the best uberblock
     to use, this should be the MMP uberblock just written.
  e. Verify the txg and random sequeunce number match the MMP
     uberblock written in 1a.

2. Restore the original MMP uberblocks.  This allows the check
   to be performed again if the pool fails to import for an
   unrelated reason.

This change also includes some refactoring and minor improvements.

- Never try loading earlier txgs during import when the import
  fails with EREMOTEIO or EINTER.  These errors don't indicate
  the txg is damaged but instead that its either in use on a
  remote host or the import was interactively cancelled.  No
  rewind is also performed for EBADD which can result from a
  stale trusted config when doing a verbatim import.

- Refactor the code for consistent logging of the multihost
  activity check using spa_load_note() and console messages
  indicating when the activity check was trigger and the result.

- Added MMP_*_MASK and MMP_SEQ_CLEAR() macros to allow easier
  modification of the sequence number in an uberblock.

- Added ZFS_LOAD_INFO_DEBUG environment variable which can be
  set to log to dump to stdout the spa_load_info nvlist returned
  during import.  This is used by the updated mmp test cases
  to determine if an activity check was run and its result.

- Standardize the mmp messages similarly to make it easier to
  find all the relevent mmp lines in the debug log.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Akash B <akash-b@hpe.com>
2026-02-11 13:33:19 -08:00
..
libavl cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
libefi SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
libicp icp: remove skein module 2024-05-31 15:13:39 -07:00
libnvpair SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
libshare SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
libspl linux: use sys/stat.h instead of linux/stat.h 2025-12-09 11:58:45 -08:00
libtpool SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
libunicode cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
libuutil SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
libzdb Provide macros for setting and getting blkptr birth times 2024-03-25 15:01:54 -07:00
libzfs mmp: claim sequence id before final import 2026-02-11 13:33:19 -08:00
libzfs_core Expose dataset encryption status via fast stat path 2025-06-17 10:49:40 -07:00
libzfsbootenv SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
libzpool Enable zhack to work properly with 4k sector size disks 2026-02-11 13:33:12 -08:00
libzstd libzstd: also build with LIBZPOOL_CPPFLAGS 2024-09-09 14:13:27 -07:00
libzutil SPDX: license tags: BSD-3-Clause 2025-04-16 09:59:44 -07:00
Makefile.am libzdb: Initial breakout of libzdb 2024-02-05 10:00:41 -08:00