]> git.proxmox.com Git - mirror_zfs.git/commit
ZTS: Provide for nested cleanup routines
authorRyan Moeller <ryan@iXsystems.com>
Tue, 3 Mar 2020 18:28:09 +0000 (13:28 -0500)
committerGitHub <noreply@github.com>
Tue, 3 Mar 2020 18:28:09 +0000 (10:28 -0800)
commit0a0f9a7dc6e4f215089cf0aabb230d5dd5dfbd1e
treed994b7072bd1ccff7e2d96566b347edc87904185
parent9bb907bc3fdcaa132ecb0f8326c8815f27824ce4
ZTS: Provide for nested cleanup routines

Shared test library functions lack a simple way to ensure proper
cleanup in the event of a failure.  The `log_onexit` cleanup pattern
cannot be used in library functions because it uses one global
variable to store the cleanup command.

An example of where this is a serious issue is when a tunable that
artifically stalls kernel progress gets activated and then some check
fails.  Unless the caller knows about the tunable and sets it back,
the system will be left in a bad state.

To solve this problem, turn the global cleanup variable into a stack.
Provide push and pop functions to add additional cleanup steps and
remove them after it is safe again.

The first use of this new functionality is in attempt_during_removal,
which sets REMOVAL_SUSPEND_PROGRESS.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10080
tests/test-runner/include/logapi.shlib
tests/zfs-tests/tests/functional/removal/removal.kshlib