fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 163
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 163
6 #
7 # Test for race between dedupe and writing the source file
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $finished_file
22     wait
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scratch_dedupe
33
34 echo "Format and mount"
35 _scratch_mkfs > $seqres.full 2>&1
36 _scratch_mount >> $seqres.full 2>&1
37
38 testdir=$SCRATCH_MNT/test-$seq
39 finished_file=/tmp/finished
40 rm -rf $finished_file
41 mkdir $testdir
42
43 loops=512
44 nr_loops=$((loops - 1))
45 blksz=65536
46
47 echo "Initialize files"
48 echo >> $seqres.full
49 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
50 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
51 _scratch_cycle_mount
52
53 overwrite() {
54         while [ ! -e $finished_file ]; do
55                 seq $nr_loops -1 0 | while read i; do
56                         _pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file1 >> $seqres.full
57                 done
58         done
59 }
60
61 echo "Dedupe and rewrite the file!"
62 overwrite &
63 for i in `seq 1 2`; do
64         seq $nr_loops -1 0 | while read i; do
65                 _dedupe_range   $testdir/file1 $((i * blksz)) \
66                                 $testdir/file2 $((i * blksz)) $blksz >> $seqres.full
67                 [ $? -ne 0 ] && break
68         done
69 done
70 echo "Finished dedupeing"
71 touch $finished_file
72 wait
73
74 # success, all done
75 status=0
76 exit