diff mbox series

[v2] dmflakey: fix environment-destroying mistakes in _cleanup_flakey

Message ID 20211028201739.GQ24282@magnolia (mailing list archive)
State New, archived
Headers show
Series [v2] dmflakey: fix environment-destroying mistakes in _cleanup_flakey | expand

Commit Message

Darrick J. Wong Oct. 28, 2021, 8:17 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

_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>
---
v2: Add review, actually send to list this time
v1: Note: I observed this problem when running Brian Foster's new test
    "[PATCH v2] tests/xfs: test COW writeback failure when overlapping
     non-shared blocks" with an external xfs log.
---
 common/dmflakey |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/common/dmflakey b/common/dmflakey
index af4371a3..52da3b10 100644
--- a/common/dmflakey
+++ b/common/dmflakey
@@ -84,11 +84,15 @@  _cleanup_flakey()
 	test -n "$NON_FLAKEY_LOGDEV" && _dmsetup_remove flakey-logtest
 	test -n "$NON_FLAKEY_RTDEV" && _dmsetup_remove flakey-rttest
 
-	SCRATCH_LOGDEV="$NON_FLAKEY_LOGDEV"
-	unset NON_FLAKEY_LOGDEV
+	if [ -n "$NON_FLAKEY_LOGDEV" ]; then
+		SCRATCH_LOGDEV="$NON_FLAKEY_LOGDEV"
+		unset NON_FLAKEY_LOGDEV
+	fi
 
-	SCRATCH_RTDEV="$NON_FLAKEY_RTDEV"
-	unset NON_FLAKEY_RTDEV
+	if [ -n "$NON_FLAKEY_RTDEV" ]; then
+		SCRATCH_RTDEV="$NON_FLAKEY_RTDEV"
+		unset NON_FLAKEY_RTDEV
+	fi
 }
 
 # _load_flakey_table <table> [lockfs]