2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
7 # Test for race between dedupe and writing the dest file
10 _begin_fstest auto quick clone dedupe
12 _register_cleanup "_cleanup" BUS
14 # Override the default cleanup function.
18 rm -rf $tmp.* $finished_file
22 # Import common functions.
26 # real QA test starts here
27 _require_scratch_dedupe
29 echo "Format and mount"
30 _scratch_mkfs > $seqres.full 2>&1
31 _scratch_mount >> $seqres.full 2>&1
33 testdir=$SCRATCH_MNT/test-$seq
34 finished_file=/tmp/finished
39 nr_loops=$((loops - 1))
42 echo "Initialize files"
44 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
45 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
49 while [ ! -e $finished_file ]; do
50 seq $nr_loops -1 0 | while read i; do
51 _pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file2 >> $seqres.full
56 echo "Dedupe and rewrite the file!"
58 for i in `seq 1 2`; do
59 seq $nr_loops -1 0 | while read i; do
60 _dedupe_range $testdir/file1 $((i * blksz)) \
61 $testdir/file2 $((i * blksz)) $blksz >> $seqres.full
65 echo "Finished dedupeing"