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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 TEMPLATE=$(mktemp "${TMPDIR:-${TEMP:-/tmp}}/template.fio.XXXXXX") || exit $?
26 trap 'rm -f "$TEMPLATE"' EXIT
32 MODES="write,randwrite,read,randread"
41 echo "usage of $PROG:"
43 -h : Show this help & exit
44 -c : Enable cached-based IOs
46 -a : Run sequential test then parallel one
48 -s : Run sequential test (default value)
49 one test after another then one disk after another
51 -p : Run parallel test
52 one test after another but all disks at the same time
54 -D iodepth : Run with the specified iodepth
56 -d disk1[,disk2,disk3,..] : Run the tests on the selected disks
57 Separated each disk with a comma
58 -z filesize : Specify the working file size, if you are passing filepaths to -d
60 -r seconds : Time in seconds per benchmark
61 0 means till the end of the device
62 Default is $RUNTIME seconds
63 -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...)
64 Separated each blocksize with a comma
65 Default is $BLOCK_SIZE
66 -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite
68 -x prefix : Add a prefix to the fio filename
69 Useful to let a context associated with the file
70 If the prefix features a / (slash), prefix will be considered as a directory
71 -A cmd_to_run : System command to run after each job (exec_postrun in fio)
72 -B cmd_to_run : System command to run before each job (exec_prerun in fio)
76 $PROG -d /dev/sdb,/dev/sdc,/dev/sdd,/dev/sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/
78 Will generate an fio file that will run
79 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
80 ETA ~ 4 tests * 4 disks * 100 seconds
81 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
82 ETA ~ 4 tests * 4 disks * 100 seconds
83 - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
84 ETA ~ 4 tests * 4 disks * 100 seconds
85 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
86 ETA ~ 4 tests * 100 seconds
87 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
88 ETA ~ 4 tests * 100 seconds
89 - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
90 ETA ~ 4 tests * 100 seconds
92 Generating dellr720-day2/localhost-4k,128k,1m-all-write,randwrite,read,randread-sdb,sdc,sdd,sde.fio
93 Estimated Time = 6000 seconds : 1 hour 40 minutes
98 echo "iodepth=$IODEPTH" >> $TEMPLATE
100 if [ "$RUNTIME" != "0" ]; then
101 echo "runtime=$RUNTIME" >> $TEMPLATE
102 echo "time_based" >> $TEMPLATE
105 if [ "$CACHED_IO" = "FALSE" ]; then
106 echo "direct=1" >> $TEMPLATE
111 diskname_to_printable() {
113 for disk in $(echo $@ | tr "," " "); do
114 R=$(basename $disk | sed 's|/|_|g')
115 COUNT=$(($COUNT + 1))
116 if [ $COUNT -eq 1 ]; then
126 cat >$TEMPLATE << EOF
137 PRINTABLE_DISK=$(diskname_to_printable $disk)
138 cat >> $OUTFILE << EOF
139 [$TYPE-$PRINTABLE_DISK-$BLK_SIZE-seq]
144 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results
145 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results
147 ETA=$(($ETA + $RUNTIME))
151 for disk in $(echo $DISKS | tr "," " "); do
152 for mode in $(echo $MODES | tr "," " "); do
153 gen_seq_suite "$mode" "$disk"
163 for disk in $(echo $DISKS | tr "," " "); do
164 PRINTABLE_DISK=$(diskname_to_printable $disk)
165 cat >> $OUTFILE << EOF
166 [$TYPE-$PRINTABLE_DISK-$BLK_SIZE-para]
170 if [ "$D" = 0 ]; then
171 echo "stonewall" >> $OUTFILE
175 cat >> $OUTFILE << EOF
178 write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results
179 write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results
183 ETA=$(($ETA + $RUNTIME))
188 for mode in $(echo $MODES | tr "," " "); do
189 gen_para_suite "$mode"
209 while getopts "hacpsd:b:r:m:x:z:D:A:B:" opt; do
222 if [ "$SEQ" = "-1" ]; then
228 echo "$PREFIX" | grep -q "/"
229 if [ "$?" -eq 0 ]; then
231 # No need to keep the prefix for the log files
232 # we do have a directory for that
235 # We need to keep the prefix for the log files
236 PREFIX_FILENAME=$PREFIX
243 if [ "$SEQ" = "-1" ]; then
252 PRINTABLE_DISKS=$(diskname_to_printable "$DISKS")
261 echo "exec_prerun=$OPTARG" >> $TEMPLATE
264 echo "exec_postrun=$OPTARG" >> $TEMPLATE
268 echo "size=$FSIZE" >> $TEMPLATE
271 echo "Invalid option: -$OPTARG" >&2
276 if [ "$SEQ" = "-1" ]; then
280 SHORT_HOSTNAME=$(hostname -s)
283 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$PRINTABLE_DISKS.fio
287 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$PRINTABLE_DISKS.fio
290 OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$PRINTABLE_DISKS.fio
294 if [ -z "$DISKS" ]; then
295 echo "Missing DISKS !"
296 echo "Please read the help !"
305 CAUSE="You are reading data before writing them "
307 # If no write occurs, let's show a different message
308 echo $MODES | grep -q "write"
309 if [ "$?" -ne 0 ]; then
310 CAUSE="You are reading data while never wrote them before"
313 for mode in $(echo $MODES | tr "," " "); do
314 echo $mode | grep -q write
315 if [ "$?" -eq 0 ]; then
318 echo $mode | grep -q "read"
319 if [ "$?" -eq 0 ]; then
320 if [ "$FOUND_WRITE" = "NO" ]; then
321 echo "###############################################################"
322 echo "# Warning : $CAUSE#"
323 echo "# On some storage devices, this could lead to invalid results #"
325 echo "# Press Ctrl-C to adjust pattern order if you have doubts #"
326 echo "# Or Wait 5 seconds before the file will be created #"
327 echo "###############################################################"
329 # No need to try showing the message more than one time
343 echo "Generating $OUTFILE"
344 cp -f $TEMPLATE $OUTFILE
347 for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do
350 ETA_H=$(($ETA / 3600))
351 ETA_M=$((($ETA - ($ETA_H*3600)) / 60))
352 if [ "$ETA" = "0" ]; then
353 echo "Cannot estimate ETA as RUNTIME=0"
355 echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes"