Files
apfstests/tests/generic/441
T
Jeff Layton 702421f528 generic: add a writeback error handling test
I'm working on a set of kernel patches to change how writeback errors
are handled and reported in the kernel. Instead of reporting a
writeback error to only the first fsync caller on the file, it has
the the kernel report them once on every file description that was
open at the time of the error.

This patch adds a test for this new behavior. Basically, open many fds
to the same file, turn on dm_error, write to each of the fds, and then
fsync them all to ensure that they all get an error back.

To do that, I'm adding a new tools/dmerror script that the C program
can use to load the error table from the script. It's also suitable for
setting up, frobbing and tearing down a dmerror device for by-hand testing.

For now, only ext2/3/4 and xfs are whitelisted on this test, since those
filesystems are included in the initial patchset. We can add to that as
we convert filesystems, and eventually make it a more general test.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-06-20 20:30:05 +08:00

85 lines
2.2 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 441
#
# Open a file several times, write to it, fsync on all fds and make sure that
# they all return 0. Change the device to start throwing errors. Write again
# on all fds and fsync on all fds. Ensure that we get errors on all of them.
# Then fsync on all one last time and verify that all return 0.
#
#-----------------------------------------------------------------------
# Copyright (c) 2017, Jeff Layton <jlayton@redhat.com>
#
# 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 -rf $tmp.* $testdir
_dmerror_cleanup
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/dmerror
# real QA test starts here
_supported_fs ext2 ext3 ext4 xfs
_supported_os Linux
_require_scratch
# Generally, we want to avoid journal errors in this test. Ensure that
# journalled fs' have a logdev.
if [ "$FSTYP" != "ext2" ]; then
_require_logdev
fi
_require_dm_target error
_require_test_program fsync-err
_require_test_program dmerror
rm -f $seqres.full
echo "Format and mount"
_scratch_mkfs > $seqres.full 2>&1
_dmerror_init
_dmerror_mount
_require_fs_space $SCRATCH_MNT 65536
testfile=$SCRATCH_MNT/fsync-err-test
$here/src/fsync-err -d $here/src/dmerror $testfile
# success, all done
_dmerror_load_working_table
_dmerror_unmount
_dmerror_cleanup
# fs may be corrupt after this -- attempt to repair it
_repair_scratch_fs >> $seqres.full
status=0
exit