4 # Truncate a file at midway through a CoW region.
6 # This test is dependent on the system page size, so we cannot use md5 in
7 # the golden output; we can only compare to a check file.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # real QA test starts here
48 _require_scratch_reflink
50 _require_xfs_io_command "truncate"
55 echo "Format and mount"
56 _scratch_mkfs > $seqres.full 2>&1
57 _scratch_mount >> $seqres.full 2>&1
59 testdir=$SCRATCH_MNT/test-$seq
64 filesize=$((blksz * nr))
66 echo "Create the original files"
67 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
68 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
69 _pwrite_byte 0x61 0 $filesize $testdir/file2.chk >> $seqres.full
73 md5sum $testdir/file1 | _filter_scratch
74 md5sum $testdir/file2 | _filter_scratch
75 md5sum $testdir/file2.chk | _filter_scratch
77 echo "CoW and unmount"
78 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" $testdir/file2 >> $seqres.full
80 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" $testdir/file2.chk >> $seqres.full
84 md5sum $testdir/file1 | _filter_scratch
85 md5sum $testdir/file2 | _filter_scratch
86 md5sum $testdir/file2.chk | _filter_scratch