2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2022 Oracle. All Rights Reserved.
7 # Regression test for kernel commits:
9 # 5679897eb104 ("vfs: make sync_filesystem return errors from ->sync_fs")
10 # 2d86293c7075 ("xfs: return errors in xfs_fs_sync_fs")
12 # During a code inspection, I noticed that sync_filesystem ignores the return
13 # value of the ->sync_fs calls that it makes. sync_filesystem, in turn is used
14 # by the syncfs(2) syscall to persist filesystem changes to disk. This means
15 # that syncfs(2) does not capture internal filesystem errors that are neither
16 # visible from the block device (e.g. media error) nor recorded in s_wb_err.
17 # XFS historically returned 0 from ->sync_fs even if there were log failures,
18 # so that had to be corrected as well.
20 # The kernel commits above fix this problem, so this test tries to trigger the
21 # bug by using the shutdown ioctl on a clean, freshly mounted filesystem in the
22 # hope that the EIO generated as a result of the filesystem being shut down is
23 # only visible via ->sync_fs.
26 _begin_fstest auto quick shutdown
28 # real QA test starts here
30 # Modify as appropriate.
32 _require_xfs_io_command syncfs
33 _require_scratch_nocheck
34 _require_scratch_shutdown
36 # Reuse the fs formatted when we checked for the shutdown ioctl, and don't
37 # bother checking the filesystem afterwards since we never wrote anything.
39 $XFS_IO_PROG -x -c 'shutdown -f ' -c syncfs $SCRATCH_MNT