dmflakey: fix environment-destroying mistakes in _cleanup_flakey
authorDarrick J. Wong <djwong@kernel.org>
Thu, 28 Oct 2021 20:17:39 +0000 (13:17 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 31 Oct 2021 14:22:27 +0000 (22:22 +0800)
commit45d3cae176a592717de3de6d13ab3cc29e730722
tree30cc3c6e7bc10b7aa9e27c03d5a3876b1551f6e4
parent5c4de305a3a75b7db982821330a51e775a3678c4
dmflakey: fix environment-destroying mistakes in _cleanup_flakey

_cleanup_flakey can be called even when _init_flakey hasn't been called.
For example, _require_flakey_with_error_writes does this.

Unfortunately, the patch to add support for external logs and rt devices
will "reset" the SCRATCH_LOGDEV/SCRATCH_RTDEV variables without noticing
that _init_flakey hasn't been called yet.  When this happens, those two
variables will be set to the empty string, with the result that the rest
of the test doesn't use those devices.

To fix this, only reset SCRATCH_LOGDEV/RTDEV to the "NON_FLAKEY" value
if we actually set one.

Fixes: 9c1f3149 ("dmflakey: support external log and realtime devices")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/dmflakey