This file is indexed.

/usr/bin/genfio is in fio 2.1.3-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#!/bin/bash
#
#  Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#  Author: Erwan Velu  <erwan@enovance.com>
#
#  The license below covers all files distributed with fio unless otherwise
#  noted in the file itself.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License version 2 as
#  published by the Free Software Foundation.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

BLK_SIZE=
BLOCK_SIZE=4k
SEQ=-1
TEMPLATE=/tmp/template.fio
OUTFILE=
DISKS=
PRINTABLE_DISKS=
RUNTIME=300
ETA=0
MODES="write,randwrite,read,randread"
SHORT_HOSTNAME=
CACHED_IO="FALSE"
PREFIX=""
PREFIX_FILENAME=""
IODEPTH=1

show_help() {
	PROG=$(basename $0)
	echo "usage of $PROG:"
	cat << EOF
-h				: Show this help & exit
-c				: Enable cached-based IOs
					Disabled by default
-a				: Run sequential test then parallel one
					Disabled by default
-s				: Run sequential test (default value)
					one test after another then one disk after another
					Disabled by default
-p				: Run parallel test
					one test after anoter but all disks at the same time
					Enabled by default
-D iodepth			: Run with the specified iodepth
					Default is $IODEPTH
-d disk1[,disk2,disk3,..]	: Run the tests on the selected disks
					Separated each disk with a comma
-r seconds			: Time in seconds per benchmark
					0 means till the end of the device
					Default is $RUNTIME seconds
-b blocksize[,blocksize1, ...]  : The blocksizes to test under fio format (4k, 1m, ...)
					Separated each blocksize with a comma
					Default is $BLOCK_SIZE
-m mode1,[mode2,mode3, ...]     : Define the fio IO profile to use like read, write, randread, randwrite
					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 /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
			ETA ~ 4 tests * 4 disks * 100 seconds
		- a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
			ETA ~ 4 tests * 4 disks * 100 seconds
		- a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
			ETA ~ 4 tests * 4 disks * 100 seconds
		- a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with write,randwrite,read,randread tests
			ETA ~ 4 tests * 100 seconds
		- a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with write,randwrite,read,randread tests
			ETA ~ 4 tests * 100 seconds
		- a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with write,randwrite,read,randread tests
			ETA ~ 4 tests * 100 seconds

Generating dellr720-day2/localhost-4k,128k,1m-all-write,randwrite,read,randread-sdb,sdc,sdd,sde.fio
Estimated Time = 6000 seconds : 1 hour 40 minutes
EOF
}

finish_template() {
echo "iodepth=$IODEPTH" >> $TEMPLATE

if [ "$RUNTIME" != "0" ]; then
	echo "runtime=$RUNTIME" >> $TEMPLATE
	echo "time_based" >> $TEMPLATE
fi

if [ "$CACHED_IO" = "FALSE" ]; then
	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]
ioengine=libaio
invalidate=1
ramp_time=5
EOF
}

gen_seq_suite() {
TYPE=$1
disk=$2
PRINTABLE_DISK=$(diskname_to_printable $disk)
cat >> $OUTFILE << EOF
[$TYPE-$PRINTABLE_DISK-$BLK_SIZE-seq]
stonewall
bs=$BLK_SIZE
filename=$disk
rw=$TYPE
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))
}

gen_seq_fio() {
for disk in $(echo $DISKS | tr "," " "); do
	for mode in $(echo $MODES | tr "," " "); do
		gen_seq_suite "$mode" "$disk"
	done
done
}


gen_para_suite() {
TYPE=$1
NEED_WALL=$2
D=0
for disk in $(echo $DISKS | tr "," " "); do
    PRINTABLE_DISK=$(diskname_to_printable $disk)
    cat >> $OUTFILE << EOF
[$TYPE-$PRINTABLE_DISK-$BLK_SIZE-para]
bs=$BLK_SIZE
EOF

if [ "$D" = 0 ]; then
    echo "stonewall" >> $OUTFILE
    D=1
fi

cat >> $OUTFILE << EOF
filename=$disk
rw=$TYPE
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

ETA=$(($ETA + $RUNTIME))
echo >> $OUTFILE
}

gen_para_fio() {
for mode in $(echo $MODES | tr "," " "); do
	gen_para_suite "$mode"
done
}

gen_fio() {
case $SEQ in
	2)
		gen_seq_fio
		gen_para_fio
	;;
	1)
		gen_seq_fio
	;;
	0)
		gen_para_fio
	;;
esac
}

parse_cmdline() {
while getopts "hacpsd:b:r:m:x:D:A:B:" opt; do
  case $opt in
    h)
	show_help
	exit 0
	;;
    b)
	BLOCK_SIZE=$OPTARG
	;;
    c)
	CACHED_IO="TRUE"
	;;
    s)
	if [ "$SEQ" = "-1" ]; then
		SEQ=1
	fi
      ;;
    x)
	PREFIX=$OPTARG
	echo "$PREFIX" | grep -q "/"
	if [ "$?" -eq 0 ]; then
		mkdir -p $PREFIX
		# No need to keep the prefix for the log files
		# we do have a directory for that
		PREFIX_FILENAME=""
	else
		# We need to keep the prefix for the log files
		PREFIX_FILENAME=$PREFIX
	fi
	;;
    r)
	RUNTIME=$OPTARG
      ;;
    p)
	if [ "$SEQ" = "-1" ]; then
		SEQ=0
	fi
      ;;
    m)
        MODES=$OPTARG;
      ;;
    d)
 	DISKS=$OPTARG
	PRINTABLE_DISKS=$(diskname_to_printable "$DISKS")
      ;;
    D)
	IODEPTH=$OPTARG
      ;;
    a)
	SEQ=2
      ;;
    B)
	echo "exec_prerun=$OPTARG" >> $TEMPLATE
      ;;
    A)
	echo "exec_postrun=$OPTARG" >> $TEMPLATE
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      ;;
  esac
done

if [ "$SEQ" = "-1" ]; then
	SEQ=0
fi

SHORT_HOSTNAME=$(hostname -s)
case $SEQ in
	2)
		OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$PRINTABLE_DISKS.fio
	;;

	1)
		OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$PRINTABLE_DISKS.fio
	;;
	0)
		OUTFILE=${PREFIX}$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$PRINTABLE_DISKS.fio
	;;
esac

if [ -z "$DISKS" ]; then
	echo "Missing DISKS !"
	echo "Please read the help !"
	show_help
	exit 1
fi

}

check_mode_order() {
FOUND_WRITE="NO"
CAUSE="You are reading data before writing them          "

# If no write occurs, let's show a different message
echo $MODES | grep -q "write"
if [ "$?" -ne 0 ]; then
	CAUSE="You are reading data while never wrote them before"
fi

for mode in $(echo $MODES | tr "," " "); do
	echo $mode | grep -q write
	if [ "$?" -eq 0 ]; then
		FOUND_WRITE="YES"
	fi
	echo $mode | grep -q "read"
	if [ "$?" -eq 0 ]; then
		if [ "$FOUND_WRITE" = "NO" ]; then
			echo "###############################################################"
			echo "# Warning : $CAUSE#"
			echo "# On some storage devices, this could lead to invalid results #"
			echo "#                                                             #"
			echo "# Press Ctrl-C to adjust pattern order if you have doubts     #"
			echo "# Or Wait 5 seconds before the file will be created           #"
			echo "###############################################################"
			sleep 5
			# No need to try showing the message more than one time
			return
		fi
	fi
done
}


########## MAIN
gen_template
parse_cmdline "$@"
finish_template
check_mode_order

echo "Generating $OUTFILE"
cp -f $TEMPLATE $OUTFILE
echo >> $OUTFILE

for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do
	gen_fio
done
ETA_H=$(($ETA / 3600))
ETA_M=$((($ETA - ($ETA_H*3600)) / 60))
if [ "$ETA" = "0" ]; then
	echo "Cannot estimate ETA as RUNTIME=0"
else
	echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes"
fi