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
31 MODES="write,randwrite,read,randread"
40 echo "usage of $PROG:"
42 -h : Show this help & exit
43 -c : Enable cached-based IOs
45 -a : Run sequential test then parallel one
47 -s : Run sequential test (default value)
48 one test after another then one disk after another
50 -p : Run parallel test
51 one test after anoter but all disks at the same time
53 -D iodepth : Run with the specified iodepth
55 -d disk1[,disk2,disk3,..] : Run the tests on the selected disks
56 Separated each disk with a comma
57 -z filesize : Specify the working file size, if you are passing filepaths to -d
59 -r seconds : Time in seconds per benchmark
60 0 means till the end of the device
61 Default is $RUNTIME seconds
62 -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...)
63 Separated each blocksize with a comma
64 Default is $BLOCK_SIZE
65 -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite
67 -x prefix : Add a prefix to the fio filename
68 Useful to let a context associated with the file
69 If the prefix features a / (slash), prefix will be considered as a directory
70 -A cmd_to_run : System command to run after each job (exec_postrun in fio)
71 -B cmd_to_run : System command to run before each job (exec_prerun in fio)
75 $PROG -d /dev/sdb,/dev/sdc,/dev/sdd,/dev/sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/
77 Will generate an fio file that will run
78 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
79 ETA ~ 4 tests * 4 disks * 100 seconds
80 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
81 ETA ~ 4 tests * 4 disks * 100 seconds
82 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
83 ETA ~ 4 tests * 4 disks * 100 seconds
84 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
85 ETA ~ 4 tests * 100 seconds
86 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
87 ETA ~ 4 tests * 100 seconds
88 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
89 ETA ~ 4 tests * 100 seconds
91 Generating dellr720-day2/localhost-4k,128k,1m-all-write,randwrite,read,randread-sdb,sdc,sdd,sde.fio
92 Estimated Time = 6000 seconds : 1 hour 40 minutes
97 echo "iodepth=$IODEPTH" >> $TEMPLATE
99 if [ "$RUNTIME" != "0" ]; then
100 echo "runtime=$RUNTIME" >> $TEMPLATE
101 echo "time_based" >> $TEMPLATE
104 if [ "$CACHED_IO" = "FALSE" ]; then
105 echo "direct=1" >> $TEMPLATE
110 diskname_to_printable() {
112 for disk in $(echo $@ | tr "," " "); do
113 R=$(basename $disk | sed 's|/|_|g')
114 COUNT=$(($COUNT + 1))
115 if [ $COUNT -eq 1 ]; then
125 cat >$TEMPLATE << EOF
136 PRINTABLE_DISK=$(diskname_to_printable $disk)
137 cat >> $OUTFILE << EOF
138 [$TYPE-$PRINTABLE_DISK-$BLK_SIZE-seq]
143 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results
144 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results
146 ETA=$(($ETA + $RUNTIME))
150 for disk in $(echo $DISKS | tr "," " "); do
151 for mode in $(echo $MODES | tr "," " "); do
152 gen_seq_suite "$mode" "$disk"
162 for disk in $(echo $DISKS | tr "," " "); do
163 PRINTABLE_DISK=$(diskname_to_printable $disk)
164 cat >> $OUTFILE << EOF
165 [$TYPE-$PRINTABLE_DISK-$BLK_SIZE-para]
169 if [ "$D" = 0 ]; then
170 echo "stonewall" >> $OUTFILE
174 cat >> $OUTFILE << EOF
177 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results
178 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results
182 ETA=$(($ETA + $RUNTIME))
187 for mode in $(echo $MODES | tr "," " "); do
188 gen_para_suite "$mode"
208 while getopts "hacpsd:b:r:m:x:z:D:A:B:" opt; do
221 if [ "$SEQ" = "-1" ]; then
227 echo "$PREFIX" | grep -q "/"
228 if [ "$?" -eq 0 ]; then
230 # No need to keep the prefix for the log files
231 # we do have a directory for that
234 # We need to keep the prefix for the log files
235 PREFIX_FILENAME=$PREFIX
242 if [ "$SEQ" = "-1" ]; then
251 PRINTABLE_DISKS=$(diskname_to_printable "$DISKS")
260 echo "exec_prerun=$OPTARG" >> $TEMPLATE
263 echo "exec_postrun=$OPTARG" >> $TEMPLATE
267 echo "size=$FSIZE" >> $TEMPLATE
270 echo "Invalid option: -$OPTARG" >&2
275 if [ "$SEQ" = "-1" ]; then
279 SHORT_HOSTNAME=$(hostname -s)
282 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$PRINTABLE_DISKS.fio
286 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$PRINTABLE_DISKS.fio
289 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$PRINTABLE_DISKS.fio
293 if [ -z "$DISKS" ]; then
294 echo "Missing DISKS !"
295 echo "Please read the help !"
304 CAUSE="You are reading data before writing them "
306 # If no write occurs, let's show a different message
307 echo $MODES | grep -q "write"
308 if [ "$?" -ne 0 ]; then
309 CAUSE="You are reading data while never wrote them before"
312 for mode in $(echo $MODES | tr "," " "); do
313 echo $mode | grep -q write
314 if [ "$?" -eq 0 ]; then
317 echo $mode | grep -q "read"
318 if [ "$?" -eq 0 ]; then
319 if [ "$FOUND_WRITE" = "NO" ]; then
320 echo "###############################################################"
321 echo "# Warning : $CAUSE#"
322 echo "# On some storage devices, this could lead to invalid results #"
324 echo "# Press Ctrl-C to adjust pattern order if you have doubts #"
325 echo "# Or Wait 5 seconds before the file will be created #"
326 echo "###############################################################"
328 # No need to try showing the message more than one time
342 echo "Generating $OUTFILE"
343 cp -f $TEMPLATE $OUTFILE
346 for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do
349 ETA_H=$(($ETA / 3600))
350 ETA_M=$((($ETA - ($ETA_H*3600)) / 60))
351 if [ "$ETA" = "0" ]; then
352 echo "Cannot estimate ETA as RUNTIME=0"
354 echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes"