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