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"
38 echo "usage of $PROG:"
40 -h : Show this help & exit
41 -c : Enable cached-based IOs
43 -a : Run sequential test then parallel one
45 -s : Run sequential test (default value)
46 one test after another then one disk after another
48 -p : Run parallel test
49 one test after anoter but all disks at the same time
51 -d disk1[,disk2,disk3,..] : Run the tests on the selected disks
52 Separated each disk with a comma
53 Disk name shall be "sdxx", /dev/ shall NOT be used here
54 -r seconds : Time in seconds per benchmark
55 0 means till the end of the device
56 Default is 300 seconds
57 -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...)
58 Separated each blocksize with a comma
60 -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite
61 Default is "write,randwrite,read,randread"
62 -x prefix : Add a prefix to the fio filename
63 Useful to let a context associated with the file
64 If the prefix features a / (slash), prefix will be considered as a directory
68 $PROG -d sdb,sdc,sdd,sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/
70 Will generate an fio file that will run
71 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
72 ETA ~ 4 tests * 4 disks * 100 seconds
73 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
74 ETA ~ 4 tests * 4 disks * 100 seconds
75 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
76 ETA ~ 4 tests * 4 disks * 100 seconds
77 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
78 ETA ~ 4 tests * 100 seconds
79 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
80 ETA ~ 4 tests * 100 seconds
81 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
82 ETA ~ 4 tests * 100 seconds
84 Generating dellr720-day2/localhost-4k,128k,1m-all-write,randwrite,read,randread-sdb,sdc,sdd,sde.fio
85 Estimated Time = 6000 seconds : 1 hour 40 minutes
97 if [ "$RUNTIME" != "0" ]; then
98 cat >>$TEMPLATE << EOF
103 if [ "$CACHED_IO" = "FALSE" ]; then
104 cat >>$TEMPLATE << EOF
113 cat >> $OUTFILE << EOF
114 [$TYPE-$disk-$BLK_SIZE-seq]
119 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results
120 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results
122 ETA=$(($ETA + $RUNTIME))
126 for disk in $(echo $DISKS | tr "," " "); do
127 for mode in $(echo $MODES | tr "," " "); do
128 gen_seq_suite "$mode"
138 for disk in $(echo $DISKS | tr "," " "); do
139 cat >> $OUTFILE << EOF
140 [$TYPE-$disk-$BLK_SIZE-para]
144 if [ "$D" = 0 ]; then
145 echo "stonewall" >> $OUTFILE
149 cat >> $OUTFILE << EOF
152 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results
153 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results
157 ETA=$(($ETA + $RUNTIME))
162 for mode in $(echo $MODES | tr "," " "); do
163 gen_para_suite "$mode"
183 while getopts "hacpsd:b:r:m:x:" opt; do
196 if [ "$SEQ" = "-1" ]; then
202 echo "$PREFIX" | grep -q "/"
203 if [ "$?" -eq 0 ]; then
205 # No need to keep the prefix for the log files
206 # we do have a directory for that
209 # We need to keep the prefix for the log files
210 PREFIX_FILENAME=$PREFIX
217 if [ "$SEQ" = "-1" ]; then
231 echo "Invalid option: -$OPTARG" >&2
236 if [ "$SEQ" = "-1" ]; then
240 SHORT_HOSTNAME=$(hostname -s)
243 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$DISKS.fio
247 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$DISKS.fio
250 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$DISKS.fio
254 if [ -z "$DISKS" ]; then
255 echo "Missing DISKS !"
256 echo "Please read the help !"
265 CAUSE="You are reading data before writing them "
267 # If no write occurs, let's show a different message
268 echo $MODES | grep -q "write"
269 if [ "$?" -ne 0 ]; then
270 CAUSE="You are reading data while never wrote them before"
273 for mode in $(echo $MODES | tr "," " "); do
274 echo $mode | grep -q write
275 if [ "$?" -eq 0 ]; then
278 echo $mode | grep -q "read"
279 if [ "$?" -eq 0 ]; then
280 if [ "$FOUND_WRITE" = "NO" ]; then
281 echo "###############################################################"
282 echo "# Warning : $CAUSE#"
283 echo "# On some storage devices, this could lead to invalid results #"
285 echo "# Press Ctrl-C to adjust pattern order if you have doubts #"
286 echo "# Or Wait 5 seconds before the file will be created #"
287 echo "###############################################################"
289 # No need to try showing the message more than one time
302 echo "Generating $OUTFILE"
303 cp -f $TEMPLATE $OUTFILE
306 for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do
309 ETA_H=$(($ETA / 3600))
310 ETA_M=$((($ETA - ($ETA_H*3600)) / 60))
311 if [ "$ETA" = "0" ]; then
312 echo "Cannot estimate ETA as RUNTIME=0"
314 echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes"