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