diff mbox series

[09/40] fstests: per-test dmdelay instances

Message ID 20241127045403.3665299-10-david@fromorbit.com (mailing list archive)
State New
Headers show
Series fstests: concurrent test execution | expand

Commit Message

Dave Chinner Nov. 27, 2024, 4:51 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

We can't run two tests that use dmdelay at the same time because
the device name is the same. hence they interfere with each other.
Give dmdelay devices their own per-test names to avoid this
problem.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/dmdelay | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/common/dmdelay b/common/dmdelay
index 66cac1a70..1c4fca6e9 100644
--- a/common/dmdelay
+++ b/common/dmdelay
@@ -7,13 +7,15 @@ 
 DELAY_NONE=0
 DELAY_READ=1
 
+export DELAY_NAME="delay-test.$seq"
+
 _init_delay()
 {
 	local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
-	DELAY_DEV=/dev/mapper/delay-test
+	DELAY_DEV=/dev/mapper/$DELAY_NAME
 	DELAY_TABLE="0 $BLK_DEV_SIZE delay $SCRATCH_DEV 0 0"
 	DELAY_TABLE_RDELAY="0 $BLK_DEV_SIZE delay $SCRATCH_DEV 0 10000 $SCRATCH_DEV 0 0"
-	_dmsetup_create delay-test --table "$DELAY_TABLE" || \
+	_dmsetup_create $DELAY_NAME --table "$DELAY_TABLE" || \
 		_fatal "failed to create delay device"
 }
 
@@ -33,9 +35,9 @@  _cleanup_delay()
 {
 	# If dmsetup load fails then we need to make sure to do resume here
 	# otherwise the umount will hang
-	$DMSETUP_PROG resume delay-test > /dev/null 2>&1
+	$DMSETUP_PROG resume $DELAY_NAME > /dev/null 2>&1
 	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
-	_dmsetup_remove delay-test
+	_dmsetup_remove $DELAY_NAME
 }
 
 # _load_delay_table <table> [lockfs]
@@ -52,15 +54,15 @@  _load_delay_table()
 
 	# run a suspend/resume cycle to avoid excessive resume delays once a
 	# delay is introduced below
-	$DMSETUP_PROG suspend $suspend_opt delay-test
-	$DMSETUP_PROG resume $suspend_opt delay-test
+	$DMSETUP_PROG suspend $suspend_opt $DELAY_NAME
+	$DMSETUP_PROG resume $suspend_opt $DELAY_NAME
 
-	$DMSETUP_PROG suspend $suspend_opt delay-test
+	$DMSETUP_PROG suspend $suspend_opt $DELAY_NAME
 	[ $? -ne 0 ] && _fatal "failed to suspend delay-test"
 
-	$DMSETUP_PROG load delay-test --table "$table"
+	$DMSETUP_PROG load $DELAY_NAME --table "$table"
 	[ $? -ne 0 ] && _fatal "failed to load table into delay-test"
 
-	$DMSETUP_PROG resume delay-test
+	$DMSETUP_PROG resume $DELAY_NAME
 	[ $? -ne 0 ] && _fatal  "failed to resume delay-test"
 }