netsplice: fix a few typos
[fio.git] / options.c
CommitLineData
214e1eca
JA
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <ctype.h>
5#include <string.h>
6#include <getopt.h>
7#include <assert.h>
8
9#include "fio.h"
10#include "parse.h"
11
2dc1bbeb 12#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
214e1eca
JA
13
14/*
15 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
16 */
17static char *get_opt_postfix(const char *str)
18{
19 char *p = strstr(str, ":");
20
21 if (!p)
22 return NULL;
23
24 p++;
25 strip_blank_front(&p);
26 strip_blank_end(p);
27 return strdup(p);
28}
29
211097b2
JA
30static int str_rw_cb(void *data, const char *str)
31{
32 struct thread_data *td = data;
33 char *nr = get_opt_postfix(str);
34
fafdba3c 35 td->o.ddir_nr = 1;
211097b2
JA
36 if (nr)
37 td->o.ddir_nr = atoi(nr);
38
211097b2
JA
39 return 0;
40}
41
214e1eca
JA
42static int str_mem_cb(void *data, const char *mem)
43{
44 struct thread_data *td = data;
45
2dc1bbeb 46 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
214e1eca 47 td->mmapfile = get_opt_postfix(mem);
2dc1bbeb 48 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
214e1eca
JA
49 log_err("fio: mmaphuge:/path/to/file\n");
50 return 1;
51 }
52 }
53
54 return 0;
55}
56
57static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
58{
59 mlock_size = *val;
60 return 0;
61}
62
63#ifdef FIO_HAVE_IOPRIO
64static int str_prioclass_cb(void *data, unsigned int *val)
65{
66 struct thread_data *td = data;
6cefbe33
JA
67 unsigned short mask;
68
69 /*
70 * mask off old class bits, str_prio_cb() may have set a default class
71 */
72 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
73 td->ioprio &= mask;
214e1eca
JA
74
75 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
76 return 0;
77}
78
79static int str_prio_cb(void *data, unsigned int *val)
80{
81 struct thread_data *td = data;
82
83 td->ioprio |= *val;
6cefbe33
JA
84
85 /*
86 * If no class is set, assume BE
87 */
88 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
89 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
90
214e1eca
JA
91 return 0;
92}
93#endif
94
95static int str_exitall_cb(void)
96{
97 exitall_on_terminate = 1;
98 return 0;
99}
100
214e1eca 101#ifdef FIO_HAVE_CPU_AFFINITY
d2e268b0
JA
102static int str_cpumask_cb(void *data, unsigned int *val)
103{
104 struct thread_data *td = data;
214e1eca
JA
105 unsigned int i;
106
d2e268b0 107 CPU_ZERO(&td->o.cpumask);
214e1eca 108
e600f7f1 109 for (i = 0; i < sizeof(int) * 8; i++)
d2e268b0
JA
110 if ((1 << i) & *val)
111 CPU_SET(*val, &td->o.cpumask);
112
113 td->o.cpumask_set = 1;
114 return 0;
214e1eca
JA
115}
116
d2e268b0 117static int str_cpus_allowed_cb(void *data, const char *input)
214e1eca
JA
118{
119 struct thread_data *td = data;
d2e268b0
JA
120 char *cpu, *str, *p;
121
122 CPU_ZERO(&td->o.cpumask);
123
124 p = str = strdup(input);
214e1eca 125
d2e268b0
JA
126 strip_blank_front(&str);
127 strip_blank_end(str);
128
129 while ((cpu = strsep(&str, ",")) != NULL) {
130 if (!strlen(cpu))
131 break;
132 CPU_SET(atoi(cpu), &td->o.cpumask);
133 }
134
135 free(p);
375b2695 136 td->o.cpumask_set = 1;
d2e268b0 137 exit(0);
214e1eca
JA
138 return 0;
139}
d2e268b0 140#endif
214e1eca
JA
141
142static int str_fst_cb(void *data, const char *str)
143{
144 struct thread_data *td = data;
145 char *nr = get_opt_postfix(str);
146
147 td->file_service_nr = 1;
148 if (nr)
149 td->file_service_nr = atoi(nr);
150
151 return 0;
152}
153
154static int str_filename_cb(void *data, const char *input)
155{
156 struct thread_data *td = data;
157 char *fname, *str, *p;
158
159 p = str = strdup(input);
160
161 strip_blank_front(&str);
162 strip_blank_end(str);
163
164 if (!td->files_index)
2dc1bbeb 165 td->o.nr_files = 0;
214e1eca
JA
166
167 while ((fname = strsep(&str, ":")) != NULL) {
168 if (!strlen(fname))
169 break;
170 add_file(td, fname);
2dc1bbeb 171 td->o.nr_files++;
214e1eca
JA
172 }
173
174 free(p);
175 return 0;
176}
177
178static int str_directory_cb(void *data, const char fio_unused *str)
179{
180 struct thread_data *td = data;
181 struct stat sb;
182
2dc1bbeb
JA
183 if (lstat(td->o.directory, &sb) < 0) {
184 log_err("fio: %s is not a directory\n", td->o.directory);
214e1eca
JA
185 td_verror(td, errno, "lstat");
186 return 1;
187 }
188 if (!S_ISDIR(sb.st_mode)) {
2dc1bbeb 189 log_err("fio: %s is not a directory\n", td->o.directory);
214e1eca
JA
190 return 1;
191 }
192
193 return 0;
194}
195
196static int str_opendir_cb(void *data, const char fio_unused *str)
197{
198 struct thread_data *td = data;
199
200 if (!td->files_index)
2dc1bbeb 201 td->o.nr_files = 0;
214e1eca 202
2dc1bbeb 203 return add_dir_files(td, td->o.opendir);
214e1eca
JA
204}
205
206
207#define __stringify_1(x) #x
208#define __stringify(x) __stringify_1(x)
209
210/*
211 * Map of job/command line options
212 */
213static struct fio_option options[] = {
214 {
215 .name = "description",
216 .type = FIO_OPT_STR_STORE,
217 .off1 = td_var_offset(description),
218 .help = "Text job description",
219 },
220 {
221 .name = "name",
222 .type = FIO_OPT_STR_STORE,
223 .off1 = td_var_offset(name),
224 .help = "Name of this job",
225 },
226 {
227 .name = "directory",
228 .type = FIO_OPT_STR_STORE,
229 .off1 = td_var_offset(directory),
230 .cb = str_directory_cb,
231 .help = "Directory to store files in",
232 },
233 {
234 .name = "filename",
235 .type = FIO_OPT_STR_STORE,
236 .off1 = td_var_offset(filename),
237 .cb = str_filename_cb,
238 .help = "File(s) to use for the workload",
239 },
240 {
241 .name = "opendir",
242 .type = FIO_OPT_STR_STORE,
243 .off1 = td_var_offset(opendir),
244 .cb = str_opendir_cb,
245 .help = "Recursively add files from this directory and down",
246 },
247 {
248 .name = "rw",
d3aad8f2 249 .alias = "readwrite",
214e1eca 250 .type = FIO_OPT_STR,
211097b2 251 .cb = str_rw_cb,
214e1eca
JA
252 .off1 = td_var_offset(td_ddir),
253 .help = "IO direction",
254 .def = "read",
255 .posval = {
256 { .ival = "read",
257 .oval = TD_DDIR_READ,
258 .help = "Sequential read",
259 },
260 { .ival = "write",
261 .oval = TD_DDIR_WRITE,
262 .help = "Sequential write",
263 },
264 { .ival = "randread",
265 .oval = TD_DDIR_RANDREAD,
266 .help = "Random read",
267 },
268 { .ival = "randwrite",
269 .oval = TD_DDIR_RANDWRITE,
270 .help = "Random write",
271 },
272 { .ival = "rw",
273 .oval = TD_DDIR_RW,
274 .help = "Sequential read and write mix",
275 },
276 { .ival = "randrw",
277 .oval = TD_DDIR_RANDRW,
278 .help = "Random read and write mix"
279 },
280 },
281 },
d2f3ac35
JA
282 {
283 .name = "fadvise_hint",
284 .type = FIO_OPT_BOOL,
285 .off1 = td_var_offset(fadvise_hint),
286 .help = "Use fadvise() to advise the kernel on IO pattern",
287 .def = "1",
288 },
214e1eca
JA
289 {
290 .name = "ioengine",
291 .type = FIO_OPT_STR_STORE,
292 .off1 = td_var_offset(ioengine),
293 .help = "IO engine to use",
294 .def = "sync",
295 .posval = {
296 { .ival = "sync",
297 .help = "Use read/write",
298 },
299#ifdef FIO_HAVE_LIBAIO
300 { .ival = "libaio",
301 .help = "Linux native asynchronous IO",
302 },
303#endif
304#ifdef FIO_HAVE_POSIXAIO
305 { .ival = "posixaio",
306 .help = "POSIX asynchronous IO",
307 },
308#endif
309 { .ival = "mmap",
310 .help = "Memory mapped IO",
311 },
312#ifdef FIO_HAVE_SPLICE
313 { .ival = "splice",
314 .help = "splice/vmsplice based IO",
315 },
9cce02e8
JA
316 { .ival = "netsplice",
317 .help = "splice/vmsplice to/from the network",
318 },
214e1eca
JA
319#endif
320#ifdef FIO_HAVE_SGIO
321 { .ival = "sg",
322 .help = "SCSI generic v3 IO",
323 },
324#endif
325 { .ival = "null",
326 .help = "Testing engine (no data transfer)",
327 },
328 { .ival = "net",
329 .help = "Network IO",
330 },
331#ifdef FIO_HAVE_SYSLET
332 { .ival = "syslet-rw",
333 .help = "syslet enabled async pread/pwrite IO",
334 },
335#endif
336 { .ival = "cpuio",
337 .help = "CPU cycler burner engine",
338 },
b8c82a46
JA
339#ifdef FIO_HAVE_GUASI
340 { .ival = "guasi",
341 .help = "GUASI IO engine",
342 },
343#endif
214e1eca
JA
344 { .ival = "external",
345 .help = "Load external engine (append name)",
346 },
347 },
348 },
349 {
350 .name = "iodepth",
351 .type = FIO_OPT_INT,
352 .off1 = td_var_offset(iodepth),
353 .help = "Amount of IO buffers to keep in flight",
354 .def = "1",
355 },
356 {
357 .name = "iodepth_batch",
358 .type = FIO_OPT_INT,
359 .off1 = td_var_offset(iodepth_batch),
360 .help = "Number of IO to submit in one go",
361 },
362 {
363 .name = "iodepth_low",
364 .type = FIO_OPT_INT,
365 .off1 = td_var_offset(iodepth_low),
366 .help = "Low water mark for queuing depth",
367 },
368 {
369 .name = "size",
370 .type = FIO_OPT_STR_VAL,
2dc1bbeb 371 .off1 = td_var_offset(size),
214e1eca
JA
372 .help = "Total size of device or files",
373 },
374 {
375 .name = "filesize",
376 .type = FIO_OPT_STR_VAL,
377 .off1 = td_var_offset(file_size_low),
378 .off2 = td_var_offset(file_size_high),
379 .help = "Size of individual files",
380 },
381 {
382 .name = "bs",
d3aad8f2 383 .alias = "blocksize",
214e1eca
JA
384 .type = FIO_OPT_STR_VAL_INT,
385 .off1 = td_var_offset(bs[DDIR_READ]),
386 .off2 = td_var_offset(bs[DDIR_WRITE]),
387 .help = "Block size unit",
388 .def = "4k",
389 },
390 {
391 .name = "bsrange",
d3aad8f2 392 .alias = "blocksize_range",
214e1eca
JA
393 .type = FIO_OPT_RANGE,
394 .off1 = td_var_offset(min_bs[DDIR_READ]),
395 .off2 = td_var_offset(max_bs[DDIR_READ]),
396 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
397 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
398 .help = "Set block size range (in more detail than bs)",
399 },
400 {
401 .name = "bs_unaligned",
d3aad8f2 402 .alias = "blocksize_unaligned",
214e1eca
JA
403 .type = FIO_OPT_STR_SET,
404 .off1 = td_var_offset(bs_unaligned),
405 .help = "Don't sector align IO buffer sizes",
406 },
407 {
408 .name = "offset",
409 .type = FIO_OPT_STR_VAL,
410 .off1 = td_var_offset(start_offset),
411 .help = "Start IO from this offset",
412 .def = "0",
413 },
414 {
415 .name = "randrepeat",
416 .type = FIO_OPT_BOOL,
417 .off1 = td_var_offset(rand_repeatable),
418 .help = "Use repeatable random IO pattern",
419 .def = "1",
420 },
421 {
422 .name = "norandommap",
423 .type = FIO_OPT_STR_SET,
424 .off1 = td_var_offset(norandommap),
425 .help = "Accept potential duplicate random blocks",
426 },
427 {
428 .name = "nrfiles",
429 .type = FIO_OPT_INT,
430 .off1 = td_var_offset(nr_files),
431 .help = "Split job workload between this number of files",
432 .def = "1",
433 },
434 {
435 .name = "openfiles",
436 .type = FIO_OPT_INT,
437 .off1 = td_var_offset(open_files),
438 .help = "Number of files to keep open at the same time",
439 },
440 {
441 .name = "file_service_type",
442 .type = FIO_OPT_STR,
443 .cb = str_fst_cb,
444 .off1 = td_var_offset(file_service_type),
445 .help = "How to select which file to service next",
446 .def = "roundrobin",
447 .posval = {
448 { .ival = "random",
449 .oval = FIO_FSERVICE_RANDOM,
450 .help = "Choose a file at random",
451 },
452 { .ival = "roundrobin",
453 .oval = FIO_FSERVICE_RR,
454 .help = "Round robin select files",
455 },
456 },
457 },
458 {
459 .name = "fsync",
460 .type = FIO_OPT_INT,
461 .off1 = td_var_offset(fsync_blocks),
462 .help = "Issue fsync for writes every given number of blocks",
463 .def = "0",
464 },
465 {
466 .name = "direct",
467 .type = FIO_OPT_BOOL,
468 .off1 = td_var_offset(odirect),
469 .help = "Use O_DIRECT IO (negates buffered)",
470 .def = "0",
471 },
472 {
473 .name = "buffered",
474 .type = FIO_OPT_BOOL,
475 .off1 = td_var_offset(odirect),
476 .neg = 1,
477 .help = "Use buffered IO (negates direct)",
478 .def = "1",
479 },
480 {
481 .name = "overwrite",
482 .type = FIO_OPT_BOOL,
483 .off1 = td_var_offset(overwrite),
484 .help = "When writing, set whether to overwrite current data",
485 .def = "0",
486 },
487 {
488 .name = "loops",
489 .type = FIO_OPT_INT,
490 .off1 = td_var_offset(loops),
491 .help = "Number of times to run the job",
492 .def = "1",
493 },
494 {
495 .name = "numjobs",
496 .type = FIO_OPT_INT,
497 .off1 = td_var_offset(numjobs),
498 .help = "Duplicate this job this many times",
499 .def = "1",
500 },
501 {
502 .name = "startdelay",
503 .type = FIO_OPT_INT,
504 .off1 = td_var_offset(start_delay),
505 .help = "Only start job when this period has passed",
506 .def = "0",
507 },
508 {
509 .name = "runtime",
510 .alias = "timeout",
511 .type = FIO_OPT_STR_VAL_TIME,
512 .off1 = td_var_offset(timeout),
513 .help = "Stop workload when this amount of time has passed",
514 .def = "0",
515 },
cf4464ca
JA
516 {
517 .name = "time_based",
518 .type = FIO_OPT_STR_SET,
519 .off1 = td_var_offset(time_based),
520 .help = "Keep running until runtime/timeout is met",
521 },
214e1eca
JA
522 {
523 .name = "mem",
d3aad8f2 524 .alias = "iomem",
214e1eca
JA
525 .type = FIO_OPT_STR,
526 .cb = str_mem_cb,
527 .off1 = td_var_offset(mem_type),
528 .help = "Backing type for IO buffers",
529 .def = "malloc",
530 .posval = {
531 { .ival = "malloc",
532 .oval = MEM_MALLOC,
533 .help = "Use malloc(3) for IO buffers",
534 },
37c8cdfe
JA
535 { .ival = "shm",
536 .oval = MEM_SHM,
537 .help = "Use shared memory segments for IO buffers",
538 },
214e1eca
JA
539#ifdef FIO_HAVE_HUGETLB
540 { .ival = "shmhuge",
541 .oval = MEM_SHMHUGE,
542 .help = "Like shm, but use huge pages",
543 },
b370e46a 544#endif
37c8cdfe
JA
545 { .ival = "mmap",
546 .oval = MEM_MMAP,
547 .help = "Use mmap(2) (file or anon) for IO buffers",
548 },
214e1eca
JA
549#ifdef FIO_HAVE_HUGETLB
550 { .ival = "mmaphuge",
551 .oval = MEM_MMAPHUGE,
552 .help = "Like mmap, but use huge pages",
553 },
554#endif
555 },
556 },
557 {
558 .name = "verify",
559 .type = FIO_OPT_STR,
560 .off1 = td_var_offset(verify),
561 .help = "Verify data written",
562 .def = "0",
563 .posval = {
564 { .ival = "0",
565 .oval = VERIFY_NONE,
566 .help = "Don't do IO verification",
567 },
568 { .ival = "crc32",
569 .oval = VERIFY_CRC32,
570 .help = "Use crc32 checksums for verification",
571 },
572 { .ival = "md5",
573 .oval = VERIFY_MD5,
574 .help = "Use md5 checksums for verification",
575 },
36690c9b
JA
576 {
577 .ival = "null",
578 .oval = VERIFY_NULL,
579 .help = "Pretend to verify",
580 },
214e1eca
JA
581 },
582 },
160b966d
JA
583 {
584 .name = "verifysort",
585 .type = FIO_OPT_BOOL,
586 .off1 = td_var_offset(verifysort),
587 .help = "Sort written verify blocks for read back",
588 .def = "1",
589 },
214e1eca
JA
590 {
591 .name = "write_iolog",
592 .type = FIO_OPT_STR_STORE,
593 .off1 = td_var_offset(write_iolog_file),
594 .help = "Store IO pattern to file",
595 },
596 {
597 .name = "read_iolog",
598 .type = FIO_OPT_STR_STORE,
599 .off1 = td_var_offset(read_iolog_file),
600 .help = "Playback IO pattern from file",
601 },
602 {
603 .name = "exec_prerun",
604 .type = FIO_OPT_STR_STORE,
605 .off1 = td_var_offset(exec_prerun),
606 .help = "Execute this file prior to running job",
607 },
608 {
609 .name = "exec_postrun",
610 .type = FIO_OPT_STR_STORE,
611 .off1 = td_var_offset(exec_postrun),
612 .help = "Execute this file after running job",
613 },
614#ifdef FIO_HAVE_IOSCHED_SWITCH
615 {
616 .name = "ioscheduler",
617 .type = FIO_OPT_STR_STORE,
618 .off1 = td_var_offset(ioscheduler),
619 .help = "Use this IO scheduler on the backing device",
620 },
621#endif
622 {
623 .name = "zonesize",
624 .type = FIO_OPT_STR_VAL,
625 .off1 = td_var_offset(zone_size),
626 .help = "Give size of an IO zone",
627 .def = "0",
628 },
629 {
630 .name = "zoneskip",
631 .type = FIO_OPT_STR_VAL,
632 .off1 = td_var_offset(zone_skip),
633 .help = "Space between IO zones",
634 .def = "0",
635 },
636 {
637 .name = "lockmem",
638 .type = FIO_OPT_STR_VAL,
639 .cb = str_lockmem_cb,
640 .help = "Lock down this amount of memory",
641 .def = "0",
642 },
643 {
644 .name = "rwmixcycle",
645 .type = FIO_OPT_INT,
646 .off1 = td_var_offset(rwmixcycle),
647 .help = "Cycle period for mixed read/write workloads (msec)",
648 .def = "500",
649 },
650 {
651 .name = "rwmixread",
652 .type = FIO_OPT_INT,
e47f799f 653 .off1 = td_var_offset(rwmix[DDIR_READ]),
214e1eca
JA
654 .maxval = 100,
655 .help = "Percentage of mixed workload that is reads",
656 .def = "50",
657 },
658 {
659 .name = "rwmixwrite",
660 .type = FIO_OPT_INT,
e47f799f 661 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
214e1eca
JA
662 .maxval = 100,
663 .help = "Percentage of mixed workload that is writes",
664 .def = "50",
665 },
666 {
667 .name = "nice",
668 .type = FIO_OPT_INT,
669 .off1 = td_var_offset(nice),
670 .help = "Set job CPU nice value",
671 .minval = -19,
672 .maxval = 20,
673 .def = "0",
674 },
675#ifdef FIO_HAVE_IOPRIO
676 {
677 .name = "prio",
678 .type = FIO_OPT_INT,
679 .cb = str_prio_cb,
680 .help = "Set job IO priority value",
681 .minval = 0,
682 .maxval = 7,
683 },
684 {
685 .name = "prioclass",
686 .type = FIO_OPT_INT,
687 .cb = str_prioclass_cb,
688 .help = "Set job IO priority class",
689 .minval = 0,
690 .maxval = 3,
691 },
692#endif
693 {
694 .name = "thinktime",
695 .type = FIO_OPT_INT,
696 .off1 = td_var_offset(thinktime),
697 .help = "Idle time between IO buffers (usec)",
698 .def = "0",
699 },
700 {
701 .name = "thinktime_spin",
702 .type = FIO_OPT_INT,
703 .off1 = td_var_offset(thinktime_spin),
704 .help = "Start think time by spinning this amount (usec)",
705 .def = "0",
706 },
707 {
708 .name = "thinktime_blocks",
709 .type = FIO_OPT_INT,
710 .off1 = td_var_offset(thinktime_blocks),
711 .help = "IO buffer period between 'thinktime'",
712 .def = "1",
713 },
714 {
715 .name = "rate",
716 .type = FIO_OPT_INT,
717 .off1 = td_var_offset(rate),
718 .help = "Set bandwidth rate",
719 },
720 {
721 .name = "ratemin",
722 .type = FIO_OPT_INT,
723 .off1 = td_var_offset(ratemin),
4e991c23
JA
724 .help = "Job must meet this rate or it will be shutdown",
725 },
726 {
727 .name = "rate_iops",
728 .type = FIO_OPT_INT,
729 .off1 = td_var_offset(rate_iops),
730 .help = "Limit IO used to this number of IO operations/sec",
731 },
732 {
733 .name = "rate_iops_min",
734 .type = FIO_OPT_INT,
735 .off1 = td_var_offset(rate_iops_min),
736 .help = "Job must meet this rate or it will be shutdown",
214e1eca
JA
737 },
738 {
739 .name = "ratecycle",
740 .type = FIO_OPT_INT,
741 .off1 = td_var_offset(ratecycle),
742 .help = "Window average for rate limits (msec)",
743 .def = "1000",
744 },
745 {
746 .name = "invalidate",
747 .type = FIO_OPT_BOOL,
748 .off1 = td_var_offset(invalidate_cache),
749 .help = "Invalidate buffer/page cache prior to running job",
750 .def = "1",
751 },
752 {
753 .name = "sync",
754 .type = FIO_OPT_BOOL,
755 .off1 = td_var_offset(sync_io),
756 .help = "Use O_SYNC for buffered writes",
757 .def = "0",
758 },
759 {
760 .name = "bwavgtime",
761 .type = FIO_OPT_INT,
762 .off1 = td_var_offset(bw_avg_time),
763 .help = "Time window over which to calculate bandwidth (msec)",
764 .def = "500",
765 },
766 {
767 .name = "create_serialize",
768 .type = FIO_OPT_BOOL,
769 .off1 = td_var_offset(create_serialize),
770 .help = "Serialize creating of job files",
771 .def = "1",
772 },
773 {
774 .name = "create_fsync",
775 .type = FIO_OPT_BOOL,
776 .off1 = td_var_offset(create_fsync),
777 .help = "Fsync file after creation",
778 .def = "1",
779 },
780 {
781 .name = "cpuload",
782 .type = FIO_OPT_INT,
783 .off1 = td_var_offset(cpuload),
784 .help = "Use this percentage of CPU",
785 },
786 {
787 .name = "cpuchunks",
788 .type = FIO_OPT_INT,
789 .off1 = td_var_offset(cpucycle),
790 .help = "Length of the CPU burn cycles (usecs)",
791 .def = "50000",
792 },
793#ifdef FIO_HAVE_CPU_AFFINITY
794 {
795 .name = "cpumask",
796 .type = FIO_OPT_INT,
797 .cb = str_cpumask_cb,
798 .help = "CPU affinity mask",
799 },
d2e268b0
JA
800 {
801 .name = "cpus_allowed",
802 .type = FIO_OPT_STR,
803 .cb = str_cpus_allowed_cb,
804 .help = "Set CPUs allowed",
805 },
214e1eca
JA
806#endif
807 {
808 .name = "end_fsync",
809 .type = FIO_OPT_BOOL,
810 .off1 = td_var_offset(end_fsync),
811 .help = "Include fsync at the end of job",
812 .def = "0",
813 },
814 {
815 .name = "fsync_on_close",
816 .type = FIO_OPT_BOOL,
817 .off1 = td_var_offset(fsync_on_close),
818 .help = "fsync files on close",
819 .def = "0",
820 },
821 {
822 .name = "unlink",
823 .type = FIO_OPT_BOOL,
824 .off1 = td_var_offset(unlink),
825 .help = "Unlink created files after job has completed",
826 .def = "0",
827 },
828 {
829 .name = "exitall",
830 .type = FIO_OPT_STR_SET,
831 .cb = str_exitall_cb,
832 .help = "Terminate all jobs when one exits",
833 },
834 {
835 .name = "stonewall",
836 .type = FIO_OPT_STR_SET,
837 .off1 = td_var_offset(stonewall),
838 .help = "Insert a hard barrier between this job and previous",
839 },
b3d62a75
JA
840 {
841 .name = "new_group",
842 .type = FIO_OPT_STR_SET,
843 .off1 = td_var_offset(new_group),
844 .help = "Mark the start of a new group (for reporting)",
845 },
214e1eca
JA
846 {
847 .name = "thread",
848 .type = FIO_OPT_STR_SET,
849 .off1 = td_var_offset(use_thread),
850 .help = "Use threads instead of forks",
851 },
852 {
853 .name = "write_bw_log",
854 .type = FIO_OPT_STR_SET,
855 .off1 = td_var_offset(write_bw_log),
856 .help = "Write log of bandwidth during run",
857 },
858 {
859 .name = "write_lat_log",
860 .type = FIO_OPT_STR_SET,
861 .off1 = td_var_offset(write_lat_log),
862 .help = "Write log of latency during run",
863 },
864 {
865 .name = "hugepage-size",
866 .type = FIO_OPT_STR_VAL,
867 .off1 = td_var_offset(hugepage_size),
868 .help = "When using hugepages, specify size of each page",
869 .def = __stringify(FIO_HUGE_PAGE),
870 },
871 {
872 .name = "group_reporting",
873 .type = FIO_OPT_STR_SET,
874 .off1 = td_var_offset(group_reporting),
875 .help = "Do reporting on a per-group basis",
876 },
e9459e5a
JA
877 {
878 .name = "zero_buffers",
879 .type = FIO_OPT_STR_SET,
880 .off1 = td_var_offset(zero_buffers),
881 .help = "Init IO buffers to all zeroes",
882 },
0a839f30
JA
883#ifdef FIO_HAVE_DISK_UTIL
884 {
885 .name = "disk_util",
886 .type = FIO_OPT_BOOL,
887 .off1 = td_var_offset(do_disk_util),
888 .help = "Log disk utilization stats",
889 .def = "1",
890 },
891#endif
214e1eca
JA
892 {
893 .name = NULL,
894 },
895};
896
897void fio_options_dup_and_init(struct option *long_options)
898{
899 struct fio_option *o;
900 unsigned int i;
901
902 options_init(options);
903
904 i = 0;
905 while (long_options[i].name)
906 i++;
907
908 o = &options[0];
909 while (o->name) {
910 long_options[i].name = o->name;
911 long_options[i].val = FIO_GETOPT_JOB;
912 if (o->type == FIO_OPT_STR_SET)
913 long_options[i].has_arg = no_argument;
914 else
915 long_options[i].has_arg = required_argument;
916
917 i++;
918 o++;
919 assert(i < FIO_NR_OPTIONS);
920 }
921}
922
923int fio_option_parse(struct thread_data *td, const char *opt)
924{
925 return parse_option(opt, options, td);
926}
927
928int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
929{
930 return parse_cmd_option(opt, val, options, td);
931}
932
933void fio_fill_default_options(struct thread_data *td)
934{
935 fill_default_options(td, options);
936}
937
938int fio_show_option_help(const char *opt)
939{
940 return show_cmd_help(options, opt);
941}
d23bb327
JA
942
943static void __options_mem(struct thread_data *td, int alloc)
944{
945 struct thread_options *o = &td->o;
946 struct fio_option *opt;
947 char **ptr;
948 int i;
949
950 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
951 if (opt->type != FIO_OPT_STR_STORE)
952 continue;
953
954 ptr = (void *) o + opt->off1;
955 if (*ptr) {
956 if (alloc)
957 *ptr = strdup(*ptr);
958 else {
959 free(*ptr);
960 *ptr = NULL;
961 }
962 }
963 }
964}
965
966/*
967 * dupe FIO_OPT_STR_STORE options
968 */
969void options_mem_dupe(struct thread_data *td)
970{
971 __options_mem(td, 1);
972}
973
22d66213 974void options_mem_free(struct thread_data fio_unused *td)
d23bb327 975{
22d66213 976#if 0
d23bb327 977 __options_mem(td, 0);
22d66213 978#endif
d23bb327 979}