tests: remove udf/101
[xfstests-dev.git] / tests / generic / 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 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 fio_config=$tmp.fio
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os Linux
44 _require_scratch
45 _require_odirect
46 _require_block_device $SCRATCH_DEV
47
48 NUM_JOBS=$((4*LOAD_FACTOR))
49 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
50 FILE_SIZE=$((BLK_DEV_SIZE * 512))
51
52 cat >$fio_config <<EOF
53 ###########
54 # $seq test fio activity
55 # Filenames derived from jobsname and jobid like follows:
56 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
57 [global]
58 ioengine=libaio
59 bs=128k
60 directory=${SCRATCH_MNT}
61 filesize=${FILE_SIZE}
62 size=999G
63 iodepth=128*${LOAD_FACTOR}
64 continue_on_error=write
65 ignore_error=,ENOSPC
66 error_dump=0
67 create_on_open=1
68 fallocate=none
69 exitall=1
70
71 ## Perform direct aio, to files which may be truncated
72 ## by external task
73 [direct_aio]
74 direct=1
75 buffered=0
76 numjobs=${NUM_JOBS}
77 rw=randwrite
78 runtime=100*${TIME_FACTOR}
79 time_based
80
81 # Perform direct aio and verify data
82 # This test case should check use-after-free issues
83 [aio-dio-verifier]
84 numjobs=1
85 verify=crc32c-intel
86 verify_fatal=1
87 verify_dump=1
88 verify_backlog=1024
89 verify_async=4
90 verifysort=1
91 direct=1
92 bs=4k
93 rw=randrw
94 filename=aio-dio-verifier
95
96 # Perform buffered aio and verify data
97 # This test case should check use-after-free issues
98 [buffered-aio-verifier]
99 numjobs=1
100 verify=crc32c-intel
101 verify_fatal=1
102 verify_dump=1
103 verify_backlog=1024
104 verify_async=4
105 verifysort=1
106 direct=0
107 buffered=1
108 bs=4k
109 rw=randrw
110 filename=buffered-aio-verifier
111 EOF
112
113 rm -f $seqres.full
114
115 _require_fio $fio_config
116 _require_xfs_io_command "falloc"
117
118 _workout()
119 {
120         echo ""
121         echo "Run fio with random aio-dio pattern"
122         echo ""
123         cat $fio_config >>  $seqres.full
124         run_check $FIO_PROG $fio_config &
125         pid=$!
126         echo "Start fallocate/truncate loop"
127
128         for ((i=0; ; i++))
129         do
130             for ((k=1; k <= NUM_JOBS; k++))
131             do
132                 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
133                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
134             done
135             for ((k=1; k <= NUM_JOBS; k++))
136             do
137                 $XFS_IO_PROG -c "truncate  0" \
138                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
139             done
140             # Following like will check that pid is still run.
141             # Once fio exit we can stop fallocate/truncate loop
142             pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
143         done
144         wait $pid
145 }
146
147 _scratch_mkfs >> $seqres.full 2>&1
148 _scratch_mount
149
150 if ! _workout; then
151         _scratch_unmount 2>/dev/null
152         exit
153 fi
154
155 if ! _scratch_unmount; then
156         echo "failed to umount"
157         status=1
158         exit
159 fi
160 status=0
161 exit