2 # SPDX-License-Identifier: GPL-2.0
6 # Test for races or FS corruption when mmap writing to a file that's also
7 # the target of a reflink operation. (MMAP version of generic/168,170)
10 _begin_fstest auto clone
12 _register_cleanup "_cleanup" BUS
14 # Import common functions.
18 # real QA test starts here
19 _require_scratch_reflink
21 echo "Format and mount"
22 _scratch_mkfs > $seqres.full 2>&1
23 _scratch_mount >> $seqres.full 2>&1
25 testdir=$SCRATCH_MNT/test-$seq
26 finished_file=/tmp/finished
31 nr_loops=$((loops - 1))
34 echo "Initialize files"
36 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
37 _pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
42 while [ ! -e $finished_file ]; do
43 seq $nr_loops -1 0 | while read i; do
44 $XFS_IO_PROG -f -c "mmap -rw $((i * blksz)) $blksz" \
45 -c "mwrite -S 0x63 $((i * blksz)) $blksz" $testdir/file2 >> $seqres.full
50 echo "Reflink and mmap write the target"
52 seq 1 10 | while read j; do
53 seq 0 $nr_loops | while read i; do
54 _reflink_range $testdir/file1 $((i * blksz)) \
55 $testdir/file2 $((i * blksz)) $blksz >> $seqres.full