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 CoW blocks 2-4 of a page's worth of blocks when the
8 # second block is a 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
34 _require_scratch_reflink
35 _require_xfs_io_command "falloc"
39 pagesz=$(getconf PAGE_SIZE)
42 echo "Format and mount"
43 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
44 _scratch_mount >> $seqres.full 2>&1
46 testdir=$SCRATCH_MNT/test-$seq
49 real_blksz=$(_get_file_block_size $testdir)
50 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
52 echo "Create the original files"
53 _pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
55 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
56 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
58 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
59 _pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
63 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
64 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
66 echo "CoW and unmount"
67 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
68 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
72 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
73 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."