zfs/tests/zfs-tests/cmd
John Gallagher e60e158eff Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.

This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:

 - Scrubs or resilvers to complete
 - Devices to initialized
 - Devices to be replaced
 - Devices to be removed
 - Checkpoints to be discarded
 - Background freeing to complete

For example, a scrub that is in progress could be waited for by running

    zpool wait -t scrub <pool>

This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.

This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.

Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:

 - Added ZoL-style ioctl input declaration.
 - Reorganized error handling in zpool_initialize in libzfs to integrate
   better with changes made for TRIM support.
 - Fixed check for whether a checkpoint discard is in progress.
   Previously it also waited if the pool had a checkpoint, instead of
   just if a checkpoint was being discarded.
 - Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
 - Updated more existing tests to make use of new 'zpool wait'
   functionality, tests that don't exist in Delphix OS.
 - Used existing ZoL tunable zfs_scan_suspend_progress, together with
   zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
 - Added support for a non-integral interval argument to zpool wait.

Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-13 18:09:06 -07:00
..
chg_usr_exec Add the ZFS Test Suite 2016-03-16 13:46:16 -07:00
devname2devid Fedora 28: Fix misc bounds check compiler warnings 2018-04-04 10:16:47 -07:00
dir_rd_update Use cstyle -cpP in `make cstyle` check 2016-12-12 10:46:26 -08:00
file_check Add the ZFS Test Suite 2016-03-16 13:46:16 -07:00
file_trunc Enable remaining tests 2017-05-22 12:34:32 -04:00
file_write OpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R 2016-10-03 14:51:15 -07:00
get_diff Add missing .gitignore from "Implement Redacted Send/Receive" 2019-06-23 11:51:29 -07:00
largest_file Use sigaction(2) instead of sigset(3) for portability 2019-04-30 20:45:17 -07:00
libzfs_input_check Add subcommand to wait for background zfs activity to complete 2019-09-13 18:09:06 -07:00
mkbusy Fedora 28: Fix misc bounds check compiler warnings 2018-04-04 10:16:47 -07:00
mkfile Fix calloc(3) arguments order 2018-04-12 10:50:39 -07:00
mkfiles Add support for user/group dnode accounting & quota 2016-10-07 09:45:13 -07:00
mktree Fedora 28: Fix misc bounds check compiler warnings 2018-04-04 10:16:47 -07:00
mmap_exec Enable remaining tests 2017-05-22 12:34:32 -04:00
mmap_libaio Fix mmap / libaio deadlock 2018-03-28 10:19:22 -07:00
mmapwrite Fix typos in tests/ 2019-09-02 18:14:53 -07:00
nvlist_to_lua OpenZFS 7431 - ZFS Channel Programs 2018-02-08 15:28:18 -08:00
randfree_file Fix coverity defects: CID 147692, 147693, 147694 2016-10-13 14:38:59 -07:00
randwritecomp OpenZFS 9166 - zfs storage pool checkpoint 2018-06-26 10:07:42 -07:00
readmmap Add the ZFS Test Suite 2016-03-16 13:46:16 -07:00
rename_dir Add the ZFS Test Suite 2016-03-16 13:46:16 -07:00
rm_lnkcnt_zero_file Prefer `for (;;)` to `while (TRUE)` 2019-08-28 10:38:40 -07:00
stride_dd Implement Redacted Send/Receive 2019-06-19 09:48:12 -07:00
threadsappend Add the ZFS Test Suite 2016-03-16 13:46:16 -07:00
user_ns_exec Take user namespaces into account in policy checks 2018-03-07 15:40:42 -08:00
xattrtest Fix handling of maxblkid for raw sends 2019-03-13 10:52:01 -07:00
Makefile.am Revert "Develop tests for issues #5866 and #8858" 2019-07-29 12:46:56 -07:00
file_common.h Enable remaining tests 2017-05-22 12:34:32 -04:00