2 # SPDX-License-Identifier: GPL-2.0
6 # Ensuring that copy on write in mmap mode works when the CoW
7 # range originally covers multiple extents, some unwritten, some not.
8 # (MMAP version of generic/189,188)
9 # - Create a file and fallocate a second file.
10 # - Reflink the odd blocks of the first file into the second file.
11 # - mmap CoW across the halfway mark, starting with the unwritten extent.
12 # - Check that the files are now different where we say they're different.
15 _begin_fstest auto quick clone
17 # Import common functions.
21 # real QA test starts here
22 _require_scratch_reflink
23 _require_xfs_io_command "falloc"
25 echo "Format and mount"
26 _scratch_mkfs > $seqres.full 2>&1
27 _scratch_mount >> $seqres.full 2>&1
29 testdir=$SCRATCH_MNT/test-$seq
32 echo "Create the original files"
35 filesize=$((blksz * nr))
36 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
40 md5sum $testdir/file1 | _filter_scratch
41 md5sum $testdir/file3 | _filter_scratch
42 md5sum $testdir/file3.chk | _filter_scratch
44 echo "mmap CoW across the transition"
45 cowoff=$((filesize / 4))
46 cowsz=$((filesize / 2))
47 mmapsz=$((cowoff + cowsz))
48 _mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full
49 _mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full
53 md5sum $testdir/file1 | _filter_scratch
54 md5sum $testdir/file3 | _filter_scratch
55 md5sum $testdir/file3.chk | _filter_scratch