4 # See what happens if we CoW blocks 2-4 of a page's worth of blocks when the
5 # surrounding blocks vary between unwritten/regular/delalloc/hole.
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
50 _require_xfs_io_command "falloc"
54 pagesz=$(getconf PAGE_SIZE)
57 echo "Format and mount"
58 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
59 _scratch_mount >> $seqres.full 2>&1
61 testdir=$SCRATCH_MNT/test-$seq
64 real_blksz=$(get_block_size $testdir)
65 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
73 echo "Create the original files"
75 _pwrite_byte 0x61 0 $pagesz $dir/file1 >> $seqres.full
77 $XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2 >> $seqres.full
78 $XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2.chk >> $seqres.full
82 _pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
83 _pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
86 $XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $dir/file2 >> $seqres.full
87 _pwrite_byte 0x00 $blksz $blksz $dir/file2.chk >> $seqres.full
97 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
98 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
101 $XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $dir/file2 >> $seqres.full
102 _pwrite_byte 0x00 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
108 _reflink_range $dir/file1 $blksz $dir/file2 $((blksz * 2)) $blksz >> $seqres.full
109 _pwrite_byte 0x61 $((blksz * 2)) $blksz $dir/file2.chk >> $seqres.full
113 ! cmp -s $dir/file1 $dir/file2 || _fail "file1 and file2 don't match."
114 cmp -s $dir/file2 $dir/file2.chk || _fail "file2 and file2.chk don't match."
116 echo "CoW and unmount"
117 if [ $b2 = "delalloc" ]; then
118 _pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
119 _pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
122 if [ $b4 = "delalloc" ]; then
123 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
124 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
127 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2 >> $seqres.full
128 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2.chk >> $seqres.full
132 ! cmp -s $dir/file1 $dir/file2 || _fail "file1 and file2 don't match."
133 cmp -s $dir/file2 $dir/file2.chk || _fail "file2 and file2.chk don't match."
136 runtest regular delalloc "$testdir/r-d"
137 runtest regular unwritten "$testdir/r-u"
138 runtest regular hole "$testdir/r-h"
139 runtest regular regular "$testdir/r-r"
141 runtest hole delalloc "$testdir/h-d"
142 runtest hole unwritten "$testdir/h-u"
143 runtest hole hole "$testdir/h-h"
144 runtest hole regular "$testdir/h-r"
146 runtest unwritten delalloc "$testdir/u-d"
147 runtest unwritten unwritten "$testdir/u-u"
148 runtest unwritten hole "$testdir/u-h"
149 runtest unwritten regular "$testdir/u-r"
151 runtest delalloc delalloc "$testdir/d-d"
152 runtest delalloc unwritten "$testdir/d-u"
153 runtest delalloc hole "$testdir/d-h"
154 runtest delalloc regular "$testdir/d-r"