2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # See what happens if we DIO CoW blocks 2-4 of a page's worth of blocks when
8 # the surrounding blocks vary between unwritten/regular/delalloc/hole.
10 # This test is dependent on the system page size, so we cannot use md5 in
11 # the golden output; we can only compare to a check 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
25 rm -rf $tmp.* $testdir
28 # get standard environment, filters and checks
33 # real QA test starts here
35 _require_scratch_reflink
36 _require_xfs_io_command "falloc"
41 pagesz=$(getconf PAGE_SIZE)
44 echo "Format and mount"
45 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
48 testdir=$SCRATCH_MNT/test-$seq
51 real_blksz=$(_get_file_block_size $testdir)
52 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
60 echo "Create the original files"
62 _pwrite_byte 0x61 0 $pagesz $dir/file1 >> $seqres.full
64 $XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2 >> $seqres.full
65 $XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2.chk >> $seqres.full
69 _pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
70 _pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
73 $XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $dir/file2 >> $seqres.full
74 _pwrite_byte 0x00 $blksz $blksz $dir/file2.chk >> $seqres.full
84 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
85 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
88 $XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $dir/file2 >> $seqres.full
89 _pwrite_byte 0x00 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
95 _reflink_range $dir/file1 $blksz $dir/file2 $((blksz * 2)) $blksz >> $seqres.full
96 _pwrite_byte 0x61 $((blksz * 2)) $blksz $dir/file2.chk >> $seqres.full
100 ! cmp -s $dir/file1 $dir/file2 || _fail "file1 and file2 don't match."
101 cmp -s $dir/file2 $dir/file2.chk || _fail "file2 and file2.chk don't match."
103 echo "CoW and unmount"
104 if [ $b2 = "delalloc" ]; then
105 _pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
106 _pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
109 if [ $b4 = "delalloc" ]; then
110 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
111 _pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
114 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 $blksz $((blksz * 3))" $dir/file2 >> $seqres.full
115 $XFS_IO_PROG -f -c "pwrite -S 0x63 $blksz $((blksz * 3))" $dir/file2.chk >> $seqres.full
119 ! cmp -s $dir/file1 $dir/file2 || _fail "file1 and file2 don't match."
120 cmp -s $dir/file2 $dir/file2.chk || _fail "file2 and file2.chk don't match."
123 runtest regular delalloc "$testdir/r-d"
124 runtest regular unwritten "$testdir/r-u"
125 runtest regular hole "$testdir/r-h"
126 runtest regular regular "$testdir/r-r"
128 runtest hole delalloc "$testdir/h-d"
129 runtest hole unwritten "$testdir/h-u"
130 runtest hole hole "$testdir/h-h"
131 runtest hole regular "$testdir/h-r"
133 runtest unwritten delalloc "$testdir/u-d"
134 runtest unwritten unwritten "$testdir/u-u"
135 runtest unwritten hole "$testdir/u-h"
136 runtest unwritten regular "$testdir/u-r"
138 runtest delalloc delalloc "$testdir/d-d"
139 runtest delalloc unwritten "$testdir/d-u"
140 runtest delalloc hole "$testdir/d-h"
141 runtest delalloc regular "$testdir/d-r"