2 # SPDX-License-Identifier: GPL-2.0
6 # Ensuring that copy on write in mmap mode to the source file when the
7 # CoW range covers unwritten and regular shared blocks.
8 # (MMAP version of generic/289,290)
10 # - fallocate the first file.
11 # - Write the odd blocks of the first file.
12 # - Reflink the odd blocks of the first file into the second file.
13 # - mmap CoW the first file across the halfway mark, starting with the
15 # - Check that the files are now different where we say they're different.
18 _begin_fstest auto quick clone
20 # Import common functions.
24 # real QA test starts here
25 _require_scratch_reflink
26 _require_xfs_io_command "falloc"
28 echo "Format and mount"
29 _scratch_mkfs > $seqres.full 2>&1
30 _scratch_mount >> $seqres.full 2>&1
32 testdir=$SCRATCH_MNT/test-$seq
35 echo "Create the original files"
38 filesize=$((blksz * nr))
39 _sweave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
43 md5sum $testdir/file1 | _filter_scratch
44 md5sum $testdir/file3 | _filter_scratch
45 md5sum $testdir/file1.chk | _filter_scratch
47 echo "mmap CoW across the transition"
48 cowoff=$((filesize / 4))
49 cowsz=$((filesize / 2))
50 mmapsz=$((cowoff + cowsz))
51 _mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full
52 _mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full
56 md5sum $testdir/file1 | _filter_scratch
57 md5sum $testdir/file3 | _filter_scratch
58 md5sum $testdir/file1.chk | _filter_scratch