blob: eee23359afc68d209366d7f95cb1c5242de111bf [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 *);
Jens Axboe1907dbc2007-03-12 11:44:28 +010033static int str_fst_cb(void *, const char *);
Jens Axboee1f36502006-10-27 10:54:08 +020034
Jens Axboeee738492007-01-10 11:23:16 +010035#define __stringify_1(x) #x
36#define __stringify(x) __stringify_1(x)
37
Jens Axboee1f36502006-10-27 10:54:08 +020038/*
39 * Map of job/command line options
40 */
41static struct fio_option options[] = {
42 {
Jens Axboe61697c32007-02-05 15:04:46 +010043 .name = "description",
44 .type = FIO_OPT_STR_STORE,
45 .off1 = td_var_offset(description),
46 .help = "Text job description",
47 },
48 {
Jens Axboee1f36502006-10-27 10:54:08 +020049 .name = "name",
50 .type = FIO_OPT_STR_STORE,
51 .off1 = td_var_offset(name),
Jens Axboefd28ca42007-01-09 21:20:13 +010052 .help = "Name of this job",
Jens Axboee1f36502006-10-27 10:54:08 +020053 },
54 {
55 .name = "directory",
56 .type = FIO_OPT_STR_STORE,
57 .off1 = td_var_offset(directory),
Jens Axboefd28ca42007-01-09 21:20:13 +010058 .help = "Directory to store files in",
Jens Axboee1f36502006-10-27 10:54:08 +020059 },
60 {
61 .name = "filename",
62 .type = FIO_OPT_STR_STORE,
63 .off1 = td_var_offset(filename),
Jens Axboefd28ca42007-01-09 21:20:13 +010064 .help = "Force the use of a specific file",
Jens Axboee1f36502006-10-27 10:54:08 +020065 },
66 {
67 .name = "rw",
68 .type = FIO_OPT_STR,
Jens Axboeb1ec1da2007-02-23 10:29:16 +010069 .off1 = td_var_offset(td_ddir),
Jens Axboe15f79182007-01-10 12:26:18 +010070 .help = "IO direction",
Jens Axboeee738492007-01-10 11:23:16 +010071 .def = "read",
Jens Axboeb1ec1da2007-02-23 10:29:16 +010072 .posval = {
73 { .ival = "read", .oval = TD_DDIR_READ },
74 { .ival = "write", .oval = TD_DDIR_WRITE },
75 { .ival = "randread", .oval = TD_DDIR_RANDREAD },
76 { .ival = "randwrite", .oval = TD_DDIR_RANDWRITE },
77 { .ival = "rw", .oval = TD_DDIR_RW },
78 { .ival = "randrw", .oval = TD_DDIR_RANDRW },
79 },
Jens Axboee1f36502006-10-27 10:54:08 +020080 },
81 {
82 .name = "ioengine",
Jens Axboe09629a92007-03-09 09:00:06 +010083 .type = FIO_OPT_STR_STORE,
84 .off1 = td_var_offset(ioengine),
Jens Axboe15f79182007-01-10 12:26:18 +010085 .help = "IO engine to use",
Jens Axboeee738492007-01-10 11:23:16 +010086 .def = "sync",
Jens Axboeb1ec1da2007-02-23 10:29:16 +010087 .posval = {
Jens Axboe10cad1a2007-02-23 11:23:03 +010088 { .ival = "sync", },
89#ifdef FIO_HAVE_LIBAIO
90 { .ival = "libaio", },
91#endif
92#ifdef FIO_HAVE_POSIXAIO
93 { .ival = "posixaio", },
94#endif
95 { .ival = "mmap", },
96#ifdef FIO_HAVE_SPLICE
97 { .ival = "splice", },
98#endif
99#ifdef FIO_HAVE_SGIO
100 { .ival = "sg", },
101#endif
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100102 { .ival = "null", }, { .ival = "net", },
Jens Axboe10cad1a2007-02-23 11:23:03 +0100103#ifdef FIO_HAVE_SYSLET
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100104 { .ival = "syslet-rw", },
Jens Axboe10cad1a2007-02-23 11:23:03 +0100105#endif
Jens Axboeba0fbe12007-03-09 14:34:23 +0100106 { .ival = "cpuio", },
Joel Becker7b395ca2007-02-28 11:10:58 +0100107 { .ival = "external", },
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100108 },
Jens Axboee1f36502006-10-27 10:54:08 +0200109 },
110 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100111 .name = "iodepth",
112 .type = FIO_OPT_INT,
113 .off1 = td_var_offset(iodepth),
114 .help = "Amount of IO buffers to keep in flight",
115 .def = "1",
116 },
117 {
Jens Axboecb5ab512007-02-26 12:57:09 +0100118 .name = "iodepth_batch",
119 .type = FIO_OPT_INT,
120 .off1 = td_var_offset(iodepth_batch),
121 .help = "Number of IO to submit in one go",
122 },
123 {
Jens Axboee916b392007-02-20 14:37:26 +0100124 .name = "iodepth_low",
125 .type = FIO_OPT_INT,
126 .off1 = td_var_offset(iodepth_low),
127 .help = "Low water mark for queuing depth",
128 },
129 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100130 .name = "size",
131 .type = FIO_OPT_STR_VAL,
132 .off1 = td_var_offset(total_file_size),
133 .help = "Size of device or file",
134 },
135 {
136 .name = "bs",
137 .type = FIO_OPT_STR_VAL_INT,
138 .off1 = td_var_offset(bs[DDIR_READ]),
139 .off2 = td_var_offset(bs[DDIR_WRITE]),
140 .help = "Block size unit",
141 .def = "4k",
142 },
143 {
144 .name = "bsrange",
145 .type = FIO_OPT_RANGE,
146 .off1 = td_var_offset(min_bs[DDIR_READ]),
147 .off2 = td_var_offset(max_bs[DDIR_READ]),
148 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
149 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
150 .help = "Set block size range (in more detail than bs)",
151 },
152 {
153 .name = "bs_unaligned",
154 .type = FIO_OPT_STR_SET,
155 .off1 = td_var_offset(bs_unaligned),
156 .help = "Don't sector align IO buffer sizes",
157 },
158 {
159 .name = "offset",
160 .type = FIO_OPT_STR_VAL,
161 .off1 = td_var_offset(start_offset),
162 .help = "Start IO from this offset",
163 .def = "0",
164 },
165 {
166 .name = "randrepeat",
167 .type = FIO_OPT_BOOL,
168 .off1 = td_var_offset(rand_repeatable),
169 .help = "Use repeatable random IO pattern",
170 .def = "1",
171 },
172 {
173 .name = "norandommap",
174 .type = FIO_OPT_STR_SET,
175 .off1 = td_var_offset(norandommap),
176 .help = "Accept potential duplicate random blocks",
177 },
178 {
179 .name = "nrfiles",
180 .type = FIO_OPT_INT,
181 .off1 = td_var_offset(nr_files),
182 .help = "Split job workload between this number of files",
183 .def = "1",
184 },
185 {
Jens Axboeb5af8292007-03-08 12:43:13 +0100186 .name = "openfiles",
187 .type = FIO_OPT_INT,
188 .off1 = td_var_offset(open_files),
189 .help = "Number of files to keep open at the same time",
190 },
191 {
Jens Axboe0aabe162007-02-23 08:45:55 +0100192 .name = "file_service_type",
193 .type = FIO_OPT_STR,
Jens Axboe1907dbc2007-03-12 11:44:28 +0100194 .cb = str_fst_cb,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100195 .off1 = td_var_offset(file_service_type),
Jens Axboe0aabe162007-02-23 08:45:55 +0100196 .help = "How to select which file to service next",
197 .def = "roundrobin",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100198 .posval = {
199 { .ival = "random", .oval = FIO_FSERVICE_RANDOM },
200 { .ival = "roundrobin", .oval = FIO_FSERVICE_RR },
201 },
Jens Axboe0aabe162007-02-23 08:45:55 +0100202 },
203 {
Jens Axboe03b74b32007-01-11 11:04:31 +0100204 .name = "fsync",
205 .type = FIO_OPT_INT,
206 .off1 = td_var_offset(fsync_blocks),
207 .help = "Issue fsync for writes every given number of blocks",
208 .def = "0",
209 },
210 {
211 .name = "direct",
212 .type = FIO_OPT_BOOL,
213 .off1 = td_var_offset(odirect),
Jens Axboe76a43db2007-01-11 13:24:44 +0100214 .help = "Use O_DIRECT IO (negates buffered)",
215 .def = "0",
216 },
217 {
218 .name = "buffered",
219 .type = FIO_OPT_BOOL,
220 .off1 = td_var_offset(odirect),
221 .neg = 1,
222 .help = "Use buffered IO (negates direct)",
Jens Axboe03b74b32007-01-11 11:04:31 +0100223 .def = "1",
224 },
225 {
226 .name = "overwrite",
227 .type = FIO_OPT_BOOL,
228 .off1 = td_var_offset(overwrite),
229 .help = "When writing, set whether to overwrite current data",
230 .def = "0",
231 },
232 {
233 .name = "loops",
234 .type = FIO_OPT_INT,
235 .off1 = td_var_offset(loops),
236 .help = "Number of times to run the job",
237 .def = "1",
238 },
239 {
240 .name = "numjobs",
241 .type = FIO_OPT_INT,
242 .off1 = td_var_offset(numjobs),
243 .help = "Duplicate this job this many times",
244 .def = "1",
245 },
246 {
247 .name = "startdelay",
248 .type = FIO_OPT_INT,
249 .off1 = td_var_offset(start_delay),
250 .help = "Only start job when this period has passed",
251 .def = "0",
252 },
253 {
254 .name = "runtime",
255 .alias = "timeout",
256 .type = FIO_OPT_STR_VAL_TIME,
257 .off1 = td_var_offset(timeout),
258 .help = "Stop workload when this amount of time has passed",
259 .def = "0",
260 },
261 {
Jens Axboee1f36502006-10-27 10:54:08 +0200262 .name = "mem",
263 .type = FIO_OPT_STR,
264 .cb = str_mem_cb,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100265 .off1 = td_var_offset(mem_type),
Jens Axboe15f79182007-01-10 12:26:18 +0100266 .help = "Backing type for IO buffers",
Jens Axboeee738492007-01-10 11:23:16 +0100267 .def = "malloc",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100268 .posval = {
269 { .ival = "malloc", .oval = MEM_MALLOC },
270 { .ival = "shm", .oval = MEM_SHM },
271#ifdef FIO_HAVE_HUGETLB
272 { .ival = "shmhuge", .oval = MEM_SHMHUGE },
273#endif
274 { .ival = "mmap", .oval = MEM_MMAP },
275#ifdef FIO_HAVE_HUGETLB
276 { .ival = "mmaphuge", .oval = MEM_MMAPHUGE },
277#endif
278 },
Jens Axboee1f36502006-10-27 10:54:08 +0200279 },
280 {
281 .name = "verify",
282 .type = FIO_OPT_STR,
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100283 .off1 = td_var_offset(verify),
Jens Axboe15f79182007-01-10 12:26:18 +0100284 .help = "Verify sum function",
Jens Axboeee738492007-01-10 11:23:16 +0100285 .def = "0",
Jens Axboeb1ec1da2007-02-23 10:29:16 +0100286 .posval = {
287 { .ival = "0", .oval = VERIFY_NONE },
288 { .ival = "crc32", .oval = VERIFY_CRC32 },
289 { .ival = "md5", .oval = VERIFY_MD5 },
290 },
Jens Axboee1f36502006-10-27 10:54:08 +0200291 },
292 {
293 .name = "write_iolog",
Jens Axboe076efc72006-10-27 11:24:25 +0200294 .type = FIO_OPT_STR_STORE,
295 .off1 = td_var_offset(write_iolog_file),
Jens Axboefd28ca42007-01-09 21:20:13 +0100296 .help = "Store IO pattern to file",
Jens Axboee1f36502006-10-27 10:54:08 +0200297 },
298 {
Jens Axboe076efc72006-10-27 11:24:25 +0200299 .name = "read_iolog",
Jens Axboee1f36502006-10-27 10:54:08 +0200300 .type = FIO_OPT_STR_STORE,
Jens Axboe076efc72006-10-27 11:24:25 +0200301 .off1 = td_var_offset(read_iolog_file),
Jens Axboefd28ca42007-01-09 21:20:13 +0100302 .help = "Playback IO pattern from file",
Jens Axboee1f36502006-10-27 10:54:08 +0200303 },
304 {
305 .name = "exec_prerun",
306 .type = FIO_OPT_STR_STORE,
307 .off1 = td_var_offset(exec_prerun),
Jens Axboefd28ca42007-01-09 21:20:13 +0100308 .help = "Execute this file prior to running job",
Jens Axboee1f36502006-10-27 10:54:08 +0200309 },
310 {
311 .name = "exec_postrun",
312 .type = FIO_OPT_STR_STORE,
313 .off1 = td_var_offset(exec_postrun),
Jens Axboefd28ca42007-01-09 21:20:13 +0100314 .help = "Execute this file after running job",
Jens Axboee1f36502006-10-27 10:54:08 +0200315 },
316#ifdef FIO_HAVE_IOSCHED_SWITCH
317 {
318 .name = "ioscheduler",
319 .type = FIO_OPT_STR_STORE,
320 .off1 = td_var_offset(ioscheduler),
Jens Axboefd28ca42007-01-09 21:20:13 +0100321 .help = "Use this IO scheduler on the backing device",
Jens Axboee1f36502006-10-27 10:54:08 +0200322 },
323#endif
324 {
Jens Axboee1f36502006-10-27 10:54:08 +0200325 .name = "zonesize",
326 .type = FIO_OPT_STR_VAL,
327 .off1 = td_var_offset(zone_size),
Jens Axboefd28ca42007-01-09 21:20:13 +0100328 .help = "Give size of an IO zone",
Jens Axboeee738492007-01-10 11:23:16 +0100329 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200330 },
331 {
332 .name = "zoneskip",
333 .type = FIO_OPT_STR_VAL,
334 .off1 = td_var_offset(zone_skip),
Jens Axboefd28ca42007-01-09 21:20:13 +0100335 .help = "Space between IO zones",
Jens Axboeee738492007-01-10 11:23:16 +0100336 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200337 },
338 {
339 .name = "lockmem",
340 .type = FIO_OPT_STR_VAL,
341 .cb = str_lockmem_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100342 .help = "Lock down this amount of memory",
Jens Axboeee738492007-01-10 11:23:16 +0100343 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200344 },
345 {
Jens Axboee1f36502006-10-27 10:54:08 +0200346 .name = "rwmixcycle",
347 .type = FIO_OPT_INT,
348 .off1 = td_var_offset(rwmixcycle),
Jens Axboeee738492007-01-10 11:23:16 +0100349 .help = "Cycle period for mixed read/write workloads (msec)",
350 .def = "500",
Jens Axboee1f36502006-10-27 10:54:08 +0200351 },
352 {
353 .name = "rwmixread",
354 .type = FIO_OPT_INT,
355 .off1 = td_var_offset(rwmixread),
Jens Axboeee738492007-01-10 11:23:16 +0100356 .maxval = 100,
Jens Axboefd28ca42007-01-09 21:20:13 +0100357 .help = "Percentage of mixed workload that is reads",
Jens Axboeee738492007-01-10 11:23:16 +0100358 .def = "50",
Jens Axboee1f36502006-10-27 10:54:08 +0200359 },
360 {
361 .name = "rwmixwrite",
362 .type = FIO_OPT_INT,
363 .off1 = td_var_offset(rwmixwrite),
Jens Axboeee738492007-01-10 11:23:16 +0100364 .maxval = 100,
Jens Axboefd28ca42007-01-09 21:20:13 +0100365 .help = "Percentage of mixed workload that is writes",
Jens Axboeee738492007-01-10 11:23:16 +0100366 .def = "50",
Jens Axboee1f36502006-10-27 10:54:08 +0200367 },
368 {
369 .name = "nice",
370 .type = FIO_OPT_INT,
371 .off1 = td_var_offset(nice),
Jens Axboefd28ca42007-01-09 21:20:13 +0100372 .help = "Set job CPU nice value",
Jens Axboe15f79182007-01-10 12:26:18 +0100373 .minval = -19,
Jens Axboeee738492007-01-10 11:23:16 +0100374 .maxval = 20,
375 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200376 },
377#ifdef FIO_HAVE_IOPRIO
378 {
379 .name = "prio",
380 .type = FIO_OPT_INT,
381 .cb = str_prio_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100382 .help = "Set job IO priority value",
Jens Axboe15f79182007-01-10 12:26:18 +0100383 .minval = 0,
384 .maxval = 7,
Jens Axboee1f36502006-10-27 10:54:08 +0200385 },
386 {
387 .name = "prioclass",
388 .type = FIO_OPT_INT,
389 .cb = str_prioclass_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100390 .help = "Set job IO priority class",
Jens Axboe15f79182007-01-10 12:26:18 +0100391 .minval = 0,
392 .maxval = 3,
Jens Axboee1f36502006-10-27 10:54:08 +0200393 },
394#endif
395 {
396 .name = "thinktime",
397 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100398 .off1 = td_var_offset(thinktime),
Jens Axboe5fa0f812007-01-11 14:06:35 +0100399 .help = "Idle time between IO buffers (usec)",
Jens Axboeee738492007-01-10 11:23:16 +0100400 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200401 },
402 {
Jens Axboe48097d52007-02-17 06:30:44 +0100403 .name = "thinktime_spin",
404 .type = FIO_OPT_INT,
405 .off1 = td_var_offset(thinktime_spin),
Jens Axboe34403fb2007-03-02 21:43:25 +0100406 .help = "Start think time by spinning this amount (usec)",
Jens Axboe48097d52007-02-17 06:30:44 +0100407 .def = "0",
408 },
409 {
Jens Axboe9c1f7432007-01-03 20:43:19 +0100410 .name = "thinktime_blocks",
411 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100412 .off1 = td_var_offset(thinktime_blocks),
Jens Axboefd28ca42007-01-09 21:20:13 +0100413 .help = "IO buffer period between 'thinktime'",
Jens Axboeee738492007-01-10 11:23:16 +0100414 .def = "1",
Jens Axboe9c1f7432007-01-03 20:43:19 +0100415 },
416 {
Jens Axboee1f36502006-10-27 10:54:08 +0200417 .name = "rate",
418 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100419 .off1 = td_var_offset(rate),
Jens Axboefd28ca42007-01-09 21:20:13 +0100420 .help = "Set bandwidth rate",
Jens Axboee1f36502006-10-27 10:54:08 +0200421 },
422 {
423 .name = "ratemin",
424 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100425 .off1 = td_var_offset(ratemin),
Jens Axboefd28ca42007-01-09 21:20:13 +0100426 .help = "The bottom limit accepted",
Jens Axboee1f36502006-10-27 10:54:08 +0200427 },
428 {
429 .name = "ratecycle",
430 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100431 .off1 = td_var_offset(ratecycle),
Jens Axboe6da1fa72007-01-10 11:27:48 +0100432 .help = "Window average for rate limits (msec)",
Jens Axboeee738492007-01-10 11:23:16 +0100433 .def = "1000",
Jens Axboee1f36502006-10-27 10:54:08 +0200434 },
435 {
Jens Axboee1f36502006-10-27 10:54:08 +0200436 .name = "invalidate",
Jens Axboe13335dd2007-01-10 13:14:02 +0100437 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100438 .off1 = td_var_offset(invalidate_cache),
Jens Axboefd28ca42007-01-09 21:20:13 +0100439 .help = "Invalidate buffer/page cache prior to running job",
Jens Axboeee738492007-01-10 11:23:16 +0100440 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200441 },
442 {
443 .name = "sync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100444 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100445 .off1 = td_var_offset(sync_io),
Jens Axboefd28ca42007-01-09 21:20:13 +0100446 .help = "Use O_SYNC for buffered writes",
Jens Axboeee738492007-01-10 11:23:16 +0100447 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200448 },
449 {
450 .name = "bwavgtime",
451 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100452 .off1 = td_var_offset(bw_avg_time),
Jens Axboeee738492007-01-10 11:23:16 +0100453 .help = "Time window over which to calculate bandwidth (msec)",
454 .def = "500",
Jens Axboee1f36502006-10-27 10:54:08 +0200455 },
456 {
457 .name = "create_serialize",
Jens Axboe13335dd2007-01-10 13:14:02 +0100458 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100459 .off1 = td_var_offset(create_serialize),
Jens Axboefd28ca42007-01-09 21:20:13 +0100460 .help = "Serialize creating of job files",
Jens Axboeee738492007-01-10 11:23:16 +0100461 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200462 },
463 {
464 .name = "create_fsync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100465 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100466 .off1 = td_var_offset(create_fsync),
Jens Axboefd28ca42007-01-09 21:20:13 +0100467 .help = "Fsync file after creation",
Jens Axboeee738492007-01-10 11:23:16 +0100468 .def = "1",
Jens Axboee1f36502006-10-27 10:54:08 +0200469 },
470 {
Jens Axboee1f36502006-10-27 10:54:08 +0200471 .name = "cpuload",
472 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100473 .off1 = td_var_offset(cpuload),
Jens Axboefd28ca42007-01-09 21:20:13 +0100474 .help = "Use this percentage of CPU",
Jens Axboee1f36502006-10-27 10:54:08 +0200475 },
476 {
477 .name = "cpuchunks",
478 .type = FIO_OPT_INT,
Jens Axboe13049232007-01-03 20:45:09 +0100479 .off1 = td_var_offset(cpucycle),
Jens Axboeba0fbe12007-03-09 14:34:23 +0100480 .help = "Length of the CPU burn cycles (usecs)",
481 .def = "50000",
Jens Axboee1f36502006-10-27 10:54:08 +0200482 },
Jens Axboee1f36502006-10-27 10:54:08 +0200483#ifdef FIO_HAVE_CPU_AFFINITY
484 {
485 .name = "cpumask",
486 .type = FIO_OPT_INT,
487 .cb = str_cpumask_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100488 .help = "CPU affinity mask",
Jens Axboee1f36502006-10-27 10:54:08 +0200489 },
490#endif
491 {
492 .name = "end_fsync",
Jens Axboe13335dd2007-01-10 13:14:02 +0100493 .type = FIO_OPT_BOOL,
Jens Axboe13049232007-01-03 20:45:09 +0100494 .off1 = td_var_offset(end_fsync),
Jens Axboefd28ca42007-01-09 21:20:13 +0100495 .help = "Include fsync at the end of job",
Jens Axboeee738492007-01-10 11:23:16 +0100496 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200497 },
498 {
499 .name = "unlink",
Jens Axboe13335dd2007-01-10 13:14:02 +0100500 .type = FIO_OPT_BOOL,
Jens Axboee1f36502006-10-27 10:54:08 +0200501 .off1 = td_var_offset(unlink),
Jens Axboeee738492007-01-10 11:23:16 +0100502 .help = "Unlink created files after job has completed",
Jens Axboee545a6c2007-01-14 00:00:29 +0100503 .def = "0",
Jens Axboee1f36502006-10-27 10:54:08 +0200504 },
505 {
506 .name = "exitall",
507 .type = FIO_OPT_STR_SET,
508 .cb = str_exitall_cb,
Jens Axboefd28ca42007-01-09 21:20:13 +0100509 .help = "Terminate all jobs when one exits",
Jens Axboee1f36502006-10-27 10:54:08 +0200510 },
511 {
512 .name = "stonewall",
513 .type = FIO_OPT_STR_SET,
514 .off1 = td_var_offset(stonewall),
Jens Axboefd28ca42007-01-09 21:20:13 +0100515 .help = "Insert a hard barrier between this job and previous",
Jens Axboee1f36502006-10-27 10:54:08 +0200516 },
517 {
518 .name = "thread",
519 .type = FIO_OPT_STR_SET,
Jens Axboed9bb3b82007-01-10 20:30:53 +0100520 .off1 = td_var_offset(use_thread),
Jens Axboefd28ca42007-01-09 21:20:13 +0100521 .help = "Use threads instead of forks",
Jens Axboee1f36502006-10-27 10:54:08 +0200522 },
523 {
524 .name = "write_bw_log",
525 .type = FIO_OPT_STR_SET,
526 .off1 = td_var_offset(write_bw_log),
Jens Axboefd28ca42007-01-09 21:20:13 +0100527 .help = "Write log of bandwidth during run",
Jens Axboee1f36502006-10-27 10:54:08 +0200528 },
529 {
530 .name = "write_lat_log",
531 .type = FIO_OPT_STR_SET,
532 .off1 = td_var_offset(write_lat_log),
Jens Axboefd28ca42007-01-09 21:20:13 +0100533 .help = "Write log of latency during run",
Jens Axboee1f36502006-10-27 10:54:08 +0200534 },
535 {
Jens Axboe56bb17f2006-12-20 20:27:36 +0100536 .name = "hugepage-size",
537 .type = FIO_OPT_STR_VAL,
538 .off1 = td_var_offset(hugepage_size),
Jens Axboefd28ca42007-01-09 21:20:13 +0100539 .help = "When using hugepages, specify size of each page",
Jens Axboeee738492007-01-10 11:23:16 +0100540 .def = __stringify(FIO_HUGE_PAGE),
Jens Axboe56bb17f2006-12-20 20:27:36 +0100541 },
542 {
Jens Axboeb2560f32007-03-06 12:43:03 +0100543 .name = "group_reporting",
544 .type = FIO_OPT_STR_SET,
545 .off1 = td_var_offset(group_reporting),
546 .help = "Do reporting on a per-group basis",
547 },
548 {
Jens Axboee1f36502006-10-27 10:54:08 +0200549 .name = NULL,
550 },
551};
552
Jens Axboeb4692822006-10-27 13:43:22 +0200553#define FIO_JOB_OPTS (sizeof(options) / sizeof(struct fio_option))
554#define FIO_CMD_OPTS (16)
555#define FIO_GETOPT_JOB (0x89988998)
556
557/*
558 * Command line options. These will contain the above, plus a few
559 * extra that only pertain to fio itself and not jobs.
560 */
561static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = {
562 {
563 .name = "output",
564 .has_arg = required_argument,
565 .val = 'o',
566 },
567 {
568 .name = "timeout",
569 .has_arg = required_argument,
570 .val = 't',
571 },
572 {
573 .name = "latency-log",
574 .has_arg = required_argument,
575 .val = 'l',
576 },
577 {
578 .name = "bandwidth-log",
579 .has_arg = required_argument,
580 .val = 'b',
581 },
582 {
583 .name = "minimal",
584 .has_arg = optional_argument,
585 .val = 'm',
586 },
587 {
588 .name = "version",
589 .has_arg = no_argument,
590 .val = 'v',
591 },
592 {
Jens Axboefd28ca42007-01-09 21:20:13 +0100593 .name = "help",
594 .has_arg = no_argument,
595 .val = 'h',
596 },
597 {
598 .name = "cmdhelp",
Jens Axboe320beef2007-03-01 10:44:12 +0100599 .has_arg = optional_argument,
Jens Axboefd28ca42007-01-09 21:20:13 +0100600 .val = 'c',
601 },
602 {
Jens Axboeb4692822006-10-27 13:43:22 +0200603 .name = NULL,
604 },
605};
606
Jens Axboeee738492007-01-10 11:23:16 +0100607static int def_timeout = 0;
Jens Axboe972cfd22006-06-09 11:08:56 +0200608
Jens Axboefdf3de22007-03-03 12:21:34 +0100609static char fio_version_string[] = "fio 1.13";
Jens Axboeebac4652005-12-08 15:25:21 +0100610
Jens Axboe972cfd22006-06-09 11:08:56 +0200611static char **ini_file;
Jens Axboeebac4652005-12-08 15:25:21 +0100612static int max_jobs = MAX_JOBS;
613
614struct thread_data def_thread;
615struct thread_data *threads = NULL;
616
Jens Axboeebac4652005-12-08 15:25:21 +0100617int exitall_on_terminate = 0;
Jens Axboec6ae0a52006-06-12 11:04:44 +0200618int terse_output = 0;
Jens Axboec04f7ec2006-05-31 10:13:16 +0200619unsigned long long mlock_size = 0;
Jens Axboeeb8bbf42006-06-08 21:40:11 +0200620FILE *f_out = NULL;
621FILE *f_err = NULL;
Jens Axboeebac4652005-12-08 15:25:21 +0100622
Jens Axboeee738492007-01-10 11:23:16 +0100623static int write_lat_log = 0;
Jens Axboebb3884d2007-01-17 17:23:11 +1100624int write_bw_log = 0;
Jens Axboeec94ec52006-10-20 10:59:19 +0200625
Joel Becker9728ce32007-03-01 08:24:39 +0100626FILE *get_f_out()
627{
628 return f_out;
629}
630
631FILE *get_f_err()
632{
633 return f_err;
634}
635
Jens Axboe906c8d72006-06-13 09:37:56 +0200636/*
637 * Return a free job structure.
638 */
Jens Axboeebac4652005-12-08 15:25:21 +0100639static struct thread_data *get_new_job(int global, struct thread_data *parent)
640{
641 struct thread_data *td;
642
643 if (global)
644 return &def_thread;
645 if (thread_number >= max_jobs)
646 return NULL;
647
648 td = &threads[thread_number++];
Jens Axboeddaeaa52006-06-08 11:00:58 +0200649 *td = *parent;
Jens Axboeebac4652005-12-08 15:25:21 +0100650
Jens Axboeebac4652005-12-08 15:25:21 +0100651 td->thread_number = thread_number;
Jens Axboeebac4652005-12-08 15:25:21 +0100652 return td;
653}
654
655static void put_job(struct thread_data *td)
656{
Jens Axboe549577a2006-10-30 12:23:41 +0100657 if (td == &def_thread)
658 return;
659
Jens Axboe16edf252007-02-10 14:59:22 +0100660 if (td->error)
661 fprintf(f_out, "fio: %s\n", td->verror);
662
Jens Axboeebac4652005-12-08 15:25:21 +0100663 memset(&threads[td->thread_number - 1], 0, sizeof(*td));
664 thread_number--;
665}
666
Jens Axboedad915e2006-10-27 11:10:18 +0200667/*
668 * Lazy way of fixing up options that depend on each other. We could also
669 * define option callback handlers, but this is easier.
670 */
Jens Axboee1f36502006-10-27 10:54:08 +0200671static void fixup_options(struct thread_data *td)
672{
Jens Axboee1f36502006-10-27 10:54:08 +0200673 if (!td->rwmixread && td->rwmixwrite)
674 td->rwmixread = 100 - td->rwmixwrite;
Jens Axboedad915e2006-10-27 11:10:18 +0200675
Jens Axboe076efc72006-10-27 11:24:25 +0200676 if (td->write_iolog_file && td->read_iolog_file) {
677 log_err("fio: read iolog overrides write_iolog\n");
678 free(td->write_iolog_file);
679 td->write_iolog_file = NULL;
680 }
Jens Axboe16b462a2006-10-30 12:35:18 +0100681
682 if (td->io_ops->flags & FIO_SYNCIO)
683 td->iodepth = 1;
684 else {
685 if (!td->iodepth)
Jens Axboeb5af8292007-03-08 12:43:13 +0100686 td->iodepth = td->open_files;
Jens Axboe16b462a2006-10-30 12:35:18 +0100687 }
688
689 /*
690 * only really works for sequential io for now, and with 1 file
691 */
Jens Axboeb5af8292007-03-08 12:43:13 +0100692 if (td->zone_size && td_random(td) && td->open_files == 1)
Jens Axboe16b462a2006-10-30 12:35:18 +0100693 td->zone_size = 0;
694
695 /*
696 * Reads can do overwrites, we always need to pre-create the file
697 */
698 if (td_read(td) || td_rw(td))
699 td->overwrite = 1;
700
Jens Axboea00735e2006-11-03 08:58:08 +0100701 if (!td->min_bs[DDIR_READ])
702 td->min_bs[DDIR_READ]= td->bs[DDIR_READ];
703 if (!td->max_bs[DDIR_READ])
704 td->max_bs[DDIR_READ] = td->bs[DDIR_READ];
705 if (!td->min_bs[DDIR_WRITE])
Jens Axboe75e6f362006-11-03 08:17:09 +0100706 td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE];
Jens Axboea00735e2006-11-03 08:58:08 +0100707 if (!td->max_bs[DDIR_WRITE])
Jens Axboe75e6f362006-11-03 08:17:09 +0100708 td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE];
Jens Axboea00735e2006-11-03 08:58:08 +0100709
710 td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
711
Jens Axboe16b462a2006-10-30 12:35:18 +0100712 if (td_read(td) && !td_rw(td))
713 td->verify = 0;
Jens Axboebb8895e2006-10-30 15:14:48 +0100714
715 if (td->norandommap && td->verify != VERIFY_NONE) {
716 log_err("fio: norandommap given, verify disabled\n");
717 td->verify = VERIFY_NONE;
718 }
Jens Axboe690adba2006-10-30 15:25:09 +0100719 if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO))
720 log_err("fio: bs_unaligned may not work with raw io\n");
Jens Axboee0a22332006-12-20 12:54:25 +0100721
722 /*
723 * O_DIRECT and char doesn't mix, clear that flag if necessary.
724 */
725 if (td->filetype == FIO_TYPE_CHAR && td->odirect)
726 td->odirect = 0;
Jens Axboe48097d52007-02-17 06:30:44 +0100727
728 /*
729 * thinktime_spin must be less than thinktime
730 */
731 if (td->thinktime_spin > td->thinktime)
732 td->thinktime_spin = td->thinktime;
Jens Axboee916b392007-02-20 14:37:26 +0100733
734 /*
735 * The low water mark cannot be bigger than the iodepth
736 */
Jens Axboe9467b772007-02-27 19:56:43 +0100737 if (td->iodepth_low > td->iodepth || !td->iodepth_low) {
738 /*
739 * syslet work around - if the workload is sequential,
740 * we want to let the queue drain all the way down to
741 * avoid seeking between async threads
742 */
743 if (!strcmp(td->io_ops->name, "syslet-rw") && !td_random(td))
744 td->iodepth_low = 1;
745 else
746 td->iodepth_low = td->iodepth;
747 }
Jens Axboecb5ab512007-02-26 12:57:09 +0100748
749 /*
750 * If batch number isn't set, default to the same as iodepth
751 */
752 if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
753 td->iodepth_batch = td->iodepth;
Jens Axboeb5af8292007-03-08 12:43:13 +0100754
755 if (td->open_files > td->nr_files || !td->open_files)
756 td->open_files = td->nr_files;
Jens Axboee1f36502006-10-27 10:54:08 +0200757}
758
Jens Axboe906c8d72006-06-13 09:37:56 +0200759/*
Jens Axboef8977ee2006-11-06 14:03:03 +0100760 * This function leaks the buffer
761 */
762static char *to_kmg(unsigned int val)
763{
764 char *buf = malloc(32);
Jens Axboef3502ba2007-02-14 01:27:09 +0100765 char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 };
Jens Axboef8977ee2006-11-06 14:03:03 +0100766 char *p = post;
767
Jens Axboe245142f2006-11-08 12:49:21 +0100768 do {
Jens Axboef8977ee2006-11-06 14:03:03 +0100769 if (val & 1023)
770 break;
771
772 val >>= 10;
773 p++;
Jens Axboe245142f2006-11-08 12:49:21 +0100774 } while (*p);
Jens Axboef8977ee2006-11-06 14:03:03 +0100775
776 snprintf(buf, 31, "%u%c", val, *p);
777 return buf;
778}
779
Jens Axboe09629a92007-03-09 09:00:06 +0100780/* External engines are specified by "external:name.o") */
781static const char *get_engine_name(const char *str)
782{
783 char *p = strstr(str, ":");
784
785 if (!p)
786 return str;
787
788 p++;
789 strip_blank_front(&p);
790 strip_blank_end(p);
791 return p;
792}
793
Jens Axboef8977ee2006-11-06 14:03:03 +0100794/*
Jens Axboe906c8d72006-06-13 09:37:56 +0200795 * Adds a job to the list of things todo. Sanitizes the various options
796 * to make sure we don't have conflicts, and initializes various
797 * members of td.
798 */
Jens Axboe75154842006-06-01 13:56:09 +0200799static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
Jens Axboeebac4652005-12-08 15:25:21 +0100800{
Jens Axboe413dd452007-02-23 09:26:09 +0100801 const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
802 "randread", "randwrite", "randrw" };
Jens Axboeebac4652005-12-08 15:25:21 +0100803 struct stat sb;
Jens Axboe413dd452007-02-23 09:26:09 +0100804 int numjobs, i;
Jens Axboe53cdc682006-10-18 11:50:58 +0200805 struct fio_file *f;
Jens Axboe09629a92007-03-09 09:00:06 +0100806 const char *engine;
Jens Axboeebac4652005-12-08 15:25:21 +0100807
Jens Axboeebac4652005-12-08 15:25:21 +0100808 /*
809 * the def_thread is just for options, it's not a real job
810 */
811 if (td == &def_thread)
812 return 0;
813
Jens Axboe09629a92007-03-09 09:00:06 +0100814 engine = get_engine_name(td->ioengine);
815 td->io_ops = load_ioengine(td, engine);
816 if (!td->io_ops) {
817 log_err("fio: failed to load engine %s\n", engine);
818 return 1;
819 }
Jens Axboedf641192006-10-12 07:55:41 +0200820
Jens Axboe9cedf162007-03-12 11:29:30 +0100821 if (td->use_thread)
822 nr_thread++;
823 else
824 nr_process++;
825
Jens Axboe690adba2006-10-30 15:25:09 +0100826 if (td->odirect)
827 td->io_ops->flags |= FIO_RAWIO;
828
Jens Axboe80be24f2007-03-12 11:01:25 +0100829 if (!td->filename)
830 td->filename = strdup(jobname);
831
Jens Axboeebac4652005-12-08 15:25:21 +0100832 td->filetype = FIO_TYPE_FILE;
Jens Axboe80be24f2007-03-12 11:01:25 +0100833 if (!lstat(td->filename, &sb)) {
Jens Axboe0af7b542006-02-17 10:10:12 +0100834 if (S_ISBLK(sb.st_mode))
835 td->filetype = FIO_TYPE_BD;
836 else if (S_ISCHR(sb.st_mode))
837 td->filetype = FIO_TYPE_CHAR;
838 }
Jens Axboeebac4652005-12-08 15:25:21 +0100839
Jens Axboee0a22332006-12-20 12:54:25 +0100840 fixup_options(td);
841
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200842 if (td->filename)
843 td->nr_uniq_files = 1;
844 else
Jens Axboe0f14fef2007-03-08 13:08:24 +0100845 td->nr_uniq_files = td->open_files;
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200846
847 if (td->filetype == FIO_TYPE_FILE || td->filename) {
Jens Axboee9c047a2006-06-07 21:13:04 +0200848 char tmp[PATH_MAX];
Jens Axboe53cdc682006-10-18 11:50:58 +0200849 int len = 0;
Jens Axboee9c047a2006-06-07 21:13:04 +0200850
Jens Axboe16edf252007-02-10 14:59:22 +0100851 if (td->directory && td->directory[0] != '\0') {
852 if (lstat(td->directory, &sb) < 0) {
853 log_err("fio: %s is not a directory\n", td->directory);
Jens Axboee1161c32007-02-22 19:36:48 +0100854 td_verror(td, errno, "lstat");
Jens Axboe16edf252007-02-10 14:59:22 +0100855 return 1;
856 }
857 if (!S_ISDIR(sb.st_mode)) {
858 log_err("fio: %s is not a directory\n", td->directory);
859 return 1;
860 }
Jens Axboe8aeebd52007-01-08 10:47:43 +0100861 len = sprintf(tmp, "%s/", td->directory);
Jens Axboe16edf252007-02-10 14:59:22 +0100862 }
Jens Axboeebac4652005-12-08 15:25:21 +0100863
Jens Axboeb5af8292007-03-08 12:43:13 +0100864 td->files = malloc(sizeof(struct fio_file) * td->open_files);
Jens Axboe53cdc682006-10-18 11:50:58 +0200865
866 for_each_file(td, f, i) {
867 memset(f, 0, sizeof(*f));
868 f->fd = -1;
869
Jens Axboe13f8e2d2006-10-24 09:29:45 +0200870 if (td->filename)
871 sprintf(tmp + len, "%s", td->filename);
872 else
873 sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
Jens Axboe53cdc682006-10-18 11:50:58 +0200874 f->file_name = strdup(tmp);
875 }
876 } else {
Jens Axboeb5af8292007-03-08 12:43:13 +0100877 td->open_files = td->nr_files = 1;
Jens Axboe53cdc682006-10-18 11:50:58 +0200878 td->files = malloc(sizeof(struct fio_file));
879 f = &td->files[0];
880
881 memset(f, 0, sizeof(*f));
882 f->fd = -1;
883 f->file_name = strdup(jobname);
884 }
885
886 for_each_file(td, f, i) {
887 f->file_size = td->total_file_size / td->nr_files;
888 f->file_offset = td->start_offset;
889 }
890
Jens Axboe07739b52007-03-08 20:25:46 +0100891 td->mutex = fio_sem_init(0);
Jens Axboeebac4652005-12-08 15:25:21 +0100892
Jens Axboe756867b2007-03-06 15:19:24 +0100893 td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
894 td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;
895 td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
Jens Axboeebac4652005-12-08 15:25:21 +0100896
Jens Axboeebac4652005-12-08 15:25:21 +0100897 if (td->stonewall && td->thread_number > 1)
898 groupid++;
899
900 td->groupid = groupid;
901
902 if (setup_rate(td))
903 goto err;
904
Jens Axboeec94ec52006-10-20 10:59:19 +0200905 if (td->write_lat_log) {
Jens Axboe756867b2007-03-06 15:19:24 +0100906 setup_log(&td->ts.slat_log);
907 setup_log(&td->ts.clat_log);
Jens Axboeebac4652005-12-08 15:25:21 +0100908 }
Jens Axboeec94ec52006-10-20 10:59:19 +0200909 if (td->write_bw_log)
Jens Axboe756867b2007-03-06 15:19:24 +0100910 setup_log(&td->ts.bw_log);
Jens Axboeebac4652005-12-08 15:25:21 +0100911
Jens Axboeb4692822006-10-27 13:43:22 +0200912 if (!td->name)
913 td->name = strdup(jobname);
Jens Axboe01452052006-06-07 10:29:47 +0200914
Jens Axboec6ae0a52006-06-12 11:04:44 +0200915 if (!terse_output) {
Jens Axboeb990b5c2006-09-14 09:48:22 +0200916 if (!job_add_num) {
Jens Axboeba0fbe12007-03-09 14:34:23 +0100917 if (!strcmp(td->io_ops->name, "cpuio"))
Jens Axboeb990b5c2006-09-14 09:48:22 +0200918 fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
Jens Axboef8977ee2006-11-06 14:03:03 +0100919 else {
920 char *c1, *c2, *c3, *c4;
921
922 c1 = to_kmg(td->min_bs[DDIR_READ]);
923 c2 = to_kmg(td->max_bs[DDIR_READ]);
924 c3 = to_kmg(td->min_bs[DDIR_WRITE]);
925 c4 = to_kmg(td->max_bs[DDIR_WRITE]);
926
Jens Axboe413dd452007-02-23 09:26:09 +0100927 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 +0100928
929 free(c1);
930 free(c2);
931 free(c3);
932 free(c4);
933 }
Jens Axboeb990b5c2006-09-14 09:48:22 +0200934 } else if (job_add_num == 1)
Jens Axboec6ae0a52006-06-12 11:04:44 +0200935 fprintf(f_out, "...\n");
936 }
Jens Axboeebac4652005-12-08 15:25:21 +0100937
938 /*
939 * recurse add identical jobs, clear numjobs and stonewall options
940 * as they don't apply to sub-jobs
941 */
942 numjobs = td->numjobs;
943 while (--numjobs) {
944 struct thread_data *td_new = get_new_job(0, td);
945
946 if (!td_new)
947 goto err;
948
949 td_new->numjobs = 1;
950 td_new->stonewall = 0;
Jens Axboe75154842006-06-01 13:56:09 +0200951 job_add_num = numjobs - 1;
Jens Axboeebac4652005-12-08 15:25:21 +0100952
Jens Axboe75154842006-06-01 13:56:09 +0200953 if (add_job(td_new, jobname, job_add_num))
Jens Axboeebac4652005-12-08 15:25:21 +0100954 goto err;
955 }
956 return 0;
957err:
958 put_job(td);
959 return -1;
960}
961
Jens Axboe906c8d72006-06-13 09:37:56 +0200962/*
963 * Initialize the various random states we need (random io, block size ranges,
964 * read/write mix, etc).
965 */
Jens Axboeebac4652005-12-08 15:25:21 +0100966int init_random_state(struct thread_data *td)
967{
Jens Axboe0aabe162007-02-23 08:45:55 +0100968 unsigned long seeds[5];
Jens Axboe53cdc682006-10-18 11:50:58 +0200969 int fd, num_maps, blocks, i;
Jens Axboe0ab8db82006-10-18 17:16:23 +0200970 struct fio_file *f;
Jens Axboeebac4652005-12-08 15:25:21 +0100971
Jens Axboeba0fbe12007-03-09 14:34:23 +0100972 if (td->io_ops->flags & FIO_DISKLESSIO)
Jens Axboef48b4672006-10-27 11:30:07 +0200973 return 0;
974
Jens Axboe1ac267b2006-05-31 20:29:00 +0200975 fd = open("/dev/urandom", O_RDONLY);
Jens Axboeebac4652005-12-08 15:25:21 +0100976 if (fd == -1) {
Jens Axboee1161c32007-02-22 19:36:48 +0100977 td_verror(td, errno, "open");
Jens Axboeebac4652005-12-08 15:25:21 +0100978 return 1;
979 }
980
Jens Axboea6ccc7b2006-06-02 10:14:15 +0200981 if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
Jens Axboee1161c32007-02-22 19:36:48 +0100982 td_verror(td, EIO, "read");
Jens Axboeebac4652005-12-08 15:25:21 +0100983 close(fd);
984 return 1;
985 }
986
987 close(fd);
988
Jens Axboe6dfd46b2006-06-07 13:57:06 +0200989 os_random_seed(seeds[0], &td->bsrange_state);
990 os_random_seed(seeds[1], &td->verify_state);
991 os_random_seed(seeds[2], &td->rwmix_state);
Jens Axboeebac4652005-12-08 15:25:21 +0100992
Jens Axboe413dd452007-02-23 09:26:09 +0100993 if (td->file_service_type == FIO_FSERVICE_RANDOM)
994 os_random_seed(seeds[3], &td->next_file_state);
995
996 if (!td_random(td))
Jens Axboeebac4652005-12-08 15:25:21 +0100997 return 0;
998
Jens Axboe9ebc27e2006-06-12 10:21:50 +0200999 if (td->rand_repeatable)
Jens Axboe0aabe162007-02-23 08:45:55 +01001000 seeds[4] = FIO_RANDSEED * td->thread_number;
Jens Axboeebac4652005-12-08 15:25:21 +01001001
Jens Axboebb8895e2006-10-30 15:14:48 +01001002 if (!td->norandommap) {
1003 for_each_file(td, f, i) {
Jens Axboea4a81712007-02-13 20:07:26 +01001004 blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
Jens Axboec7c280e2006-11-02 20:10:33 +01001005 num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
Jens Axboebb8895e2006-10-30 15:14:48 +01001006 f->file_map = malloc(num_maps * sizeof(long));
Jens Axboebda4fd92007-03-12 11:21:48 +01001007 if (!f->file_map) {
1008 log_err("fio: failed allocating random map. If running a large number of jobs, try the 'norandommap' option\n");
1009 return 1;
1010 }
Jens Axboebb8895e2006-10-30 15:14:48 +01001011 f->num_maps = num_maps;
1012 memset(f->file_map, 0, num_maps * sizeof(long));
1013 }
Jens Axboe53cdc682006-10-18 11:50:58 +02001014 }
Jens Axboeebac4652005-12-08 15:25:21 +01001015
Jens Axboe0aabe162007-02-23 08:45:55 +01001016 os_random_seed(seeds[4], &td->random_state);
Jens Axboeebac4652005-12-08 15:25:21 +01001017 return 0;
1018}
1019
1020static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu)
1021{
1022#ifdef FIO_HAVE_CPU_AFFINITY
1023 unsigned int i;
1024
1025 CPU_ZERO(&cpumask);
1026
1027 for (i = 0; i < sizeof(int) * 8; i++) {
1028 if ((1 << i) & cpu)
1029 CPU_SET(i, &cpumask);
1030 }
1031#endif
1032}
1033
Jens Axboeebac4652005-12-08 15:25:21 +01001034static int is_empty_or_comment(char *line)
1035{
1036 unsigned int i;
1037
1038 for (i = 0; i < strlen(line); i++) {
1039 if (line[i] == ';')
1040 return 1;
Ingo Molnar5cc2da32007-02-20 10:19:44 +01001041 if (line[i] == '#')
1042 return 1;
Jens Axboeebac4652005-12-08 15:25:21 +01001043 if (!isspace(line[i]) && !iscntrl(line[i]))
1044 return 0;
1045 }
1046
1047 return 1;
1048}
1049
Jens Axboe313cb202006-12-21 09:50:00 +01001050/*
1051 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
1052 */
Jens Axboe1907dbc2007-03-12 11:44:28 +01001053static char *get_opt_postfix(const char *str)
Jens Axboe313cb202006-12-21 09:50:00 +01001054{
1055 char *p = strstr(str, ":");
1056
1057 if (!p)
1058 return NULL;
1059
1060 p++;
1061 strip_blank_front(&p);
1062 strip_blank_end(p);
1063 return strdup(p);
1064}
1065
Jens Axboeb4692822006-10-27 13:43:22 +02001066static int str_mem_cb(void *data, const char *mem)
Jens Axboeebac4652005-12-08 15:25:21 +01001067{
Jens Axboecb2c86f2006-10-26 13:48:34 +02001068 struct thread_data *td = data;
1069
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001070 if (td->mem_type == MEM_MMAPHUGE || td->mem_type == MEM_MMAP) {
Jens Axboe1907dbc2007-03-12 11:44:28 +01001071 td->mmapfile = get_opt_postfix(mem);
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001072 if (td->mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboed0bdaf42006-12-20 14:40:44 +01001073 log_err("fio: mmaphuge:/path/to/file\n");
1074 return 1;
1075 }
Jens Axboeebac4652005-12-08 15:25:21 +01001076 }
1077
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001078 return 0;
Jens Axboeebac4652005-12-08 15:25:21 +01001079}
1080
Jens Axboee1f36502006-10-27 10:54:08 +02001081static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
1082{
1083 mlock_size = *val;
1084 return 0;
1085}
1086
Jens Axboe34cfcda2006-11-03 14:00:45 +01001087#ifdef FIO_HAVE_IOPRIO
Jens Axboee1f36502006-10-27 10:54:08 +02001088static int str_prioclass_cb(void *data, unsigned int *val)
1089{
1090 struct thread_data *td = data;
1091
1092 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
1093 return 0;
1094}
1095
1096static int str_prio_cb(void *data, unsigned int *val)
1097{
1098 struct thread_data *td = data;
1099
1100 td->ioprio |= *val;
1101 return 0;
1102}
Jens Axboe34cfcda2006-11-03 14:00:45 +01001103#endif
Jens Axboee1f36502006-10-27 10:54:08 +02001104
1105static int str_exitall_cb(void)
1106{
1107 exitall_on_terminate = 1;
1108 return 0;
1109}
1110
1111static int str_cpumask_cb(void *data, unsigned int *val)
1112{
1113 struct thread_data *td = data;
1114
1115 fill_cpu_mask(td->cpumask, *val);
1116 return 0;
1117}
1118
Jens Axboe1907dbc2007-03-12 11:44:28 +01001119static int str_fst_cb(void *data, const char *str)
1120{
1121 struct thread_data *td = data;
1122 char *nr = get_opt_postfix(str);
1123
1124 td->file_service_nr = 1;
1125 if (nr)
1126 td->file_service_nr = atoi(nr);
1127
1128 return 0;
1129}
1130
Jens Axboe07261982006-06-07 10:51:12 +02001131/*
1132 * This is our [ini] type file parser.
1133 */
Jens Axboe1e97cce2006-12-05 11:44:16 +01001134static int parse_jobs_ini(char *file, int stonewall_flag)
Jens Axboeebac4652005-12-08 15:25:21 +01001135{
Jens Axboee1f36502006-10-27 10:54:08 +02001136 unsigned int global;
Jens Axboeebac4652005-12-08 15:25:21 +01001137 struct thread_data *td;
Jens Axboefee3bb42006-10-30 13:32:08 +01001138 char *string, *name;
Jens Axboeebac4652005-12-08 15:25:21 +01001139 fpos_t off;
1140 FILE *f;
1141 char *p;
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001142 int ret = 0, stonewall;
Jens Axboeebac4652005-12-08 15:25:21 +01001143
1144 f = fopen(file, "r");
1145 if (!f) {
Jens Axboeaea47d42006-05-26 19:27:29 +02001146 perror("fopen job file");
Jens Axboeebac4652005-12-08 15:25:21 +01001147 return 1;
1148 }
1149
1150 string = malloc(4096);
1151 name = malloc(256);
Jens Axboefee3bb42006-10-30 13:32:08 +01001152 memset(name, 0, 256);
Jens Axboeebac4652005-12-08 15:25:21 +01001153
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001154 stonewall = stonewall_flag;
Jens Axboe7c124ac2006-10-30 13:36:52 +01001155 do {
1156 p = fgets(string, 4095, f);
1157 if (!p)
Jens Axboe45410ac2006-06-07 11:10:39 +02001158 break;
Jens Axboeebac4652005-12-08 15:25:21 +01001159 if (is_empty_or_comment(p))
1160 continue;
Jens Axboefee3bb42006-10-30 13:32:08 +01001161 if (sscanf(p, "[%255s]", name) != 1)
Jens Axboeebac4652005-12-08 15:25:21 +01001162 continue;
1163
1164 global = !strncmp(name, "global", 6);
1165
1166 name[strlen(name) - 1] = '\0';
1167
1168 td = get_new_job(global, &def_thread);
Jens Axboe45410ac2006-06-07 11:10:39 +02001169 if (!td) {
1170 ret = 1;
1171 break;
1172 }
Jens Axboeebac4652005-12-08 15:25:21 +01001173
Jens Axboe972cfd22006-06-09 11:08:56 +02001174 /*
1175 * Seperate multiple job files by a stonewall
1176 */
Jens Axboef9481912006-06-09 11:37:28 +02001177 if (!global && stonewall) {
Jens Axboe972cfd22006-06-09 11:08:56 +02001178 td->stonewall = stonewall;
1179 stonewall = 0;
1180 }
1181
Jens Axboeebac4652005-12-08 15:25:21 +01001182 fgetpos(f, &off);
1183 while ((p = fgets(string, 4096, f)) != NULL) {
1184 if (is_empty_or_comment(p))
1185 continue;
Jens Axboee1f36502006-10-27 10:54:08 +02001186
Jens Axboeb6754f92006-05-30 14:29:32 +02001187 strip_blank_front(&p);
Jens Axboe7c124ac2006-10-30 13:36:52 +01001188
1189 if (p[0] == '[')
1190 break;
1191
Jens Axboe4ae3f762006-05-30 13:35:14 +02001192 strip_blank_end(p);
Jens Axboeaea47d42006-05-26 19:27:29 +02001193
Jens Axboee1f36502006-10-27 10:54:08 +02001194 fgetpos(f, &off);
Jens Axboeebac4652005-12-08 15:25:21 +01001195
Jens Axboe45410ac2006-06-07 11:10:39 +02001196 /*
1197 * Don't break here, continue parsing options so we
1198 * dump all the bad ones. Makes trial/error fixups
1199 * easier on the user.
1200 */
Jens Axboe7c124ac2006-10-30 13:36:52 +01001201 ret |= parse_option(p, options, td);
Jens Axboeebac4652005-12-08 15:25:21 +01001202 }
Jens Axboeebac4652005-12-08 15:25:21 +01001203
Jens Axboe45410ac2006-06-07 11:10:39 +02001204 if (!ret) {
1205 fsetpos(f, &off);
1206 ret = add_job(td, name, 0);
Jens Axboeb1508cf2006-11-02 09:12:40 +01001207 } else {
1208 log_err("fio: job %s dropped\n", name);
1209 put_job(td);
Jens Axboe45410ac2006-06-07 11:10:39 +02001210 }
Jens Axboe7c124ac2006-10-30 13:36:52 +01001211 } while (!ret);
Jens Axboeebac4652005-12-08 15:25:21 +01001212
1213 free(string);
1214 free(name);
1215 fclose(f);
Jens Axboe45410ac2006-06-07 11:10:39 +02001216 return ret;
Jens Axboeebac4652005-12-08 15:25:21 +01001217}
1218
1219static int fill_def_thread(void)
1220{
1221 memset(&def_thread, 0, sizeof(def_thread));
1222
1223 if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) {
1224 perror("sched_getaffinity");
1225 return 1;
1226 }
1227
1228 /*
Jens Axboeee738492007-01-10 11:23:16 +01001229 * fill default options
Jens Axboeebac4652005-12-08 15:25:21 +01001230 */
Jens Axboeee738492007-01-10 11:23:16 +01001231 fill_default_options(&def_thread, options);
1232
Jens Axboe972cfd22006-06-09 11:08:56 +02001233 def_thread.timeout = def_timeout;
Jens Axboeec94ec52006-10-20 10:59:19 +02001234 def_thread.write_bw_log = write_bw_log;
1235 def_thread.write_lat_log = write_lat_log;
Jens Axboeee738492007-01-10 11:23:16 +01001236
Jens Axboeebac4652005-12-08 15:25:21 +01001237#ifdef FIO_HAVE_DISK_UTIL
1238 def_thread.do_disk_util = 1;
1239#endif
1240
1241 return 0;
1242}
1243
Jens Axboe0ab8db82006-10-18 17:16:23 +02001244static void usage(void)
Jens Axboe4785f992006-05-26 03:59:10 +02001245{
1246 printf("%s\n", fio_version_string);
Jens Axboeb4692822006-10-27 13:43:22 +02001247 printf("\t--output\tWrite output to file\n");
1248 printf("\t--timeout\tRuntime in seconds\n");
1249 printf("\t--latency-log\tGenerate per-job latency logs\n");
1250 printf("\t--bandwidth-log\tGenerate per-job bandwidth logs\n");
1251 printf("\t--minimal\tMinimal (terse) output\n");
1252 printf("\t--version\tPrint version info and exit\n");
Jens Axboefd28ca42007-01-09 21:20:13 +01001253 printf("\t--help\t\tPrint this page\n");
1254 printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n");
Jens Axboe4785f992006-05-26 03:59:10 +02001255}
1256
Jens Axboe972cfd22006-06-09 11:08:56 +02001257static int parse_cmd_line(int argc, char *argv[])
Jens Axboeebac4652005-12-08 15:25:21 +01001258{
Jens Axboeb4692822006-10-27 13:43:22 +02001259 struct thread_data *td = NULL;
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001260 int c, ini_idx = 0, lidx, ret, dont_add_job = 0;
Jens Axboeebac4652005-12-08 15:25:21 +01001261
Jens Axboe0be06ea2007-03-01 14:23:28 +01001262 while ((c = getopt_long_only(argc, argv, "", long_options, &lidx)) != -1) {
Jens Axboeebac4652005-12-08 15:25:21 +01001263 switch (c) {
Jens Axboeb4692822006-10-27 13:43:22 +02001264 case 't':
1265 def_timeout = atoi(optarg);
1266 break;
1267 case 'l':
1268 write_lat_log = 1;
1269 break;
1270 case 'w':
1271 write_bw_log = 1;
1272 break;
1273 case 'o':
1274 f_out = fopen(optarg, "w+");
1275 if (!f_out) {
1276 perror("fopen output");
1277 exit(1);
1278 }
1279 f_err = f_out;
1280 break;
1281 case 'm':
1282 terse_output = 1;
1283 break;
1284 case 'h':
1285 usage();
1286 exit(0);
Jens Axboefd28ca42007-01-09 21:20:13 +01001287 case 'c':
Jens Axboe29fc6af2007-01-09 21:22:02 +01001288 ret = show_cmd_help(options, optarg);
1289 exit(ret);
Jens Axboeb4692822006-10-27 13:43:22 +02001290 case 'v':
1291 printf("%s\n", fio_version_string);
1292 exit(0);
1293 case FIO_GETOPT_JOB: {
1294 const char *opt = long_options[lidx].name;
1295 char *val = optarg;
1296
Jens Axboec2b1e752006-10-30 09:03:13 +01001297 if (!strncmp(opt, "name", 4) && td) {
1298 ret = add_job(td, td->name ?: "fio", 0);
1299 if (ret) {
1300 put_job(td);
1301 return 0;
1302 }
1303 td = NULL;
1304 }
Jens Axboeb4692822006-10-27 13:43:22 +02001305 if (!td) {
Jens Axboe38d0adb2006-10-30 12:21:25 +01001306 int global = !strncmp(val, "global", 6);
Jens Axboec2b1e752006-10-30 09:03:13 +01001307
1308 td = get_new_job(global, &def_thread);
Jens Axboeb4692822006-10-27 13:43:22 +02001309 if (!td)
1310 return 0;
1311 }
Jens Axboe38d0adb2006-10-30 12:21:25 +01001312
Jens Axboeb1508cf2006-11-02 09:12:40 +01001313 ret = parse_cmd_option(opt, val, options, td);
Jens Axboe78217df2007-02-23 11:18:30 +01001314 if (ret)
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001315 dont_add_job = 1;
Jens Axboeb4692822006-10-27 13:43:22 +02001316 break;
1317 }
1318 default:
Jens Axboeb4692822006-10-27 13:43:22 +02001319 break;
Jens Axboeebac4652005-12-08 15:25:21 +01001320 }
1321 }
Jens Axboec9fad892006-05-27 17:26:50 +02001322
Jens Axboeb4692822006-10-27 13:43:22 +02001323 if (td) {
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001324 if (dont_add_job)
Jens Axboeb4692822006-10-27 13:43:22 +02001325 put_job(td);
Jens Axboeb1ec1da2007-02-23 10:29:16 +01001326 else {
1327 ret = add_job(td, td->name ?: "fio", 0);
1328 if (ret)
1329 put_job(td);
1330 }
Jens Axboe972cfd22006-06-09 11:08:56 +02001331 }
Jens Axboe774a6172006-08-24 08:44:26 +02001332
Jens Axboeb4692822006-10-27 13:43:22 +02001333 while (optind < argc) {
1334 ini_idx++;
1335 ini_file = realloc(ini_file, ini_idx * sizeof(char *));
1336 ini_file[ini_idx - 1] = strdup(argv[optind]);
1337 optind++;
Jens Axboeeb8bbf42006-06-08 21:40:11 +02001338 }
Jens Axboe972cfd22006-06-09 11:08:56 +02001339
1340 return ini_idx;
Jens Axboeebac4652005-12-08 15:25:21 +01001341}
1342
1343static void free_shm(void)
1344{
1345 struct shmid_ds sbuf;
1346
1347 if (threads) {
Jens Axboe2c0ecd22006-06-08 13:25:41 +02001348 shmdt((void *) threads);
Jens Axboeebac4652005-12-08 15:25:21 +01001349 threads = NULL;
1350 shmctl(shm_id, IPC_RMID, &sbuf);
1351 }
1352}
1353
Jens Axboe906c8d72006-06-13 09:37:56 +02001354/*
1355 * The thread area is shared between the main process and the job
1356 * threads/processes. So setup a shared memory segment that will hold
1357 * all the job info.
1358 */
Jens Axboeebac4652005-12-08 15:25:21 +01001359static int setup_thread_area(void)
1360{
1361 /*
1362 * 1024 is too much on some machines, scale max_jobs if
1363 * we get a failure that looks like too large a shm segment
1364 */
1365 do {
Jens Axboe906c8d72006-06-13 09:37:56 +02001366 size_t size = max_jobs * sizeof(struct thread_data);
Jens Axboeebac4652005-12-08 15:25:21 +01001367
Jens Axboe906c8d72006-06-13 09:37:56 +02001368 shm_id = shmget(0, size, IPC_CREAT | 0600);
Jens Axboeebac4652005-12-08 15:25:21 +01001369 if (shm_id != -1)
1370 break;
1371 if (errno != EINVAL) {
1372 perror("shmget");
1373 break;
1374 }
1375
1376 max_jobs >>= 1;
1377 } while (max_jobs);
1378
1379 if (shm_id == -1)
1380 return 1;
1381
1382 threads = shmat(shm_id, NULL, 0);
1383 if (threads == (void *) -1) {
1384 perror("shmat");
1385 return 1;
1386 }
1387
1388 atexit(free_shm);
1389 return 0;
1390}
1391
Jens Axboeb4692822006-10-27 13:43:22 +02001392/*
1393 * Copy the fio options into the long options map, so we mirror
1394 * job and cmd line options.
1395 */
1396static void dupe_job_options(void)
1397{
1398 struct fio_option *o;
1399 unsigned int i;
1400
1401 i = 0;
1402 while (long_options[i].name)
1403 i++;
1404
1405 o = &options[0];
1406 while (o->name) {
1407 long_options[i].name = o->name;
1408 long_options[i].val = FIO_GETOPT_JOB;
1409 if (o->type == FIO_OPT_STR_SET)
1410 long_options[i].has_arg = no_argument;
1411 else
1412 long_options[i].has_arg = required_argument;
1413
1414 i++;
1415 o++;
1416 assert(i < FIO_JOB_OPTS + FIO_CMD_OPTS);
1417 }
1418}
1419
Jens Axboeebac4652005-12-08 15:25:21 +01001420int parse_options(int argc, char *argv[])
1421{
Jens Axboe972cfd22006-06-09 11:08:56 +02001422 int job_files, i;
1423
Jens Axboeb4692822006-10-27 13:43:22 +02001424 f_out = stdout;
1425 f_err = stderr;
1426
Jens Axboe13335dd2007-01-10 13:14:02 +01001427 options_init(options);
1428
Jens Axboeb4692822006-10-27 13:43:22 +02001429 dupe_job_options();
1430
Jens Axboeebac4652005-12-08 15:25:21 +01001431 if (setup_thread_area())
1432 return 1;
1433 if (fill_def_thread())
1434 return 1;
1435
Jens Axboe972cfd22006-06-09 11:08:56 +02001436 job_files = parse_cmd_line(argc, argv);
Jens Axboeebac4652005-12-08 15:25:21 +01001437
Jens Axboe972cfd22006-06-09 11:08:56 +02001438 for (i = 0; i < job_files; i++) {
1439 if (fill_def_thread())
1440 return 1;
Jens Axboe0c7e37a2006-06-13 14:53:38 +02001441 if (parse_jobs_ini(ini_file[i], i))
Jens Axboe972cfd22006-06-09 11:08:56 +02001442 return 1;
Jens Axboe88c6ed82006-06-09 11:28:10 +02001443 free(ini_file[i]);
Jens Axboe972cfd22006-06-09 11:08:56 +02001444 }
Jens Axboeebac4652005-12-08 15:25:21 +01001445
Jens Axboe88c6ed82006-06-09 11:28:10 +02001446 free(ini_file);
Jens Axboeb4692822006-10-27 13:43:22 +02001447
1448 if (!thread_number) {
1449 log_err("No jobs defined(s)\n");
Jens Axboeb4692822006-10-27 13:43:22 +02001450 return 1;
1451 }
1452
Jens Axboeebac4652005-12-08 15:25:21 +01001453 return 0;
1454}