4 # See what happens if we CoW blocks 2-4 of a page's worth of blocks when the
5 # second block is a regular block.
7 # This test is dependent on the system page size, so we cannot use md5 in
8 # the golden output; we can only compare to a check file.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
39 rm -rf $tmp.* $testdir
42 # get standard environment, filters and checks
47 # real QA test starts here
49 _require_scratch_reflink
53 pagesz=$(getconf PAGE_SIZE)
56 echo "Format and mount"
57 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
58 _scratch_mount >> $seqres.full 2>&1
60 testdir=$SCRATCH_MNT/test-$seq
63 real_blksz=$(_get_block_size $testdir)
64 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
66 echo "Create the original files"
67 _pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
69 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
70 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
72 _pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
73 _pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
75 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
76 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
78 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
79 _pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
83 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
84 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
86 echo "CoW and unmount"
87 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
88 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
92 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
93 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."