2 # SPDX-License-Identifier: GPL-2.0
6 # See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
7 # the second block is a regular block. (MMAP version of generic/205,206)
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
13 _begin_fstest auto quick clone
15 # Import common functions.
19 # real QA test starts here
20 _require_scratch_reflink
22 pagesz=$(getconf PAGE_SIZE)
25 echo "Format and mount"
26 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
27 _scratch_mount >> $seqres.full 2>&1
29 testdir=$SCRATCH_MNT/test-$seq
32 real_blksz=$(_get_file_block_size $testdir)
33 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
35 echo "Create the original files"
36 _pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
38 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
39 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
41 _pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
42 _pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
44 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
45 _pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
47 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
48 _pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
52 cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
53 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
55 echo "CoW and unmount"
56 $XFS_IO_PROG -f -c "mmap 0 $pagesz" \
57 -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
58 $XFS_IO_PROG -f -c "mmap 0 $pagesz" \
59 -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
63 cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
64 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."