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