2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018, Jeff Layton <jlayton@redhat.com>
7 # Open a file several times, write to it, fsync on all fds and make sure that
8 # they all return 0. Change the device to start throwing errors. Write again
9 # on all fds and fsync on all fds. Ensure that we get errors on all of them.
10 # Then fsync on all one last time and verify that all return 0.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # real QA test starts here
34 _require_scratch_nocheck
35 # This test uses "dm" without taking into account the data could be on
36 # realtime subvolume, thus the test will fail with rtinherit=1
42 _notrun "btrfs has a specialized test for this"
49 _require_dm_target error
53 echo "Format and mount"
54 _scratch_mkfs > $seqres.full 2>&1
59 _require_fs_space $SCRATCH_MNT $datalen
61 # use fd 5 to hold file open
62 testfile=$SCRATCH_MNT/fsync-open-after-err
65 # write some data to file and fsync it out
66 $XFS_IO_PROG -c "pwrite -q 0 $datalen" -c fsync $testfile
68 # flip device to non-working mode
69 _dmerror_load_error_table
71 # rewrite the data, call sync to ensure it's written back w/o scraping error
72 $XFS_IO_PROG -c "pwrite -q 0 $datalen" -c sync $testfile
74 # heal the device error
75 _dmerror_load_working_table
77 # open again and call fsync
78 echo "The following fsync should fail with EIO:"
79 $XFS_IO_PROG -c fsync $testfile