2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
7 # Test for races or FS corruption between reflink and buffered I/O reading the
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
35 echo "Format and mount"
36 _scratch_mkfs > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
39 testdir=$SCRATCH_MNT/test-$seq
40 finished_file=/tmp/finished
45 nr_loops=$((loops - 1))
48 echo "Initialize files"
50 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
51 _pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
52 _cp_reflink $testdir/file1 $testdir/file3
56 egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
60 while [ ! -e $finished_file ]; do
61 _read_range $testdir/file3 0 $((loops * blksz)) | fbytes
65 echo "Reflink and reread the files!"
67 for i in `seq 1 2`; do
68 seq $nr_loops -1 0 | while read i; do
69 _reflink_range $testdir/file1 $((i * blksz)) \
70 $testdir/file3 $((i * blksz)) $blksz >> $seqres.full
73 seq $nr_loops -1 0 | while read i; do
74 _reflink_range $testdir/file2 $((i * blksz)) \
75 $testdir/file3 $((i * blksz)) $blksz >> $seqres.full
79 echo "Finished reflinking"