@@ -8,15 +8,19 @@ FLAKEY_ALLOW_WRITES=0
FLAKEY_DROP_WRITES=1
FLAKEY_ERROR_WRITES=2
+export FLAKEY_NAME="flakey-test.$seq"
+export FLAKEY_RTNAME="flakey-rttest.$seq"
+export FLAKEY_LOGNAME="flakey-logtest.$seq"
+
_init_flakey()
{
# Scratch device
local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
- FLAKEY_DEV=/dev/mapper/flakey-test
+ export FLAKEY_DEV="/dev/mapper/$FLAKEY_NAME"
FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 180 0"
FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 drop_writes"
FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes"
- _dmsetup_create flakey-test --table "$FLAKEY_TABLE" || \
+ _dmsetup_create $FLAKEY_NAME --table "$FLAKEY_TABLE" || \
_fatal "failed to create flakey device"
# Realtime device
@@ -25,7 +29,7 @@ _init_flakey()
# Set up the device switch
local backing_dev="$SCRATCH_RTDEV"
export NON_FLAKEY_RTDEV="$SCRATCH_RTDEV"
- SCRATCH_RTDEV=/dev/mapper/flakey-rttest
+ SCRATCH_RTDEV=/dev/mapper/$FLAKEY_RTNAME
else
# Already set up; recreate tables
local backing_dev="$NON_FLAKEY_RTDEV"
@@ -34,7 +38,7 @@ _init_flakey()
FLAKEY_RTTABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
FLAKEY_RTTABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
FLAKEY_RTTABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
- _dmsetup_create flakey-rttest --table "$FLAKEY_RTTABLE" || \
+ _dmsetup_create $FLAKEY_RTNAME --table "$FLAKEY_RTTABLE" || \
_fatal "failed to create flakey rt device"
fi
@@ -44,7 +48,7 @@ _init_flakey()
# Set up the device switch
local backing_dev="$SCRATCH_LOGDEV"
export NON_FLAKEY_LOGDEV="$SCRATCH_LOGDEV"
- SCRATCH_LOGDEV=/dev/mapper/flakey-logtest
+ SCRATCH_LOGDEV=/dev/mapper/$FLAKEY_LOGNAME
else
# Already set up; recreate tables
local backing_dev="$NON_FLAKEY_LOGDEV"
@@ -53,7 +57,7 @@ _init_flakey()
FLAKEY_LOGTABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
FLAKEY_LOGTABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
FLAKEY_LOGTABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
- _dmsetup_create flakey-logtest --table "$FLAKEY_LOGTABLE" || \
+ _dmsetup_create $FLAKEY_LOGNAME --table "$FLAKEY_LOGTABLE" || \
_fatal "failed to create flakey log device"
fi
}
@@ -74,15 +78,15 @@ _cleanup_flakey()
{
# If dmsetup load fails then we need to make sure to do resume here
# otherwise the umount will hang
- test -n "$NON_FLAKEY_LOGDEV" && $DMSETUP_PROG resume flakey-logtest &> /dev/null
- test -n "$NON_FLAKEY_RTDEV" && $DMSETUP_PROG resume flakey-rttest &> /dev/null
+ test -n "$NON_FLAKEY_LOGDEV" && $DMSETUP_PROG resume $FLAKEY_LOGNAME &> /dev/null
+ test -n "$NON_FLAKEY_RTDEV" && $DMSETUP_PROG resume $FLAKEY_RTNAME &> /dev/null
$DMSETUP_PROG resume flakey-test > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- _dmsetup_remove flakey-test
- test -n "$NON_FLAKEY_LOGDEV" && _dmsetup_remove flakey-logtest
- test -n "$NON_FLAKEY_RTDEV" && _dmsetup_remove flakey-rttest
+ _dmsetup_remove $FLAKEY_NAME
+ test -n "$NON_FLAKEY_LOGDEV" && _dmsetup_remove $FLAKEY_LOGNAME
+ test -n "$NON_FLAKEY_RTDEV" && _dmsetup_remove $FLAKEY_RTNAME
if [ -n "$NON_FLAKEY_LOGDEV" ]; then
SCRATCH_LOGDEV="$NON_FLAKEY_LOGDEV"
@@ -125,54 +129,58 @@ _load_flakey_table()
# Suspend the scratch device before the log and realtime devices so
# that the kernel can freeze and flush the filesystem if the caller
# wanted a freeze.
- $DMSETUP_PROG suspend $suspend_opt flakey-test
- [ $? -ne 0 ] && _fatal "failed to suspend flakey-test"
+ $DMSETUP_PROG suspend $suspend_opt $FLAKEY_NAME
+ [ $? -ne 0 ] && _fatal "failed to suspend $FLAKEY_NAME"
if [ -n "$NON_FLAKEY_RTDEV" ]; then
- $DMSETUP_PROG suspend $suspend_opt flakey-rttest
+ $DMSETUP_PROG suspend $suspend_opt $FLAKEY_RTNAME
[ $? -ne 0 ] && _fatal "failed to suspend flakey-rttest"
fi
if [ -n "$NON_FLAKEY_LOGDEV" ]; then
- $DMSETUP_PROG suspend $suspend_opt flakey-logtest
+ $DMSETUP_PROG suspend $suspend_opt $FLAKEY_LOGNAME
[ $? -ne 0 ] && _fatal "failed to suspend flakey-logtest"
fi
# There may be multiple dm targets in the table, and these dm targets
# will be joined by the newline ("\n"). Option --table can not cope with
# the multiple-targets case, so get them by reading from standard input.
- echo -e "$table" | $DMSETUP_PROG load flakey-test
- [ $? -ne 0 ] && _fatal "failed to load table into flakey-test"
+ echo -e "$table" | $DMSETUP_PROG load $FLAKEY_NAME
+ [ $? -ne 0 ] && _fatal "failed to load table into $FLAKEY_NAME"
if [ -n "$NON_FLAKEY_RTDEV" ]; then
- echo -e "$rttable" | $DMSETUP_PROG load flakey-rttest
+ echo -e "$rttable" | $DMSETUP_PROG load $FLAKEY_RTNAME
[ $? -ne 0 ] && _fatal "failed to load table into flakey-rttest"
fi
if [ -n "$NON_FLAKEY_LOGDEV" ]; then
- echo -e "$logtable" | $DMSETUP_PROG load flakey-logtest
+ echo -e "$logtable" | $DMSETUP_PROG load $FLAKEY_LOGNAME
[ $? -ne 0 ] && _fatal "failed to load table into flakey-logtest"
fi
# Resume devices in the opposite order that we suspended them.
if [ -n "$NON_FLAKEY_LOGDEV" ]; then
- $DMSETUP_PROG resume flakey-logtest
+ $DMSETUP_PROG resume $FLAKEY_LOGNAME
[ $? -ne 0 ] && _fatal "failed to resume flakey-logtest"
fi
if [ -n "$NON_FLAKEY_RTDEV" ]; then
- $DMSETUP_PROG resume flakey-rttest
+ $DMSETUP_PROG resume $FLAKEY_RTNAME
[ $? -ne 0 ] && _fatal "failed to resume flakey-rttest"
fi
- $DMSETUP_PROG resume flakey-test
- [ $? -ne 0 ] && _fatal "failed to resume flakey-test"
+ $DMSETUP_PROG resume $FLAKEY_NAME
+ [ $? -ne 0 ] && _fatal "failed to resume $FLAKEY_NAME"
}
# Silently drop all writes and unmount/remount to simulate a crash/power
# failure.
_flakey_drop_and_remount()
{
+ # If the full environment is set up, configure ourselves for shutdown
+ type _prepare_for_eio_shutdown &>/dev/null && \
+ _prepare_for_eio_shutdown $FLAKEY_DEV
+
_load_flakey_table $FLAKEY_DROP_WRITES
_unmount_flakey
@@ -188,7 +196,7 @@ _require_flakey_with_error_writes()
{
local SIZE
local TABLE
- local NAME=flakey-test
+ local NAME=$FLAKEY_NAME
_require_dm_target flakey