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