fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 165
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. 165
6 #
7 # Test for races or FS corruption between reflink and direct I/O reading the
8 # target file.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.* $finished_file
23     wait
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30
31 # real QA test starts here
32 _supported_os Linux
33 _require_scratch_reflink
34 _require_cp_reflink
35 _require_odirect
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 finished_file=/tmp/finished
43 rm -rf $finished_file
44 mkdir $testdir
45
46 loops=512
47 nr_loops=$((loops - 1))
48 blksz=65536
49
50 echo "Initialize files"
51 echo >> $seqres.full
52 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
53 _pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file3
55 _scratch_cycle_mount
56
57 fbytes() {
58         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)'
59 }
60
61 reader() {
62         while [ ! -e $finished_file ]; do
63                 _read_range $testdir/file3 0 $((loops * blksz)) -d | fbytes
64         done
65 }
66
67 echo "Reflink and dio reread the files!"
68 reader &
69 for i in `seq 1 2`; do
70         seq $nr_loops -1 0 | while read i; do
71                 _reflink_range  $testdir/file1 $((i * blksz)) \
72                                 $testdir/file3 $((i * blksz)) $blksz >> $seqres.full
73                 [ $? -ne 0 ] && break
74         done
75         seq $nr_loops -1 0 | while read i; do
76                 _reflink_range  $testdir/file2 $((i * blksz)) \
77                                 $testdir/file3 $((i * blksz)) $blksz >> $seqres.full
78                 [ $? -ne 0 ] && break
79         done
80 done
81 echo "Finished reflinking"
82 touch $finished_file
83 wait
84
85 # success, all done
86 status=0
87 exit