2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Make sure that copy_file_range forces the log out if we open the file with
8 # O_SYNC or set FS_XFLAG_SYNC on the file. We test that it actually forced the
9 # log by using dm-error to shut down the fs without flushing the log and then
10 # remounting to check file contents. This is a regression test for commit
11 # 5ffce3cc22a0 ("xfs: force the log after remapping a synchronous-writes file")
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
35 # real QA test starts here
37 _require_dm_target error
38 _require_xfs_io_command "chattr" "s"
39 _require_xfs_io_command "copy_range"
44 # Format filesystem and set up quota limits
45 _scratch_mkfs > $seqres.full
46 _require_metadata_journaling $SCRATCH_DEV
50 # Test that O_SYNC actually results in file data being written even if the
52 echo "test o_sync write"
53 $XFS_IO_PROG -x -f -s -c "pwrite -S 0x58 0 1m -b 1m" $SCRATCH_MNT/0 >> $seqres.full
54 _dmerror_load_error_table
56 _dmerror_load_working_table
58 md5sum $SCRATCH_MNT/0 | _filter_scratch
60 # Set up initial files for copy test
61 $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
65 # Test that unaligned copy file range forces dirty data/metadata to disk when
66 # destination file opened with O_SYNC
67 echo "test unaligned copy range o_sync"
68 $XFS_IO_PROG -x -s -c "copy_range -s 13 -d 13 -l 1048550 $SCRATCH_MNT/a" $SCRATCH_MNT/b >> $seqres.full
69 _dmerror_load_error_table
71 _dmerror_load_working_table
73 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
75 # Set up dest file with chattr +S
78 chattr +S $SCRATCH_MNT/b
81 # Test that unaligned copy file range forces dirty data/metadata to disk when
82 # destination file has the sync iflag set
83 echo "test unaligned copy range iflag"
84 $XFS_IO_PROG -x -c "copy_range -s 13 -d 13 -l 1048550 $SCRATCH_MNT/a" $SCRATCH_MNT/b >> $seqres.full
85 _dmerror_load_error_table
87 _dmerror_load_working_table
89 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch