Add strong madvise() hint for cache pruning
[fio.git] / options.c
... / ...
CommitLineData
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#include <libgen.h>
9#include <fcntl.h>
10#include <sys/types.h>
11#include <sys/stat.h>
12
13#include "fio.h"
14#include "verify.h"
15#include "parse.h"
16#include "lib/fls.h"
17
18#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
19
20/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
36static int bs_cmp(const void *p1, const void *p2)
37{
38 const struct bssplit *bsp1 = p1;
39 const struct bssplit *bsp2 = p2;
40
41 return bsp1->perc < bsp2->perc;
42}
43
44static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
45{
46 struct bssplit *bssplit;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
49 long long val;
50 char *fname;
51
52 td->o.bssplit_nr[ddir] = 4;
53 bssplit = malloc(4 * sizeof(struct bssplit));
54
55 i = 0;
56 max_bs = 0;
57 min_bs = -1;
58 while ((fname = strsep(&str, ":")) != NULL) {
59 char *perc_str;
60
61 if (!strlen(fname))
62 break;
63
64 /*
65 * grow struct buffer, if needed
66 */
67 if (i == td->o.bssplit_nr[ddir]) {
68 td->o.bssplit_nr[ddir] <<= 1;
69 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
70 * sizeof(struct bssplit));
71 }
72
73 perc_str = strstr(fname, "/");
74 if (perc_str) {
75 *perc_str = '\0';
76 perc_str++;
77 perc = atoi(perc_str);
78 if (perc > 100)
79 perc = 100;
80 else if (!perc)
81 perc = -1;
82 } else
83 perc = -1;
84
85 if (str_to_decimal(fname, &val, 1, &td)) {
86 log_err("fio: bssplit conversion failed\n");
87 free(td->o.bssplit);
88 return 1;
89 }
90
91 if (val > max_bs)
92 max_bs = val;
93 if (val < min_bs)
94 min_bs = val;
95
96 bssplit[i].bs = val;
97 bssplit[i].perc = perc;
98 i++;
99 }
100
101 td->o.bssplit_nr[ddir] = i;
102
103 /*
104 * Now check if the percentages add up, and how much is missing
105 */
106 perc = perc_missing = 0;
107 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108 struct bssplit *bsp = &bssplit[i];
109
110 if (bsp->perc == (unsigned char) -1)
111 perc_missing++;
112 else
113 perc += bsp->perc;
114 }
115
116 if (perc > 100) {
117 log_err("fio: bssplit percentages add to more than 100%%\n");
118 free(bssplit);
119 return 1;
120 }
121 /*
122 * If values didn't have a percentage set, divide the remains between
123 * them.
124 */
125 if (perc_missing) {
126 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127 struct bssplit *bsp = &bssplit[i];
128
129 if (bsp->perc == (unsigned char) -1)
130 bsp->perc = (100 - perc) / perc_missing;
131 }
132 }
133
134 td->o.min_bs[ddir] = min_bs;
135 td->o.max_bs[ddir] = max_bs;
136
137 /*
138 * now sort based on percentages, for ease of lookup
139 */
140 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141 td->o.bssplit[ddir] = bssplit;
142 return 0;
143
144}
145
146static int str_bssplit_cb(void *data, const char *input)
147{
148 struct thread_data *td = data;
149 char *str, *p, *odir;
150 int ret = 0;
151
152 p = str = strdup(input);
153
154 strip_blank_front(&str);
155 strip_blank_end(str);
156
157 odir = strchr(str, ',');
158 if (odir) {
159 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
160 if (!ret) {
161 *odir = '\0';
162 ret = bssplit_ddir(td, DDIR_READ, str);
163 }
164 } else {
165 char *op;
166
167 op = strdup(str);
168
169 ret = bssplit_ddir(td, DDIR_READ, str);
170 if (!ret)
171 ret = bssplit_ddir(td, DDIR_WRITE, op);
172
173 free(op);
174 }
175
176 free(p);
177 return ret;
178}
179
180static int str_rw_cb(void *data, const char *str)
181{
182 struct thread_data *td = data;
183 char *nr = get_opt_postfix(str);
184
185 td->o.ddir_nr = 1;
186 if (nr) {
187 td->o.ddir_nr = atoi(nr);
188 free(nr);
189 }
190
191 return 0;
192}
193
194static int str_mem_cb(void *data, const char *mem)
195{
196 struct thread_data *td = data;
197
198 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
199 td->mmapfile = get_opt_postfix(mem);
200 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
201 log_err("fio: mmaphuge:/path/to/file\n");
202 return 1;
203 }
204 }
205
206 return 0;
207}
208
209static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
210{
211 mlock_size = *val;
212 return 0;
213}
214
215static int str_rwmix_read_cb(void *data, unsigned int *val)
216{
217 struct thread_data *td = data;
218
219 td->o.rwmix[DDIR_READ] = *val;
220 td->o.rwmix[DDIR_WRITE] = 100 - *val;
221 return 0;
222}
223
224static int str_rwmix_write_cb(void *data, unsigned int *val)
225{
226 struct thread_data *td = data;
227
228 td->o.rwmix[DDIR_WRITE] = *val;
229 td->o.rwmix[DDIR_READ] = 100 - *val;
230 return 0;
231}
232
233#ifdef FIO_HAVE_IOPRIO
234static int str_prioclass_cb(void *data, unsigned int *val)
235{
236 struct thread_data *td = data;
237 unsigned short mask;
238
239 /*
240 * mask off old class bits, str_prio_cb() may have set a default class
241 */
242 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
243 td->ioprio &= mask;
244
245 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
246 td->ioprio_set = 1;
247 return 0;
248}
249
250static int str_prio_cb(void *data, unsigned int *val)
251{
252 struct thread_data *td = data;
253
254 td->ioprio |= *val;
255
256 /*
257 * If no class is set, assume BE
258 */
259 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
261
262 td->ioprio_set = 1;
263 return 0;
264}
265#endif
266
267static int str_exitall_cb(void)
268{
269 exitall_on_terminate = 1;
270 return 0;
271}
272
273#ifdef FIO_HAVE_CPU_AFFINITY
274static int str_cpumask_cb(void *data, unsigned int *val)
275{
276 struct thread_data *td = data;
277 unsigned int i;
278 long max_cpu;
279 int ret;
280
281 ret = fio_cpuset_init(&td->o.cpumask);
282 if (ret < 0) {
283 log_err("fio: cpuset_init failed\n");
284 td_verror(td, ret, "fio_cpuset_init");
285 return 1;
286 }
287
288 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
289
290 for (i = 0; i < sizeof(int) * 8; i++) {
291 if ((1 << i) & *val) {
292 if (i > max_cpu) {
293 log_err("fio: CPU %d too large (max=%ld)\n", i,
294 max_cpu);
295 return 1;
296 }
297 dprint(FD_PARSE, "set cpu allowed %d\n", i);
298 fio_cpu_set(&td->o.cpumask, i);
299 }
300 }
301
302 td->o.cpumask_set = 1;
303 return 0;
304}
305
306static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
307 const char *input)
308{
309 char *cpu, *str, *p;
310 long max_cpu;
311 int ret = 0;
312
313 ret = fio_cpuset_init(mask);
314 if (ret < 0) {
315 log_err("fio: cpuset_init failed\n");
316 td_verror(td, ret, "fio_cpuset_init");
317 return 1;
318 }
319
320 p = str = strdup(input);
321
322 strip_blank_front(&str);
323 strip_blank_end(str);
324
325 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
326
327 while ((cpu = strsep(&str, ",")) != NULL) {
328 char *str2, *cpu2;
329 int icpu, icpu2;
330
331 if (!strlen(cpu))
332 break;
333
334 str2 = cpu;
335 icpu2 = -1;
336 while ((cpu2 = strsep(&str2, "-")) != NULL) {
337 if (!strlen(cpu2))
338 break;
339
340 icpu2 = atoi(cpu2);
341 }
342
343 icpu = atoi(cpu);
344 if (icpu2 == -1)
345 icpu2 = icpu;
346 while (icpu <= icpu2) {
347 if (icpu >= FIO_MAX_CPUS) {
348 log_err("fio: your OS only supports up to"
349 " %d CPUs\n", (int) FIO_MAX_CPUS);
350 ret = 1;
351 break;
352 }
353 if (icpu > max_cpu) {
354 log_err("fio: CPU %d too large (max=%ld)\n",
355 icpu, max_cpu);
356 ret = 1;
357 break;
358 }
359
360 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
361 fio_cpu_set(mask, icpu);
362 icpu++;
363 }
364 if (ret)
365 break;
366 }
367
368 free(p);
369 if (!ret)
370 td->o.cpumask_set = 1;
371 return ret;
372}
373
374static int str_cpus_allowed_cb(void *data, const char *input)
375{
376 struct thread_data *td = data;
377 int ret;
378
379 ret = set_cpus_allowed(td, &td->o.cpumask, input);
380 if (!ret)
381 td->o.cpumask_set = 1;
382
383 return ret;
384}
385
386static int str_verify_cpus_allowed_cb(void *data, const char *input)
387{
388 struct thread_data *td = data;
389 int ret;
390
391 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
392 if (!ret)
393 td->o.verify_cpumask_set = 1;
394
395 return ret;
396}
397#endif
398
399static int str_fst_cb(void *data, const char *str)
400{
401 struct thread_data *td = data;
402 char *nr = get_opt_postfix(str);
403
404 td->file_service_nr = 1;
405 if (nr) {
406 td->file_service_nr = atoi(nr);
407 free(nr);
408 }
409
410 return 0;
411}
412
413static int check_dir(struct thread_data *td, char *fname)
414{
415 char file[PATH_MAX], *dir;
416 int elen = 0;
417
418 if (td->o.directory) {
419 strcpy(file, td->o.directory);
420 strcat(file, "/");
421 elen = strlen(file);
422 }
423
424 sprintf(file + elen, "%s", fname);
425 dir = dirname(file);
426
427#if 0
428 {
429 struct stat sb;
430 /*
431 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
432 * yet, so we can't do this check right here...
433 */
434 if (lstat(dir, &sb) < 0) {
435 int ret = errno;
436
437 log_err("fio: %s is not a directory\n", dir);
438 td_verror(td, ret, "lstat");
439 return 1;
440 }
441
442 if (!S_ISDIR(sb.st_mode)) {
443 log_err("fio: %s is not a directory\n", dir);
444 return 1;
445 }
446 }
447#endif
448
449 return 0;
450}
451
452/*
453 * Return next file in the string. Files are separated with ':'. If the ':'
454 * is escaped with a '\', then that ':' is part of the filename and does not
455 * indicate a new file.
456 */
457static char *get_next_file_name(char **ptr)
458{
459 char *str = *ptr;
460 char *p, *start;
461
462 if (!str || !strlen(str))
463 return NULL;
464
465 start = str;
466 do {
467 /*
468 * No colon, we are done
469 */
470 p = strchr(str, ':');
471 if (!p) {
472 *ptr = NULL;
473 break;
474 }
475
476 /*
477 * We got a colon, but it's the first character. Skip and
478 * continue
479 */
480 if (p == start) {
481 str = ++start;
482 continue;
483 }
484
485 if (*(p - 1) != '\\') {
486 *p = '\0';
487 *ptr = p + 1;
488 break;
489 }
490
491 memmove(p - 1, p, strlen(p) + 1);
492 str = p;
493 } while (1);
494
495 return start;
496}
497
498static int str_filename_cb(void *data, const char *input)
499{
500 struct thread_data *td = data;
501 char *fname, *str, *p;
502
503 p = str = strdup(input);
504
505 strip_blank_front(&str);
506 strip_blank_end(str);
507
508 if (!td->files_index)
509 td->o.nr_files = 0;
510
511 while ((fname = get_next_file_name(&str)) != NULL) {
512 if (!strlen(fname))
513 break;
514 if (check_dir(td, fname)) {
515 free(p);
516 return 1;
517 }
518 add_file(td, fname);
519 td->o.nr_files++;
520 }
521
522 free(p);
523 return 0;
524}
525
526static int str_directory_cb(void *data, const char fio_unused *str)
527{
528 struct thread_data *td = data;
529 struct stat sb;
530
531 if (lstat(td->o.directory, &sb) < 0) {
532 int ret = errno;
533
534 log_err("fio: %s is not a directory\n", td->o.directory);
535 td_verror(td, ret, "lstat");
536 return 1;
537 }
538 if (!S_ISDIR(sb.st_mode)) {
539 log_err("fio: %s is not a directory\n", td->o.directory);
540 return 1;
541 }
542
543 return 0;
544}
545
546static int str_opendir_cb(void *data, const char fio_unused *str)
547{
548 struct thread_data *td = data;
549
550 if (!td->files_index)
551 td->o.nr_files = 0;
552
553 return add_dir_files(td, td->o.opendir);
554}
555
556static int str_verify_offset_cb(void *data, unsigned int *off)
557{
558 struct thread_data *td = data;
559
560 if (*off && *off < sizeof(struct verify_header)) {
561 log_err("fio: verify_offset too small\n");
562 return 1;
563 }
564
565 td->o.verify_offset = *off;
566 return 0;
567}
568
569static int str_verify_pattern_cb(void *data, unsigned int *off)
570{
571 struct thread_data *td = data;
572 unsigned int msb;
573
574 msb = __fls(*off);
575 if (msb <= 8)
576 td->o.verify_pattern_bytes = 1;
577 else if (msb <= 16)
578 td->o.verify_pattern_bytes = 2;
579 else if (msb <= 24)
580 td->o.verify_pattern_bytes = 3;
581 else
582 td->o.verify_pattern_bytes = 4;
583
584 td->o.verify_pattern = *off;
585 return 0;
586}
587
588static int str_lockfile_cb(void *data, const char *str)
589{
590 struct thread_data *td = data;
591 char *nr = get_opt_postfix(str);
592
593 td->o.lockfile_batch = 1;
594 if (nr) {
595 td->o.lockfile_batch = atoi(nr);
596 free(nr);
597 }
598
599 return 0;
600}
601
602static int str_write_bw_log_cb(void *data, const char *str)
603{
604 struct thread_data *td = data;
605
606 if (str)
607 td->o.bw_log_file = strdup(str);
608
609 td->o.write_bw_log = 1;
610 return 0;
611}
612
613static int str_write_lat_log_cb(void *data, const char *str)
614{
615 struct thread_data *td = data;
616
617 if (str)
618 td->o.lat_log_file = strdup(str);
619
620 td->o.write_lat_log = 1;
621 return 0;
622}
623
624static int str_gtod_reduce_cb(void *data, int *il)
625{
626 struct thread_data *td = data;
627 int val = *il;
628
629 td->o.disable_clat = !!val;
630 td->o.disable_slat = !!val;
631 td->o.disable_bw = !!val;
632 if (val)
633 td->tv_cache_mask = 63;
634
635 return 0;
636}
637
638static int str_gtod_cpu_cb(void *data, int *il)
639{
640 struct thread_data *td = data;
641 int val = *il;
642
643 td->o.gtod_cpu = val;
644 td->o.gtod_offload = 1;
645 return 0;
646}
647
648static int rw_verify(struct fio_option *o, void *data)
649{
650 struct thread_data *td = data;
651
652 if (read_only && td_write(td)) {
653 log_err("fio: job <%s> has write bit set, but fio is in"
654 " read-only mode\n", td->o.name);
655 return 1;
656 }
657
658 return 0;
659}
660
661static int gtod_cpu_verify(struct fio_option *o, void *data)
662{
663#ifndef FIO_HAVE_CPU_AFFINITY
664 struct thread_data *td = data;
665
666 if (td->o.gtod_cpu) {
667 log_err("fio: platform must support CPU affinity for"
668 "gettimeofday() offloading\n");
669 return 1;
670 }
671#endif
672
673 return 0;
674}
675
676static int kb_base_verify(struct fio_option *o, void *data)
677{
678 struct thread_data *td = data;
679
680 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
681 log_err("fio: kb_base set to nonsensical value: %u\n",
682 td->o.kb_base);
683 return 1;
684 }
685
686 return 0;
687}
688
689#define __stringify_1(x) #x
690#define __stringify(x) __stringify_1(x)
691
692/*
693 * Map of job/command line options
694 */
695static struct fio_option options[] = {
696 {
697 .name = "description",
698 .type = FIO_OPT_STR_STORE,
699 .off1 = td_var_offset(description),
700 .help = "Text job description",
701 },
702 {
703 .name = "name",
704 .type = FIO_OPT_STR_STORE,
705 .off1 = td_var_offset(name),
706 .help = "Name of this job",
707 },
708 {
709 .name = "directory",
710 .type = FIO_OPT_STR_STORE,
711 .off1 = td_var_offset(directory),
712 .cb = str_directory_cb,
713 .help = "Directory to store files in",
714 },
715 {
716 .name = "filename",
717 .type = FIO_OPT_STR_STORE,
718 .off1 = td_var_offset(filename),
719 .cb = str_filename_cb,
720 .prio = -1, /* must come after "directory" */
721 .help = "File(s) to use for the workload",
722 },
723 {
724 .name = "kb_base",
725 .type = FIO_OPT_INT,
726 .off1 = td_var_offset(kb_base),
727 .verify = kb_base_verify,
728 .prio = 1,
729 .def = "1024",
730 .help = "How many bytes per KB for reporting (1000 or 1024)",
731 },
732 {
733 .name = "lockfile",
734 .type = FIO_OPT_STR,
735 .cb = str_lockfile_cb,
736 .off1 = td_var_offset(file_lock_mode),
737 .help = "Lock file when doing IO to it",
738 .parent = "filename",
739 .def = "none",
740 .posval = {
741 { .ival = "none",
742 .oval = FILE_LOCK_NONE,
743 .help = "No file locking",
744 },
745 { .ival = "exclusive",
746 .oval = FILE_LOCK_EXCLUSIVE,
747 .help = "Exclusive file lock",
748 },
749 {
750 .ival = "readwrite",
751 .oval = FILE_LOCK_READWRITE,
752 .help = "Read vs write lock",
753 },
754 },
755 },
756 {
757 .name = "opendir",
758 .type = FIO_OPT_STR_STORE,
759 .off1 = td_var_offset(opendir),
760 .cb = str_opendir_cb,
761 .help = "Recursively add files from this directory and down",
762 },
763 {
764 .name = "rw",
765 .alias = "readwrite",
766 .type = FIO_OPT_STR,
767 .cb = str_rw_cb,
768 .off1 = td_var_offset(td_ddir),
769 .help = "IO direction",
770 .def = "read",
771 .verify = rw_verify,
772 .posval = {
773 { .ival = "read",
774 .oval = TD_DDIR_READ,
775 .help = "Sequential read",
776 },
777 { .ival = "write",
778 .oval = TD_DDIR_WRITE,
779 .help = "Sequential write",
780 },
781 { .ival = "randread",
782 .oval = TD_DDIR_RANDREAD,
783 .help = "Random read",
784 },
785 { .ival = "randwrite",
786 .oval = TD_DDIR_RANDWRITE,
787 .help = "Random write",
788 },
789 { .ival = "rw",
790 .oval = TD_DDIR_RW,
791 .help = "Sequential read and write mix",
792 },
793 { .ival = "randrw",
794 .oval = TD_DDIR_RANDRW,
795 .help = "Random read and write mix"
796 },
797 },
798 },
799 {
800 .name = "ioengine",
801 .type = FIO_OPT_STR_STORE,
802 .off1 = td_var_offset(ioengine),
803 .help = "IO engine to use",
804 .def = "sync",
805 .posval = {
806 { .ival = "sync",
807 .help = "Use read/write",
808 },
809 { .ival = "psync",
810 .help = "Use pread/pwrite",
811 },
812 { .ival = "vsync",
813 .help = "Use readv/writev",
814 },
815#ifdef FIO_HAVE_LIBAIO
816 { .ival = "libaio",
817 .help = "Linux native asynchronous IO",
818 },
819#endif
820#ifdef FIO_HAVE_POSIXAIO
821 { .ival = "posixaio",
822 .help = "POSIX asynchronous IO",
823 },
824#endif
825#ifdef FIO_HAVE_SOLARISAIO
826 { .ival = "solarisaio",
827 .help = "Solaris native asynchronous IO",
828 },
829#endif
830 { .ival = "mmap",
831 .help = "Memory mapped IO",
832 },
833#ifdef FIO_HAVE_SPLICE
834 { .ival = "splice",
835 .help = "splice/vmsplice based IO",
836 },
837 { .ival = "netsplice",
838 .help = "splice/vmsplice to/from the network",
839 },
840#endif
841#ifdef FIO_HAVE_SGIO
842 { .ival = "sg",
843 .help = "SCSI generic v3 IO",
844 },
845#endif
846 { .ival = "null",
847 .help = "Testing engine (no data transfer)",
848 },
849 { .ival = "net",
850 .help = "Network IO",
851 },
852#ifdef FIO_HAVE_SYSLET
853 { .ival = "syslet-rw",
854 .help = "syslet enabled async pread/pwrite IO",
855 },
856#endif
857 { .ival = "cpuio",
858 .help = "CPU cycler burner engine",
859 },
860#ifdef FIO_HAVE_GUASI
861 { .ival = "guasi",
862 .help = "GUASI IO engine",
863 },
864#endif
865 { .ival = "external",
866 .help = "Load external engine (append name)",
867 },
868 },
869 },
870 {
871 .name = "iodepth",
872 .type = FIO_OPT_INT,
873 .off1 = td_var_offset(iodepth),
874 .help = "Amount of IO buffers to keep in flight",
875 .minval = 1,
876 .def = "1",
877 },
878 {
879 .name = "iodepth_batch",
880 .alias = "iodepth_batch_submit",
881 .type = FIO_OPT_INT,
882 .off1 = td_var_offset(iodepth_batch),
883 .help = "Number of IO buffers to submit in one go",
884 .parent = "iodepth",
885 .minval = 1,
886 .def = "1",
887 },
888 {
889 .name = "iodepth_batch_complete",
890 .type = FIO_OPT_INT,
891 .off1 = td_var_offset(iodepth_batch_complete),
892 .help = "Number of IO buffers to retrieve in one go",
893 .parent = "iodepth",
894 .minval = 0,
895 .def = "1",
896 },
897 {
898 .name = "iodepth_low",
899 .type = FIO_OPT_INT,
900 .off1 = td_var_offset(iodepth_low),
901 .help = "Low water mark for queuing depth",
902 .parent = "iodepth",
903 },
904 {
905 .name = "size",
906 .type = FIO_OPT_STR_VAL,
907 .off1 = td_var_offset(size),
908 .minval = 1,
909 .help = "Total size of device or files",
910 },
911 {
912 .name = "fill_device",
913 .type = FIO_OPT_BOOL,
914 .off1 = td_var_offset(fill_device),
915 .help = "Write until an ENOSPC error occurs",
916 .def = "0",
917 },
918 {
919 .name = "filesize",
920 .type = FIO_OPT_STR_VAL,
921 .off1 = td_var_offset(file_size_low),
922 .off2 = td_var_offset(file_size_high),
923 .minval = 1,
924 .help = "Size of individual files",
925 },
926 {
927 .name = "offset",
928 .alias = "fileoffset",
929 .type = FIO_OPT_STR_VAL,
930 .off1 = td_var_offset(start_offset),
931 .help = "Start IO from this offset",
932 .def = "0",
933 },
934 {
935 .name = "bs",
936 .alias = "blocksize",
937 .type = FIO_OPT_INT,
938 .off1 = td_var_offset(bs[DDIR_READ]),
939 .off2 = td_var_offset(bs[DDIR_WRITE]),
940 .minval = 1,
941 .help = "Block size unit",
942 .def = "4k",
943 .parent = "rw",
944 },
945 {
946 .name = "ba",
947 .alias = "blockalign",
948 .type = FIO_OPT_INT,
949 .off1 = td_var_offset(ba[DDIR_READ]),
950 .off2 = td_var_offset(ba[DDIR_WRITE]),
951 .minval = 1,
952 .help = "IO block offset alignment",
953 .parent = "rw",
954 },
955 {
956 .name = "bsrange",
957 .alias = "blocksize_range",
958 .type = FIO_OPT_RANGE,
959 .off1 = td_var_offset(min_bs[DDIR_READ]),
960 .off2 = td_var_offset(max_bs[DDIR_READ]),
961 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
962 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
963 .minval = 1,
964 .help = "Set block size range (in more detail than bs)",
965 .parent = "rw",
966 },
967 {
968 .name = "bssplit",
969 .type = FIO_OPT_STR,
970 .cb = str_bssplit_cb,
971 .help = "Set a specific mix of block sizes",
972 .parent = "rw",
973 },
974 {
975 .name = "bs_unaligned",
976 .alias = "blocksize_unaligned",
977 .type = FIO_OPT_STR_SET,
978 .off1 = td_var_offset(bs_unaligned),
979 .help = "Don't sector align IO buffer sizes",
980 .parent = "rw",
981 },
982 {
983 .name = "randrepeat",
984 .type = FIO_OPT_BOOL,
985 .off1 = td_var_offset(rand_repeatable),
986 .help = "Use repeatable random IO pattern",
987 .def = "1",
988 .parent = "rw",
989 },
990 {
991 .name = "norandommap",
992 .type = FIO_OPT_STR_SET,
993 .off1 = td_var_offset(norandommap),
994 .help = "Accept potential duplicate random blocks",
995 .parent = "rw",
996 },
997 {
998 .name = "softrandommap",
999 .type = FIO_OPT_BOOL,
1000 .off1 = td_var_offset(softrandommap),
1001 .help = "Set norandommap if randommap allocation fails",
1002 .parent = "norandommap",
1003 .def = "0",
1004 },
1005 {
1006 .name = "nrfiles",
1007 .type = FIO_OPT_INT,
1008 .off1 = td_var_offset(nr_files),
1009 .help = "Split job workload between this number of files",
1010 .def = "1",
1011 },
1012 {
1013 .name = "openfiles",
1014 .type = FIO_OPT_INT,
1015 .off1 = td_var_offset(open_files),
1016 .help = "Number of files to keep open at the same time",
1017 },
1018 {
1019 .name = "file_service_type",
1020 .type = FIO_OPT_STR,
1021 .cb = str_fst_cb,
1022 .off1 = td_var_offset(file_service_type),
1023 .help = "How to select which file to service next",
1024 .def = "roundrobin",
1025 .posval = {
1026 { .ival = "random",
1027 .oval = FIO_FSERVICE_RANDOM,
1028 .help = "Choose a file at random",
1029 },
1030 { .ival = "roundrobin",
1031 .oval = FIO_FSERVICE_RR,
1032 .help = "Round robin select files",
1033 },
1034 { .ival = "sequential",
1035 .oval = FIO_FSERVICE_SEQ,
1036 .help = "Finish one file before moving to the next",
1037 },
1038 },
1039 .parent = "nrfiles",
1040 },
1041 {
1042 .name = "fadvise_hint",
1043 .type = FIO_OPT_BOOL,
1044 .off1 = td_var_offset(fadvise_hint),
1045 .help = "Use fadvise() to advise the kernel on IO pattern",
1046 .def = "1",
1047 },
1048 {
1049 .name = "fsync",
1050 .type = FIO_OPT_INT,
1051 .off1 = td_var_offset(fsync_blocks),
1052 .help = "Issue fsync for writes every given number of blocks",
1053 .def = "0",
1054 },
1055 {
1056 .name = "fdatasync",
1057 .type = FIO_OPT_INT,
1058 .off1 = td_var_offset(fdatasync_blocks),
1059 .help = "Issue fdatasync for writes every given number of blocks",
1060 .def = "0",
1061 },
1062 {
1063 .name = "direct",
1064 .type = FIO_OPT_BOOL,
1065 .off1 = td_var_offset(odirect),
1066 .help = "Use O_DIRECT IO (negates buffered)",
1067 .def = "0",
1068 },
1069 {
1070 .name = "buffered",
1071 .type = FIO_OPT_BOOL,
1072 .off1 = td_var_offset(odirect),
1073 .neg = 1,
1074 .help = "Use buffered IO (negates direct)",
1075 .def = "1",
1076 },
1077 {
1078 .name = "overwrite",
1079 .type = FIO_OPT_BOOL,
1080 .off1 = td_var_offset(overwrite),
1081 .help = "When writing, set whether to overwrite current data",
1082 .def = "0",
1083 },
1084 {
1085 .name = "loops",
1086 .type = FIO_OPT_INT,
1087 .off1 = td_var_offset(loops),
1088 .help = "Number of times to run the job",
1089 .def = "1",
1090 },
1091 {
1092 .name = "numjobs",
1093 .type = FIO_OPT_INT,
1094 .off1 = td_var_offset(numjobs),
1095 .help = "Duplicate this job this many times",
1096 .def = "1",
1097 },
1098 {
1099 .name = "startdelay",
1100 .type = FIO_OPT_INT,
1101 .off1 = td_var_offset(start_delay),
1102 .help = "Only start job when this period has passed",
1103 .def = "0",
1104 },
1105 {
1106 .name = "runtime",
1107 .alias = "timeout",
1108 .type = FIO_OPT_STR_VAL_TIME,
1109 .off1 = td_var_offset(timeout),
1110 .help = "Stop workload when this amount of time has passed",
1111 .def = "0",
1112 },
1113 {
1114 .name = "time_based",
1115 .type = FIO_OPT_STR_SET,
1116 .off1 = td_var_offset(time_based),
1117 .help = "Keep running until runtime/timeout is met",
1118 },
1119 {
1120 .name = "ramp_time",
1121 .type = FIO_OPT_STR_VAL_TIME,
1122 .off1 = td_var_offset(ramp_time),
1123 .help = "Ramp up time before measuring performance",
1124 },
1125 {
1126 .name = "mem",
1127 .alias = "iomem",
1128 .type = FIO_OPT_STR,
1129 .cb = str_mem_cb,
1130 .off1 = td_var_offset(mem_type),
1131 .help = "Backing type for IO buffers",
1132 .def = "malloc",
1133 .posval = {
1134 { .ival = "malloc",
1135 .oval = MEM_MALLOC,
1136 .help = "Use malloc(3) for IO buffers",
1137 },
1138 { .ival = "shm",
1139 .oval = MEM_SHM,
1140 .help = "Use shared memory segments for IO buffers",
1141 },
1142#ifdef FIO_HAVE_HUGETLB
1143 { .ival = "shmhuge",
1144 .oval = MEM_SHMHUGE,
1145 .help = "Like shm, but use huge pages",
1146 },
1147#endif
1148 { .ival = "mmap",
1149 .oval = MEM_MMAP,
1150 .help = "Use mmap(2) (file or anon) for IO buffers",
1151 },
1152#ifdef FIO_HAVE_HUGETLB
1153 { .ival = "mmaphuge",
1154 .oval = MEM_MMAPHUGE,
1155 .help = "Like mmap, but use huge pages",
1156 },
1157#endif
1158 },
1159 },
1160 {
1161 .name = "iomem_align",
1162 .alias = "mem_align",
1163 .type = FIO_OPT_INT,
1164 .off1 = td_var_offset(mem_align),
1165 .minval = 0,
1166 .help = "IO memory buffer offset alignment",
1167 .def = "0",
1168 .parent = "iomem",
1169 },
1170 {
1171 .name = "verify",
1172 .type = FIO_OPT_STR,
1173 .off1 = td_var_offset(verify),
1174 .help = "Verify data written",
1175 .def = "0",
1176 .posval = {
1177 { .ival = "0",
1178 .oval = VERIFY_NONE,
1179 .help = "Don't do IO verification",
1180 },
1181 { .ival = "md5",
1182 .oval = VERIFY_MD5,
1183 .help = "Use md5 checksums for verification",
1184 },
1185 { .ival = "crc64",
1186 .oval = VERIFY_CRC64,
1187 .help = "Use crc64 checksums for verification",
1188 },
1189 { .ival = "crc32",
1190 .oval = VERIFY_CRC32,
1191 .help = "Use crc32 checksums for verification",
1192 },
1193 { .ival = "crc32c-intel",
1194 .oval = VERIFY_CRC32C_INTEL,
1195 .help = "Use hw crc32c checksums for verification",
1196 },
1197 { .ival = "crc32c",
1198 .oval = VERIFY_CRC32C,
1199 .help = "Use crc32c checksums for verification",
1200 },
1201 { .ival = "crc16",
1202 .oval = VERIFY_CRC16,
1203 .help = "Use crc16 checksums for verification",
1204 },
1205 { .ival = "crc7",
1206 .oval = VERIFY_CRC7,
1207 .help = "Use crc7 checksums for verification",
1208 },
1209 { .ival = "sha256",
1210 .oval = VERIFY_SHA256,
1211 .help = "Use sha256 checksums for verification",
1212 },
1213 { .ival = "sha512",
1214 .oval = VERIFY_SHA512,
1215 .help = "Use sha512 checksums for verification",
1216 },
1217 { .ival = "meta",
1218 .oval = VERIFY_META,
1219 .help = "Use io information",
1220 },
1221 {
1222 .ival = "null",
1223 .oval = VERIFY_NULL,
1224 .help = "Pretend to verify",
1225 },
1226 },
1227 },
1228 {
1229 .name = "do_verify",
1230 .type = FIO_OPT_BOOL,
1231 .off1 = td_var_offset(do_verify),
1232 .help = "Run verification stage after write",
1233 .def = "1",
1234 .parent = "verify",
1235 },
1236 {
1237 .name = "verifysort",
1238 .type = FIO_OPT_BOOL,
1239 .off1 = td_var_offset(verifysort),
1240 .help = "Sort written verify blocks for read back",
1241 .def = "1",
1242 .parent = "verify",
1243 },
1244 {
1245 .name = "verify_interval",
1246 .type = FIO_OPT_INT,
1247 .off1 = td_var_offset(verify_interval),
1248 .minval = 2 * sizeof(struct verify_header),
1249 .help = "Store verify buffer header every N bytes",
1250 .parent = "verify",
1251 },
1252 {
1253 .name = "verify_offset",
1254 .type = FIO_OPT_INT,
1255 .help = "Offset verify header location by N bytes",
1256 .def = "0",
1257 .cb = str_verify_offset_cb,
1258 .parent = "verify",
1259 },
1260 {
1261 .name = "verify_pattern",
1262 .type = FIO_OPT_INT,
1263 .cb = str_verify_pattern_cb,
1264 .help = "Fill pattern for IO buffers",
1265 .parent = "verify",
1266 },
1267 {
1268 .name = "verify_fatal",
1269 .type = FIO_OPT_BOOL,
1270 .off1 = td_var_offset(verify_fatal),
1271 .def = "0",
1272 .help = "Exit on a single verify failure, don't continue",
1273 .parent = "verify",
1274 },
1275 {
1276 .name = "verify_async",
1277 .type = FIO_OPT_INT,
1278 .off1 = td_var_offset(verify_async),
1279 .def = "0",
1280 .help = "Number of async verifier threads to use",
1281 .parent = "verify",
1282 },
1283#ifdef FIO_HAVE_CPU_AFFINITY
1284 {
1285 .name = "verify_async_cpus",
1286 .type = FIO_OPT_STR,
1287 .cb = str_verify_cpus_allowed_cb,
1288 .help = "Set CPUs allowed for async verify threads",
1289 .parent = "verify_async",
1290 },
1291#endif
1292 {
1293 .name = "write_iolog",
1294 .type = FIO_OPT_STR_STORE,
1295 .off1 = td_var_offset(write_iolog_file),
1296 .help = "Store IO pattern to file",
1297 },
1298 {
1299 .name = "read_iolog",
1300 .type = FIO_OPT_STR_STORE,
1301 .off1 = td_var_offset(read_iolog_file),
1302 .help = "Playback IO pattern from file",
1303 },
1304 {
1305 .name = "exec_prerun",
1306 .type = FIO_OPT_STR_STORE,
1307 .off1 = td_var_offset(exec_prerun),
1308 .help = "Execute this file prior to running job",
1309 },
1310 {
1311 .name = "exec_postrun",
1312 .type = FIO_OPT_STR_STORE,
1313 .off1 = td_var_offset(exec_postrun),
1314 .help = "Execute this file after running job",
1315 },
1316#ifdef FIO_HAVE_IOSCHED_SWITCH
1317 {
1318 .name = "ioscheduler",
1319 .type = FIO_OPT_STR_STORE,
1320 .off1 = td_var_offset(ioscheduler),
1321 .help = "Use this IO scheduler on the backing device",
1322 },
1323#endif
1324 {
1325 .name = "zonesize",
1326 .type = FIO_OPT_STR_VAL,
1327 .off1 = td_var_offset(zone_size),
1328 .help = "Give size of an IO zone",
1329 .def = "0",
1330 },
1331 {
1332 .name = "zoneskip",
1333 .type = FIO_OPT_STR_VAL,
1334 .off1 = td_var_offset(zone_skip),
1335 .help = "Space between IO zones",
1336 .def = "0",
1337 },
1338 {
1339 .name = "lockmem",
1340 .type = FIO_OPT_STR_VAL,
1341 .cb = str_lockmem_cb,
1342 .help = "Lock down this amount of memory",
1343 .def = "0",
1344 },
1345 {
1346 .name = "rwmixread",
1347 .type = FIO_OPT_INT,
1348 .cb = str_rwmix_read_cb,
1349 .maxval = 100,
1350 .help = "Percentage of mixed workload that is reads",
1351 .def = "50",
1352 },
1353 {
1354 .name = "rwmixwrite",
1355 .type = FIO_OPT_INT,
1356 .cb = str_rwmix_write_cb,
1357 .maxval = 100,
1358 .help = "Percentage of mixed workload that is writes",
1359 .def = "50",
1360 },
1361 {
1362 .name = "rwmixcycle",
1363 .type = FIO_OPT_DEPRECATED,
1364 },
1365 {
1366 .name = "nice",
1367 .type = FIO_OPT_INT,
1368 .off1 = td_var_offset(nice),
1369 .help = "Set job CPU nice value",
1370 .minval = -19,
1371 .maxval = 20,
1372 .def = "0",
1373 },
1374#ifdef FIO_HAVE_IOPRIO
1375 {
1376 .name = "prio",
1377 .type = FIO_OPT_INT,
1378 .cb = str_prio_cb,
1379 .help = "Set job IO priority value",
1380 .minval = 0,
1381 .maxval = 7,
1382 },
1383 {
1384 .name = "prioclass",
1385 .type = FIO_OPT_INT,
1386 .cb = str_prioclass_cb,
1387 .help = "Set job IO priority class",
1388 .minval = 0,
1389 .maxval = 3,
1390 },
1391#endif
1392 {
1393 .name = "thinktime",
1394 .type = FIO_OPT_INT,
1395 .off1 = td_var_offset(thinktime),
1396 .help = "Idle time between IO buffers (usec)",
1397 .def = "0",
1398 },
1399 {
1400 .name = "thinktime_spin",
1401 .type = FIO_OPT_INT,
1402 .off1 = td_var_offset(thinktime_spin),
1403 .help = "Start think time by spinning this amount (usec)",
1404 .def = "0",
1405 .parent = "thinktime",
1406 },
1407 {
1408 .name = "thinktime_blocks",
1409 .type = FIO_OPT_INT,
1410 .off1 = td_var_offset(thinktime_blocks),
1411 .help = "IO buffer period between 'thinktime'",
1412 .def = "1",
1413 .parent = "thinktime",
1414 },
1415 {
1416 .name = "rate",
1417 .type = FIO_OPT_INT,
1418 .off1 = td_var_offset(rate[0]),
1419 .off2 = td_var_offset(rate[1]),
1420 .help = "Set bandwidth rate",
1421 },
1422 {
1423 .name = "ratemin",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(ratemin[0]),
1426 .off2 = td_var_offset(ratemin[1]),
1427 .help = "Job must meet this rate or it will be shutdown",
1428 .parent = "rate",
1429 },
1430 {
1431 .name = "rate_iops",
1432 .type = FIO_OPT_INT,
1433 .off1 = td_var_offset(rate_iops[0]),
1434 .off2 = td_var_offset(rate_iops[1]),
1435 .help = "Limit IO used to this number of IO operations/sec",
1436 },
1437 {
1438 .name = "rate_iops_min",
1439 .type = FIO_OPT_INT,
1440 .off1 = td_var_offset(rate_iops_min[0]),
1441 .off2 = td_var_offset(rate_iops_min[1]),
1442 .help = "Job must meet this rate or it will be shutdown",
1443 .parent = "rate_iops",
1444 },
1445 {
1446 .name = "ratecycle",
1447 .type = FIO_OPT_INT,
1448 .off1 = td_var_offset(ratecycle),
1449 .help = "Window average for rate limits (msec)",
1450 .def = "1000",
1451 .parent = "rate",
1452 },
1453 {
1454 .name = "invalidate",
1455 .type = FIO_OPT_BOOL,
1456 .off1 = td_var_offset(invalidate_cache),
1457 .help = "Invalidate buffer/page cache prior to running job",
1458 .def = "1",
1459 },
1460 {
1461 .name = "sync",
1462 .type = FIO_OPT_BOOL,
1463 .off1 = td_var_offset(sync_io),
1464 .help = "Use O_SYNC for buffered writes",
1465 .def = "0",
1466 .parent = "buffered",
1467 },
1468 {
1469 .name = "bwavgtime",
1470 .type = FIO_OPT_INT,
1471 .off1 = td_var_offset(bw_avg_time),
1472 .help = "Time window over which to calculate bandwidth"
1473 " (msec)",
1474 .def = "500",
1475 },
1476 {
1477 .name = "create_serialize",
1478 .type = FIO_OPT_BOOL,
1479 .off1 = td_var_offset(create_serialize),
1480 .help = "Serialize creating of job files",
1481 .def = "1",
1482 },
1483 {
1484 .name = "create_fsync",
1485 .type = FIO_OPT_BOOL,
1486 .off1 = td_var_offset(create_fsync),
1487 .help = "Fsync file after creation",
1488 .def = "1",
1489 },
1490 {
1491 .name = "create_on_open",
1492 .type = FIO_OPT_BOOL,
1493 .off1 = td_var_offset(create_on_open),
1494 .help = "Create files when they are opened for IO",
1495 .def = "0",
1496 },
1497 {
1498 .name = "pre_read",
1499 .type = FIO_OPT_BOOL,
1500 .off1 = td_var_offset(pre_read),
1501 .help = "Preread files before starting official testing",
1502 .def = "0",
1503 },
1504 {
1505 .name = "cpuload",
1506 .type = FIO_OPT_INT,
1507 .off1 = td_var_offset(cpuload),
1508 .help = "Use this percentage of CPU",
1509 },
1510 {
1511 .name = "cpuchunks",
1512 .type = FIO_OPT_INT,
1513 .off1 = td_var_offset(cpucycle),
1514 .help = "Length of the CPU burn cycles (usecs)",
1515 .def = "50000",
1516 .parent = "cpuload",
1517 },
1518#ifdef FIO_HAVE_CPU_AFFINITY
1519 {
1520 .name = "cpumask",
1521 .type = FIO_OPT_INT,
1522 .cb = str_cpumask_cb,
1523 .help = "CPU affinity mask",
1524 },
1525 {
1526 .name = "cpus_allowed",
1527 .type = FIO_OPT_STR,
1528 .cb = str_cpus_allowed_cb,
1529 .help = "Set CPUs allowed",
1530 },
1531#endif
1532 {
1533 .name = "end_fsync",
1534 .type = FIO_OPT_BOOL,
1535 .off1 = td_var_offset(end_fsync),
1536 .help = "Include fsync at the end of job",
1537 .def = "0",
1538 },
1539 {
1540 .name = "fsync_on_close",
1541 .type = FIO_OPT_BOOL,
1542 .off1 = td_var_offset(fsync_on_close),
1543 .help = "fsync files on close",
1544 .def = "0",
1545 },
1546 {
1547 .name = "unlink",
1548 .type = FIO_OPT_BOOL,
1549 .off1 = td_var_offset(unlink),
1550 .help = "Unlink created files after job has completed",
1551 .def = "0",
1552 },
1553 {
1554 .name = "exitall",
1555 .type = FIO_OPT_STR_SET,
1556 .cb = str_exitall_cb,
1557 .help = "Terminate all jobs when one exits",
1558 },
1559 {
1560 .name = "stonewall",
1561 .type = FIO_OPT_STR_SET,
1562 .off1 = td_var_offset(stonewall),
1563 .help = "Insert a hard barrier between this job and previous",
1564 },
1565 {
1566 .name = "new_group",
1567 .type = FIO_OPT_STR_SET,
1568 .off1 = td_var_offset(new_group),
1569 .help = "Mark the start of a new group (for reporting)",
1570 },
1571 {
1572 .name = "thread",
1573 .type = FIO_OPT_STR_SET,
1574 .off1 = td_var_offset(use_thread),
1575 .help = "Use threads instead of forks",
1576 },
1577 {
1578 .name = "write_bw_log",
1579 .type = FIO_OPT_STR,
1580 .off1 = td_var_offset(write_bw_log),
1581 .cb = str_write_bw_log_cb,
1582 .help = "Write log of bandwidth during run",
1583 },
1584 {
1585 .name = "write_lat_log",
1586 .type = FIO_OPT_STR,
1587 .off1 = td_var_offset(write_lat_log),
1588 .cb = str_write_lat_log_cb,
1589 .help = "Write log of latency during run",
1590 },
1591 {
1592 .name = "hugepage-size",
1593 .type = FIO_OPT_INT,
1594 .off1 = td_var_offset(hugepage_size),
1595 .help = "When using hugepages, specify size of each page",
1596 .def = __stringify(FIO_HUGE_PAGE),
1597 },
1598 {
1599 .name = "group_reporting",
1600 .type = FIO_OPT_STR_SET,
1601 .off1 = td_var_offset(group_reporting),
1602 .help = "Do reporting on a per-group basis",
1603 },
1604 {
1605 .name = "zero_buffers",
1606 .type = FIO_OPT_STR_SET,
1607 .off1 = td_var_offset(zero_buffers),
1608 .help = "Init IO buffers to all zeroes",
1609 },
1610 {
1611 .name = "refill_buffers",
1612 .type = FIO_OPT_STR_SET,
1613 .off1 = td_var_offset(refill_buffers),
1614 .help = "Refill IO buffers on every IO submit",
1615 },
1616#ifdef FIO_HAVE_DISK_UTIL
1617 {
1618 .name = "disk_util",
1619 .type = FIO_OPT_BOOL,
1620 .off1 = td_var_offset(do_disk_util),
1621 .help = "Log disk utilization statistics",
1622 .def = "1",
1623 },
1624#endif
1625 {
1626 .name = "gtod_reduce",
1627 .type = FIO_OPT_BOOL,
1628 .help = "Greatly reduce number of gettimeofday() calls",
1629 .cb = str_gtod_reduce_cb,
1630 .def = "0",
1631 },
1632 {
1633 .name = "disable_clat",
1634 .type = FIO_OPT_BOOL,
1635 .off1 = td_var_offset(disable_clat),
1636 .help = "Disable completion latency numbers",
1637 .parent = "gtod_reduce",
1638 .def = "0",
1639 },
1640 {
1641 .name = "disable_slat",
1642 .type = FIO_OPT_BOOL,
1643 .off1 = td_var_offset(disable_slat),
1644 .help = "Disable submissionn latency numbers",
1645 .parent = "gtod_reduce",
1646 .def = "0",
1647 },
1648 {
1649 .name = "disable_bw_measurement",
1650 .type = FIO_OPT_BOOL,
1651 .off1 = td_var_offset(disable_bw),
1652 .help = "Disable bandwidth logging",
1653 .parent = "gtod_reduce",
1654 .def = "0",
1655 },
1656 {
1657 .name = "gtod_cpu",
1658 .type = FIO_OPT_INT,
1659 .cb = str_gtod_cpu_cb,
1660 .help = "Setup dedicated gettimeofday() thread on this CPU",
1661 .verify = gtod_cpu_verify,
1662 },
1663 {
1664 .name = "continue_on_error",
1665 .type = FIO_OPT_BOOL,
1666 .off1 = td_var_offset(continue_on_error),
1667 .help = "Continue on non-fatal errors during I/O",
1668 .def = "0",
1669 },
1670 {
1671 .name = NULL,
1672 },
1673};
1674
1675void fio_options_dup_and_init(struct option *long_options)
1676{
1677 struct fio_option *o;
1678 unsigned int i;
1679
1680 options_init(options);
1681
1682 i = 0;
1683 while (long_options[i].name)
1684 i++;
1685
1686 o = &options[0];
1687 while (o->name) {
1688 long_options[i].name = (char *) o->name;
1689 long_options[i].val = FIO_GETOPT_JOB;
1690 if (o->type == FIO_OPT_STR_SET)
1691 long_options[i].has_arg = no_argument;
1692 else
1693 long_options[i].has_arg = required_argument;
1694
1695 i++;
1696 o++;
1697 assert(i < FIO_NR_OPTIONS);
1698 }
1699}
1700
1701int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1702{
1703 int i, ret;
1704
1705 sort_options(opts, options, num_opts);
1706
1707 for (ret = 0, i = 0; i < num_opts; i++)
1708 ret |= parse_option(opts[i], options, td);
1709
1710 return ret;
1711}
1712
1713int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1714{
1715 return parse_cmd_option(opt, val, options, td);
1716}
1717
1718void fio_fill_default_options(struct thread_data *td)
1719{
1720 fill_default_options(td, options);
1721}
1722
1723int fio_show_option_help(const char *opt)
1724{
1725 return show_cmd_help(options, opt);
1726}
1727
1728static void __options_mem(struct thread_data *td, int alloc)
1729{
1730 struct thread_options *o = &td->o;
1731 struct fio_option *opt;
1732 char **ptr;
1733 int i;
1734
1735 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1736 if (opt->type != FIO_OPT_STR_STORE)
1737 continue;
1738
1739 ptr = (void *) o + opt->off1;
1740 if (*ptr) {
1741 if (alloc)
1742 *ptr = strdup(*ptr);
1743 else {
1744 free(*ptr);
1745 *ptr = NULL;
1746 }
1747 }
1748 }
1749}
1750
1751/*
1752 * dupe FIO_OPT_STR_STORE options
1753 */
1754void options_mem_dupe(struct thread_data *td)
1755{
1756 __options_mem(td, 1);
1757}
1758
1759void options_mem_free(struct thread_data fio_unused *td)
1760{
1761#if 0
1762 __options_mem(td, 0);
1763#endif
1764}
1765
1766unsigned int fio_get_kb_base(void *data)
1767{
1768 struct thread_data *td = data;
1769 unsigned int kb_base = 0;
1770
1771 if (td)
1772 kb_base = td->o.kb_base;
1773 if (!kb_base)
1774 kb_base = 1024;
1775
1776 return kb_base;
1777}