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