blob: 2129882f5309ccdaea91fe737e8f01132ed2b3e1 [file] [log] [blame]
Jens Axboe906c8d72006-06-13 09:37:56 +02001/*
Jens Axboecb2c86f2006-10-26 13:48:34 +02002 * This file contains job initialization and setup functions.
Jens Axboe906c8d72006-06-13 09:37:56 +02003 */
Jens Axboeebac4652005-12-08 15:25:21 +01004#include <stdio.h>
5#include <stdlib.h>
6#include <unistd.h>
7#include <fcntl.h>
8#include <ctype.h>
9#include <string.h>
10#include <errno.h>
Jens Axboeb4692822006-10-27 13:43:22 +020011#include <getopt.h>
12#include <assert.h>
Jens Axboeebac4652005-12-08 15:25:21 +010013#include <sys/ipc.h>
14#include <sys/shm.h>
15#include <sys/types.h>
16#include <sys/stat.h>
17
18#include "fio.h"
Jens Axboecb2c86f2006-10-26 13:48:34 +020019#include "parse.h"
Jens Axboeebac4652005-12-08 15:25:21 +010020
Jens Axboeee738492007-01-10 11:23:16 +010021#define FIO_RANDSEED (0xb1899bedUL)
Jens Axboeebac4652005-12-08 15:25:21 +010022
Jens Axboee1f36502006-10-27 10:54:08 +020023#define td_var_offset(var) ((size_t) &((struct thread_data *)0)->var)
24
Jens Axboeb4692822006-10-27 13:43:22 +020025static int str_mem_cb(void *, const char *);
Jens Axboee1f36502006-10-27 10:54:08 +020026static int str_lockmem_cb(void *, unsigned long *);
Jens Axboe34cfcda2006-11-03 14:00:45 +010027#ifdef FIO_HAVE_IOPRIO
Jens Axboee1f36502006-10-27 10:54:08 +020028static int str_prio_cb(void *, unsigned int *);
29static int str_prioclass_cb(void *, unsigned int *);
Jens Axboe34cfcda2006-11-03 14:00:45 +010030#endif
Jens Axboee1f36502006-10-27 10:54:08 +020031static int str_exitall_cb(void);
32static int str_cpumask_cb(void *, unsigned int *);
33
Jens Axboeee738492007-01-10 11:23:16 +010034#define __stringify_1(x) #x
35#define __stringify(x) __stringify_1(x)
36
Jens Axboee1f36502006-10-27 10:54:08 +020037/*
38 * Map of job/command line options
39 */
40static struct fio_option options[] = {
41 {
Jens Axboe61697c32007-02-05 15:04:46 +010042 .name = "description",
43 .type = FIO_OPT_STR_STORE,
44 .off1 = td_var_offset(description),
45 .help = "Text job description",
46 },
47 {
Jens Axboee1f36502006-10-27 10:54:08 +020048 .name = "name",
49 .type = FIO_OPT_STR_STORE,
50 .off1 = td_var_offset(name),
Jens Axboefd28ca42007-01-09 21:20:13 +010051 .help = "Name of this job",
Jens Axboee1f36502006-10-27 10:54:08 +020052 },
53 {
54 .name = "directory",
55 .type = FIO_OPT_STR_STORE,
56 .off1 = td_var_offset(directory),
Jens Axboefd28ca42007-01-09 21:20:13 +010057 .help = "Directory to store files in",
Jens Axboee1f36502006-10-27 10:54:08 +020058 },
59 {
60 .name = "filename",
61 .type = FIO_OPT_STR_STORE,
62 .off1 = td_var_offset(filename),
Jens Axboefd28ca42007-01-09 21:20:13 +010063 .help = "Force the use of a specific file",
Jens Axboee1f36502006-10-27 10:54:08 +020064 },
65 {
66 .name = "rw",
67 .type = FIO_OPT_STR,
Jens Axboeb1ec1da2007-02-23 10:29:16 +010068 .off1 = td_var_offset(td_ddir),
Jens Axboe15f79182007-01-10 12:26:18 +010069 .help = "IO direction",
Jens Axboeee738492007-01-10 11:23:16 +010070 .def = "read",
Jens Axboeb1ec1da2007-02-23 10:29:16 +010071 .posval = {
72 { .ival = "read", .oval = TD_DDIR_READ },
73 { .ival = "write", .oval = TD_DDIR_WRITE },
74 { .ival = "randread", .oval = TD_DDIR_RANDREAD },
75 { .ival = "randwrite", .oval = TD_DDIR_RANDWRITE },
76 { .ival = "rw", .oval = TD_DDIR_RW },
77 { .ival = "randrw", .oval = TD_DDIR_RANDRW },
78 },
Jens Axboee1f36502006-10-27 10:54:08 +020079 },
80 {
81 .name = "ioengine",
Jens Axboe09629a92007-03-09 09:00:06 +010082 .type = FIO_OPT_STR_STORE,
83 .off1 = td_var_offset(ioengine),
Jens Axboe15f79182007-01-10 12:26:18 +010084 .help = "IO engine to use",
Jens Axboeee738492007-01-10 11:23:16 +010085 .def = "sync",
Jens Axboeb1ec1da2007-02-23 10:29:16 +010086 .posval = {
Jens Axboe10cad1a2007-02-23 11:23:03 +010087 { .ival = "sync", },
88#ifdef FIO_HAVE_LIBAIO
89 { .ival = "libaio", },
90#endif
91#ifdef FIO_HAVE_POSIXAIO
92 { .ival = "posixaio", },
93#endif
94 { .ival = "mmap", },
95#ifdef FIO_HAVE_SPLICE
96 { .ival = "splice", },
97#endif
98#ifdef FIO_HAVE_SGIO
99 { .ival = "sg", },
100#endif
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100101 { .ival = "null", }, { .ival = "net", },
Jens Axboe10cad1a2007-02-23 11:23:03 +0100102#ifdef FIO_HAVE_SYSLET
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100103 { .ival = "syslet-rw", },
Jens Axboe10cad1a2007-02-23 11:23:03 +0100104#endif
Jens Axboeba0fbe12007-03-09 14:34:23 +0100105 { .ival = "cpuio", },
Joel Becker7b395ca2007-02-28 11:10:58 +0100106 { .ival = "external", },
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100107 },
Jens Axboee1f36502006-10-27 10:54:08 +0200108 },
109 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100110 .name = "iodepth",
111 .type = FIO_OPT_INT,
112 .off1 = td_var_offset(iodepth),
113 .help = "Amount of IO buffers to keep in flight",
114 .def = "1",
115 },
116 {
Jens Axboecb5ab512007-02-26 12:57:09 +0100117 .name = "iodepth_batch",
118 .type = FIO_OPT_INT,
119 .off1 = td_var_offset(iodepth_batch),
120 .help = "Number of IO to submit in one go",
121 },
122 {
Jens Axboee916b392007-02-20 14:37:26 +0100123 .name = "iodepth_low",
124 .type = FIO_OPT_INT,
125 .off1 = td_var_offset(iodepth_low),
126 .help = "Low water mark for queuing depth",
127 },
128 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100129 .name = "size",
130 .type = FIO_OPT_STR_VAL,
131 .off1 = td_var_offset(total_file_size),
132 .help = "Size of device or file",
133 },
134 {
135 .name = "bs",
136 .type = FIO_OPT_STR_VAL_INT,
137 .off1 = td_var_offset(bs[DDIR_READ]),
138 .off2 = td_var_offset(bs[DDIR_WRITE]),
139 .help = "Block size unit",
140 .def = "4k",
141 },
142 {
143 .name = "bsrange",
144 .type = FIO_OPT_RANGE,
145 .off1 = td_var_offset(min_bs[DDIR_READ]),
146 .off2 = td_var_offset(max_bs[DDIR_READ]),
147 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
148 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
149 .help = "Set block size range (in more detail than bs)",
150 },
151 {
152 .name = "bs_unaligned",
153 .type = FIO_OPT_STR_SET,
154 .off1 = td_var_offset(bs_unaligned),
155 .help = "Don't sector align IO buffer sizes",
156 },
157 {
158 .name = "offset",
159 .type = FIO_OPT_STR_VAL,
160 .off1 = td_var_offset(start_offset),
161 .help = "Start IO from this offset",
162 .def = "0",
163 },
164 {
165 .name = "randrepeat",
166 .type = FIO_OPT_BOOL,
167 .off1 = td_var_offset(rand_repeatable),
168 .help = "Use repeatable random IO pattern",
169 .def = "1",
170 },
171 {
172 .name = "norandommap",
173 .type = FIO_OPT_STR_SET,
174 .off1 = td_var_offset(norandommap),
175 .help = "Accept potential duplicate random blocks",
176 },
177 {
178 .name = "nrfiles",
179 .type = FIO_OPT_INT,
180 .off1 = td_var_offset(nr_files),
181 .help = "Split job workload between this number of files",
182 .def = "1",
183 },
184 {
Jens Axboeb5af8292007-03-08 12:43:13 +0100185 .name = "openfiles",
186 .type = FIO_OPT_INT,
187 .off1 = td_var_offset(open_files),
188 .help = "Number of files to keep open at the same time",
189 },
190 {
Jens Axboe0aabe162007-02-23 08:45:55 +0100191 .name = "file_service_type",
192 .type = FIO_OPT_STR,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100193 .off1 = td_var_offset(file_service_type),
Jens Axboe0aabe162007-02-23 08:45:55 +0100194 .help = "How to select which file to service next",
195 .def = "roundrobin",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100196 .posval = {
197 { .ival = "random", .oval = FIO_FSERVICE_RANDOM },
198 { .ival = "roundrobin", .oval = FIO_FSERVICE_RR },
199 },
Jens Axboe0aabe162007-02-23 08:45:55 +0100200 },
201 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100202 .name = "fsync",
203 .type = FIO_OPT_INT,
204 .off1 = td_var_offset(fsync_blocks),
205 .help = "Issue fsync for writes every given number of blocks",
206 .def = "0",
207 },
208 {
209 .name = "direct",
210 .type = FIO_OPT_BOOL,
211 .off1 = td_var_offset(odirect),
Jens Axboe76a43db2007-01-11 13:24:44 +0100212 .help = "Use O_DIRECT IO (negates buffered)",
213 .def = "0",
214 },
215 {
216 .name = "buffered",
217 .type = FIO_OPT_BOOL,
218 .off1 = td_var_offset(odirect),
219 .neg = 1,
220 .help = "Use buffered IO (negates direct)",
Jens Axboe03b74b32007-01-11 11:04:31 +0100221 .def = "1",
222 },
223 {
224 .name = "overwrite",
225 .type = FIO_OPT_BOOL,
226 .off1 = td_var_offset(overwrite),
227 .help = "When writing, set whether to overwrite current data",
228 .def = "0",
229 },
230 {
231 .name = "loops",
232 .type = FIO_OPT_INT,
233 .off1 = td_var_offset(loops),
234 .help = "Number of times to run the job",
235 .def = "1",
236 },
237 {
238 .name = "numjobs",
239 .type = FIO_OPT_INT,
240 .off1 = td_var_offset(numjobs),
241 .help = "Duplicate this job this many times",
242 .def = "1",
243 },
244 {
245 .name = "startdelay",
246 .type = FIO_OPT_INT,
247 .off1 = td_var_offset(start_delay),
248 .help = "Only start job when this period has passed",
249 .def = "0",
250 },
251 {
252 .name = "runtime",
253 .alias = "timeout",
254 .type = FIO_OPT_STR_VAL_TIME,
255 .off1 = td_var_offset(timeout),
256 .help = "Stop workload when this amount of time has passed",
257 .def = "0",
258 },
259 {
Jens Axboee1f36502006-10-27 10:54:08 +0200260 .name = "mem",
261 .type = FIO_OPT_STR,
262 .cb = str_mem_cb,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100263 .off1 = td_var_offset(mem_type),
Jens Axboe15f79182007-01-10 12:26:18 +0100264 .help = "Backing type for IO buffers",
Jens Axboeee738492007-01-10 11:23:16 +0100265 .def = "malloc",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100266 .posval = {
267 { .ival = "malloc", .oval = MEM_MALLOC },
268 { .ival = "shm", .oval = MEM_SHM },
269#ifdef FIO_HAVE_HUGETLB
270 { .ival = "shmhuge", .oval = MEM_SHMHUGE },
271#endif
272 { .ival = "mmap", .oval = MEM_MMAP },
273#ifdef FIO_HAVE_HUGETLB
274 { .ival = "mmaphuge", .oval = MEM_MMAPHUGE },
275#endif
276 },
Jens Axboee1f36502006-10-27 10:54:08 +0200277 },
278 {
279 .name = "verify",
280 .type = FIO_OPT_STR,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100281 .off1 = td_var_offset(verify),
Jens Axboe15f79182007-01-10 12:26:18 +0100282 .help = "Verify sum function",
Jens Axboeee738492007-01-10 11:23:16 +0100283 .def = "0",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100284 .posval = {
285 { .ival = "0", .oval = VERIFY_NONE },
286 { .ival = "crc32", .oval = VERIFY_CRC32 },
287 { .ival = "md5", .oval = VERIFY_MD5 },
288 },
Jens Axboee1f36502006-10-27 10:54:08 +0200289 },
290 {
291 .name = "write_iolog",
Jens Axboe076efc72006-10-27 11:24:25 +0200292 .type = FIO_OPT_STR_STORE,
293 .off1 = td_var_offset(write_iolog_file),
Jens Axboefd28ca42007-01-09 21:20:13 +0100294 .help = "Store IO pattern to file",
Jens Axboee1f36502006-10-27 10:54:08 +0200295 },
296 {
Jens Axboe076efc72006-10-27 11:24:25 +0200297 .name = "read_iolog",
Jens Axboee1f36502006-10-27 10:54:08 +0200298 .type = FIO_OPT_STR_STORE,
Jens Axboe076efc72006-10-27 11:24:25 +0200299 .off1 = td_var_offset(read_iolog_file),
Jens Axboefd28ca42007-01-09 21:20:13 +0100300 .help = "Playback IO pattern from file",
Jens Axboee1f36502006-10-27 10:54:08 +0200301 },
302 {
303 .name = "exec_prerun",
304 .type = FIO_OPT_STR_STORE,
305 .off1 = td_var_offset(exec_prerun),
Jens Axboefd28ca42007-01-09 21:20:13 +0100306 .help = "Execute this file prior to running job",
Jens Axboee1f36502006-10-27 10:54:08 +0200307 },
308 {
309 .name = "exec_postrun",
310 .type = FIO_OPT_STR_STORE,
311 .off1 = td_var_offset(exec_postrun),
Jens Axboefd28ca42007-01-09 21:20:13 +0100312 .help = "Execute this file after running job",
Jens Axboee1f36502006-10-27 10:54:08 +0200313 },
314#ifdef FIO_HAVE_IOSCHED_SWITCH
315 {
316 .name = "ioscheduler",
317 .type = FIO_OPT_STR_STORE,
318 .off1 = td_var_offset(ioscheduler),
Jens Axboefd28ca42007-01-09 21:20:13 +0100319 .help = "Use this IO scheduler on the backing device",
Jens Axboee1f36502006-10-27 10:54:08 +0200320 },
321#endif
322 {
Jens Axboee1f36502006-10-27 10:54:08 +0200323 .name = "zonesize",
324 .type = FIO_OPT_STR_VAL,
325 .off1 = td_var_offset(zone_size),
Jens Axboefd28ca42007-01-09 21:20:13 +0100326 .help = "Give size of an IO zone",
Jens Axboeee738492007-01-10 11:23:16 +0100327 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200328 },
329 {
330 .name = "zoneskip",
331 .type = FIO_OPT_STR_VAL,
332 .off1 = td_var_offset(zone_skip),
Jens Axboefd28ca42007-01-09 21:20:13 +0100333 .help = "Space between IO zones",
Jens Axboeee738492007-01-10 11:23:16 +0100334 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200335 },
336 {
337 .name = "lockmem",
338 .type = FIO_OPT_STR_VAL,
339 .cb = str_lockmem_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100340 .help = "Lock down this amount of memory",
Jens Axboeee738492007-01-10 11:23:16 +0100341 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200342 },
343 {
Jens Axboee1f36502006-10-27 10:54:08 +0200344 .name = "rwmixcycle",
345 .type = FIO_OPT_INT,
346 .off1 = td_var_offset(rwmixcycle),
Jens Axboeee738492007-01-10 11:23:16 +0100347 .help = "Cycle period for mixed read/write workloads (msec)",
348 .def = "500",
Jens Axboee1f36502006-10-27 10:54:08 +0200349 },
350 {
351 .name = "rwmixread",
352 .type = FIO_OPT_INT,
353 .off1 = td_var_offset(rwmixread),
Jens Axboeee738492007-01-10 11:23:16 +0100354 .maxval = 100,
Jens Axboefd28ca42007-01-09 21:20:13 +0100355 .help = "Percentage of mixed workload that is reads",
Jens Axboeee738492007-01-10 11:23:16 +0100356 .def = "50",
Jens Axboee1f36502006-10-27 10:54:08 +0200357 },
358 {
359 .name = "rwmixwrite",
360 .type = FIO_OPT_INT,
361 .off1 = td_var_offset(rwmixwrite),
Jens Axboeee738492007-01-10 11:23:16 +0100362 .maxval = 100,
Jens Axboefd28ca42007-01-09 21:20:13 +0100363 .help = "Percentage of mixed workload that is writes",
Jens Axboeee738492007-01-10 11:23:16 +0100364 .def = "50",
Jens Axboee1f36502006-10-27 10:54:08 +0200365 },
366 {
367 .name = "nice",
368 .type = FIO_OPT_INT,
369 .off1 = td_var_offset(nice),
Jens Axboefd28ca42007-01-09 21:20:13 +0100370 .help = "Set job CPU nice value",
Jens Axboe15f79182007-01-10 12:26:18 +0100371 .minval = -19,
Jens Axboeee738492007-01-10 11:23:16 +0100372 .maxval = 20,
373 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200374 },
375#ifdef FIO_HAVE_IOPRIO
376 {
377 .name = "prio",
378 .type = FIO_OPT_INT,
379 .cb = str_prio_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100380 .help = "Set job IO priority value",
Jens Axboe15f79182007-01-10 12:26:18 +0100381 .minval = 0,
382 .maxval = 7,
Jens Axboee1f36502006-10-27 10:54:08 +0200383 },
384 {
385 .name = "prioclass",
386 .type = FIO_OPT_INT,
387 .cb = str_prioclass_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100388 .help = "Set job IO priority class",
Jens Axboe15f79182007-01-10 12:26:18 +0100389 .minval = 0,
390 .maxval = 3,
Jens Axboee1f36502006-10-27 10:54:08 +0200391 },
392#endif
393 {
394 .name = "thinktime",
395 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100396 .off1 = td_var_offset(thinktime),
Jens Axboe5fa0f812007-01-11 14:06:35 +0100397 .help = "Idle time between IO buffers (usec)",
Jens Axboeee738492007-01-10 11:23:16 +0100398 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200399 },
400 {
Jens Axboe48097d52007-02-17 06:30:44 +0100401 .name = "thinktime_spin",
402 .type = FIO_OPT_INT,
403 .off1 = td_var_offset(thinktime_spin),
Jens Axboe34403fb2007-03-02 21:43:25 +0100404 .help = "Start think time by spinning this amount (usec)",
Jens Axboe48097d52007-02-17 06:30:44 +0100405 .def = "0",
406 },
407 {
Jens Axboe9c1f7432007-01-03 20:43:19 +0100408 .name = "thinktime_blocks",
409 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100410 .off1 = td_var_offset(thinktime_blocks),
Jens Axboefd28ca42007-01-09 21:20:13 +0100411 .help = "IO buffer period between 'thinktime'",
Jens Axboeee738492007-01-10 11:23:16 +0100412 .def = "1",
Jens Axboe9c1f7432007-01-03 20:43:19 +0100413 },
414 {
Jens Axboee1f36502006-10-27 10:54:08 +0200415 .name = "rate",
416 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100417 .off1 = td_var_offset(rate),
Jens Axboefd28ca42007-01-09 21:20:13 +0100418 .help = "Set bandwidth rate",
Jens Axboee1f36502006-10-27 10:54:08 +0200419 },
420 {
421 .name = "ratemin",
422 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100423 .off1 = td_var_offset(ratemin),
Jens Axboefd28ca42007-01-09 21:20:13 +0100424 .help = "The bottom limit accepted",
Jens Axboee1f36502006-10-27 10:54:08 +0200425 },
426 {
427 .name = "ratecycle",
428 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100429 .off1 = td_var_offset(ratecycle),
Jens Axboe6da1fa72007-01-10 11:27:48 +0100430 .help = "Window average for rate limits (msec)",
Jens Axboeee738492007-01-10 11:23:16 +0100431 .def = "1000",
Jens Axboee1f36502006-10-27 10:54:08 +0200432 },
433 {
Jens Axboee1f36502006-10-27 10:54:08 +0200434 .name = "invalidate",
Jens Axboe13335dd2007-01-10 13:14:02 +0100435 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100436 .off1 = td_var_offset(invalidate_cache),
Jens Axboefd28ca42007-01-09 21:20:13 +0100437 .help = "Invalidate buffer/page cache prior to running job",
Jens Axboeee738492007-01-10 11:23:16 +0100438 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200439 },
440 {
441 .name = "sync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100442 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100443 .off1 = td_var_offset(sync_io),
Jens Axboefd28ca42007-01-09 21:20:13 +0100444 .help = "Use O_SYNC for buffered writes",
Jens Axboeee738492007-01-10 11:23:16 +0100445 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200446 },
447 {
448 .name = "bwavgtime",
449 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100450 .off1 = td_var_offset(bw_avg_time),
Jens Axboeee738492007-01-10 11:23:16 +0100451 .help = "Time window over which to calculate bandwidth (msec)",
452 .def = "500",
Jens Axboee1f36502006-10-27 10:54:08 +0200453 },
454 {
455 .name = "create_serialize",
Jens Axboe13335dd2007-01-10 13:14:02 +0100456 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100457 .off1 = td_var_offset(create_serialize),
Jens Axboefd28ca42007-01-09 21:20:13 +0100458 .help = "Serialize creating of job files",
Jens Axboeee738492007-01-10 11:23:16 +0100459 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200460 },
461 {
462 .name = "create_fsync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100463 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100464 .off1 = td_var_offset(create_fsync),
Jens Axboefd28ca42007-01-09 21:20:13 +0100465 .help = "Fsync file after creation",
Jens Axboeee738492007-01-10 11:23:16 +0100466 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200467 },
468 {
Jens Axboee1f36502006-10-27 10:54:08 +0200469 .name = "cpuload",
470 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100471 .off1 = td_var_offset(cpuload),
Jens Axboefd28ca42007-01-09 21:20:13 +0100472 .help = "Use this percentage of CPU",
Jens Axboee1f36502006-10-27 10:54:08 +0200473 },
474 {
475 .name = "cpuchunks",
476 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100477 .off1 = td_var_offset(cpucycle),
Jens Axboeba0fbe12007-03-09 14:34:23 +0100478 .help = "Length of the CPU burn cycles (usecs)",
479 .def = "50000",
Jens Axboee1f36502006-10-27 10:54:08 +0200480 },
Jens Axboee1f36502006-10-27 10:54:08 +0200481#ifdef FIO_HAVE_CPU_AFFINITY
482 {
483 .name = "cpumask",
484 .type = FIO_OPT_INT,
485 .cb = str_cpumask_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100486 .help = "CPU affinity mask",
Jens Axboee1f36502006-10-27 10:54:08 +0200487 },
488#endif
489 {
490 .name = "end_fsync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100491 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100492 .off1 = td_var_offset(end_fsync),
Jens Axboefd28ca42007-01-09 21:20:13 +0100493 .help = "Include fsync at the end of job",
Jens Axboeee738492007-01-10 11:23:16 +0100494 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200495 },
496 {
497 .name = "unlink",
Jens Axboe13335dd2007-01-10 13:14:02 +0100498 .type = FIO_OPT_BOOL,
Jens Axboee1f36502006-10-27 10:54:08 +0200499 .off1 = td_var_offset(unlink),
Jens Axboeee738492007-01-10 11:23:16 +0100500 .help = "Unlink created files after job has completed",
Jens Axboee545a6c2007-01-14 00:00:29 +0100501 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200502 },
503 {
504 .name = "exitall",
505 .type = FIO_OPT_STR_SET,
506 .cb = str_exitall_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100507 .help = "Terminate all jobs when one exits",
Jens Axboee1f36502006-10-27 10:54:08 +0200508 },
509 {
510 .name = "stonewall",
511 .type = FIO_OPT_STR_SET,
512 .off1 = td_var_offset(stonewall),
Jens Axboefd28ca42007-01-09 21:20:13 +0100513 .help = "Insert a hard barrier between this job and previous",
Jens Axboee1f36502006-10-27 10:54:08 +0200514 },
515 {
516 .name = "thread",
517 .type = FIO_OPT_STR_SET,
Jens Axboed9bb3b82007-01-10 20:30:53 +0100518 .off1 = td_var_offset(use_thread),
Jens Axboefd28ca42007-01-09 21:20:13 +0100519 .help = "Use threads instead of forks",
Jens Axboee1f36502006-10-27 10:54:08 +0200520 },
521 {
522 .name = "write_bw_log",
523 .type = FIO_OPT_STR_SET,
524 .off1 = td_var_offset(write_bw_log),
Jens Axboefd28ca42007-01-09 21:20:13 +0100525 .help = "Write log of bandwidth during run",
Jens Axboee1f36502006-10-27 10:54:08 +0200526 },
527 {
528 .name = "write_lat_log",
529 .type = FIO_OPT_STR_SET,
530 .off1 = td_var_offset(write_lat_log),
Jens Axboefd28ca42007-01-09 21:20:13 +0100531 .help = "Write log of latency during run",
Jens Axboee1f36502006-10-27 10:54:08 +0200532 },
533 {
Jens Axboe56bb17f2006-12-20 20:27:36 +0100534 .name = "hugepage-size",
535 .type = FIO_OPT_STR_VAL,
536 .off1 = td_var_offset(hugepage_size),
Jens Axboefd28ca42007-01-09 21:20:13 +0100537 .help = "When using hugepages, specify size of each page",
Jens Axboeee738492007-01-10 11:23:16 +0100538 .def = __stringify(FIO_HUGE_PAGE),
Jens Axboe56bb17f2006-12-20 20:27:36 +0100539 },
540 {
Jens Axboeb2560f32007-03-06 12:43:03 +0100541 .name = "group_reporting",
542 .type = FIO_OPT_STR_SET,
543 .off1 = td_var_offset(group_reporting),
544 .help = "Do reporting on a per-group basis",
545 },
546 {
Jens Axboee1f36502006-10-27 10:54:08 +0200547 .name = NULL,
548 },
549};
550
Jens Axboeb4692822006-10-27 13:43:22 +0200551#define FIO_JOB_OPTS (sizeof(options) / sizeof(struct fio_option))
552#define FIO_CMD_OPTS (16)
553#define FIO_GETOPT_JOB (0x89988998)
554
555/*
556 * Command line options. These will contain the above, plus a few
557 * extra that only pertain to fio itself and not jobs.
558 */
559static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = {
560 {
561 .name = "output",
562 .has_arg = required_argument,
563 .val = 'o',
564 },
565 {
566 .name = "timeout",
567 .has_arg = required_argument,
568 .val = 't',
569 },
570 {
571 .name = "latency-log",
572 .has_arg = required_argument,
573 .val = 'l',
574 },
575 {
576 .name = "bandwidth-log",
577 .has_arg = required_argument,
578 .val = 'b',
579 },
580 {
581 .name = "minimal",
582 .has_arg = optional_argument,
583 .val = 'm',
584 },
585 {
586 .name = "version",
587 .has_arg = no_argument,
588 .val = 'v',
589 },
590 {
Jens Axboefd28ca42007-01-09 21:20:13 +0100591 .name = "help",
592 .has_arg = no_argument,
593 .val = 'h',
594 },
595 {
596 .name = "cmdhelp",
Jens Axboe320beef2007-03-01 10:44:12 +0100597 .has_arg = optional_argument,
Jens Axboefd28ca42007-01-09 21:20:13 +0100598 .val = 'c',
599 },
600 {
Jens Axboeb4692822006-10-27 13:43:22 +0200601 .name = NULL,
602 },
603};
604
Jens Axboeee738492007-01-10 11:23:16 +0100605static int def_timeout = 0;
Jens Axboe972cfd22006-06-09 11:08:56 +0200606
Jens Axboefdf3de22007-03-03 12:21:34 +0100607static char fio_version_string[] = "fio 1.13";
Jens Axboeebac4652005-12-08 15:25:21 +0100608
Jens Axboe972cfd22006-06-09 11:08:56 +0200609static char **ini_file;
Jens Axboeebac4652005-12-08 15:25:21 +0100610static int max_jobs = MAX_JOBS;
611
612struct thread_data def_thread;
613struct thread_data *threads = NULL;
614
Jens Axboeebac4652005-12-08 15:25:21 +0100615int exitall_on_terminate = 0;
Jens Axboec6ae0a52006-06-12 11:04:44 +0200616int terse_output = 0;
Jens Axboec04f7ec2006-05-31 10:13:16 +0200617unsigned long long mlock_size = 0;
Jens Axboeeb8bbf42006-06-08 21:40:11 +0200618FILE *f_out = NULL;
619FILE *f_err = NULL;
Jens Axboeebac4652005-12-08 15:25:21 +0100620
Jens Axboeee738492007-01-10 11:23:16 +0100621static int write_lat_log = 0;
Jens Axboebb3884d2007-01-17 17:23:11 +1100622int write_bw_log = 0;
Jens Axboeec94ec52006-10-20 10:59:19 +0200623
Joel Becker9728ce32007-03-01 08:24:39 +0100624FILE *get_f_out()
625{
626 return f_out;
627}
628
629FILE *get_f_err()
630{
631 return f_err;
632}
633
Jens Axboe906c8d72006-06-13 09:37:56 +0200634/*
635 * Return a free job structure.
636 */
Jens Axboeebac4652005-12-08 15:25:21 +0100637static struct thread_data *get_new_job(int global, struct thread_data *parent)
638{
639 struct thread_data *td;
640
641 if (global)
642 return &def_thread;
643 if (thread_number >= max_jobs)
644 return NULL;
645
646 td = &threads[thread_number++];
Jens Axboeddaeaa52006-06-08 11:00:58 +0200647 *td = *parent;
Jens Axboeebac4652005-12-08 15:25:21 +0100648
Jens Axboeebac4652005-12-08 15:25:21 +0100649 td->thread_number = thread_number;
Jens Axboeebac4652005-12-08 15:25:21 +0100650 return td;
651}
652
653static void put_job(struct thread_data *td)
654{
Jens Axboe549577a2006-10-30 12:23:41 +0100655 if (td == &def_thread)
656 return;
657
Jens Axboe16edf252007-02-10 14:59:22 +0100658 if (td->error)
659 fprintf(f_out, "fio: %s\n", td->verror);
660
Jens Axboeebac4652005-12-08 15:25:21 +0100661 memset(&threads[td->thread_number - 1], 0, sizeof(*td));
662 thread_number--;
663}
664
Jens Axboedad915e2006-10-27 11:10:18 +0200665/*
666 * Lazy way of fixing up options that depend on each other. We could also
667 * define option callback handlers, but this is easier.
668 */
Jens Axboee1f36502006-10-27 10:54:08 +0200669static void fixup_options(struct thread_data *td)
670{
Jens Axboee1f36502006-10-27 10:54:08 +0200671 if (!td->rwmixread && td->rwmixwrite)
672 td->rwmixread = 100 - td->rwmixwrite;
Jens Axboedad915e2006-10-27 11:10:18 +0200673
Jens Axboe076efc72006-10-27 11:24:25 +0200674 if (td->write_iolog_file && td->read_iolog_file) {
675 log_err("fio: read iolog overrides write_iolog\n");
676 free(td->write_iolog_file);
677 td->write_iolog_file = NULL;
678 }
Jens Axboe16b462a2006-10-30 12:35:18 +0100679
680 if (td->io_ops->flags & FIO_SYNCIO)
681 td->iodepth = 1;
682 else {
683 if (!td->iodepth)
Jens Axboeb5af8292007-03-08 12:43:13 +0100684 td->iodepth = td->open_files;
Jens Axboe16b462a2006-10-30 12:35:18 +0100685 }
686
687 /*
688 * only really works for sequential io for now, and with 1 file
689 */
Jens Axboeb5af8292007-03-08 12:43:13 +0100690 if (td->zone_size && td_random(td) && td->open_files == 1)
Jens Axboe16b462a2006-10-30 12:35:18 +0100691 td->zone_size = 0;
692
693 /*
694 * Reads can do overwrites, we always need to pre-create the file
695 */
696 if (td_read(td) || td_rw(td))
697 td->overwrite = 1;
698
Jens Axboea00735e2006-11-03 08:58:08 +0100699 if (!td->min_bs[DDIR_READ])
700 td->min_bs[DDIR_READ]= td->bs[DDIR_READ];
701 if (!td->max_bs[DDIR_READ])
702 td->max_bs[DDIR_READ] = td->bs[DDIR_READ];
703 if (!td->min_bs[DDIR_WRITE])
Jens Axboe75e6f362006-11-03 08:17:09 +0100704 td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE];
Jens Axboea00735e2006-11-03 08:58:08 +0100705 if (!td->max_bs[DDIR_WRITE])
Jens Axboe75e6f362006-11-03 08:17:09 +0100706 td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE];
Jens Axboea00735e2006-11-03 08:58:08 +0100707
708 td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
709
Jens Axboe16b462a2006-10-30 12:35:18 +0100710 if (td_read(td) && !td_rw(td))
711 td->verify = 0;
Jens Axboebb8895e2006-10-30 15:14:48 +0100712
713 if (td->norandommap && td->verify != VERIFY_NONE) {
714 log_err("fio: norandommap given, verify disabled\n");
715 td->verify = VERIFY_NONE;
716 }
Jens Axboe690adba2006-10-30 15:25:09 +0100717 if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO))
718 log_err("fio: bs_unaligned may not work with raw io\n");
Jens Axboee0a22332006-12-20 12:54:25 +0100719
720 /*
721 * O_DIRECT and char doesn't mix, clear that flag if necessary.
722 */
723 if (td->filetype == FIO_TYPE_CHAR && td->odirect)
724 td->odirect = 0;
Jens Axboe48097d52007-02-17 06:30:44 +0100725
726 /*
727 * thinktime_spin must be less than thinktime
728 */
729 if (td->thinktime_spin > td->thinktime)
730 td->thinktime_spin = td->thinktime;
Jens Axboee916b392007-02-20 14:37:26 +0100731
732 /*
733 * The low water mark cannot be bigger than the iodepth
734 */
Jens Axboe9467b772007-02-27 19:56:43 +0100735 if (td->iodepth_low > td->iodepth || !td->iodepth_low) {
736 /*
737 * syslet work around - if the workload is sequential,
738 * we want to let the queue drain all the way down to
739 * avoid seeking between async threads
740 */
741 if (!strcmp(td->io_ops->name, "syslet-rw") && !td_random(td))
742 td->iodepth_low = 1;
743 else
744 td->iodepth_low = td->iodepth;
745 }
Jens Axboecb5ab512007-02-26 12:57:09 +0100746
747 /*
748 * If batch number isn't set, default to the same as iodepth
749 */
750 if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
751 td->iodepth_batch = td->iodepth;
Jens Axboeb5af8292007-03-08 12:43:13 +0100752
753 if (td->open_files > td->nr_files || !td->open_files)
754 td->open_files = td->nr_files;
Jens Axboee1f36502006-10-27 10:54:08 +0200755}
756
Jens Axboe906c8d72006-06-13 09:37:56 +0200757/*
Jens Axboef8977ee2006-11-06 14:03:03 +0100758 * This function leaks the buffer
759 */
760static char *to_kmg(unsigned int val)
761{
762 char *buf = malloc(32);
Jens Axboef3502ba2007-02-14 01:27:09 +0100763 char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 };
Jens Axboef8977ee2006-11-06 14:03:03 +0100764 char *p = post;
765
Jens Axboe245142f2006-11-08 12:49:21 +0100766 do {
Jens Axboef8977ee2006-11-06 14:03:03 +0100767 if (val & 1023)
768 break;
769
770 val >>= 10;
771 p++;
Jens Axboe245142f2006-11-08 12:49:21 +0100772 } while (*p);
Jens Axboef8977ee2006-11-06 14:03:03 +0100773
774 snprintf(buf, 31, "%u%c", val, *p);
775 return buf;
776}
777
Jens Axboe09629a92007-03-09 09:00:06 +0100778/* External engines are specified by "external:name.o") */
779static const char *get_engine_name(const char *str)
780{
781 char *p = strstr(str, ":");
782
783 if (!p)
784 return str;
785
786 p++;
787 strip_blank_front(&p);
788 strip_blank_end(p);
789 return p;
790}
791
Jens Axboef8977ee2006-11-06 14:03:03 +0100792/*
Jens Axboe906c8d72006-06-13 09:37:56 +0200793 * Adds a job to the list of things todo. Sanitizes the various options
794 * to make sure we don't have conflicts, and initializes various
795 * members of td.
796 */
Jens Axboe75154842006-06-01 13:56:09 +0200797static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
Jens Axboeebac4652005-12-08 15:25:21 +0100798{
Jens Axboe413dd452007-02-23 09:26:09 +0100799 const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
800 "randread", "randwrite", "randrw" };
Jens Axboeebac4652005-12-08 15:25:21 +0100801 struct stat sb;
Jens Axboe413dd452007-02-23 09:26:09 +0100802 int numjobs, i;
Jens Axboe53cdc682006-10-18 11:50:58 +0200803 struct fio_file *f;
Jens Axboe09629a92007-03-09 09:00:06 +0100804 const char *engine;
Jens Axboeebac4652005-12-08 15:25:21 +0100805
Jens Axboeebac4652005-12-08 15:25:21 +0100806 /*
807 * the def_thread is just for options, it's not a real job
808 */
809 if (td == &def_thread)
810 return 0;
811
Jens Axboe09629a92007-03-09 09:00:06 +0100812 engine = get_engine_name(td->ioengine);
813 td->io_ops = load_ioengine(td, engine);
814 if (!td->io_ops) {
815 log_err("fio: failed to load engine %s\n", engine);
816 return 1;
817 }
Jens Axboedf641192006-10-12 07:55:41 +0200818
Jens Axboe9cedf162007-03-12 11:29:30 +0100819 if (td->use_thread)
820 nr_thread++;
821 else
822 nr_process++;
823
Jens Axboe690adba2006-10-30 15:25:09 +0100824 if (td->odirect)
825 td->io_ops->flags |= FIO_RAWIO;
826
Jens Axboe80be24f2007-03-12 11:01:25 +0100827 if (!td->filename)
828 td->filename = strdup(jobname);
829
Jens Axboeebac4652005-12-08 15:25:21 +0100830 td->filetype = FIO_TYPE_FILE;
Jens Axboe80be24f2007-03-12 11:01:25 +0100831 if (!lstat(td->filename, &sb)) {
Jens Axboe0af7b542006-02-17 10:10:12 +0100832 if (S_ISBLK(sb.st_mode))
833 td->filetype = FIO_TYPE_BD;
834 else if (S_ISCHR(sb.st_mode))
835 td->filetype = FIO_TYPE_CHAR;
836 }
Jens Axboeebac4652005-12-08 15:25:21 +0100837
Jens Axboee0a22332006-12-20 12:54:25 +0100838 fixup_options(td);
839
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200840 if (td->filename)
841 td->nr_uniq_files = 1;
842 else
Jens Axboe0f14fef2007-03-08 13:08:24 +0100843 td->nr_uniq_files = td->open_files;
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200844
845 if (td->filetype == FIO_TYPE_FILE || td->filename) {
Jens Axboee9c047a2006-06-07 21:13:04 +0200846 char tmp[PATH_MAX];
Jens Axboe53cdc682006-10-18 11:50:58 +0200847 int len = 0;
Jens Axboee9c047a2006-06-07 21:13:04 +0200848
Jens Axboe16edf252007-02-10 14:59:22 +0100849 if (td->directory && td->directory[0] != '\0') {
850 if (lstat(td->directory, &sb) < 0) {
851 log_err("fio: %s is not a directory\n", td->directory);
Jens Axboee1161c32007-02-22 19:36:48 +0100852 td_verror(td, errno, "lstat");
Jens Axboe16edf252007-02-10 14:59:22 +0100853 return 1;
854 }
855 if (!S_ISDIR(sb.st_mode)) {
856 log_err("fio: %s is not a directory\n", td->directory);
857 return 1;
858 }
Jens Axboe8aeebd52007-01-08 10:47:43 +0100859 len = sprintf(tmp, "%s/", td->directory);
Jens Axboe16edf252007-02-10 14:59:22 +0100860 }
Jens Axboeebac4652005-12-08 15:25:21 +0100861
Jens Axboeb5af8292007-03-08 12:43:13 +0100862 td->files = malloc(sizeof(struct fio_file) * td->open_files);
Jens Axboe53cdc682006-10-18 11:50:58 +0200863
864 for_each_file(td, f, i) {
865 memset(f, 0, sizeof(*f));
866 f->fd = -1;
867
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200868 if (td->filename)
869 sprintf(tmp + len, "%s", td->filename);
870 else
871 sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
Jens Axboe53cdc682006-10-18 11:50:58 +0200872 f->file_name = strdup(tmp);
873 }
874 } else {
Jens Axboeb5af8292007-03-08 12:43:13 +0100875 td->open_files = td->nr_files = 1;
Jens Axboe53cdc682006-10-18 11:50:58 +0200876 td->files = malloc(sizeof(struct fio_file));
877 f = &td->files[0];
878
879 memset(f, 0, sizeof(*f));
880 f->fd = -1;
881 f->file_name = strdup(jobname);
882 }
883
884 for_each_file(td, f, i) {
885 f->file_size = td->total_file_size / td->nr_files;
886 f->file_offset = td->start_offset;
887 }
888
Jens Axboe07739b52007-03-08 20:25:46 +0100889 td->mutex = fio_sem_init(0);
Jens Axboeebac4652005-12-08 15:25:21 +0100890
Jens Axboe756867b2007-03-06 15:19:24 +0100891 td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
892 td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;
893 td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
Jens Axboeebac4652005-12-08 15:25:21 +0100894
Jens Axboeebac4652005-12-08 15:25:21 +0100895 if (td->stonewall && td->thread_number > 1)
896 groupid++;
897
898 td->groupid = groupid;
899
900 if (setup_rate(td))
901 goto err;
902
Jens Axboeec94ec52006-10-20 10:59:19 +0200903 if (td->write_lat_log) {
Jens Axboe756867b2007-03-06 15:19:24 +0100904 setup_log(&td->ts.slat_log);
905 setup_log(&td->ts.clat_log);
Jens Axboeebac4652005-12-08 15:25:21 +0100906 }
Jens Axboeec94ec52006-10-20 10:59:19 +0200907 if (td->write_bw_log)
Jens Axboe756867b2007-03-06 15:19:24 +0100908 setup_log(&td->ts.bw_log);
Jens Axboeebac4652005-12-08 15:25:21 +0100909
Jens Axboeb4692822006-10-27 13:43:22 +0200910 if (!td->name)
911 td->name = strdup(jobname);
Jens Axboe01452052006-06-07 10:29:47 +0200912
Jens Axboec6ae0a52006-06-12 11:04:44 +0200913 if (!terse_output) {
Jens Axboeb990b5c2006-09-14 09:48:22 +0200914 if (!job_add_num) {
Jens Axboeba0fbe12007-03-09 14:34:23 +0100915 if (!strcmp(td->io_ops->name, "cpuio"))
Jens Axboeb990b5c2006-09-14 09:48:22 +0200916 fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
Jens Axboef8977ee2006-11-06 14:03:03 +0100917 else {
918 char *c1, *c2, *c3, *c4;
919
920 c1 = to_kmg(td->min_bs[DDIR_READ]);
921 c2 = to_kmg(td->max_bs[DDIR_READ]);
922 c3 = to_kmg(td->min_bs[DDIR_WRITE]);
923 c4 = to_kmg(td->max_bs[DDIR_WRITE]);
924
Jens Axboe413dd452007-02-23 09:26:09 +0100925 fprintf(f_out, "%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[td->td_ddir], c1, c2, c3, c4, td->io_ops->name, td->iodepth);
Jens Axboef8977ee2006-11-06 14:03:03 +0100926
927 free(c1);
928 free(c2);
929 free(c3);
930 free(c4);
931 }
Jens Axboeb990b5c2006-09-14 09:48:22 +0200932 } else if (job_add_num == 1)
Jens Axboec6ae0a52006-06-12 11:04:44 +0200933 fprintf(f_out, "...\n");
934 }
Jens Axboeebac4652005-12-08 15:25:21 +0100935
936 /*
937 * recurse add identical jobs, clear numjobs and stonewall options
938 * as they don't apply to sub-jobs
939 */
940 numjobs = td->numjobs;
941 while (--numjobs) {
942 struct thread_data *td_new = get_new_job(0, td);
943
944 if (!td_new)
945 goto err;
946
947 td_new->numjobs = 1;
948 td_new->stonewall = 0;
Jens Axboe75154842006-06-01 13:56:09 +0200949 job_add_num = numjobs - 1;
Jens Axboeebac4652005-12-08 15:25:21 +0100950
Jens Axboe75154842006-06-01 13:56:09 +0200951 if (add_job(td_new, jobname, job_add_num))
Jens Axboeebac4652005-12-08 15:25:21 +0100952 goto err;
953 }
954 return 0;
955err:
956 put_job(td);
957 return -1;
958}
959
Jens Axboe906c8d72006-06-13 09:37:56 +0200960/*
961 * Initialize the various random states we need (random io, block size ranges,
962 * read/write mix, etc).
963 */
Jens Axboeebac4652005-12-08 15:25:21 +0100964int init_random_state(struct thread_data *td)
965{
Jens Axboe0aabe162007-02-23 08:45:55 +0100966 unsigned long seeds[5];
Jens Axboe53cdc682006-10-18 11:50:58 +0200967 int fd, num_maps, blocks, i;
Jens Axboe0ab8db82006-10-18 17:16:23 +0200968 struct fio_file *f;
Jens Axboeebac4652005-12-08 15:25:21 +0100969
Jens Axboeba0fbe12007-03-09 14:34:23 +0100970 if (td->io_ops->flags & FIO_DISKLESSIO)
Jens Axboef48b4672006-10-27 11:30:07 +0200971 return 0;
972
Jens Axboe1ac267b2006-05-31 20:29:00 +0200973 fd = open("/dev/urandom", O_RDONLY);
Jens Axboeebac4652005-12-08 15:25:21 +0100974 if (fd == -1) {
Jens Axboee1161c32007-02-22 19:36:48 +0100975 td_verror(td, errno, "open");
Jens Axboeebac4652005-12-08 15:25:21 +0100976 return 1;
977 }
978
Jens Axboea6ccc7b2006-06-02 10:14:15 +0200979 if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
Jens Axboee1161c32007-02-22 19:36:48 +0100980 td_verror(td, EIO, "read");
Jens Axboeebac4652005-12-08 15:25:21 +0100981 close(fd);
982 return 1;
983 }
984
985 close(fd);
986
Jens Axboe6dfd46b2006-06-07 13:57:06 +0200987 os_random_seed(seeds[0], &td->bsrange_state);
988 os_random_seed(seeds[1], &td->verify_state);
989 os_random_seed(seeds[2], &td->rwmix_state);
Jens Axboeebac4652005-12-08 15:25:21 +0100990
Jens Axboe413dd452007-02-23 09:26:09 +0100991 if (td->file_service_type == FIO_FSERVICE_RANDOM)
992 os_random_seed(seeds[3], &td->next_file_state);
993
994 if (!td_random(td))
Jens Axboeebac4652005-12-08 15:25:21 +0100995 return 0;
996
Jens Axboe9ebc27e2006-06-12 10:21:50 +0200997 if (td->rand_repeatable)
Jens Axboe0aabe162007-02-23 08:45:55 +0100998 seeds[4] = FIO_RANDSEED * td->thread_number;
Jens Axboeebac4652005-12-08 15:25:21 +0100999
Jens Axboebb8895e2006-10-30 15:14:48 +01001000 if (!td->norandommap) {
1001 for_each_file(td, f, i) {
Jens Axboea4a81712007-02-13 20:07:26 +01001002 blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
Jens Axboec7c280e2006-11-02 20:10:33 +01001003 num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
Jens Axboebb8895e2006-10-30 15:14:48 +01001004 f->file_map = malloc(num_maps * sizeof(long));
Jens Axboebda4fd92007-03-12 11:21:48 +01001005 if (!f->file_map) {
1006 log_err("fio: failed allocating random map. If running a large number of jobs, try the 'norandommap' option\n");
1007 return 1;
1008 }
Jens Axboebb8895e2006-10-30 15:14:48 +01001009 f->num_maps = num_maps;
1010 memset(f->file_map, 0, num_maps * sizeof(long));
1011 }
Jens Axboe53cdc682006-10-18 11:50:58 +02001012 }
Jens Axboeebac4652005-12-08 15:25:21 +01001013
Jens Axboe0aabe162007-02-23 08:45:55 +01001014 os_random_seed(seeds[4], &td->random_state);
Jens Axboeebac4652005-12-08 15:25:21 +01001015 return 0;
1016}
1017
1018static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu)
1019{
1020#ifdef FIO_HAVE_CPU_AFFINITY
1021 unsigned int i;
1022
1023 CPU_ZERO(&cpumask);
1024
1025 for (i = 0; i < sizeof(int) * 8; i++) {
1026 if ((1 << i) & cpu)
1027 CPU_SET(i, &cpumask);
1028 }
1029#endif
1030}
1031
Jens Axboeebac4652005-12-08 15:25:21 +01001032static int is_empty_or_comment(char *line)
1033{
1034 unsigned int i;
1035
1036 for (i = 0; i < strlen(line); i++) {
1037 if (line[i] == ';')
1038 return 1;
Ingo Molnar5cc2da32007-02-20 10:19:44 +01001039 if (line[i] == '#')
1040 return 1;
Jens Axboeebac4652005-12-08 15:25:21 +01001041 if (!isspace(line[i]) && !iscntrl(line[i]))
1042 return 0;
1043 }
1044
1045 return 1;
1046}
1047
Jens Axboe313cb202006-12-21 09:50:00 +01001048/*
1049 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
1050 */
1051static char *get_mmap_file(const char *str)
1052{
1053 char *p = strstr(str, ":");
1054
1055 if (!p)
1056 return NULL;
1057
1058 p++;
1059 strip_blank_front(&p);
1060 strip_blank_end(p);
1061 return strdup(p);
1062}
1063
Jens Axboeb4692822006-10-27 13:43:22 +02001064static int str_mem_cb(void *data, const char *mem)
Jens Axboeebac4652005-12-08 15:25:21 +01001065{
Jens Axboecb2c86f2006-10-26 13:48:34 +02001066 struct thread_data *td = data;
1067
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001068 if (td->mem_type == MEM_MMAPHUGE || td->mem_type == MEM_MMAP) {
Jens Axboe313cb202006-12-21 09:50:00 +01001069 td->mmapfile = get_mmap_file(mem);
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001070 if (td->mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboed0bdaf42006-12-20 14:40:44 +01001071 log_err("fio: mmaphuge:/path/to/file\n");
1072 return 1;
1073 }
Jens Axboeebac4652005-12-08 15:25:21 +01001074 }
1075
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001076 return 0;
Jens Axboeebac4652005-12-08 15:25:21 +01001077}
1078
Jens Axboee1f36502006-10-27 10:54:08 +02001079static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
1080{
1081 mlock_size = *val;
1082 return 0;
1083}
1084
Jens Axboe34cfcda2006-11-03 14:00:45 +01001085#ifdef FIO_HAVE_IOPRIO
Jens Axboee1f36502006-10-27 10:54:08 +02001086static int str_prioclass_cb(void *data, unsigned int *val)
1087{
1088 struct thread_data *td = data;
1089
1090 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
1091 return 0;
1092}
1093
1094static int str_prio_cb(void *data, unsigned int *val)
1095{
1096 struct thread_data *td = data;
1097
1098 td->ioprio |= *val;
1099 return 0;
1100}
Jens Axboe34cfcda2006-11-03 14:00:45 +01001101#endif
Jens Axboee1f36502006-10-27 10:54:08 +02001102
1103static int str_exitall_cb(void)
1104{
1105 exitall_on_terminate = 1;
1106 return 0;
1107}
1108
1109static int str_cpumask_cb(void *data, unsigned int *val)
1110{
1111 struct thread_data *td = data;
1112
1113 fill_cpu_mask(td->cpumask, *val);
1114 return 0;
1115}
1116
Jens Axboe07261982006-06-07 10:51:12 +02001117/*
1118 * This is our [ini] type file parser.
1119 */
Jens Axboe1e97cce2006-12-05 11:44:16 +01001120static int parse_jobs_ini(char *file, int stonewall_flag)
Jens Axboeebac4652005-12-08 15:25:21 +01001121{
Jens Axboee1f36502006-10-27 10:54:08 +02001122 unsigned int global;
Jens Axboeebac4652005-12-08 15:25:21 +01001123 struct thread_data *td;
Jens Axboefee3bb42006-10-30 13:32:08 +01001124 char *string, *name;
Jens Axboeebac4652005-12-08 15:25:21 +01001125 fpos_t off;
1126 FILE *f;
1127 char *p;
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001128 int ret = 0, stonewall;
Jens Axboeebac4652005-12-08 15:25:21 +01001129
1130 f = fopen(file, "r");
1131 if (!f) {
Jens Axboeaea47d42006-05-26 19:27:29 +02001132 perror("fopen job file");
Jens Axboeebac4652005-12-08 15:25:21 +01001133 return 1;
1134 }
1135
1136 string = malloc(4096);
1137 name = malloc(256);
Jens Axboefee3bb42006-10-30 13:32:08 +01001138 memset(name, 0, 256);
Jens Axboeebac4652005-12-08 15:25:21 +01001139
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001140 stonewall = stonewall_flag;
Jens Axboe7c124ac2006-10-30 13:36:52 +01001141 do {
1142 p = fgets(string, 4095, f);
1143 if (!p)
Jens Axboe45410ac2006-06-07 11:10:39 +02001144 break;
Jens Axboeebac4652005-12-08 15:25:21 +01001145 if (is_empty_or_comment(p))
1146 continue;
Jens Axboefee3bb42006-10-30 13:32:08 +01001147 if (sscanf(p, "[%255s]", name) != 1)
Jens Axboeebac4652005-12-08 15:25:21 +01001148 continue;
1149
1150 global = !strncmp(name, "global", 6);
1151
1152 name[strlen(name) - 1] = '\0';
1153
1154 td = get_new_job(global, &def_thread);
Jens Axboe45410ac2006-06-07 11:10:39 +02001155 if (!td) {
1156 ret = 1;
1157 break;
1158 }
Jens Axboeebac4652005-12-08 15:25:21 +01001159
Jens Axboe972cfd22006-06-09 11:08:56 +02001160 /*
1161 * Seperate multiple job files by a stonewall
1162 */
Jens Axboef9481912006-06-09 11:37:28 +02001163 if (!global && stonewall) {
Jens Axboe972cfd22006-06-09 11:08:56 +02001164 td->stonewall = stonewall;
1165 stonewall = 0;
1166 }
1167
Jens Axboeebac4652005-12-08 15:25:21 +01001168 fgetpos(f, &off);
1169 while ((p = fgets(string, 4096, f)) != NULL) {
1170 if (is_empty_or_comment(p))
1171 continue;
Jens Axboee1f36502006-10-27 10:54:08 +02001172
Jens Axboeb6754f92006-05-30 14:29:32 +02001173 strip_blank_front(&p);
Jens Axboe7c124ac2006-10-30 13:36:52 +01001174
1175 if (p[0] == '[')
1176 break;
1177
Jens Axboe4ae3f762006-05-30 13:35:14 +02001178 strip_blank_end(p);
Jens Axboeaea47d42006-05-26 19:27:29 +02001179
Jens Axboee1f36502006-10-27 10:54:08 +02001180 fgetpos(f, &off);
Jens Axboeebac4652005-12-08 15:25:21 +01001181
Jens Axboe45410ac2006-06-07 11:10:39 +02001182 /*
1183 * Don't break here, continue parsing options so we
1184 * dump all the bad ones. Makes trial/error fixups
1185 * easier on the user.
1186 */
Jens Axboe7c124ac2006-10-30 13:36:52 +01001187 ret |= parse_option(p, options, td);
Jens Axboeebac4652005-12-08 15:25:21 +01001188 }
Jens Axboeebac4652005-12-08 15:25:21 +01001189
Jens Axboe45410ac2006-06-07 11:10:39 +02001190 if (!ret) {
1191 fsetpos(f, &off);
1192 ret = add_job(td, name, 0);
Jens Axboeb1508cf2006-11-02 09:12:40 +01001193 } else {
1194 log_err("fio: job %s dropped\n", name);
1195 put_job(td);
Jens Axboe45410ac2006-06-07 11:10:39 +02001196 }
Jens Axboe7c124ac2006-10-30 13:36:52 +01001197 } while (!ret);
Jens Axboeebac4652005-12-08 15:25:21 +01001198
1199 free(string);
1200 free(name);
1201 fclose(f);
Jens Axboe45410ac2006-06-07 11:10:39 +02001202 return ret;
Jens Axboeebac4652005-12-08 15:25:21 +01001203}
1204
1205static int fill_def_thread(void)
1206{
1207 memset(&def_thread, 0, sizeof(def_thread));
1208
1209 if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) {
1210 perror("sched_getaffinity");
1211 return 1;
1212 }
1213
1214 /*
Jens Axboeee738492007-01-10 11:23:16 +01001215 * fill default options
Jens Axboeebac4652005-12-08 15:25:21 +01001216 */
Jens Axboeee738492007-01-10 11:23:16 +01001217 fill_default_options(&def_thread, options);
1218
Jens Axboe972cfd22006-06-09 11:08:56 +02001219 def_thread.timeout = def_timeout;
Jens Axboeec94ec52006-10-20 10:59:19 +02001220 def_thread.write_bw_log = write_bw_log;
1221 def_thread.write_lat_log = write_lat_log;
Jens Axboeee738492007-01-10 11:23:16 +01001222
Jens Axboeebac4652005-12-08 15:25:21 +01001223#ifdef FIO_HAVE_DISK_UTIL
1224 def_thread.do_disk_util = 1;
1225#endif
1226
1227 return 0;
1228}
1229
Jens Axboe0ab8db82006-10-18 17:16:23 +02001230static void usage(void)
Jens Axboe4785f992006-05-26 03:59:10 +02001231{
1232 printf("%s\n", fio_version_string);
Jens Axboeb4692822006-10-27 13:43:22 +02001233 printf("\t--output\tWrite output to file\n");
1234 printf("\t--timeout\tRuntime in seconds\n");
1235 printf("\t--latency-log\tGenerate per-job latency logs\n");
1236 printf("\t--bandwidth-log\tGenerate per-job bandwidth logs\n");
1237 printf("\t--minimal\tMinimal (terse) output\n");
1238 printf("\t--version\tPrint version info and exit\n");
Jens Axboefd28ca42007-01-09 21:20:13 +01001239 printf("\t--help\t\tPrint this page\n");
1240 printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n");
Jens Axboe4785f992006-05-26 03:59:10 +02001241}
1242
Jens Axboe972cfd22006-06-09 11:08:56 +02001243static int parse_cmd_line(int argc, char *argv[])
Jens Axboeebac4652005-12-08 15:25:21 +01001244{
Jens Axboeb4692822006-10-27 13:43:22 +02001245 struct thread_data *td = NULL;
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001246 int c, ini_idx = 0, lidx, ret, dont_add_job = 0;
Jens Axboeebac4652005-12-08 15:25:21 +01001247
Jens Axboe0be06ea2007-03-01 14:23:28 +01001248 while ((c = getopt_long_only(argc, argv, "", long_options, &lidx)) != -1) {
Jens Axboeebac4652005-12-08 15:25:21 +01001249 switch (c) {
Jens Axboeb4692822006-10-27 13:43:22 +02001250 case 't':
1251 def_timeout = atoi(optarg);
1252 break;
1253 case 'l':
1254 write_lat_log = 1;
1255 break;
1256 case 'w':
1257 write_bw_log = 1;
1258 break;
1259 case 'o':
1260 f_out = fopen(optarg, "w+");
1261 if (!f_out) {
1262 perror("fopen output");
1263 exit(1);
1264 }
1265 f_err = f_out;
1266 break;
1267 case 'm':
1268 terse_output = 1;
1269 break;
1270 case 'h':
1271 usage();
1272 exit(0);
Jens Axboefd28ca42007-01-09 21:20:13 +01001273 case 'c':
Jens Axboe29fc6af2007-01-09 21:22:02 +01001274 ret = show_cmd_help(options, optarg);
1275 exit(ret);
Jens Axboeb4692822006-10-27 13:43:22 +02001276 case 'v':
1277 printf("%s\n", fio_version_string);
1278 exit(0);
1279 case FIO_GETOPT_JOB: {
1280 const char *opt = long_options[lidx].name;
1281 char *val = optarg;
1282
Jens Axboec2b1e752006-10-30 09:03:13 +01001283 if (!strncmp(opt, "name", 4) && td) {
1284 ret = add_job(td, td->name ?: "fio", 0);
1285 if (ret) {
1286 put_job(td);
1287 return 0;
1288 }
1289 td = NULL;
1290 }
Jens Axboeb4692822006-10-27 13:43:22 +02001291 if (!td) {
Jens Axboe38d0adb2006-10-30 12:21:25 +01001292 int global = !strncmp(val, "global", 6);
Jens Axboec2b1e752006-10-30 09:03:13 +01001293
1294 td = get_new_job(global, &def_thread);
Jens Axboeb4692822006-10-27 13:43:22 +02001295 if (!td)
1296 return 0;
1297 }
Jens Axboe38d0adb2006-10-30 12:21:25 +01001298
Jens Axboeb1508cf2006-11-02 09:12:40 +01001299 ret = parse_cmd_option(opt, val, options, td);
Jens Axboe78217df2007-02-23 11:18:30 +01001300 if (ret)
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001301 dont_add_job = 1;
Jens Axboeb4692822006-10-27 13:43:22 +02001302 break;
1303 }
1304 default:
Jens Axboeb4692822006-10-27 13:43:22 +02001305 break;
Jens Axboeebac4652005-12-08 15:25:21 +01001306 }
1307 }
Jens Axboec9fad892006-05-27 17:26:50 +02001308
Jens Axboeb4692822006-10-27 13:43:22 +02001309 if (td) {
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001310 if (dont_add_job)
Jens Axboeb4692822006-10-27 13:43:22 +02001311 put_job(td);
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001312 else {
1313 ret = add_job(td, td->name ?: "fio", 0);
1314 if (ret)
1315 put_job(td);
1316 }
Jens Axboe972cfd22006-06-09 11:08:56 +02001317 }
Jens Axboe774a6172006-08-24 08:44:26 +02001318
Jens Axboeb4692822006-10-27 13:43:22 +02001319 while (optind < argc) {
1320 ini_idx++;
1321 ini_file = realloc(ini_file, ini_idx * sizeof(char *));
1322 ini_file[ini_idx - 1] = strdup(argv[optind]);
1323 optind++;
Jens Axboeeb8bbf42006-06-08 21:40:11 +02001324 }
Jens Axboe972cfd22006-06-09 11:08:56 +02001325
1326 return ini_idx;
Jens Axboeebac4652005-12-08 15:25:21 +01001327}
1328
1329static void free_shm(void)
1330{
1331 struct shmid_ds sbuf;
1332
1333 if (threads) {
Jens Axboe2c0ecd22006-06-08 13:25:41 +02001334 shmdt((void *) threads);
Jens Axboeebac4652005-12-08 15:25:21 +01001335 threads = NULL;
1336 shmctl(shm_id, IPC_RMID, &sbuf);
1337 }
1338}
1339
Jens Axboe906c8d72006-06-13 09:37:56 +02001340/*
1341 * The thread area is shared between the main process and the job
1342 * threads/processes. So setup a shared memory segment that will hold
1343 * all the job info.
1344 */
Jens Axboeebac4652005-12-08 15:25:21 +01001345static int setup_thread_area(void)
1346{
1347 /*
1348 * 1024 is too much on some machines, scale max_jobs if
1349 * we get a failure that looks like too large a shm segment
1350 */
1351 do {
Jens Axboe906c8d72006-06-13 09:37:56 +02001352 size_t size = max_jobs * sizeof(struct thread_data);
Jens Axboeebac4652005-12-08 15:25:21 +01001353
Jens Axboe906c8d72006-06-13 09:37:56 +02001354 shm_id = shmget(0, size, IPC_CREAT | 0600);
Jens Axboeebac4652005-12-08 15:25:21 +01001355 if (shm_id != -1)
1356 break;
1357 if (errno != EINVAL) {
1358 perror("shmget");
1359 break;
1360 }
1361
1362 max_jobs >>= 1;
1363 } while (max_jobs);
1364
1365 if (shm_id == -1)
1366 return 1;
1367
1368 threads = shmat(shm_id, NULL, 0);
1369 if (threads == (void *) -1) {
1370 perror("shmat");
1371 return 1;
1372 }
1373
1374 atexit(free_shm);
1375 return 0;
1376}
1377
Jens Axboeb4692822006-10-27 13:43:22 +02001378/*
1379 * Copy the fio options into the long options map, so we mirror
1380 * job and cmd line options.
1381 */
1382static void dupe_job_options(void)
1383{
1384 struct fio_option *o;
1385 unsigned int i;
1386
1387 i = 0;
1388 while (long_options[i].name)
1389 i++;
1390
1391 o = &options[0];
1392 while (o->name) {
1393 long_options[i].name = o->name;
1394 long_options[i].val = FIO_GETOPT_JOB;
1395 if (o->type == FIO_OPT_STR_SET)
1396 long_options[i].has_arg = no_argument;
1397 else
1398 long_options[i].has_arg = required_argument;
1399
1400 i++;
1401 o++;
1402 assert(i < FIO_JOB_OPTS + FIO_CMD_OPTS);
1403 }
1404}
1405
Jens Axboeebac4652005-12-08 15:25:21 +01001406int parse_options(int argc, char *argv[])
1407{
Jens Axboe972cfd22006-06-09 11:08:56 +02001408 int job_files, i;
1409
Jens Axboeb4692822006-10-27 13:43:22 +02001410 f_out = stdout;
1411 f_err = stderr;
1412
Jens Axboe13335dd2007-01-10 13:14:02 +01001413 options_init(options);
1414
Jens Axboeb4692822006-10-27 13:43:22 +02001415 dupe_job_options();
1416
Jens Axboeebac4652005-12-08 15:25:21 +01001417 if (setup_thread_area())
1418 return 1;
1419 if (fill_def_thread())
1420 return 1;
1421
Jens Axboe972cfd22006-06-09 11:08:56 +02001422 job_files = parse_cmd_line(argc, argv);
Jens Axboeebac4652005-12-08 15:25:21 +01001423
Jens Axboe972cfd22006-06-09 11:08:56 +02001424 for (i = 0; i < job_files; i++) {
1425 if (fill_def_thread())
1426 return 1;
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001427 if (parse_jobs_ini(ini_file[i], i))
Jens Axboe972cfd22006-06-09 11:08:56 +02001428 return 1;
Jens Axboe88c6ed82006-06-09 11:28:10 +02001429 free(ini_file[i]);
Jens Axboe972cfd22006-06-09 11:08:56 +02001430 }
Jens Axboeebac4652005-12-08 15:25:21 +01001431
Jens Axboe88c6ed82006-06-09 11:28:10 +02001432 free(ini_file);
Jens Axboeb4692822006-10-27 13:43:22 +02001433
1434 if (!thread_number) {
1435 log_err("No jobs defined(s)\n");
Jens Axboeb4692822006-10-27 13:43:22 +02001436 return 1;
1437 }
1438
Jens Axboeebac4652005-12-08 15:25:21 +01001439 return 0;
1440}