2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
7 # Test for races or FS corruption when DIO writing to a file that's also
8 # the target of a reflink operation.
11 _begin_fstest auto clone
13 _register_cleanup "_cleanup" BUS
15 # Override the default cleanup function.
19 rm -rf $tmp.* $finished_file
23 # Import common functions.
27 # real QA test starts here
28 _require_scratch_reflink
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
35 testdir=$SCRATCH_MNT/test-$seq
36 finished_file=/tmp/finished
41 nr_loops=$((loops - 1))
44 echo "Initialize files"
46 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
47 _pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
50 # Direct I/O overwriter...
52 while [ ! -e $finished_file ]; do
53 seq $nr_loops -1 0 | while read i; do
54 _pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file2 >> $seqres.full
59 echo "Reflink and dio write the target"
61 seq 1 10 | while read j; do
62 seq 0 $nr_loops | while read i; do
63 _reflink_range $testdir/file1 $((i * blksz)) \
64 $testdir/file2 $((i * blksz)) $blksz >> $seqres.full