mirror_zfs/lib/libzfs
Brian Behlendorf 20176224ee 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-09 09:36:01 -08:00
..
os libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
.gitignore Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libzfs_changelist.c zfs: replace uu_avl with sys/avl 2025-11-17 06:21:26 -08:00
libzfs_config.c zfs: replace uu_avl with sys/avl 2025-11-17 06:21:26 -08:00
libzfs_crypto.c libzpool: remove global libzpool includes 2025-11-12 10:03:15 -08:00
libzfs_dataset.c Add snapshots_changed_nsecs dataset property 2026-01-06 09:36:20 -08:00
libzfs_diff.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
libzfs_impl.h libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
libzfs_import.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
libzfs_iter.c Sort the blocking snapshots list #12751 (#17264) 2025-05-01 17:40:23 -07:00
libzfs_mount.c libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
libzfs_pool.c mmp: claim sequence id before final import 2026-02-09 09:36:01 -08:00
libzfs_sendrecv.c libzfs: ignoring unreachable code 2025-11-07 09:27:18 -05:00
libzfs_share_nfs.c libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
libzfs_share.c libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
libzfs_share.h libshare: fold into libzfs and reorg headers a little 2025-12-19 19:52:33 -08:00
libzfs_status.c Suppress some ashift warnings 2025-10-13 10:41:42 -07:00
libzfs_util.c Detect a slow raidz child during reads 2025-09-10 15:25:03 -07:00
libzfs.abi Add snapshots_changed_nsecs dataset property 2026-01-06 09:36:20 -08:00
libzfs.pc.in Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
libzfs.suppr Library ABI tracking with abigail 2020-11-17 09:18:52 -08:00
Makefile.am build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
THIRDPARTYLICENSE.openssl Fix typos in lib/ 2019-09-02 17:53:27 -07:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00