add a test for reporting writeback errors across all fds on fsync
Subsystems (2)
v3 cover add a test for reporting writeback errors across all fds on fsync
This patchset is a companion to the Linux kernel patch series I recently posted with the cover letter:
[PATCH v5 00/17] fs: introduce new writeback error reporting and convert ext2 and ext4 to use it
That patchset adds a new userland-visible change to report errors on all open file descriptions when there is an error on fsync, not just the first one to race in.
Note that this set contains a patch to emulate $SCRATCH_LOGDEV on btrfs, but the kernel patches for that are not quite ready yet. The test did pass on btrfs in an earlier incarnation of the set, however.
Jeff Layton (5):
generic: add a writeback error handling test
ext4: allow ext4 to use $SCRATCH_LOGDEV
generic: test writeback error handling on dmerror devices
ext3: allow it to put journal on a separate device when doing
scratch_mkfs
btrfs: allow it to use $SCRATCH_LOGDEV
common/dmerror | 13 ++-- common/rc | 16 ++++- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/998 | 64 ++++++++++++++++++ tests/generic/998.out | 2 + tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 2 + tools/dmerror | 44 +++++++++++++ 11 files changed, 384 insertions(+), 7 deletions(-) create mode 100644 src/fsync-err.c 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 create mode 100755 tools/dmerror
Signature · 1 line
2.9.4
PATCH v3 1/5 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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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. For now, that's all it can do, but we can fill it out with other commands as necessary.
--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++ 8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerror
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 +8 -0
@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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 +1 -1
@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
src/fsync-err.c new file +161 -0
161 lines not on this page · raw message
tests/generic/999 new file +76 -0
76 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
@@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +999 auto quick
tools/dmerror new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.9.4
PATCH v3 2/5 ext4: allow ext4 to use $SCRATCH_LOGDEV
In reply to Jeff LaytonThe 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
@@ -676,6 +676,9 @@ _scratch_mkfs_ext4() local tmp=`mktemp` local mkfs_status + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + $mkfs_cmd -O journal_dev $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.9.4
PATCH v3 3/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 | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/998.out | 2 ++ tests/generic/group | 1 + 3 files changed, 67 insertions(+) create mode 100755 tests/generic/998 create mode 100644 tests/generic/998.out
tests/generic/998 new file +64 -0
@@ -0,0 +1,64 @@ +#! /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_logdev +_require_dm_target error +_require_test_program fsync-err + +rm -f $seqres.full + +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.full +_dmerror_init + +$here/src/fsync-err $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
@@ -440,4 +440,5 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +998 auto quick 999 auto quick
Signature · 1 line
2.9.4
PATCH v3 4/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
@@ -832,7 +832,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 $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.9.4
PATCH v3 5/5 btrfs: allow it to use $SCRATCH_LOGDEV
In reply to Jeff LaytonWith btrfs, we can't really put the log on a separate device. What we can do however is mirror the metadata across two devices and make the data striped across all devices. When we turn on dmerror then the metadata can fall back to using the other mirror while the data errors out.
Note that the current incarnation of btrfs has a fixed 64k stripe width. If that ever changes or becomes settable, we may need to adjust the amount of data that the test program writes.
--- common/rc | 2 ++ 1 file changed, 2 insertions(+)
common/rc +2 -0
@@ -830,6 +830,8 @@ _scratch_mkfs() ;; btrfs) mkfs_cmd="$MKFS_BTRFS_PROG" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + mkfs_cmd="$mkfs_cmd -d raid0 -m raid1 $SCRATCH_LOGDEV" mkfs_filter="cat" ;; ext3)
Signature · 1 line
2.9.4
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
In reply to Jeff LaytonHello,
Quoted 128 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++ 8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +19
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +*
src/fsync-err.c line 29
Quoted 10 lines
src/fsync-err.c new file +10
-0+* FIXME: have the test script pass in the length? +*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10 + +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +}
Just to follow the same style as your main:
+static void usage()
+{
+ fprintf(stderr, "Usage: fsync-err <filename>\n");
+}
Quoted 38 lines
src/fsync-err.c new file +38
-0+ +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } +
src/fsync-err.c line 77
Quoted 10 lines
src/fsync-err.c new file +10
-0+for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );
Just assuming a hardcoded relative path?
src/fsync-err.c line 89
Quoted 12 lines
src/fsync-err.c new file +12
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 );
Why not BUFSIZE here?
Quoted 92 lines
src/fsync-err.c new file +72
-0+if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */ +if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */ +printf ("Third fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to working mode */ + ret =system ("./tools/dmerror load_working_table" ); +if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* The error should still be clear */ +printf ("fsync after healing device on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* +* reopen each file one at a time to ensure the same inode stays +* in core. fsync each one to make sure we see no errors on a fresh +* open of the inode. +*/ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =close (fd[i]); +if (ret <0 ) { +printf ("Close of fd[%d] returned unexpected error: %m\n" , i); +return 1 ; + } + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("Second open of fd[%d] failed: %m\n" , i); +return 1 ; + } + ret =fsync (fd[i]); +if (ret <0 ) { +/* New opens should not return an error */ +printf ("First fsync after reopen of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +printf ("Test passed!\n" ); +return 0 ; +}tests/generic/999 new file +14
-0@@ -0,0 +1,76 @@ +#! /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.
tests/generic/999 line 24
Quoted 10 lines
tests/generic/999 new file +10
-0+# +# 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 +#-----------------------------------------------------------------------
Sure you want to track the address? Maybe just remove it?
Quoted 127 lines
tests/generic/999 new file +52
-0+ +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_logdev +_require_dm_target error +_require_test_program fsync-err + +rm -f $seqres.full + +echo "Format and mount" +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.full +_scratch_mkfs > $seqres.full 2>&1 +_dmerror_init +_dmerror_mount >> $seqres.full 2>&1 +_dmerror_unmount +_dmerror_mount + +_require_fs_space $SCRATCH_MNT 8192 + +testfile=$SCRATCH_MNT/fsync-err-test + +$here/src/fsync-err $testfile + +# success, all done +_dmerror_load_working_table +_dmerror_unmount +_dmerror_cleanup +_repair_scratch_fs >> $seqres.full +status=0 +exittests/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@@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +999 auto quicktools/dmerror new file +44
-0@@ -0,0 +1,44 @@ +#!/bin/bash +#----------------------------------------------------------------------- +# 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 +#----------------------------------------------------------------------- + +. ./common/config +. ./common/dmerror + +_dmerror_setup + +case $1 in +cleanup) + _dmerror_cleanup + ;; +init) + _dmerror_init + ;; +load_error_table) + _dmerror_load_error_table + ;; +load_working_table) + _dmerror_load_working_table + ;; +*) + echo "Usage: $0 {init|cleanup|load_error_table|load_working_table}" + exit 1 + ;; +esac + +status=0 +exitSignature · 1 line
2.9.4
Signature · 2 lines
All the best, Eduardo Valentin
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
Quoted 191 lines · Eduardo Valentin
Hello,
Quoted 128 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++ 8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +19
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +* src/fsync-err.c line 29
Quoted 10 lines
src/fsync-err.c new file +10
-0+* FIXME: have the test script pass in the length? +*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10 + +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +}Just to follow the same style as your main:
src/fsync-err.c new file +4
-0+static void usage () +{ +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +}Quoted 43 lines
src/fsync-err.c new file +42
-0+ +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i);
Quoted 9 lines
src/fsync-err.c line 77
Quoted 6 lines
src/fsync-err.c new file +6
-0+return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );Just assuming a hardcoded relative path?
The callers in tests/ call commands with hardcoded paths like "src/", so I figured that was OK here.
Is there some other way we should do this? I'd prefer to shell out to the dmerror tool than reimplement it here.
Quoted 6 lines
Quoted 6 lines
src/fsync-err.c new file +6
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret);
Quoted 9 lines
src/fsync-err.c line 89
Quoted 6 lines
src/fsync-err.c new file +6
-0+ +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 );Why not BUFSIZE here?
Good catch. It should be BUFSIZE.
Quoted 96 lines
Quoted 96 lines
src/fsync-err.c new file +72
-0+if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */ +if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */ +printf ("Third fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to working mode */ + ret =system ("./tools/dmerror load_working_table" ); +if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* The error should still be clear */ +printf ("fsync after healing device on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* +* reopen each file one at a time to ensure the same inode stays +* in core. fsync each one to make sure we see no errors on a fresh +* open of the inode. +*/ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =close (fd[i]); +if (ret <0 ) { +printf ("Close of fd[%d] returned unexpected error: %m\n" , i); +return 1 ; + } + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("Second open of fd[%d] failed: %m\n" , i); +return 1 ; + } + ret =fsync (fd[i]); +if (ret <0 ) { +/* New opens should not return an error */ +printf ("First fsync after reopen of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +printf ("Test passed!\n" ); +return 0 ; +}tests/generic/999 new file +18
-0@@ -0,0 +1,76 @@ +#! /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
Quoted 9 lines
tests/generic/999 line 24
Quoted 6 lines
tests/generic/999 new file +6
-0+# 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 +#-----------------------------------------------------------------------Sure you want to track the address? Maybe just remove it?
Will do. I ended up copying and pasting instead of doing the "new" script like I probably should have. I'll go back and read the docs and make sure I get the boilerplate stuff right.
Quoted 119 lines
Quoted 119 lines
tests/generic/999 new file +52
-0+ +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_logdev +_require_dm_target error +_require_test_program fsync-err + +rm -f $seqres.full + +echo "Format and mount" +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.full +_scratch_mkfs > $seqres.full 2>&1 +_dmerror_init +_dmerror_mount >> $seqres.full 2>&1 +_dmerror_unmount +_dmerror_mount + +_require_fs_space $SCRATCH_MNT 8192 + +testfile=$SCRATCH_MNT/fsync-err-test + +$here/src/fsync-err $testfile + +# success, all done +_dmerror_load_working_table +_dmerror_unmount +_dmerror_cleanup +_repair_scratch_fs >> $seqres.full +status=0 +exittests/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@@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +999 auto quicktools/dmerror new file +40
-0@@ -0,0 +1,44 @@ +#!/bin/bash +#----------------------------------------------------------------------- +# 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 +#----------------------------------------------------------------------- + +. ./common/config +. ./common/dmerror + +_dmerror_setup + +case $1 in +cleanup) + _dmerror_cleanup + ;; +init) + _dmerror_init + ;; +load_error_table) + _dmerror_load_error_table + ;; +load_working_table) + _dmerror_load_working_table + ;; +*) + echo "Usage: $0 {init|cleanup|load_error_table|load_working_table}" + exit 1 + ;;
Quoted 10 lines
Quoted 8 lines
tools/dmerror new file +4
-0+esac + +status=0 +exitSignature · 1 line
2.9.4
Thanks for the review!
Signature · 1 line
Jeff Layton <[email protected]>
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
In reply to Jeff LaytonQuoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.
Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>
Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and _notrun on filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Besides this kinda high-level question, some minor comments inline.
Quoted 5 lines
--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++
New binary needs an entry in .gitignore file.
Quoted 4 lines
tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++
This file is used by the test, then it should be in src/ directory and be installed along with other executable files on "make install". Because files under tools/ are not installed. Most people will run tests in the root dir of xfstests and this is not a problem, but there're still cases people do "make && make install" and run fstests from /var/lib/xfstests (default installation target).
Quoted 101 lines
8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +15
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +
src/fsync-err.c line 25
Quoted 10 lines
src/fsync-err.c new file +10
-0+/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +* +* FIXME: have the test script pass in the length? +*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10
Passed through command line parameter, and default value is 10 if not specified?
Quoted 42 lines
src/fsync-err.c new file +42
-0+ +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +} + +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } +
src/fsync-err.c line 77
Quoted 10 lines
src/fsync-err.c new file +10
-0+for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );
Hmm, how about passing these "load error table" and "load working table" commands through command line parameters too?
Quoted 21 lines
src/fsync-err.c new file +21
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 ); +if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */
src/fsync-err.c line 108
Quoted 10 lines
src/fsync-err.c new file +10
-0+if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */
It's not obvious to me why error should be clear at this stage, adding some comments would be good.
Quoted 101 lines
src/fsync-err.c new file +53
-0+printf ("Third fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to working mode */ + ret =system ("./tools/dmerror load_working_table" ); +if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* The error should still be clear */ +printf ("fsync after healing device on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* +* reopen each file one at a time to ensure the same inode stays +* in core. fsync each one to make sure we see no errors on a fresh +* open of the inode. +*/ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =close (fd[i]); +if (ret <0 ) { +printf ("Close of fd[%d] returned unexpected error: %m\n" , i); +return 1 ; + } + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("Second open of fd[%d] failed: %m\n" , i); +return 1 ; + } + ret =fsync (fd[i]); +if (ret <0 ) { +/* New opens should not return an error */ +printf ("First fsync after reopen of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +printf ("Test passed!\n" ); +return 0 ; +}tests/generic/999 new file +42
-0@@ -0,0 +1,76 @@ +#! /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
tests/generic/999 line 52
Quoted 10 lines
tests/generic/999 new file +10
-0+. ./common/rc +. ./common/filter +. ./common/dmerror + +# real QA test starts here +_supported_os Linux +_require_scratch +_require_logdev +_require_dm_target error +_require_test_program fsync-err
Test also uses tools/dmerror (or src/dmerror), also should make sure that file is there.
# Assuming src/dmerror_require_test_program "dmerror"
tests/generic/999 line 57
Quoted 5 lines
tests/generic/999 new file +5
-0+ +rm -f $seqres.full + +echo "Format and mount" +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.full
This is not needed.
tests/generic/999 line 61
Quoted 4 lines
tests/generic/999 new file +4
-0+_scratch_mkfs > $seqres.full 2>&1 +_dmerror_init +_dmerror_mount >> $seqres.full 2>&1 +_dmerror_unmount
This extra _dmerror_mount/unmount cycle doesn't seem necessary to me either.
tests/generic/999 line 74
Quoted 13 lines
tests/generic/999 new file +13
-0+_dmerror_mount + +_require_fs_space $SCRATCH_MNT 8192 + +testfile=$SCRATCH_MNT/fsync-err-test + +$here/src/fsync-err $testfile + +# success, all done +_dmerror_load_working_table +_dmerror_unmount +_dmerror_cleanup +_repair_scratch_fs >> $seqres.full
_require_scratch_fs will return 0 if it found corruption but repaired it successfully, then we'll miss a fs curruption failure.
Test harness will do fsck after each test by default, we can exit directly.
Thanks,
Eryu
Quoted 77 lines
tests/generic/999 new file +2
-0+status=0 +exittests/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@@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +999 auto quicktools/dmerror new file +44
-0@@ -0,0 +1,44 @@ +#!/bin/bash +#----------------------------------------------------------------------- +# 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 +#----------------------------------------------------------------------- + +. ./common/config +. ./common/dmerror + +_dmerror_setup + +case $1 in +cleanup) + _dmerror_cleanup + ;; +init) + _dmerror_init + ;; +load_error_table) + _dmerror_load_error_table + ;; +load_working_table) + _dmerror_load_working_table + ;; +*) + echo "Usage: $0 {init|cleanup|load_error_table|load_working_table}" + exit 1 + ;; +esac + +status=0 +exitSignature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [xfstests PATCH v3 2/5] ext4: allow ext4 to use $SCRATCH_LOGDEV
In reply to Jeff LaytonQuoted 19 lines · Jeff Layton
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_mkfsis called.Signed-off-by Jeff Layton <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- common/rc | 3 +++ 1 file changed, 3 insertions(+)common/rc +0
-0
common/rc _scratch_mkfs_ext4() · line 681
Quoted 6 lines
common/rc +3
-0@@ -676,6 +676,9 @@ _scratch_mkfs_ext4() local tmp=`mktemp` local mkfs_status + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + $mkfs_cmd -O journal_dev $SCRATCH_LOGDEV && \ + mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"
Need $MKFS_OPTIONS too when creating journal device, otherwise mkfs will fail when making non-default block size ext4, i.e. journal device has 4k block size, but ext4 has 1k block size if we have MKFS_OPTIONS="-b 1024"
Thanks,
Eryu
Quoted 10 lines
common/rc +0
-0_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd mkfs_status=$?Signature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [xfstests PATCH v3 3/5] generic: test writeback error handling on dmerror devices
In reply to Jeff LaytonQuoted 55 lines · Jeff Layton
Ensure that we get an error back on all fds when a block device is open by multiple writers and writeback fails.
Signed-off-by Jeff Layton <[email protected]>--- tests/generic/998 | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/998.out | 2 ++ tests/generic/group | 1 + 3 files changed, 67 insertions(+) create mode 100755 tests/generic/998 create mode 100644 tests/generic/998.outtests/generic/998 new file +37
-0@@ -0,0 +1,64 @@ +#! /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
tests/generic/998 line 47
Quoted 10 lines
tests/generic/998 new file +10
-0+} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/dmerror + +# real QA test starts here +_supported_os Linux +_require_scratch
_require_scratch_nocheck
Then we don't have to re-create a filesystem on SCRATCH_DEV before exiting.
tests/generic/998 line 54
Quoted 7 lines
tests/generic/998 new file +7
-0+_require_logdev +_require_dm_target error +_require_test_program fsync-err + +rm -f $seqres.full + +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.full
I don't see why this is needed, add some comments? Or remove it if it's not needed?
Quoted 23 lines
tests/generic/998 new file +10
-0+_dmerror_init + +$here/src/fsync-err $DMERROR_DEV + +# success, all done +_dmerror_load_working_table +_dmerror_cleanup +_scratch_mkfs > $seqres.full 2>&1 +status=0 +exittests/generic/998.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 998 +Test passed!tests/generic/group +0
-0
tests/generic/group line 443
Quoted 4 lines
tests/generic/group +1
-0@@ -440,4 +440,5 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +998 auto quick
This is a test for block device, not filesystems, I'd remove it from auto and quick group, but add it to 'blockdev' group. So it won't be run if someone wants to test filesystems.
Thanks,
Eryu
Quoted 8 lines
tests/generic/group +0
-0999 auto quickSignature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [xfstests PATCH v3 4/5] ext3: allow it to put journal on a separate device when doing scratch_mkfs
In reply to Jeff LaytonQuoted 12 lines · Jeff Layton
Signed-off-by Jeff Layton <[email protected]>--- common/rc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)common/rc +0
-0@@ -832,7 +832,16 @@ _scratch_mkfs() mkfs_cmd="$MKFS_BTRFS_PROG" mkfs_filter="cat"
common/rc _scratch_mkfs() · line 842
Quoted 10 lines
common/rc +8
-1;; - 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 $SCRATCH_LOGDEV && \ + mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"
Similar to that ext4 patch, need $MKFS_OPTIONS when creating journal device.
Thanks,
Eryu
Quoted 12 lines
common/rc +2
-0+ ;; + ext2) mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F" mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \"" ;;Signature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [xfstests PATCH v3 5/5] btrfs: allow it to use $SCRATCH_LOGDEV
In reply to Jeff LaytonQuoted 20 lines · Jeff Layton
With btrfs, we can't really put the log on a separate device. What we can do however is mirror the metadata across two devices and make the data striped across all devices. When we turn on dmerror then the metadata can fall back to using the other mirror while the data errors out.
Note that the current incarnation of btrfs has a fixed 64k stripe width. If that ever changes or becomes settable, we may need to adjust the amount of data that the test program writes.
Signed-off-by Jeff Layton <[email protected]>--- common/rc | 2 ++ 1 file changed, 2 insertions(+)common/rc +0
-0
common/rc _scratch_mkfs() · line 834
Quoted 5 lines
common/rc +2
-0@@ -830,6 +830,8 @@ _scratch_mkfs() ;; btrfs) mkfs_cmd="$MKFS_BTRFS_PROG" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + mkfs_cmd="$mkfs_cmd -d raid0 -m raid1 $SCRATCH_LOGDEV"
I don't think this is the correct way to do it. If btrfs doesn't support external log device, then this test doesn't fit btrfs, or we need other ways to test btrfs.
One of the problems of this hack is that raid1 requires all devices are in the same size, we have a _require_scratch_dev_pool_equal_size() rule to check on it, but this hack doesn't do the proper check and test fails if SCRATCH_LOGDEV is smaller or bigger in size.
If btrfs "-d raid0 -m raid1" is capable to do this writeback error test, perhaps you can write a new btrfs test and mkfs with "-d raid0 -m raid1" explicitly. e.g.
..._require_scratch_dev_pool 2_require_scratch_dev_pool_equal_size
..._scratch_mkfs "-d raid0 -m raid1"
...
Thanks,
Eryu
Quoted 10 lines
common/rc +0
-0mkfs_filter="cat" ;; ext3)Signature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
In reply to Eryu GuanQuoted 22 lines · Eryu Guan
Quoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Quoted 7 lines
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and
_notrunon filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.
Thanks for the review! I'm not sure how to categorize this either. Since the plan is to convert all the filesystems piecemeal, maybe we should just consider it a new feature.
Quoted 5 lines
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Besides this kinda high-level question, some minor comments inline.
Yes, ext4 should pass on my latest kernel tree, but everything else should fail.
Quoted 8 lines
Quoted 5 lines
--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++New binary needs an entry in .gitignore file.
OK, thanks. Will fix.
Quoted 5 lines
Quoted 4 lines
tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++
Quoted 7 lines
This file is used by the test, then it should be in src/ directory and be installed along with other executable files on "make install". Because files under
tools/are not installed. Most people will run tests in the root dir of xfstests and this is not a problem, but there're still cases people do "make && make install" and run fstests from/var/lib/xfstests(default installation target).
Ok, no problem. I'll move it. I wasn't sure here since dmerror is a shell script, and most of the stuff in src/ is stuff that needs to be built.
Quoted 106 lines
Quoted 106 lines
8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +20
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +* +* FIXME: have the test script pass in the length?
Quoted 9 lines
src/fsync-err.c line 25
Quoted 5 lines
src/fsync-err.c new file +5
-0+*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10Passed through command line parameter, and default value is 10 if not specified?
Sure. Perhaps we should do the same with BUFSIZE? Particularly if we need to vary it between fs'.
Quoted 82 lines
Quoted 42 lines
src/fsync-err.c new file +42
-0+ +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +} + +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } +src/fsync-err.c line 77
Quoted 10 lines
src/fsync-err.c new file +10
-0+for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );Hmm, how about passing these "load error table" and "load working table" commands through command line parameters too?
Quoted 26 lines
src/fsync-err.c new file +26
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 ); +if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */ +if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + }
Quoted 9 lines
src/fsync-err.c line 108
Quoted 5 lines
src/fsync-err.c new file +5
-0+ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */ It's not obvious to me why error should be clear at this stage, adding some comments would be good.
Ok. FWIW:
We did some writes to a failing device and called fsync and got an error back. Since no more data was written since then, we don't expect to see an error at this point since it should have been "cleared".
Quoted 126 lines
Quoted 101 lines
src/fsync-err.c new file +53
-0+printf ("Third fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to working mode */ + ret =system ("./tools/dmerror load_working_table" ); +if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* The error should still be clear */ +printf ("fsync after healing device on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* +* reopen each file one at a time to ensure the same inode stays +* in core. fsync each one to make sure we see no errors on a fresh +* open of the inode. +*/ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =close (fd[i]); +if (ret <0 ) { +printf ("Close of fd[%d] returned unexpected error: %m\n" , i); +return 1 ; + } + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("Second open of fd[%d] failed: %m\n" , i); +return 1 ; + } + ret =fsync (fd[i]); +if (ret <0 ) { +/* New opens should not return an error */ +printf ("First fsync after reopen of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +printf ("Test passed!\n" ); +return 0 ; +}tests/generic/999 new file +42
-0@@ -0,0 +1,76 @@ +#! /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 checkstests/generic/999 line 52
Quoted 10 lines
tests/generic/999 new file +10
-0+. ./common/rc +. ./common/filter +. ./common/dmerror + +# real QA test starts here +_supported_os Linux +_require_scratch +_require_logdev +_require_dm_target error +_require_test_program fsync-errTest also uses
tools/dmerror(or src/dmerror), also should make sure that file is there.# Assuming src/dmerror
_require_test_program"dmerror"tests/generic/999 line 57
Quoted 5 lines
tests/generic/999 new file +5
-0+ +rm -f $seqres.full + +echo "Format and mount" +$XFS_IO_PROG -d -c "pwrite -S 0x7c -b 1048576 0 $((64 * 1048576))" $SCRATCH_DEV >> $seqres.fullThis is not needed.
Quoted 8 lines
tests/generic/999 line 61
Quoted 4 lines
tests/generic/999 new file +4
-0+_scratch_mkfs > $seqres.full 2>&1 +_dmerror_init +_dmerror_mount >> $seqres.full 2>&1 +_dmerror_unmountThis extra _dmerror_mount/unmount cycle doesn't seem necessary to me either.
ACK -- will fix all of the above.
Quoted 17 lines
tests/generic/999 line 74
Quoted 13 lines
tests/generic/999 new file +13
-0+_dmerror_mount + +_require_fs_space $SCRATCH_MNT 8192 + +testfile=$SCRATCH_MNT/fsync-err-test + +$here/src/fsync-err $testfile + +# success, all done +_dmerror_load_working_table +_dmerror_unmount +_dmerror_cleanup +_repair_scratch_fs >> $seqres.full
_require_scratch_fswill return 0 if it found corruption but repaired it successfully, then we'll miss a fs curruption failure.
Quoted 3 lines
Test harness will do fsck after each test by default, we can exit directly.
I'm not really interested in testing whether the fs is corrupt after this. It may very well be completely hosed afterward. The only thing we want to test here is the behavior while the errors actually occur.
Quoted 80 lines
Thanks,
EryuQuoted 77 lines
tests/generic/999 new file +2
-0+status=0 +exittests/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@@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +999 auto quicktools/dmerror new file +44
-0@@ -0,0 +1,44 @@ +#!/bin/bash +#----------------------------------------------------------------------- +# 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 +#----------------------------------------------------------------------- + +. ./common/config +. ./common/dmerror + +_dmerror_setup + +case $1 in +cleanup) + _dmerror_cleanup + ;; +init) + _dmerror_init + ;; +load_error_table) + _dmerror_load_error_table + ;; +load_working_table) + _dmerror_load_working_table + ;; +*) + echo "Usage: $0 {init|cleanup|load_error_table|load_working_table}" + exit 1 + ;; +esac + +status=0 +exitSignature · 6 lines
2.9.4 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Jeff Layton <[email protected]>
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
Quoted 31 lines · Jeff Layton
Quoted 22 lines · Eryu Guan
Quoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Quoted 7 lines
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and
_notrunon filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.
Quoted 3 lines
Thanks for the review! I'm not sure how to categorize this either. Since the plan is to convert all the filesystems piecemeal, maybe we should just consider it a new feature.
Then we need a new _require rule to properly detect for the 'feature' support. I'm not sure if this is doable, but something like _require_statx, _require_seek_data_hole would be good.
Quoted 9 lines
Quoted 6 lines
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Besides this kinda high-level question, some minor comments inline.
Yes, ext4 should pass on my latest kernel tree, but everything else should fail.
With the new _require rule, test should _notrun on XFS and btrfs then.
Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++New binary needs an entry in .gitignore file.
OK, thanks. Will fix.
Quoted 5 lines
Quoted 4 lines
tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++Quoted 7 lines
This file is used by the test, then it should be in src/ directory and be installed along with other executable files on "make install". Because files under
tools/are not installed. Most people will run tests in the root dir of xfstests and this is not a problem, but there're still cases people do "make && make install" and run fstests from/var/lib/xfstests(default installation target).
Quoted 3 lines
Ok, no problem. I'll move it. I wasn't sure here since dmerror is a shell script, and most of the stuff in src/ is stuff that needs to be built.
We do have a few perl or shell scripts in src/ dir, we can see this from src/Makefile
$(LTINSTALL) -m 755 fill2attr fill2fs fill2fs_check scaleread.sh $(PKG_LIB_DIR)/src
Quoted 212 lines
Quoted 107 lines
Quoted 107 lines
8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +20
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +* +* FIXME: have the test script pass in the length? Quoted 9 lines
src/fsync-err.c line 25
Quoted 5 lines
src/fsync-err.c new file +5
-0+*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10Passed through command line parameter, and default value is 10 if not specified?
Sure. Perhaps we should do the same with BUFSIZE? Particularly if we need to vary it between fs'.
Quoted 82 lines
Quoted 42 lines
src/fsync-err.c new file +42
-0+ +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +} + +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } +src/fsync-err.c line 77
Quoted 10 lines
src/fsync-err.c new file +10
-0+for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );Hmm, how about passing these "load error table" and "load working table" commands through command line parameters too?
Quoted 26 lines
src/fsync-err.c new file +26
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 ); +if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */ +if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + }Quoted 9 lines
src/fsync-err.c line 108
Quoted 5 lines
src/fsync-err.c new file +5
-0+ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */ It's not obvious to me why error should be clear at this stage, adding some comments would be good.
Quoted 5 lines
Ok. FWIW:
We did some writes to a failing device and called fsync and got an error back. Since no more data was written since then, we don't expect to see an error at this point since it should have been "cleared".
Thanks! It wasn't clear to me until I read your kernel patch :)
Thanks,
Eryu
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
Quoted 44 lines · Eryu Guan
Quoted 31 lines · Jeff Layton
Quoted 22 lines · Eryu Guan
Quoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Quoted 7 lines
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and
_notrunon filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.Quoted 3 lines
Thanks for the review! I'm not sure how to categorize this either. Since the plan is to convert all the filesystems piecemeal, maybe we should just consider it a new feature.
Then we need a new
_requirerule to properly detect for the 'feature' support. I'm not sure if this is doable, but something like_require_statx,_require_seek_data_holewould be good.Quoted 4 lines
Quoted 4 lines
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Besides this kinda high-level question, some minor comments inline.
Yes, ext4 should pass on my latest kernel tree, but everything else should fail.
With the new
_requirerule, test should_notrunon XFS and btrfs then.
Frankly I personally prefer that upstream XFS fails until someone fixes it. :) (But that's just my opinion.)
That said, I'm not 100% sure what's required of XFS to play nicely with this new mechanism -- glancing at the ext* patches it looks like we'd need to set a fs flag and possibly change some or all of the "write cached dirty buffers out to disk" calls to their _since variants? Metadata writeback errors are handled by retrying writes and/or shutting down the fs, so I think the f_md_wb_error case is already covered.
That said, I agree that it's useful to detect that the kernel simply lacks any of the new wb error reporting at all, so therefore we can skip the tests.
--D
Quoted 257 lines
Quoted 26 lines
Quoted 10 lines
Quoted 7 lines
--- common/dmerror | 13 ++-- doc/auxiliary-programs.txt | 8 +++ src/Makefile | 2 +- src/fsync-err.c | 161 +++++++++++++++++++++++++++++++++++++++++++++New binary needs an entry in .gitignore file.
OK, thanks. Will fix.
Quoted 5 lines
Quoted 4 lines
tests/generic/999 | 76 +++++++++++++++++++++ tests/generic/999.out | 3 + tests/generic/group | 1 + tools/dmerror | 44 +++++++++++++Quoted 7 lines
This file is used by the test, then it should be in src/ directory and be installed along with other executable files on "make install". Because files under
tools/are not installed. Most people will run tests in the root dir of xfstests and this is not a problem, but there're still cases people do "make && make install" and run fstests from/var/lib/xfstests(default installation target).Quoted 3 lines
Ok, no problem. I'll move it. I wasn't sure here since dmerror is a shell script, and most of the stuff in src/ is stuff that needs to be built.
We do have a few perl or shell scripts in src/ dir, we can see this from src/Makefile
$(LTINSTALL) -m 755 fill2attr fill2fs
fill2fs_checkscaleread.sh$(PKG_LIB_DIR)/srcQuoted 212 lines
Quoted 107 lines
Quoted 107 lines
8 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 src/fsync-err.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out create mode 100755 tools/dmerrorcommon/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 +8
-0@@ -16,6 +16,7 @@ note the dependency with: Contents: - af_unix -- Create an AF_UNIX socket + - 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 +31,13 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +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() systemsrc/Makefile +1
-1@@ -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_cow_race fsync-err LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \src/fsync-err.c new file +20
-0@@ -0,0 +1,161 @@ +/* +* fsync-err.c: test whether writeback errors are reported to all open fds +* and properly cleared as expected after being seen once on each +* +* Copyright (c) 2017: Jeff Layton <[email protected]> +*/ +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +/* +* btrfs has a fixed stripewidth of 64k, so we need to write enough data to +* ensure that we hit both stripes. +* +* FIXME: have the test script pass in the length? Quoted 9 lines
src/fsync-err.c line 25
Quoted 5 lines
src/fsync-err.c new file +5
-0+*/ +#define BUFSIZE (65 * 1024) + +/* FIXME: should this be tunable */ +#define NUM_FDS 10Passed through command line parameter, and default value is 10 if not specified?
Sure. Perhaps we should do the same with BUFSIZE? Particularly if we need to vary it between fs'.
Quoted 82 lines
Quoted 42 lines
src/fsync-err.c new file +42
-0+ +static void usage () { +fprintf (stderr,"Usage: fsync-err <filename>\n" ); +} + +int main (int argc,char **argv) +{ +int fd[NUM_FDS ], ret, i; +char *fname, *buf; + +if (argc <1 ) { +usage (); +return 1 ; + } + +/* First argument is filename */ + fname = argv[1 ]; + +for (i =0 ; i <NUM_FDS ; ++i) { + fd[i] =open (fname,O_WRONLY |O_CREAT |O_TRUNC ,0644 ); +if (fd[i] <0 ) { +printf ("open of fd[%d] failed: %m\n" , i); +return 1 ; + } + } + + buf =malloc (BUFSIZE ); +if (!buf) { +printf ("malloc failed: %m\n" ); +return 1 ; + } + +memset (buf,0x7c ,BUFSIZE ); + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,BUFSIZE ); +if (ret <0 ) { +printf ("First write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } +src/fsync-err.c line 77
Quoted 10 lines
src/fsync-err.c new file +10
-0+for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +printf ("First fsync on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +/* flip the device to non-working mode */ + ret =system ("./tools/dmerror load_error_table" );Hmm, how about passing these "load error table" and "load working table" commands through command line parameters too?
Quoted 26 lines
src/fsync-err.c new file +26
-0+if (ret) { +if (WIFEXITED (ret)) +printf ("system: program exited: %d\n" , +WEXITSTATUS (ret)); +else +printf ("system: 0x%x\n" , (int )ret); + +return 1 ; + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =write (fd[i], buf,strlen (buf) +1 ); +if (ret <0 ) { +printf ("Second write on fd[%d] failed: %m\n" , i); +return 1 ; + } + } + +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +/* Now, we EXPECT the error! */ +if (ret >=0 ) { +printf ("Success on second fsync on fd[%d]!\n" , i); +return 1 ; + } + }Quoted 9 lines
src/fsync-err.c line 108
Quoted 5 lines
src/fsync-err.c new file +5
-0+ +for (i =0 ; i <NUM_FDS ; ++i) { + ret =fsync (fd[i]); +if (ret <0 ) { +/* Now the error should be clear */ It's not obvious to me why error should be clear at this stage, adding some comments would be good.
Quoted 5 lines
Ok. FWIW:
We did some writes to a failing device and called fsync and got an error back. Since no more data was written since then, we don't expect to see an error at this point since it should have been "cleared".
Thanks! It wasn't clear to me until I read your kernel patch :)
Thanks,
Eryu
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
Quoted 42 lines · Darrick J. Wong
Quoted 41 lines · Eryu Guan
Quoted 31 lines · Jeff Layton
Quoted 22 lines · Eryu Guan
Quoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Quoted 7 lines
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and
_notrunon filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.Quoted 3 lines
Thanks for the review! I'm not sure how to categorize this either. Since the plan is to convert all the filesystems piecemeal, maybe we should just consider it a new feature.
Then we need a new
_requirerule to properly detect for the 'feature' support. I'm not sure if this is doable, but something like_require_statx,_require_seek_data_holewould be good.Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Besides this kinda high-level question, some minor comments inline.
Yes, ext4 should pass on my latest kernel tree, but everything else should fail.
Oh, and I should mention that ext2/3 also pass when mounted using ext4 driver. Legacy ext2 driver sort of works, but it reports a few too many errors because of the way the ext2_error macro works. That shouldn't be too hard to fix, I just need some guidance on that one.
I had xfs and btrfs working with an earlier iteration of the patches, but now that we're converting a fs at a time, it's a little more work to get there. It shouldn't be too hard to do though. I'll probably re-post in a few days, and will try to take a stab at XFS and btrfs conversion too.
Quoted 10 lines
Quoted 2 lines
With the new
_requirerule, test should_notrunon XFS and btrfs then.Frankly I personally prefer that upstream XFS fails until someone fixes it. :) (But that's just my opinion.)
That said, I'm not 100% sure what's required of XFS to play nicely with this new mechanism -- glancing at the ext* patches it looks like we'd need to set a fs flag and possibly change some or all of the "write cached dirty buffers out to disk" calls to their
_sincevariants?
Yeah, that's pretty much the size of it.
In fact, the latter part (changing to the _since variants) is somewhat optional. We can have the errseq_t based tracking coexist with the AS_EIO/AS_ENOSPC flags. It's weird but I don't see a real downside to preserving them until we've got more of this converted over.
In the latest branch I'm working on, I'm breaking up those changes into different patches so it should be a little clearer for other fs maintainers to see what I'm doing and why. Stay tuned...
Quoted 2 lines
Metadata writeback errors are handled by retrying writes and/or shutting down the fs, so I think the
f_md_wb_errorcase is already covered.
Thanks. I think we do need f_md_wb_err for ext2/4 though, IIUC?
Quoted 5 lines
That said, I agree that it's useful to detect that the kernel simply lacks any of the new wb error reporting at all, so therefore we can skip the tests.
Suggestions on ways to implement such a check would be welcome. Maybe a file in /sys or in debugfs?
Signature · 1 line
Jeff Layton <[email protected]>
Re: [xfstests PATCH v3 1/5] generic: add a writeback error handling test
Quoted 76 lines · Jeff Layton
Quoted 42 lines · Darrick J. Wong
Quoted 41 lines · Eryu Guan
Quoted 31 lines · Jeff Layton
Quoted 22 lines · Eryu Guan
Quoted 9 lines · Jeff Layton
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, I aim to make the kernel report them once on every file description.
This patch adds a test for the 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.Quoted 5 lines
To do that, I'm adding a new
tools/dmerrorscript that the C program can use to load the error table. For now, that's all it can do, but we can fill it out with other commands as necessary.Signed-off-by Jeff Layton <[email protected]>Thanks for the new tests! And sorry for the late review..
It's testing a new behavior on error reporting on writeback, I'm not sure if we can call it a new feature or it fixed a bug? But it's more like a behavior change, I'm not sure how to categorize it.
Quoted 7 lines
Because if it's testing a new feature, we usually let test do proper detection of current test environment (based on actual behavior not kernel version) and
_notrunon filesystems that don't have this feature yet, instead of failing the test; if it's testing a bug fix, we could leave the test fail on unfixed filesystems, this also serves as a reminder that there's bug to fix.Quoted 3 lines
Thanks for the review! I'm not sure how to categorize this either. Since the plan is to convert all the filesystems piecemeal, maybe we should just consider it a new feature.
Then we need a new
_requirerule to properly detect for the 'feature' support. I'm not sure if this is doable, but something like_require_statx,_require_seek_data_holewould be good.Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
I pulled your test kernel tree, and test passed on EXT4 but failed on other local filesystems (XFS, btrfs). I assume that's expected.
Besides this kinda high-level question, some minor comments inline.
Yes, ext4 should pass on my latest kernel tree, but everything else should fail.
Oh, and I should mention that ext2/3 also pass when mounted using ext4 driver. Legacy ext2 driver sort of works, but it reports a few too many errors because of the way the
ext2_errormacro works. That shouldn't be too hard to fix, I just need some guidance on that one.I had xfs and btrfs working with an earlier iteration of the patches, but now that we're converting a fs at a time, it's a little more work to get there. It shouldn't be too hard to do though. I'll probably re-post in a few days, and will try to take a stab at XFS and btrfs conversion too.
Quoted 10 lines
Quoted 2 lines
With the new
_requirerule, test should_notrunon XFS and btrfs then.Frankly I personally prefer that upstream XFS fails until someone fixes it. :) (But that's just my opinion.)
That said, I'm not 100% sure what's required of XFS to play nicely with this new mechanism -- glancing at the ext* patches it looks like we'd need to set a fs flag and possibly change some or all of the "write cached dirty buffers out to disk" calls to their
_sincevariants?Yeah, that's pretty much the size of it.
Quoted 8 lines
In fact, the latter part (changing to the
_sincevariants) is somewhat optional. We can have theerrseq_tbased tracking coexist with the AS_EIO/AS_ENOSPC flags. It's weird but I don't see a real downside to preserving them until we've got more of this converted over.In the latest branch I'm working on, I'm breaking up those changes into different patches so it should be a little clearer for other fs maintainers to see what I'm doing and why. Stay tuned...
Ok.
Quoted 4 lines
Quoted 2 lines
Metadata writeback errors are handled by retrying writes and/or shutting down the fs, so I think the
f_md_wb_errorcase is already covered.Thanks. I think we do need
f_md_wb_errfor ext2/4 though, IIUC?
Yes. Sorry, the previous statement applies only to XFS.
Quoted 7 lines
Quoted 4 lines
That said, I agree that it's useful to detect that the kernel simply lacks any of the new wb error reporting at all, so therefore we can skip the tests.
Suggestions on ways to implement such a check would be welcome. Maybe a file in /sys or in debugfs?
Assuming that this patchset applies the same wb error reporting behavior to block devices, you could open a bunch of file descriptors to a linear dm target sitting atop $SCRATCH_DEV, switch out the table to dm_error, then write something, fsync, and see if we get more than one EIO. Then you'd know if the kernel supports it, at least... I think?
--D
Quoted 3 lines
Signature · 2 lines
-- Jeff Layton <[email protected]>
Re: [xfstests PATCH v3 5/5] btrfs: allow it to use $SCRATCH_LOGDEV
In reply to Eryu GuanQuoted 47 lines · Eryu Guan
Quoted 20 lines · Jeff Layton
With btrfs, we can't really put the log on a separate device. What we can do however is mirror the metadata across two devices and make the data striped across all devices. When we turn on dmerror then the metadata can fall back to using the other mirror while the data errors out.
Note that the current incarnation of btrfs has a fixed 64k stripe width. If that ever changes or becomes settable, we may need to adjust the amount of data that the test program writes.
Signed-off-by Jeff Layton <[email protected]>--- common/rc | 2 ++ 1 file changed, 2 insertions(+)common/rc +0
-0common/rc _scratch_mkfs() · line 834
Quoted 5 lines
common/rc +2
-0@@ -830,6 +830,8 @@ _scratch_mkfs() ;; btrfs) mkfs_cmd="$MKFS_BTRFS_PROG" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + mkfs_cmd="$mkfs_cmd -d raid0 -m raid1 $SCRATCH_LOGDEV"I don't think this is the correct way to do it. If btrfs doesn't support external log device, then this test doesn't fit btrfs, or we need other ways to test btrfs.
One of the problems of this hack is that raid1 requires all devices are in the same size, we have a
_require_scratch_dev_pool_equal_size()rule to check on it, but this hack doesn't do the proper check and test fails ifSCRATCH_LOGDEVis smaller or bigger in size.If btrfs "-d raid0 -m raid1" is capable to do this writeback error test, perhaps you can write a new btrfs test and mkfs with "-d raid0 -m raid1" explicitly. e.g.
...
_require_scratch_dev_pool2_require_scratch_dev_pool_equal_size
..._scratch_mkfs"-d raid0 -m raid1"
...
Quoted 2 lines
Thanks,
Eryu
Yeah, that's probably the right way to do this. It looks like btrfs also has $SCRATCH_DEV_POOL, and we can probably base it on that. I'll look at reworking it.
Signature · 1 line
Jeff Layton <[email protected]>