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