X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=tools%2Fgenfio;h=4d32d13084707103e5bd32beac10eb1156378e3e;hp=3f9ab283840a54bef1c1ae2ef70bf2e1ccc7d759;hb=c60587f663d2b800bdae254e86da84b4cfd070e8;hpb=fdc0f3b646e417497849d4398029f780b0e5262f diff --git a/tools/genfio b/tools/genfio index 3f9ab283..4d32d130 100755 --- a/tools/genfio +++ b/tools/genfio @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2013 eNovance SAS # Author: Erwan Velu @@ -25,6 +25,7 @@ SEQ=-1 TEMPLATE=/tmp/template.fio OUTFILE= DISKS= +PRINTABLE_DISKS= RUNTIME=300 ETA=0 MODES="write,randwrite,read,randread" @@ -50,25 +51,26 @@ show_help() { one test after anoter but all disks at the same time Enabled by default -D iodepth : Run with the specified iodepth - Default is 32 + Default is $IODEPTH -d disk1[,disk2,disk3,..] : Run the tests on the selected disks Separated each disk with a comma - Disk name shall be "sdxx", /dev/ shall NOT be used here -r seconds : Time in seconds per benchmark 0 means till the end of the device - Default is 300 seconds + Default is $RUNTIME seconds -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...) Separated each blocksize with a comma - Default is 4k + Default is $BLOCK_SIZE -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite - Default is "write,randwrite,read,randread" + Default is "$MODES" -x prefix : Add a prefix to the fio filename Useful to let a context associated with the file If the prefix features a / (slash), prefix will be considered as a directory +-A cmd_to_run : System command to run after each job (exec_postrun in fio) +-B cmd_to_run : System command to run before each job (exec_prerun in fio) Example: -$PROG -d sdb,sdc,sdd,sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/ +$PROG -d /dev/sdb,/dev/sdc,/dev/sdd,/dev/sde -a -b 4k,128k,1m -r 100 -a -x dellr720-day2/ Will generate an fio file that will run - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests @@ -90,24 +92,33 @@ EOF } finish_template() { -cat >>$TEMPLATE <> $TEMPLATE if [ "$RUNTIME" != "0" ]; then -cat >>$TEMPLATE << EOF -runtime=$RUNTIME -time_based -EOF + echo "runtime=$RUNTIME" >> $TEMPLATE + echo "time_based" >> $TEMPLATE fi if [ "$CACHED_IO" = "FALSE" ]; then -cat >>$TEMPLATE << EOF -direct=1 -EOF + echo "direct=1" >> $TEMPLATE fi } + +diskname_to_printable() { +COUNT=0 +for disk in $(echo $@ | tr "," " "); do + R=$(basename $disk | sed 's|/|_|g') + COUNT=$(($COUNT + 1)) + if [ $COUNT -eq 1 ]; then + P="$R" + else + P="$P,$R" + fi +done +echo $P +} + gen_template() { cat >$TEMPLATE << EOF [global] @@ -119,14 +130,16 @@ EOF gen_seq_suite() { TYPE=$1 +disk=$2 +PRINTABLE_DISK=$(diskname_to_printable $disk) cat >> $OUTFILE << EOF -[$TYPE-$disk-$BLK_SIZE-seq] +[$TYPE-$PRINTABLE_DISK-$BLK_SIZE-seq] stonewall bs=$BLK_SIZE -filename=/dev/$disk +filename=$disk rw=$TYPE -write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results -write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results +write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results +write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-seq.results EOF ETA=$(($ETA + $RUNTIME)) } @@ -134,7 +147,7 @@ ETA=$(($ETA + $RUNTIME)) gen_seq_fio() { for disk in $(echo $DISKS | tr "," " "); do for mode in $(echo $MODES | tr "," " "); do - gen_seq_suite "$mode" + gen_seq_suite "$mode" "$disk" done done } @@ -145,8 +158,9 @@ TYPE=$1 NEED_WALL=$2 D=0 for disk in $(echo $DISKS | tr "," " "); do + PRINTABLE_DISK=$(diskname_to_printable $disk) cat >> $OUTFILE << EOF -[$TYPE-$disk-$BLK_SIZE-para] +[$TYPE-$PRINTABLE_DISK-$BLK_SIZE-para] bs=$BLK_SIZE EOF @@ -156,10 +170,10 @@ if [ "$D" = 0 ]; then fi cat >> $OUTFILE << EOF -filename=/dev/$disk +filename=$disk rw=$TYPE -write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results -write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results +write_bw_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results +write_iops_log=${PREFIX_FILENAME}$SHORT_HOSTNAME-$BLK_SIZE-$PRINTABLE_DISK-$TYPE-para.results EOF done @@ -189,7 +203,7 @@ esac } parse_cmdline() { -while getopts "hacpsd:b:r:m:x:D:" opt; do +while getopts "hacpsd:b:r:m:x:D:A:B:" opt; do case $opt in h) show_help @@ -232,6 +246,7 @@ while getopts "hacpsd:b:r:m:x:D:" opt; do ;; d) DISKS=$OPTARG + PRINTABLE_DISKS=$(diskname_to_printable "$DISKS") ;; D) IODEPTH=$OPTARG @@ -239,6 +254,12 @@ while getopts "hacpsd:b:r:m:x:D:" opt; do a) SEQ=2 ;; + B) + echo "exec_prerun=$OPTARG" >> $TEMPLATE + ;; + A) + echo "exec_postrun=$OPTARG" >> $TEMPLATE + ;; \?) echo "Invalid option: -$OPTARG" >&2 ;; @@ -252,14 +273,14 @@ fi SHORT_HOSTNAME=$(hostname -s) case $SEQ in 2) - OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$DISKS.fio + OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$PRINTABLE_DISKS.fio ;; 1) - OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$DISKS.fio + OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$PRINTABLE_DISKS.fio ;; 0) - OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$DISKS.fio + OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$PRINTABLE_DISKS.fio ;; esac @@ -308,7 +329,7 @@ done ########## MAIN gen_template -parse_cmdline $@ +parse_cmdline "$@" finish_template check_mode_order