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 source of a reflink operation.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
22 rm -rf $tmp.* $finished_file
26 # get standard environment, filters and checks
31 # real QA test starts here
32 _require_scratch_reflink
36 echo "Format and mount"
37 _scratch_mkfs > $seqres.full 2>&1
38 _scratch_mount >> $seqres.full 2>&1
40 testdir=$SCRATCH_MNT/test-$seq
41 finished_file=/tmp/finished
42 do_snapshot=/tmp/snapshot
47 nr_loops=$((loops - 1))
50 echo "Initialize file"
52 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
57 # We rate limit the snapshot creator to one snapshot per full file write. this
58 # limits the runtime on slow devices, whilst not substantially reducing the the
59 # number of snapshots taken on fast devices.
62 while [ ! -e $finished_file ]; do
63 if [ ! -e $do_snapshot ]; then
67 out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
69 echo "$out" | grep -q "No space left" && break
70 test -n "$out" && echo "$out"
71 test $res -ne 0 && break
77 echo "Snapshot a file undergoing directio rewrite"
79 seq $nr_loops -1 0 | while read i; do
80 _pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file1 >> $seqres.full