Speedup init_disk_util() when dealing with many jobs
[fio.git] / init.c
CommitLineData
906c8d75 1/*
cb2c86fd 2 * This file contains job initialization and setup functions.
906c8d75 3 */
ebac4655
JA
4#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>
b4692828
JA
11#include <getopt.h>
12#include <assert.h>
ebac4655
JA
13#include <sys/ipc.h>
14#include <sys/shm.h>
15#include <sys/types.h>
16#include <sys/stat.h>
17
18#include "fio.h"
cb2c86fd 19#include "parse.h"
ebac4655 20
ee738499 21#define FIO_RANDSEED (0xb1899bedUL)
ebac4655 22
e1f36503
JA
23#define td_var_offset(var) ((size_t) &((struct thread_data *)0)->var)
24
b4692828
JA
25static int str_ioengine_cb(void *, const char *);
26static int str_mem_cb(void *, const char *);
e1f36503 27static int str_lockmem_cb(void *, unsigned long *);
34cfcdaf 28#ifdef FIO_HAVE_IOPRIO
e1f36503
JA
29static int str_prio_cb(void *, unsigned int *);
30static int str_prioclass_cb(void *, unsigned int *);
34cfcdaf 31#endif
e1f36503
JA
32static int str_exitall_cb(void);
33static int str_cpumask_cb(void *, unsigned int *);
34
ee738499
JA
35#define __stringify_1(x) #x
36#define __stringify(x) __stringify_1(x)
37
e1f36503
JA
38/*
39 * Map of job/command line options
40 */
41static struct fio_option options[] = {
61697c37
JA
42 {
43 .name = "description",
44 .type = FIO_OPT_STR_STORE,
45 .off1 = td_var_offset(description),
46 .help = "Text job description",
47 },
e1f36503
JA
48 {
49 .name = "name",
50 .type = FIO_OPT_STR_STORE,
51 .off1 = td_var_offset(name),
fd28ca49 52 .help = "Name of this job",
e1f36503
JA
53 },
54 {
55 .name = "directory",
56 .type = FIO_OPT_STR_STORE,
57 .off1 = td_var_offset(directory),
fd28ca49 58 .help = "Directory to store files in",
e1f36503
JA
59 },
60 {
61 .name = "filename",
62 .type = FIO_OPT_STR_STORE,
63 .off1 = td_var_offset(filename),
fd28ca49 64 .help = "Force the use of a specific file",
e1f36503
JA
65 },
66 {
67 .name = "rw",
68 .type = FIO_OPT_STR,
b1ec1da6 69 .off1 = td_var_offset(td_ddir),
15f7918f 70 .help = "IO direction",
ee738499 71 .def = "read",
b1ec1da6
JA
72 .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 },
e1f36503
JA
80 },
81 {
82 .name = "ioengine",
83 .type = FIO_OPT_STR,
84 .cb = str_ioengine_cb,
15f7918f 85 .help = "IO engine to use",
ee738499 86 .def = "sync",
b1ec1da6 87 .posval = {
10cad1aa
JA
88 { .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
b1ec1da6 102 { .ival = "null", }, { .ival = "net", },
10cad1aa 103#ifdef FIO_HAVE_SYSLET
b1ec1da6 104 { .ival = "syslet-rw", },
10cad1aa 105#endif
b1ec1da6 106 },
e1f36503 107 },
03b74b3e
JA
108 {
109 .name = "iodepth",
110 .type = FIO_OPT_INT,
111 .off1 = td_var_offset(iodepth),
112 .help = "Amount of IO buffers to keep in flight",
113 .def = "1",
114 },
e916b390
JA
115 {
116 .name = "iodepth_low",
117 .type = FIO_OPT_INT,
118 .off1 = td_var_offset(iodepth_low),
119 .help = "Low water mark for queuing depth",
120 },
03b74b3e
JA
121 {
122 .name = "size",
123 .type = FIO_OPT_STR_VAL,
124 .off1 = td_var_offset(total_file_size),
125 .help = "Size of device or file",
126 },
127 {
128 .name = "bs",
129 .type = FIO_OPT_STR_VAL_INT,
130 .off1 = td_var_offset(bs[DDIR_READ]),
131 .off2 = td_var_offset(bs[DDIR_WRITE]),
132 .help = "Block size unit",
133 .def = "4k",
134 },
135 {
136 .name = "bsrange",
137 .type = FIO_OPT_RANGE,
138 .off1 = td_var_offset(min_bs[DDIR_READ]),
139 .off2 = td_var_offset(max_bs[DDIR_READ]),
140 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
141 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
142 .help = "Set block size range (in more detail than bs)",
143 },
144 {
145 .name = "bs_unaligned",
146 .type = FIO_OPT_STR_SET,
147 .off1 = td_var_offset(bs_unaligned),
148 .help = "Don't sector align IO buffer sizes",
149 },
150 {
151 .name = "offset",
152 .type = FIO_OPT_STR_VAL,
153 .off1 = td_var_offset(start_offset),
154 .help = "Start IO from this offset",
155 .def = "0",
156 },
157 {
158 .name = "randrepeat",
159 .type = FIO_OPT_BOOL,
160 .off1 = td_var_offset(rand_repeatable),
161 .help = "Use repeatable random IO pattern",
162 .def = "1",
163 },
164 {
165 .name = "norandommap",
166 .type = FIO_OPT_STR_SET,
167 .off1 = td_var_offset(norandommap),
168 .help = "Accept potential duplicate random blocks",
169 },
170 {
171 .name = "nrfiles",
172 .type = FIO_OPT_INT,
173 .off1 = td_var_offset(nr_files),
174 .help = "Split job workload between this number of files",
175 .def = "1",
176 },
0aabe160
JA
177 {
178 .name = "file_service_type",
179 .type = FIO_OPT_STR,
b1ec1da6 180 .off1 = td_var_offset(file_service_type),
0aabe160
JA
181 .help = "How to select which file to service next",
182 .def = "roundrobin",
b1ec1da6
JA
183 .posval = {
184 { .ival = "random", .oval = FIO_FSERVICE_RANDOM },
185 { .ival = "roundrobin", .oval = FIO_FSERVICE_RR },
186 },
0aabe160 187 },
03b74b3e
JA
188 {
189 .name = "fsync",
190 .type = FIO_OPT_INT,
191 .off1 = td_var_offset(fsync_blocks),
192 .help = "Issue fsync for writes every given number of blocks",
193 .def = "0",
194 },
195 {
196 .name = "direct",
197 .type = FIO_OPT_BOOL,
198 .off1 = td_var_offset(odirect),
76a43db4
JA
199 .help = "Use O_DIRECT IO (negates buffered)",
200 .def = "0",
201 },
202 {
203 .name = "buffered",
204 .type = FIO_OPT_BOOL,
205 .off1 = td_var_offset(odirect),
206 .neg = 1,
207 .help = "Use buffered IO (negates direct)",
03b74b3e
JA
208 .def = "1",
209 },
210 {
211 .name = "overwrite",
212 .type = FIO_OPT_BOOL,
213 .off1 = td_var_offset(overwrite),
214 .help = "When writing, set whether to overwrite current data",
215 .def = "0",
216 },
217 {
218 .name = "loops",
219 .type = FIO_OPT_INT,
220 .off1 = td_var_offset(loops),
221 .help = "Number of times to run the job",
222 .def = "1",
223 },
224 {
225 .name = "numjobs",
226 .type = FIO_OPT_INT,
227 .off1 = td_var_offset(numjobs),
228 .help = "Duplicate this job this many times",
229 .def = "1",
230 },
231 {
232 .name = "startdelay",
233 .type = FIO_OPT_INT,
234 .off1 = td_var_offset(start_delay),
235 .help = "Only start job when this period has passed",
236 .def = "0",
237 },
238 {
239 .name = "runtime",
240 .alias = "timeout",
241 .type = FIO_OPT_STR_VAL_TIME,
242 .off1 = td_var_offset(timeout),
243 .help = "Stop workload when this amount of time has passed",
244 .def = "0",
245 },
e1f36503
JA
246 {
247 .name = "mem",
248 .type = FIO_OPT_STR,
249 .cb = str_mem_cb,
b1ec1da6 250 .off1 = td_var_offset(mem_type),
15f7918f 251 .help = "Backing type for IO buffers",
ee738499 252 .def = "malloc",
b1ec1da6
JA
253 .posval = {
254 { .ival = "malloc", .oval = MEM_MALLOC },
255 { .ival = "shm", .oval = MEM_SHM },
256#ifdef FIO_HAVE_HUGETLB
257 { .ival = "shmhuge", .oval = MEM_SHMHUGE },
258#endif
259 { .ival = "mmap", .oval = MEM_MMAP },
260#ifdef FIO_HAVE_HUGETLB
261 { .ival = "mmaphuge", .oval = MEM_MMAPHUGE },
262#endif
263 },
e1f36503
JA
264 },
265 {
266 .name = "verify",
267 .type = FIO_OPT_STR,
b1ec1da6 268 .off1 = td_var_offset(verify),
15f7918f 269 .help = "Verify sum function",
ee738499 270 .def = "0",
b1ec1da6
JA
271 .posval = {
272 { .ival = "0", .oval = VERIFY_NONE },
273 { .ival = "crc32", .oval = VERIFY_CRC32 },
274 { .ival = "md5", .oval = VERIFY_MD5 },
275 },
e1f36503
JA
276 },
277 {
278 .name = "write_iolog",
076efc7c
JA
279 .type = FIO_OPT_STR_STORE,
280 .off1 = td_var_offset(write_iolog_file),
fd28ca49 281 .help = "Store IO pattern to file",
e1f36503
JA
282 },
283 {
076efc7c 284 .name = "read_iolog",
e1f36503 285 .type = FIO_OPT_STR_STORE,
076efc7c 286 .off1 = td_var_offset(read_iolog_file),
fd28ca49 287 .help = "Playback IO pattern from file",
e1f36503
JA
288 },
289 {
290 .name = "exec_prerun",
291 .type = FIO_OPT_STR_STORE,
292 .off1 = td_var_offset(exec_prerun),
fd28ca49 293 .help = "Execute this file prior to running job",
e1f36503
JA
294 },
295 {
296 .name = "exec_postrun",
297 .type = FIO_OPT_STR_STORE,
298 .off1 = td_var_offset(exec_postrun),
fd28ca49 299 .help = "Execute this file after running job",
e1f36503
JA
300 },
301#ifdef FIO_HAVE_IOSCHED_SWITCH
302 {
303 .name = "ioscheduler",
304 .type = FIO_OPT_STR_STORE,
305 .off1 = td_var_offset(ioscheduler),
fd28ca49 306 .help = "Use this IO scheduler on the backing device",
e1f36503
JA
307 },
308#endif
e1f36503
JA
309 {
310 .name = "zonesize",
311 .type = FIO_OPT_STR_VAL,
312 .off1 = td_var_offset(zone_size),
fd28ca49 313 .help = "Give size of an IO zone",
ee738499 314 .def = "0",
e1f36503
JA
315 },
316 {
317 .name = "zoneskip",
318 .type = FIO_OPT_STR_VAL,
319 .off1 = td_var_offset(zone_skip),
fd28ca49 320 .help = "Space between IO zones",
ee738499 321 .def = "0",
e1f36503
JA
322 },
323 {
324 .name = "lockmem",
325 .type = FIO_OPT_STR_VAL,
326 .cb = str_lockmem_cb,
fd28ca49 327 .help = "Lock down this amount of memory",
ee738499 328 .def = "0",
e1f36503 329 },
e1f36503
JA
330 {
331 .name = "rwmixcycle",
332 .type = FIO_OPT_INT,
333 .off1 = td_var_offset(rwmixcycle),
ee738499
JA
334 .help = "Cycle period for mixed read/write workloads (msec)",
335 .def = "500",
e1f36503
JA
336 },
337 {
338 .name = "rwmixread",
339 .type = FIO_OPT_INT,
340 .off1 = td_var_offset(rwmixread),
ee738499 341 .maxval = 100,
fd28ca49 342 .help = "Percentage of mixed workload that is reads",
ee738499 343 .def = "50",
e1f36503
JA
344 },
345 {
346 .name = "rwmixwrite",
347 .type = FIO_OPT_INT,
348 .off1 = td_var_offset(rwmixwrite),
ee738499 349 .maxval = 100,
fd28ca49 350 .help = "Percentage of mixed workload that is writes",
ee738499 351 .def = "50",
e1f36503
JA
352 },
353 {
354 .name = "nice",
355 .type = FIO_OPT_INT,
356 .off1 = td_var_offset(nice),
fd28ca49 357 .help = "Set job CPU nice value",
15f7918f 358 .minval = -19,
ee738499
JA
359 .maxval = 20,
360 .def = "0",
e1f36503
JA
361 },
362#ifdef FIO_HAVE_IOPRIO
363 {
364 .name = "prio",
365 .type = FIO_OPT_INT,
366 .cb = str_prio_cb,
fd28ca49 367 .help = "Set job IO priority value",
15f7918f
JA
368 .minval = 0,
369 .maxval = 7,
e1f36503
JA
370 },
371 {
372 .name = "prioclass",
373 .type = FIO_OPT_INT,
374 .cb = str_prioclass_cb,
fd28ca49 375 .help = "Set job IO priority class",
15f7918f
JA
376 .minval = 0,
377 .maxval = 3,
e1f36503
JA
378 },
379#endif
380 {
381 .name = "thinktime",
382 .type = FIO_OPT_INT,
1304923a 383 .off1 = td_var_offset(thinktime),
5fa0f817 384 .help = "Idle time between IO buffers (usec)",
ee738499 385 .def = "0",
e1f36503 386 },
48097d5c
JA
387 {
388 .name = "thinktime_spin",
389 .type = FIO_OPT_INT,
390 .off1 = td_var_offset(thinktime_spin),
391 .help = "Start thinktime by spinning this amount (usec)",
392 .def = "0",
393 },
9c1f7434
JA
394 {
395 .name = "thinktime_blocks",
396 .type = FIO_OPT_INT,
1304923a 397 .off1 = td_var_offset(thinktime_blocks),
fd28ca49 398 .help = "IO buffer period between 'thinktime'",
ee738499 399 .def = "1",
9c1f7434 400 },
e1f36503
JA
401 {
402 .name = "rate",
403 .type = FIO_OPT_INT,
1304923a 404 .off1 = td_var_offset(rate),
fd28ca49 405 .help = "Set bandwidth rate",
e1f36503
JA
406 },
407 {
408 .name = "ratemin",
409 .type = FIO_OPT_INT,
1304923a 410 .off1 = td_var_offset(ratemin),
fd28ca49 411 .help = "The bottom limit accepted",
e1f36503
JA
412 },
413 {
414 .name = "ratecycle",
415 .type = FIO_OPT_INT,
1304923a 416 .off1 = td_var_offset(ratecycle),
6da1fa7f 417 .help = "Window average for rate limits (msec)",
ee738499 418 .def = "1000",
e1f36503 419 },
e1f36503
JA
420 {
421 .name = "invalidate",
13335ddb 422 .type = FIO_OPT_BOOL,
1304923a 423 .off1 = td_var_offset(invalidate_cache),
fd28ca49 424 .help = "Invalidate buffer/page cache prior to running job",
ee738499 425 .def = "1",
e1f36503
JA
426 },
427 {
428 .name = "sync",
13335ddb 429 .type = FIO_OPT_BOOL,
1304923a 430 .off1 = td_var_offset(sync_io),
fd28ca49 431 .help = "Use O_SYNC for buffered writes",
ee738499 432 .def = "0",
e1f36503
JA
433 },
434 {
435 .name = "bwavgtime",
436 .type = FIO_OPT_INT,
1304923a 437 .off1 = td_var_offset(bw_avg_time),
ee738499
JA
438 .help = "Time window over which to calculate bandwidth (msec)",
439 .def = "500",
e1f36503
JA
440 },
441 {
442 .name = "create_serialize",
13335ddb 443 .type = FIO_OPT_BOOL,
1304923a 444 .off1 = td_var_offset(create_serialize),
fd28ca49 445 .help = "Serialize creating of job files",
ee738499 446 .def = "1",
e1f36503
JA
447 },
448 {
449 .name = "create_fsync",
13335ddb 450 .type = FIO_OPT_BOOL,
1304923a 451 .off1 = td_var_offset(create_fsync),
fd28ca49 452 .help = "Fsync file after creation",
ee738499 453 .def = "1",
e1f36503 454 },
e1f36503
JA
455 {
456 .name = "cpuload",
457 .type = FIO_OPT_INT,
1304923a 458 .off1 = td_var_offset(cpuload),
fd28ca49 459 .help = "Use this percentage of CPU",
e1f36503
JA
460 },
461 {
462 .name = "cpuchunks",
463 .type = FIO_OPT_INT,
1304923a 464 .off1 = td_var_offset(cpucycle),
fd28ca49 465 .help = "Length of the CPU burn cycles",
e1f36503 466 },
e1f36503
JA
467#ifdef FIO_HAVE_CPU_AFFINITY
468 {
469 .name = "cpumask",
470 .type = FIO_OPT_INT,
471 .cb = str_cpumask_cb,
fd28ca49 472 .help = "CPU affinity mask",
e1f36503
JA
473 },
474#endif
475 {
476 .name = "end_fsync",
13335ddb 477 .type = FIO_OPT_BOOL,
1304923a 478 .off1 = td_var_offset(end_fsync),
fd28ca49 479 .help = "Include fsync at the end of job",
ee738499 480 .def = "0",
e1f36503
JA
481 },
482 {
483 .name = "unlink",
13335ddb 484 .type = FIO_OPT_BOOL,
e1f36503 485 .off1 = td_var_offset(unlink),
ee738499 486 .help = "Unlink created files after job has completed",
e545a6ce 487 .def = "0",
e1f36503
JA
488 },
489 {
490 .name = "exitall",
491 .type = FIO_OPT_STR_SET,
492 .cb = str_exitall_cb,
fd28ca49 493 .help = "Terminate all jobs when one exits",
e1f36503
JA
494 },
495 {
496 .name = "stonewall",
497 .type = FIO_OPT_STR_SET,
498 .off1 = td_var_offset(stonewall),
fd28ca49 499 .help = "Insert a hard barrier between this job and previous",
e1f36503
JA
500 },
501 {
502 .name = "thread",
503 .type = FIO_OPT_STR_SET,
d9bb3b80 504 .off1 = td_var_offset(use_thread),
fd28ca49 505 .help = "Use threads instead of forks",
e1f36503
JA
506 },
507 {
508 .name = "write_bw_log",
509 .type = FIO_OPT_STR_SET,
510 .off1 = td_var_offset(write_bw_log),
fd28ca49 511 .help = "Write log of bandwidth during run",
e1f36503
JA
512 },
513 {
514 .name = "write_lat_log",
515 .type = FIO_OPT_STR_SET,
516 .off1 = td_var_offset(write_lat_log),
fd28ca49 517 .help = "Write log of latency during run",
e1f36503 518 },
56bb17f2
JA
519 {
520 .name = "hugepage-size",
521 .type = FIO_OPT_STR_VAL,
522 .off1 = td_var_offset(hugepage_size),
fd28ca49 523 .help = "When using hugepages, specify size of each page",
ee738499 524 .def = __stringify(FIO_HUGE_PAGE),
56bb17f2 525 },
e1f36503
JA
526 {
527 .name = NULL,
528 },
529};
530
b4692828
JA
531#define FIO_JOB_OPTS (sizeof(options) / sizeof(struct fio_option))
532#define FIO_CMD_OPTS (16)
533#define FIO_GETOPT_JOB (0x89988998)
534
535/*
536 * Command line options. These will contain the above, plus a few
537 * extra that only pertain to fio itself and not jobs.
538 */
539static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = {
540 {
541 .name = "output",
542 .has_arg = required_argument,
543 .val = 'o',
544 },
545 {
546 .name = "timeout",
547 .has_arg = required_argument,
548 .val = 't',
549 },
550 {
551 .name = "latency-log",
552 .has_arg = required_argument,
553 .val = 'l',
554 },
555 {
556 .name = "bandwidth-log",
557 .has_arg = required_argument,
558 .val = 'b',
559 },
560 {
561 .name = "minimal",
562 .has_arg = optional_argument,
563 .val = 'm',
564 },
565 {
566 .name = "version",
567 .has_arg = no_argument,
568 .val = 'v',
569 },
fd28ca49
JA
570 {
571 .name = "help",
572 .has_arg = no_argument,
573 .val = 'h',
574 },
575 {
576 .name = "cmdhelp",
577 .has_arg = required_argument,
578 .val = 'c',
579 },
b4692828
JA
580 {
581 .name = NULL,
582 },
583};
584
ee738499 585static int def_timeout = 0;
972cfd25 586
5cd033bb 587static char fio_version_string[] = "fio 1.11";
ebac4655 588
972cfd25 589static char **ini_file;
ebac4655
JA
590static int max_jobs = MAX_JOBS;
591
592struct thread_data def_thread;
593struct thread_data *threads = NULL;
594
ebac4655 595int exitall_on_terminate = 0;
c6ae0a5b 596int terse_output = 0;
c04f7ec3 597unsigned long long mlock_size = 0;
eb8bbf48
JA
598FILE *f_out = NULL;
599FILE *f_err = NULL;
ebac4655 600
ee738499 601static int write_lat_log = 0;
bb3884d8 602int write_bw_log = 0;
ec94ec56 603
906c8d75
JA
604/*
605 * Return a free job structure.
606 */
ebac4655
JA
607static struct thread_data *get_new_job(int global, struct thread_data *parent)
608{
609 struct thread_data *td;
610
611 if (global)
612 return &def_thread;
613 if (thread_number >= max_jobs)
614 return NULL;
615
616 td = &threads[thread_number++];
ddaeaa5a 617 *td = *parent;
ebac4655 618
ebac4655 619 td->thread_number = thread_number;
ebac4655
JA
620 return td;
621}
622
623static void put_job(struct thread_data *td)
624{
549577a7
JA
625 if (td == &def_thread)
626 return;
627
16edf25d
JA
628 if (td->error)
629 fprintf(f_out, "fio: %s\n", td->verror);
630
ebac4655
JA
631 memset(&threads[td->thread_number - 1], 0, sizeof(*td));
632 thread_number--;
633}
634
dad915e3
JA
635/*
636 * Lazy way of fixing up options that depend on each other. We could also
637 * define option callback handlers, but this is easier.
638 */
e1f36503
JA
639static void fixup_options(struct thread_data *td)
640{
e1f36503
JA
641 if (!td->rwmixread && td->rwmixwrite)
642 td->rwmixread = 100 - td->rwmixwrite;
dad915e3 643
076efc7c
JA
644 if (td->write_iolog_file && td->read_iolog_file) {
645 log_err("fio: read iolog overrides write_iolog\n");
646 free(td->write_iolog_file);
647 td->write_iolog_file = NULL;
648 }
16b462ae
JA
649
650 if (td->io_ops->flags & FIO_SYNCIO)
651 td->iodepth = 1;
652 else {
653 if (!td->iodepth)
654 td->iodepth = td->nr_files;
655 }
656
657 /*
658 * only really works for sequential io for now, and with 1 file
659 */
413dd459 660 if (td->zone_size && td_random(td) && td->nr_files == 1)
16b462ae
JA
661 td->zone_size = 0;
662
663 /*
664 * Reads can do overwrites, we always need to pre-create the file
665 */
666 if (td_read(td) || td_rw(td))
667 td->overwrite = 1;
668
a00735e6
JA
669 if (!td->min_bs[DDIR_READ])
670 td->min_bs[DDIR_READ]= td->bs[DDIR_READ];
671 if (!td->max_bs[DDIR_READ])
672 td->max_bs[DDIR_READ] = td->bs[DDIR_READ];
673 if (!td->min_bs[DDIR_WRITE])
75e6f36f 674 td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE];
a00735e6 675 if (!td->max_bs[DDIR_WRITE])
75e6f36f 676 td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE];
a00735e6
JA
677
678 td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
679
16b462ae
JA
680 if (td_read(td) && !td_rw(td))
681 td->verify = 0;
bb8895e0
JA
682
683 if (td->norandommap && td->verify != VERIFY_NONE) {
684 log_err("fio: norandommap given, verify disabled\n");
685 td->verify = VERIFY_NONE;
686 }
690adba3
JA
687 if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO))
688 log_err("fio: bs_unaligned may not work with raw io\n");
e0a22335
JA
689
690 /*
691 * O_DIRECT and char doesn't mix, clear that flag if necessary.
692 */
693 if (td->filetype == FIO_TYPE_CHAR && td->odirect)
694 td->odirect = 0;
48097d5c
JA
695
696 /*
697 * thinktime_spin must be less than thinktime
698 */
699 if (td->thinktime_spin > td->thinktime)
700 td->thinktime_spin = td->thinktime;
e916b390
JA
701
702 /*
703 * The low water mark cannot be bigger than the iodepth
704 */
705 if (td->iodepth_low > td->iodepth || !td->iodepth_low)
706 td->iodepth_low = td->iodepth;
e1f36503
JA
707}
708
f8977ee6
JA
709/*
710 * This function leaks the buffer
711 */
712static char *to_kmg(unsigned int val)
713{
714 char *buf = malloc(32);
f3502ba2 715 char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 };
f8977ee6
JA
716 char *p = post;
717
245142ff 718 do {
f8977ee6
JA
719 if (val & 1023)
720 break;
721
722 val >>= 10;
723 p++;
245142ff 724 } while (*p);
f8977ee6
JA
725
726 snprintf(buf, 31, "%u%c", val, *p);
727 return buf;
728}
729
906c8d75
JA
730/*
731 * Adds a job to the list of things todo. Sanitizes the various options
732 * to make sure we don't have conflicts, and initializes various
733 * members of td.
734 */
75154845 735static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
ebac4655 736{
413dd459
JA
737 const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
738 "randread", "randwrite", "randrw" };
ebac4655 739 struct stat sb;
413dd459 740 int numjobs, i;
53cdc686 741 struct fio_file *f;
ebac4655 742
ebac4655
JA
743 /*
744 * the def_thread is just for options, it's not a real job
745 */
746 if (td == &def_thread)
747 return 0;
748
ee738499 749 assert(td->io_ops);
df64119d 750
690adba3
JA
751 if (td->odirect)
752 td->io_ops->flags |= FIO_RAWIO;
753
ebac4655 754 td->filetype = FIO_TYPE_FILE;
890df538 755 if (td->filename && !lstat(td->filename, &sb)) {
0af7b542
JA
756 if (S_ISBLK(sb.st_mode))
757 td->filetype = FIO_TYPE_BD;
758 else if (S_ISCHR(sb.st_mode))
759 td->filetype = FIO_TYPE_CHAR;
760 }
ebac4655 761
e0a22335
JA
762 fixup_options(td);
763
13f8e2d2
JA
764 if (td->filename)
765 td->nr_uniq_files = 1;
766 else
767 td->nr_uniq_files = td->nr_files;
768
769 if (td->filetype == FIO_TYPE_FILE || td->filename) {
e9c047a0 770 char tmp[PATH_MAX];
53cdc686 771 int len = 0;
e9c047a0 772
16edf25d
JA
773 if (td->directory && td->directory[0] != '\0') {
774 if (lstat(td->directory, &sb) < 0) {
775 log_err("fio: %s is not a directory\n", td->directory);
e1161c32 776 td_verror(td, errno, "lstat");
16edf25d
JA
777 return 1;
778 }
779 if (!S_ISDIR(sb.st_mode)) {
780 log_err("fio: %s is not a directory\n", td->directory);
781 return 1;
782 }
8aeebd55 783 len = sprintf(tmp, "%s/", td->directory);
16edf25d 784 }
ebac4655 785
53cdc686
JA
786 td->files = malloc(sizeof(struct fio_file) * td->nr_files);
787
788 for_each_file(td, f, i) {
789 memset(f, 0, sizeof(*f));
790 f->fd = -1;
791
13f8e2d2
JA
792 if (td->filename)
793 sprintf(tmp + len, "%s", td->filename);
794 else
795 sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
53cdc686
JA
796 f->file_name = strdup(tmp);
797 }
798 } else {
799 td->nr_files = 1;
800 td->files = malloc(sizeof(struct fio_file));
801 f = &td->files[0];
802
803 memset(f, 0, sizeof(*f));
804 f->fd = -1;
805 f->file_name = strdup(jobname);
806 }
807
808 for_each_file(td, f, i) {
809 f->file_size = td->total_file_size / td->nr_files;
810 f->file_offset = td->start_offset;
811 }
812
bbfd6b00 813 fio_sem_init(&td->mutex, 0);
ebac4655 814
079ad09b
JA
815 td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
816 td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;
817 td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
ebac4655 818
ebac4655
JA
819 if (td->stonewall && td->thread_number > 1)
820 groupid++;
821
822 td->groupid = groupid;
823
824 if (setup_rate(td))
825 goto err;
826
ec94ec56 827 if (td->write_lat_log) {
079ad09b
JA
828 setup_log(&td->ts.slat_log);
829 setup_log(&td->ts.clat_log);
ebac4655 830 }
ec94ec56 831 if (td->write_bw_log)
079ad09b 832 setup_log(&td->ts.bw_log);
ebac4655 833
b4692828
JA
834 if (!td->name)
835 td->name = strdup(jobname);
01452055 836
c6ae0a5b 837 if (!terse_output) {
b990b5c0 838 if (!job_add_num) {
2866c82d 839 if (td->io_ops->flags & FIO_CPUIO)
b990b5c0 840 fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
f8977ee6
JA
841 else {
842 char *c1, *c2, *c3, *c4;
843
844 c1 = to_kmg(td->min_bs[DDIR_READ]);
845 c2 = to_kmg(td->max_bs[DDIR_READ]);
846 c3 = to_kmg(td->min_bs[DDIR_WRITE]);
847 c4 = to_kmg(td->max_bs[DDIR_WRITE]);
848
413dd459 849 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);
f8977ee6
JA
850
851 free(c1);
852 free(c2);
853 free(c3);
854 free(c4);
855 }
b990b5c0 856 } else if (job_add_num == 1)
c6ae0a5b
JA
857 fprintf(f_out, "...\n");
858 }
ebac4655
JA
859
860 /*
861 * recurse add identical jobs, clear numjobs and stonewall options
862 * as they don't apply to sub-jobs
863 */
864 numjobs = td->numjobs;
865 while (--numjobs) {
866 struct thread_data *td_new = get_new_job(0, td);
867
868 if (!td_new)
869 goto err;
870
871 td_new->numjobs = 1;
872 td_new->stonewall = 0;
75154845 873 job_add_num = numjobs - 1;
ebac4655 874
75154845 875 if (add_job(td_new, jobname, job_add_num))
ebac4655
JA
876 goto err;
877 }
878 return 0;
879err:
880 put_job(td);
881 return -1;
882}
883
906c8d75
JA
884/*
885 * Initialize the various random states we need (random io, block size ranges,
886 * read/write mix, etc).
887 */
ebac4655
JA
888int init_random_state(struct thread_data *td)
889{
0aabe160 890 unsigned long seeds[5];
53cdc686 891 int fd, num_maps, blocks, i;
0ab8db89 892 struct fio_file *f;
ebac4655 893
f48b467c
JA
894 if (td->io_ops->flags & FIO_CPUIO)
895 return 0;
896
1ac267bb 897 fd = open("/dev/urandom", O_RDONLY);
ebac4655 898 if (fd == -1) {
e1161c32 899 td_verror(td, errno, "open");
ebac4655
JA
900 return 1;
901 }
902
a6ccc7be 903 if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
e1161c32 904 td_verror(td, EIO, "read");
ebac4655
JA
905 close(fd);
906 return 1;
907 }
908
909 close(fd);
910
6dfd46b9
JA
911 os_random_seed(seeds[0], &td->bsrange_state);
912 os_random_seed(seeds[1], &td->verify_state);
913 os_random_seed(seeds[2], &td->rwmix_state);
ebac4655 914
413dd459
JA
915 if (td->file_service_type == FIO_FSERVICE_RANDOM)
916 os_random_seed(seeds[3], &td->next_file_state);
917
918 if (!td_random(td))
ebac4655
JA
919 return 0;
920
9ebc27e1 921 if (td->rand_repeatable)
0aabe160 922 seeds[4] = FIO_RANDSEED * td->thread_number;
ebac4655 923
bb8895e0
JA
924 if (!td->norandommap) {
925 for_each_file(td, f, i) {
a4a81712 926 blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
c7c280ed 927 num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
bb8895e0
JA
928 f->file_map = malloc(num_maps * sizeof(long));
929 f->num_maps = num_maps;
930 memset(f->file_map, 0, num_maps * sizeof(long));
931 }
53cdc686 932 }
ebac4655 933
0aabe160 934 os_random_seed(seeds[4], &td->random_state);
ebac4655
JA
935 return 0;
936}
937
938static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu)
939{
940#ifdef FIO_HAVE_CPU_AFFINITY
941 unsigned int i;
942
943 CPU_ZERO(&cpumask);
944
945 for (i = 0; i < sizeof(int) * 8; i++) {
946 if ((1 << i) & cpu)
947 CPU_SET(i, &cpumask);
948 }
949#endif
950}
951
ebac4655
JA
952static int is_empty_or_comment(char *line)
953{
954 unsigned int i;
955
956 for (i = 0; i < strlen(line); i++) {
957 if (line[i] == ';')
958 return 1;
5cc2da30
IM
959 if (line[i] == '#')
960 return 1;
ebac4655
JA
961 if (!isspace(line[i]) && !iscntrl(line[i]))
962 return 0;
963 }
964
965 return 1;
966}
967
313cb206
JA
968/*
969 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
970 */
971static char *get_mmap_file(const char *str)
972{
973 char *p = strstr(str, ":");
974
975 if (!p)
976 return NULL;
977
978 p++;
979 strip_blank_front(&p);
980 strip_blank_end(p);
981 return strdup(p);
982}
983
b4692828 984static int str_mem_cb(void *data, const char *mem)
ebac4655 985{
cb2c86fd
JA
986 struct thread_data *td = data;
987
b1ec1da6 988 if (td->mem_type == MEM_MMAPHUGE || td->mem_type == MEM_MMAP) {
313cb206 989 td->mmapfile = get_mmap_file(mem);
b1ec1da6 990 if (td->mem_type == MEM_MMAPHUGE && !td->mmapfile) {
d0bdaf49
JA
991 log_err("fio: mmaphuge:/path/to/file\n");
992 return 1;
993 }
ebac4655
JA
994 }
995
b1ec1da6 996 return 0;
ebac4655
JA
997}
998
b4692828 999static int str_ioengine_cb(void *data, const char *str)
ebac4655 1000{
cb2c86fd
JA
1001 struct thread_data *td = data;
1002
2866c82d
JA
1003 td->io_ops = load_ioengine(td, str);
1004 if (td->io_ops)
b990b5c0 1005 return 0;
ebac4655 1006
ebac4655
JA
1007 return 1;
1008}
1009
e1f36503
JA
1010static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
1011{
1012 mlock_size = *val;
1013 return 0;
1014}
1015
34cfcdaf 1016#ifdef FIO_HAVE_IOPRIO
e1f36503
JA
1017static int str_prioclass_cb(void *data, unsigned int *val)
1018{
1019 struct thread_data *td = data;
1020
1021 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
1022 return 0;
1023}
1024
1025static int str_prio_cb(void *data, unsigned int *val)
1026{
1027 struct thread_data *td = data;
1028
1029 td->ioprio |= *val;
1030 return 0;
1031}
34cfcdaf 1032#endif
e1f36503
JA
1033
1034static int str_exitall_cb(void)
1035{
1036 exitall_on_terminate = 1;
1037 return 0;
1038}
1039
1040static int str_cpumask_cb(void *data, unsigned int *val)
1041{
1042 struct thread_data *td = data;
1043
1044 fill_cpu_mask(td->cpumask, *val);
1045 return 0;
1046}
1047
07261983
JA
1048/*
1049 * This is our [ini] type file parser.
1050 */
1e97cce9 1051static int parse_jobs_ini(char *file, int stonewall_flag)
ebac4655 1052{
e1f36503 1053 unsigned int global;
ebac4655 1054 struct thread_data *td;
fee3bb48 1055 char *string, *name;
ebac4655
JA
1056 fpos_t off;
1057 FILE *f;
1058 char *p;
0c7e37a0 1059 int ret = 0, stonewall;
ebac4655
JA
1060
1061 f = fopen(file, "r");
1062 if (!f) {
aea47d44 1063 perror("fopen job file");
ebac4655
JA
1064 return 1;
1065 }
1066
1067 string = malloc(4096);
1068 name = malloc(256);
fee3bb48 1069 memset(name, 0, 256);
ebac4655 1070
0c7e37a0 1071 stonewall = stonewall_flag;
7c124ac1
JA
1072 do {
1073 p = fgets(string, 4095, f);
1074 if (!p)
45410acb 1075 break;
ebac4655
JA
1076 if (is_empty_or_comment(p))
1077 continue;
fee3bb48 1078 if (sscanf(p, "[%255s]", name) != 1)
ebac4655
JA
1079 continue;
1080
1081 global = !strncmp(name, "global", 6);
1082
1083 name[strlen(name) - 1] = '\0';
1084
1085 td = get_new_job(global, &def_thread);
45410acb
JA
1086 if (!td) {
1087 ret = 1;
1088 break;
1089 }
ebac4655 1090
972cfd25
JA
1091 /*
1092 * Seperate multiple job files by a stonewall
1093 */
f9481919 1094 if (!global && stonewall) {
972cfd25
JA
1095 td->stonewall = stonewall;
1096 stonewall = 0;
1097 }
1098
ebac4655
JA
1099 fgetpos(f, &off);
1100 while ((p = fgets(string, 4096, f)) != NULL) {
1101 if (is_empty_or_comment(p))
1102 continue;
e1f36503 1103
b6754f9d 1104 strip_blank_front(&p);
7c124ac1
JA
1105
1106 if (p[0] == '[')
1107 break;
1108
4ae3f763 1109 strip_blank_end(p);
aea47d44 1110
e1f36503 1111 fgetpos(f, &off);
ebac4655 1112
45410acb
JA
1113 /*
1114 * Don't break here, continue parsing options so we
1115 * dump all the bad ones. Makes trial/error fixups
1116 * easier on the user.
1117 */
7c124ac1 1118 ret |= parse_option(p, options, td);
ebac4655 1119 }
ebac4655 1120
45410acb
JA
1121 if (!ret) {
1122 fsetpos(f, &off);
1123 ret = add_job(td, name, 0);
b1508cf9
JA
1124 } else {
1125 log_err("fio: job %s dropped\n", name);
1126 put_job(td);
45410acb 1127 }
7c124ac1 1128 } while (!ret);
ebac4655
JA
1129
1130 free(string);
1131 free(name);
1132 fclose(f);
45410acb 1133 return ret;
ebac4655
JA
1134}
1135
1136static int fill_def_thread(void)
1137{
1138 memset(&def_thread, 0, sizeof(def_thread));
1139
1140 if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) {
1141 perror("sched_getaffinity");
1142 return 1;
1143 }
1144
1145 /*
ee738499 1146 * fill default options
ebac4655 1147 */
ee738499
JA
1148 fill_default_options(&def_thread, options);
1149
972cfd25 1150 def_thread.timeout = def_timeout;
ec94ec56
JA
1151 def_thread.write_bw_log = write_bw_log;
1152 def_thread.write_lat_log = write_lat_log;
ee738499 1153
ebac4655
JA
1154#ifdef FIO_HAVE_DISK_UTIL
1155 def_thread.do_disk_util = 1;
1156#endif
1157
1158 return 0;
1159}
1160
0ab8db89 1161static void usage(void)
4785f995
JA
1162{
1163 printf("%s\n", fio_version_string);
b4692828
JA
1164 printf("\t--output\tWrite output to file\n");
1165 printf("\t--timeout\tRuntime in seconds\n");
1166 printf("\t--latency-log\tGenerate per-job latency logs\n");
1167 printf("\t--bandwidth-log\tGenerate per-job bandwidth logs\n");
1168 printf("\t--minimal\tMinimal (terse) output\n");
1169 printf("\t--version\tPrint version info and exit\n");
fd28ca49
JA
1170 printf("\t--help\t\tPrint this page\n");
1171 printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n");
4785f995
JA
1172}
1173
972cfd25 1174static int parse_cmd_line(int argc, char *argv[])
ebac4655 1175{
b4692828 1176 struct thread_data *td = NULL;
b1ec1da6 1177 int c, ini_idx = 0, lidx, ret, dont_add_job = 0;
ebac4655 1178
b4692828 1179 while ((c = getopt_long(argc, argv, "", long_options, &lidx)) != -1) {
ebac4655 1180 switch (c) {
b4692828
JA
1181 case 't':
1182 def_timeout = atoi(optarg);
1183 break;
1184 case 'l':
1185 write_lat_log = 1;
1186 break;
1187 case 'w':
1188 write_bw_log = 1;
1189 break;
1190 case 'o':
1191 f_out = fopen(optarg, "w+");
1192 if (!f_out) {
1193 perror("fopen output");
1194 exit(1);
1195 }
1196 f_err = f_out;
1197 break;
1198 case 'm':
1199 terse_output = 1;
1200 break;
1201 case 'h':
1202 usage();
1203 exit(0);
fd28ca49 1204 case 'c':
29fc6afe
JA
1205 ret = show_cmd_help(options, optarg);
1206 exit(ret);
b4692828
JA
1207 case 'v':
1208 printf("%s\n", fio_version_string);
1209 exit(0);
1210 case FIO_GETOPT_JOB: {
1211 const char *opt = long_options[lidx].name;
1212 char *val = optarg;
1213
c2b1e753
JA
1214 if (!strncmp(opt, "name", 4) && td) {
1215 ret = add_job(td, td->name ?: "fio", 0);
1216 if (ret) {
1217 put_job(td);
1218 return 0;
1219 }
1220 td = NULL;
1221 }
b4692828 1222 if (!td) {
38d0adb0 1223 int global = !strncmp(val, "global", 6);
c2b1e753
JA
1224
1225 td = get_new_job(global, &def_thread);
b4692828
JA
1226 if (!td)
1227 return 0;
1228 }
38d0adb0 1229
b1508cf9 1230 ret = parse_cmd_option(opt, val, options, td);
78217dfa 1231 if (ret)
b1ec1da6 1232 dont_add_job = 1;
b4692828
JA
1233 break;
1234 }
1235 default:
b4692828 1236 break;
ebac4655
JA
1237 }
1238 }
c9fad893 1239
b4692828 1240 if (td) {
b1ec1da6 1241 if (dont_add_job)
b4692828 1242 put_job(td);
b1ec1da6
JA
1243 else {
1244 ret = add_job(td, td->name ?: "fio", 0);
1245 if (ret)
1246 put_job(td);
1247 }
972cfd25 1248 }
774a6177 1249
b4692828
JA
1250 while (optind < argc) {
1251 ini_idx++;
1252 ini_file = realloc(ini_file, ini_idx * sizeof(char *));
1253 ini_file[ini_idx - 1] = strdup(argv[optind]);
1254 optind++;
eb8bbf48 1255 }
972cfd25
JA
1256
1257 return ini_idx;
ebac4655
JA
1258}
1259
1260static void free_shm(void)
1261{
1262 struct shmid_ds sbuf;
1263
1264 if (threads) {
2c0ecd28 1265 shmdt((void *) threads);
ebac4655
JA
1266 threads = NULL;
1267 shmctl(shm_id, IPC_RMID, &sbuf);
1268 }
1269}
1270
906c8d75
JA
1271/*
1272 * The thread area is shared between the main process and the job
1273 * threads/processes. So setup a shared memory segment that will hold
1274 * all the job info.
1275 */
ebac4655
JA
1276static int setup_thread_area(void)
1277{
1278 /*
1279 * 1024 is too much on some machines, scale max_jobs if
1280 * we get a failure that looks like too large a shm segment
1281 */
1282 do {
906c8d75 1283 size_t size = max_jobs * sizeof(struct thread_data);
ebac4655 1284
906c8d75 1285 shm_id = shmget(0, size, IPC_CREAT | 0600);
ebac4655
JA
1286 if (shm_id != -1)
1287 break;
1288 if (errno != EINVAL) {
1289 perror("shmget");
1290 break;
1291 }
1292
1293 max_jobs >>= 1;
1294 } while (max_jobs);
1295
1296 if (shm_id == -1)
1297 return 1;
1298
1299 threads = shmat(shm_id, NULL, 0);
1300 if (threads == (void *) -1) {
1301 perror("shmat");
1302 return 1;
1303 }
1304
1305 atexit(free_shm);
1306 return 0;
1307}
1308
b4692828
JA
1309/*
1310 * Copy the fio options into the long options map, so we mirror
1311 * job and cmd line options.
1312 */
1313static void dupe_job_options(void)
1314{
1315 struct fio_option *o;
1316 unsigned int i;
1317
1318 i = 0;
1319 while (long_options[i].name)
1320 i++;
1321
1322 o = &options[0];
1323 while (o->name) {
1324 long_options[i].name = o->name;
1325 long_options[i].val = FIO_GETOPT_JOB;
1326 if (o->type == FIO_OPT_STR_SET)
1327 long_options[i].has_arg = no_argument;
1328 else
1329 long_options[i].has_arg = required_argument;
1330
1331 i++;
1332 o++;
1333 assert(i < FIO_JOB_OPTS + FIO_CMD_OPTS);
1334 }
1335}
1336
ebac4655
JA
1337int parse_options(int argc, char *argv[])
1338{
972cfd25
JA
1339 int job_files, i;
1340
b4692828
JA
1341 f_out = stdout;
1342 f_err = stderr;
1343
13335ddb
JA
1344 options_init(options);
1345
b4692828
JA
1346 dupe_job_options();
1347
ebac4655
JA
1348 if (setup_thread_area())
1349 return 1;
1350 if (fill_def_thread())
1351 return 1;
1352
972cfd25 1353 job_files = parse_cmd_line(argc, argv);
ebac4655 1354
972cfd25
JA
1355 for (i = 0; i < job_files; i++) {
1356 if (fill_def_thread())
1357 return 1;
0c7e37a0 1358 if (parse_jobs_ini(ini_file[i], i))
972cfd25 1359 return 1;
88c6ed80 1360 free(ini_file[i]);
972cfd25 1361 }
ebac4655 1362
88c6ed80 1363 free(ini_file);
b4692828
JA
1364
1365 if (!thread_number) {
1366 log_err("No jobs defined(s)\n");
b4692828
JA
1367 return 1;
1368 }
1369
ebac4655
JA
1370 return 0;
1371}