71a1191938c3653f6a4411b7abcd0d2cfb473f1f
[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 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41
42 # real QA test starts here
43 _supported_fs generic
44 _supported_os Linux
45 _need_to_be_root
46 _require_scratch
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 >$tmp-$seq.fio <<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 _require_fio $tmp-$seq.fio
114
115 _workout()
116 {
117         echo ""
118         echo "Run fio with random aio-dio pattern"
119         echo ""
120         cat $tmp-$seq.fio >>  $seqres.full
121         run_check $FIO_PROG $tmp-$seq.fio &
122         pid=$!
123         echo "Start fallocate/truncate loop"
124
125         for ((i=0; ; i++))
126         do
127             for ((k=1; k <= NUM_JOBS; k++))
128             do
129                 fallocate -l $FILE_SIZE $SCRATCH_MNT/direct_aio.$k.0 \
130                         >> $seqres.full 2>&1
131             done
132             for ((k=1; k <= NUM_JOBS; k++))
133             do
134                 truncate -s 0 $SCRATCH_MNT/direct_aio.$k.0
135             done
136             # Following like will check that pid is still run.
137             # Once fio exit we can stop fallocate/truncate loop
138             kill -0 $pid > /dev/null 2>&1 || break
139         done
140         wait $pid
141 }
142
143 _scratch_mkfs >> $seqres.full 2>&1
144 _scratch_mount
145
146 if ! _workout; then
147         umount $SCRATCH_DEV 2>/dev/null
148         exit
149 fi
150
151 if ! _scratch_unmount; then
152         echo "failed to umount"
153         status=1
154         exit
155 fi
156 _check_scratch_fs
157 status=$?
158 exit