zfs/tests/zfs-tests/tests/functional/fault
Mariusz Zaborski 40a9efd0e8 zfs: support force exporting pools
This is primarily of use when a pool has lost its disk, while the user
doesn't care about any pending (or otherwise) transactions.

Implement various control methods to make this feasible:
- txg_wait can now take a NOSUSPEND flag, in which case the caller will
  be alerted if their txg can't be committed.  This is primarily of
  interest for callers that would normally pass TXG_WAIT, but don't want
  to wait if the pool becomes suspended, which allows unwinding in some
  cases, specifically when one is attempting a non-forced export.
  Without this, the non-forced export would preclude a forced export
  by virtue of holding the namespace lock indefinitely.
- txg_wait also returns failure for TXG_WAIT users if a pool is actually
  being force exported.  Adjust most callers to tolerate this.
- spa_config_enter_flags now takes a NOSUSPEND flag to the same effect.
- DMU objset initiator which may be set on an objset being forcibly
  exported / unmounted.
- SPA export initiator may be set on a pool being forcibly exported.
- DMU send/recv now use an interruption mechanism which relies on the
  SPA export initiator being able to enumerate datasets and closing any
  send/recv streams, causing their EINTR paths to be invoked.
- ZIO now has a cancel entry point, which tells all suspended zios to
  fail, and which suppresses the failures for non-CANFAIL users.
- metaslab, etc. cleanup, which consists of simply throwing away any
  changes that were not able to be synced out.
- Linux specific: introduce a new tunable,
  zfs_forced_export_unmount_enabled, which allows the filesystem to
  remain in a modified 'unmounted' state upon exiting zpl_umount_begin,
  to achieve parity with FreeBSD and illumos,
  which have VFS-level support for yanking filesystems out from under
  users.  However, this only helps when the user is actively performing
  I/O, while not sitting on the filesystem.  In particular, this allows
  test #3 below to pass on Linux.
- Add basic logic to zpool to indicate a force-exporting pool, instead
  of crashing due to lack of config, etc.

Add tests which cover the basic use cases:
- Force export while a send is in progress
- Force export while a recv is in progress
- Force export while POSIX I/O is in progress

This change modifies the libzfs ABI:
- New ZPOOL_STATUS_FORCE_EXPORTING zpool_status_t enum value.
- New field libzfs_force_export for libzfs_handle.

Signed-off-by: Will Andrews <will@firepipe.net>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Sponsored-by:  Klara, Inc.
Sponsored-by:  Catalogics, Inc.
Sponsored-by:  Wasabi Technology, Inc.
Closes #3461
(cherry picked from commit 852e633772217d779a63e8c46fe3c5f81dd8960e)
2023-07-05 13:27:30 +00:00
..
Makefile.am ZED: Match added disk by pool/vdev GUID if found (#12217) 2021-09-14 12:10:44 -07:00
auto_offline_001_pos.ksh Fix various typos 2021-04-07 13:27:11 -07:00
auto_online_001_pos.ksh zfs: support force exporting pools 2023-07-05 13:27:30 +00:00
auto_online_002_pos.ksh ZED: Match added disk by pool/vdev GUID if found (#12217) 2021-09-14 12:10:44 -07:00
auto_replace_001_pos.ksh ZTS: Fix auto_replace_001_pos test 2018-10-29 15:05:14 -05:00
auto_spare_001_pos.ksh Distributed Spare (dRAID) Feature 2020-11-13 13:51:51 -08:00
auto_spare_002_pos.ksh Distributed Spare (dRAID) Feature 2020-11-13 13:51:51 -08:00
auto_spare_ashift.ksh Distributed Spare (dRAID) Feature 2020-11-13 13:51:51 -08:00
auto_spare_multiple.ksh Distributed Spare (dRAID) Feature 2020-11-13 13:51:51 -08:00
auto_spare_shared.ksh Distributed Spare (dRAID) Feature 2020-11-13 13:51:51 -08:00
cleanup.ksh Add scrub after resilver zed script 2018-02-23 11:38:05 -08:00
decompress_fault.ksh ZTS: Catalog tunable names for tests in tunables.cfg 2020-01-14 14:57:28 -08:00
decrypt_fault.ksh Update ZTS to work on FreeBSD 2019-12-18 12:29:43 -08:00
fault.cfg ZTS: Fix a few defaults 2020-01-31 08:51:23 -08:00
scrub_after_resilver.ksh ZTS: Fix zpool_status_-s 2019-10-11 10:22:20 -07:00
setup.ksh Add scrub after resilver zed script 2018-02-23 11:38:05 -08:00
zpool_status_-s.ksh ZTS: Catalog tunable names for tests in tunables.cfg 2020-01-14 14:57:28 -08:00