]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs/006: refactor reset error handling code to common/rc
authorZorro Lang <zlang@redhat.com>
Fri, 19 Aug 2016 17:56:31 +0000 (01:56 +0800)
committerEryu Guan <eguan@redhat.com>
Fri, 26 Aug 2016 07:29:49 +0000 (15:29 +0800)
Nearly 1/3 code is used to reset the xfs error handling attributes,
This part can be picked up, and used for other cases. So move them
to a new function _reset_xfs_sysfs_error_handling() in common/rc.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc
tests/xfs/006
tests/xfs/006.out

index 4a30fb3699a28453b59f8fdccd8fa737ab26080e..04039a42168c08fc8a9b703518f18c8cfecf12fb 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3890,6 +3890,43 @@ _get_fs_sysfs_attr()
        cat /sys/fs/${FSTYP}/${dname}/${attr}
 }
 
+
+# Reset all xfs error handling attributes, set them to original
+# status.
+#
+# Only one argument, and it's mandatory:
+#  - dev: device name, e.g. $SCRATCH_DEV
+#
+# Note: this function only works for XFS
+_reset_xfs_sysfs_error_handling()
+{
+       local dev=$1
+
+       if [ ! -b "$dev" -o "$FSTYP" != "xfs" ];then
+               _fail "Usage: reset_xfs_sysfs_error_handling <device>"
+       fi
+
+       _set_fs_sysfs_attr $dev error/fail_at_unmount 1
+       echo -n "error/fail_at_unmount="
+       _get_fs_sysfs_attr $dev error/fail_at_unmount
+
+       # Make sure all will be configured to retry forever by default, except
+       # for ENODEV, which is an unrecoverable error, so it will be configured
+       # to not retry on error by default.
+       for e in default EIO ENOSPC; do
+               _set_fs_sysfs_attr $dev \
+                                  error/metadata/${e}/max_retries -1
+               echo -n "error/metadata/${e}/max_retries="
+               _get_fs_sysfs_attr $dev error/metadata/${e}/max_retries
+
+               _set_fs_sysfs_attr $dev \
+                                  error/metadata/${e}/retry_timeout_seconds 0
+               echo -n "error/metadata/${e}/retry_timeout_seconds="
+               _get_fs_sysfs_attr $dev \
+                                  error/metadata/${e}/retry_timeout_seconds
+       done
+}
+
 # Skip if we are running an older binary without the stricter input checks.
 # Make multiple checks to be sure that there is no regression on the one
 # selected feature check, which would skew the result.
index 89100267079a13a8728e754416a9a248e48ded1c..58f93489ee190d7b5e2bf248718175145c8f8ae1 100755 (executable)
@@ -57,31 +57,18 @@ _scratch_mkfs > $seqres.full 2>&1
 _dmerror_init
 _dmerror_mount
 
-# Enable fail_at_unmount, so XFS stops retrying on errors at unmount
-# time. _fail the test if we fail to set it to 1, because the test
-# probably will hang in such case and block subsequent tests.
-_set_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount 1
+# Make sure all error handling attributes are original status
+reset_xfs_sysfs_error_handling $DMERROR_DEV
+
+# Make sure fail_at_unmount is enabled, so XFS stops retrying on
+# errors at unmount time. _fail the test if we fail to set it to 1,
+# because the test probably will hang in such case and block
+# subsequent tests.
 attr=`_get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount`
 if [ "$attr" != "1" ]; then
        _fail "Failed to set error/fail_at_unmount: $attr"
 fi
 
-# Make sure all will be configured to retry forever by default, except
-# for ENODEV, which is an unrecoverable error, so it will be configured
-# to not retry on error by default.
-for e in default EIO ENOSPC; do
-       _set_fs_sysfs_attr $DMERROR_DEV \
-                          error/metadata/${e}/max_retries -1
-       echo -n "error/metadata/${e}/max_retries="
-       _get_fs_sysfs_attr $DMERROR_DEV error/metadata/${e}/max_retries
-
-       _set_fs_sysfs_attr $DMERROR_DEV \
-                          error/metadata/${e}/retry_timeout_seconds 0
-       echo -n "error/metadata/${e}/retry_timeout_seconds="
-       _get_fs_sysfs_attr $DMERROR_DEV \
-                          error/metadata/${e}/retry_timeout_seconds
-done
-
 # start a metadata-intensive workload, but no data allocation operation.
 # Because uncompleted new space allocation I/Os may cause XFS to shutdown
 # after loading error table.
index 393f4116bc9d9acb3dd0b864f22e2208854efa78..3260b3a2743cfa739ffdf2955a9e02512a09b761 100644 (file)
@@ -1,4 +1,5 @@
 QA output created by 006
+error/fail_at_unmount=1
 error/metadata/default/max_retries=-1
 error/metadata/default/retry_timeout_seconds=0
 error/metadata/EIO/max_retries=-1