lib/pattern: Support short repeated read calls when loading from file
[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 <assert.h>
7#include <sys/stat.h>
8#include <netinet/in.h>
9
10#include "fio.h"
11#include "verify.h"
12#include "parse.h"
13#include "lib/pattern.h"
14#include "options.h"
15#include "optgroup.h"
16#include "zbd.h"
17
18char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
19
20#define cb_data_to_td(data) container_of(data, struct thread_data, o)
21
22static const struct pattern_fmt_desc fmt_desc[] = {
23 {
24 .fmt = "%o",
25 .len = FIO_FIELD_SIZE(struct io_u *, offset),
26 .paste = paste_blockoff
27 },
28 { }
29};
30
31/*
32 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
33 */
34static char *get_opt_postfix(const char *str)
35{
36 char *p = strstr(str, ":");
37
38 if (!p)
39 return NULL;
40
41 p++;
42 strip_blank_front(&p);
43 strip_blank_end(p);
44 return strdup(p);
45}
46
47static bool split_parse_distr(const char *str, double *val, double *center)
48{
49 char *cp, *p;
50 bool r;
51
52 p = strdup(str);
53 if (!p)
54 return false;
55
56 cp = strstr(p, ":");
57 r = true;
58 if (cp) {
59 *cp = '\0';
60 cp++;
61 r = str_to_float(cp, center, 0);
62 }
63 r = r && str_to_float(p, val, 0);
64 free(p);
65 return r;
66}
67
68static int bs_cmp(const void *p1, const void *p2)
69{
70 const struct bssplit *bsp1 = p1;
71 const struct bssplit *bsp2 = p2;
72
73 return (int) bsp1->perc - (int) bsp2->perc;
74}
75
76int split_parse_ddir(struct thread_options *o, struct split *split,
77 char *str, bool absolute, unsigned int max_splits)
78{
79 unsigned long long perc;
80 unsigned int i;
81 long long val;
82 char *fname;
83
84 split->nr = 0;
85
86 i = 0;
87 while ((fname = strsep(&str, ":")) != NULL) {
88 char *perc_str;
89
90 if (!strlen(fname))
91 break;
92
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
97 if (absolute) {
98 if (str_to_decimal(perc_str, &val, 1, o, 0, 0)) {
99 log_err("fio: split conversion failed\n");
100 return 1;
101 }
102 perc = val;
103 } else {
104 perc = atoi(perc_str);
105 if (perc > 100)
106 perc = 100;
107 else if (!perc)
108 perc = -1U;
109 }
110 } else {
111 if (absolute)
112 perc = 0;
113 else
114 perc = -1U;
115 }
116
117 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
118 log_err("fio: split conversion failed\n");
119 return 1;
120 }
121
122 split->val1[i] = val;
123 split->val2[i] = perc;
124 i++;
125 if (i == max_splits) {
126 log_err("fio: hit max of %d split entries\n", i);
127 break;
128 }
129 }
130
131 split->nr = i;
132 return 0;
133}
134
135static int bssplit_ddir(struct thread_options *o, void *eo,
136 enum fio_ddir ddir, char *str, bool data)
137{
138 unsigned int i, perc, perc_missing;
139 unsigned long long max_bs, min_bs;
140 struct split split;
141
142 memset(&split, 0, sizeof(split));
143
144 if (split_parse_ddir(o, &split, str, data, BSSPLIT_MAX))
145 return 1;
146 if (!split.nr)
147 return 0;
148
149 max_bs = 0;
150 min_bs = -1;
151 o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
152 o->bssplit_nr[ddir] = split.nr;
153 for (i = 0; i < split.nr; i++) {
154 if (split.val1[i] > max_bs)
155 max_bs = split.val1[i];
156 if (split.val1[i] < min_bs)
157 min_bs = split.val1[i];
158
159 o->bssplit[ddir][i].bs = split.val1[i];
160 o->bssplit[ddir][i].perc =split.val2[i];
161 }
162
163 /*
164 * Now check if the percentages add up, and how much is missing
165 */
166 perc = perc_missing = 0;
167 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
168 struct bssplit *bsp = &o->bssplit[ddir][i];
169
170 if (bsp->perc == -1U)
171 perc_missing++;
172 else
173 perc += bsp->perc;
174 }
175
176 if (perc > 100 && perc_missing > 1) {
177 log_err("fio: bssplit percentages add to more than 100%%\n");
178 free(o->bssplit[ddir]);
179 o->bssplit[ddir] = NULL;
180 return 1;
181 }
182
183 /*
184 * If values didn't have a percentage set, divide the remains between
185 * them.
186 */
187 if (perc_missing) {
188 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
189 perc = 100;
190 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
191 struct bssplit *bsp = &o->bssplit[ddir][i];
192
193 if (bsp->perc == -1U)
194 bsp->perc = (100 - perc) / perc_missing;
195 }
196 }
197
198 o->min_bs[ddir] = min_bs;
199 o->max_bs[ddir] = max_bs;
200
201 /*
202 * now sort based on percentages, for ease of lookup
203 */
204 qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
205 return 0;
206}
207
208int str_split_parse(struct thread_data *td, char *str,
209 split_parse_fn *fn, void *eo, bool data)
210{
211 char *odir, *ddir;
212 int ret = 0;
213
214 odir = strchr(str, ',');
215 if (odir) {
216 ddir = strchr(odir + 1, ',');
217 if (ddir) {
218 ret = fn(&td->o, eo, DDIR_TRIM, ddir + 1, data);
219 if (!ret)
220 *ddir = '\0';
221 } else {
222 char *op;
223
224 op = strdup(odir + 1);
225 ret = fn(&td->o, eo, DDIR_TRIM, op, data);
226
227 free(op);
228 }
229 if (!ret)
230 ret = fn(&td->o, eo, DDIR_WRITE, odir + 1, data);
231 if (!ret) {
232 *odir = '\0';
233 ret = fn(&td->o, eo, DDIR_READ, str, data);
234 }
235 } else {
236 char *op;
237
238 op = strdup(str);
239 ret = fn(&td->o, eo, DDIR_WRITE, op, data);
240 free(op);
241
242 if (!ret) {
243 op = strdup(str);
244 ret = fn(&td->o, eo, DDIR_TRIM, op, data);
245 free(op);
246 }
247 if (!ret)
248 ret = fn(&td->o, eo, DDIR_READ, str, data);
249 }
250
251 return ret;
252}
253
254static int str_bssplit_cb(void *data, const char *input)
255{
256 struct thread_data *td = cb_data_to_td(data);
257 char *str, *p;
258 int ret = 0;
259
260 p = str = strdup(input);
261
262 strip_blank_front(&str);
263 strip_blank_end(str);
264
265 ret = str_split_parse(td, str, bssplit_ddir, NULL, false);
266
267 if (parse_dryrun()) {
268 int i;
269
270 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
271 free(td->o.bssplit[i]);
272 td->o.bssplit[i] = NULL;
273 td->o.bssplit_nr[i] = 0;
274 }
275 }
276
277 free(p);
278 return ret;
279}
280
281static int parse_cmdprio_bssplit_entry(struct thread_options *o,
282 struct split_prio *entry, char *str)
283{
284 int matches = 0;
285 char *bs_str = NULL;
286 long long bs_val;
287 unsigned int perc = 0, class, level;
288
289 /*
290 * valid entry formats:
291 * bs/ - %s/ - set perc to 0, prio to -1.
292 * bs/perc - %s/%u - set prio to -1.
293 * bs/perc/class/level - %s/%u/%u/%u
294 */
295 matches = sscanf(str, "%m[^/]/%u/%u/%u", &bs_str, &perc, &class, &level);
296 if (matches < 1) {
297 log_err("fio: invalid cmdprio_bssplit format\n");
298 return 1;
299 }
300
301 if (str_to_decimal(bs_str, &bs_val, 1, o, 0, 0)) {
302 log_err("fio: split conversion failed\n");
303 free(bs_str);
304 return 1;
305 }
306 free(bs_str);
307
308 entry->bs = bs_val;
309 entry->perc = min(perc, 100u);
310 entry->prio = -1;
311 switch (matches) {
312 case 1: /* bs/ case */
313 case 2: /* bs/perc case */
314 break;
315 case 4: /* bs/perc/class/level case */
316 class = min(class, (unsigned int) IOPRIO_MAX_PRIO_CLASS);
317 level = min(level, (unsigned int) IOPRIO_MAX_PRIO);
318 entry->prio = ioprio_value(class, level);
319 break;
320 default:
321 log_err("fio: invalid cmdprio_bssplit format\n");
322 return 1;
323 }
324
325 return 0;
326}
327
328/*
329 * Returns a negative integer if the first argument should be before the second
330 * argument in the sorted list. A positive integer if the first argument should
331 * be after the second argument in the sorted list. A zero if they are equal.
332 */
333static int fio_split_prio_cmp(const void *p1, const void *p2)
334{
335 const struct split_prio *tmp1 = p1;
336 const struct split_prio *tmp2 = p2;
337
338 if (tmp1->bs > tmp2->bs)
339 return 1;
340 if (tmp1->bs < tmp2->bs)
341 return -1;
342 return 0;
343}
344
345int split_parse_prio_ddir(struct thread_options *o, struct split_prio **entries,
346 int *nr_entries, char *str)
347{
348 struct split_prio *tmp_entries;
349 unsigned int nr_bssplits;
350 char *str_cpy, *p, *fname;
351
352 /* strsep modifies the string, dup it so that we can use strsep twice */
353 p = str_cpy = strdup(str);
354 if (!p)
355 return 1;
356
357 nr_bssplits = 0;
358 while ((fname = strsep(&str_cpy, ":")) != NULL) {
359 if (!strlen(fname))
360 break;
361 nr_bssplits++;
362 }
363 free(p);
364
365 if (nr_bssplits > BSSPLIT_MAX) {
366 log_err("fio: too many cmdprio_bssplit entries\n");
367 return 1;
368 }
369
370 tmp_entries = calloc(nr_bssplits, sizeof(*tmp_entries));
371 if (!tmp_entries)
372 return 1;
373
374 nr_bssplits = 0;
375 while ((fname = strsep(&str, ":")) != NULL) {
376 struct split_prio *entry;
377
378 if (!strlen(fname))
379 break;
380
381 entry = &tmp_entries[nr_bssplits];
382
383 if (parse_cmdprio_bssplit_entry(o, entry, fname)) {
384 log_err("fio: failed to parse cmdprio_bssplit entry\n");
385 free(tmp_entries);
386 return 1;
387 }
388
389 /* skip zero perc entries, they provide no useful information */
390 if (entry->perc)
391 nr_bssplits++;
392 }
393
394 qsort(tmp_entries, nr_bssplits, sizeof(*tmp_entries),
395 fio_split_prio_cmp);
396
397 *entries = tmp_entries;
398 *nr_entries = nr_bssplits;
399
400 return 0;
401}
402
403static int str2error(char *str)
404{
405 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
406 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
407 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
408 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
409 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
410 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
411 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
412 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
413 int i = 0, num = sizeof(err) / sizeof(char *);
414
415 while (i < num) {
416 if (!strcmp(err[i], str))
417 return i + 1;
418 i++;
419 }
420 return 0;
421}
422
423static int ignore_error_type(struct thread_data *td, enum error_type_bit etype,
424 char *str)
425{
426 unsigned int i;
427 int *error;
428 char *fname;
429
430 if (etype >= ERROR_TYPE_CNT) {
431 log_err("Illegal error type\n");
432 return 1;
433 }
434
435 td->o.ignore_error_nr[etype] = 4;
436 error = calloc(4, sizeof(int));
437
438 i = 0;
439 while ((fname = strsep(&str, ":")) != NULL) {
440
441 if (!strlen(fname))
442 break;
443
444 /*
445 * grow struct buffer, if needed
446 */
447 if (i == td->o.ignore_error_nr[etype]) {
448 td->o.ignore_error_nr[etype] <<= 1;
449 error = realloc(error, td->o.ignore_error_nr[etype]
450 * sizeof(int));
451 }
452 if (fname[0] == 'E') {
453 error[i] = str2error(fname);
454 } else {
455 error[i] = atoi(fname);
456 if (error[i] < 0)
457 error[i] = -error[i];
458 }
459 if (!error[i]) {
460 log_err("Unknown error %s, please use number value\n",
461 fname);
462 td->o.ignore_error_nr[etype] = 0;
463 free(error);
464 return 1;
465 }
466 i++;
467 }
468 if (i) {
469 td->o.continue_on_error |= 1 << etype;
470 td->o.ignore_error_nr[etype] = i;
471 td->o.ignore_error[etype] = error;
472 } else {
473 td->o.ignore_error_nr[etype] = 0;
474 free(error);
475 }
476
477 return 0;
478
479}
480
481static int str_replay_skip_cb(void *data, const char *input)
482{
483 struct thread_data *td = cb_data_to_td(data);
484 char *str, *p, *n;
485 int ret = 0;
486
487 if (parse_dryrun())
488 return 0;
489
490 p = str = strdup(input);
491
492 strip_blank_front(&str);
493 strip_blank_end(str);
494
495 while (p) {
496 n = strchr(p, ',');
497 if (n)
498 *n++ = '\0';
499 if (!strcmp(p, "read"))
500 td->o.replay_skip |= 1u << DDIR_READ;
501 else if (!strcmp(p, "write"))
502 td->o.replay_skip |= 1u << DDIR_WRITE;
503 else if (!strcmp(p, "trim"))
504 td->o.replay_skip |= 1u << DDIR_TRIM;
505 else if (!strcmp(p, "sync"))
506 td->o.replay_skip |= 1u << DDIR_SYNC;
507 else {
508 log_err("Unknown skip type: %s\n", p);
509 ret = 1;
510 break;
511 }
512 p = n;
513 }
514 free(str);
515 return ret;
516}
517
518static int str_ignore_error_cb(void *data, const char *input)
519{
520 struct thread_data *td = cb_data_to_td(data);
521 char *str, *p, *n;
522 int ret = 1;
523 enum error_type_bit type = 0;
524
525 if (parse_dryrun())
526 return 0;
527
528 p = str = strdup(input);
529
530 strip_blank_front(&str);
531 strip_blank_end(str);
532
533 while (p) {
534 n = strchr(p, ',');
535 if (n)
536 *n++ = '\0';
537 ret = ignore_error_type(td, type, p);
538 if (ret)
539 break;
540 p = n;
541 type++;
542 }
543 free(str);
544 return ret;
545}
546
547static int str_rw_cb(void *data, const char *str)
548{
549 struct thread_data *td = cb_data_to_td(data);
550 struct thread_options *o = &td->o;
551 char *nr;
552
553 if (parse_dryrun())
554 return 0;
555
556 o->ddir_seq_nr = 1;
557 o->ddir_seq_add = 0;
558
559 nr = get_opt_postfix(str);
560 if (!nr)
561 return 0;
562
563 if (td_random(td))
564 o->ddir_seq_nr = atoi(nr);
565 else {
566 long long val;
567
568 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
569 log_err("fio: rw postfix parsing failed\n");
570 free(nr);
571 return 1;
572 }
573
574 o->ddir_seq_add = val;
575 }
576
577 free(nr);
578 return 0;
579}
580
581static int str_mem_cb(void *data, const char *mem)
582{
583 struct thread_data *td = cb_data_to_td(data);
584
585 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
586 td->o.mem_type == MEM_MMAPSHARED)
587 td->o.mmapfile = get_opt_postfix(mem);
588
589 return 0;
590}
591
592static int fio_clock_source_cb(void *data, const char *str)
593{
594 struct thread_data *td = cb_data_to_td(data);
595
596 fio_clock_source = td->o.clocksource;
597 fio_clock_source_set = 1;
598 fio_clock_init();
599 return 0;
600}
601
602static int str_rwmix_read_cb(void *data, unsigned long long *val)
603{
604 struct thread_data *td = cb_data_to_td(data);
605
606 td->o.rwmix[DDIR_READ] = *val;
607 td->o.rwmix[DDIR_WRITE] = 100 - *val;
608 return 0;
609}
610
611static int str_rwmix_write_cb(void *data, unsigned long long *val)
612{
613 struct thread_data *td = cb_data_to_td(data);
614
615 td->o.rwmix[DDIR_WRITE] = *val;
616 td->o.rwmix[DDIR_READ] = 100 - *val;
617 return 0;
618}
619
620static int str_exitall_cb(void)
621{
622 exitall_on_terminate = true;
623 return 0;
624}
625
626#ifdef FIO_HAVE_CPU_AFFINITY
627int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
628{
629 unsigned int i, index, cpus_in_mask;
630 const long max_cpu = cpus_configured();
631
632 cpus_in_mask = fio_cpu_count(mask);
633 if (!cpus_in_mask)
634 return 0;
635
636 cpu_index = cpu_index % cpus_in_mask;
637
638 index = 0;
639 for (i = 0; i < max_cpu; i++) {
640 if (!fio_cpu_isset(mask, i))
641 continue;
642
643 if (cpu_index != index)
644 fio_cpu_clear(mask, i);
645
646 index++;
647 }
648
649 return fio_cpu_count(mask);
650}
651
652static int str_cpumask_cb(void *data, unsigned long long *val)
653{
654 struct thread_data *td = cb_data_to_td(data);
655 unsigned int i;
656 long max_cpu;
657 int ret;
658
659 if (parse_dryrun())
660 return 0;
661
662 ret = fio_cpuset_init(&td->o.cpumask);
663 if (ret < 0) {
664 log_err("fio: cpuset_init failed\n");
665 td_verror(td, ret, "fio_cpuset_init");
666 return 1;
667 }
668
669 max_cpu = cpus_configured();
670
671 for (i = 0; i < sizeof(int) * 8; i++) {
672 if ((1 << i) & *val) {
673 if (i >= max_cpu) {
674 log_err("fio: CPU %d too large (max=%ld)\n", i,
675 max_cpu - 1);
676 return 1;
677 }
678 dprint(FD_PARSE, "set cpu allowed %d\n", i);
679 fio_cpu_set(&td->o.cpumask, i);
680 }
681 }
682
683 return 0;
684}
685
686static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
687 const char *input)
688{
689 char *cpu, *str, *p;
690 long max_cpu;
691 int ret = 0;
692
693 ret = fio_cpuset_init(mask);
694 if (ret < 0) {
695 log_err("fio: cpuset_init failed\n");
696 td_verror(td, ret, "fio_cpuset_init");
697 return 1;
698 }
699
700 p = str = strdup(input);
701
702 strip_blank_front(&str);
703 strip_blank_end(str);
704
705 max_cpu = cpus_configured();
706
707 while ((cpu = strsep(&str, ",")) != NULL) {
708 char *str2, *cpu2;
709 int icpu, icpu2;
710
711 if (!strlen(cpu))
712 break;
713
714 str2 = cpu;
715 icpu2 = -1;
716 while ((cpu2 = strsep(&str2, "-")) != NULL) {
717 if (!strlen(cpu2))
718 break;
719
720 icpu2 = atoi(cpu2);
721 }
722
723 icpu = atoi(cpu);
724 if (icpu2 == -1)
725 icpu2 = icpu;
726 while (icpu <= icpu2) {
727 if (icpu >= FIO_MAX_CPUS) {
728 log_err("fio: your OS only supports up to"
729 " %d CPUs\n", (int) FIO_MAX_CPUS);
730 ret = 1;
731 break;
732 }
733 if (icpu >= max_cpu) {
734 log_err("fio: CPU %d too large (max=%ld)\n",
735 icpu, max_cpu - 1);
736 ret = 1;
737 break;
738 }
739
740 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
741 fio_cpu_set(mask, icpu);
742 icpu++;
743 }
744 if (ret)
745 break;
746 }
747
748 free(p);
749 return ret;
750}
751
752static int str_cpus_allowed_cb(void *data, const char *input)
753{
754 struct thread_data *td = cb_data_to_td(data);
755
756 if (parse_dryrun())
757 return 0;
758
759 return set_cpus_allowed(td, &td->o.cpumask, input);
760}
761
762static int str_verify_cpus_allowed_cb(void *data, const char *input)
763{
764 struct thread_data *td = cb_data_to_td(data);
765
766 if (parse_dryrun())
767 return 0;
768
769 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
770}
771
772#ifdef CONFIG_ZLIB
773static int str_log_cpus_allowed_cb(void *data, const char *input)
774{
775 struct thread_data *td = cb_data_to_td(data);
776
777 if (parse_dryrun())
778 return 0;
779
780 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
781}
782#endif /* CONFIG_ZLIB */
783
784#endif /* FIO_HAVE_CPU_AFFINITY */
785
786#ifdef CONFIG_LIBNUMA
787static int str_numa_cpunodes_cb(void *data, char *input)
788{
789 struct thread_data *td = cb_data_to_td(data);
790 struct bitmask *verify_bitmask;
791
792 if (parse_dryrun())
793 return 0;
794
795 /* numa_parse_nodestring() parses a character string list
796 * of nodes into a bit mask. The bit mask is allocated by
797 * numa_allocate_nodemask(), so it should be freed by
798 * numa_free_nodemask().
799 */
800 verify_bitmask = numa_parse_nodestring(input);
801 if (verify_bitmask == NULL) {
802 log_err("fio: numa_parse_nodestring failed\n");
803 td_verror(td, 1, "str_numa_cpunodes_cb");
804 return 1;
805 }
806 numa_free_nodemask(verify_bitmask);
807
808 td->o.numa_cpunodes = strdup(input);
809 return 0;
810}
811
812static int str_numa_mpol_cb(void *data, char *input)
813{
814 struct thread_data *td = cb_data_to_td(data);
815 const char * const policy_types[] =
816 { "default", "prefer", "bind", "interleave", "local", NULL };
817 int i;
818 char *nodelist;
819 struct bitmask *verify_bitmask;
820
821 if (parse_dryrun())
822 return 0;
823
824 nodelist = strchr(input, ':');
825 if (nodelist) {
826 /* NUL-terminate mode */
827 *nodelist++ = '\0';
828 }
829
830 for (i = 0; i <= MPOL_LOCAL; i++) {
831 if (!strcmp(input, policy_types[i])) {
832 td->o.numa_mem_mode = i;
833 break;
834 }
835 }
836 if (i > MPOL_LOCAL) {
837 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
838 goto out;
839 }
840
841 switch (td->o.numa_mem_mode) {
842 case MPOL_PREFERRED:
843 /*
844 * Insist on a nodelist of one node only
845 */
846 if (nodelist) {
847 char *rest = nodelist;
848 while (isdigit(*rest))
849 rest++;
850 if (*rest) {
851 log_err("fio: one node only for \'prefer\'\n");
852 goto out;
853 }
854 } else {
855 log_err("fio: one node is needed for \'prefer\'\n");
856 goto out;
857 }
858 break;
859 case MPOL_INTERLEAVE:
860 /*
861 * Default to online nodes with memory if no nodelist
862 */
863 if (!nodelist)
864 nodelist = strdup("all");
865 break;
866 case MPOL_LOCAL:
867 case MPOL_DEFAULT:
868 /*
869 * Don't allow a nodelist
870 */
871 if (nodelist) {
872 log_err("fio: NO nodelist for \'local\'\n");
873 goto out;
874 }
875 break;
876 case MPOL_BIND:
877 /*
878 * Insist on a nodelist
879 */
880 if (!nodelist) {
881 log_err("fio: a nodelist is needed for \'bind\'\n");
882 goto out;
883 }
884 break;
885 }
886
887
888 /* numa_parse_nodestring() parses a character string list
889 * of nodes into a bit mask. The bit mask is allocated by
890 * numa_allocate_nodemask(), so it should be freed by
891 * numa_free_nodemask().
892 */
893 switch (td->o.numa_mem_mode) {
894 case MPOL_PREFERRED:
895 td->o.numa_mem_prefer_node = atoi(nodelist);
896 break;
897 case MPOL_INTERLEAVE:
898 case MPOL_BIND:
899 verify_bitmask = numa_parse_nodestring(nodelist);
900 if (verify_bitmask == NULL) {
901 log_err("fio: numa_parse_nodestring failed\n");
902 td_verror(td, 1, "str_numa_memnodes_cb");
903 return 1;
904 }
905 td->o.numa_memnodes = strdup(nodelist);
906 numa_free_nodemask(verify_bitmask);
907
908 break;
909 case MPOL_LOCAL:
910 case MPOL_DEFAULT:
911 default:
912 break;
913 }
914
915 return 0;
916out:
917 return 1;
918}
919#endif
920
921static int str_fst_cb(void *data, const char *str)
922{
923 struct thread_data *td = cb_data_to_td(data);
924 double val;
925 double center = -1;
926 bool done = false;
927 char *nr;
928
929 td->file_service_nr = 1;
930
931 switch (td->o.file_service_type) {
932 case FIO_FSERVICE_RANDOM:
933 case FIO_FSERVICE_RR:
934 case FIO_FSERVICE_SEQ:
935 nr = get_opt_postfix(str);
936 if (nr) {
937 td->file_service_nr = atoi(nr);
938 free(nr);
939 }
940 done = true;
941 break;
942 case FIO_FSERVICE_ZIPF:
943 val = FIO_DEF_ZIPF;
944 break;
945 case FIO_FSERVICE_PARETO:
946 val = FIO_DEF_PARETO;
947 break;
948 case FIO_FSERVICE_GAUSS:
949 val = 0.0;
950 break;
951 default:
952 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
953 return 1;
954 }
955
956 if (done)
957 return 0;
958
959 nr = get_opt_postfix(str);
960 if (nr && !split_parse_distr(nr, &val, &center)) {
961 log_err("fio: file service type random postfix parsing failed\n");
962 free(nr);
963 return 1;
964 }
965
966 free(nr);
967
968 if (center != -1 && (center < 0.00 || center > 1.00)) {
969 log_err("fio: distribution center out of range (0 <= center <= 1.0)\n");
970 return 1;
971 }
972 td->random_center = center;
973
974 switch (td->o.file_service_type) {
975 case FIO_FSERVICE_ZIPF:
976 if (val == 1.00) {
977 log_err("fio: zipf theta must be different than 1.0\n");
978 return 1;
979 }
980 if (parse_dryrun())
981 return 0;
982 td->zipf_theta = val;
983 break;
984 case FIO_FSERVICE_PARETO:
985 if (val <= 0.00 || val >= 1.00) {
986 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
987 return 1;
988 }
989 if (parse_dryrun())
990 return 0;
991 td->pareto_h = val;
992 break;
993 case FIO_FSERVICE_GAUSS:
994 if (val < 0.00 || val >= 100.00) {
995 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
996 return 1;
997 }
998 if (parse_dryrun())
999 return 0;
1000 td->gauss_dev = val;
1001 break;
1002 }
1003
1004 return 0;
1005}
1006
1007#ifdef CONFIG_SYNC_FILE_RANGE
1008static int str_sfr_cb(void *data, const char *str)
1009{
1010 struct thread_data *td = cb_data_to_td(data);
1011 char *nr = get_opt_postfix(str);
1012
1013 td->sync_file_range_nr = 1;
1014 if (nr) {
1015 td->sync_file_range_nr = atoi(nr);
1016 free(nr);
1017 }
1018
1019 return 0;
1020}
1021#endif
1022
1023static int zone_split_ddir(struct thread_options *o, void *eo,
1024 enum fio_ddir ddir, char *str, bool absolute)
1025{
1026 unsigned int i, perc, perc_missing, sperc, sperc_missing;
1027 struct split split;
1028
1029 memset(&split, 0, sizeof(split));
1030
1031 if (split_parse_ddir(o, &split, str, absolute, ZONESPLIT_MAX))
1032 return 1;
1033 if (!split.nr)
1034 return 0;
1035
1036 o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
1037 o->zone_split_nr[ddir] = split.nr;
1038 for (i = 0; i < split.nr; i++) {
1039 o->zone_split[ddir][i].access_perc = split.val1[i];
1040 if (absolute)
1041 o->zone_split[ddir][i].size = split.val2[i];
1042 else
1043 o->zone_split[ddir][i].size_perc = split.val2[i];
1044 }
1045
1046 /*
1047 * Now check if the percentages add up, and how much is missing
1048 */
1049 perc = perc_missing = 0;
1050 sperc = sperc_missing = 0;
1051 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
1052 struct zone_split *zsp = &o->zone_split[ddir][i];
1053
1054 if (zsp->access_perc == (uint8_t) -1U)
1055 perc_missing++;
1056 else
1057 perc += zsp->access_perc;
1058
1059 if (!absolute) {
1060 if (zsp->size_perc == (uint8_t) -1U)
1061 sperc_missing++;
1062 else
1063 sperc += zsp->size_perc;
1064 }
1065 }
1066
1067 if (perc > 100 || sperc > 100) {
1068 log_err("fio: zone_split percentages add to more than 100%%\n");
1069 free(o->zone_split[ddir]);
1070 o->zone_split[ddir] = NULL;
1071 return 1;
1072 }
1073 if (perc < 100) {
1074 log_err("fio: access percentage don't add up to 100 for zoned "
1075 "random distribution (got=%u)\n", perc);
1076 free(o->zone_split[ddir]);
1077 o->zone_split[ddir] = NULL;
1078 return 1;
1079 }
1080
1081 /*
1082 * If values didn't have a percentage set, divide the remains between
1083 * them.
1084 */
1085 if (perc_missing) {
1086 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
1087 perc = 100;
1088 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
1089 struct zone_split *zsp = &o->zone_split[ddir][i];
1090
1091 if (zsp->access_perc == (uint8_t) -1U)
1092 zsp->access_perc = (100 - perc) / perc_missing;
1093 }
1094 }
1095 if (sperc_missing) {
1096 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
1097 sperc = 100;
1098 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
1099 struct zone_split *zsp = &o->zone_split[ddir][i];
1100
1101 if (zsp->size_perc == (uint8_t) -1U)
1102 zsp->size_perc = (100 - sperc) / sperc_missing;
1103 }
1104 }
1105
1106 return 0;
1107}
1108
1109static int parse_zoned_distribution(struct thread_data *td, const char *input,
1110 bool absolute)
1111{
1112 const char *pre = absolute ? "zoned_abs:" : "zoned:";
1113 char *str, *p;
1114 int i, ret = 0;
1115
1116 p = str = strdup(input);
1117
1118 strip_blank_front(&str);
1119 strip_blank_end(str);
1120
1121 /* We expect it to start like that, bail if not */
1122 if (strncmp(str, pre, strlen(pre))) {
1123 log_err("fio: mismatch in zoned input <%s>\n", str);
1124 free(p);
1125 return 1;
1126 }
1127 str += strlen(pre);
1128
1129 ret = str_split_parse(td, str, zone_split_ddir, NULL, absolute);
1130
1131 free(p);
1132
1133 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1134 int j;
1135
1136 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
1137
1138 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
1139 struct zone_split *zsp = &td->o.zone_split[i][j];
1140
1141 if (absolute) {
1142 dprint(FD_PARSE, "\t%d: %u/%llu\n", j,
1143 zsp->access_perc,
1144 (unsigned long long) zsp->size);
1145 } else {
1146 dprint(FD_PARSE, "\t%d: %u/%u\n", j,
1147 zsp->access_perc,
1148 zsp->size_perc);
1149 }
1150 }
1151 }
1152
1153 if (parse_dryrun()) {
1154 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1155 free(td->o.zone_split[i]);
1156 td->o.zone_split[i] = NULL;
1157 td->o.zone_split_nr[i] = 0;
1158 }
1159
1160 return ret;
1161 }
1162
1163 if (ret) {
1164 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1165 td->o.zone_split_nr[i] = 0;
1166 }
1167
1168 return ret;
1169}
1170
1171static int str_random_distribution_cb(void *data, const char *str)
1172{
1173 struct thread_data *td = cb_data_to_td(data);
1174 double val;
1175 double center = -1;
1176 char *nr;
1177
1178 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1179 val = FIO_DEF_ZIPF;
1180 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1181 val = FIO_DEF_PARETO;
1182 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1183 val = 0.0;
1184 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1185 return parse_zoned_distribution(td, str, false);
1186 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED_ABS)
1187 return parse_zoned_distribution(td, str, true);
1188 else
1189 return 0;
1190
1191 nr = get_opt_postfix(str);
1192 if (nr && !split_parse_distr(nr, &val, &center)) {
1193 log_err("fio: random postfix parsing failed\n");
1194 free(nr);
1195 return 1;
1196 }
1197
1198 free(nr);
1199
1200 if (center != -1 && (center < 0.00 || center > 1.00)) {
1201 log_err("fio: distribution center out of range (0 <= center <= 1.0)\n");
1202 return 1;
1203 }
1204 td->o.random_center.u.f = center;
1205
1206 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1207 if (val == 1.00) {
1208 log_err("fio: zipf theta must different than 1.0\n");
1209 return 1;
1210 }
1211 if (parse_dryrun())
1212 return 0;
1213 td->o.zipf_theta.u.f = val;
1214 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1215 if (val <= 0.00 || val >= 1.00) {
1216 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1217 return 1;
1218 }
1219 if (parse_dryrun())
1220 return 0;
1221 td->o.pareto_h.u.f = val;
1222 } else {
1223 if (val < 0.00 || val >= 100.0) {
1224 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1225 return 1;
1226 }
1227 if (parse_dryrun())
1228 return 0;
1229 td->o.gauss_dev.u.f = val;
1230 }
1231
1232 return 0;
1233}
1234
1235static int str_steadystate_cb(void *data, const char *str)
1236{
1237 struct thread_data *td = cb_data_to_td(data);
1238 double val;
1239 char *nr;
1240 char *pct;
1241 long long ll;
1242
1243 if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1244 td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1245 /* should be impossible to get here */
1246 log_err("fio: unknown steady state criterion\n");
1247 return 1;
1248 }
1249
1250 nr = get_opt_postfix(str);
1251 if (!nr) {
1252 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1253 free(nr);
1254 return 1;
1255 }
1256
1257 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1258 pct = strstr(nr, "%");
1259 if (pct) {
1260 *pct = '\0';
1261 strip_blank_end(nr);
1262 if (!str_to_float(nr, &val, 0)) {
1263 log_err("fio: could not parse steadystate threshold percentage\n");
1264 free(nr);
1265 return 1;
1266 }
1267
1268 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1269 free(nr);
1270 if (parse_dryrun())
1271 return 0;
1272
1273 td->o.ss_state |= FIO_SS_PCT;
1274 td->o.ss_limit.u.f = val;
1275 } else if (td->o.ss_state & FIO_SS_IOPS) {
1276 if (!str_to_float(nr, &val, 0)) {
1277 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1278 free(nr);
1279 return 1;
1280 }
1281
1282 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1283 free(nr);
1284 if (parse_dryrun())
1285 return 0;
1286
1287 td->o.ss_limit.u.f = val;
1288 } else { /* bandwidth criterion */
1289 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1290 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1291 free(nr);
1292 return 1;
1293 }
1294
1295 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1296 free(nr);
1297 if (parse_dryrun())
1298 return 0;
1299
1300 td->o.ss_limit.u.f = (double) ll;
1301 }
1302
1303 td->ss.state = td->o.ss_state;
1304 return 0;
1305}
1306
1307/*
1308 * Return next name in the string. Files are separated with ':'. If the ':'
1309 * is escaped with a '\', then that ':' is part of the filename and does not
1310 * indicate a new file.
1311 */
1312char *get_next_str(char **ptr)
1313{
1314 char *str = *ptr;
1315 char *p, *start;
1316
1317 if (!str || !strlen(str))
1318 return NULL;
1319
1320 start = str;
1321 do {
1322 /*
1323 * No colon, we are done
1324 */
1325 p = strchr(str, ':');
1326 if (!p) {
1327 *ptr = NULL;
1328 break;
1329 }
1330
1331 /*
1332 * We got a colon, but it's the first character. Skip and
1333 * continue
1334 */
1335 if (p == start) {
1336 str = ++start;
1337 continue;
1338 }
1339
1340 if (*(p - 1) != '\\') {
1341 *p = '\0';
1342 *ptr = p + 1;
1343 break;
1344 }
1345
1346 memmove(p - 1, p, strlen(p) + 1);
1347 str = p;
1348 } while (1);
1349
1350 return start;
1351}
1352
1353
1354int get_max_str_idx(char *input)
1355{
1356 unsigned int cur_idx;
1357 char *str, *p;
1358
1359 p = str = strdup(input);
1360 for (cur_idx = 0; ; cur_idx++)
1361 if (get_next_str(&str) == NULL)
1362 break;
1363
1364 free(p);
1365 return cur_idx;
1366}
1367
1368/*
1369 * Returns the directory at the index, indexes > entries will be
1370 * assigned via modulo division of the index
1371 */
1372int set_name_idx(char *target, size_t tlen, char *input, int index,
1373 bool unique_filename)
1374{
1375 unsigned int cur_idx;
1376 int len;
1377 char *fname, *str, *p;
1378
1379 p = str = strdup(input);
1380
1381 index %= get_max_str_idx(input);
1382 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1383 fname = get_next_str(&str);
1384
1385 if (client_sockaddr_str[0] && unique_filename) {
1386 len = snprintf(target, tlen, "%s/%s.", fname,
1387 client_sockaddr_str);
1388 } else
1389 len = snprintf(target, tlen, "%s%c", fname,
1390 FIO_OS_PATH_SEPARATOR);
1391
1392 target[tlen - 1] = '\0';
1393 free(p);
1394
1395 return len;
1396}
1397
1398char* get_name_by_idx(char *input, int index)
1399{
1400 unsigned int cur_idx;
1401 char *fname, *str, *p;
1402
1403 p = str = strdup(input);
1404
1405 index %= get_max_str_idx(input);
1406 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1407 fname = get_next_str(&str);
1408
1409 fname = strdup(fname);
1410 free(p);
1411
1412 return fname;
1413}
1414
1415static int str_filename_cb(void *data, const char *input)
1416{
1417 struct thread_data *td = cb_data_to_td(data);
1418 char *fname, *str, *p;
1419
1420 p = str = strdup(input);
1421
1422 strip_blank_front(&str);
1423 strip_blank_end(str);
1424
1425 /*
1426 * Ignore what we may already have from nrfiles option.
1427 */
1428 if (!td->files_index)
1429 td->o.nr_files = 0;
1430
1431 while ((fname = get_next_str(&str)) != NULL) {
1432 if (!strlen(fname))
1433 break;
1434 add_file(td, fname, 0, 1);
1435 }
1436
1437 free(p);
1438 return 0;
1439}
1440
1441static int str_directory_cb(void *data, const char fio_unused *unused)
1442{
1443 struct thread_data *td = cb_data_to_td(data);
1444 struct stat sb;
1445 char *dirname, *str, *p;
1446 int ret = 0;
1447
1448 if (parse_dryrun())
1449 return 0;
1450
1451 p = str = strdup(td->o.directory);
1452 while ((dirname = get_next_str(&str)) != NULL) {
1453 if (lstat(dirname, &sb) < 0) {
1454 ret = errno;
1455
1456 log_err("fio: %s is not a directory\n", dirname);
1457 td_verror(td, ret, "lstat");
1458 goto out;
1459 }
1460 if (!S_ISDIR(sb.st_mode)) {
1461 log_err("fio: %s is not a directory\n", dirname);
1462 ret = 1;
1463 goto out;
1464 }
1465 }
1466
1467out:
1468 free(p);
1469 return ret;
1470}
1471
1472static int str_opendir_cb(void *data, const char fio_unused *str)
1473{
1474 struct thread_data *td = cb_data_to_td(data);
1475
1476 if (parse_dryrun())
1477 return 0;
1478
1479 if (!td->files_index)
1480 td->o.nr_files = 0;
1481
1482 return add_dir_files(td, td->o.opendir);
1483}
1484
1485static int str_buffer_pattern_cb(void *data, const char *input)
1486{
1487 struct thread_data *td = cb_data_to_td(data);
1488 int ret;
1489
1490 /* FIXME: for now buffer pattern does not support formats */
1491 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1492 MAX_PATTERN_SIZE, NULL, NULL, NULL);
1493 if (ret < 0)
1494 return 1;
1495
1496 assert(ret != 0);
1497 td->o.buffer_pattern_bytes = ret;
1498
1499 /*
1500 * If this job is doing any reading or has compression set,
1501 * ensure that we refill buffers for writes or we could be
1502 * invalidating the pattern through reads.
1503 */
1504 if (!td->o.compress_percentage && !td_read(td))
1505 td->o.refill_buffers = 0;
1506 else
1507 td->o.refill_buffers = 1;
1508
1509 td->o.scramble_buffers = 0;
1510 td->o.zero_buffers = 0;
1511
1512 return 0;
1513}
1514
1515static int str_buffer_compress_cb(void *data, unsigned long long *il)
1516{
1517 struct thread_data *td = cb_data_to_td(data);
1518
1519 td->flags |= TD_F_COMPRESS;
1520 td->o.compress_percentage = *il;
1521 return 0;
1522}
1523
1524static int str_dedupe_cb(void *data, unsigned long long *il)
1525{
1526 struct thread_data *td = cb_data_to_td(data);
1527
1528 td->flags |= TD_F_COMPRESS;
1529 td->o.dedupe_percentage = *il;
1530 td->o.refill_buffers = 1;
1531 return 0;
1532}
1533
1534static int str_verify_pattern_cb(void *data, const char *input)
1535{
1536 struct thread_data *td = cb_data_to_td(data);
1537 int ret;
1538
1539 td->o.verify_fmt_sz = FIO_ARRAY_SIZE(td->o.verify_fmt);
1540 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1541 MAX_PATTERN_SIZE, fmt_desc,
1542 td->o.verify_fmt, &td->o.verify_fmt_sz);
1543 if (ret < 0)
1544 return 1;
1545
1546 assert(ret != 0);
1547 td->o.verify_pattern_bytes = ret;
1548 /*
1549 * VERIFY_* could already be set
1550 */
1551 if (!fio_option_is_set(&td->o, verify))
1552 td->o.verify = VERIFY_PATTERN;
1553
1554 return 0;
1555}
1556
1557static int str_gtod_reduce_cb(void *data, int *il)
1558{
1559 struct thread_data *td = cb_data_to_td(data);
1560 int val = *il;
1561
1562 /*
1563 * Only modify options if gtod_reduce==1
1564 * Otherwise leave settings alone.
1565 */
1566 if (val) {
1567 td->o.disable_lat = 1;
1568 td->o.disable_clat = 1;
1569 td->o.disable_slat = 1;
1570 td->o.disable_bw = 1;
1571 td->o.clat_percentiles = 0;
1572 td->o.lat_percentiles = 0;
1573 td->o.slat_percentiles = 0;
1574 td->ts_cache_mask = 63;
1575 }
1576
1577 return 0;
1578}
1579
1580static int str_offset_cb(void *data, unsigned long long *__val)
1581{
1582 struct thread_data *td = cb_data_to_td(data);
1583 unsigned long long v = *__val;
1584
1585 if (parse_is_percent(v)) {
1586 td->o.start_offset = 0;
1587 td->o.start_offset_percent = -1ULL - v;
1588 td->o.start_offset_nz = 0;
1589 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1590 td->o.start_offset_percent);
1591 } else if (parse_is_zone(v)) {
1592 td->o.start_offset = 0;
1593 td->o.start_offset_percent = 0;
1594 td->o.start_offset_nz = v - ZONE_BASE_VAL;
1595 } else
1596 td->o.start_offset = v;
1597
1598 return 0;
1599}
1600
1601static int str_offset_increment_cb(void *data, unsigned long long *__val)
1602{
1603 struct thread_data *td = cb_data_to_td(data);
1604 unsigned long long v = *__val;
1605
1606 if (parse_is_percent(v)) {
1607 td->o.offset_increment = 0;
1608 td->o.offset_increment_percent = -1ULL - v;
1609 td->o.offset_increment_nz = 0;
1610 dprint(FD_PARSE, "SET offset_increment_percent %d\n",
1611 td->o.offset_increment_percent);
1612 } else if (parse_is_zone(v)) {
1613 td->o.offset_increment = 0;
1614 td->o.offset_increment_percent = 0;
1615 td->o.offset_increment_nz = v - ZONE_BASE_VAL;
1616 } else
1617 td->o.offset_increment = v;
1618
1619 return 0;
1620}
1621
1622static int str_size_cb(void *data, unsigned long long *__val)
1623{
1624 struct thread_data *td = cb_data_to_td(data);
1625 unsigned long long v = *__val;
1626
1627 if (parse_is_percent(v)) {
1628 td->o.size = 0;
1629 td->o.size_percent = -1ULL - v;
1630 dprint(FD_PARSE, "SET size_percent %d\n",
1631 td->o.size_percent);
1632 } else if (parse_is_zone(v)) {
1633 td->o.size = 0;
1634 td->o.size_percent = 0;
1635 td->o.size_nz = v - ZONE_BASE_VAL;
1636 } else
1637 td->o.size = v;
1638
1639 return 0;
1640}
1641
1642static int str_io_size_cb(void *data, unsigned long long *__val)
1643{
1644 struct thread_data *td = cb_data_to_td(data);
1645 unsigned long long v = *__val;
1646
1647 if (parse_is_percent_uncapped(v)) {
1648 td->o.io_size = 0;
1649 td->o.io_size_percent = -1ULL - v;
1650 if (td->o.io_size_percent > 100) {
1651 log_err("fio: io_size values greater than 100%% aren't supported\n");
1652 return 1;
1653 }
1654 dprint(FD_PARSE, "SET io_size_percent %d\n",
1655 td->o.io_size_percent);
1656 } else if (parse_is_zone(v)) {
1657 td->o.io_size = 0;
1658 td->o.io_size_percent = 0;
1659 td->o.io_size_nz = v - ZONE_BASE_VAL;
1660 } else
1661 td->o.io_size = v;
1662
1663 return 0;
1664}
1665
1666static int str_zoneskip_cb(void *data, unsigned long long *__val)
1667{
1668 struct thread_data *td = cb_data_to_td(data);
1669 unsigned long long v = *__val;
1670
1671 if (parse_is_zone(v)) {
1672 td->o.zone_skip = 0;
1673 td->o.zone_skip_nz = v - ZONE_BASE_VAL;
1674 } else
1675 td->o.zone_skip = v;
1676
1677 return 0;
1678}
1679
1680static int str_write_bw_log_cb(void *data, const char *str)
1681{
1682 struct thread_data *td = cb_data_to_td(data);
1683
1684 if (str)
1685 td->o.bw_log_file = strdup(str);
1686
1687 td->o.write_bw_log = 1;
1688 return 0;
1689}
1690
1691static int str_write_lat_log_cb(void *data, const char *str)
1692{
1693 struct thread_data *td = cb_data_to_td(data);
1694
1695 if (str)
1696 td->o.lat_log_file = strdup(str);
1697
1698 td->o.write_lat_log = 1;
1699 return 0;
1700}
1701
1702static int str_write_iops_log_cb(void *data, const char *str)
1703{
1704 struct thread_data *td = cb_data_to_td(data);
1705
1706 if (str)
1707 td->o.iops_log_file = strdup(str);
1708
1709 td->o.write_iops_log = 1;
1710 return 0;
1711}
1712
1713static int str_write_hist_log_cb(void *data, const char *str)
1714{
1715 struct thread_data *td = cb_data_to_td(data);
1716
1717 if (str)
1718 td->o.hist_log_file = strdup(str);
1719
1720 td->o.write_hist_log = 1;
1721 return 0;
1722}
1723
1724/*
1725 * str is supposed to be a substring of the strdup'd original string,
1726 * and is valid only if it's a regular file path.
1727 * This function keeps the pointer to the path as needed later.
1728 *
1729 * "external:/path/to/so\0" <- original pointer updated with strdup'd
1730 * "external\0" <- above pointer after parsed, i.e. ->ioengine
1731 * "/path/to/so\0" <- str argument, i.e. ->ioengine_so_path
1732 */
1733static int str_ioengine_external_cb(void *data, const char *str)
1734{
1735 struct thread_data *td = cb_data_to_td(data);
1736 struct stat sb;
1737 char *p;
1738
1739 if (!str) {
1740 log_err("fio: null external ioengine path\n");
1741 return 1;
1742 }
1743
1744 p = (char *)str; /* str is mutable */
1745 strip_blank_front(&p);
1746 strip_blank_end(p);
1747
1748 if (stat(p, &sb) || !S_ISREG(sb.st_mode)) {
1749 log_err("fio: invalid external ioengine path \"%s\"\n", p);
1750 return 1;
1751 }
1752
1753 td->o.ioengine_so_path = p;
1754 return 0;
1755}
1756
1757static int rw_verify(const struct fio_option *o, void *data)
1758{
1759 struct thread_data *td = cb_data_to_td(data);
1760
1761 if (read_only && (td_write(td) || td_trim(td))) {
1762 log_err("fio: job <%s> has write or trim bit set, but"
1763 " fio is in read-only mode\n", td->o.name);
1764 return 1;
1765 }
1766
1767 return 0;
1768}
1769
1770static int gtod_cpu_verify(const struct fio_option *o, void *data)
1771{
1772#ifndef FIO_HAVE_CPU_AFFINITY
1773 struct thread_data *td = cb_data_to_td(data);
1774
1775 if (td->o.gtod_cpu) {
1776 log_err("fio: platform must support CPU affinity for"
1777 "gettimeofday() offloading\n");
1778 return 1;
1779 }
1780#endif
1781
1782 return 0;
1783}
1784
1785/*
1786 * Map of job/command line options
1787 */
1788struct fio_option fio_options[FIO_MAX_OPTS] = {
1789 {
1790 .name = "description",
1791 .lname = "Description of job",
1792 .type = FIO_OPT_STR_STORE,
1793 .off1 = offsetof(struct thread_options, description),
1794 .help = "Text job description",
1795 .category = FIO_OPT_C_GENERAL,
1796 .group = FIO_OPT_G_DESC,
1797 },
1798 {
1799 .name = "name",
1800 .lname = "Job name",
1801 .type = FIO_OPT_STR_STORE,
1802 .off1 = offsetof(struct thread_options, name),
1803 .help = "Name of this job",
1804 .category = FIO_OPT_C_GENERAL,
1805 .group = FIO_OPT_G_DESC,
1806 },
1807 {
1808 .name = "wait_for",
1809 .lname = "Waitee name",
1810 .type = FIO_OPT_STR_STORE,
1811 .off1 = offsetof(struct thread_options, wait_for),
1812 .help = "Name of the job this one wants to wait for before starting",
1813 .category = FIO_OPT_C_GENERAL,
1814 .group = FIO_OPT_G_DESC,
1815 },
1816 {
1817 .name = "filename",
1818 .lname = "Filename(s)",
1819 .type = FIO_OPT_STR_STORE,
1820 .off1 = offsetof(struct thread_options, filename),
1821 .maxlen = PATH_MAX,
1822 .cb = str_filename_cb,
1823 .prio = -1, /* must come after "directory" */
1824 .help = "File(s) to use for the workload",
1825 .category = FIO_OPT_C_FILE,
1826 .group = FIO_OPT_G_FILENAME,
1827 },
1828 {
1829 .name = "directory",
1830 .lname = "Directory",
1831 .type = FIO_OPT_STR_STORE,
1832 .off1 = offsetof(struct thread_options, directory),
1833 .cb = str_directory_cb,
1834 .help = "Directory to store files in",
1835 .category = FIO_OPT_C_FILE,
1836 .group = FIO_OPT_G_FILENAME,
1837 },
1838 {
1839 .name = "filename_format",
1840 .lname = "Filename Format",
1841 .type = FIO_OPT_STR_STORE,
1842 .off1 = offsetof(struct thread_options, filename_format),
1843 .prio = -1, /* must come after "directory" */
1844 .help = "Override default $jobname.$jobnum.$filenum naming",
1845 .def = "$jobname.$jobnum.$filenum",
1846 .category = FIO_OPT_C_FILE,
1847 .group = FIO_OPT_G_FILENAME,
1848 },
1849 {
1850 .name = "unique_filename",
1851 .lname = "Unique Filename",
1852 .type = FIO_OPT_BOOL,
1853 .off1 = offsetof(struct thread_options, unique_filename),
1854 .help = "For network clients, prefix file with source IP",
1855 .def = "1",
1856 .category = FIO_OPT_C_FILE,
1857 .group = FIO_OPT_G_FILENAME,
1858 },
1859 {
1860 .name = "lockfile",
1861 .lname = "Lockfile",
1862 .type = FIO_OPT_STR,
1863 .off1 = offsetof(struct thread_options, file_lock_mode),
1864 .help = "Lock file when doing IO to it",
1865 .prio = 1,
1866 .parent = "filename",
1867 .hide = 0,
1868 .def = "none",
1869 .category = FIO_OPT_C_FILE,
1870 .group = FIO_OPT_G_FILENAME,
1871 .posval = {
1872 { .ival = "none",
1873 .oval = FILE_LOCK_NONE,
1874 .help = "No file locking",
1875 },
1876 { .ival = "exclusive",
1877 .oval = FILE_LOCK_EXCLUSIVE,
1878 .help = "Exclusive file lock",
1879 },
1880 {
1881 .ival = "readwrite",
1882 .oval = FILE_LOCK_READWRITE,
1883 .help = "Read vs write lock",
1884 },
1885 },
1886 },
1887 {
1888 .name = "opendir",
1889 .lname = "Open directory",
1890 .type = FIO_OPT_STR_STORE,
1891 .off1 = offsetof(struct thread_options, opendir),
1892 .cb = str_opendir_cb,
1893 .help = "Recursively add files from this directory and down",
1894 .category = FIO_OPT_C_FILE,
1895 .group = FIO_OPT_G_FILENAME,
1896 },
1897 {
1898 .name = "rw",
1899 .lname = "Read/write",
1900 .alias = "readwrite",
1901 .type = FIO_OPT_STR,
1902 .cb = str_rw_cb,
1903 .off1 = offsetof(struct thread_options, td_ddir),
1904 .help = "IO direction",
1905 .def = "read",
1906 .verify = rw_verify,
1907 .category = FIO_OPT_C_IO,
1908 .group = FIO_OPT_G_IO_BASIC,
1909 .posval = {
1910 { .ival = "read",
1911 .oval = TD_DDIR_READ,
1912 .help = "Sequential read",
1913 },
1914 { .ival = "write",
1915 .oval = TD_DDIR_WRITE,
1916 .help = "Sequential write",
1917 },
1918 { .ival = "trim",
1919 .oval = TD_DDIR_TRIM,
1920 .help = "Sequential trim",
1921 },
1922 { .ival = "randread",
1923 .oval = TD_DDIR_RANDREAD,
1924 .help = "Random read",
1925 },
1926 { .ival = "randwrite",
1927 .oval = TD_DDIR_RANDWRITE,
1928 .help = "Random write",
1929 },
1930 { .ival = "randtrim",
1931 .oval = TD_DDIR_RANDTRIM,
1932 .help = "Random trim",
1933 },
1934 { .ival = "rw",
1935 .oval = TD_DDIR_RW,
1936 .help = "Sequential read and write mix",
1937 },
1938 { .ival = "readwrite",
1939 .oval = TD_DDIR_RW,
1940 .help = "Sequential read and write mix",
1941 },
1942 { .ival = "randrw",
1943 .oval = TD_DDIR_RANDRW,
1944 .help = "Random read and write mix"
1945 },
1946 { .ival = "trimwrite",
1947 .oval = TD_DDIR_TRIMWRITE,
1948 .help = "Trim and write mix, trims preceding writes"
1949 },
1950 { .ival = "randtrimwrite",
1951 .oval = TD_DDIR_RANDTRIMWRITE,
1952 .help = "Randomly trim and write mix, trims preceding writes"
1953 },
1954 },
1955 },
1956 {
1957 .name = "rw_sequencer",
1958 .lname = "RW Sequencer",
1959 .type = FIO_OPT_STR,
1960 .off1 = offsetof(struct thread_options, rw_seq),
1961 .help = "IO offset generator modifier",
1962 .def = "sequential",
1963 .category = FIO_OPT_C_IO,
1964 .group = FIO_OPT_G_IO_BASIC,
1965 .posval = {
1966 { .ival = "sequential",
1967 .oval = RW_SEQ_SEQ,
1968 .help = "Generate sequential offsets",
1969 },
1970 { .ival = "identical",
1971 .oval = RW_SEQ_IDENT,
1972 .help = "Generate identical offsets",
1973 },
1974 },
1975 },
1976
1977 {
1978 .name = "ioengine",
1979 .lname = "IO Engine",
1980 .type = FIO_OPT_STR_STORE,
1981 .off1 = offsetof(struct thread_options, ioengine),
1982 .help = "IO engine to use",
1983 .def = FIO_PREFERRED_ENGINE,
1984 .category = FIO_OPT_C_IO,
1985 .group = FIO_OPT_G_IO_BASIC,
1986 .posval = {
1987 { .ival = "sync",
1988 .help = "Use read/write",
1989 },
1990 { .ival = "psync",
1991 .help = "Use pread/pwrite",
1992 },
1993 { .ival = "vsync",
1994 .help = "Use readv/writev",
1995 },
1996#ifdef CONFIG_PWRITEV
1997 { .ival = "pvsync",
1998 .help = "Use preadv/pwritev",
1999 },
2000#endif
2001#ifdef FIO_HAVE_PWRITEV2
2002 { .ival = "pvsync2",
2003 .help = "Use preadv2/pwritev2",
2004 },
2005#endif
2006#ifdef CONFIG_LIBAIO
2007 { .ival = "libaio",
2008 .help = "Linux native asynchronous IO",
2009 },
2010#endif
2011#ifdef ARCH_HAVE_IOURING
2012 { .ival = "io_uring",
2013 .help = "Fast Linux native aio",
2014 },
2015#endif
2016#ifdef CONFIG_POSIXAIO
2017 { .ival = "posixaio",
2018 .help = "POSIX asynchronous IO",
2019 },
2020#endif
2021#ifdef CONFIG_SOLARISAIO
2022 { .ival = "solarisaio",
2023 .help = "Solaris native asynchronous IO",
2024 },
2025#endif
2026#ifdef CONFIG_WINDOWSAIO
2027 { .ival = "windowsaio",
2028 .help = "Windows native asynchronous IO"
2029 },
2030#endif
2031#ifdef CONFIG_RBD
2032 { .ival = "rbd",
2033 .help = "Rados Block Device asynchronous IO"
2034 },
2035#endif
2036 { .ival = "mmap",
2037 .help = "Memory mapped IO"
2038 },
2039#ifdef CONFIG_LINUX_SPLICE
2040 { .ival = "splice",
2041 .help = "splice/vmsplice based IO",
2042 },
2043 { .ival = "netsplice",
2044 .help = "splice/vmsplice to/from the network",
2045 },
2046#endif
2047#ifdef FIO_HAVE_SGIO
2048 { .ival = "sg",
2049 .help = "SCSI generic v3 IO",
2050 },
2051#endif
2052 { .ival = "null",
2053 .help = "Testing engine (no data transfer)",
2054 },
2055 { .ival = "net",
2056 .help = "Network IO",
2057 },
2058 { .ival = "cpuio",
2059 .help = "CPU cycle burner engine",
2060 },
2061#ifdef CONFIG_RDMA
2062 { .ival = "rdma",
2063 .help = "RDMA IO engine",
2064 },
2065#endif
2066#ifdef CONFIG_LIBRPMA_APM
2067 { .ival = "librpma_apm",
2068 .help = "librpma IO engine in APM mode",
2069 },
2070#endif
2071#ifdef CONFIG_LIBRPMA_GPSPM
2072 { .ival = "librpma_gpspm",
2073 .help = "librpma IO engine in GPSPM mode",
2074 },
2075#endif
2076#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
2077 { .ival = "e4defrag",
2078 .help = "ext4 defrag engine",
2079 },
2080#endif
2081#ifdef CONFIG_LINUX_FALLOCATE
2082 { .ival = "falloc",
2083 .help = "fallocate() file based engine",
2084 },
2085#endif
2086#ifdef CONFIG_GFAPI
2087 { .ival = "gfapi",
2088 .help = "Glusterfs libgfapi(sync) based engine"
2089 },
2090 { .ival = "gfapi_async",
2091 .help = "Glusterfs libgfapi(async) based engine"
2092 },
2093#endif
2094#ifdef CONFIG_LIBHDFS
2095 { .ival = "libhdfs",
2096 .help = "Hadoop Distributed Filesystem (HDFS) engine"
2097 },
2098#endif
2099#ifdef CONFIG_PMEMBLK
2100 { .ival = "pmemblk",
2101 .help = "PMDK libpmemblk based IO engine",
2102 },
2103
2104#endif
2105#ifdef CONFIG_IME
2106 { .ival = "ime_psync",
2107 .help = "DDN's IME synchronous IO engine",
2108 },
2109 { .ival = "ime_psyncv",
2110 .help = "DDN's IME synchronous IO engine using iovecs",
2111 },
2112 { .ival = "ime_aio",
2113 .help = "DDN's IME asynchronous IO engine",
2114 },
2115#endif
2116#ifdef CONFIG_LINUX_DEVDAX
2117 { .ival = "dev-dax",
2118 .help = "DAX Device based IO engine",
2119 },
2120#endif
2121 {
2122 .ival = "filecreate",
2123 .help = "File creation engine",
2124 },
2125 { .ival = "external",
2126 .help = "Load external engine (append name)",
2127 .cb = str_ioengine_external_cb,
2128 },
2129#ifdef CONFIG_LIBPMEM
2130 { .ival = "libpmem",
2131 .help = "PMDK libpmem based IO engine",
2132 },
2133#endif
2134#ifdef CONFIG_HTTP
2135 { .ival = "http",
2136 .help = "HTTP (WebDAV/S3) IO engine",
2137 },
2138#endif
2139 { .ival = "nbd",
2140 .help = "Network Block Device (NBD) IO engine"
2141 },
2142#ifdef CONFIG_DFS
2143 { .ival = "dfs",
2144 .help = "DAOS File System (dfs) IO engine",
2145 },
2146#endif
2147#ifdef CONFIG_LIBNFS
2148 { .ival = "nfs",
2149 .help = "NFS IO engine",
2150 },
2151#endif
2152#ifdef CONFIG_LIBXNVME
2153 { .ival = "xnvme",
2154 .help = "XNVME IO engine",
2155 },
2156#endif
2157 },
2158 },
2159 {
2160 .name = "iodepth",
2161 .lname = "IO Depth",
2162 .type = FIO_OPT_INT,
2163 .off1 = offsetof(struct thread_options, iodepth),
2164 .help = "Number of IO buffers to keep in flight",
2165 .minval = 1,
2166 .interval = 1,
2167 .def = "1",
2168 .category = FIO_OPT_C_IO,
2169 .group = FIO_OPT_G_IO_BASIC,
2170 },
2171 {
2172 .name = "iodepth_batch",
2173 .lname = "IO Depth batch",
2174 .alias = "iodepth_batch_submit",
2175 .type = FIO_OPT_INT,
2176 .off1 = offsetof(struct thread_options, iodepth_batch),
2177 .help = "Number of IO buffers to submit in one go",
2178 .parent = "iodepth",
2179 .hide = 1,
2180 .interval = 1,
2181 .def = "1",
2182 .category = FIO_OPT_C_IO,
2183 .group = FIO_OPT_G_IO_BASIC,
2184 },
2185 {
2186 .name = "iodepth_batch_complete_min",
2187 .lname = "Min IO depth batch complete",
2188 .alias = "iodepth_batch_complete",
2189 .type = FIO_OPT_INT,
2190 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
2191 .help = "Min number of IO buffers to retrieve in one go",
2192 .parent = "iodepth",
2193 .hide = 1,
2194 .minval = 0,
2195 .interval = 1,
2196 .def = "1",
2197 .category = FIO_OPT_C_IO,
2198 .group = FIO_OPT_G_IO_BASIC,
2199 },
2200 {
2201 .name = "iodepth_batch_complete_max",
2202 .lname = "Max IO depth batch complete",
2203 .type = FIO_OPT_INT,
2204 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
2205 .help = "Max number of IO buffers to retrieve in one go",
2206 .parent = "iodepth",
2207 .hide = 1,
2208 .minval = 0,
2209 .interval = 1,
2210 .category = FIO_OPT_C_IO,
2211 .group = FIO_OPT_G_IO_BASIC,
2212 },
2213 {
2214 .name = "iodepth_low",
2215 .lname = "IO Depth batch low",
2216 .type = FIO_OPT_INT,
2217 .off1 = offsetof(struct thread_options, iodepth_low),
2218 .help = "Low water mark for queuing depth",
2219 .parent = "iodepth",
2220 .hide = 1,
2221 .interval = 1,
2222 .category = FIO_OPT_C_IO,
2223 .group = FIO_OPT_G_IO_BASIC,
2224 },
2225 {
2226 .name = "serialize_overlap",
2227 .lname = "Serialize overlap",
2228 .off1 = offsetof(struct thread_options, serialize_overlap),
2229 .type = FIO_OPT_BOOL,
2230 .help = "Wait for in-flight IOs that collide to complete",
2231 .parent = "iodepth",
2232 .def = "0",
2233 .category = FIO_OPT_C_IO,
2234 .group = FIO_OPT_G_IO_BASIC,
2235 },
2236 {
2237 .name = "io_submit_mode",
2238 .lname = "IO submit mode",
2239 .type = FIO_OPT_STR,
2240 .off1 = offsetof(struct thread_options, io_submit_mode),
2241 .help = "How IO submissions and completions are done",
2242 .def = "inline",
2243 .category = FIO_OPT_C_IO,
2244 .group = FIO_OPT_G_IO_BASIC,
2245 .posval = {
2246 { .ival = "inline",
2247 .oval = IO_MODE_INLINE,
2248 .help = "Submit and complete IO inline",
2249 },
2250 { .ival = "offload",
2251 .oval = IO_MODE_OFFLOAD,
2252 .help = "Offload submit and complete to threads",
2253 },
2254 },
2255 },
2256 {
2257 .name = "size",
2258 .lname = "Size",
2259 .type = FIO_OPT_STR_VAL_ZONE,
2260 .cb = str_size_cb,
2261 .off1 = offsetof(struct thread_options, size),
2262 .help = "Total size of device or files",
2263 .category = FIO_OPT_C_IO,
2264 .group = FIO_OPT_G_INVALID,
2265 },
2266 {
2267 .name = "io_size",
2268 .alias = "io_limit",
2269 .lname = "IO Size",
2270 .type = FIO_OPT_STR_VAL_ZONE,
2271 .cb = str_io_size_cb,
2272 .off1 = offsetof(struct thread_options, io_size),
2273 .help = "Total size of I/O to be performed",
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_INVALID,
2276 },
2277 {
2278 .name = "fill_device",
2279 .lname = "Fill device",
2280 .alias = "fill_fs",
2281 .type = FIO_OPT_BOOL,
2282 .off1 = offsetof(struct thread_options, fill_device),
2283 .help = "Write until an ENOSPC error occurs",
2284 .def = "0",
2285 .category = FIO_OPT_C_FILE,
2286 .group = FIO_OPT_G_INVALID,
2287 },
2288 {
2289 .name = "filesize",
2290 .lname = "File size",
2291 .type = FIO_OPT_STR_VAL,
2292 .off1 = offsetof(struct thread_options, file_size_low),
2293 .off2 = offsetof(struct thread_options, file_size_high),
2294 .minval = 1,
2295 .help = "Size of individual files",
2296 .interval = 1024 * 1024,
2297 .category = FIO_OPT_C_FILE,
2298 .group = FIO_OPT_G_INVALID,
2299 },
2300 {
2301 .name = "file_append",
2302 .lname = "File append",
2303 .type = FIO_OPT_BOOL,
2304 .off1 = offsetof(struct thread_options, file_append),
2305 .help = "IO will start at the end of the file(s)",
2306 .def = "0",
2307 .category = FIO_OPT_C_FILE,
2308 .group = FIO_OPT_G_INVALID,
2309 },
2310 {
2311 .name = "offset",
2312 .lname = "IO offset",
2313 .alias = "fileoffset",
2314 .type = FIO_OPT_STR_VAL_ZONE,
2315 .cb = str_offset_cb,
2316 .off1 = offsetof(struct thread_options, start_offset),
2317 .help = "Start IO from this offset",
2318 .def = "0",
2319 .category = FIO_OPT_C_IO,
2320 .group = FIO_OPT_G_INVALID,
2321 },
2322 {
2323 .name = "offset_align",
2324 .lname = "IO offset alignment",
2325 .type = FIO_OPT_INT,
2326 .off1 = offsetof(struct thread_options, start_offset_align),
2327 .help = "Start IO from this offset alignment",
2328 .def = "0",
2329 .interval = 512,
2330 .category = FIO_OPT_C_IO,
2331 .group = FIO_OPT_G_INVALID,
2332 },
2333 {
2334 .name = "offset_increment",
2335 .lname = "IO offset increment",
2336 .type = FIO_OPT_STR_VAL_ZONE,
2337 .cb = str_offset_increment_cb,
2338 .off1 = offsetof(struct thread_options, offset_increment),
2339 .help = "What is the increment from one offset to the next",
2340 .parent = "offset",
2341 .hide = 1,
2342 .def = "0",
2343 .category = FIO_OPT_C_IO,
2344 .group = FIO_OPT_G_INVALID,
2345 },
2346 {
2347 .name = "number_ios",
2348 .lname = "Number of IOs to perform",
2349 .type = FIO_OPT_STR_VAL,
2350 .off1 = offsetof(struct thread_options, number_ios),
2351 .help = "Force job completion after this number of IOs",
2352 .def = "0",
2353 .category = FIO_OPT_C_IO,
2354 .group = FIO_OPT_G_INVALID,
2355 },
2356 {
2357 .name = "bs",
2358 .lname = "Block size",
2359 .alias = "blocksize",
2360 .type = FIO_OPT_ULL,
2361 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
2362 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
2363 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
2364 .minval = 1,
2365 .help = "Block size unit",
2366 .def = "4096",
2367 .parent = "rw",
2368 .hide = 1,
2369 .interval = 512,
2370 .category = FIO_OPT_C_IO,
2371 .group = FIO_OPT_G_INVALID,
2372 },
2373 {
2374 .name = "ba",
2375 .lname = "Block size align",
2376 .alias = "blockalign",
2377 .type = FIO_OPT_ULL,
2378 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
2379 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
2380 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2381 .minval = 1,
2382 .help = "IO block offset alignment",
2383 .parent = "rw",
2384 .hide = 1,
2385 .interval = 512,
2386 .category = FIO_OPT_C_IO,
2387 .group = FIO_OPT_G_INVALID,
2388 },
2389 {
2390 .name = "bsrange",
2391 .lname = "Block size range",
2392 .alias = "blocksize_range",
2393 .type = FIO_OPT_RANGE,
2394 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
2395 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
2396 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2397 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2398 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2399 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2400 .minval = 1,
2401 .help = "Set block size range (in more detail than bs)",
2402 .parent = "rw",
2403 .hide = 1,
2404 .interval = 4096,
2405 .category = FIO_OPT_C_IO,
2406 .group = FIO_OPT_G_INVALID,
2407 },
2408 {
2409 .name = "bssplit",
2410 .lname = "Block size split",
2411 .type = FIO_OPT_STR_ULL,
2412 .cb = str_bssplit_cb,
2413 .off1 = offsetof(struct thread_options, bssplit),
2414 .help = "Set a specific mix of block sizes",
2415 .parent = "rw",
2416 .hide = 1,
2417 .category = FIO_OPT_C_IO,
2418 .group = FIO_OPT_G_INVALID,
2419 },
2420 {
2421 .name = "bs_unaligned",
2422 .lname = "Block size unaligned",
2423 .alias = "blocksize_unaligned",
2424 .type = FIO_OPT_STR_SET,
2425 .off1 = offsetof(struct thread_options, bs_unaligned),
2426 .help = "Don't sector align IO buffer sizes",
2427 .parent = "rw",
2428 .hide = 1,
2429 .category = FIO_OPT_C_IO,
2430 .group = FIO_OPT_G_INVALID,
2431 },
2432 {
2433 .name = "bs_is_seq_rand",
2434 .lname = "Block size division is seq/random (not read/write)",
2435 .type = FIO_OPT_BOOL,
2436 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
2437 .help = "Consider any blocksize setting to be sequential,random",
2438 .def = "0",
2439 .parent = "blocksize",
2440 .category = FIO_OPT_C_IO,
2441 .group = FIO_OPT_G_INVALID,
2442 },
2443 {
2444 .name = "randrepeat",
2445 .lname = "Random repeatable",
2446 .type = FIO_OPT_BOOL,
2447 .off1 = offsetof(struct thread_options, rand_repeatable),
2448 .help = "Use repeatable random IO pattern",
2449 .def = "1",
2450 .parent = "rw",
2451 .hide = 1,
2452 .category = FIO_OPT_C_IO,
2453 .group = FIO_OPT_G_RANDOM,
2454 },
2455 {
2456 .name = "randseed",
2457 .lname = "The random generator seed",
2458 .type = FIO_OPT_STR_VAL,
2459 .off1 = offsetof(struct thread_options, rand_seed),
2460 .help = "Set the random generator seed value",
2461 .def = "0x89",
2462 .parent = "rw",
2463 .category = FIO_OPT_C_IO,
2464 .group = FIO_OPT_G_RANDOM,
2465 },
2466 {
2467 .name = "norandommap",
2468 .lname = "No randommap",
2469 .type = FIO_OPT_STR_SET,
2470 .off1 = offsetof(struct thread_options, norandommap),
2471 .help = "Accept potential duplicate random blocks",
2472 .parent = "rw",
2473 .hide = 1,
2474 .hide_on_set = 1,
2475 .category = FIO_OPT_C_IO,
2476 .group = FIO_OPT_G_RANDOM,
2477 },
2478 {
2479 .name = "softrandommap",
2480 .lname = "Soft randommap",
2481 .type = FIO_OPT_BOOL,
2482 .off1 = offsetof(struct thread_options, softrandommap),
2483 .help = "Set norandommap if randommap allocation fails",
2484 .parent = "norandommap",
2485 .hide = 1,
2486 .def = "0",
2487 .category = FIO_OPT_C_IO,
2488 .group = FIO_OPT_G_RANDOM,
2489 },
2490 {
2491 .name = "random_generator",
2492 .lname = "Random Generator",
2493 .type = FIO_OPT_STR,
2494 .off1 = offsetof(struct thread_options, random_generator),
2495 .help = "Type of random number generator to use",
2496 .def = "tausworthe",
2497 .posval = {
2498 { .ival = "tausworthe",
2499 .oval = FIO_RAND_GEN_TAUSWORTHE,
2500 .help = "Strong Tausworthe generator",
2501 },
2502 { .ival = "lfsr",
2503 .oval = FIO_RAND_GEN_LFSR,
2504 .help = "Variable length LFSR",
2505 },
2506 {
2507 .ival = "tausworthe64",
2508 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2509 .help = "64-bit Tausworthe variant",
2510 },
2511 },
2512 .category = FIO_OPT_C_IO,
2513 .group = FIO_OPT_G_RANDOM,
2514 },
2515 {
2516 .name = "random_distribution",
2517 .lname = "Random Distribution",
2518 .type = FIO_OPT_STR,
2519 .off1 = offsetof(struct thread_options, random_distribution),
2520 .cb = str_random_distribution_cb,
2521 .help = "Random offset distribution generator",
2522 .def = "random",
2523 .posval = {
2524 { .ival = "random",
2525 .oval = FIO_RAND_DIST_RANDOM,
2526 .help = "Completely random",
2527 },
2528 { .ival = "zipf",
2529 .oval = FIO_RAND_DIST_ZIPF,
2530 .help = "Zipf distribution",
2531 },
2532 { .ival = "pareto",
2533 .oval = FIO_RAND_DIST_PARETO,
2534 .help = "Pareto distribution",
2535 },
2536 { .ival = "normal",
2537 .oval = FIO_RAND_DIST_GAUSS,
2538 .help = "Normal (Gaussian) distribution",
2539 },
2540 { .ival = "zoned",
2541 .oval = FIO_RAND_DIST_ZONED,
2542 .help = "Zoned random distribution",
2543 },
2544 { .ival = "zoned_abs",
2545 .oval = FIO_RAND_DIST_ZONED_ABS,
2546 .help = "Zoned absolute random distribution",
2547 },
2548 },
2549 .category = FIO_OPT_C_IO,
2550 .group = FIO_OPT_G_RANDOM,
2551 },
2552 {
2553 .name = "percentage_random",
2554 .lname = "Percentage Random",
2555 .type = FIO_OPT_INT,
2556 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2557 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2558 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2559 .maxval = 100,
2560 .help = "Percentage of seq/random mix that should be random",
2561 .def = "100,100,100",
2562 .interval = 5,
2563 .inverse = "percentage_sequential",
2564 .category = FIO_OPT_C_IO,
2565 .group = FIO_OPT_G_RANDOM,
2566 },
2567 {
2568 .name = "percentage_sequential",
2569 .lname = "Percentage Sequential",
2570 .type = FIO_OPT_DEPRECATED,
2571 .category = FIO_OPT_C_IO,
2572 .group = FIO_OPT_G_RANDOM,
2573 },
2574 {
2575 .name = "allrandrepeat",
2576 .lname = "All Random Repeat",
2577 .type = FIO_OPT_BOOL,
2578 .off1 = offsetof(struct thread_options, allrand_repeatable),
2579 .help = "Use repeatable random numbers for everything",
2580 .def = "0",
2581 .category = FIO_OPT_C_IO,
2582 .group = FIO_OPT_G_RANDOM,
2583 },
2584 {
2585 .name = "nrfiles",
2586 .lname = "Number of files",
2587 .alias = "nr_files",
2588 .type = FIO_OPT_INT,
2589 .off1 = offsetof(struct thread_options, nr_files),
2590 .help = "Split job workload between this number of files",
2591 .def = "1",
2592 .interval = 1,
2593 .category = FIO_OPT_C_FILE,
2594 .group = FIO_OPT_G_INVALID,
2595 },
2596 {
2597 .name = "openfiles",
2598 .lname = "Number of open files",
2599 .type = FIO_OPT_INT,
2600 .off1 = offsetof(struct thread_options, open_files),
2601 .help = "Number of files to keep open at the same time",
2602 .category = FIO_OPT_C_FILE,
2603 .group = FIO_OPT_G_INVALID,
2604 },
2605 {
2606 .name = "file_service_type",
2607 .lname = "File service type",
2608 .type = FIO_OPT_STR,
2609 .cb = str_fst_cb,
2610 .off1 = offsetof(struct thread_options, file_service_type),
2611 .help = "How to select which file to service next",
2612 .def = "roundrobin",
2613 .category = FIO_OPT_C_FILE,
2614 .group = FIO_OPT_G_INVALID,
2615 .posval = {
2616 { .ival = "random",
2617 .oval = FIO_FSERVICE_RANDOM,
2618 .help = "Choose a file at random (uniform)",
2619 },
2620 { .ival = "zipf",
2621 .oval = FIO_FSERVICE_ZIPF,
2622 .help = "Zipf randomized",
2623 },
2624 { .ival = "pareto",
2625 .oval = FIO_FSERVICE_PARETO,
2626 .help = "Pareto randomized",
2627 },
2628 { .ival = "normal",
2629 .oval = FIO_FSERVICE_GAUSS,
2630 .help = "Normal (Gaussian) randomized",
2631 },
2632 { .ival = "gauss",
2633 .oval = FIO_FSERVICE_GAUSS,
2634 .help = "Alias for normal",
2635 },
2636 { .ival = "roundrobin",
2637 .oval = FIO_FSERVICE_RR,
2638 .help = "Round robin select files",
2639 },
2640 { .ival = "sequential",
2641 .oval = FIO_FSERVICE_SEQ,
2642 .help = "Finish one file before moving to the next",
2643 },
2644 },
2645 .parent = "nrfiles",
2646 .hide = 1,
2647 },
2648 {
2649 .name = "fallocate",
2650 .lname = "Fallocate",
2651 .type = FIO_OPT_STR,
2652 .off1 = offsetof(struct thread_options, fallocate_mode),
2653 .help = "Whether pre-allocation is performed when laying out files",
2654#ifdef FIO_HAVE_DEFAULT_FALLOCATE
2655 .def = "native",
2656#else
2657 .def = "none",
2658#endif
2659 .category = FIO_OPT_C_FILE,
2660 .group = FIO_OPT_G_INVALID,
2661 .posval = {
2662 { .ival = "none",
2663 .oval = FIO_FALLOCATE_NONE,
2664 .help = "Do not pre-allocate space",
2665 },
2666 { .ival = "native",
2667 .oval = FIO_FALLOCATE_NATIVE,
2668 .help = "Use native pre-allocation if possible",
2669 },
2670#ifdef CONFIG_POSIX_FALLOCATE
2671 { .ival = "posix",
2672 .oval = FIO_FALLOCATE_POSIX,
2673 .help = "Use posix_fallocate()",
2674 },
2675#endif
2676#ifdef CONFIG_LINUX_FALLOCATE
2677 { .ival = "keep",
2678 .oval = FIO_FALLOCATE_KEEP_SIZE,
2679 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2680 },
2681#endif
2682 { .ival = "truncate",
2683 .oval = FIO_FALLOCATE_TRUNCATE,
2684 .help = "Truncate file to final size instead of allocating"
2685 },
2686 /* Compatibility with former boolean values */
2687 { .ival = "0",
2688 .oval = FIO_FALLOCATE_NONE,
2689 .help = "Alias for 'none'",
2690 },
2691#ifdef CONFIG_POSIX_FALLOCATE
2692 { .ival = "1",
2693 .oval = FIO_FALLOCATE_POSIX,
2694 .help = "Alias for 'posix'",
2695 },
2696#endif
2697 },
2698 },
2699 {
2700 .name = "fadvise_hint",
2701 .lname = "Fadvise hint",
2702 .type = FIO_OPT_STR,
2703 .off1 = offsetof(struct thread_options, fadvise_hint),
2704 .posval = {
2705 { .ival = "0",
2706 .oval = F_ADV_NONE,
2707 .help = "Don't issue fadvise/madvise",
2708 },
2709 { .ival = "1",
2710 .oval = F_ADV_TYPE,
2711 .help = "Advise using fio IO pattern",
2712 },
2713 { .ival = "random",
2714 .oval = F_ADV_RANDOM,
2715 .help = "Advise using FADV_RANDOM",
2716 },
2717 { .ival = "sequential",
2718 .oval = F_ADV_SEQUENTIAL,
2719 .help = "Advise using FADV_SEQUENTIAL",
2720 },
2721 },
2722 .help = "Use fadvise() to advise the kernel on IO pattern",
2723 .def = "1",
2724 .category = FIO_OPT_C_FILE,
2725 .group = FIO_OPT_G_INVALID,
2726 },
2727 {
2728 .name = "fsync",
2729 .lname = "Fsync",
2730 .type = FIO_OPT_INT,
2731 .off1 = offsetof(struct thread_options, fsync_blocks),
2732 .help = "Issue fsync for writes every given number of blocks",
2733 .def = "0",
2734 .interval = 1,
2735 .category = FIO_OPT_C_FILE,
2736 .group = FIO_OPT_G_INVALID,
2737 },
2738 {
2739 .name = "fdatasync",
2740 .lname = "Fdatasync",
2741 .type = FIO_OPT_INT,
2742 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2743 .help = "Issue fdatasync for writes every given number of blocks",
2744 .def = "0",
2745 .interval = 1,
2746 .category = FIO_OPT_C_FILE,
2747 .group = FIO_OPT_G_INVALID,
2748 },
2749 {
2750 .name = "write_barrier",
2751 .lname = "Write barrier",
2752 .type = FIO_OPT_INT,
2753 .off1 = offsetof(struct thread_options, barrier_blocks),
2754 .help = "Make every Nth write a barrier write",
2755 .def = "0",
2756 .interval = 1,
2757 .category = FIO_OPT_C_IO,
2758 .group = FIO_OPT_G_INVALID,
2759 },
2760#ifdef CONFIG_SYNC_FILE_RANGE
2761 {
2762 .name = "sync_file_range",
2763 .lname = "Sync file range",
2764 .posval = {
2765 { .ival = "wait_before",
2766 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2767 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2768 .orval = 1,
2769 },
2770 { .ival = "write",
2771 .oval = SYNC_FILE_RANGE_WRITE,
2772 .help = "SYNC_FILE_RANGE_WRITE",
2773 .orval = 1,
2774 },
2775 {
2776 .ival = "wait_after",
2777 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2778 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2779 .orval = 1,
2780 },
2781 },
2782 .type = FIO_OPT_STR_MULTI,
2783 .cb = str_sfr_cb,
2784 .off1 = offsetof(struct thread_options, sync_file_range),
2785 .help = "Use sync_file_range()",
2786 .category = FIO_OPT_C_FILE,
2787 .group = FIO_OPT_G_INVALID,
2788 },
2789#else
2790 {
2791 .name = "sync_file_range",
2792 .lname = "Sync file range",
2793 .type = FIO_OPT_UNSUPPORTED,
2794 .help = "Your platform does not support sync_file_range",
2795 },
2796#endif
2797 {
2798 .name = "direct",
2799 .lname = "Direct I/O",
2800 .type = FIO_OPT_BOOL,
2801 .off1 = offsetof(struct thread_options, odirect),
2802 .help = "Use O_DIRECT IO (negates buffered)",
2803 .def = "0",
2804 .inverse = "buffered",
2805 .category = FIO_OPT_C_IO,
2806 .group = FIO_OPT_G_IO_TYPE,
2807 },
2808 {
2809 .name = "atomic",
2810 .lname = "Atomic I/O",
2811 .type = FIO_OPT_BOOL,
2812 .off1 = offsetof(struct thread_options, oatomic),
2813 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2814 .def = "0",
2815 .category = FIO_OPT_C_IO,
2816 .group = FIO_OPT_G_IO_TYPE,
2817 },
2818 {
2819 .name = "buffered",
2820 .lname = "Buffered I/O",
2821 .type = FIO_OPT_BOOL,
2822 .off1 = offsetof(struct thread_options, odirect),
2823 .neg = 1,
2824 .help = "Use buffered IO (negates direct)",
2825 .def = "1",
2826 .inverse = "direct",
2827 .category = FIO_OPT_C_IO,
2828 .group = FIO_OPT_G_IO_TYPE,
2829 },
2830 {
2831 .name = "overwrite",
2832 .lname = "Overwrite",
2833 .type = FIO_OPT_BOOL,
2834 .off1 = offsetof(struct thread_options, overwrite),
2835 .help = "When writing, set whether to overwrite current data",
2836 .def = "0",
2837 .category = FIO_OPT_C_FILE,
2838 .group = FIO_OPT_G_INVALID,
2839 },
2840 {
2841 .name = "loops",
2842 .lname = "Loops",
2843 .type = FIO_OPT_INT,
2844 .off1 = offsetof(struct thread_options, loops),
2845 .help = "Number of times to run the job",
2846 .def = "1",
2847 .interval = 1,
2848 .category = FIO_OPT_C_GENERAL,
2849 .group = FIO_OPT_G_RUNTIME,
2850 },
2851 {
2852 .name = "numjobs",
2853 .lname = "Number of jobs",
2854 .type = FIO_OPT_INT,
2855 .off1 = offsetof(struct thread_options, numjobs),
2856 .help = "Duplicate this job this many times",
2857 .def = "1",
2858 .interval = 1,
2859 .category = FIO_OPT_C_GENERAL,
2860 .group = FIO_OPT_G_RUNTIME,
2861 },
2862 {
2863 .name = "startdelay",
2864 .lname = "Start delay",
2865 .type = FIO_OPT_STR_VAL_TIME,
2866 .off1 = offsetof(struct thread_options, start_delay),
2867 .off2 = offsetof(struct thread_options, start_delay_high),
2868 .help = "Only start job when this period has passed",
2869 .def = "0",
2870 .is_seconds = 1,
2871 .is_time = 1,
2872 .category = FIO_OPT_C_GENERAL,
2873 .group = FIO_OPT_G_RUNTIME,
2874 },
2875 {
2876 .name = "runtime",
2877 .lname = "Runtime",
2878 .alias = "timeout",
2879 .type = FIO_OPT_STR_VAL_TIME,
2880 .off1 = offsetof(struct thread_options, timeout),
2881 .help = "Stop workload when this amount of time has passed",
2882 .def = "0",
2883 .is_seconds = 1,
2884 .is_time = 1,
2885 .category = FIO_OPT_C_GENERAL,
2886 .group = FIO_OPT_G_RUNTIME,
2887 },
2888 {
2889 .name = "time_based",
2890 .lname = "Time based",
2891 .type = FIO_OPT_STR_SET,
2892 .off1 = offsetof(struct thread_options, time_based),
2893 .help = "Keep running until runtime/timeout is met",
2894 .category = FIO_OPT_C_GENERAL,
2895 .group = FIO_OPT_G_RUNTIME,
2896 },
2897 {
2898 .name = "verify_only",
2899 .lname = "Verify only",
2900 .type = FIO_OPT_STR_SET,
2901 .off1 = offsetof(struct thread_options, verify_only),
2902 .help = "Verifies previously written data is still valid",
2903 .category = FIO_OPT_C_GENERAL,
2904 .group = FIO_OPT_G_RUNTIME,
2905 },
2906 {
2907 .name = "ramp_time",
2908 .lname = "Ramp time",
2909 .type = FIO_OPT_STR_VAL_TIME,
2910 .off1 = offsetof(struct thread_options, ramp_time),
2911 .help = "Ramp up time before measuring performance",
2912 .is_seconds = 1,
2913 .is_time = 1,
2914 .category = FIO_OPT_C_GENERAL,
2915 .group = FIO_OPT_G_RUNTIME,
2916 },
2917 {
2918 .name = "clocksource",
2919 .lname = "Clock source",
2920 .type = FIO_OPT_STR,
2921 .cb = fio_clock_source_cb,
2922 .off1 = offsetof(struct thread_options, clocksource),
2923 .help = "What type of timing source to use",
2924 .category = FIO_OPT_C_GENERAL,
2925 .group = FIO_OPT_G_CLOCK,
2926 .posval = {
2927#ifdef CONFIG_GETTIMEOFDAY
2928 { .ival = "gettimeofday",
2929 .oval = CS_GTOD,
2930 .help = "Use gettimeofday(2) for timing",
2931 },
2932#endif
2933#ifdef CONFIG_CLOCK_GETTIME
2934 { .ival = "clock_gettime",
2935 .oval = CS_CGETTIME,
2936 .help = "Use clock_gettime(2) for timing",
2937 },
2938#endif
2939#ifdef ARCH_HAVE_CPU_CLOCK
2940 { .ival = "cpu",
2941 .oval = CS_CPUCLOCK,
2942 .help = "Use CPU private clock",
2943 },
2944#endif
2945 },
2946 },
2947 {
2948 .name = "mem",
2949 .alias = "iomem",
2950 .lname = "I/O Memory",
2951 .type = FIO_OPT_STR,
2952 .cb = str_mem_cb,
2953 .off1 = offsetof(struct thread_options, mem_type),
2954 .help = "Backing type for IO buffers",
2955 .def = "malloc",
2956 .category = FIO_OPT_C_IO,
2957 .group = FIO_OPT_G_INVALID,
2958 .posval = {
2959 { .ival = "malloc",
2960 .oval = MEM_MALLOC,
2961 .help = "Use malloc(3) for IO buffers",
2962 },
2963#ifndef CONFIG_NO_SHM
2964 { .ival = "shm",
2965 .oval = MEM_SHM,
2966 .help = "Use shared memory segments for IO buffers",
2967 },
2968#ifdef FIO_HAVE_HUGETLB
2969 { .ival = "shmhuge",
2970 .oval = MEM_SHMHUGE,
2971 .help = "Like shm, but use huge pages",
2972 },
2973#endif
2974#endif
2975 { .ival = "mmap",
2976 .oval = MEM_MMAP,
2977 .help = "Use mmap(2) (file or anon) for IO buffers",
2978 },
2979 { .ival = "mmapshared",
2980 .oval = MEM_MMAPSHARED,
2981 .help = "Like mmap, but use the shared flag",
2982 },
2983#ifdef FIO_HAVE_HUGETLB
2984 { .ival = "mmaphuge",
2985 .oval = MEM_MMAPHUGE,
2986 .help = "Like mmap, but use huge pages",
2987 },
2988#endif
2989#ifdef CONFIG_CUDA
2990 { .ival = "cudamalloc",
2991 .oval = MEM_CUDA_MALLOC,
2992 .help = "Allocate GPU device memory for GPUDirect RDMA",
2993 },
2994#endif
2995 },
2996 },
2997 {
2998 .name = "iomem_align",
2999 .alias = "mem_align",
3000 .lname = "I/O memory alignment",
3001 .type = FIO_OPT_INT,
3002 .off1 = offsetof(struct thread_options, mem_align),
3003 .minval = 0,
3004 .help = "IO memory buffer offset alignment",
3005 .def = "0",
3006 .parent = "iomem",
3007 .hide = 1,
3008 .category = FIO_OPT_C_IO,
3009 .group = FIO_OPT_G_INVALID,
3010 },
3011 {
3012 .name = "verify",
3013 .lname = "Verify",
3014 .type = FIO_OPT_STR,
3015 .off1 = offsetof(struct thread_options, verify),
3016 .help = "Verify data written",
3017 .def = "0",
3018 .category = FIO_OPT_C_IO,
3019 .group = FIO_OPT_G_VERIFY,
3020 .posval = {
3021 { .ival = "0",
3022 .oval = VERIFY_NONE,
3023 .help = "Don't do IO verification",
3024 },
3025 { .ival = "md5",
3026 .oval = VERIFY_MD5,
3027 .help = "Use md5 checksums for verification",
3028 },
3029 { .ival = "crc64",
3030 .oval = VERIFY_CRC64,
3031 .help = "Use crc64 checksums for verification",
3032 },
3033 { .ival = "crc32",
3034 .oval = VERIFY_CRC32,
3035 .help = "Use crc32 checksums for verification",
3036 },
3037 { .ival = "crc32c-intel",
3038 .oval = VERIFY_CRC32C,
3039 .help = "Use crc32c checksums for verification (hw assisted, if available)",
3040 },
3041 { .ival = "crc32c",
3042 .oval = VERIFY_CRC32C,
3043 .help = "Use crc32c checksums for verification (hw assisted, if available)",
3044 },
3045 { .ival = "crc16",
3046 .oval = VERIFY_CRC16,
3047 .help = "Use crc16 checksums for verification",
3048 },
3049 { .ival = "crc7",
3050 .oval = VERIFY_CRC7,
3051 .help = "Use crc7 checksums for verification",
3052 },
3053 { .ival = "sha1",
3054 .oval = VERIFY_SHA1,
3055 .help = "Use sha1 checksums for verification",
3056 },
3057 { .ival = "sha256",
3058 .oval = VERIFY_SHA256,
3059 .help = "Use sha256 checksums for verification",
3060 },
3061 { .ival = "sha512",
3062 .oval = VERIFY_SHA512,
3063 .help = "Use sha512 checksums for verification",
3064 },
3065 { .ival = "sha3-224",
3066 .oval = VERIFY_SHA3_224,
3067 .help = "Use sha3-224 checksums for verification",
3068 },
3069 { .ival = "sha3-256",
3070 .oval = VERIFY_SHA3_256,
3071 .help = "Use sha3-256 checksums for verification",
3072 },
3073 { .ival = "sha3-384",
3074 .oval = VERIFY_SHA3_384,
3075 .help = "Use sha3-384 checksums for verification",
3076 },
3077 { .ival = "sha3-512",
3078 .oval = VERIFY_SHA3_512,
3079 .help = "Use sha3-512 checksums for verification",
3080 },
3081 { .ival = "xxhash",
3082 .oval = VERIFY_XXHASH,
3083 .help = "Use xxhash checksums for verification",
3084 },
3085 /* Meta information was included into verify_header,
3086 * 'meta' verification is implied by default. */
3087 { .ival = "meta",
3088 .oval = VERIFY_HDR_ONLY,
3089 .help = "Use io information for verification. "
3090 "Now is implied by default, thus option is obsolete, "
3091 "don't use it",
3092 },
3093 { .ival = "pattern",
3094 .oval = VERIFY_PATTERN_NO_HDR,
3095 .help = "Verify strict pattern",
3096 },
3097 {
3098 .ival = "null",
3099 .oval = VERIFY_NULL,
3100 .help = "Pretend to verify",
3101 },
3102 },
3103 },
3104 {
3105 .name = "do_verify",
3106 .lname = "Perform verify step",
3107 .type = FIO_OPT_BOOL,
3108 .off1 = offsetof(struct thread_options, do_verify),
3109 .help = "Run verification stage after write",
3110 .def = "1",
3111 .parent = "verify",
3112 .hide = 1,
3113 .category = FIO_OPT_C_IO,
3114 .group = FIO_OPT_G_VERIFY,
3115 },
3116 {
3117 .name = "verifysort",
3118 .lname = "Verify sort",
3119 .type = FIO_OPT_SOFT_DEPRECATED,
3120 .category = FIO_OPT_C_IO,
3121 .group = FIO_OPT_G_VERIFY,
3122 },
3123 {
3124 .name = "verifysort_nr",
3125 .lname = "Verify Sort Nr",
3126 .type = FIO_OPT_SOFT_DEPRECATED,
3127 .category = FIO_OPT_C_IO,
3128 .group = FIO_OPT_G_VERIFY,
3129 },
3130 {
3131 .name = "verify_interval",
3132 .lname = "Verify interval",
3133 .type = FIO_OPT_INT,
3134 .off1 = offsetof(struct thread_options, verify_interval),
3135 .minval = 2 * sizeof(struct verify_header),
3136 .help = "Store verify buffer header every N bytes",
3137 .parent = "verify",
3138 .hide = 1,
3139 .interval = 2 * sizeof(struct verify_header),
3140 .category = FIO_OPT_C_IO,
3141 .group = FIO_OPT_G_VERIFY,
3142 },
3143 {
3144 .name = "verify_offset",
3145 .lname = "Verify offset",
3146 .type = FIO_OPT_INT,
3147 .help = "Offset verify header location by N bytes",
3148 .off1 = offsetof(struct thread_options, verify_offset),
3149 .minval = sizeof(struct verify_header),
3150 .parent = "verify",
3151 .hide = 1,
3152 .category = FIO_OPT_C_IO,
3153 .group = FIO_OPT_G_VERIFY,
3154 },
3155 {
3156 .name = "verify_pattern",
3157 .lname = "Verify pattern",
3158 .type = FIO_OPT_STR,
3159 .cb = str_verify_pattern_cb,
3160 .off1 = offsetof(struct thread_options, verify_pattern),
3161 .help = "Fill pattern for IO buffers",
3162 .parent = "verify",
3163 .hide = 1,
3164 .category = FIO_OPT_C_IO,
3165 .group = FIO_OPT_G_VERIFY,
3166 },
3167 {
3168 .name = "verify_fatal",
3169 .lname = "Verify fatal",
3170 .type = FIO_OPT_BOOL,
3171 .off1 = offsetof(struct thread_options, verify_fatal),
3172 .def = "0",
3173 .help = "Exit on a single verify failure, don't continue",
3174 .parent = "verify",
3175 .hide = 1,
3176 .category = FIO_OPT_C_IO,
3177 .group = FIO_OPT_G_VERIFY,
3178 },
3179 {
3180 .name = "verify_dump",
3181 .lname = "Verify dump",
3182 .type = FIO_OPT_BOOL,
3183 .off1 = offsetof(struct thread_options, verify_dump),
3184 .def = "0",
3185 .help = "Dump contents of good and bad blocks on failure",
3186 .parent = "verify",
3187 .hide = 1,
3188 .category = FIO_OPT_C_IO,
3189 .group = FIO_OPT_G_VERIFY,
3190 },
3191 {
3192 .name = "verify_async",
3193 .lname = "Verify asynchronously",
3194 .type = FIO_OPT_INT,
3195 .off1 = offsetof(struct thread_options, verify_async),
3196 .def = "0",
3197 .help = "Number of async verifier threads to use",
3198 .parent = "verify",
3199 .hide = 1,
3200 .category = FIO_OPT_C_IO,
3201 .group = FIO_OPT_G_VERIFY,
3202 },
3203 {
3204 .name = "verify_backlog",
3205 .lname = "Verify backlog",
3206 .type = FIO_OPT_STR_VAL,
3207 .off1 = offsetof(struct thread_options, verify_backlog),
3208 .help = "Verify after this number of blocks are written",
3209 .parent = "verify",
3210 .hide = 1,
3211 .category = FIO_OPT_C_IO,
3212 .group = FIO_OPT_G_VERIFY,
3213 },
3214 {
3215 .name = "verify_backlog_batch",
3216 .lname = "Verify backlog batch",
3217 .type = FIO_OPT_INT,
3218 .off1 = offsetof(struct thread_options, verify_batch),
3219 .help = "Verify this number of IO blocks",
3220 .parent = "verify",
3221 .hide = 1,
3222 .category = FIO_OPT_C_IO,
3223 .group = FIO_OPT_G_VERIFY,
3224 },
3225#ifdef FIO_HAVE_CPU_AFFINITY
3226 {
3227 .name = "verify_async_cpus",
3228 .lname = "Async verify CPUs",
3229 .type = FIO_OPT_STR,
3230 .cb = str_verify_cpus_allowed_cb,
3231 .off1 = offsetof(struct thread_options, verify_cpumask),
3232 .help = "Set CPUs allowed for async verify threads",
3233 .parent = "verify_async",
3234 .hide = 1,
3235 .category = FIO_OPT_C_IO,
3236 .group = FIO_OPT_G_VERIFY,
3237 },
3238#else
3239 {
3240 .name = "verify_async_cpus",
3241 .lname = "Async verify CPUs",
3242 .type = FIO_OPT_UNSUPPORTED,
3243 .help = "Your platform does not support CPU affinities",
3244 },
3245#endif
3246 {
3247 .name = "experimental_verify",
3248 .lname = "Experimental Verify",
3249 .off1 = offsetof(struct thread_options, experimental_verify),
3250 .type = FIO_OPT_BOOL,
3251 .help = "Enable experimental verification",
3252 .parent = "verify",
3253 .category = FIO_OPT_C_IO,
3254 .group = FIO_OPT_G_VERIFY,
3255 },
3256 {
3257 .name = "verify_state_load",
3258 .lname = "Load verify state",
3259 .off1 = offsetof(struct thread_options, verify_state),
3260 .type = FIO_OPT_BOOL,
3261 .help = "Load verify termination state",
3262 .parent = "verify",
3263 .category = FIO_OPT_C_IO,
3264 .group = FIO_OPT_G_VERIFY,
3265 },
3266 {
3267 .name = "verify_state_save",
3268 .lname = "Save verify state",
3269 .off1 = offsetof(struct thread_options, verify_state_save),
3270 .type = FIO_OPT_BOOL,
3271 .def = "1",
3272 .help = "Save verify state on termination",
3273 .parent = "verify",
3274 .category = FIO_OPT_C_IO,
3275 .group = FIO_OPT_G_VERIFY,
3276 },
3277#ifdef FIO_HAVE_TRIM
3278 {
3279 .name = "trim_percentage",
3280 .lname = "Trim percentage",
3281 .type = FIO_OPT_INT,
3282 .off1 = offsetof(struct thread_options, trim_percentage),
3283 .minval = 0,
3284 .maxval = 100,
3285 .help = "Number of verify blocks to trim (i.e., discard)",
3286 .parent = "verify",
3287 .def = "0",
3288 .interval = 1,
3289 .hide = 1,
3290 .category = FIO_OPT_C_IO,
3291 .group = FIO_OPT_G_TRIM,
3292 },
3293 {
3294 .name = "trim_verify_zero",
3295 .lname = "Verify trim zero",
3296 .type = FIO_OPT_BOOL,
3297 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
3298 .off1 = offsetof(struct thread_options, trim_zero),
3299 .parent = "trim_percentage",
3300 .hide = 1,
3301 .def = "1",
3302 .category = FIO_OPT_C_IO,
3303 .group = FIO_OPT_G_TRIM,
3304 },
3305 {
3306 .name = "trim_backlog",
3307 .lname = "Trim backlog",
3308 .type = FIO_OPT_STR_VAL,
3309 .off1 = offsetof(struct thread_options, trim_backlog),
3310 .help = "Trim after this number of blocks are written",
3311 .parent = "trim_percentage",
3312 .hide = 1,
3313 .interval = 1,
3314 .category = FIO_OPT_C_IO,
3315 .group = FIO_OPT_G_TRIM,
3316 },
3317 {
3318 .name = "trim_backlog_batch",
3319 .lname = "Trim backlog batch",
3320 .type = FIO_OPT_INT,
3321 .off1 = offsetof(struct thread_options, trim_batch),
3322 .help = "Trim this number of IO blocks",
3323 .parent = "trim_percentage",
3324 .hide = 1,
3325 .interval = 1,
3326 .category = FIO_OPT_C_IO,
3327 .group = FIO_OPT_G_TRIM,
3328 },
3329#else
3330 {
3331 .name = "trim_percentage",
3332 .lname = "Trim percentage",
3333 .type = FIO_OPT_UNSUPPORTED,
3334 .help = "Fio does not support TRIM on your platform",
3335 },
3336 {
3337 .name = "trim_verify_zero",
3338 .lname = "Verify trim zero",
3339 .type = FIO_OPT_UNSUPPORTED,
3340 .help = "Fio does not support TRIM on your platform",
3341 },
3342 {
3343 .name = "trim_backlog",
3344 .lname = "Trim backlog",
3345 .type = FIO_OPT_UNSUPPORTED,
3346 .help = "Fio does not support TRIM on your platform",
3347 },
3348 {
3349 .name = "trim_backlog_batch",
3350 .lname = "Trim backlog batch",
3351 .type = FIO_OPT_UNSUPPORTED,
3352 .help = "Fio does not support TRIM on your platform",
3353 },
3354#endif
3355 {
3356 .name = "write_iolog",
3357 .lname = "Write I/O log",
3358 .type = FIO_OPT_STR_STORE,
3359 .off1 = offsetof(struct thread_options, write_iolog_file),
3360 .help = "Store IO pattern to file",
3361 .category = FIO_OPT_C_IO,
3362 .group = FIO_OPT_G_IOLOG,
3363 },
3364 {
3365 .name = "read_iolog",
3366 .lname = "Read I/O log",
3367 .type = FIO_OPT_STR_STORE,
3368 .off1 = offsetof(struct thread_options, read_iolog_file),
3369 .help = "Playback IO pattern from file",
3370 .category = FIO_OPT_C_IO,
3371 .group = FIO_OPT_G_IOLOG,
3372 },
3373 {
3374 .name = "read_iolog_chunked",
3375 .lname = "Read I/O log in parts",
3376 .type = FIO_OPT_BOOL,
3377 .off1 = offsetof(struct thread_options, read_iolog_chunked),
3378 .def = "0",
3379 .parent = "read_iolog",
3380 .help = "Parse IO pattern in chunks",
3381 .category = FIO_OPT_C_IO,
3382 .group = FIO_OPT_G_IOLOG,
3383 },
3384 {
3385 .name = "replay_no_stall",
3386 .lname = "Don't stall on replay",
3387 .type = FIO_OPT_BOOL,
3388 .off1 = offsetof(struct thread_options, no_stall),
3389 .def = "0",
3390 .parent = "read_iolog",
3391 .hide = 1,
3392 .help = "Playback IO pattern file as fast as possible without stalls",
3393 .category = FIO_OPT_C_IO,
3394 .group = FIO_OPT_G_IOLOG,
3395 },
3396 {
3397 .name = "replay_redirect",
3398 .lname = "Redirect device for replay",
3399 .type = FIO_OPT_STR_STORE,
3400 .off1 = offsetof(struct thread_options, replay_redirect),
3401 .parent = "read_iolog",
3402 .hide = 1,
3403 .help = "Replay all I/O onto this device, regardless of trace device",
3404 .category = FIO_OPT_C_IO,
3405 .group = FIO_OPT_G_IOLOG,
3406 },
3407 {
3408 .name = "replay_scale",
3409 .lname = "Replace offset scale factor",
3410 .type = FIO_OPT_INT,
3411 .off1 = offsetof(struct thread_options, replay_scale),
3412 .parent = "read_iolog",
3413 .def = "1",
3414 .help = "Align offsets to this blocksize",
3415 .category = FIO_OPT_C_IO,
3416 .group = FIO_OPT_G_IOLOG,
3417 },
3418 {
3419 .name = "replay_align",
3420 .lname = "Replace alignment",
3421 .type = FIO_OPT_INT,
3422 .off1 = offsetof(struct thread_options, replay_align),
3423 .parent = "read_iolog",
3424 .help = "Scale offset down by this factor",
3425 .category = FIO_OPT_C_IO,
3426 .group = FIO_OPT_G_IOLOG,
3427 .pow2 = 1,
3428 },
3429 {
3430 .name = "replay_time_scale",
3431 .lname = "Replay Time Scale",
3432 .type = FIO_OPT_INT,
3433 .off1 = offsetof(struct thread_options, replay_time_scale),
3434 .def = "100",
3435 .minval = 1,
3436 .parent = "read_iolog",
3437 .hide = 1,
3438 .help = "Scale time for replay events",
3439 .category = FIO_OPT_C_IO,
3440 .group = FIO_OPT_G_IOLOG,
3441 },
3442 {
3443 .name = "replay_skip",
3444 .lname = "Replay Skip",
3445 .type = FIO_OPT_STR,
3446 .cb = str_replay_skip_cb,
3447 .off1 = offsetof(struct thread_options, replay_skip),
3448 .parent = "read_iolog",
3449 .help = "Skip certain IO types (read,write,trim,flush)",
3450 .category = FIO_OPT_C_IO,
3451 .group = FIO_OPT_G_IOLOG,
3452 },
3453 {
3454 .name = "merge_blktrace_file",
3455 .lname = "Merged blktrace output filename",
3456 .type = FIO_OPT_STR_STORE,
3457 .off1 = offsetof(struct thread_options, merge_blktrace_file),
3458 .help = "Merged blktrace output filename",
3459 .category = FIO_OPT_C_IO,
3460 .group = FIO_OPT_G_IOLOG,
3461 },
3462 {
3463 .name = "merge_blktrace_scalars",
3464 .lname = "Percentage to scale each trace",
3465 .type = FIO_OPT_FLOAT_LIST,
3466 .off1 = offsetof(struct thread_options, merge_blktrace_scalars),
3467 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3468 .help = "Percentage to scale each trace",
3469 .category = FIO_OPT_C_IO,
3470 .group = FIO_OPT_G_IOLOG,
3471 },
3472 {
3473 .name = "merge_blktrace_iters",
3474 .lname = "Number of iterations to run per trace",
3475 .type = FIO_OPT_FLOAT_LIST,
3476 .off1 = offsetof(struct thread_options, merge_blktrace_iters),
3477 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3478 .help = "Number of iterations to run per trace",
3479 .category = FIO_OPT_C_IO,
3480 .group = FIO_OPT_G_IOLOG,
3481 },
3482 {
3483 .name = "exec_prerun",
3484 .lname = "Pre-execute runnable",
3485 .type = FIO_OPT_STR_STORE,
3486 .off1 = offsetof(struct thread_options, exec_prerun),
3487 .help = "Execute this file prior to running job",
3488 .category = FIO_OPT_C_GENERAL,
3489 .group = FIO_OPT_G_INVALID,
3490 },
3491 {
3492 .name = "exec_postrun",
3493 .lname = "Post-execute runnable",
3494 .type = FIO_OPT_STR_STORE,
3495 .off1 = offsetof(struct thread_options, exec_postrun),
3496 .help = "Execute this file after running job",
3497 .category = FIO_OPT_C_GENERAL,
3498 .group = FIO_OPT_G_INVALID,
3499 },
3500#ifdef FIO_HAVE_IOSCHED_SWITCH
3501 {
3502 .name = "ioscheduler",
3503 .lname = "I/O scheduler",
3504 .type = FIO_OPT_STR_STORE,
3505 .off1 = offsetof(struct thread_options, ioscheduler),
3506 .help = "Use this IO scheduler on the backing device",
3507 .category = FIO_OPT_C_FILE,
3508 .group = FIO_OPT_G_INVALID,
3509 },
3510#else
3511 {
3512 .name = "ioscheduler",
3513 .lname = "I/O scheduler",
3514 .type = FIO_OPT_UNSUPPORTED,
3515 .help = "Your platform does not support IO scheduler switching",
3516 },
3517#endif
3518 {
3519 .name = "zonemode",
3520 .lname = "Zone mode",
3521 .help = "Mode for the zonesize, zonerange and zoneskip parameters",
3522 .type = FIO_OPT_STR,
3523 .off1 = offsetof(struct thread_options, zone_mode),
3524 .def = "none",
3525 .category = FIO_OPT_C_IO,
3526 .group = FIO_OPT_G_ZONE,
3527 .posval = {
3528 { .ival = "none",
3529 .oval = ZONE_MODE_NONE,
3530 .help = "no zoning",
3531 },
3532 { .ival = "strided",
3533 .oval = ZONE_MODE_STRIDED,
3534 .help = "strided mode - random I/O is restricted to a single zone",
3535 },
3536 { .ival = "zbd",
3537 .oval = ZONE_MODE_ZBD,
3538 .help = "zoned block device mode - random I/O selects one of multiple zones randomly",
3539 },
3540 },
3541 },
3542 {
3543 .name = "zonesize",
3544 .lname = "Zone size",
3545 .type = FIO_OPT_STR_VAL,
3546 .off1 = offsetof(struct thread_options, zone_size),
3547 .help = "Amount of data to read per zone",
3548 .def = "0",
3549 .interval = 1024 * 1024,
3550 .category = FIO_OPT_C_IO,
3551 .group = FIO_OPT_G_ZONE,
3552 },
3553 {
3554 .name = "zonecapacity",
3555 .lname = "Zone capacity",
3556 .type = FIO_OPT_STR_VAL,
3557 .off1 = offsetof(struct thread_options, zone_capacity),
3558 .help = "Capacity per zone",
3559 .def = "0",
3560 .interval = 1024 * 1024,
3561 .category = FIO_OPT_C_IO,
3562 .group = FIO_OPT_G_ZONE,
3563 },
3564 {
3565 .name = "zonerange",
3566 .lname = "Zone range",
3567 .type = FIO_OPT_STR_VAL,
3568 .off1 = offsetof(struct thread_options, zone_range),
3569 .help = "Give size of an IO zone",
3570 .def = "0",
3571 .interval = 1024 * 1024,
3572 .category = FIO_OPT_C_IO,
3573 .group = FIO_OPT_G_ZONE,
3574 },
3575 {
3576 .name = "zoneskip",
3577 .lname = "Zone skip",
3578 .type = FIO_OPT_STR_VAL_ZONE,
3579 .cb = str_zoneskip_cb,
3580 .off1 = offsetof(struct thread_options, zone_skip),
3581 .help = "Space between IO zones",
3582 .def = "0",
3583 .category = FIO_OPT_C_IO,
3584 .group = FIO_OPT_G_ZONE,
3585 },
3586 {
3587 .name = "read_beyond_wp",
3588 .lname = "Allow reads beyond the zone write pointer",
3589 .type = FIO_OPT_BOOL,
3590 .off1 = offsetof(struct thread_options, read_beyond_wp),
3591 .help = "Allow reads beyond the zone write pointer",
3592 .def = "0",
3593 .category = FIO_OPT_C_IO,
3594 .group = FIO_OPT_G_INVALID,
3595 },
3596 {
3597 .name = "max_open_zones",
3598 .lname = "Per device/file maximum number of open zones",
3599 .type = FIO_OPT_INT,
3600 .off1 = offsetof(struct thread_options, max_open_zones),
3601 .maxval = ZBD_MAX_OPEN_ZONES,
3602 .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd",
3603 .def = "0",
3604 .category = FIO_OPT_C_IO,
3605 .group = FIO_OPT_G_INVALID,
3606 },
3607 {
3608 .name = "job_max_open_zones",
3609 .lname = "Job maximum number of open zones",
3610 .type = FIO_OPT_INT,
3611 .off1 = offsetof(struct thread_options, job_max_open_zones),
3612 .maxval = ZBD_MAX_OPEN_ZONES,
3613 .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd by one thread/process",
3614 .def = "0",
3615 .category = FIO_OPT_C_IO,
3616 .group = FIO_OPT_G_INVALID,
3617 },
3618 {
3619 .name = "ignore_zone_limits",
3620 .lname = "Ignore zone resource limits",
3621 .type = FIO_OPT_BOOL,
3622 .off1 = offsetof(struct thread_options, ignore_zone_limits),
3623 .def = "0",
3624 .help = "Ignore the zone resource limits (max open/active zones) reported by the device",
3625 .category = FIO_OPT_C_IO,
3626 .group = FIO_OPT_G_INVALID,
3627 },
3628 {
3629 .name = "zone_reset_threshold",
3630 .lname = "Zone reset threshold",
3631 .help = "Zoned block device reset threshold",
3632 .type = FIO_OPT_FLOAT_LIST,
3633 .maxlen = 1,
3634 .off1 = offsetof(struct thread_options, zrt),
3635 .minfp = 0,
3636 .maxfp = 1,
3637 .category = FIO_OPT_C_IO,
3638 .group = FIO_OPT_G_ZONE,
3639 },
3640 {
3641 .name = "zone_reset_frequency",
3642 .lname = "Zone reset frequency",
3643 .help = "Zoned block device zone reset frequency in HZ",
3644 .type = FIO_OPT_FLOAT_LIST,
3645 .maxlen = 1,
3646 .off1 = offsetof(struct thread_options, zrf),
3647 .minfp = 0,
3648 .maxfp = 1,
3649 .category = FIO_OPT_C_IO,
3650 .group = FIO_OPT_G_ZONE,
3651 },
3652 {
3653 .name = "lockmem",
3654 .lname = "Lock memory",
3655 .type = FIO_OPT_STR_VAL,
3656 .off1 = offsetof(struct thread_options, lockmem),
3657 .help = "Lock down this amount of memory (per worker)",
3658 .def = "0",
3659 .interval = 1024 * 1024,
3660 .category = FIO_OPT_C_GENERAL,
3661 .group = FIO_OPT_G_INVALID,
3662 },
3663 {
3664 .name = "rwmixread",
3665 .lname = "Read/write mix read",
3666 .type = FIO_OPT_INT,
3667 .cb = str_rwmix_read_cb,
3668 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3669 .maxval = 100,
3670 .help = "Percentage of mixed workload that is reads",
3671 .def = "50",
3672 .interval = 5,
3673 .inverse = "rwmixwrite",
3674 .category = FIO_OPT_C_IO,
3675 .group = FIO_OPT_G_RWMIX,
3676 },
3677 {
3678 .name = "rwmixwrite",
3679 .lname = "Read/write mix write",
3680 .type = FIO_OPT_INT,
3681 .cb = str_rwmix_write_cb,
3682 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3683 .maxval = 100,
3684 .help = "Percentage of mixed workload that is writes",
3685 .def = "50",
3686 .interval = 5,
3687 .inverse = "rwmixread",
3688 .category = FIO_OPT_C_IO,
3689 .group = FIO_OPT_G_RWMIX,
3690 },
3691 {
3692 .name = "rwmixcycle",
3693 .lname = "Read/write mix cycle",
3694 .type = FIO_OPT_DEPRECATED,
3695 .category = FIO_OPT_C_IO,
3696 .group = FIO_OPT_G_RWMIX,
3697 },
3698 {
3699 .name = "nice",
3700 .lname = "Nice",
3701 .type = FIO_OPT_INT,
3702 .off1 = offsetof(struct thread_options, nice),
3703 .help = "Set job CPU nice value",
3704 .minval = -20,
3705 .maxval = 19,
3706 .def = "0",
3707 .interval = 1,
3708 .category = FIO_OPT_C_GENERAL,
3709 .group = FIO_OPT_G_CRED,
3710 },
3711#ifdef FIO_HAVE_IOPRIO
3712 {
3713 .name = "prio",
3714 .lname = "I/O nice priority",
3715 .type = FIO_OPT_INT,
3716 .off1 = offsetof(struct thread_options, ioprio),
3717 .help = "Set job IO priority value",
3718 .minval = IOPRIO_MIN_PRIO,
3719 .maxval = IOPRIO_MAX_PRIO,
3720 .interval = 1,
3721 .category = FIO_OPT_C_GENERAL,
3722 .group = FIO_OPT_G_CRED,
3723 },
3724#else
3725 {
3726 .name = "prio",
3727 .lname = "I/O nice priority",
3728 .type = FIO_OPT_UNSUPPORTED,
3729 .help = "Your platform does not support IO priorities",
3730 },
3731#endif
3732#ifdef FIO_HAVE_IOPRIO_CLASS
3733#ifndef FIO_HAVE_IOPRIO
3734#error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3735#endif
3736 {
3737 .name = "prioclass",
3738 .lname = "I/O nice priority class",
3739 .type = FIO_OPT_INT,
3740 .off1 = offsetof(struct thread_options, ioprio_class),
3741 .help = "Set job IO priority class",
3742 .minval = IOPRIO_MIN_PRIO_CLASS,
3743 .maxval = IOPRIO_MAX_PRIO_CLASS,
3744 .interval = 1,
3745 .category = FIO_OPT_C_GENERAL,
3746 .group = FIO_OPT_G_CRED,
3747 },
3748#else
3749 {
3750 .name = "prioclass",
3751 .lname = "I/O nice priority class",
3752 .type = FIO_OPT_UNSUPPORTED,
3753 .help = "Your platform does not support IO priority classes",
3754 },
3755#endif
3756 {
3757 .name = "thinktime",
3758 .lname = "Thinktime",
3759 .type = FIO_OPT_INT,
3760 .off1 = offsetof(struct thread_options, thinktime),
3761 .help = "Idle time between IO buffers (usec)",
3762 .def = "0",
3763 .is_time = 1,
3764 .category = FIO_OPT_C_IO,
3765 .group = FIO_OPT_G_THINKTIME,
3766 },
3767 {
3768 .name = "thinktime_spin",
3769 .lname = "Thinktime spin",
3770 .type = FIO_OPT_INT,
3771 .off1 = offsetof(struct thread_options, thinktime_spin),
3772 .help = "Start think time by spinning this amount (usec)",
3773 .def = "0",
3774 .is_time = 1,
3775 .parent = "thinktime",
3776 .hide = 1,
3777 .category = FIO_OPT_C_IO,
3778 .group = FIO_OPT_G_THINKTIME,
3779 },
3780 {
3781 .name = "thinktime_blocks",
3782 .lname = "Thinktime blocks",
3783 .type = FIO_OPT_INT,
3784 .off1 = offsetof(struct thread_options, thinktime_blocks),
3785 .help = "IO buffer period between 'thinktime'",
3786 .def = "1",
3787 .parent = "thinktime",
3788 .hide = 1,
3789 .category = FIO_OPT_C_IO,
3790 .group = FIO_OPT_G_THINKTIME,
3791 },
3792 {
3793 .name = "thinktime_blocks_type",
3794 .lname = "Thinktime blocks type",
3795 .type = FIO_OPT_STR,
3796 .off1 = offsetof(struct thread_options, thinktime_blocks_type),
3797 .help = "How thinktime_blocks takes effect",
3798 .def = "complete",
3799 .category = FIO_OPT_C_IO,
3800 .group = FIO_OPT_G_THINKTIME,
3801 .posval = {
3802 { .ival = "complete",
3803 .oval = THINKTIME_BLOCKS_TYPE_COMPLETE,
3804 .help = "thinktime_blocks takes effect at the completion side",
3805 },
3806 {
3807 .ival = "issue",
3808 .oval = THINKTIME_BLOCKS_TYPE_ISSUE,
3809 .help = "thinktime_blocks takes effect at the issue side",
3810 },
3811 },
3812 .parent = "thinktime",
3813 },
3814 {
3815 .name = "thinktime_iotime",
3816 .lname = "Thinktime interval",
3817 .type = FIO_OPT_INT,
3818 .off1 = offsetof(struct thread_options, thinktime_iotime),
3819 .help = "IO time interval between 'thinktime'",
3820 .def = "0",
3821 .parent = "thinktime",
3822 .hide = 1,
3823 .is_seconds = 1,
3824 .is_time = 1,
3825 .category = FIO_OPT_C_IO,
3826 .group = FIO_OPT_G_THINKTIME,
3827 },
3828 {
3829 .name = "rate",
3830 .lname = "I/O rate",
3831 .type = FIO_OPT_ULL,
3832 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3833 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3834 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3835 .help = "Set bandwidth rate",
3836 .category = FIO_OPT_C_IO,
3837 .group = FIO_OPT_G_RATE,
3838 },
3839 {
3840 .name = "rate_min",
3841 .alias = "ratemin",
3842 .lname = "I/O min rate",
3843 .type = FIO_OPT_ULL,
3844 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3845 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3846 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3847 .help = "Job must meet this rate or it will be shutdown",
3848 .parent = "rate",
3849 .hide = 1,
3850 .category = FIO_OPT_C_IO,
3851 .group = FIO_OPT_G_RATE,
3852 },
3853 {
3854 .name = "rate_iops",
3855 .lname = "I/O rate IOPS",
3856 .type = FIO_OPT_INT,
3857 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3858 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3859 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3860 .help = "Limit IO used to this number of IO operations/sec",
3861 .hide = 1,
3862 .category = FIO_OPT_C_IO,
3863 .group = FIO_OPT_G_RATE,
3864 },
3865 {
3866 .name = "rate_iops_min",
3867 .lname = "I/O min rate IOPS",
3868 .type = FIO_OPT_INT,
3869 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3870 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3871 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3872 .help = "Job must meet this rate or it will be shut down",
3873 .parent = "rate_iops",
3874 .hide = 1,
3875 .category = FIO_OPT_C_IO,
3876 .group = FIO_OPT_G_RATE,
3877 },
3878 {
3879 .name = "rate_process",
3880 .lname = "Rate Process",
3881 .type = FIO_OPT_STR,
3882 .off1 = offsetof(struct thread_options, rate_process),
3883 .help = "What process controls how rated IO is managed",
3884 .def = "linear",
3885 .category = FIO_OPT_C_IO,
3886 .group = FIO_OPT_G_RATE,
3887 .posval = {
3888 { .ival = "linear",
3889 .oval = RATE_PROCESS_LINEAR,
3890 .help = "Linear rate of IO",
3891 },
3892 {
3893 .ival = "poisson",
3894 .oval = RATE_PROCESS_POISSON,
3895 .help = "Rate follows Poisson process",
3896 },
3897 },
3898 .parent = "rate",
3899 },
3900 {
3901 .name = "rate_cycle",
3902 .alias = "ratecycle",
3903 .lname = "I/O rate cycle",
3904 .type = FIO_OPT_INT,
3905 .off1 = offsetof(struct thread_options, ratecycle),
3906 .help = "Window average for rate limits (msec)",
3907 .def = "1000",
3908 .parent = "rate",
3909 .hide = 1,
3910 .category = FIO_OPT_C_IO,
3911 .group = FIO_OPT_G_RATE,
3912 },
3913 {
3914 .name = "rate_ignore_thinktime",
3915 .lname = "Rate ignore thinktime",
3916 .type = FIO_OPT_BOOL,
3917 .off1 = offsetof(struct thread_options, rate_ign_think),
3918 .help = "Rated IO ignores thinktime settings",
3919 .parent = "rate",
3920 .category = FIO_OPT_C_IO,
3921 .group = FIO_OPT_G_RATE,
3922 },
3923 {
3924 .name = "max_latency",
3925 .lname = "Max Latency (usec)",
3926 .type = FIO_OPT_ULL,
3927 .off1 = offsetof(struct thread_options, max_latency[DDIR_READ]),
3928 .off2 = offsetof(struct thread_options, max_latency[DDIR_WRITE]),
3929 .off3 = offsetof(struct thread_options, max_latency[DDIR_TRIM]),
3930 .help = "Maximum tolerated IO latency (usec)",
3931 .is_time = 1,
3932 .category = FIO_OPT_C_IO,
3933 .group = FIO_OPT_G_LATPROF,
3934 },
3935 {
3936 .name = "latency_target",
3937 .lname = "Latency Target (usec)",
3938 .type = FIO_OPT_STR_VAL_TIME,
3939 .off1 = offsetof(struct thread_options, latency_target),
3940 .help = "Ramp to max queue depth supporting this latency",
3941 .is_time = 1,
3942 .category = FIO_OPT_C_IO,
3943 .group = FIO_OPT_G_LATPROF,
3944 },
3945 {
3946 .name = "latency_window",
3947 .lname = "Latency Window (usec)",
3948 .type = FIO_OPT_STR_VAL_TIME,
3949 .off1 = offsetof(struct thread_options, latency_window),
3950 .help = "Time to sustain latency_target",
3951 .is_time = 1,
3952 .category = FIO_OPT_C_IO,
3953 .group = FIO_OPT_G_LATPROF,
3954 },
3955 {
3956 .name = "latency_percentile",
3957 .lname = "Latency Percentile",
3958 .type = FIO_OPT_FLOAT_LIST,
3959 .off1 = offsetof(struct thread_options, latency_percentile),
3960 .help = "Percentile of IOs must be below latency_target",
3961 .def = "100",
3962 .maxlen = 1,
3963 .minfp = 0.0,
3964 .maxfp = 100.0,
3965 .category = FIO_OPT_C_IO,
3966 .group = FIO_OPT_G_LATPROF,
3967 },
3968 {
3969 .name = "latency_run",
3970 .lname = "Latency Run",
3971 .type = FIO_OPT_BOOL,
3972 .off1 = offsetof(struct thread_options, latency_run),
3973 .help = "Keep adjusting queue depth to match latency_target",
3974 .def = "0",
3975 .category = FIO_OPT_C_IO,
3976 .group = FIO_OPT_G_LATPROF,
3977 },
3978 {
3979 .name = "invalidate",
3980 .lname = "Cache invalidate",
3981 .type = FIO_OPT_BOOL,
3982 .off1 = offsetof(struct thread_options, invalidate_cache),
3983 .help = "Invalidate buffer/page cache prior to running job",
3984 .def = "1",
3985 .category = FIO_OPT_C_IO,
3986 .group = FIO_OPT_G_IO_TYPE,
3987 },
3988 {
3989 .name = "sync",
3990 .lname = "Synchronous I/O",
3991 .type = FIO_OPT_STR,
3992 .off1 = offsetof(struct thread_options, sync_io),
3993 .help = "Use synchronous write IO",
3994 .def = "none",
3995 .hide = 1,
3996 .category = FIO_OPT_C_IO,
3997 .group = FIO_OPT_G_IO_TYPE,
3998 .posval = {
3999 { .ival = "none",
4000 .oval = 0,
4001 },
4002 { .ival = "0",
4003 .oval = 0,
4004 },
4005 { .ival = "sync",
4006 .oval = O_SYNC,
4007 },
4008 { .ival = "1",
4009 .oval = O_SYNC,
4010 },
4011#ifdef O_DSYNC
4012 { .ival = "dsync",
4013 .oval = O_DSYNC,
4014 },
4015#endif
4016 },
4017 },
4018#ifdef FIO_HAVE_WRITE_HINT
4019 {
4020 .name = "write_hint",
4021 .lname = "Write hint",
4022 .type = FIO_OPT_STR,
4023 .off1 = offsetof(struct thread_options, write_hint),
4024 .help = "Set expected write life time",
4025 .category = FIO_OPT_C_ENGINE,
4026 .group = FIO_OPT_G_INVALID,
4027 .posval = {
4028 { .ival = "none",
4029 .oval = RWH_WRITE_LIFE_NONE,
4030 },
4031 { .ival = "short",
4032 .oval = RWH_WRITE_LIFE_SHORT,
4033 },
4034 { .ival = "medium",
4035 .oval = RWH_WRITE_LIFE_MEDIUM,
4036 },
4037 { .ival = "long",
4038 .oval = RWH_WRITE_LIFE_LONG,
4039 },
4040 { .ival = "extreme",
4041 .oval = RWH_WRITE_LIFE_EXTREME,
4042 },
4043 },
4044 },
4045#endif
4046 {
4047 .name = "create_serialize",
4048 .lname = "Create serialize",
4049 .type = FIO_OPT_BOOL,
4050 .off1 = offsetof(struct thread_options, create_serialize),
4051 .help = "Serialize creation of job files",
4052 .def = "1",
4053 .category = FIO_OPT_C_FILE,
4054 .group = FIO_OPT_G_INVALID,
4055 },
4056 {
4057 .name = "create_fsync",
4058 .lname = "Create fsync",
4059 .type = FIO_OPT_BOOL,
4060 .off1 = offsetof(struct thread_options, create_fsync),
4061 .help = "fsync file after creation",
4062 .def = "1",
4063 .category = FIO_OPT_C_FILE,
4064 .group = FIO_OPT_G_INVALID,
4065 },
4066 {
4067 .name = "create_on_open",
4068 .lname = "Create on open",
4069 .type = FIO_OPT_BOOL,
4070 .off1 = offsetof(struct thread_options, create_on_open),
4071 .help = "Create files when they are opened for IO",
4072 .def = "0",
4073 .category = FIO_OPT_C_FILE,
4074 .group = FIO_OPT_G_INVALID,
4075 },
4076 {
4077 .name = "create_only",
4078 .lname = "Create Only",
4079 .type = FIO_OPT_BOOL,
4080 .off1 = offsetof(struct thread_options, create_only),
4081 .help = "Only perform file creation phase",
4082 .category = FIO_OPT_C_FILE,
4083 .def = "0",
4084 },
4085 {
4086 .name = "allow_file_create",
4087 .lname = "Allow file create",
4088 .type = FIO_OPT_BOOL,
4089 .off1 = offsetof(struct thread_options, allow_create),
4090 .help = "Permit fio to create files, if they don't exist",
4091 .def = "1",
4092 .category = FIO_OPT_C_FILE,
4093 .group = FIO_OPT_G_FILENAME,
4094 },
4095 {
4096 .name = "allow_mounted_write",
4097 .lname = "Allow mounted write",
4098 .type = FIO_OPT_BOOL,
4099 .off1 = offsetof(struct thread_options, allow_mounted_write),
4100 .help = "Allow writes to a mounted partition",
4101 .def = "0",
4102 .category = FIO_OPT_C_FILE,
4103 .group = FIO_OPT_G_FILENAME,
4104 },
4105 {
4106 .name = "pre_read",
4107 .lname = "Pre-read files",
4108 .type = FIO_OPT_BOOL,
4109 .off1 = offsetof(struct thread_options, pre_read),
4110 .help = "Pre-read files before starting official testing",
4111 .def = "0",
4112 .category = FIO_OPT_C_FILE,
4113 .group = FIO_OPT_G_INVALID,
4114 },
4115#ifdef FIO_HAVE_CPU_AFFINITY
4116 {
4117 .name = "cpumask",
4118 .lname = "CPU mask",
4119 .type = FIO_OPT_INT,
4120 .cb = str_cpumask_cb,
4121 .off1 = offsetof(struct thread_options, cpumask),
4122 .help = "CPU affinity mask",
4123 .category = FIO_OPT_C_GENERAL,
4124 .group = FIO_OPT_G_CRED,
4125 },
4126 {
4127 .name = "cpus_allowed",
4128 .lname = "CPUs allowed",
4129 .type = FIO_OPT_STR,
4130 .cb = str_cpus_allowed_cb,
4131 .off1 = offsetof(struct thread_options, cpumask),
4132 .help = "Set CPUs allowed",
4133 .category = FIO_OPT_C_GENERAL,
4134 .group = FIO_OPT_G_CRED,
4135 },
4136 {
4137 .name = "cpus_allowed_policy",
4138 .lname = "CPUs allowed distribution policy",
4139 .type = FIO_OPT_STR,
4140 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
4141 .help = "Distribution policy for cpus_allowed",
4142 .parent = "cpus_allowed",
4143 .prio = 1,
4144 .posval = {
4145 { .ival = "shared",
4146 .oval = FIO_CPUS_SHARED,
4147 .help = "Mask shared between threads",
4148 },
4149 { .ival = "split",
4150 .oval = FIO_CPUS_SPLIT,
4151 .help = "Mask split between threads",
4152 },
4153 },
4154 .category = FIO_OPT_C_GENERAL,
4155 .group = FIO_OPT_G_CRED,
4156 },
4157#else
4158 {
4159 .name = "cpumask",
4160 .lname = "CPU mask",
4161 .type = FIO_OPT_UNSUPPORTED,
4162 .help = "Your platform does not support CPU affinities",
4163 },
4164 {
4165 .name = "cpus_allowed",
4166 .lname = "CPUs allowed",
4167 .type = FIO_OPT_UNSUPPORTED,
4168 .help = "Your platform does not support CPU affinities",
4169 },
4170 {
4171 .name = "cpus_allowed_policy",
4172 .lname = "CPUs allowed distribution policy",
4173 .type = FIO_OPT_UNSUPPORTED,
4174 .help = "Your platform does not support CPU affinities",
4175 },
4176#endif
4177#ifdef CONFIG_LIBNUMA
4178 {
4179 .name = "numa_cpu_nodes",
4180 .lname = "NUMA CPU Nodes",
4181 .type = FIO_OPT_STR,
4182 .cb = str_numa_cpunodes_cb,
4183 .off1 = offsetof(struct thread_options, numa_cpunodes),
4184 .help = "NUMA CPU nodes bind",
4185 .category = FIO_OPT_C_GENERAL,
4186 .group = FIO_OPT_G_INVALID,
4187 },
4188 {
4189 .name = "numa_mem_policy",
4190 .lname = "NUMA Memory Policy",
4191 .type = FIO_OPT_STR,
4192 .cb = str_numa_mpol_cb,
4193 .off1 = offsetof(struct thread_options, numa_memnodes),
4194 .help = "NUMA memory policy setup",
4195 .category = FIO_OPT_C_GENERAL,
4196 .group = FIO_OPT_G_INVALID,
4197 },
4198#else
4199 {
4200 .name = "numa_cpu_nodes",
4201 .lname = "NUMA CPU Nodes",
4202 .type = FIO_OPT_UNSUPPORTED,
4203 .help = "Build fio with libnuma-dev(el) to enable this option",
4204 },
4205 {
4206 .name = "numa_mem_policy",
4207 .lname = "NUMA Memory Policy",
4208 .type = FIO_OPT_UNSUPPORTED,
4209 .help = "Build fio with libnuma-dev(el) to enable this option",
4210 },
4211#endif
4212#ifdef CONFIG_CUDA
4213 {
4214 .name = "gpu_dev_id",
4215 .lname = "GPU device ID",
4216 .type = FIO_OPT_INT,
4217 .off1 = offsetof(struct thread_options, gpu_dev_id),
4218 .help = "Set GPU device ID for GPUDirect RDMA",
4219 .def = "0",
4220 .category = FIO_OPT_C_GENERAL,
4221 .group = FIO_OPT_G_INVALID,
4222 },
4223#endif
4224 {
4225 .name = "end_fsync",
4226 .lname = "End fsync",
4227 .type = FIO_OPT_BOOL,
4228 .off1 = offsetof(struct thread_options, end_fsync),
4229 .help = "Include fsync at the end of job",
4230 .def = "0",
4231 .category = FIO_OPT_C_FILE,
4232 .group = FIO_OPT_G_INVALID,
4233 },
4234 {
4235 .name = "fsync_on_close",
4236 .lname = "Fsync on close",
4237 .type = FIO_OPT_BOOL,
4238 .off1 = offsetof(struct thread_options, fsync_on_close),
4239 .help = "fsync files on close",
4240 .def = "0",
4241 .category = FIO_OPT_C_FILE,
4242 .group = FIO_OPT_G_INVALID,
4243 },
4244 {
4245 .name = "unlink",
4246 .lname = "Unlink file",
4247 .type = FIO_OPT_BOOL,
4248 .off1 = offsetof(struct thread_options, unlink),
4249 .help = "Unlink created files after job has completed",
4250 .def = "0",
4251 .category = FIO_OPT_C_FILE,
4252 .group = FIO_OPT_G_INVALID,
4253 },
4254 {
4255 .name = "unlink_each_loop",
4256 .lname = "Unlink file after each loop of a job",
4257 .type = FIO_OPT_BOOL,
4258 .off1 = offsetof(struct thread_options, unlink_each_loop),
4259 .help = "Unlink created files after each loop in a job has completed",
4260 .def = "0",
4261 .category = FIO_OPT_C_FILE,
4262 .group = FIO_OPT_G_INVALID,
4263 },
4264 {
4265 .name = "exitall",
4266 .lname = "Exit-all on terminate",
4267 .type = FIO_OPT_STR_SET,
4268 .cb = str_exitall_cb,
4269 .help = "Terminate all jobs when one exits",
4270 .category = FIO_OPT_C_GENERAL,
4271 .group = FIO_OPT_G_PROCESS,
4272 },
4273 {
4274 .name = "exit_what",
4275 .lname = "What jobs to quit on terminate",
4276 .type = FIO_OPT_STR,
4277 .off1 = offsetof(struct thread_options, exit_what),
4278 .help = "Fine-grained control for exitall",
4279 .def = "group",
4280 .category = FIO_OPT_C_GENERAL,
4281 .group = FIO_OPT_G_PROCESS,
4282 .posval = {
4283 { .ival = "group",
4284 .oval = TERMINATE_GROUP,
4285 .help = "exit_all=1 default behaviour",
4286 },
4287 { .ival = "stonewall",
4288 .oval = TERMINATE_STONEWALL,
4289 .help = "quit all currently running jobs; continue with next stonewall",
4290 },
4291 { .ival = "all",
4292 .oval = TERMINATE_ALL,
4293 .help = "Quit everything",
4294 },
4295 },
4296 },
4297 {
4298 .name = "exitall_on_error",
4299 .lname = "Exit-all on terminate in error",
4300 .type = FIO_OPT_STR_SET,
4301 .off1 = offsetof(struct thread_options, exitall_error),
4302 .help = "Terminate all jobs when one exits in error",
4303 .category = FIO_OPT_C_GENERAL,
4304 .group = FIO_OPT_G_PROCESS,
4305 },
4306 {
4307 .name = "stonewall",
4308 .lname = "Wait for previous",
4309 .alias = "wait_for_previous",
4310 .type = FIO_OPT_STR_SET,
4311 .off1 = offsetof(struct thread_options, stonewall),
4312 .help = "Insert a hard barrier between this job and previous",
4313 .category = FIO_OPT_C_GENERAL,
4314 .group = FIO_OPT_G_PROCESS,
4315 },
4316 {
4317 .name = "new_group",
4318 .lname = "New group",
4319 .type = FIO_OPT_STR_SET,
4320 .off1 = offsetof(struct thread_options, new_group),
4321 .help = "Mark the start of a new group (for reporting)",
4322 .category = FIO_OPT_C_GENERAL,
4323 .group = FIO_OPT_G_PROCESS,
4324 },
4325 {
4326 .name = "thread",
4327 .lname = "Thread",
4328 .type = FIO_OPT_STR_SET,
4329 .off1 = offsetof(struct thread_options, use_thread),
4330 .help = "Use threads instead of processes",
4331#ifdef CONFIG_NO_SHM
4332 .def = "1",
4333 .no_warn_def = 1,
4334#endif
4335 .category = FIO_OPT_C_GENERAL,
4336 .group = FIO_OPT_G_PROCESS,
4337 },
4338 {
4339 .name = "per_job_logs",
4340 .lname = "Per Job Logs",
4341 .type = FIO_OPT_BOOL,
4342 .off1 = offsetof(struct thread_options, per_job_logs),
4343 .help = "Include job number in generated log files or not",
4344 .def = "1",
4345 .category = FIO_OPT_C_LOG,
4346 .group = FIO_OPT_G_INVALID,
4347 },
4348 {
4349 .name = "write_bw_log",
4350 .lname = "Write bandwidth log",
4351 .type = FIO_OPT_STR,
4352 .off1 = offsetof(struct thread_options, bw_log_file),
4353 .cb = str_write_bw_log_cb,
4354 .help = "Write log of bandwidth during run",
4355 .category = FIO_OPT_C_LOG,
4356 .group = FIO_OPT_G_INVALID,
4357 },
4358 {
4359 .name = "write_lat_log",
4360 .lname = "Write latency log",
4361 .type = FIO_OPT_STR,
4362 .off1 = offsetof(struct thread_options, lat_log_file),
4363 .cb = str_write_lat_log_cb,
4364 .help = "Write log of latency during run",
4365 .category = FIO_OPT_C_LOG,
4366 .group = FIO_OPT_G_INVALID,
4367 },
4368 {
4369 .name = "write_iops_log",
4370 .lname = "Write IOPS log",
4371 .type = FIO_OPT_STR,
4372 .off1 = offsetof(struct thread_options, iops_log_file),
4373 .cb = str_write_iops_log_cb,
4374 .help = "Write log of IOPS during run",
4375 .category = FIO_OPT_C_LOG,
4376 .group = FIO_OPT_G_INVALID,
4377 },
4378 {
4379 .name = "log_entries",
4380 .lname = "Log entries",
4381 .type = FIO_OPT_INT,
4382 .off1 = offsetof(struct thread_options, log_entries),
4383 .help = "Initial number of entries in a job IO log",
4384 .def = __fio_stringify(DEF_LOG_ENTRIES),
4385 .minval = DEF_LOG_ENTRIES,
4386 .maxval = MAX_LOG_ENTRIES,
4387 .category = FIO_OPT_C_LOG,
4388 .group = FIO_OPT_G_INVALID,
4389 },
4390 {
4391 .name = "log_avg_msec",
4392 .lname = "Log averaging (msec)",
4393 .type = FIO_OPT_INT,
4394 .off1 = offsetof(struct thread_options, log_avg_msec),
4395 .help = "Average bw/iops/lat logs over this period of time",
4396 .def = "0",
4397 .category = FIO_OPT_C_LOG,
4398 .group = FIO_OPT_G_INVALID,
4399 },
4400 {
4401 .name = "log_hist_msec",
4402 .lname = "Log histograms (msec)",
4403 .type = FIO_OPT_INT,
4404 .off1 = offsetof(struct thread_options, log_hist_msec),
4405 .help = "Dump completion latency histograms at frequency of this time value",
4406 .def = "0",
4407 .category = FIO_OPT_C_LOG,
4408 .group = FIO_OPT_G_INVALID,
4409 },
4410 {
4411 .name = "log_hist_coarseness",
4412 .lname = "Histogram logs coarseness",
4413 .type = FIO_OPT_INT,
4414 .off1 = offsetof(struct thread_options, log_hist_coarseness),
4415 .help = "Integer in range [0,6]. Higher coarseness outputs"
4416 " fewer histogram bins per sample. The number of bins for"
4417 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
4418 .def = "0",
4419 .category = FIO_OPT_C_LOG,
4420 .group = FIO_OPT_G_INVALID,
4421 },
4422 {
4423 .name = "write_hist_log",
4424 .lname = "Write latency histogram logs",
4425 .type = FIO_OPT_STR,
4426 .off1 = offsetof(struct thread_options, hist_log_file),
4427 .cb = str_write_hist_log_cb,
4428 .help = "Write log of latency histograms during run",
4429 .category = FIO_OPT_C_LOG,
4430 .group = FIO_OPT_G_INVALID,
4431 },
4432 {
4433 .name = "log_max_value",
4434 .lname = "Log maximum instead of average",
4435 .type = FIO_OPT_BOOL,
4436 .off1 = offsetof(struct thread_options, log_max),
4437 .help = "Log max sample in a window instead of average",
4438 .def = "0",
4439 .category = FIO_OPT_C_LOG,
4440 .group = FIO_OPT_G_INVALID,
4441 },
4442 {
4443 .name = "log_offset",
4444 .lname = "Log offset of IO",
4445 .type = FIO_OPT_BOOL,
4446 .off1 = offsetof(struct thread_options, log_offset),
4447 .help = "Include offset of IO for each log entry",
4448 .def = "0",
4449 .category = FIO_OPT_C_LOG,
4450 .group = FIO_OPT_G_INVALID,
4451 },
4452 {
4453 .name = "log_prio",
4454 .lname = "Log priority of IO",
4455 .type = FIO_OPT_BOOL,
4456 .off1 = offsetof(struct thread_options, log_prio),
4457 .help = "Include priority value of IO for each log entry",
4458 .def = "0",
4459 .category = FIO_OPT_C_LOG,
4460 .group = FIO_OPT_G_INVALID,
4461 },
4462#ifdef CONFIG_ZLIB
4463 {
4464 .name = "log_compression",
4465 .lname = "Log compression",
4466 .type = FIO_OPT_INT,
4467 .off1 = offsetof(struct thread_options, log_gz),
4468 .help = "Log in compressed chunks of this size",
4469 .minval = 1024ULL,
4470 .maxval = 512 * 1024 * 1024ULL,
4471 .category = FIO_OPT_C_LOG,
4472 .group = FIO_OPT_G_INVALID,
4473 },
4474#ifdef FIO_HAVE_CPU_AFFINITY
4475 {
4476 .name = "log_compression_cpus",
4477 .lname = "Log Compression CPUs",
4478 .type = FIO_OPT_STR,
4479 .cb = str_log_cpus_allowed_cb,
4480 .off1 = offsetof(struct thread_options, log_gz_cpumask),
4481 .parent = "log_compression",
4482 .help = "Limit log compression to these CPUs",
4483 .category = FIO_OPT_C_LOG,
4484 .group = FIO_OPT_G_INVALID,
4485 },
4486#else
4487 {
4488 .name = "log_compression_cpus",
4489 .lname = "Log Compression CPUs",
4490 .type = FIO_OPT_UNSUPPORTED,
4491 .help = "Your platform does not support CPU affinities",
4492 },
4493#endif
4494 {
4495 .name = "log_store_compressed",
4496 .lname = "Log store compressed",
4497 .type = FIO_OPT_BOOL,
4498 .off1 = offsetof(struct thread_options, log_gz_store),
4499 .help = "Store logs in a compressed format",
4500 .category = FIO_OPT_C_LOG,
4501 .group = FIO_OPT_G_INVALID,
4502 },
4503#else
4504 {
4505 .name = "log_compression",
4506 .lname = "Log compression",
4507 .type = FIO_OPT_UNSUPPORTED,
4508 .help = "Install libz-dev(el) to get compression support",
4509 },
4510 {
4511 .name = "log_store_compressed",
4512 .lname = "Log store compressed",
4513 .type = FIO_OPT_UNSUPPORTED,
4514 .help = "Install libz-dev(el) to get compression support",
4515 },
4516#endif
4517 {
4518 .name = "log_unix_epoch",
4519 .lname = "Log epoch unix",
4520 .type = FIO_OPT_BOOL,
4521 .off1 = offsetof(struct thread_options, log_unix_epoch),
4522 .help = "Use Unix time in log files",
4523 .category = FIO_OPT_C_LOG,
4524 .group = FIO_OPT_G_INVALID,
4525 },
4526 {
4527 .name = "log_alternate_epoch",
4528 .lname = "Log epoch alternate",
4529 .type = FIO_OPT_BOOL,
4530 .off1 = offsetof(struct thread_options, log_alternate_epoch),
4531 .help = "Use alternate epoch time in log files. Uses the same epoch as that is used by clock_gettime with specified log_alternate_epoch_clock_id.",
4532 .category = FIO_OPT_C_LOG,
4533 .group = FIO_OPT_G_INVALID,
4534 },
4535 {
4536 .name = "log_alternate_epoch_clock_id",
4537 .lname = "Log alternate epoch clock_id",
4538 .type = FIO_OPT_INT,
4539 .off1 = offsetof(struct thread_options, log_alternate_epoch_clock_id),
4540 .help = "If log_alternate_epoch or log_unix_epoch is true, this option specifies the clock_id from clock_gettime whose epoch should be used. If neither of those is true, this option has no effect. Default value is 0, or CLOCK_REALTIME",
4541 .category = FIO_OPT_C_LOG,
4542 .group = FIO_OPT_G_INVALID,
4543 },
4544 {
4545 .name = "block_error_percentiles",
4546 .lname = "Block error percentiles",
4547 .type = FIO_OPT_BOOL,
4548 .off1 = offsetof(struct thread_options, block_error_hist),
4549 .help = "Record trim block errors and make a histogram",
4550 .def = "0",
4551 .category = FIO_OPT_C_LOG,
4552 .group = FIO_OPT_G_INVALID,
4553 },
4554 {
4555 .name = "bwavgtime",
4556 .lname = "Bandwidth average time",
4557 .type = FIO_OPT_INT,
4558 .off1 = offsetof(struct thread_options, bw_avg_time),
4559 .help = "Time window over which to calculate bandwidth"
4560 " (msec)",
4561 .def = "500",
4562 .parent = "write_bw_log",
4563 .hide = 1,
4564 .interval = 100,
4565 .category = FIO_OPT_C_LOG,
4566 .group = FIO_OPT_G_INVALID,
4567 },
4568 {
4569 .name = "iopsavgtime",
4570 .lname = "IOPS average time",
4571 .type = FIO_OPT_INT,
4572 .off1 = offsetof(struct thread_options, iops_avg_time),
4573 .help = "Time window over which to calculate IOPS (msec)",
4574 .def = "500",
4575 .parent = "write_iops_log",
4576 .hide = 1,
4577 .interval = 100,
4578 .category = FIO_OPT_C_LOG,
4579 .group = FIO_OPT_G_INVALID,
4580 },
4581 {
4582 .name = "group_reporting",
4583 .lname = "Group reporting",
4584 .type = FIO_OPT_STR_SET,
4585 .off1 = offsetof(struct thread_options, group_reporting),
4586 .help = "Do reporting on a per-group basis",
4587 .category = FIO_OPT_C_STAT,
4588 .group = FIO_OPT_G_INVALID,
4589 },
4590 {
4591 .name = "stats",
4592 .lname = "Stats",
4593 .type = FIO_OPT_BOOL,
4594 .off1 = offsetof(struct thread_options, stats),
4595 .help = "Enable collection of stats",
4596 .def = "1",
4597 .category = FIO_OPT_C_STAT,
4598 .group = FIO_OPT_G_INVALID,
4599 },
4600 {
4601 .name = "zero_buffers",
4602 .lname = "Zero I/O buffers",
4603 .type = FIO_OPT_STR_SET,
4604 .off1 = offsetof(struct thread_options, zero_buffers),
4605 .help = "Init IO buffers to all zeroes",
4606 .category = FIO_OPT_C_IO,
4607 .group = FIO_OPT_G_IO_BUF,
4608 },
4609 {
4610 .name = "refill_buffers",
4611 .lname = "Refill I/O buffers",
4612 .type = FIO_OPT_STR_SET,
4613 .off1 = offsetof(struct thread_options, refill_buffers),
4614 .help = "Refill IO buffers on every IO submit",
4615 .category = FIO_OPT_C_IO,
4616 .group = FIO_OPT_G_IO_BUF,
4617 },
4618 {
4619 .name = "scramble_buffers",
4620 .lname = "Scramble I/O buffers",
4621 .type = FIO_OPT_BOOL,
4622 .off1 = offsetof(struct thread_options, scramble_buffers),
4623 .help = "Slightly scramble buffers on every IO submit",
4624 .def = "1",
4625 .category = FIO_OPT_C_IO,
4626 .group = FIO_OPT_G_IO_BUF,
4627 },
4628 {
4629 .name = "buffer_pattern",
4630 .lname = "Buffer pattern",
4631 .type = FIO_OPT_STR,
4632 .cb = str_buffer_pattern_cb,
4633 .off1 = offsetof(struct thread_options, buffer_pattern),
4634 .help = "Fill pattern for IO buffers",
4635 .category = FIO_OPT_C_IO,
4636 .group = FIO_OPT_G_IO_BUF,
4637 },
4638 {
4639 .name = "buffer_compress_percentage",
4640 .lname = "Buffer compression percentage",
4641 .type = FIO_OPT_INT,
4642 .cb = str_buffer_compress_cb,
4643 .off1 = offsetof(struct thread_options, compress_percentage),
4644 .maxval = 100,
4645 .minval = 0,
4646 .help = "How compressible the buffer is (approximately)",
4647 .interval = 5,
4648 .category = FIO_OPT_C_IO,
4649 .group = FIO_OPT_G_IO_BUF,
4650 },
4651 {
4652 .name = "buffer_compress_chunk",
4653 .lname = "Buffer compression chunk size",
4654 .type = FIO_OPT_INT,
4655 .off1 = offsetof(struct thread_options, compress_chunk),
4656 .parent = "buffer_compress_percentage",
4657 .hide = 1,
4658 .help = "Size of compressible region in buffer",
4659 .def = "512",
4660 .interval = 256,
4661 .category = FIO_OPT_C_IO,
4662 .group = FIO_OPT_G_IO_BUF,
4663 },
4664 {
4665 .name = "dedupe_percentage",
4666 .lname = "Dedupe percentage",
4667 .type = FIO_OPT_INT,
4668 .cb = str_dedupe_cb,
4669 .off1 = offsetof(struct thread_options, dedupe_percentage),
4670 .maxval = 100,
4671 .minval = 0,
4672 .help = "Percentage of buffers that are dedupable",
4673 .interval = 1,
4674 .category = FIO_OPT_C_IO,
4675 .group = FIO_OPT_G_IO_BUF,
4676 },
4677 {
4678 .name = "dedupe_global",
4679 .lname = "Global deduplication",
4680 .type = FIO_OPT_BOOL,
4681 .off1 = offsetof(struct thread_options, dedupe_global),
4682 .help = "Share deduplication buffers across jobs",
4683 .def = "0",
4684 .category = FIO_OPT_C_IO,
4685 .group = FIO_OPT_G_IO_BUF,
4686 },
4687 {
4688 .name = "dedupe_mode",
4689 .lname = "Dedupe mode",
4690 .help = "Mode for the deduplication buffer generation",
4691 .type = FIO_OPT_STR,
4692 .off1 = offsetof(struct thread_options, dedupe_mode),
4693 .parent = "dedupe_percentage",
4694 .def = "repeat",
4695 .category = FIO_OPT_C_IO,
4696 .group = FIO_OPT_G_IO_BUF,
4697 .posval = {
4698 { .ival = "repeat",
4699 .oval = DEDUPE_MODE_REPEAT,
4700 .help = "repeat previous page",
4701 },
4702 { .ival = "working_set",
4703 .oval = DEDUPE_MODE_WORKING_SET,
4704 .help = "choose a page randomly from limited working set defined in dedupe_working_set_percentage",
4705 },
4706 },
4707 },
4708 {
4709 .name = "dedupe_working_set_percentage",
4710 .lname = "Dedupe working set percentage",
4711 .help = "Dedupe working set size in percentages from file or device size used to generate dedupe patterns from",
4712 .type = FIO_OPT_INT,
4713 .off1 = offsetof(struct thread_options, dedupe_working_set_percentage),
4714 .parent = "dedupe_percentage",
4715 .def = "5",
4716 .maxval = 100,
4717 .minval = 0,
4718 .category = FIO_OPT_C_IO,
4719 .group = FIO_OPT_G_IO_BUF,
4720 },
4721 {
4722 .name = "clat_percentiles",
4723 .lname = "Completion latency percentiles",
4724 .type = FIO_OPT_BOOL,
4725 .off1 = offsetof(struct thread_options, clat_percentiles),
4726 .help = "Enable the reporting of completion latency percentiles",
4727 .def = "1",
4728 .category = FIO_OPT_C_STAT,
4729 .group = FIO_OPT_G_INVALID,
4730 },
4731 {
4732 .name = "lat_percentiles",
4733 .lname = "IO latency percentiles",
4734 .type = FIO_OPT_BOOL,
4735 .off1 = offsetof(struct thread_options, lat_percentiles),
4736 .help = "Enable the reporting of IO latency percentiles",
4737 .def = "0",
4738 .category = FIO_OPT_C_STAT,
4739 .group = FIO_OPT_G_INVALID,
4740 },
4741 {
4742 .name = "slat_percentiles",
4743 .lname = "Submission latency percentiles",
4744 .type = FIO_OPT_BOOL,
4745 .off1 = offsetof(struct thread_options, slat_percentiles),
4746 .help = "Enable the reporting of submission latency percentiles",
4747 .def = "0",
4748 .category = FIO_OPT_C_STAT,
4749 .group = FIO_OPT_G_INVALID,
4750 },
4751 {
4752 .name = "percentile_list",
4753 .lname = "Percentile list",
4754 .type = FIO_OPT_FLOAT_LIST,
4755 .off1 = offsetof(struct thread_options, percentile_list),
4756 .off2 = offsetof(struct thread_options, percentile_precision),
4757 .help = "Specify a custom list of percentiles to report for "
4758 "completion latency and block errors",
4759 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
4760 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4761 .minfp = 0.0,
4762 .maxfp = 100.0,
4763 .category = FIO_OPT_C_STAT,
4764 .group = FIO_OPT_G_INVALID,
4765 },
4766 {
4767 .name = "significant_figures",
4768 .lname = "Significant figures",
4769 .type = FIO_OPT_INT,
4770 .off1 = offsetof(struct thread_options, sig_figs),
4771 .maxval = 10,
4772 .minval = 1,
4773 .help = "Significant figures for output-format set to normal",
4774 .def = "4",
4775 .interval = 1,
4776 .category = FIO_OPT_C_STAT,
4777 .group = FIO_OPT_G_INVALID,
4778 },
4779
4780#ifdef FIO_HAVE_DISK_UTIL
4781 {
4782 .name = "disk_util",
4783 .lname = "Disk utilization",
4784 .type = FIO_OPT_BOOL,
4785 .off1 = offsetof(struct thread_options, do_disk_util),
4786 .help = "Log disk utilization statistics",
4787 .def = "1",
4788 .category = FIO_OPT_C_STAT,
4789 .group = FIO_OPT_G_INVALID,
4790 },
4791#else
4792 {
4793 .name = "disk_util",
4794 .lname = "Disk utilization",
4795 .type = FIO_OPT_UNSUPPORTED,
4796 .help = "Your platform does not support disk utilization",
4797 },
4798#endif
4799 {
4800 .name = "gtod_reduce",
4801 .lname = "Reduce gettimeofday() calls",
4802 .type = FIO_OPT_BOOL,
4803 .help = "Greatly reduce number of gettimeofday() calls",
4804 .cb = str_gtod_reduce_cb,
4805 .def = "0",
4806 .hide_on_set = 1,
4807 .category = FIO_OPT_C_STAT,
4808 .group = FIO_OPT_G_INVALID,
4809 },
4810 {
4811 .name = "disable_lat",
4812 .lname = "Disable all latency stats",
4813 .type = FIO_OPT_BOOL,
4814 .off1 = offsetof(struct thread_options, disable_lat),
4815 .help = "Disable latency numbers",
4816 .parent = "gtod_reduce",
4817 .hide = 1,
4818 .def = "0",
4819 .category = FIO_OPT_C_STAT,
4820 .group = FIO_OPT_G_INVALID,
4821 },
4822 {
4823 .name = "disable_clat",
4824 .lname = "Disable completion latency stats",
4825 .type = FIO_OPT_BOOL,
4826 .off1 = offsetof(struct thread_options, disable_clat),
4827 .help = "Disable completion latency numbers",
4828 .parent = "gtod_reduce",
4829 .hide = 1,
4830 .def = "0",
4831 .category = FIO_OPT_C_STAT,
4832 .group = FIO_OPT_G_INVALID,
4833 },
4834 {
4835 .name = "disable_slat",
4836 .lname = "Disable submission latency stats",
4837 .type = FIO_OPT_BOOL,
4838 .off1 = offsetof(struct thread_options, disable_slat),
4839 .help = "Disable submission latency numbers",
4840 .parent = "gtod_reduce",
4841 .hide = 1,
4842 .def = "0",
4843 .category = FIO_OPT_C_STAT,
4844 .group = FIO_OPT_G_INVALID,
4845 },
4846 {
4847 .name = "disable_bw_measurement",
4848 .alias = "disable_bw",
4849 .lname = "Disable bandwidth stats",
4850 .type = FIO_OPT_BOOL,
4851 .off1 = offsetof(struct thread_options, disable_bw),
4852 .help = "Disable bandwidth logging",
4853 .parent = "gtod_reduce",
4854 .hide = 1,
4855 .def = "0",
4856 .category = FIO_OPT_C_STAT,
4857 .group = FIO_OPT_G_INVALID,
4858 },
4859 {
4860 .name = "gtod_cpu",
4861 .lname = "Dedicated gettimeofday() CPU",
4862 .type = FIO_OPT_INT,
4863 .off1 = offsetof(struct thread_options, gtod_cpu),
4864 .help = "Set up dedicated gettimeofday() thread on this CPU",
4865 .verify = gtod_cpu_verify,
4866 .category = FIO_OPT_C_GENERAL,
4867 .group = FIO_OPT_G_CLOCK,
4868 },
4869 {
4870 .name = "unified_rw_reporting",
4871 .lname = "Unified RW Reporting",
4872 .type = FIO_OPT_STR,
4873 .off1 = offsetof(struct thread_options, unified_rw_rep),
4874 .help = "Unify reporting across data direction",
4875 .def = "none",
4876 .category = FIO_OPT_C_GENERAL,
4877 .group = FIO_OPT_G_INVALID,
4878 .posval = {
4879 { .ival = "none",
4880 .oval = UNIFIED_SPLIT,
4881 .help = "Normal statistics reporting",
4882 },
4883 { .ival = "mixed",
4884 .oval = UNIFIED_MIXED,
4885 .help = "Statistics are summed per data direction and reported together",
4886 },
4887 { .ival = "both",
4888 .oval = UNIFIED_BOTH,
4889 .help = "Statistics are reported normally, followed by the mixed statistics"
4890 },
4891 /* Compatibility with former boolean values */
4892 { .ival = "0",
4893 .oval = UNIFIED_SPLIT,
4894 .help = "Alias for 'none'",
4895 },
4896 { .ival = "1",
4897 .oval = UNIFIED_MIXED,
4898 .help = "Alias for 'mixed'",
4899 },
4900 { .ival = "2",
4901 .oval = UNIFIED_BOTH,
4902 .help = "Alias for 'both'",
4903 },
4904 },
4905 },
4906 {
4907 .name = "continue_on_error",
4908 .lname = "Continue on error",
4909 .type = FIO_OPT_STR,
4910 .off1 = offsetof(struct thread_options, continue_on_error),
4911 .help = "Continue on non-fatal errors during IO",
4912 .def = "none",
4913 .category = FIO_OPT_C_GENERAL,
4914 .group = FIO_OPT_G_ERR,
4915 .posval = {
4916 { .ival = "none",
4917 .oval = ERROR_TYPE_NONE,
4918 .help = "Exit when an error is encountered",
4919 },
4920 { .ival = "read",
4921 .oval = ERROR_TYPE_READ,
4922 .help = "Continue on read errors only",
4923 },
4924 { .ival = "write",
4925 .oval = ERROR_TYPE_WRITE,
4926 .help = "Continue on write errors only",
4927 },
4928 { .ival = "io",
4929 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4930 .help = "Continue on any IO errors",
4931 },
4932 { .ival = "verify",
4933 .oval = ERROR_TYPE_VERIFY,
4934 .help = "Continue on verify errors only",
4935 },
4936 { .ival = "all",
4937 .oval = ERROR_TYPE_ANY,
4938 .help = "Continue on all io and verify errors",
4939 },
4940 { .ival = "0",
4941 .oval = ERROR_TYPE_NONE,
4942 .help = "Alias for 'none'",
4943 },
4944 { .ival = "1",
4945 .oval = ERROR_TYPE_ANY,
4946 .help = "Alias for 'all'",
4947 },
4948 },
4949 },
4950 {
4951 .name = "ignore_error",
4952 .lname = "Ignore Error",
4953 .type = FIO_OPT_STR,
4954 .cb = str_ignore_error_cb,
4955 .off1 = offsetof(struct thread_options, ignore_error_nr),
4956 .help = "Set a specific list of errors to ignore",
4957 .parent = "rw",
4958 .category = FIO_OPT_C_GENERAL,
4959 .group = FIO_OPT_G_ERR,
4960 },
4961 {
4962 .name = "error_dump",
4963 .lname = "Error Dump",
4964 .type = FIO_OPT_BOOL,
4965 .off1 = offsetof(struct thread_options, error_dump),
4966 .def = "0",
4967 .help = "Dump info on each error",
4968 .category = FIO_OPT_C_GENERAL,
4969 .group = FIO_OPT_G_ERR,
4970 },
4971 {
4972 .name = "profile",
4973 .lname = "Profile",
4974 .type = FIO_OPT_STR_STORE,
4975 .off1 = offsetof(struct thread_options, profile),
4976 .help = "Select a specific builtin performance test",
4977 .category = FIO_OPT_C_PROFILE,
4978 .group = FIO_OPT_G_INVALID,
4979 },
4980 {
4981 .name = "cgroup",
4982 .lname = "Cgroup",
4983 .type = FIO_OPT_STR_STORE,
4984 .off1 = offsetof(struct thread_options, cgroup),
4985 .help = "Add job to cgroup of this name",
4986 .category = FIO_OPT_C_GENERAL,
4987 .group = FIO_OPT_G_CGROUP,
4988 },
4989 {
4990 .name = "cgroup_nodelete",
4991 .lname = "Cgroup no-delete",
4992 .type = FIO_OPT_BOOL,
4993 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4994 .help = "Do not delete cgroups after job completion",
4995 .def = "0",
4996 .parent = "cgroup",
4997 .category = FIO_OPT_C_GENERAL,
4998 .group = FIO_OPT_G_CGROUP,
4999 },
5000 {
5001 .name = "cgroup_weight",
5002 .lname = "Cgroup weight",
5003 .type = FIO_OPT_INT,
5004 .off1 = offsetof(struct thread_options, cgroup_weight),
5005 .help = "Use given weight for cgroup",
5006 .minval = 100,
5007 .maxval = 1000,
5008 .parent = "cgroup",
5009 .category = FIO_OPT_C_GENERAL,
5010 .group = FIO_OPT_G_CGROUP,
5011 },
5012 {
5013 .name = "uid",
5014 .lname = "User ID",
5015 .type = FIO_OPT_INT,
5016 .off1 = offsetof(struct thread_options, uid),
5017 .help = "Run job with this user ID",
5018 .category = FIO_OPT_C_GENERAL,
5019 .group = FIO_OPT_G_CRED,
5020 },
5021 {
5022 .name = "gid",
5023 .lname = "Group ID",
5024 .type = FIO_OPT_INT,
5025 .off1 = offsetof(struct thread_options, gid),
5026 .help = "Run job with this group ID",
5027 .category = FIO_OPT_C_GENERAL,
5028 .group = FIO_OPT_G_CRED,
5029 },
5030 {
5031 .name = "kb_base",
5032 .lname = "KB Base",
5033 .type = FIO_OPT_STR,
5034 .off1 = offsetof(struct thread_options, kb_base),
5035 .prio = 1,
5036 .def = "1024",
5037 .posval = {
5038 { .ival = "1024",
5039 .oval = 1024,
5040 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
5041 },
5042 { .ival = "1000",
5043 .oval = 1000,
5044 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
5045 },
5046 },
5047 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
5048 .category = FIO_OPT_C_GENERAL,
5049 .group = FIO_OPT_G_INVALID,
5050 },
5051 {
5052 .name = "unit_base",
5053 .lname = "Unit for quantities of data (Bits or Bytes)",
5054 .type = FIO_OPT_STR,
5055 .off1 = offsetof(struct thread_options, unit_base),
5056 .prio = 1,
5057 .posval = {
5058 { .ival = "0",
5059 .oval = N2S_NONE,
5060 .help = "Auto-detect",
5061 },
5062 { .ival = "8",
5063 .oval = N2S_BYTEPERSEC,
5064 .help = "Normal (byte based)",
5065 },
5066 { .ival = "1",
5067 .oval = N2S_BITPERSEC,
5068 .help = "Bit based",
5069 },
5070 },
5071 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
5072 .category = FIO_OPT_C_GENERAL,
5073 .group = FIO_OPT_G_INVALID,
5074 },
5075 {
5076 .name = "hugepage-size",
5077 .lname = "Hugepage size",
5078 .type = FIO_OPT_INT,
5079 .off1 = offsetof(struct thread_options, hugepage_size),
5080 .help = "When using hugepages, specify size of each page",
5081 .def = __fio_stringify(FIO_HUGE_PAGE),
5082 .interval = 1024 * 1024,
5083 .category = FIO_OPT_C_GENERAL,
5084 .group = FIO_OPT_G_INVALID,
5085 },
5086 {
5087 .name = "flow_id",
5088 .lname = "I/O flow ID",
5089 .type = FIO_OPT_INT,
5090 .off1 = offsetof(struct thread_options, flow_id),
5091 .help = "The flow index ID to use",
5092 .def = "0",
5093 .category = FIO_OPT_C_IO,
5094 .group = FIO_OPT_G_IO_FLOW,
5095 },
5096 {
5097 .name = "flow",
5098 .lname = "I/O flow weight",
5099 .type = FIO_OPT_INT,
5100 .off1 = offsetof(struct thread_options, flow),
5101 .help = "Weight for flow control of this job",
5102 .parent = "flow_id",
5103 .hide = 1,
5104 .def = "0",
5105 .maxval = FLOW_MAX_WEIGHT,
5106 .category = FIO_OPT_C_IO,
5107 .group = FIO_OPT_G_IO_FLOW,
5108 },
5109 {
5110 .name = "flow_watermark",
5111 .lname = "I/O flow watermark",
5112 .type = FIO_OPT_SOFT_DEPRECATED,
5113 .category = FIO_OPT_C_IO,
5114 .group = FIO_OPT_G_IO_FLOW,
5115 },
5116 {
5117 .name = "flow_sleep",
5118 .lname = "I/O flow sleep",
5119 .type = FIO_OPT_INT,
5120 .off1 = offsetof(struct thread_options, flow_sleep),
5121 .help = "How many microseconds to sleep after being held"
5122 " back by the flow control mechanism",
5123 .parent = "flow_id",
5124 .hide = 1,
5125 .def = "0",
5126 .category = FIO_OPT_C_IO,
5127 .group = FIO_OPT_G_IO_FLOW,
5128 },
5129 {
5130 .name = "steadystate",
5131 .lname = "Steady state threshold",
5132 .alias = "ss",
5133 .type = FIO_OPT_STR,
5134 .off1 = offsetof(struct thread_options, ss_state),
5135 .cb = str_steadystate_cb,
5136 .help = "Define the criterion and limit to judge when a job has reached steady state",
5137 .def = "iops_slope:0.01%",
5138 .posval = {
5139 { .ival = "iops",
5140 .oval = FIO_SS_IOPS,
5141 .help = "maximum mean deviation of IOPS measurements",
5142 },
5143 { .ival = "iops_slope",
5144 .oval = FIO_SS_IOPS_SLOPE,
5145 .help = "slope calculated from IOPS measurements",
5146 },
5147 { .ival = "bw",
5148 .oval = FIO_SS_BW,
5149 .help = "maximum mean deviation of bandwidth measurements",
5150 },
5151 {
5152 .ival = "bw_slope",
5153 .oval = FIO_SS_BW_SLOPE,
5154 .help = "slope calculated from bandwidth measurements",
5155 },
5156 },
5157 .category = FIO_OPT_C_GENERAL,
5158 .group = FIO_OPT_G_RUNTIME,
5159 },
5160 {
5161 .name = "steadystate_duration",
5162 .lname = "Steady state duration",
5163 .alias = "ss_dur",
5164 .parent = "steadystate",
5165 .type = FIO_OPT_STR_VAL_TIME,
5166 .off1 = offsetof(struct thread_options, ss_dur),
5167 .help = "Stop workload upon attaining steady state for specified duration",
5168 .def = "0",
5169 .is_seconds = 1,
5170 .is_time = 1,
5171 .category = FIO_OPT_C_GENERAL,
5172 .group = FIO_OPT_G_RUNTIME,
5173 },
5174 {
5175 .name = "steadystate_ramp_time",
5176 .lname = "Steady state ramp time",
5177 .alias = "ss_ramp",
5178 .parent = "steadystate",
5179 .type = FIO_OPT_STR_VAL_TIME,
5180 .off1 = offsetof(struct thread_options, ss_ramp_time),
5181 .help = "Delay before initiation of data collection for steady state job termination testing",
5182 .def = "0",
5183 .is_seconds = 1,
5184 .is_time = 1,
5185 .category = FIO_OPT_C_GENERAL,
5186 .group = FIO_OPT_G_RUNTIME,
5187 },
5188 {
5189 .name = NULL,
5190 },
5191};
5192
5193static void add_to_lopt(struct option *lopt, struct fio_option *o,
5194 const char *name, int val)
5195{
5196 lopt->name = (char *) name;
5197 lopt->val = val;
5198 if (o->type == FIO_OPT_STR_SET)
5199 lopt->has_arg = optional_argument;
5200 else
5201 lopt->has_arg = required_argument;
5202}
5203
5204static void options_to_lopts(struct fio_option *opts,
5205 struct option *long_options,
5206 int i, int option_type)
5207{
5208 struct fio_option *o = &opts[0];
5209 while (o->name) {
5210 add_to_lopt(&long_options[i], o, o->name, option_type);
5211 if (o->alias) {
5212 i++;
5213 add_to_lopt(&long_options[i], o, o->alias, option_type);
5214 }
5215
5216 i++;
5217 o++;
5218 assert(i < FIO_NR_OPTIONS);
5219 }
5220}
5221
5222void fio_options_set_ioengine_opts(struct option *long_options,
5223 struct thread_data *td)
5224{
5225 unsigned int i;
5226
5227 i = 0;
5228 while (long_options[i].name) {
5229 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
5230 memset(&long_options[i], 0, sizeof(*long_options));
5231 break;
5232 }
5233 i++;
5234 }
5235
5236 /*
5237 * Just clear out the prior ioengine options.
5238 */
5239 if (!td || !td->eo)
5240 return;
5241
5242 options_to_lopts(td->io_ops->options, long_options, i,
5243 FIO_GETOPT_IOENGINE);
5244}
5245
5246void fio_options_dup_and_init(struct option *long_options)
5247{
5248 unsigned int i;
5249
5250 options_init(fio_options);
5251
5252 i = 0;
5253 while (long_options[i].name)
5254 i++;
5255
5256 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
5257}
5258
5259struct fio_keyword {
5260 const char *word;
5261 const char *desc;
5262 char *replace;
5263};
5264
5265static struct fio_keyword fio_keywords[] = {
5266 {
5267 .word = "$pagesize",
5268 .desc = "Page size in the system",
5269 },
5270 {
5271 .word = "$mb_memory",
5272 .desc = "Megabytes of memory online",
5273 },
5274 {
5275 .word = "$ncpus",
5276 .desc = "Number of CPUs online in the system",
5277 },
5278 {
5279 .word = NULL,
5280 },
5281};
5282
5283void fio_keywords_exit(void)
5284{
5285 struct fio_keyword *kw;
5286
5287 kw = &fio_keywords[0];
5288 while (kw->word) {
5289 free(kw->replace);
5290 kw->replace = NULL;
5291 kw++;
5292 }
5293}
5294
5295void fio_keywords_init(void)
5296{
5297 unsigned long long mb_memory;
5298 char buf[128];
5299 long l;
5300
5301 sprintf(buf, "%lu", (unsigned long) page_size);
5302 fio_keywords[0].replace = strdup(buf);
5303
5304 mb_memory = os_phys_mem() / (1024 * 1024);
5305 sprintf(buf, "%llu", mb_memory);
5306 fio_keywords[1].replace = strdup(buf);
5307
5308 l = cpus_configured();
5309 sprintf(buf, "%lu", l);
5310 fio_keywords[2].replace = strdup(buf);
5311}
5312
5313#define BC_APP "bc"
5314
5315static char *bc_calc(char *str)
5316{
5317 char buf[128], *tmp;
5318 FILE *f;
5319 int ret;
5320
5321 /*
5322 * No math, just return string
5323 */
5324 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
5325 !strchr(str, '/')) || strchr(str, '\''))
5326 return str;
5327
5328 /*
5329 * Split option from value, we only need to calculate the value
5330 */
5331 tmp = strchr(str, '=');
5332 if (!tmp)
5333 return str;
5334
5335 tmp++;
5336
5337 /*
5338 * Prevent buffer overflows; such a case isn't reasonable anyway
5339 */
5340 if (strlen(str) >= 128 || strlen(tmp) > 100)
5341 return str;
5342
5343 sprintf(buf, "which %s > /dev/null", BC_APP);
5344 if (system(buf)) {
5345 log_err("fio: bc is needed for performing math\n");
5346 return NULL;
5347 }
5348
5349 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
5350 f = popen(buf, "r");
5351 if (!f)
5352 return NULL;
5353
5354 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
5355 if (ret <= 0) {
5356 pclose(f);
5357 return NULL;
5358 }
5359
5360 pclose(f);
5361 buf[(tmp - str) + ret - 1] = '\0';
5362 memcpy(buf, str, tmp - str);
5363 free(str);
5364 return strdup(buf);
5365}
5366
5367/*
5368 * Return a copy of the input string with substrings of the form ${VARNAME}
5369 * substituted with the value of the environment variable VARNAME. The
5370 * substitution always occurs, even if VARNAME is empty or the corresponding
5371 * environment variable undefined.
5372 */
5373char *fio_option_dup_subs(const char *opt)
5374{
5375 char out[OPT_LEN_MAX+1];
5376 char in[OPT_LEN_MAX+1];
5377 char *outptr = out;
5378 char *inptr = in;
5379 char *ch1, *ch2, *env;
5380 ssize_t nchr = OPT_LEN_MAX;
5381 size_t envlen;
5382
5383 if (strlen(opt) + 1 > OPT_LEN_MAX) {
5384 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
5385 return NULL;
5386 }
5387
5388 snprintf(in, sizeof(in), "%s", opt);
5389
5390 while (*inptr && nchr > 0) {
5391 if (inptr[0] == '$' && inptr[1] == '{') {
5392 ch2 = strchr(inptr, '}');
5393 if (ch2 && inptr+1 < ch2) {
5394 ch1 = inptr+2;
5395 inptr = ch2+1;
5396 *ch2 = '\0';
5397
5398 env = getenv(ch1);
5399 if (env) {
5400 envlen = strlen(env);
5401 if (envlen <= nchr) {
5402 memcpy(outptr, env, envlen);
5403 outptr += envlen;
5404 nchr -= envlen;
5405 }
5406 }
5407
5408 continue;
5409 }
5410 }
5411
5412 *outptr++ = *inptr++;
5413 --nchr;
5414 }
5415
5416 *outptr = '\0';
5417 return strdup(out);
5418}
5419
5420/*
5421 * Look for reserved variable names and replace them with real values
5422 */
5423static char *fio_keyword_replace(char *opt)
5424{
5425 char *s;
5426 int i;
5427 int docalc = 0;
5428
5429 for (i = 0; fio_keywords[i].word != NULL; i++) {
5430 struct fio_keyword *kw = &fio_keywords[i];
5431
5432 while ((s = strstr(opt, kw->word)) != NULL) {
5433 char *new = calloc(strlen(opt) + 1, 1);
5434 char *o_org = opt;
5435 int olen = s - opt;
5436 int len;
5437
5438 /*
5439 * Copy part of the string before the keyword and
5440 * sprintf() the replacement after it.
5441 */
5442 memcpy(new, opt, olen);
5443 len = sprintf(new + olen, "%s", kw->replace);
5444
5445 /*
5446 * If there's more in the original string, copy that
5447 * in too
5448 */
5449 opt += olen + strlen(kw->word);
5450 /* keeps final zero thanks to calloc */
5451 if (strlen(opt))
5452 memcpy(new + olen + len, opt, strlen(opt));
5453
5454 /*
5455 * replace opt and free the old opt
5456 */
5457 opt = new;
5458 free(o_org);
5459
5460 docalc = 1;
5461 }
5462 }
5463
5464 /*
5465 * Check for potential math and invoke bc, if possible
5466 */
5467 if (docalc)
5468 opt = bc_calc(opt);
5469
5470 return opt;
5471}
5472
5473static char **dup_and_sub_options(char **opts, int num_opts)
5474{
5475 int i;
5476 char **opts_copy = malloc(num_opts * sizeof(*opts));
5477 for (i = 0; i < num_opts; i++) {
5478 opts_copy[i] = fio_option_dup_subs(opts[i]);
5479 if (!opts_copy[i])
5480 continue;
5481 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
5482 }
5483 return opts_copy;
5484}
5485
5486static void show_closest_option(const char *opt)
5487{
5488 int best_option, best_distance;
5489 int i, distance;
5490 char *name;
5491
5492 if (!strlen(opt))
5493 return;
5494
5495 name = strdup(opt);
5496 i = 0;
5497 while (name[i] != '\0' && name[i] != '=')
5498 i++;
5499 name[i] = '\0';
5500
5501 best_option = -1;
5502 best_distance = INT_MAX;
5503 i = 0;
5504 while (fio_options[i].name) {
5505 distance = string_distance(name, fio_options[i].name);
5506 if (distance < best_distance) {
5507 best_distance = distance;
5508 best_option = i;
5509 }
5510 i++;
5511 }
5512
5513 if (best_option != -1 && string_distance_ok(name, best_distance) &&
5514 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
5515 log_err("Did you mean %s?\n", fio_options[best_option].name);
5516
5517 free(name);
5518}
5519
5520int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
5521{
5522 int i, ret, unknown;
5523 char **opts_copy;
5524
5525 sort_options(opts, fio_options, num_opts);
5526 opts_copy = dup_and_sub_options(opts, num_opts);
5527
5528 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
5529 const struct fio_option *o;
5530 int newret = parse_option(opts_copy[i], opts[i], fio_options,
5531 &o, &td->o, &td->opt_list);
5532
5533 if (!newret && o)
5534 fio_option_mark_set(&td->o, o);
5535
5536 if (opts_copy[i]) {
5537 if (newret && !o) {
5538 unknown++;
5539 continue;
5540 }
5541 free(opts_copy[i]);
5542 opts_copy[i] = NULL;
5543 }
5544
5545 ret |= newret;
5546 }
5547
5548 if (unknown) {
5549 ret |= ioengine_load(td);
5550 if (td->eo) {
5551 sort_options(opts_copy, td->io_ops->options, num_opts);
5552 opts = opts_copy;
5553 }
5554 for (i = 0; i < num_opts; i++) {
5555 const struct fio_option *o = NULL;
5556 int newret = 1;
5557
5558 if (!opts_copy[i])
5559 continue;
5560
5561 if (td->eo)
5562 newret = parse_option(opts_copy[i], opts[i],
5563 td->io_ops->options, &o,
5564 td->eo, &td->opt_list);
5565
5566 ret |= newret;
5567 if (!o) {
5568 log_err("Bad option <%s>\n", opts[i]);
5569 show_closest_option(opts[i]);
5570 }
5571 free(opts_copy[i]);
5572 opts_copy[i] = NULL;
5573 }
5574 }
5575
5576 free(opts_copy);
5577 return ret;
5578}
5579
5580int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
5581{
5582 int ret;
5583
5584 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
5585 if (!ret) {
5586 const struct fio_option *o;
5587
5588 o = find_option_c(fio_options, opt);
5589 if (o)
5590 fio_option_mark_set(&td->o, o);
5591 }
5592
5593 return ret;
5594}
5595
5596int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
5597 char *val)
5598{
5599 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
5600 &td->opt_list);
5601}
5602
5603void fio_fill_default_options(struct thread_data *td)
5604{
5605 td->o.magic = OPT_MAGIC;
5606 fill_default_options(&td->o, fio_options);
5607}
5608
5609int fio_show_option_help(const char *opt)
5610{
5611 return show_cmd_help(fio_options, opt);
5612}
5613
5614/*
5615 * dupe FIO_OPT_STR_STORE options
5616 */
5617void fio_options_mem_dupe(struct thread_data *td)
5618{
5619 options_mem_dupe(fio_options, &td->o);
5620
5621 if (td->eo && td->io_ops) {
5622 void *oldeo = td->eo;
5623
5624 td->eo = malloc(td->io_ops->option_struct_size);
5625 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
5626 options_mem_dupe(td->io_ops->options, td->eo);
5627 }
5628}
5629
5630unsigned int fio_get_kb_base(void *data)
5631{
5632 struct thread_data *td = cb_data_to_td(data);
5633 struct thread_options *o = &td->o;
5634 unsigned int kb_base = 0;
5635
5636 /*
5637 * This is a hack... For private options, *data is not holding
5638 * a pointer to the thread_options, but to private data. This means
5639 * we can't safely dereference it, but magic is first so mem wise
5640 * it is valid. But this also means that if the job first sets
5641 * kb_base and expects that to be honored by private options,
5642 * it will be disappointed. We will return the global default
5643 * for this.
5644 */
5645 if (o && o->magic == OPT_MAGIC)
5646 kb_base = o->kb_base;
5647 if (!kb_base)
5648 kb_base = 1024;
5649
5650 return kb_base;
5651}
5652
5653int add_option(const struct fio_option *o)
5654{
5655 struct fio_option *__o;
5656 int opt_index = 0;
5657
5658 __o = fio_options;
5659 while (__o->name) {
5660 opt_index++;
5661 __o++;
5662 }
5663
5664 if (opt_index + 1 == FIO_MAX_OPTS) {
5665 log_err("fio: FIO_MAX_OPTS is too small\n");
5666 return 1;
5667 }
5668
5669 memcpy(&fio_options[opt_index], o, sizeof(*o));
5670 fio_options[opt_index + 1].name = NULL;
5671 return 0;
5672}
5673
5674void invalidate_profile_options(const char *prof_name)
5675{
5676 struct fio_option *o;
5677
5678 o = fio_options;
5679 while (o->name) {
5680 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
5681 o->type = FIO_OPT_INVALID;
5682 o->prof_name = NULL;
5683 }
5684 o++;
5685 }
5686}
5687
5688void add_opt_posval(const char *optname, const char *ival, const char *help)
5689{
5690 struct fio_option *o;
5691 unsigned int i;
5692
5693 o = find_option(fio_options, optname);
5694 if (!o)
5695 return;
5696
5697 for (i = 0; i < PARSE_MAX_VP; i++) {
5698 if (o->posval[i].ival)
5699 continue;
5700
5701 o->posval[i].ival = ival;
5702 o->posval[i].help = help;
5703 break;
5704 }
5705}
5706
5707void del_opt_posval(const char *optname, const char *ival)
5708{
5709 struct fio_option *o;
5710 unsigned int i;
5711
5712 o = find_option(fio_options, optname);
5713 if (!o)
5714 return;
5715
5716 for (i = 0; i < PARSE_MAX_VP; i++) {
5717 if (!o->posval[i].ival)
5718 continue;
5719 if (strcmp(o->posval[i].ival, ival))
5720 continue;
5721
5722 o->posval[i].ival = NULL;
5723 o->posval[i].help = NULL;
5724 }
5725}
5726
5727void fio_options_free(struct thread_data *td)
5728{
5729 options_free(fio_options, &td->o);
5730 if (td->eo && td->io_ops && td->io_ops->options) {
5731 options_free(td->io_ops->options, td->eo);
5732 free(td->eo);
5733 td->eo = NULL;
5734 }
5735}
5736
5737void fio_dump_options_free(struct thread_data *td)
5738{
5739 while (!flist_empty(&td->opt_list)) {
5740 struct print_option *p;
5741
5742 p = flist_first_entry(&td->opt_list, struct print_option, list);
5743 flist_del_init(&p->list);
5744 free(p->name);
5745 free(p->value);
5746 free(p);
5747 }
5748}
5749
5750struct fio_option *fio_option_find(const char *name)
5751{
5752 return find_option(fio_options, name);
5753}
5754
5755static struct fio_option *find_next_opt(struct fio_option *from,
5756 unsigned int off1)
5757{
5758 struct fio_option *opt;
5759
5760 if (!from)
5761 from = &fio_options[0];
5762 else
5763 from++;
5764
5765 opt = NULL;
5766 do {
5767 if (off1 == from->off1) {
5768 opt = from;
5769 break;
5770 }
5771 from++;
5772 } while (from->name);
5773
5774 return opt;
5775}
5776
5777static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5778{
5779 unsigned int opt_off, index, offset;
5780
5781 opt_off = opt - &fio_options[0];
5782 index = opt_off / (8 * sizeof(uint64_t));
5783 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5784 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
5785}
5786
5787bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
5788{
5789 struct fio_option *opt, *next;
5790
5791 next = NULL;
5792 while ((opt = find_next_opt(next, off1)) != NULL) {
5793 if (opt_is_set(o, opt))
5794 return true;
5795
5796 next = opt;
5797 }
5798
5799 return false;
5800}
5801
5802void fio_option_mark_set(struct thread_options *o, const struct fio_option *opt)
5803{
5804 unsigned int opt_off, index, offset;
5805
5806 opt_off = opt - &fio_options[0];
5807 index = opt_off / (8 * sizeof(uint64_t));
5808 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5809 o->set_options[index] |= (uint64_t)1 << offset;
5810}