xfstests: introduce a common directory
[xfstests-dev.git] / tests / generic / 300
1 #! /bin/bash
2 # FSQA Test No. 300
3 #
4 # AIO/DIO stress test
5 # Run random AIO/DIO activity and fallocate/punch_hole simultaneously
6 # Test will operate on huge sparsed file 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 if [ $((BLK_DEV_SIZE)) -gt 1048576 ]
51 then
52     BLK_DEV_SIZE=1048576
53 fi
54 FS_SIZE=$((BLK_DEV_SIZE * 512))
55
56 cat >$tmp-$seq.fio <<EOF
57 ###########
58 # $seq test fio activity
59 # Run DIO, fallocate and punch_hole threads on a single in parallel
60 #
61 # If race exist old dio request may rewrite punched block after it was
62 # allocated to another file, we will catch that by verifying blocks content
63 #
64 [global]
65 directory=${SCRATCH_MNT}
66 filesize=${FS_SIZE}
67 size=999G
68 continue_on_error=write
69 ignore_error=,ENOSPC
70 error_dump=0
71
72 create_on_open=1
73 fallocate=none
74 exitall=1
75
76 ## Perform direct aio, to files which may be truncated
77 ## by external task
78 [direct_aio_raicer]
79 ioengine=libaio
80 iodepth=128*${LOAD_FACTOR}
81 bs=128k
82 direct=1
83 numjobs=${NUM_JOBS}
84 rw=randwrite
85 runtime=100*${TIME_FACTOR}
86 time_based
87 filename=racer
88
89 # Run falloc and punch_hole threads in parallel
90 # After activity file will be highly fragmented
91 [falloc_raicer]
92 ioengine=falloc
93 runtime=100*${TIME_FACTOR}
94 iodepth=1
95 bssplit=128k/80:512k/10:32k/10
96 rw=randwrite
97 numjobs=1
98 filename=racer
99
100 [punch_hole_raicer]
101 ioengine=falloc
102 runtime=100*${TIME_FACTOR}
103 bs=4k
104 time_based=10
105 rw=randtrim
106 numjobs=2
107 filename=racer
108 time_based
109
110 # Verifier thread continiously write to newly allcated blocks
111 # and veryfy written content
112 [aio-dio-verifier]
113 ioengine=libaio
114 iodepth=128*${LOAD_FACTOR}
115 numjobs=1
116 verify=crc32c-intel
117 verify_fatal=1
118 verify_dump=1
119 verify_backlog=1024
120 verify_async=4
121 verifysort=1
122 direct=1
123 bs=4k
124 rw=randwrite
125 filename=aio-dio-verifier
126 EOF
127
128 _workout()
129 {
130         echo ""
131         echo "Run fio with random aio-dio pattern"
132         echo ""
133         cat $tmp-$seq.fio >>  $seqres.full
134         run_check $FIO_PROG $tmp-$seq.fio
135 }
136
137 _require_fio $tmp-$seq.fio
138
139 _scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
140 _scratch_mount
141
142 if ! _workout; then
143         umount $SCRATCH_DEV 2>/dev/null
144         exit
145 fi
146
147 if ! _scratch_unmount; then
148         echo "failed to umount"
149         status=1
150         exit
151 fi
152 _check_scratch_fs
153 status=$?
154 exit