xfs: configurable behavior on errors at unmount time

XFS used to retry forever on non-critical errors, and unmount could
hang in such case. Commit e6b3bb78962e ("xfs: add "fail at unmount"
error handling configuration") introduced an error configuration
option in sysfs(fail_at_unmount) and made this behavior
configurable.

Now test this "fail_at_unmount" behavior to make sure XFS doesn't
retry forever on error at unmount time, if configured so. Also
introduced new helpers to require/set/get sysfs attributes.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Zorro Lang
2016-07-05 17:30:24 +08:00
committed by Eryu Guan
parent 4cd659be9c
commit 2a7b77abcd
4 changed files with 191 additions and 0 deletions
+67
View File
@@ -3768,6 +3768,73 @@ run_fsx()
fi
}
# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
#
# Only one argument is needed:
# - attr: path name under /sys/fs/$FSTYP/DEV
#
# Usage example:
# _require_fs_sysfs error/fail_at_unmount
_require_fs_sysfs()
{
local attr=$1
local dname=$(_short_dev $TEST_DEV)
if [ -z "$attr" -o -z "$dname" ];then
_fail "Usage: _require_fs_sysfs <sysfs_attr_path>"
fi
if [ ! -e /sys/fs/${FSTYP}/${dname}/${attr} ];then
_notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}"
fi
}
# Write "content" into /sys/fs/$FSTYP/$DEV/$ATTR
#
# All arguments are necessary, and in this order:
# - dev: device name, e.g. $SCRATCH_DEV
# - attr: path name under /sys/fs/$FSTYP/$dev
# - content: the content of $attr
#
# Usage example:
# _set_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount 0
_set_fs_sysfs_attr()
{
local dev=$1
shift
local attr=$1
shift
local content="$*"
if [ ! -b "$dev" -o -z "$attr" -o -z "$content" ];then
_fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>"
fi
local dname=$(_short_dev $dev)
echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr}
}
# Print the content of /sys/fs/$FSTYP/$DEV/$ATTR
#
# All arguments are necessary, and in this order:
# - dev: device name, e.g. $SCRATCH_DEV
# - attr: path name under /sys/fs/$FSTYP/$dev
#
# Usage example:
# _get_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount
_get_fs_sysfs_attr()
{
local dev=$1
local attr=$2
if [ ! -b "$dev" -o -z "$attr" ];then
_fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>"
fi
local dname=$(_short_dev $dev)
cat /sys/fs/${FSTYP}/${dname}/${attr}
}
init_rc
################################################################################