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 regular block.
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 _begin_fstest auto quick clone
16 # Override the default cleanup function.
20 rm -rf $tmp.* $testdir
23 # Import common functions.
27 # real QA test starts here
28 _require_scratch_reflink
30 pagesz=$(getconf PAGE_SIZE)
33 echo "Format and mount"
34 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
37 testdir=$SCRATCH_MNT/test-$seq
40 real_blksz=$(_get_file_block_size $testdir)
41 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
43 echo "Create the original files"
44 _pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
46 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
47 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
49 _pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
50 _pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
52 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
53 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
55 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
56 _pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
60 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
61 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
63 echo "CoW and unmount"
64 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
65 $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
69 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
70 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."