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
################################################################################
Executable
+116
View File
@@ -0,0 +1,116 @@
#! /bin/bash
# FS QA Test 006
#
# Test xfs' "fail at unmount" error handling configuration. Stop
# XFS from retrying to writeback forever at unmount.
#
#-----------------------------------------------------------------------
# Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
_dmerror_cleanup
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/dmerror
# remove previous $seqres.full before test
rm -f $seqres.full
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_dm_target error
_require_scratch
_require_fs_sysfs error/fail_at_unmount
_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
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.
$FSSTRESS_PROG -z -n 5000 -p 10 \
-f creat=10 \
-f resvsp=1 \
-f truncate=1 \
-f punch=1 \
-f chown=5 \
-f mkdir=5 \
-f rmdir=1 \
-f mknod=1 \
-f unlink=1 \
-f symlink=1 \
-f rename=1 \
-d $SCRATCH_MNT/fsstress >> $seqres.full 2>&1
# Loading error table without "--nolockfs" option. Because "--nolockfs"
# won't freeze fs, then some running I/Os may cause XFS to shutdown
# prematurely. That's not what we want to test.
_dmerror_load_error_table lockfs
_dmerror_unmount
# Mount again to replay log after loading working table, so we have a
# consistent XFS after test.
_dmerror_load_working_table
_dmerror_mount
_dmerror_unmount
# success, all done
status=0
exit
+7
View File
@@ -0,0 +1,7 @@
QA output created by 006
error/metadata/default/max_retries=-1
error/metadata/default/retry_timeout_seconds=0
error/metadata/EIO/max_retries=-1
error/metadata/EIO/retry_timeout_seconds=0
error/metadata/ENOSPC/max_retries=-1
error/metadata/ENOSPC/retry_timeout_seconds=0
+1
View File
@@ -4,6 +4,7 @@
004 db auto quick
005 auto quick
007 auto quota quick
006 auto quick mount
008 rw ioctl auto quick
009 rw ioctl auto prealloc quick
010 auto quick repair