xfstests: include test subdirectory support
[xfstests-dev.git] / 299
1 #! /bin/bash
2 # FSQA Test No. 299
3 #
4 # AIO/DIO stress test
5 # Run random AIO/DIO activity and fallocate/truncate simultaneously
6 # Test will operate on huge sparsed files so ENOSPC is expected.
7 #
8 #-----------------------------------------------------------------------
9 # (c) 2013 Dmitry Monakhov
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 # real QA test starts here
40 _supported_fs generic
41 _supported_os Linux
42 _need_to_be_root
43 _require_scratch
44
45 NUM_JOBS=$((4*LOAD_FACTOR))
46 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
47 FILE_SIZE=$((BLK_DEV_SIZE * 512))
48
49 cat >$tmp-$seq.fio <<EOF
50 ###########
51 # $seq test fio activity
52 # Filenames derived from jobsname and jobid like follows:
53 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
54 [global]
55 ioengine=libaio
56 bs=128k
57 directory=${SCRATCH_MNT}
58 filesize=${FILE_SIZE}
59 size=999G
60 iodepth=128*${LOAD_FACTOR}
61 continue_on_error=write
62 ignore_error=,ENOSPC
63 error_dump=0
64 create_on_open=1
65 fallocate=none
66 exitall=1
67
68 ## Perform direct aio, to files which may be truncated
69 ## by external task
70 [direct_aio]
71 direct=1
72 buffered=0
73 numjobs=${NUM_JOBS}
74 rw=randwrite
75 runtime=100*${TIME_FACTOR}
76 time_based
77
78 # Perform direct aio and verify data
79 # This test case should check use-after-free issues
80 [aio-dio-verifier]
81 numjobs=1
82 verify=crc32c-intel
83 verify_fatal=1
84 verify_dump=1
85 verify_backlog=1024
86 verify_async=4
87 verifysort=1
88 direct=1
89 bs=4k
90 rw=randrw
91 filename=aio-dio-verifier
92
93 # Perform buffered aio and verify data
94 # This test case should check use-after-free issues
95 [buffered-aio-verifier]
96 numjobs=1
97 verify=crc32c-intel
98 verify_fatal=1
99 verify_dump=1
100 verify_backlog=1024
101 verify_async=4
102 verifysort=1
103 direct=0
104 buffered=1
105 bs=4k
106 rw=randrw
107 filename=buffered-aio-verifier
108 EOF
109
110 _require_fio $tmp-$seq.fio
111
112 _workout()
113 {
114         echo ""
115         echo "Run fio with random aio-dio pattern"
116         echo ""
117         cat $tmp-$seq.fio >>  $seq.full
118         run_check $FIO_PROG $tmp-$seq.fio &
119         pid=$!
120         echo "Start fallocate/truncate loop"
121
122         for ((i=0; ; i++))
123         do
124             for ((k=1; k <= NUM_JOBS; k++))
125             do
126                 fallocate -l $FILE_SIZE $SCRATCH_MNT/direct_aio.$k.0 \
127                         >> $seq.full 2>&1
128             done
129             for ((k=1; k <= NUM_JOBS; k++))
130             do
131                 truncate -s 0 $SCRATCH_MNT/direct_aio.$k.0
132             done
133             # Following like will check that pid is still run.
134             # Once fio exit we can stop fallocate/truncate loop
135             kill -0 $pid > /dev/null 2>&1 || break
136         done
137         wait $pid
138 }
139
140 _scratch_mkfs >> $seq.full 2>&1
141 _scratch_mount
142
143 if ! _workout; then
144         umount $SCRATCH_DEV 2>/dev/null
145         exit
146 fi
147
148 if ! _scratch_unmount; then
149         echo "failed to umount"
150         status=1
151         exit
152 fi
153 _check_scratch_fs
154 status=$?
155 exit