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