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