new tests for writeback error reporting behavior
v5 cover new tests for writeback error reporting behavior
The main changes in this set from the last are:
- add a btrfs/999.out file
- use _supported_fs to whitelist fs' on which the tests should run
- fix the ext3/4 mount option handling when creating journal device
- ensure that dmerror is installed on make install
These tests are intended to test the new writeback error reporting introduced by this kernel patchset:
[PATCH v7 00/22] fs: enhanced writeback error reporting with errseq_t (pile #1)
It adds 3 new xfstests for testing kernel behavior when writeback from the pagecache fails: one generic filesystem test, one test for raw block devices and one test for btrfs.
The tests work with dmerror to make data writeback from the pagecache fail, and then tests how the kernel reports errors afterward.
xfs, ext2/3/4 and btrfs all pass on a kernel with the patchset above. "Bare" block devices also work correctly.
Jeff Layton (5):
ext4: allow ext4 to use $SCRATCH_LOGDEV
ext3: allow it to put journal on a separate device when doing
scratch_mkfs
generic: add a writeback error handling test
generic: test writeback error handling on dmerror devices
btrfs: make a btrfs version of writeback error reporting test
.gitignore | 1 + common/dmerror | 13 ++- common/rc | 14 ++- doc/auxiliary-programs.txt | 16 ++++ src/Makefile | 4 +- src/dmerror | 44 +++++++++ src/fsync-err.c | 223 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/999 | 94 +++++++++++++++++++ tests/btrfs/999.out | 3 + tests/btrfs/group | 1 + tests/generic/998 | 63 +++++++++++++ tests/generic/998.out | 2 + tests/generic/999 | 84 +++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 2 + 15 files changed, 559 insertions(+), 8 deletions(-) create mode 100755 src/dmerror create mode 100644 src/fsync-err.c create mode 100755 tests/btrfs/999 create mode 100644 tests/btrfs/999.out create mode 100755 tests/generic/998 create mode 100644 tests/generic/998.out create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out
Signature · 1 line
2.13.0
PATCH v5 1/5 ext4: allow ext4 to use $SCRATCH_LOGDEV
The writeback error handling test requires that you put the journal on a separate device. This allows us to use dmerror to simulate data writeback failure, without affecting the journal.
xfs already has infrastructure for this (a'la $SCRATCH_LOGDEV), so wire up the ext4 code so that it can do the same thing when _scratch_mkfs is called.
--- common/rc | 3 +++ 1 file changed, 3 insertions(+)
common/rc +3 -0
@@ -679,6 +679,9 @@ _scratch_mkfs_ext4() local tmp=`mktemp` local mkfs_status + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \ + mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV" _scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd mkfs_status=$?
Signature · 1 line
2.13.0
PATCH v5 2/5 ext3: allow it to put journal on a separate device when doing scratch_mkfs
In reply to Jeff Layton--- common/rc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
common/rc +10 -1
@@ -840,7 +840,16 @@ _scratch_mkfs() mkfs_cmd="$MKFS_BTRFS_PROG" mkfs_filter="cat" ;; - ext2|ext3) + ext3) + mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F" + mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \"" + + # put journal on separate device? + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \ + mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV" + ;; + ext2) mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F" mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \"" ;;
Signature · 1 line
2.13.0
PATCH v5 3/5 generic: add a writeback error handling test
In reply to Jeff LaytonI'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.
--- .gitignore | 1 + common/dmerror | 13 ++- doc/auxiliary-programs.txt | 16 ++++ src/Makefile | 4 +- src/dmerror | 44 +++++++++ src/fsync-err.c | 223 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/999 | 84 +++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + 9 files changed, 382 insertions(+), 7 deletions(-) create mode 100755 src/dmerror create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out
.gitignore +1 -0
@@ -72,6 +72,7 @@ /src/fs_perms /src/fssum /src/fstest +/src/fsync-err /src/fsync-tester /src/ftrunc /src/genhashnames
common/dmerror +8 -5
@@ -23,22 +23,25 @@ if [ $? -eq 0 ]; then _notrun "Cannot run tests with DAX on dmerror devices" fi -_dmerror_init() +_dmerror_setup() { local dm_backing_dev=$SCRATCH_DEV - $DMSETUP_PROG remove error-test > /dev/null 2>&1 - local blk_dev_size=`blockdev --getsz $dm_backing_dev` DMERROR_DEV='/dev/mapper/error-test' DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0" + DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0" +} + +_dmerror_init() +{ + _dmerror_setup + $DMSETUP_PROG remove error-test > /dev/null 2>&1 $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \ _fatal "failed to create dm linear device" - - DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0" } _dmerror_mount()
doc/auxiliary-programs.txt +16 -0
@@ -16,6 +16,8 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - dmerror -- fault injection block device control + - fsync-err -- tests fsync error reporting after failed writeback - open_by_handle -- open_by_handle_at syscall exercise - stat_test -- statx syscall exercise - t_dir_type -- print directory entries and their file type
@@ -30,6 +32,20 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +dmerror + + dmerror is a program for creating, destroying and controlling a + fault injection device. The device can be set up as initially + working and then flip to throwing errors for testing purposes. + +fsync-err + + Specialized program for testing how the kernel reports errors that + occur during writeback. Works in conjunction with the dmerror script + in tools/ to write data to a device, and then force it to fail + writeback and test that errors are reported during fsync and cleared + afterward. + open_by_handle The open_by_handle program exercises the open_by_handle_at() system
src/Makefile +2 -2
@@ -13,7 +13,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \ t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \ holetest t_truncate_self t_mmap_dio af_unix t_mmap_stale_pmd \ - t_mmap_cow_race t_mmap_fallocate + t_mmap_cow_race t_mmap_fallocate fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
@@ -86,7 +86,7 @@ LINKTEST = $(LTLINK) [email protected] -o $@ $(CFLAGS) $(LDFLAGS) install: default $(addsuffix -install,$(SUBDIRS)) $(INSTALL) -m 755 -d $(PKG_LIB_DIR)/src $(LTINSTALL) -m 755 $(LDIRT) $(PKG_LIB_DIR)/src - $(LTINSTALL) -m 755 fill2attr fill2fs fill2fs_check scaleread.sh $(PKG_LIB_DIR)/src + $(LTINSTALL) -m 755 dmerror fill2attr fill2fs fill2fs_check scaleread.sh $(PKG_LIB_DIR)/src $(LTINSTALL) -m 644 dumpfile $(PKG_LIB_DIR)/src %-install:
src/dmerror new file +44 -0
44 lines not on this page · raw message
src/fsync-err.c new file +223 -0
223 lines not on this page · raw message
tests/generic/999 new file +84 -0
84 lines not on this page · raw message
tests/generic/999.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 999 +Format and mount +Test passed!
tests/generic/group +1 -0
@@ -442,3 +442,4 @@ 437 auto quick 438 auto 439 auto quick punch +999 auto quick
Signature · 1 line
2.13.0
PATCH v5 4/5 generic: test writeback error handling on dmerror devices
In reply to Jeff LaytonEnsure that we get an error back on all fds when a block device is open by multiple writers and writeback fails.
--- tests/generic/998 | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/998.out | 2 ++ tests/generic/group | 1 + 3 files changed, 66 insertions(+) create mode 100755 tests/generic/998 create mode 100644 tests/generic/998.out
tests/generic/998 new file +63 -0
@@ -0,0 +1,63 @@ +#! /bin/bash +# FS QA Test No. 998 +# +# Test writeback error handling when writing to block devices via pagecache. +# See src/fsync-err.c for details of what test actually does. +# +#----------------------------------------------------------------------- +# Copyright (c) 2017, Jeff Layton <[email protected]> +# +# 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_os Linux +_require_scratch +_require_dm_target error +_require_test_program fsync-err +_require_test_program dmerror + +rm -f $seqres.full + +_dmerror_init + +$here/src/fsync-err -d $here/src/dmerror $DMERROR_DEV + +# success, all done +_dmerror_load_working_table +_dmerror_cleanup +_scratch_mkfs > $seqres.full 2>&1 +status=0 +exit
tests/generic/998.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 998 +Test passed!
tests/generic/group +1 -0
@@ -442,4 +442,5 @@ 437 auto quick 438 auto 439 auto quick punch +998 blockdev 999 auto quick
Signature · 1 line
2.13.0
PATCH v5 5/5 btrfs: make a btrfs version of writeback error reporting test
In reply to Jeff LaytonFor btrfs, we can test how it reports data writeback errors on fsync by implementing a suggestion from Chris Mason:
Build a filesystem with 2 devices that stripes the data across both devices, but mirrors metadata across both. Then, make one of the devices fail and test what it does.
--- tests/btrfs/999 | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/999.out | 3 ++ tests/btrfs/group | 1 + 3 files changed, 98 insertions(+) create mode 100755 tests/btrfs/999 create mode 100644 tests/btrfs/999.out
tests/btrfs/999 new file +94 -0
@@ -0,0 +1,94 @@ +#! /bin/bash +# FS QA Test No. 999 +# +# 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 <[email protected]> +# +# 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_os Linux +_supported_fs btrfs +_require_dm_target error +_require_test_program fsync-err +_require_test_program dmerror + +# bring up dmerror device +_scratch_unmount +_dmerror_init + +# Replace first device with error-test device +old_SCRATCH_DEV=$SCRATCH_DEV +SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | perl -pe "s#$SCRATCH_DEV#$DMERROR_DEV#"` +SCRATCH_DEV=$DMERROR_DEV + +_require_scratch +_require_scratch_dev_pool + +rm -f $seqres.full + +echo "Format and mount" + +_scratch_pool_mkfs "-d raid0 -m raid1" > $seqres.full 2>&1 +_scratch_mount + +# How much do we need to write? We need to hit all of the stripes. btrfs uses +# a fixed 64k stripesize, so write enough to hit each one +number_of_devices=`echo $SCRATCH_DEV_POOL | wc -w` +write_kb=$(($number_of_devices * 64)) +_require_fs_space $SCRATCH_MNT $write_kb + +testfile=$SCRATCH_MNT/fsync-err-test + +SCRATCH_DEV=$old_SCRATCH_DEV +$here/src/fsync-err -b $(($write_kb * 1024)) -d $here/src/dmerror $testfile + +# success, all done +_dmerror_load_working_table + +# fs may be corrupt after this -- attempt to repair it +_repair_scratch_fs >> $seqres.full + +# remove dmerror device +_dmerror_cleanup + +status=0 +exit
tests/btrfs/999.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 999 +Format and mount +Test passed!
tests/btrfs/group +1 -0
@@ -147,3 +147,4 @@ 142 auto quick 143 auto quick 144 auto quick send +999 auto quick
Signature · 1 line
2.13.0