aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2018-01-11 14:49:31 +0800
committerEryu Guan <eguan@redhat.com>2018-01-12 11:40:39 +0800
commitb237e01b12881d1ad02ba387b8fa32e89e44376b (patch)
tree857bea03d232518522fcd63f4e432c3c102bdbef
parent976c9ca6561ce5fc4a62c6cab1ecad0a92a98511 (diff)
downloadxfstests-b237e01b12881d1ad02ba387b8fa32e89e44376b.tar.gz
dmflakey: support error_writes feature for dm-flakey
Add _require_flakey_with_error_writes() to check the availability of dm-flakey target and its error_writes feature, and support for enabling FLAKEY_TABLE_ERROR table by passing FLAKEY_ERROR_WRITES to _load_flakey_table(). Signed-off-by: Hou Tao <houtao1@huawei.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
-rw-r--r--common/dmflakey24
1 files changed, 23 insertions, 1 deletions
diff --git a/common/dmflakey b/common/dmflakey
index e34fce85ca..06eee378d0 100644
--- a/common/dmflakey
+++ b/common/dmflakey
@@ -20,6 +20,7 @@
FLAKEY_ALLOW_WRITES=0
FLAKEY_DROP_WRITES=1
+FLAKEY_ERROR_WRITES=2
echo $MOUNT_OPTIONS | grep -q dax
if [ $? -eq 0 ]; then
@@ -32,6 +33,7 @@ _init_flakey()
FLAKEY_DEV=/dev/mapper/flakey-test
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_PROG create flakey-test --table "$FLAKEY_TABLE" || \
_fatal "failed to create flakey device"
$DMSETUP_PROG mknodes > /dev/null 2>&1
@@ -67,9 +69,9 @@ _cleanup_flakey()
# table, so it simulates power failure.
_load_flakey_table()
{
-
table="$FLAKEY_TABLE"
[ $1 -eq $FLAKEY_DROP_WRITES ] && table="$FLAKEY_TABLE_DROP"
+ [ $1 -eq $FLAKEY_ERROR_WRITES ] && table="$FLAKEY_TABLE_ERROR"
suspend_opt="--nolockfs"
[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
@@ -101,3 +103,23 @@ _flakey_drop_and_remount()
_load_flakey_table $FLAKEY_ALLOW_WRITES
_mount_flakey
}
+
+_require_flakey_with_error_writes()
+{
+ local SIZE
+ local TABLE
+ local NAME=flakey-test
+
+ _require_dm_target flakey
+
+ SIZE=`blockdev --getsz $SCRATCH_DEV`
+ TABLE="0 $SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes"
+
+ $DMSETUP_PROG create $NAME --table "$TABLE" >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ _notrun "This test requires error_writes feature in dm-flakey"
+ fi
+ $DMSETUP_PROG mknodes >/dev/null 2>&1
+
+ _cleanup_flakey
+}