3 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
4 # Author: Erwan Velu <erwan@enovance.com>
6 # The license below covers all files distributed with fio unless otherwise
7 # noted in the file itself.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2 as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 TEMPLATE=/tmp/template.fio
30 MODES="write,randwrite,read,randread"
39 echo "usage of $PROG:"
41 -h : Show this help & exit
42 -c : Enable cached-based IOs
44 -a : Run sequential test then parallel one
46 -s : Run sequential test (default value)
47 one test after another then one disk after another
49 -p : Run parallel test
50 one test after anoter but all disks at the same time
52 -D iodepth : Run with the specified iodepth
54 -d disk1[,disk2,disk3,..] : Run the tests on the selected disks
55 Separated each disk with a comma
56 Disk name shall be "sdxx", /dev/ shall NOT be used here
57 -r seconds : Time in seconds per benchmark
58 0 means till the end of the device
59 Default is 300 seconds
60 -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...)
61 Separated each blocksize with a comma
63 -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite
64 Default is "write,randwrite,read,randread"
65 -x prefix : Add a prefix to the fio filename
66 Useful to let a context associated with the file
67 If the prefix features a / (slash), prefix will be considered as a directory
71 $PROG -d sdb,sdc,sdd,sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/
73 Will generate an fio file that will run
74 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
75 ETA ~ 4 tests * 4 disks * 100 seconds
76 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
77 ETA ~ 4 tests * 4 disks * 100 seconds
78 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
79 ETA ~ 4 tests * 4 disks * 100 seconds
80 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
81 ETA ~ 4 tests * 100 seconds
82 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
83 ETA ~ 4 tests * 100 seconds
84 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
85 ETA ~ 4 tests * 100 seconds
87 Generating dellr720-day2/localhost-4k,128k,1m-all-write,randwrite,read,randread-sdb,sdc,sdd,sde.fio
88 Estimated Time = 6000 seconds : 1 hour 40 minutes
97 if [ "$RUNTIME" != "0" ]; then
98 cat >>$TEMPLATE << EOF
104 if [ "$CACHED_IO" = "FALSE" ]; then
105 cat >>$TEMPLATE << EOF
112 cat >$TEMPLATE << EOF
122 cat >> $OUTFILE << EOF
123 [$TYPE-$disk-$BLK_SIZE-seq]
128 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results
129 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results
131 ETA=$(($ETA + $RUNTIME))
135 for disk in $(echo $DISKS | tr "," " "); do
136 for mode in $(echo $MODES | tr "," " "); do
137 gen_seq_suite "$mode"
147 for disk in $(echo $DISKS | tr "," " "); do
148 cat >> $OUTFILE << EOF
149 [$TYPE-$disk-$BLK_SIZE-para]
153 if [ "$D" = 0 ]; then
154 echo "stonewall" >> $OUTFILE
158 cat >> $OUTFILE << EOF
161 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results
162 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results
166 ETA=$(($ETA + $RUNTIME))
171 for mode in $(echo $MODES | tr "," " "); do
172 gen_para_suite "$mode"
192 while getopts "hacpsd:b:r:m:x:D:" opt; do
205 if [ "$SEQ" = "-1" ]; then
211 echo "$PREFIX" | grep -q "/"
212 if [ "$?" -eq 0 ]; then
214 # No need to keep the prefix for the log files
215 # we do have a directory for that
218 # We need to keep the prefix for the log files
219 PREFIX_FILENAME=$PREFIX
226 if [ "$SEQ" = "-1" ]; then
243 echo "Invalid option: -$OPTARG" >&2
248 if [ "$SEQ" = "-1" ]; then
252 SHORT_HOSTNAME=$(hostname -s)
255 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$DISKS.fio
259 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$DISKS.fio
262 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$DISKS.fio
266 if [ -z "$DISKS" ]; then
267 echo "Missing DISKS !"
268 echo "Please read the help !"
277 CAUSE="You are reading data before writing them "
279 # If no write occurs, let's show a different message
280 echo $MODES | grep -q "write"
281 if [ "$?" -ne 0 ]; then
282 CAUSE="You are reading data while never wrote them before"
285 for mode in $(echo $MODES | tr "," " "); do
286 echo $mode | grep -q write
287 if [ "$?" -eq 0 ]; then
290 echo $mode | grep -q "read"
291 if [ "$?" -eq 0 ]; then
292 if [ "$FOUND_WRITE" = "NO" ]; then
293 echo "###############################################################"
294 echo "# Warning : $CAUSE#"
295 echo "# On some storage devices, this could lead to invalid results #"
297 echo "# Press Ctrl-C to adjust pattern order if you have doubts #"
298 echo "# Or Wait 5 seconds before the file will be created #"
299 echo "###############################################################"
301 # No need to try showing the message more than one time
315 echo "Generating $OUTFILE"
316 cp -f $TEMPLATE $OUTFILE
319 for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do
322 ETA_H=$(($ETA / 3600))
323 ETA_M=$((($ETA - ($ETA_H*3600)) / 60))
324 if [ "$ETA" = "0" ]; then
325 echo "Cannot estimate ETA as RUNTIME=0"
327 echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes"