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