Revert "ioengines: Make td_io_queue print log_err when got error "
[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_uncapped(v)) {
1485                 td->o.io_size = 0;
1486                 td->o.io_size_percent = -1ULL - v;
1487                 if (td->o.io_size_percent > 100) {
1488                         log_err("fio: io_size values greater than 100%% aren't supported\n");
1489                         return 1;
1490                 }
1491                 dprint(FD_PARSE, "SET io_size_percent %d\n",
1492                                         td->o.io_size_percent);
1493         } else
1494                 td->o.io_size = v;
1495
1496         return 0;
1497 }
1498
1499 static int str_write_bw_log_cb(void *data, const char *str)
1500 {
1501         struct thread_data *td = cb_data_to_td(data);
1502
1503         if (str)
1504                 td->o.bw_log_file = strdup(str);
1505
1506         td->o.write_bw_log = 1;
1507         return 0;
1508 }
1509
1510 static int str_write_lat_log_cb(void *data, const char *str)
1511 {
1512         struct thread_data *td = cb_data_to_td(data);
1513
1514         if (str)
1515                 td->o.lat_log_file = strdup(str);
1516
1517         td->o.write_lat_log = 1;
1518         return 0;
1519 }
1520
1521 static int str_write_iops_log_cb(void *data, const char *str)
1522 {
1523         struct thread_data *td = cb_data_to_td(data);
1524
1525         if (str)
1526                 td->o.iops_log_file = strdup(str);
1527
1528         td->o.write_iops_log = 1;
1529         return 0;
1530 }
1531
1532 static int str_write_hist_log_cb(void *data, const char *str)
1533 {
1534         struct thread_data *td = cb_data_to_td(data);
1535
1536         if (str)
1537                 td->o.hist_log_file = strdup(str);
1538
1539         td->o.write_hist_log = 1;
1540         return 0;
1541 }
1542
1543 /*
1544  * str is supposed to be a substring of the strdup'd original string,
1545  * and is valid only if it's a regular file path.
1546  * This function keeps the pointer to the path as needed later.
1547  *
1548  * "external:/path/to/so\0" <- original pointer updated with strdup'd
1549  * "external\0"             <- above pointer after parsed, i.e. ->ioengine
1550  *          "/path/to/so\0" <- str argument, i.e. ->ioengine_so_path
1551  */
1552 static int str_ioengine_external_cb(void *data, const char *str)
1553 {
1554         struct thread_data *td = cb_data_to_td(data);
1555         struct stat sb;
1556         char *p;
1557
1558         if (!str) {
1559                 log_err("fio: null external ioengine path\n");
1560                 return 1;
1561         }
1562
1563         p = (char *)str; /* str is mutable */
1564         strip_blank_front(&p);
1565         strip_blank_end(p);
1566
1567         if (stat(p, &sb) || !S_ISREG(sb.st_mode)) {
1568                 log_err("fio: invalid external ioengine path \"%s\"\n", p);
1569                 return 1;
1570         }
1571
1572         td->o.ioengine_so_path = p;
1573         return 0;
1574 }
1575
1576 static int rw_verify(const struct fio_option *o, void *data)
1577 {
1578         struct thread_data *td = cb_data_to_td(data);
1579
1580         if (read_only && (td_write(td) || td_trim(td))) {
1581                 log_err("fio: job <%s> has write or trim bit set, but"
1582                         " fio is in read-only mode\n", td->o.name);
1583                 return 1;
1584         }
1585
1586         return 0;
1587 }
1588
1589 static int gtod_cpu_verify(const struct fio_option *o, void *data)
1590 {
1591 #ifndef FIO_HAVE_CPU_AFFINITY
1592         struct thread_data *td = cb_data_to_td(data);
1593
1594         if (td->o.gtod_cpu) {
1595                 log_err("fio: platform must support CPU affinity for"
1596                         "gettimeofday() offloading\n");
1597                 return 1;
1598         }
1599 #endif
1600
1601         return 0;
1602 }
1603
1604 /*
1605  * Map of job/command line options
1606  */
1607 struct fio_option fio_options[FIO_MAX_OPTS] = {
1608         {
1609                 .name   = "description",
1610                 .lname  = "Description of job",
1611                 .type   = FIO_OPT_STR_STORE,
1612                 .off1   = offsetof(struct thread_options, description),
1613                 .help   = "Text job description",
1614                 .category = FIO_OPT_C_GENERAL,
1615                 .group  = FIO_OPT_G_DESC,
1616         },
1617         {
1618                 .name   = "name",
1619                 .lname  = "Job name",
1620                 .type   = FIO_OPT_STR_STORE,
1621                 .off1   = offsetof(struct thread_options, name),
1622                 .help   = "Name of this job",
1623                 .category = FIO_OPT_C_GENERAL,
1624                 .group  = FIO_OPT_G_DESC,
1625         },
1626         {
1627                 .name   = "wait_for",
1628                 .lname  = "Waitee name",
1629                 .type   = FIO_OPT_STR_STORE,
1630                 .off1   = offsetof(struct thread_options, wait_for),
1631                 .help   = "Name of the job this one wants to wait for before starting",
1632                 .category = FIO_OPT_C_GENERAL,
1633                 .group  = FIO_OPT_G_DESC,
1634         },
1635         {
1636                 .name   = "filename",
1637                 .lname  = "Filename(s)",
1638                 .type   = FIO_OPT_STR_STORE,
1639                 .off1   = offsetof(struct thread_options, filename),
1640                 .cb     = str_filename_cb,
1641                 .prio   = -1, /* must come after "directory" */
1642                 .help   = "File(s) to use for the workload",
1643                 .category = FIO_OPT_C_FILE,
1644                 .group  = FIO_OPT_G_FILENAME,
1645         },
1646         {
1647                 .name   = "directory",
1648                 .lname  = "Directory",
1649                 .type   = FIO_OPT_STR_STORE,
1650                 .off1   = offsetof(struct thread_options, directory),
1651                 .cb     = str_directory_cb,
1652                 .help   = "Directory to store files in",
1653                 .category = FIO_OPT_C_FILE,
1654                 .group  = FIO_OPT_G_FILENAME,
1655         },
1656         {
1657                 .name   = "filename_format",
1658                 .lname  = "Filename Format",
1659                 .type   = FIO_OPT_STR_STORE,
1660                 .off1   = offsetof(struct thread_options, filename_format),
1661                 .prio   = -1, /* must come after "directory" */
1662                 .help   = "Override default $jobname.$jobnum.$filenum naming",
1663                 .def    = "$jobname.$jobnum.$filenum",
1664                 .category = FIO_OPT_C_FILE,
1665                 .group  = FIO_OPT_G_FILENAME,
1666         },
1667         {
1668                 .name   = "unique_filename",
1669                 .lname  = "Unique Filename",
1670                 .type   = FIO_OPT_BOOL,
1671                 .off1   = offsetof(struct thread_options, unique_filename),
1672                 .help   = "For network clients, prefix file with source IP",
1673                 .def    = "1",
1674                 .category = FIO_OPT_C_FILE,
1675                 .group  = FIO_OPT_G_FILENAME,
1676         },
1677         {
1678                 .name   = "lockfile",
1679                 .lname  = "Lockfile",
1680                 .type   = FIO_OPT_STR,
1681                 .off1   = offsetof(struct thread_options, file_lock_mode),
1682                 .help   = "Lock file when doing IO to it",
1683                 .prio   = 1,
1684                 .parent = "filename",
1685                 .hide   = 0,
1686                 .def    = "none",
1687                 .category = FIO_OPT_C_FILE,
1688                 .group  = FIO_OPT_G_FILENAME,
1689                 .posval = {
1690                           { .ival = "none",
1691                             .oval = FILE_LOCK_NONE,
1692                             .help = "No file locking",
1693                           },
1694                           { .ival = "exclusive",
1695                             .oval = FILE_LOCK_EXCLUSIVE,
1696                             .help = "Exclusive file lock",
1697                           },
1698                           {
1699                             .ival = "readwrite",
1700                             .oval = FILE_LOCK_READWRITE,
1701                             .help = "Read vs write lock",
1702                           },
1703                 },
1704         },
1705         {
1706                 .name   = "opendir",
1707                 .lname  = "Open directory",
1708                 .type   = FIO_OPT_STR_STORE,
1709                 .off1   = offsetof(struct thread_options, opendir),
1710                 .cb     = str_opendir_cb,
1711                 .help   = "Recursively add files from this directory and down",
1712                 .category = FIO_OPT_C_FILE,
1713                 .group  = FIO_OPT_G_FILENAME,
1714         },
1715         {
1716                 .name   = "rw",
1717                 .lname  = "Read/write",
1718                 .alias  = "readwrite",
1719                 .type   = FIO_OPT_STR,
1720                 .cb     = str_rw_cb,
1721                 .off1   = offsetof(struct thread_options, td_ddir),
1722                 .help   = "IO direction",
1723                 .def    = "read",
1724                 .verify = rw_verify,
1725                 .category = FIO_OPT_C_IO,
1726                 .group  = FIO_OPT_G_IO_BASIC,
1727                 .posval = {
1728                           { .ival = "read",
1729                             .oval = TD_DDIR_READ,
1730                             .help = "Sequential read",
1731                           },
1732                           { .ival = "write",
1733                             .oval = TD_DDIR_WRITE,
1734                             .help = "Sequential write",
1735                           },
1736                           { .ival = "trim",
1737                             .oval = TD_DDIR_TRIM,
1738                             .help = "Sequential trim",
1739                           },
1740                           { .ival = "randread",
1741                             .oval = TD_DDIR_RANDREAD,
1742                             .help = "Random read",
1743                           },
1744                           { .ival = "randwrite",
1745                             .oval = TD_DDIR_RANDWRITE,
1746                             .help = "Random write",
1747                           },
1748                           { .ival = "randtrim",
1749                             .oval = TD_DDIR_RANDTRIM,
1750                             .help = "Random trim",
1751                           },
1752                           { .ival = "rw",
1753                             .oval = TD_DDIR_RW,
1754                             .help = "Sequential read and write mix",
1755                           },
1756                           { .ival = "readwrite",
1757                             .oval = TD_DDIR_RW,
1758                             .help = "Sequential read and write mix",
1759                           },
1760                           { .ival = "randrw",
1761                             .oval = TD_DDIR_RANDRW,
1762                             .help = "Random read and write mix"
1763                           },
1764                           { .ival = "trimwrite",
1765                             .oval = TD_DDIR_TRIMWRITE,
1766                             .help = "Trim and write mix, trims preceding writes"
1767                           },
1768                 },
1769         },
1770         {
1771                 .name   = "rw_sequencer",
1772                 .lname  = "RW Sequencer",
1773                 .type   = FIO_OPT_STR,
1774                 .off1   = offsetof(struct thread_options, rw_seq),
1775                 .help   = "IO offset generator modifier",
1776                 .def    = "sequential",
1777                 .category = FIO_OPT_C_IO,
1778                 .group  = FIO_OPT_G_IO_BASIC,
1779                 .posval = {
1780                           { .ival = "sequential",
1781                             .oval = RW_SEQ_SEQ,
1782                             .help = "Generate sequential offsets",
1783                           },
1784                           { .ival = "identical",
1785                             .oval = RW_SEQ_IDENT,
1786                             .help = "Generate identical offsets",
1787                           },
1788                 },
1789         },
1790
1791         {
1792                 .name   = "ioengine",
1793                 .lname  = "IO Engine",
1794                 .type   = FIO_OPT_STR_STORE,
1795                 .off1   = offsetof(struct thread_options, ioengine),
1796                 .help   = "IO engine to use",
1797                 .def    = FIO_PREFERRED_ENGINE,
1798                 .category = FIO_OPT_C_IO,
1799                 .group  = FIO_OPT_G_IO_BASIC,
1800                 .posval = {
1801                           { .ival = "sync",
1802                             .help = "Use read/write",
1803                           },
1804                           { .ival = "psync",
1805                             .help = "Use pread/pwrite",
1806                           },
1807                           { .ival = "vsync",
1808                             .help = "Use readv/writev",
1809                           },
1810 #ifdef CONFIG_PWRITEV
1811                           { .ival = "pvsync",
1812                             .help = "Use preadv/pwritev",
1813                           },
1814 #endif
1815 #ifdef FIO_HAVE_PWRITEV2
1816                           { .ival = "pvsync2",
1817                             .help = "Use preadv2/pwritev2",
1818                           },
1819 #endif
1820 #ifdef CONFIG_LIBAIO
1821                           { .ival = "libaio",
1822                             .help = "Linux native asynchronous IO",
1823                           },
1824 #endif
1825 #ifdef ARCH_HAVE_IOURING
1826                           { .ival = "io_uring",
1827                             .help = "Fast Linux native aio",
1828                           },
1829 #endif
1830 #ifdef CONFIG_POSIXAIO
1831                           { .ival = "posixaio",
1832                             .help = "POSIX asynchronous IO",
1833                           },
1834 #endif
1835 #ifdef CONFIG_SOLARISAIO
1836                           { .ival = "solarisaio",
1837                             .help = "Solaris native asynchronous IO",
1838                           },
1839 #endif
1840 #ifdef CONFIG_WINDOWSAIO
1841                           { .ival = "windowsaio",
1842                             .help = "Windows native asynchronous IO"
1843                           },
1844 #endif
1845 #ifdef CONFIG_RBD
1846                           { .ival = "rbd",
1847                             .help = "Rados Block Device asynchronous IO"
1848                           },
1849 #endif
1850                           { .ival = "mmap",
1851                             .help = "Memory mapped IO"
1852                           },
1853 #ifdef CONFIG_LINUX_SPLICE
1854                           { .ival = "splice",
1855                             .help = "splice/vmsplice based IO",
1856                           },
1857                           { .ival = "netsplice",
1858                             .help = "splice/vmsplice to/from the network",
1859                           },
1860 #endif
1861 #ifdef FIO_HAVE_SGIO
1862                           { .ival = "sg",
1863                             .help = "SCSI generic v3 IO",
1864                           },
1865 #endif
1866                           { .ival = "null",
1867                             .help = "Testing engine (no data transfer)",
1868                           },
1869                           { .ival = "net",
1870                             .help = "Network IO",
1871                           },
1872                           { .ival = "cpuio",
1873                             .help = "CPU cycle burner engine",
1874                           },
1875 #ifdef CONFIG_RDMA
1876                           { .ival = "rdma",
1877                             .help = "RDMA IO engine",
1878                           },
1879 #endif
1880 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1881                           { .ival = "e4defrag",
1882                             .help = "ext4 defrag engine",
1883                           },
1884 #endif
1885 #ifdef CONFIG_LINUX_FALLOCATE
1886                           { .ival = "falloc",
1887                             .help = "fallocate() file based engine",
1888                           },
1889 #endif
1890 #ifdef CONFIG_GFAPI
1891                           { .ival = "gfapi",
1892                             .help = "Glusterfs libgfapi(sync) based engine"
1893                           },
1894                           { .ival = "gfapi_async",
1895                             .help = "Glusterfs libgfapi(async) based engine"
1896                           },
1897 #endif
1898 #ifdef CONFIG_LIBHDFS
1899                           { .ival = "libhdfs",
1900                             .help = "Hadoop Distributed Filesystem (HDFS) engine"
1901                           },
1902 #endif
1903 #ifdef CONFIG_PMEMBLK
1904                           { .ival = "pmemblk",
1905                             .help = "PMDK libpmemblk based IO engine",
1906                           },
1907
1908 #endif
1909 #ifdef CONFIG_IME
1910                           { .ival = "ime_psync",
1911                             .help = "DDN's IME synchronous IO engine",
1912                           },
1913                           { .ival = "ime_psyncv",
1914                             .help = "DDN's IME synchronous IO engine using iovecs",
1915                           },
1916                           { .ival = "ime_aio",
1917                             .help = "DDN's IME asynchronous IO engine",
1918                           },
1919 #endif
1920 #ifdef CONFIG_LINUX_DEVDAX
1921                           { .ival = "dev-dax",
1922                             .help = "DAX Device based IO engine",
1923                           },
1924 #endif
1925                           {
1926                             .ival = "filecreate",
1927                             .help = "File creation engine",
1928                           },
1929                           { .ival = "external",
1930                             .help = "Load external engine (append name)",
1931                             .cb = str_ioengine_external_cb,
1932                           },
1933 #ifdef CONFIG_LIBPMEM
1934                           { .ival = "libpmem",
1935                             .help = "PMDK libpmem based IO engine",
1936                           },
1937 #endif
1938 #ifdef CONFIG_HTTP
1939                           { .ival = "http",
1940                             .help = "HTTP (WebDAV/S3) IO engine",
1941                           },
1942 #endif
1943                           { .ival = "nbd",
1944                             .help = "Network Block Device (NBD) IO engine"
1945                           },
1946                 },
1947         },
1948         {
1949                 .name   = "iodepth",
1950                 .lname  = "IO Depth",
1951                 .type   = FIO_OPT_INT,
1952                 .off1   = offsetof(struct thread_options, iodepth),
1953                 .help   = "Number of IO buffers to keep in flight",
1954                 .minval = 1,
1955                 .interval = 1,
1956                 .def    = "1",
1957                 .category = FIO_OPT_C_IO,
1958                 .group  = FIO_OPT_G_IO_BASIC,
1959         },
1960         {
1961                 .name   = "iodepth_batch",
1962                 .lname  = "IO Depth batch",
1963                 .alias  = "iodepth_batch_submit",
1964                 .type   = FIO_OPT_INT,
1965                 .off1   = offsetof(struct thread_options, iodepth_batch),
1966                 .help   = "Number of IO buffers to submit in one go",
1967                 .parent = "iodepth",
1968                 .hide   = 1,
1969                 .interval = 1,
1970                 .def    = "1",
1971                 .category = FIO_OPT_C_IO,
1972                 .group  = FIO_OPT_G_IO_BASIC,
1973         },
1974         {
1975                 .name   = "iodepth_batch_complete_min",
1976                 .lname  = "Min IO depth batch complete",
1977                 .alias  = "iodepth_batch_complete",
1978                 .type   = FIO_OPT_INT,
1979                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_min),
1980                 .help   = "Min number of IO buffers to retrieve in one go",
1981                 .parent = "iodepth",
1982                 .hide   = 1,
1983                 .minval = 0,
1984                 .interval = 1,
1985                 .def    = "1",
1986                 .category = FIO_OPT_C_IO,
1987                 .group  = FIO_OPT_G_IO_BASIC,
1988         },
1989         {
1990                 .name   = "iodepth_batch_complete_max",
1991                 .lname  = "Max IO depth batch complete",
1992                 .type   = FIO_OPT_INT,
1993                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_max),
1994                 .help   = "Max number of IO buffers to retrieve in one go",
1995                 .parent = "iodepth",
1996                 .hide   = 1,
1997                 .minval = 0,
1998                 .interval = 1,
1999                 .category = FIO_OPT_C_IO,
2000                 .group  = FIO_OPT_G_IO_BASIC,
2001         },
2002         {
2003                 .name   = "iodepth_low",
2004                 .lname  = "IO Depth batch low",
2005                 .type   = FIO_OPT_INT,
2006                 .off1   = offsetof(struct thread_options, iodepth_low),
2007                 .help   = "Low water mark for queuing depth",
2008                 .parent = "iodepth",
2009                 .hide   = 1,
2010                 .interval = 1,
2011                 .category = FIO_OPT_C_IO,
2012                 .group  = FIO_OPT_G_IO_BASIC,
2013         },
2014         {
2015                 .name   = "serialize_overlap",
2016                 .lname  = "Serialize overlap",
2017                 .off1   = offsetof(struct thread_options, serialize_overlap),
2018                 .type   = FIO_OPT_BOOL,
2019                 .help   = "Wait for in-flight IOs that collide to complete",
2020                 .parent = "iodepth",
2021                 .def    = "0",
2022                 .category = FIO_OPT_C_IO,
2023                 .group  = FIO_OPT_G_IO_BASIC,
2024         },
2025         {
2026                 .name   = "io_submit_mode",
2027                 .lname  = "IO submit mode",
2028                 .type   = FIO_OPT_STR,
2029                 .off1   = offsetof(struct thread_options, io_submit_mode),
2030                 .help   = "How IO submissions and completions are done",
2031                 .def    = "inline",
2032                 .category = FIO_OPT_C_IO,
2033                 .group  = FIO_OPT_G_IO_BASIC,
2034                 .posval = {
2035                           { .ival = "inline",
2036                             .oval = IO_MODE_INLINE,
2037                             .help = "Submit and complete IO inline",
2038                           },
2039                           { .ival = "offload",
2040                             .oval = IO_MODE_OFFLOAD,
2041                             .help = "Offload submit and complete to threads",
2042                           },
2043                 },
2044         },
2045         {
2046                 .name   = "size",
2047                 .lname  = "Size",
2048                 .type   = FIO_OPT_STR_VAL,
2049                 .cb     = str_size_cb,
2050                 .off1   = offsetof(struct thread_options, size),
2051                 .help   = "Total size of device or files",
2052                 .interval = 1024 * 1024,
2053                 .category = FIO_OPT_C_IO,
2054                 .group  = FIO_OPT_G_INVALID,
2055         },
2056         {
2057                 .name   = "io_size",
2058                 .alias  = "io_limit",
2059                 .lname  = "IO Size",
2060                 .type   = FIO_OPT_STR_VAL,
2061                 .cb     = str_io_size_cb,
2062                 .off1   = offsetof(struct thread_options, io_size),
2063                 .help   = "Total size of I/O to be performed",
2064                 .interval = 1024 * 1024,
2065                 .category = FIO_OPT_C_IO,
2066                 .group  = FIO_OPT_G_INVALID,
2067         },
2068         {
2069                 .name   = "fill_device",
2070                 .lname  = "Fill device",
2071                 .alias  = "fill_fs",
2072                 .type   = FIO_OPT_BOOL,
2073                 .off1   = offsetof(struct thread_options, fill_device),
2074                 .help   = "Write until an ENOSPC error occurs",
2075                 .def    = "0",
2076                 .category = FIO_OPT_C_FILE,
2077                 .group  = FIO_OPT_G_INVALID,
2078         },
2079         {
2080                 .name   = "filesize",
2081                 .lname  = "File size",
2082                 .type   = FIO_OPT_STR_VAL,
2083                 .off1   = offsetof(struct thread_options, file_size_low),
2084                 .off2   = offsetof(struct thread_options, file_size_high),
2085                 .minval = 1,
2086                 .help   = "Size of individual files",
2087                 .interval = 1024 * 1024,
2088                 .category = FIO_OPT_C_FILE,
2089                 .group  = FIO_OPT_G_INVALID,
2090         },
2091         {
2092                 .name   = "file_append",
2093                 .lname  = "File append",
2094                 .type   = FIO_OPT_BOOL,
2095                 .off1   = offsetof(struct thread_options, file_append),
2096                 .help   = "IO will start at the end of the file(s)",
2097                 .def    = "0",
2098                 .category = FIO_OPT_C_FILE,
2099                 .group  = FIO_OPT_G_INVALID,
2100         },
2101         {
2102                 .name   = "offset",
2103                 .lname  = "IO offset",
2104                 .alias  = "fileoffset",
2105                 .type   = FIO_OPT_STR_VAL,
2106                 .cb     = str_offset_cb,
2107                 .off1   = offsetof(struct thread_options, start_offset),
2108                 .help   = "Start IO from this offset",
2109                 .def    = "0",
2110                 .interval = 1024 * 1024,
2111                 .category = FIO_OPT_C_IO,
2112                 .group  = FIO_OPT_G_INVALID,
2113         },
2114         {
2115                 .name   = "offset_align",
2116                 .lname  = "IO offset alignment",
2117                 .type   = FIO_OPT_INT,
2118                 .off1   = offsetof(struct thread_options, start_offset_align),
2119                 .help   = "Start IO from this offset alignment",
2120                 .def    = "0",
2121                 .interval = 512,
2122                 .category = FIO_OPT_C_IO,
2123                 .group  = FIO_OPT_G_INVALID,
2124         },
2125         {
2126                 .name   = "offset_increment",
2127                 .lname  = "IO offset increment",
2128                 .type   = FIO_OPT_STR_VAL,
2129                 .cb     = str_offset_increment_cb,
2130                 .off1   = offsetof(struct thread_options, offset_increment),
2131                 .help   = "What is the increment from one offset to the next",
2132                 .parent = "offset",
2133                 .hide   = 1,
2134                 .def    = "0",
2135                 .interval = 1024 * 1024,
2136                 .category = FIO_OPT_C_IO,
2137                 .group  = FIO_OPT_G_INVALID,
2138         },
2139         {
2140                 .name   = "number_ios",
2141                 .lname  = "Number of IOs to perform",
2142                 .type   = FIO_OPT_STR_VAL,
2143                 .off1   = offsetof(struct thread_options, number_ios),
2144                 .help   = "Force job completion after this number of IOs",
2145                 .def    = "0",
2146                 .category = FIO_OPT_C_IO,
2147                 .group  = FIO_OPT_G_INVALID,
2148         },
2149         {
2150                 .name   = "bs",
2151                 .lname  = "Block size",
2152                 .alias  = "blocksize",
2153                 .type   = FIO_OPT_ULL,
2154                 .off1   = offsetof(struct thread_options, bs[DDIR_READ]),
2155                 .off2   = offsetof(struct thread_options, bs[DDIR_WRITE]),
2156                 .off3   = offsetof(struct thread_options, bs[DDIR_TRIM]),
2157                 .minval = 1,
2158                 .help   = "Block size unit",
2159                 .def    = "4096",
2160                 .parent = "rw",
2161                 .hide   = 1,
2162                 .interval = 512,
2163                 .category = FIO_OPT_C_IO,
2164                 .group  = FIO_OPT_G_INVALID,
2165         },
2166         {
2167                 .name   = "ba",
2168                 .lname  = "Block size align",
2169                 .alias  = "blockalign",
2170                 .type   = FIO_OPT_ULL,
2171                 .off1   = offsetof(struct thread_options, ba[DDIR_READ]),
2172                 .off2   = offsetof(struct thread_options, ba[DDIR_WRITE]),
2173                 .off3   = offsetof(struct thread_options, ba[DDIR_TRIM]),
2174                 .minval = 1,
2175                 .help   = "IO block offset alignment",
2176                 .parent = "rw",
2177                 .hide   = 1,
2178                 .interval = 512,
2179                 .category = FIO_OPT_C_IO,
2180                 .group  = FIO_OPT_G_INVALID,
2181         },
2182         {
2183                 .name   = "bsrange",
2184                 .lname  = "Block size range",
2185                 .alias  = "blocksize_range",
2186                 .type   = FIO_OPT_RANGE,
2187                 .off1   = offsetof(struct thread_options, min_bs[DDIR_READ]),
2188                 .off2   = offsetof(struct thread_options, max_bs[DDIR_READ]),
2189                 .off3   = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2190                 .off4   = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2191                 .off5   = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2192                 .off6   = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2193                 .minval = 1,
2194                 .help   = "Set block size range (in more detail than bs)",
2195                 .parent = "rw",
2196                 .hide   = 1,
2197                 .interval = 4096,
2198                 .category = FIO_OPT_C_IO,
2199                 .group  = FIO_OPT_G_INVALID,
2200         },
2201         {
2202                 .name   = "bssplit",
2203                 .lname  = "Block size split",
2204                 .type   = FIO_OPT_STR_ULL,
2205                 .cb     = str_bssplit_cb,
2206                 .off1   = offsetof(struct thread_options, bssplit),
2207                 .help   = "Set a specific mix of block sizes",
2208                 .parent = "rw",
2209                 .hide   = 1,
2210                 .category = FIO_OPT_C_IO,
2211                 .group  = FIO_OPT_G_INVALID,
2212         },
2213         {
2214                 .name   = "bs_unaligned",
2215                 .lname  = "Block size unaligned",
2216                 .alias  = "blocksize_unaligned",
2217                 .type   = FIO_OPT_STR_SET,
2218                 .off1   = offsetof(struct thread_options, bs_unaligned),
2219                 .help   = "Don't sector align IO buffer sizes",
2220                 .parent = "rw",
2221                 .hide   = 1,
2222                 .category = FIO_OPT_C_IO,
2223                 .group  = FIO_OPT_G_INVALID,
2224         },
2225         {
2226                 .name   = "bs_is_seq_rand",
2227                 .lname  = "Block size division is seq/random (not read/write)",
2228                 .type   = FIO_OPT_BOOL,
2229                 .off1   = offsetof(struct thread_options, bs_is_seq_rand),
2230                 .help   = "Consider any blocksize setting to be sequential,random",
2231                 .def    = "0",
2232                 .parent = "blocksize",
2233                 .category = FIO_OPT_C_IO,
2234                 .group  = FIO_OPT_G_INVALID,
2235         },
2236         {
2237                 .name   = "randrepeat",
2238                 .lname  = "Random repeatable",
2239                 .type   = FIO_OPT_BOOL,
2240                 .off1   = offsetof(struct thread_options, rand_repeatable),
2241                 .help   = "Use repeatable random IO pattern",
2242                 .def    = "1",
2243                 .parent = "rw",
2244                 .hide   = 1,
2245                 .category = FIO_OPT_C_IO,
2246                 .group  = FIO_OPT_G_RANDOM,
2247         },
2248         {
2249                 .name   = "randseed",
2250                 .lname  = "The random generator seed",
2251                 .type   = FIO_OPT_STR_VAL,
2252                 .off1   = offsetof(struct thread_options, rand_seed),
2253                 .help   = "Set the random generator seed value",
2254                 .def    = "0x89",
2255                 .parent = "rw",
2256                 .category = FIO_OPT_C_IO,
2257                 .group  = FIO_OPT_G_RANDOM,
2258         },
2259         {
2260                 .name   = "norandommap",
2261                 .lname  = "No randommap",
2262                 .type   = FIO_OPT_STR_SET,
2263                 .off1   = offsetof(struct thread_options, norandommap),
2264                 .help   = "Accept potential duplicate random blocks",
2265                 .parent = "rw",
2266                 .hide   = 1,
2267                 .hide_on_set = 1,
2268                 .category = FIO_OPT_C_IO,
2269                 .group  = FIO_OPT_G_RANDOM,
2270         },
2271         {
2272                 .name   = "softrandommap",
2273                 .lname  = "Soft randommap",
2274                 .type   = FIO_OPT_BOOL,
2275                 .off1   = offsetof(struct thread_options, softrandommap),
2276                 .help   = "Set norandommap if randommap allocation fails",
2277                 .parent = "norandommap",
2278                 .hide   = 1,
2279                 .def    = "0",
2280                 .category = FIO_OPT_C_IO,
2281                 .group  = FIO_OPT_G_RANDOM,
2282         },
2283         {
2284                 .name   = "random_generator",
2285                 .lname  = "Random Generator",
2286                 .type   = FIO_OPT_STR,
2287                 .off1   = offsetof(struct thread_options, random_generator),
2288                 .help   = "Type of random number generator to use",
2289                 .def    = "tausworthe",
2290                 .posval = {
2291                           { .ival = "tausworthe",
2292                             .oval = FIO_RAND_GEN_TAUSWORTHE,
2293                             .help = "Strong Tausworthe generator",
2294                           },
2295                           { .ival = "lfsr",
2296                             .oval = FIO_RAND_GEN_LFSR,
2297                             .help = "Variable length LFSR",
2298                           },
2299                           {
2300                             .ival = "tausworthe64",
2301                             .oval = FIO_RAND_GEN_TAUSWORTHE64,
2302                             .help = "64-bit Tausworthe variant",
2303                           },
2304                 },
2305                 .category = FIO_OPT_C_IO,
2306                 .group  = FIO_OPT_G_RANDOM,
2307         },
2308         {
2309                 .name   = "random_distribution",
2310                 .lname  = "Random Distribution",
2311                 .type   = FIO_OPT_STR,
2312                 .off1   = offsetof(struct thread_options, random_distribution),
2313                 .cb     = str_random_distribution_cb,
2314                 .help   = "Random offset distribution generator",
2315                 .def    = "random",
2316                 .posval = {
2317                           { .ival = "random",
2318                             .oval = FIO_RAND_DIST_RANDOM,
2319                             .help = "Completely random",
2320                           },
2321                           { .ival = "zipf",
2322                             .oval = FIO_RAND_DIST_ZIPF,
2323                             .help = "Zipf distribution",
2324                           },
2325                           { .ival = "pareto",
2326                             .oval = FIO_RAND_DIST_PARETO,
2327                             .help = "Pareto distribution",
2328                           },
2329                           { .ival = "normal",
2330                             .oval = FIO_RAND_DIST_GAUSS,
2331                             .help = "Normal (Gaussian) distribution",
2332                           },
2333                           { .ival = "zoned",
2334                             .oval = FIO_RAND_DIST_ZONED,
2335                             .help = "Zoned random distribution",
2336                           },
2337                           { .ival = "zoned_abs",
2338                             .oval = FIO_RAND_DIST_ZONED_ABS,
2339                             .help = "Zoned absolute random distribution",
2340                           },
2341                 },
2342                 .category = FIO_OPT_C_IO,
2343                 .group  = FIO_OPT_G_RANDOM,
2344         },
2345         {
2346                 .name   = "percentage_random",
2347                 .lname  = "Percentage Random",
2348                 .type   = FIO_OPT_INT,
2349                 .off1   = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2350                 .off2   = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2351                 .off3   = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2352                 .maxval = 100,
2353                 .help   = "Percentage of seq/random mix that should be random",
2354                 .def    = "100,100,100",
2355                 .interval = 5,
2356                 .inverse = "percentage_sequential",
2357                 .category = FIO_OPT_C_IO,
2358                 .group  = FIO_OPT_G_RANDOM,
2359         },
2360         {
2361                 .name   = "percentage_sequential",
2362                 .lname  = "Percentage Sequential",
2363                 .type   = FIO_OPT_DEPRECATED,
2364                 .category = FIO_OPT_C_IO,
2365                 .group  = FIO_OPT_G_RANDOM,
2366         },
2367         {
2368                 .name   = "allrandrepeat",
2369                 .lname  = "All Random Repeat",
2370                 .type   = FIO_OPT_BOOL,
2371                 .off1   = offsetof(struct thread_options, allrand_repeatable),
2372                 .help   = "Use repeatable random numbers for everything",
2373                 .def    = "0",
2374                 .category = FIO_OPT_C_IO,
2375                 .group  = FIO_OPT_G_RANDOM,
2376         },
2377         {
2378                 .name   = "nrfiles",
2379                 .lname  = "Number of files",
2380                 .alias  = "nr_files",
2381                 .type   = FIO_OPT_INT,
2382                 .off1   = offsetof(struct thread_options, nr_files),
2383                 .help   = "Split job workload between this number of files",
2384                 .def    = "1",
2385                 .interval = 1,
2386                 .category = FIO_OPT_C_FILE,
2387                 .group  = FIO_OPT_G_INVALID,
2388         },
2389         {
2390                 .name   = "openfiles",
2391                 .lname  = "Number of open files",
2392                 .type   = FIO_OPT_INT,
2393                 .off1   = offsetof(struct thread_options, open_files),
2394                 .help   = "Number of files to keep open at the same time",
2395                 .category = FIO_OPT_C_FILE,
2396                 .group  = FIO_OPT_G_INVALID,
2397         },
2398         {
2399                 .name   = "file_service_type",
2400                 .lname  = "File service type",
2401                 .type   = FIO_OPT_STR,
2402                 .cb     = str_fst_cb,
2403                 .off1   = offsetof(struct thread_options, file_service_type),
2404                 .help   = "How to select which file to service next",
2405                 .def    = "roundrobin",
2406                 .category = FIO_OPT_C_FILE,
2407                 .group  = FIO_OPT_G_INVALID,
2408                 .posval = {
2409                           { .ival = "random",
2410                             .oval = FIO_FSERVICE_RANDOM,
2411                             .help = "Choose a file at random (uniform)",
2412                           },
2413                           { .ival = "zipf",
2414                             .oval = FIO_FSERVICE_ZIPF,
2415                             .help = "Zipf randomized",
2416                           },
2417                           { .ival = "pareto",
2418                             .oval = FIO_FSERVICE_PARETO,
2419                             .help = "Pareto randomized",
2420                           },
2421                           { .ival = "normal",
2422                             .oval = FIO_FSERVICE_GAUSS,
2423                             .help = "Normal (Gaussian) randomized",
2424                           },
2425                           { .ival = "gauss",
2426                             .oval = FIO_FSERVICE_GAUSS,
2427                             .help = "Alias for normal",
2428                           },
2429                           { .ival = "roundrobin",
2430                             .oval = FIO_FSERVICE_RR,
2431                             .help = "Round robin select files",
2432                           },
2433                           { .ival = "sequential",
2434                             .oval = FIO_FSERVICE_SEQ,
2435                             .help = "Finish one file before moving to the next",
2436                           },
2437                 },
2438                 .parent = "nrfiles",
2439                 .hide   = 1,
2440         },
2441         {
2442                 .name   = "fallocate",
2443                 .lname  = "Fallocate",
2444                 .type   = FIO_OPT_STR,
2445                 .off1   = offsetof(struct thread_options, fallocate_mode),
2446                 .help   = "Whether pre-allocation is performed when laying out files",
2447 #ifdef FIO_HAVE_DEFAULT_FALLOCATE
2448                 .def    = "native",
2449 #else
2450                 .def    = "none",
2451 #endif
2452                 .category = FIO_OPT_C_FILE,
2453                 .group  = FIO_OPT_G_INVALID,
2454                 .posval = {
2455                           { .ival = "none",
2456                             .oval = FIO_FALLOCATE_NONE,
2457                             .help = "Do not pre-allocate space",
2458                           },
2459                           { .ival = "native",
2460                             .oval = FIO_FALLOCATE_NATIVE,
2461                             .help = "Use native pre-allocation if possible",
2462                           },
2463 #ifdef CONFIG_POSIX_FALLOCATE
2464                           { .ival = "posix",
2465                             .oval = FIO_FALLOCATE_POSIX,
2466                             .help = "Use posix_fallocate()",
2467                           },
2468 #endif
2469 #ifdef CONFIG_LINUX_FALLOCATE
2470                           { .ival = "keep",
2471                             .oval = FIO_FALLOCATE_KEEP_SIZE,
2472                             .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2473                           },
2474 #endif
2475                           { .ival = "truncate",
2476                             .oval = FIO_FALLOCATE_TRUNCATE,
2477                             .help = "Truncate file to final size instead of allocating"
2478                           },
2479                           /* Compatibility with former boolean values */
2480                           { .ival = "0",
2481                             .oval = FIO_FALLOCATE_NONE,
2482                             .help = "Alias for 'none'",
2483                           },
2484 #ifdef CONFIG_POSIX_FALLOCATE
2485                           { .ival = "1",
2486                             .oval = FIO_FALLOCATE_POSIX,
2487                             .help = "Alias for 'posix'",
2488                           },
2489 #endif
2490                 },
2491         },
2492         {
2493                 .name   = "fadvise_hint",
2494                 .lname  = "Fadvise hint",
2495                 .type   = FIO_OPT_STR,
2496                 .off1   = offsetof(struct thread_options, fadvise_hint),
2497                 .posval = {
2498                           { .ival = "0",
2499                             .oval = F_ADV_NONE,
2500                             .help = "Don't issue fadvise/madvise",
2501                           },
2502                           { .ival = "1",
2503                             .oval = F_ADV_TYPE,
2504                             .help = "Advise using fio IO pattern",
2505                           },
2506                           { .ival = "random",
2507                             .oval = F_ADV_RANDOM,
2508                             .help = "Advise using FADV_RANDOM",
2509                           },
2510                           { .ival = "sequential",
2511                             .oval = F_ADV_SEQUENTIAL,
2512                             .help = "Advise using FADV_SEQUENTIAL",
2513                           },
2514                 },
2515                 .help   = "Use fadvise() to advise the kernel on IO pattern",
2516                 .def    = "1",
2517                 .category = FIO_OPT_C_FILE,
2518                 .group  = FIO_OPT_G_INVALID,
2519         },
2520         {
2521                 .name   = "fsync",
2522                 .lname  = "Fsync",
2523                 .type   = FIO_OPT_INT,
2524                 .off1   = offsetof(struct thread_options, fsync_blocks),
2525                 .help   = "Issue fsync for writes every given number of blocks",
2526                 .def    = "0",
2527                 .interval = 1,
2528                 .category = FIO_OPT_C_FILE,
2529                 .group  = FIO_OPT_G_INVALID,
2530         },
2531         {
2532                 .name   = "fdatasync",
2533                 .lname  = "Fdatasync",
2534                 .type   = FIO_OPT_INT,
2535                 .off1   = offsetof(struct thread_options, fdatasync_blocks),
2536                 .help   = "Issue fdatasync for writes every given number of blocks",
2537                 .def    = "0",
2538                 .interval = 1,
2539                 .category = FIO_OPT_C_FILE,
2540                 .group  = FIO_OPT_G_INVALID,
2541         },
2542         {
2543                 .name   = "write_barrier",
2544                 .lname  = "Write barrier",
2545                 .type   = FIO_OPT_INT,
2546                 .off1   = offsetof(struct thread_options, barrier_blocks),
2547                 .help   = "Make every Nth write a barrier write",
2548                 .def    = "0",
2549                 .interval = 1,
2550                 .category = FIO_OPT_C_IO,
2551                 .group  = FIO_OPT_G_INVALID,
2552         },
2553 #ifdef CONFIG_SYNC_FILE_RANGE
2554         {
2555                 .name   = "sync_file_range",
2556                 .lname  = "Sync file range",
2557                 .posval = {
2558                           { .ival = "wait_before",
2559                             .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2560                             .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2561                             .orval  = 1,
2562                           },
2563                           { .ival = "write",
2564                             .oval = SYNC_FILE_RANGE_WRITE,
2565                             .help = "SYNC_FILE_RANGE_WRITE",
2566                             .orval  = 1,
2567                           },
2568                           {
2569                             .ival = "wait_after",
2570                             .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2571                             .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2572                             .orval  = 1,
2573                           },
2574                 },
2575                 .type   = FIO_OPT_STR_MULTI,
2576                 .cb     = str_sfr_cb,
2577                 .off1   = offsetof(struct thread_options, sync_file_range),
2578                 .help   = "Use sync_file_range()",
2579                 .category = FIO_OPT_C_FILE,
2580                 .group  = FIO_OPT_G_INVALID,
2581         },
2582 #else
2583         {
2584                 .name   = "sync_file_range",
2585                 .lname  = "Sync file range",
2586                 .type   = FIO_OPT_UNSUPPORTED,
2587                 .help   = "Your platform does not support sync_file_range",
2588         },
2589 #endif
2590         {
2591                 .name   = "direct",
2592                 .lname  = "Direct I/O",
2593                 .type   = FIO_OPT_BOOL,
2594                 .off1   = offsetof(struct thread_options, odirect),
2595                 .help   = "Use O_DIRECT IO (negates buffered)",
2596                 .def    = "0",
2597                 .inverse = "buffered",
2598                 .category = FIO_OPT_C_IO,
2599                 .group  = FIO_OPT_G_IO_TYPE,
2600         },
2601         {
2602                 .name   = "atomic",
2603                 .lname  = "Atomic I/O",
2604                 .type   = FIO_OPT_BOOL,
2605                 .off1   = offsetof(struct thread_options, oatomic),
2606                 .help   = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2607                 .def    = "0",
2608                 .category = FIO_OPT_C_IO,
2609                 .group  = FIO_OPT_G_IO_TYPE,
2610         },
2611         {
2612                 .name   = "buffered",
2613                 .lname  = "Buffered I/O",
2614                 .type   = FIO_OPT_BOOL,
2615                 .off1   = offsetof(struct thread_options, odirect),
2616                 .neg    = 1,
2617                 .help   = "Use buffered IO (negates direct)",
2618                 .def    = "1",
2619                 .inverse = "direct",
2620                 .category = FIO_OPT_C_IO,
2621                 .group  = FIO_OPT_G_IO_TYPE,
2622         },
2623         {
2624                 .name   = "overwrite",
2625                 .lname  = "Overwrite",
2626                 .type   = FIO_OPT_BOOL,
2627                 .off1   = offsetof(struct thread_options, overwrite),
2628                 .help   = "When writing, set whether to overwrite current data",
2629                 .def    = "0",
2630                 .category = FIO_OPT_C_FILE,
2631                 .group  = FIO_OPT_G_INVALID,
2632         },
2633         {
2634                 .name   = "loops",
2635                 .lname  = "Loops",
2636                 .type   = FIO_OPT_INT,
2637                 .off1   = offsetof(struct thread_options, loops),
2638                 .help   = "Number of times to run the job",
2639                 .def    = "1",
2640                 .interval = 1,
2641                 .category = FIO_OPT_C_GENERAL,
2642                 .group  = FIO_OPT_G_RUNTIME,
2643         },
2644         {
2645                 .name   = "numjobs",
2646                 .lname  = "Number of jobs",
2647                 .type   = FIO_OPT_INT,
2648                 .off1   = offsetof(struct thread_options, numjobs),
2649                 .help   = "Duplicate this job this many times",
2650                 .def    = "1",
2651                 .interval = 1,
2652                 .category = FIO_OPT_C_GENERAL,
2653                 .group  = FIO_OPT_G_RUNTIME,
2654         },
2655         {
2656                 .name   = "startdelay",
2657                 .lname  = "Start delay",
2658                 .type   = FIO_OPT_STR_VAL_TIME,
2659                 .off1   = offsetof(struct thread_options, start_delay),
2660                 .off2   = offsetof(struct thread_options, start_delay_high),
2661                 .help   = "Only start job when this period has passed",
2662                 .def    = "0",
2663                 .is_seconds = 1,
2664                 .is_time = 1,
2665                 .category = FIO_OPT_C_GENERAL,
2666                 .group  = FIO_OPT_G_RUNTIME,
2667         },
2668         {
2669                 .name   = "runtime",
2670                 .lname  = "Runtime",
2671                 .alias  = "timeout",
2672                 .type   = FIO_OPT_STR_VAL_TIME,
2673                 .off1   = offsetof(struct thread_options, timeout),
2674                 .help   = "Stop workload when this amount of time has passed",
2675                 .def    = "0",
2676                 .is_seconds = 1,
2677                 .is_time = 1,
2678                 .category = FIO_OPT_C_GENERAL,
2679                 .group  = FIO_OPT_G_RUNTIME,
2680         },
2681         {
2682                 .name   = "time_based",
2683                 .lname  = "Time based",
2684                 .type   = FIO_OPT_STR_SET,
2685                 .off1   = offsetof(struct thread_options, time_based),
2686                 .help   = "Keep running until runtime/timeout is met",
2687                 .category = FIO_OPT_C_GENERAL,
2688                 .group  = FIO_OPT_G_RUNTIME,
2689         },
2690         {
2691                 .name   = "verify_only",
2692                 .lname  = "Verify only",
2693                 .type   = FIO_OPT_STR_SET,
2694                 .off1   = offsetof(struct thread_options, verify_only),
2695                 .help   = "Verifies previously written data is still valid",
2696                 .category = FIO_OPT_C_GENERAL,
2697                 .group  = FIO_OPT_G_RUNTIME,
2698         },
2699         {
2700                 .name   = "ramp_time",
2701                 .lname  = "Ramp time",
2702                 .type   = FIO_OPT_STR_VAL_TIME,
2703                 .off1   = offsetof(struct thread_options, ramp_time),
2704                 .help   = "Ramp up time before measuring performance",
2705                 .is_seconds = 1,
2706                 .is_time = 1,
2707                 .category = FIO_OPT_C_GENERAL,
2708                 .group  = FIO_OPT_G_RUNTIME,
2709         },
2710         {
2711                 .name   = "clocksource",
2712                 .lname  = "Clock source",
2713                 .type   = FIO_OPT_STR,
2714                 .cb     = fio_clock_source_cb,
2715                 .off1   = offsetof(struct thread_options, clocksource),
2716                 .help   = "What type of timing source to use",
2717                 .category = FIO_OPT_C_GENERAL,
2718                 .group  = FIO_OPT_G_CLOCK,
2719                 .posval = {
2720 #ifdef CONFIG_GETTIMEOFDAY
2721                           { .ival = "gettimeofday",
2722                             .oval = CS_GTOD,
2723                             .help = "Use gettimeofday(2) for timing",
2724                           },
2725 #endif
2726 #ifdef CONFIG_CLOCK_GETTIME
2727                           { .ival = "clock_gettime",
2728                             .oval = CS_CGETTIME,
2729                             .help = "Use clock_gettime(2) for timing",
2730                           },
2731 #endif
2732 #ifdef ARCH_HAVE_CPU_CLOCK
2733                           { .ival = "cpu",
2734                             .oval = CS_CPUCLOCK,
2735                             .help = "Use CPU private clock",
2736                           },
2737 #endif
2738                 },
2739         },
2740         {
2741                 .name   = "mem",
2742                 .alias  = "iomem",
2743                 .lname  = "I/O Memory",
2744                 .type   = FIO_OPT_STR,
2745                 .cb     = str_mem_cb,
2746                 .off1   = offsetof(struct thread_options, mem_type),
2747                 .help   = "Backing type for IO buffers",
2748                 .def    = "malloc",
2749                 .category = FIO_OPT_C_IO,
2750                 .group  = FIO_OPT_G_INVALID,
2751                 .posval = {
2752                           { .ival = "malloc",
2753                             .oval = MEM_MALLOC,
2754                             .help = "Use malloc(3) for IO buffers",
2755                           },
2756 #ifndef CONFIG_NO_SHM
2757                           { .ival = "shm",
2758                             .oval = MEM_SHM,
2759                             .help = "Use shared memory segments for IO buffers",
2760                           },
2761 #ifdef FIO_HAVE_HUGETLB
2762                           { .ival = "shmhuge",
2763                             .oval = MEM_SHMHUGE,
2764                             .help = "Like shm, but use huge pages",
2765                           },
2766 #endif
2767 #endif
2768                           { .ival = "mmap",
2769                             .oval = MEM_MMAP,
2770                             .help = "Use mmap(2) (file or anon) for IO buffers",
2771                           },
2772                           { .ival = "mmapshared",
2773                             .oval = MEM_MMAPSHARED,
2774                             .help = "Like mmap, but use the shared flag",
2775                           },
2776 #ifdef FIO_HAVE_HUGETLB
2777                           { .ival = "mmaphuge",
2778                             .oval = MEM_MMAPHUGE,
2779                             .help = "Like mmap, but use huge pages",
2780                           },
2781 #endif
2782 #ifdef CONFIG_CUDA
2783                           { .ival = "cudamalloc",
2784                             .oval = MEM_CUDA_MALLOC,
2785                             .help = "Allocate GPU device memory for GPUDirect RDMA",
2786                           },
2787 #endif
2788                   },
2789         },
2790         {
2791                 .name   = "iomem_align",
2792                 .alias  = "mem_align",
2793                 .lname  = "I/O memory alignment",
2794                 .type   = FIO_OPT_INT,
2795                 .off1   = offsetof(struct thread_options, mem_align),
2796                 .minval = 0,
2797                 .help   = "IO memory buffer offset alignment",
2798                 .def    = "0",
2799                 .parent = "iomem",
2800                 .hide   = 1,
2801                 .category = FIO_OPT_C_IO,
2802                 .group  = FIO_OPT_G_INVALID,
2803         },
2804         {
2805                 .name   = "verify",
2806                 .lname  = "Verify",
2807                 .type   = FIO_OPT_STR,
2808                 .off1   = offsetof(struct thread_options, verify),
2809                 .help   = "Verify data written",
2810                 .def    = "0",
2811                 .category = FIO_OPT_C_IO,
2812                 .group  = FIO_OPT_G_VERIFY,
2813                 .posval = {
2814                           { .ival = "0",
2815                             .oval = VERIFY_NONE,
2816                             .help = "Don't do IO verification",
2817                           },
2818                           { .ival = "md5",
2819                             .oval = VERIFY_MD5,
2820                             .help = "Use md5 checksums for verification",
2821                           },
2822                           { .ival = "crc64",
2823                             .oval = VERIFY_CRC64,
2824                             .help = "Use crc64 checksums for verification",
2825                           },
2826                           { .ival = "crc32",
2827                             .oval = VERIFY_CRC32,
2828                             .help = "Use crc32 checksums for verification",
2829                           },
2830                           { .ival = "crc32c-intel",
2831                             .oval = VERIFY_CRC32C,
2832                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2833                           },
2834                           { .ival = "crc32c",
2835                             .oval = VERIFY_CRC32C,
2836                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2837                           },
2838                           { .ival = "crc16",
2839                             .oval = VERIFY_CRC16,
2840                             .help = "Use crc16 checksums for verification",
2841                           },
2842                           { .ival = "crc7",
2843                             .oval = VERIFY_CRC7,
2844                             .help = "Use crc7 checksums for verification",
2845                           },
2846                           { .ival = "sha1",
2847                             .oval = VERIFY_SHA1,
2848                             .help = "Use sha1 checksums for verification",
2849                           },
2850                           { .ival = "sha256",
2851                             .oval = VERIFY_SHA256,
2852                             .help = "Use sha256 checksums for verification",
2853                           },
2854                           { .ival = "sha512",
2855                             .oval = VERIFY_SHA512,
2856                             .help = "Use sha512 checksums for verification",
2857                           },
2858                           { .ival = "sha3-224",
2859                             .oval = VERIFY_SHA3_224,
2860                             .help = "Use sha3-224 checksums for verification",
2861                           },
2862                           { .ival = "sha3-256",
2863                             .oval = VERIFY_SHA3_256,
2864                             .help = "Use sha3-256 checksums for verification",
2865                           },
2866                           { .ival = "sha3-384",
2867                             .oval = VERIFY_SHA3_384,
2868                             .help = "Use sha3-384 checksums for verification",
2869                           },
2870                           { .ival = "sha3-512",
2871                             .oval = VERIFY_SHA3_512,
2872                             .help = "Use sha3-512 checksums for verification",
2873                           },
2874                           { .ival = "xxhash",
2875                             .oval = VERIFY_XXHASH,
2876                             .help = "Use xxhash checksums for verification",
2877                           },
2878                           /* Meta information was included into verify_header,
2879                            * 'meta' verification is implied by default. */
2880                           { .ival = "meta",
2881                             .oval = VERIFY_HDR_ONLY,
2882                             .help = "Use io information for verification. "
2883                                     "Now is implied by default, thus option is obsolete, "
2884                                     "don't use it",
2885                           },
2886                           { .ival = "pattern",
2887                             .oval = VERIFY_PATTERN_NO_HDR,
2888                             .help = "Verify strict pattern",
2889                           },
2890                           {
2891                             .ival = "null",
2892                             .oval = VERIFY_NULL,
2893                             .help = "Pretend to verify",
2894                           },
2895                 },
2896         },
2897         {
2898                 .name   = "do_verify",
2899                 .lname  = "Perform verify step",
2900                 .type   = FIO_OPT_BOOL,
2901                 .off1   = offsetof(struct thread_options, do_verify),
2902                 .help   = "Run verification stage after write",
2903                 .def    = "1",
2904                 .parent = "verify",
2905                 .hide   = 1,
2906                 .category = FIO_OPT_C_IO,
2907                 .group  = FIO_OPT_G_VERIFY,
2908         },
2909         {
2910                 .name   = "verifysort",
2911                 .lname  = "Verify sort",
2912                 .type   = FIO_OPT_SOFT_DEPRECATED,
2913                 .category = FIO_OPT_C_IO,
2914                 .group  = FIO_OPT_G_VERIFY,
2915         },
2916         {
2917                 .name   = "verifysort_nr",
2918                 .lname  = "Verify Sort Nr",
2919                 .type   = FIO_OPT_SOFT_DEPRECATED,
2920                 .category = FIO_OPT_C_IO,
2921                 .group  = FIO_OPT_G_VERIFY,
2922         },
2923         {
2924                 .name   = "verify_interval",
2925                 .lname  = "Verify interval",
2926                 .type   = FIO_OPT_INT,
2927                 .off1   = offsetof(struct thread_options, verify_interval),
2928                 .minval = 2 * sizeof(struct verify_header),
2929                 .help   = "Store verify buffer header every N bytes",
2930                 .parent = "verify",
2931                 .hide   = 1,
2932                 .interval = 2 * sizeof(struct verify_header),
2933                 .category = FIO_OPT_C_IO,
2934                 .group  = FIO_OPT_G_VERIFY,
2935         },
2936         {
2937                 .name   = "verify_offset",
2938                 .lname  = "Verify offset",
2939                 .type   = FIO_OPT_INT,
2940                 .help   = "Offset verify header location by N bytes",
2941                 .off1   = offsetof(struct thread_options, verify_offset),
2942                 .minval = sizeof(struct verify_header),
2943                 .parent = "verify",
2944                 .hide   = 1,
2945                 .category = FIO_OPT_C_IO,
2946                 .group  = FIO_OPT_G_VERIFY,
2947         },
2948         {
2949                 .name   = "verify_pattern",
2950                 .lname  = "Verify pattern",
2951                 .type   = FIO_OPT_STR,
2952                 .cb     = str_verify_pattern_cb,
2953                 .off1   = offsetof(struct thread_options, verify_pattern),
2954                 .help   = "Fill pattern for IO buffers",
2955                 .parent = "verify",
2956                 .hide   = 1,
2957                 .category = FIO_OPT_C_IO,
2958                 .group  = FIO_OPT_G_VERIFY,
2959         },
2960         {
2961                 .name   = "verify_fatal",
2962                 .lname  = "Verify fatal",
2963                 .type   = FIO_OPT_BOOL,
2964                 .off1   = offsetof(struct thread_options, verify_fatal),
2965                 .def    = "0",
2966                 .help   = "Exit on a single verify failure, don't continue",
2967                 .parent = "verify",
2968                 .hide   = 1,
2969                 .category = FIO_OPT_C_IO,
2970                 .group  = FIO_OPT_G_VERIFY,
2971         },
2972         {
2973                 .name   = "verify_dump",
2974                 .lname  = "Verify dump",
2975                 .type   = FIO_OPT_BOOL,
2976                 .off1   = offsetof(struct thread_options, verify_dump),
2977                 .def    = "0",
2978                 .help   = "Dump contents of good and bad blocks on failure",
2979                 .parent = "verify",
2980                 .hide   = 1,
2981                 .category = FIO_OPT_C_IO,
2982                 .group  = FIO_OPT_G_VERIFY,
2983         },
2984         {
2985                 .name   = "verify_async",
2986                 .lname  = "Verify asynchronously",
2987                 .type   = FIO_OPT_INT,
2988                 .off1   = offsetof(struct thread_options, verify_async),
2989                 .def    = "0",
2990                 .help   = "Number of async verifier threads to use",
2991                 .parent = "verify",
2992                 .hide   = 1,
2993                 .category = FIO_OPT_C_IO,
2994                 .group  = FIO_OPT_G_VERIFY,
2995         },
2996         {
2997                 .name   = "verify_backlog",
2998                 .lname  = "Verify backlog",
2999                 .type   = FIO_OPT_STR_VAL,
3000                 .off1   = offsetof(struct thread_options, verify_backlog),
3001                 .help   = "Verify after this number of blocks are written",
3002                 .parent = "verify",
3003                 .hide   = 1,
3004                 .category = FIO_OPT_C_IO,
3005                 .group  = FIO_OPT_G_VERIFY,
3006         },
3007         {
3008                 .name   = "verify_backlog_batch",
3009                 .lname  = "Verify backlog batch",
3010                 .type   = FIO_OPT_INT,
3011                 .off1   = offsetof(struct thread_options, verify_batch),
3012                 .help   = "Verify this number of IO blocks",
3013                 .parent = "verify",
3014                 .hide   = 1,
3015                 .category = FIO_OPT_C_IO,
3016                 .group  = FIO_OPT_G_VERIFY,
3017         },
3018 #ifdef FIO_HAVE_CPU_AFFINITY
3019         {
3020                 .name   = "verify_async_cpus",
3021                 .lname  = "Async verify CPUs",
3022                 .type   = FIO_OPT_STR,
3023                 .cb     = str_verify_cpus_allowed_cb,
3024                 .off1   = offsetof(struct thread_options, verify_cpumask),
3025                 .help   = "Set CPUs allowed for async verify threads",
3026                 .parent = "verify_async",
3027                 .hide   = 1,
3028                 .category = FIO_OPT_C_IO,
3029                 .group  = FIO_OPT_G_VERIFY,
3030         },
3031 #else
3032         {
3033                 .name   = "verify_async_cpus",
3034                 .lname  = "Async verify CPUs",
3035                 .type   = FIO_OPT_UNSUPPORTED,
3036                 .help   = "Your platform does not support CPU affinities",
3037         },
3038 #endif
3039         {
3040                 .name   = "experimental_verify",
3041                 .lname  = "Experimental Verify",
3042                 .off1   = offsetof(struct thread_options, experimental_verify),
3043                 .type   = FIO_OPT_BOOL,
3044                 .help   = "Enable experimental verification",
3045                 .parent = "verify",
3046                 .category = FIO_OPT_C_IO,
3047                 .group  = FIO_OPT_G_VERIFY,
3048         },
3049         {
3050                 .name   = "verify_state_load",
3051                 .lname  = "Load verify state",
3052                 .off1   = offsetof(struct thread_options, verify_state),
3053                 .type   = FIO_OPT_BOOL,
3054                 .help   = "Load verify termination state",
3055                 .parent = "verify",
3056                 .category = FIO_OPT_C_IO,
3057                 .group  = FIO_OPT_G_VERIFY,
3058         },
3059         {
3060                 .name   = "verify_state_save",
3061                 .lname  = "Save verify state",
3062                 .off1   = offsetof(struct thread_options, verify_state_save),
3063                 .type   = FIO_OPT_BOOL,
3064                 .def    = "1",
3065                 .help   = "Save verify state on termination",
3066                 .parent = "verify",
3067                 .category = FIO_OPT_C_IO,
3068                 .group  = FIO_OPT_G_VERIFY,
3069         },
3070 #ifdef FIO_HAVE_TRIM
3071         {
3072                 .name   = "trim_percentage",
3073                 .lname  = "Trim percentage",
3074                 .type   = FIO_OPT_INT,
3075                 .off1   = offsetof(struct thread_options, trim_percentage),
3076                 .minval = 0,
3077                 .maxval = 100,
3078                 .help   = "Number of verify blocks to trim (i.e., discard)",
3079                 .parent = "verify",
3080                 .def    = "0",
3081                 .interval = 1,
3082                 .hide   = 1,
3083                 .category = FIO_OPT_C_IO,
3084                 .group  = FIO_OPT_G_TRIM,
3085         },
3086         {
3087                 .name   = "trim_verify_zero",
3088                 .lname  = "Verify trim zero",
3089                 .type   = FIO_OPT_BOOL,
3090                 .help   = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
3091                 .off1   = offsetof(struct thread_options, trim_zero),
3092                 .parent = "trim_percentage",
3093                 .hide   = 1,
3094                 .def    = "1",
3095                 .category = FIO_OPT_C_IO,
3096                 .group  = FIO_OPT_G_TRIM,
3097         },
3098         {
3099                 .name   = "trim_backlog",
3100                 .lname  = "Trim backlog",
3101                 .type   = FIO_OPT_STR_VAL,
3102                 .off1   = offsetof(struct thread_options, trim_backlog),
3103                 .help   = "Trim after this number of blocks are written",
3104                 .parent = "trim_percentage",
3105                 .hide   = 1,
3106                 .interval = 1,
3107                 .category = FIO_OPT_C_IO,
3108                 .group  = FIO_OPT_G_TRIM,
3109         },
3110         {
3111                 .name   = "trim_backlog_batch",
3112                 .lname  = "Trim backlog batch",
3113                 .type   = FIO_OPT_INT,
3114                 .off1   = offsetof(struct thread_options, trim_batch),
3115                 .help   = "Trim this number of IO blocks",
3116                 .parent = "trim_percentage",
3117                 .hide   = 1,
3118                 .interval = 1,
3119                 .category = FIO_OPT_C_IO,
3120                 .group  = FIO_OPT_G_TRIM,
3121         },
3122 #else
3123         {
3124                 .name   = "trim_percentage",
3125                 .lname  = "Trim percentage",
3126                 .type   = FIO_OPT_UNSUPPORTED,
3127                 .help   = "Fio does not support TRIM on your platform",
3128         },
3129         {
3130                 .name   = "trim_verify_zero",
3131                 .lname  = "Verify trim zero",
3132                 .type   = FIO_OPT_UNSUPPORTED,
3133                 .help   = "Fio does not support TRIM on your platform",
3134         },
3135         {
3136                 .name   = "trim_backlog",
3137                 .lname  = "Trim backlog",
3138                 .type   = FIO_OPT_UNSUPPORTED,
3139                 .help   = "Fio does not support TRIM on your platform",
3140         },
3141         {
3142                 .name   = "trim_backlog_batch",
3143                 .lname  = "Trim backlog batch",
3144                 .type   = FIO_OPT_UNSUPPORTED,
3145                 .help   = "Fio does not support TRIM on your platform",
3146         },
3147 #endif
3148         {
3149                 .name   = "write_iolog",
3150                 .lname  = "Write I/O log",
3151                 .type   = FIO_OPT_STR_STORE,
3152                 .off1   = offsetof(struct thread_options, write_iolog_file),
3153                 .help   = "Store IO pattern to file",
3154                 .category = FIO_OPT_C_IO,
3155                 .group  = FIO_OPT_G_IOLOG,
3156         },
3157         {
3158                 .name   = "read_iolog",
3159                 .lname  = "Read I/O log",
3160                 .type   = FIO_OPT_STR_STORE,
3161                 .off1   = offsetof(struct thread_options, read_iolog_file),
3162                 .help   = "Playback IO pattern from file",
3163                 .category = FIO_OPT_C_IO,
3164                 .group  = FIO_OPT_G_IOLOG,
3165         },
3166         {
3167                 .name   = "read_iolog_chunked",
3168                 .lname  = "Read I/O log in parts",
3169                 .type   = FIO_OPT_BOOL,
3170                 .off1   = offsetof(struct thread_options, read_iolog_chunked),
3171                 .def    = "0",
3172                 .parent = "read_iolog",
3173                 .help   = "Parse IO pattern in chunks",
3174                 .category = FIO_OPT_C_IO,
3175                 .group  = FIO_OPT_G_IOLOG,
3176         },
3177         {
3178                 .name   = "replay_no_stall",
3179                 .lname  = "Don't stall on replay",
3180                 .type   = FIO_OPT_BOOL,
3181                 .off1   = offsetof(struct thread_options, no_stall),
3182                 .def    = "0",
3183                 .parent = "read_iolog",
3184                 .hide   = 1,
3185                 .help   = "Playback IO pattern file as fast as possible without stalls",
3186                 .category = FIO_OPT_C_IO,
3187                 .group  = FIO_OPT_G_IOLOG,
3188         },
3189         {
3190                 .name   = "replay_redirect",
3191                 .lname  = "Redirect device for replay",
3192                 .type   = FIO_OPT_STR_STORE,
3193                 .off1   = offsetof(struct thread_options, replay_redirect),
3194                 .parent = "read_iolog",
3195                 .hide   = 1,
3196                 .help   = "Replay all I/O onto this device, regardless of trace device",
3197                 .category = FIO_OPT_C_IO,
3198                 .group  = FIO_OPT_G_IOLOG,
3199         },
3200         {
3201                 .name   = "replay_scale",
3202                 .lname  = "Replace offset scale factor",
3203                 .type   = FIO_OPT_INT,
3204                 .off1   = offsetof(struct thread_options, replay_scale),
3205                 .parent = "read_iolog",
3206                 .def    = "1",
3207                 .help   = "Align offsets to this blocksize",
3208                 .category = FIO_OPT_C_IO,
3209                 .group  = FIO_OPT_G_IOLOG,
3210         },
3211         {
3212                 .name   = "replay_align",
3213                 .lname  = "Replace alignment",
3214                 .type   = FIO_OPT_INT,
3215                 .off1   = offsetof(struct thread_options, replay_align),
3216                 .parent = "read_iolog",
3217                 .help   = "Scale offset down by this factor",
3218                 .category = FIO_OPT_C_IO,
3219                 .group  = FIO_OPT_G_IOLOG,
3220                 .pow2   = 1,
3221         },
3222         {
3223                 .name   = "replay_time_scale",
3224                 .lname  = "Replay Time Scale",
3225                 .type   = FIO_OPT_INT,
3226                 .off1   = offsetof(struct thread_options, replay_time_scale),
3227                 .def    = "100",
3228                 .minval = 1,
3229                 .parent = "read_iolog",
3230                 .hide   = 1,
3231                 .help   = "Scale time for replay events",
3232                 .category = FIO_OPT_C_IO,
3233                 .group  = FIO_OPT_G_IOLOG,
3234         },
3235         {
3236                 .name   = "replay_skip",
3237                 .lname  = "Replay Skip",
3238                 .type   = FIO_OPT_STR,
3239                 .cb     = str_replay_skip_cb,
3240                 .off1   = offsetof(struct thread_options, replay_skip),
3241                 .parent = "read_iolog",
3242                 .help   = "Skip certain IO types (read,write,trim,flush)",
3243                 .category = FIO_OPT_C_IO,
3244                 .group  = FIO_OPT_G_IOLOG,
3245         },
3246         {
3247                 .name   = "merge_blktrace_file",
3248                 .lname  = "Merged blktrace output filename",
3249                 .type   = FIO_OPT_STR_STORE,
3250                 .off1   = offsetof(struct thread_options, merge_blktrace_file),
3251                 .help   = "Merged blktrace output filename",
3252                 .category = FIO_OPT_C_IO,
3253                 .group = FIO_OPT_G_IOLOG,
3254         },
3255         {
3256                 .name   = "merge_blktrace_scalars",
3257                 .lname  = "Percentage to scale each trace",
3258                 .type   = FIO_OPT_FLOAT_LIST,
3259                 .off1   = offsetof(struct thread_options, merge_blktrace_scalars),
3260                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3261                 .help   = "Percentage to scale each trace",
3262                 .category = FIO_OPT_C_IO,
3263                 .group  = FIO_OPT_G_IOLOG,
3264         },
3265         {
3266                 .name   = "merge_blktrace_iters",
3267                 .lname  = "Number of iterations to run per trace",
3268                 .type   = FIO_OPT_FLOAT_LIST,
3269                 .off1   = offsetof(struct thread_options, merge_blktrace_iters),
3270                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3271                 .help   = "Number of iterations to run per trace",
3272                 .category = FIO_OPT_C_IO,
3273                 .group  = FIO_OPT_G_IOLOG,
3274         },
3275         {
3276                 .name   = "exec_prerun",
3277                 .lname  = "Pre-execute runnable",
3278                 .type   = FIO_OPT_STR_STORE,
3279                 .off1   = offsetof(struct thread_options, exec_prerun),
3280                 .help   = "Execute this file prior to running job",
3281                 .category = FIO_OPT_C_GENERAL,
3282                 .group  = FIO_OPT_G_INVALID,
3283         },
3284         {
3285                 .name   = "exec_postrun",
3286                 .lname  = "Post-execute runnable",
3287                 .type   = FIO_OPT_STR_STORE,
3288                 .off1   = offsetof(struct thread_options, exec_postrun),
3289                 .help   = "Execute this file after running job",
3290                 .category = FIO_OPT_C_GENERAL,
3291                 .group  = FIO_OPT_G_INVALID,
3292         },
3293 #ifdef FIO_HAVE_IOSCHED_SWITCH
3294         {
3295                 .name   = "ioscheduler",
3296                 .lname  = "I/O scheduler",
3297                 .type   = FIO_OPT_STR_STORE,
3298                 .off1   = offsetof(struct thread_options, ioscheduler),
3299                 .help   = "Use this IO scheduler on the backing device",
3300                 .category = FIO_OPT_C_FILE,
3301                 .group  = FIO_OPT_G_INVALID,
3302         },
3303 #else
3304         {
3305                 .name   = "ioscheduler",
3306                 .lname  = "I/O scheduler",
3307                 .type   = FIO_OPT_UNSUPPORTED,
3308                 .help   = "Your platform does not support IO scheduler switching",
3309         },
3310 #endif
3311         {
3312                 .name   = "zonemode",
3313                 .lname  = "Zone mode",
3314                 .help   = "Mode for the zonesize, zonerange and zoneskip parameters",
3315                 .type   = FIO_OPT_STR,
3316                 .off1   = offsetof(struct thread_options, zone_mode),
3317                 .def    = "none",
3318                 .category = FIO_OPT_C_IO,
3319                 .group  = FIO_OPT_G_ZONE,
3320                 .posval = {
3321                            { .ival = "none",
3322                              .oval = ZONE_MODE_NONE,
3323                              .help = "no zoning",
3324                            },
3325                            { .ival = "strided",
3326                              .oval = ZONE_MODE_STRIDED,
3327                              .help = "strided mode - random I/O is restricted to a single zone",
3328                            },
3329                            { .ival = "zbd",
3330                              .oval = ZONE_MODE_ZBD,
3331                              .help = "zoned block device mode - random I/O selects one of multiple zones randomly",
3332                            },
3333                 },
3334         },
3335         {
3336                 .name   = "zonesize",
3337                 .lname  = "Zone size",
3338                 .type   = FIO_OPT_STR_VAL,
3339                 .off1   = offsetof(struct thread_options, zone_size),
3340                 .help   = "Amount of data to read per zone",
3341                 .def    = "0",
3342                 .interval = 1024 * 1024,
3343                 .category = FIO_OPT_C_IO,
3344                 .group  = FIO_OPT_G_ZONE,
3345         },
3346         {
3347                 .name   = "zonecapacity",
3348                 .lname  = "Zone capacity",
3349                 .type   = FIO_OPT_STR_VAL,
3350                 .off1   = offsetof(struct thread_options, zone_capacity),
3351                 .help   = "Capacity per zone",
3352                 .def    = "0",
3353                 .interval = 1024 * 1024,
3354                 .category = FIO_OPT_C_IO,
3355                 .group  = FIO_OPT_G_ZONE,
3356         },
3357         {
3358                 .name   = "zonerange",
3359                 .lname  = "Zone range",
3360                 .type   = FIO_OPT_STR_VAL,
3361                 .off1   = offsetof(struct thread_options, zone_range),
3362                 .help   = "Give size of an IO zone",
3363                 .def    = "0",
3364                 .interval = 1024 * 1024,
3365                 .category = FIO_OPT_C_IO,
3366                 .group  = FIO_OPT_G_ZONE,
3367         },
3368         {
3369                 .name   = "zoneskip",
3370                 .lname  = "Zone skip",
3371                 .type   = FIO_OPT_STR_VAL,
3372                 .off1   = offsetof(struct thread_options, zone_skip),
3373                 .help   = "Space between IO zones",
3374                 .def    = "0",
3375                 .interval = 1024 * 1024,
3376                 .category = FIO_OPT_C_IO,
3377                 .group  = FIO_OPT_G_ZONE,
3378         },
3379         {
3380                 .name   = "read_beyond_wp",
3381                 .lname  = "Allow reads beyond the zone write pointer",
3382                 .type   = FIO_OPT_BOOL,
3383                 .off1   = offsetof(struct thread_options, read_beyond_wp),
3384                 .help   = "Allow reads beyond the zone write pointer",
3385                 .def    = "0",
3386                 .category = FIO_OPT_C_IO,
3387                 .group  = FIO_OPT_G_INVALID,
3388         },
3389         {
3390                 .name   = "max_open_zones",
3391                 .lname  = "Per device/file maximum number of open zones",
3392                 .type   = FIO_OPT_INT,
3393                 .off1   = offsetof(struct thread_options, max_open_zones),
3394                 .maxval = ZBD_MAX_OPEN_ZONES,
3395                 .help   = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd",
3396                 .def    = "0",
3397                 .category = FIO_OPT_C_IO,
3398                 .group  = FIO_OPT_G_INVALID,
3399         },
3400         {
3401                 .name   = "job_max_open_zones",
3402                 .lname  = "Job maximum number of open zones",
3403                 .type   = FIO_OPT_INT,
3404                 .off1   = offsetof(struct thread_options, job_max_open_zones),
3405                 .maxval = ZBD_MAX_OPEN_ZONES,
3406                 .help   = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd by one thread/process",
3407                 .def    = "0",
3408                 .category = FIO_OPT_C_IO,
3409                 .group  = FIO_OPT_G_INVALID,
3410         },
3411         {
3412                 .name   = "zone_reset_threshold",
3413                 .lname  = "Zone reset threshold",
3414                 .help   = "Zoned block device reset threshold",
3415                 .type   = FIO_OPT_FLOAT_LIST,
3416                 .maxlen = 1,
3417                 .off1   = offsetof(struct thread_options, zrt),
3418                 .minfp  = 0,
3419                 .maxfp  = 1,
3420                 .category = FIO_OPT_C_IO,
3421                 .group  = FIO_OPT_G_ZONE,
3422         },
3423         {
3424                 .name   = "zone_reset_frequency",
3425                 .lname  = "Zone reset frequency",
3426                 .help   = "Zoned block device zone reset frequency in HZ",
3427                 .type   = FIO_OPT_FLOAT_LIST,
3428                 .maxlen = 1,
3429                 .off1   = offsetof(struct thread_options, zrf),
3430                 .minfp  = 0,
3431                 .maxfp  = 1,
3432                 .category = FIO_OPT_C_IO,
3433                 .group  = FIO_OPT_G_ZONE,
3434         },
3435         {
3436                 .name   = "lockmem",
3437                 .lname  = "Lock memory",
3438                 .type   = FIO_OPT_STR_VAL,
3439                 .off1   = offsetof(struct thread_options, lockmem),
3440                 .help   = "Lock down this amount of memory (per worker)",
3441                 .def    = "0",
3442                 .interval = 1024 * 1024,
3443                 .category = FIO_OPT_C_GENERAL,
3444                 .group  = FIO_OPT_G_INVALID,
3445         },
3446         {
3447                 .name   = "rwmixread",
3448                 .lname  = "Read/write mix read",
3449                 .type   = FIO_OPT_INT,
3450                 .cb     = str_rwmix_read_cb,
3451                 .off1   = offsetof(struct thread_options, rwmix[DDIR_READ]),
3452                 .maxval = 100,
3453                 .help   = "Percentage of mixed workload that is reads",
3454                 .def    = "50",
3455                 .interval = 5,
3456                 .inverse = "rwmixwrite",
3457                 .category = FIO_OPT_C_IO,
3458                 .group  = FIO_OPT_G_RWMIX,
3459         },
3460         {
3461                 .name   = "rwmixwrite",
3462                 .lname  = "Read/write mix write",
3463                 .type   = FIO_OPT_INT,
3464                 .cb     = str_rwmix_write_cb,
3465                 .off1   = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3466                 .maxval = 100,
3467                 .help   = "Percentage of mixed workload that is writes",
3468                 .def    = "50",
3469                 .interval = 5,
3470                 .inverse = "rwmixread",
3471                 .category = FIO_OPT_C_IO,
3472                 .group  = FIO_OPT_G_RWMIX,
3473         },
3474         {
3475                 .name   = "rwmixcycle",
3476                 .lname  = "Read/write mix cycle",
3477                 .type   = FIO_OPT_DEPRECATED,
3478                 .category = FIO_OPT_C_IO,
3479                 .group  = FIO_OPT_G_RWMIX,
3480         },
3481         {
3482                 .name   = "nice",
3483                 .lname  = "Nice",
3484                 .type   = FIO_OPT_INT,
3485                 .off1   = offsetof(struct thread_options, nice),
3486                 .help   = "Set job CPU nice value",
3487                 .minval = -20,
3488                 .maxval = 19,
3489                 .def    = "0",
3490                 .interval = 1,
3491                 .category = FIO_OPT_C_GENERAL,
3492                 .group  = FIO_OPT_G_CRED,
3493         },
3494 #ifdef FIO_HAVE_IOPRIO
3495         {
3496                 .name   = "prio",
3497                 .lname  = "I/O nice priority",
3498                 .type   = FIO_OPT_INT,
3499                 .off1   = offsetof(struct thread_options, ioprio),
3500                 .help   = "Set job IO priority value",
3501                 .minval = IOPRIO_MIN_PRIO,
3502                 .maxval = IOPRIO_MAX_PRIO,
3503                 .interval = 1,
3504                 .category = FIO_OPT_C_GENERAL,
3505                 .group  = FIO_OPT_G_CRED,
3506         },
3507 #else
3508         {
3509                 .name   = "prio",
3510                 .lname  = "I/O nice priority",
3511                 .type   = FIO_OPT_UNSUPPORTED,
3512                 .help   = "Your platform does not support IO priorities",
3513         },
3514 #endif
3515 #ifdef FIO_HAVE_IOPRIO_CLASS
3516 #ifndef FIO_HAVE_IOPRIO
3517 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3518 #endif
3519         {
3520                 .name   = "prioclass",
3521                 .lname  = "I/O nice priority class",
3522                 .type   = FIO_OPT_INT,
3523                 .off1   = offsetof(struct thread_options, ioprio_class),
3524                 .help   = "Set job IO priority class",
3525                 .minval = IOPRIO_MIN_PRIO_CLASS,
3526                 .maxval = IOPRIO_MAX_PRIO_CLASS,
3527                 .interval = 1,
3528                 .category = FIO_OPT_C_GENERAL,
3529                 .group  = FIO_OPT_G_CRED,
3530         },
3531 #else
3532         {
3533                 .name   = "prioclass",
3534                 .lname  = "I/O nice priority class",
3535                 .type   = FIO_OPT_UNSUPPORTED,
3536                 .help   = "Your platform does not support IO priority classes",
3537         },
3538 #endif
3539         {
3540                 .name   = "thinktime",
3541                 .lname  = "Thinktime",
3542                 .type   = FIO_OPT_INT,
3543                 .off1   = offsetof(struct thread_options, thinktime),
3544                 .help   = "Idle time between IO buffers (usec)",
3545                 .def    = "0",
3546                 .is_time = 1,
3547                 .category = FIO_OPT_C_IO,
3548                 .group  = FIO_OPT_G_THINKTIME,
3549         },
3550         {
3551                 .name   = "thinktime_spin",
3552                 .lname  = "Thinktime spin",
3553                 .type   = FIO_OPT_INT,
3554                 .off1   = offsetof(struct thread_options, thinktime_spin),
3555                 .help   = "Start think time by spinning this amount (usec)",
3556                 .def    = "0",
3557                 .is_time = 1,
3558                 .parent = "thinktime",
3559                 .hide   = 1,
3560                 .category = FIO_OPT_C_IO,
3561                 .group  = FIO_OPT_G_THINKTIME,
3562         },
3563         {
3564                 .name   = "thinktime_blocks",
3565                 .lname  = "Thinktime blocks",
3566                 .type   = FIO_OPT_INT,
3567                 .off1   = offsetof(struct thread_options, thinktime_blocks),
3568                 .help   = "IO buffer period between 'thinktime'",
3569                 .def    = "1",
3570                 .parent = "thinktime",
3571                 .hide   = 1,
3572                 .category = FIO_OPT_C_IO,
3573                 .group  = FIO_OPT_G_THINKTIME,
3574         },
3575         {
3576                 .name   = "rate",
3577                 .lname  = "I/O rate",
3578                 .type   = FIO_OPT_ULL,
3579                 .off1   = offsetof(struct thread_options, rate[DDIR_READ]),
3580                 .off2   = offsetof(struct thread_options, rate[DDIR_WRITE]),
3581                 .off3   = offsetof(struct thread_options, rate[DDIR_TRIM]),
3582                 .help   = "Set bandwidth rate",
3583                 .category = FIO_OPT_C_IO,
3584                 .group  = FIO_OPT_G_RATE,
3585         },
3586         {
3587                 .name   = "rate_min",
3588                 .alias  = "ratemin",
3589                 .lname  = "I/O min rate",
3590                 .type   = FIO_OPT_ULL,
3591                 .off1   = offsetof(struct thread_options, ratemin[DDIR_READ]),
3592                 .off2   = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3593                 .off3   = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3594                 .help   = "Job must meet this rate or it will be shutdown",
3595                 .parent = "rate",
3596                 .hide   = 1,
3597                 .category = FIO_OPT_C_IO,
3598                 .group  = FIO_OPT_G_RATE,
3599         },
3600         {
3601                 .name   = "rate_iops",
3602                 .lname  = "I/O rate IOPS",
3603                 .type   = FIO_OPT_INT,
3604                 .off1   = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3605                 .off2   = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3606                 .off3   = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3607                 .help   = "Limit IO used to this number of IO operations/sec",
3608                 .hide   = 1,
3609                 .category = FIO_OPT_C_IO,
3610                 .group  = FIO_OPT_G_RATE,
3611         },
3612         {
3613                 .name   = "rate_iops_min",
3614                 .lname  = "I/O min rate IOPS",
3615                 .type   = FIO_OPT_INT,
3616                 .off1   = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3617                 .off2   = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3618                 .off3   = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3619                 .help   = "Job must meet this rate or it will be shut down",
3620                 .parent = "rate_iops",
3621                 .hide   = 1,
3622                 .category = FIO_OPT_C_IO,
3623                 .group  = FIO_OPT_G_RATE,
3624         },
3625         {
3626                 .name   = "rate_process",
3627                 .lname  = "Rate Process",
3628                 .type   = FIO_OPT_STR,
3629                 .off1   = offsetof(struct thread_options, rate_process),
3630                 .help   = "What process controls how rated IO is managed",
3631                 .def    = "linear",
3632                 .category = FIO_OPT_C_IO,
3633                 .group  = FIO_OPT_G_RATE,
3634                 .posval = {
3635                           { .ival = "linear",
3636                             .oval = RATE_PROCESS_LINEAR,
3637                             .help = "Linear rate of IO",
3638                           },
3639                           {
3640                             .ival = "poisson",
3641                             .oval = RATE_PROCESS_POISSON,
3642                             .help = "Rate follows Poisson process",
3643                           },
3644                 },
3645                 .parent = "rate",
3646         },
3647         {
3648                 .name   = "rate_cycle",
3649                 .alias  = "ratecycle",
3650                 .lname  = "I/O rate cycle",
3651                 .type   = FIO_OPT_INT,
3652                 .off1   = offsetof(struct thread_options, ratecycle),
3653                 .help   = "Window average for rate limits (msec)",
3654                 .def    = "1000",
3655                 .parent = "rate",
3656                 .hide   = 1,
3657                 .category = FIO_OPT_C_IO,
3658                 .group  = FIO_OPT_G_RATE,
3659         },
3660         {
3661                 .name   = "rate_ignore_thinktime",
3662                 .lname  = "Rate ignore thinktime",
3663                 .type   = FIO_OPT_BOOL,
3664                 .off1   = offsetof(struct thread_options, rate_ign_think),
3665                 .help   = "Rated IO ignores thinktime settings",
3666                 .parent = "rate",
3667                 .category = FIO_OPT_C_IO,
3668                 .group  = FIO_OPT_G_RATE,
3669         },
3670         {
3671                 .name   = "max_latency",
3672                 .lname  = "Max Latency (usec)",
3673                 .type   = FIO_OPT_STR_VAL_TIME,
3674                 .off1   = offsetof(struct thread_options, max_latency),
3675                 .help   = "Maximum tolerated IO latency (usec)",
3676                 .is_time = 1,
3677                 .category = FIO_OPT_C_IO,
3678                 .group = FIO_OPT_G_LATPROF,
3679         },
3680         {
3681                 .name   = "latency_target",
3682                 .lname  = "Latency Target (usec)",
3683                 .type   = FIO_OPT_STR_VAL_TIME,
3684                 .off1   = offsetof(struct thread_options, latency_target),
3685                 .help   = "Ramp to max queue depth supporting this latency",
3686                 .is_time = 1,
3687                 .category = FIO_OPT_C_IO,
3688                 .group  = FIO_OPT_G_LATPROF,
3689         },
3690         {
3691                 .name   = "latency_window",
3692                 .lname  = "Latency Window (usec)",
3693                 .type   = FIO_OPT_STR_VAL_TIME,
3694                 .off1   = offsetof(struct thread_options, latency_window),
3695                 .help   = "Time to sustain latency_target",
3696                 .is_time = 1,
3697                 .category = FIO_OPT_C_IO,
3698                 .group  = FIO_OPT_G_LATPROF,
3699         },
3700         {
3701                 .name   = "latency_percentile",
3702                 .lname  = "Latency Percentile",
3703                 .type   = FIO_OPT_FLOAT_LIST,
3704                 .off1   = offsetof(struct thread_options, latency_percentile),
3705                 .help   = "Percentile of IOs must be below latency_target",
3706                 .def    = "100",
3707                 .maxlen = 1,
3708                 .minfp  = 0.0,
3709                 .maxfp  = 100.0,
3710                 .category = FIO_OPT_C_IO,
3711                 .group  = FIO_OPT_G_LATPROF,
3712         },
3713         {
3714                 .name   = "latency_run",
3715                 .lname  = "Latency Run",
3716                 .type   = FIO_OPT_BOOL,
3717                 .off1   = offsetof(struct thread_options, latency_run),
3718                 .help   = "Keep adjusting queue depth to match latency_target",
3719                 .def    = "0",
3720                 .category = FIO_OPT_C_IO,
3721                 .group  = FIO_OPT_G_LATPROF,
3722         },
3723         {
3724                 .name   = "invalidate",
3725                 .lname  = "Cache invalidate",
3726                 .type   = FIO_OPT_BOOL,
3727                 .off1   = offsetof(struct thread_options, invalidate_cache),
3728                 .help   = "Invalidate buffer/page cache prior to running job",
3729                 .def    = "1",
3730                 .category = FIO_OPT_C_IO,
3731                 .group  = FIO_OPT_G_IO_TYPE,
3732         },
3733         {
3734                 .name   = "sync",
3735                 .lname  = "Synchronous I/O",
3736                 .type   = FIO_OPT_BOOL,
3737                 .off1   = offsetof(struct thread_options, sync_io),
3738                 .help   = "Use O_SYNC for buffered writes",
3739                 .def    = "0",
3740                 .parent = "buffered",
3741                 .hide   = 1,
3742                 .category = FIO_OPT_C_IO,
3743                 .group  = FIO_OPT_G_IO_TYPE,
3744         },
3745 #ifdef FIO_HAVE_WRITE_HINT
3746         {
3747                 .name   = "write_hint",
3748                 .lname  = "Write hint",
3749                 .type   = FIO_OPT_STR,
3750                 .off1   = offsetof(struct thread_options, write_hint),
3751                 .help   = "Set expected write life time",
3752                 .category = FIO_OPT_C_ENGINE,
3753                 .group  = FIO_OPT_G_INVALID,
3754                 .posval = {
3755                           { .ival = "none",
3756                             .oval = RWH_WRITE_LIFE_NONE,
3757                           },
3758                           { .ival = "short",
3759                             .oval = RWH_WRITE_LIFE_SHORT,
3760                           },
3761                           { .ival = "medium",
3762                             .oval = RWH_WRITE_LIFE_MEDIUM,
3763                           },
3764                           { .ival = "long",
3765                             .oval = RWH_WRITE_LIFE_LONG,
3766                           },
3767                           { .ival = "extreme",
3768                             .oval = RWH_WRITE_LIFE_EXTREME,
3769                           },
3770                 },
3771         },
3772 #endif
3773         {
3774                 .name   = "create_serialize",
3775                 .lname  = "Create serialize",
3776                 .type   = FIO_OPT_BOOL,
3777                 .off1   = offsetof(struct thread_options, create_serialize),
3778                 .help   = "Serialize creation of job files",
3779                 .def    = "1",
3780                 .category = FIO_OPT_C_FILE,
3781                 .group  = FIO_OPT_G_INVALID,
3782         },
3783         {
3784                 .name   = "create_fsync",
3785                 .lname  = "Create fsync",
3786                 .type   = FIO_OPT_BOOL,
3787                 .off1   = offsetof(struct thread_options, create_fsync),
3788                 .help   = "fsync file after creation",
3789                 .def    = "1",
3790                 .category = FIO_OPT_C_FILE,
3791                 .group  = FIO_OPT_G_INVALID,
3792         },
3793         {
3794                 .name   = "create_on_open",
3795                 .lname  = "Create on open",
3796                 .type   = FIO_OPT_BOOL,
3797                 .off1   = offsetof(struct thread_options, create_on_open),
3798                 .help   = "Create files when they are opened for IO",
3799                 .def    = "0",
3800                 .category = FIO_OPT_C_FILE,
3801                 .group  = FIO_OPT_G_INVALID,
3802         },
3803         {
3804                 .name   = "create_only",
3805                 .lname  = "Create Only",
3806                 .type   = FIO_OPT_BOOL,
3807                 .off1   = offsetof(struct thread_options, create_only),
3808                 .help   = "Only perform file creation phase",
3809                 .category = FIO_OPT_C_FILE,
3810                 .def    = "0",
3811         },
3812         {
3813                 .name   = "allow_file_create",
3814                 .lname  = "Allow file create",
3815                 .type   = FIO_OPT_BOOL,
3816                 .off1   = offsetof(struct thread_options, allow_create),
3817                 .help   = "Permit fio to create files, if they don't exist",
3818                 .def    = "1",
3819                 .category = FIO_OPT_C_FILE,
3820                 .group  = FIO_OPT_G_FILENAME,
3821         },
3822         {
3823                 .name   = "allow_mounted_write",
3824                 .lname  = "Allow mounted write",
3825                 .type   = FIO_OPT_BOOL,
3826                 .off1   = offsetof(struct thread_options, allow_mounted_write),
3827                 .help   = "Allow writes to a mounted partition",
3828                 .def    = "0",
3829                 .category = FIO_OPT_C_FILE,
3830                 .group  = FIO_OPT_G_FILENAME,
3831         },
3832         {
3833                 .name   = "pre_read",
3834                 .lname  = "Pre-read files",
3835                 .type   = FIO_OPT_BOOL,
3836                 .off1   = offsetof(struct thread_options, pre_read),
3837                 .help   = "Pre-read files before starting official testing",
3838                 .def    = "0",
3839                 .category = FIO_OPT_C_FILE,
3840                 .group  = FIO_OPT_G_INVALID,
3841         },
3842 #ifdef FIO_HAVE_CPU_AFFINITY
3843         {
3844                 .name   = "cpumask",
3845                 .lname  = "CPU mask",
3846                 .type   = FIO_OPT_INT,
3847                 .cb     = str_cpumask_cb,
3848                 .off1   = offsetof(struct thread_options, cpumask),
3849                 .help   = "CPU affinity mask",
3850                 .category = FIO_OPT_C_GENERAL,
3851                 .group  = FIO_OPT_G_CRED,
3852         },
3853         {
3854                 .name   = "cpus_allowed",
3855                 .lname  = "CPUs allowed",
3856                 .type   = FIO_OPT_STR,
3857                 .cb     = str_cpus_allowed_cb,
3858                 .off1   = offsetof(struct thread_options, cpumask),
3859                 .help   = "Set CPUs allowed",
3860                 .category = FIO_OPT_C_GENERAL,
3861                 .group  = FIO_OPT_G_CRED,
3862         },
3863         {
3864                 .name   = "cpus_allowed_policy",
3865                 .lname  = "CPUs allowed distribution policy",
3866                 .type   = FIO_OPT_STR,
3867                 .off1   = offsetof(struct thread_options, cpus_allowed_policy),
3868                 .help   = "Distribution policy for cpus_allowed",
3869                 .parent = "cpus_allowed",
3870                 .prio   = 1,
3871                 .posval = {
3872                           { .ival = "shared",
3873                             .oval = FIO_CPUS_SHARED,
3874                             .help = "Mask shared between threads",
3875                           },
3876                           { .ival = "split",
3877                             .oval = FIO_CPUS_SPLIT,
3878                             .help = "Mask split between threads",
3879                           },
3880                 },
3881                 .category = FIO_OPT_C_GENERAL,
3882                 .group  = FIO_OPT_G_CRED,
3883         },
3884 #else
3885         {
3886                 .name   = "cpumask",
3887                 .lname  = "CPU mask",
3888                 .type   = FIO_OPT_UNSUPPORTED,
3889                 .help   = "Your platform does not support CPU affinities",
3890         },
3891         {
3892                 .name   = "cpus_allowed",
3893                 .lname  = "CPUs allowed",
3894                 .type   = FIO_OPT_UNSUPPORTED,
3895                 .help   = "Your platform does not support CPU affinities",
3896         },
3897         {
3898                 .name   = "cpus_allowed_policy",
3899                 .lname  = "CPUs allowed distribution policy",
3900                 .type   = FIO_OPT_UNSUPPORTED,
3901                 .help   = "Your platform does not support CPU affinities",
3902         },
3903 #endif
3904 #ifdef CONFIG_LIBNUMA
3905         {
3906                 .name   = "numa_cpu_nodes",
3907                 .lname  = "NUMA CPU Nodes",
3908                 .type   = FIO_OPT_STR,
3909                 .cb     = str_numa_cpunodes_cb,
3910                 .off1   = offsetof(struct thread_options, numa_cpunodes),
3911                 .help   = "NUMA CPU nodes bind",
3912                 .category = FIO_OPT_C_GENERAL,
3913                 .group  = FIO_OPT_G_INVALID,
3914         },
3915         {
3916                 .name   = "numa_mem_policy",
3917                 .lname  = "NUMA Memory Policy",
3918                 .type   = FIO_OPT_STR,
3919                 .cb     = str_numa_mpol_cb,
3920                 .off1   = offsetof(struct thread_options, numa_memnodes),
3921                 .help   = "NUMA memory policy setup",
3922                 .category = FIO_OPT_C_GENERAL,
3923                 .group  = FIO_OPT_G_INVALID,
3924         },
3925 #else
3926         {
3927                 .name   = "numa_cpu_nodes",
3928                 .lname  = "NUMA CPU Nodes",
3929                 .type   = FIO_OPT_UNSUPPORTED,
3930                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3931         },
3932         {
3933                 .name   = "numa_mem_policy",
3934                 .lname  = "NUMA Memory Policy",
3935                 .type   = FIO_OPT_UNSUPPORTED,
3936                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3937         },
3938 #endif
3939 #ifdef CONFIG_CUDA
3940         {
3941                 .name   = "gpu_dev_id",
3942                 .lname  = "GPU device ID",
3943                 .type   = FIO_OPT_INT,
3944                 .off1   = offsetof(struct thread_options, gpu_dev_id),
3945                 .help   = "Set GPU device ID for GPUDirect RDMA",
3946                 .def    = "0",
3947                 .category = FIO_OPT_C_GENERAL,
3948                 .group  = FIO_OPT_G_INVALID,
3949         },
3950 #endif
3951         {
3952                 .name   = "end_fsync",
3953                 .lname  = "End fsync",
3954                 .type   = FIO_OPT_BOOL,
3955                 .off1   = offsetof(struct thread_options, end_fsync),
3956                 .help   = "Include fsync at the end of job",
3957                 .def    = "0",
3958                 .category = FIO_OPT_C_FILE,
3959                 .group  = FIO_OPT_G_INVALID,
3960         },
3961         {
3962                 .name   = "fsync_on_close",
3963                 .lname  = "Fsync on close",
3964                 .type   = FIO_OPT_BOOL,
3965                 .off1   = offsetof(struct thread_options, fsync_on_close),
3966                 .help   = "fsync files on close",
3967                 .def    = "0",
3968                 .category = FIO_OPT_C_FILE,
3969                 .group  = FIO_OPT_G_INVALID,
3970         },
3971         {
3972                 .name   = "unlink",
3973                 .lname  = "Unlink file",
3974                 .type   = FIO_OPT_BOOL,
3975                 .off1   = offsetof(struct thread_options, unlink),
3976                 .help   = "Unlink created files after job has completed",
3977                 .def    = "0",
3978                 .category = FIO_OPT_C_FILE,
3979                 .group  = FIO_OPT_G_INVALID,
3980         },
3981         {
3982                 .name   = "unlink_each_loop",
3983                 .lname  = "Unlink file after each loop of a job",
3984                 .type   = FIO_OPT_BOOL,
3985                 .off1   = offsetof(struct thread_options, unlink_each_loop),
3986                 .help   = "Unlink created files after each loop in a job has completed",
3987                 .def    = "0",
3988                 .category = FIO_OPT_C_FILE,
3989                 .group  = FIO_OPT_G_INVALID,
3990         },
3991         {
3992                 .name   = "exitall",
3993                 .lname  = "Exit-all on terminate",
3994                 .type   = FIO_OPT_STR_SET,
3995                 .cb     = str_exitall_cb,
3996                 .help   = "Terminate all jobs when one exits",
3997                 .category = FIO_OPT_C_GENERAL,
3998                 .group  = FIO_OPT_G_PROCESS,
3999         },
4000         {
4001                 .name   = "exit_what",
4002                 .lname  = "What jobs to quit on terminate",
4003                 .type   = FIO_OPT_STR,
4004                 .off1   = offsetof(struct thread_options, exit_what),
4005                 .help   = "Fine-grained control for exitall",
4006                 .def    = "group",
4007                 .category = FIO_OPT_C_GENERAL,
4008                 .group  = FIO_OPT_G_PROCESS,
4009                 .posval = {
4010                           { .ival = "group",
4011                             .oval = TERMINATE_GROUP,
4012                             .help = "exit_all=1 default behaviour",
4013                           },
4014                           { .ival = "stonewall",
4015                             .oval = TERMINATE_STONEWALL,
4016                             .help = "quit all currently running jobs; continue with next stonewall",
4017                           },
4018                           { .ival = "all",
4019                             .oval = TERMINATE_ALL,
4020                             .help = "Quit everything",
4021                           },
4022                 },
4023         },
4024         {
4025                 .name   = "exitall_on_error",
4026                 .lname  = "Exit-all on terminate in error",
4027                 .type   = FIO_OPT_STR_SET,
4028                 .off1   = offsetof(struct thread_options, exitall_error),
4029                 .help   = "Terminate all jobs when one exits in error",
4030                 .category = FIO_OPT_C_GENERAL,
4031                 .group  = FIO_OPT_G_PROCESS,
4032         },
4033         {
4034                 .name   = "stonewall",
4035                 .lname  = "Wait for previous",
4036                 .alias  = "wait_for_previous",
4037                 .type   = FIO_OPT_STR_SET,
4038                 .off1   = offsetof(struct thread_options, stonewall),
4039                 .help   = "Insert a hard barrier between this job and previous",
4040                 .category = FIO_OPT_C_GENERAL,
4041                 .group  = FIO_OPT_G_PROCESS,
4042         },
4043         {
4044                 .name   = "new_group",
4045                 .lname  = "New group",
4046                 .type   = FIO_OPT_STR_SET,
4047                 .off1   = offsetof(struct thread_options, new_group),
4048                 .help   = "Mark the start of a new group (for reporting)",
4049                 .category = FIO_OPT_C_GENERAL,
4050                 .group  = FIO_OPT_G_PROCESS,
4051         },
4052         {
4053                 .name   = "thread",
4054                 .lname  = "Thread",
4055                 .type   = FIO_OPT_STR_SET,
4056                 .off1   = offsetof(struct thread_options, use_thread),
4057                 .help   = "Use threads instead of processes",
4058 #ifdef CONFIG_NO_SHM
4059                 .def    = "1",
4060                 .no_warn_def = 1,
4061 #endif
4062                 .category = FIO_OPT_C_GENERAL,
4063                 .group  = FIO_OPT_G_PROCESS,
4064         },
4065         {
4066                 .name   = "per_job_logs",
4067                 .lname  = "Per Job Logs",
4068                 .type   = FIO_OPT_BOOL,
4069                 .off1   = offsetof(struct thread_options, per_job_logs),
4070                 .help   = "Include job number in generated log files or not",
4071                 .def    = "1",
4072                 .category = FIO_OPT_C_LOG,
4073                 .group  = FIO_OPT_G_INVALID,
4074         },
4075         {
4076                 .name   = "write_bw_log",
4077                 .lname  = "Write bandwidth log",
4078                 .type   = FIO_OPT_STR,
4079                 .off1   = offsetof(struct thread_options, bw_log_file),
4080                 .cb     = str_write_bw_log_cb,
4081                 .help   = "Write log of bandwidth during run",
4082                 .category = FIO_OPT_C_LOG,
4083                 .group  = FIO_OPT_G_INVALID,
4084         },
4085         {
4086                 .name   = "write_lat_log",
4087                 .lname  = "Write latency log",
4088                 .type   = FIO_OPT_STR,
4089                 .off1   = offsetof(struct thread_options, lat_log_file),
4090                 .cb     = str_write_lat_log_cb,
4091                 .help   = "Write log of latency during run",
4092                 .category = FIO_OPT_C_LOG,
4093                 .group  = FIO_OPT_G_INVALID,
4094         },
4095         {
4096                 .name   = "write_iops_log",
4097                 .lname  = "Write IOPS log",
4098                 .type   = FIO_OPT_STR,
4099                 .off1   = offsetof(struct thread_options, iops_log_file),
4100                 .cb     = str_write_iops_log_cb,
4101                 .help   = "Write log of IOPS during run",
4102                 .category = FIO_OPT_C_LOG,
4103                 .group  = FIO_OPT_G_INVALID,
4104         },
4105         {
4106                 .name   = "log_avg_msec",
4107                 .lname  = "Log averaging (msec)",
4108                 .type   = FIO_OPT_INT,
4109                 .off1   = offsetof(struct thread_options, log_avg_msec),
4110                 .help   = "Average bw/iops/lat logs over this period of time",
4111                 .def    = "0",
4112                 .category = FIO_OPT_C_LOG,
4113                 .group  = FIO_OPT_G_INVALID,
4114         },
4115         {
4116                 .name   = "log_hist_msec",
4117                 .lname  = "Log histograms (msec)",
4118                 .type   = FIO_OPT_INT,
4119                 .off1   = offsetof(struct thread_options, log_hist_msec),
4120                 .help   = "Dump completion latency histograms at frequency of this time value",
4121                 .def    = "0",
4122                 .category = FIO_OPT_C_LOG,
4123                 .group  = FIO_OPT_G_INVALID,
4124         },
4125         {
4126                 .name   = "log_hist_coarseness",
4127                 .lname  = "Histogram logs coarseness",
4128                 .type   = FIO_OPT_INT,
4129                 .off1   = offsetof(struct thread_options, log_hist_coarseness),
4130                 .help   = "Integer in range [0,6]. Higher coarseness outputs"
4131                         " fewer histogram bins per sample. The number of bins for"
4132                         " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
4133                 .def    = "0",
4134                 .category = FIO_OPT_C_LOG,
4135                 .group  = FIO_OPT_G_INVALID,
4136         },
4137         {
4138                 .name   = "write_hist_log",
4139                 .lname  = "Write latency histogram logs",
4140                 .type   = FIO_OPT_STR,
4141                 .off1   = offsetof(struct thread_options, hist_log_file),
4142                 .cb     = str_write_hist_log_cb,
4143                 .help   = "Write log of latency histograms during run",
4144                 .category = FIO_OPT_C_LOG,
4145                 .group  = FIO_OPT_G_INVALID,
4146         },
4147         {
4148                 .name   = "log_max_value",
4149                 .lname  = "Log maximum instead of average",
4150                 .type   = FIO_OPT_BOOL,
4151                 .off1   = offsetof(struct thread_options, log_max),
4152                 .help   = "Log max sample in a window instead of average",
4153                 .def    = "0",
4154                 .category = FIO_OPT_C_LOG,
4155                 .group  = FIO_OPT_G_INVALID,
4156         },
4157         {
4158                 .name   = "log_offset",
4159                 .lname  = "Log offset of IO",
4160                 .type   = FIO_OPT_BOOL,
4161                 .off1   = offsetof(struct thread_options, log_offset),
4162                 .help   = "Include offset of IO for each log entry",
4163                 .def    = "0",
4164                 .category = FIO_OPT_C_LOG,
4165                 .group  = FIO_OPT_G_INVALID,
4166         },
4167 #ifdef CONFIG_ZLIB
4168         {
4169                 .name   = "log_compression",
4170                 .lname  = "Log compression",
4171                 .type   = FIO_OPT_INT,
4172                 .off1   = offsetof(struct thread_options, log_gz),
4173                 .help   = "Log in compressed chunks of this size",
4174                 .minval = 1024ULL,
4175                 .maxval = 512 * 1024 * 1024ULL,
4176                 .category = FIO_OPT_C_LOG,
4177                 .group  = FIO_OPT_G_INVALID,
4178         },
4179 #ifdef FIO_HAVE_CPU_AFFINITY
4180         {
4181                 .name   = "log_compression_cpus",
4182                 .lname  = "Log Compression CPUs",
4183                 .type   = FIO_OPT_STR,
4184                 .cb     = str_log_cpus_allowed_cb,
4185                 .off1   = offsetof(struct thread_options, log_gz_cpumask),
4186                 .parent = "log_compression",
4187                 .help   = "Limit log compression to these CPUs",
4188                 .category = FIO_OPT_C_LOG,
4189                 .group  = FIO_OPT_G_INVALID,
4190         },
4191 #else
4192         {
4193                 .name   = "log_compression_cpus",
4194                 .lname  = "Log Compression CPUs",
4195                 .type   = FIO_OPT_UNSUPPORTED,
4196                 .help   = "Your platform does not support CPU affinities",
4197         },
4198 #endif
4199         {
4200                 .name   = "log_store_compressed",
4201                 .lname  = "Log store compressed",
4202                 .type   = FIO_OPT_BOOL,
4203                 .off1   = offsetof(struct thread_options, log_gz_store),
4204                 .help   = "Store logs in a compressed format",
4205                 .category = FIO_OPT_C_LOG,
4206                 .group  = FIO_OPT_G_INVALID,
4207         },
4208 #else
4209         {
4210                 .name   = "log_compression",
4211                 .lname  = "Log compression",
4212                 .type   = FIO_OPT_UNSUPPORTED,
4213                 .help   = "Install libz-dev(el) to get compression support",
4214         },
4215         {
4216                 .name   = "log_store_compressed",
4217                 .lname  = "Log store compressed",
4218                 .type   = FIO_OPT_UNSUPPORTED,
4219                 .help   = "Install libz-dev(el) to get compression support",
4220         },
4221 #endif
4222         {
4223                 .name = "log_unix_epoch",
4224                 .lname = "Log epoch unix",
4225                 .type = FIO_OPT_BOOL,
4226                 .off1 = offsetof(struct thread_options, log_unix_epoch),
4227                 .help = "Use Unix time in log files",
4228                 .category = FIO_OPT_C_LOG,
4229                 .group = FIO_OPT_G_INVALID,
4230         },
4231         {
4232                 .name   = "block_error_percentiles",
4233                 .lname  = "Block error percentiles",
4234                 .type   = FIO_OPT_BOOL,
4235                 .off1   = offsetof(struct thread_options, block_error_hist),
4236                 .help   = "Record trim block errors and make a histogram",
4237                 .def    = "0",
4238                 .category = FIO_OPT_C_LOG,
4239                 .group  = FIO_OPT_G_INVALID,
4240         },
4241         {
4242                 .name   = "bwavgtime",
4243                 .lname  = "Bandwidth average time",
4244                 .type   = FIO_OPT_INT,
4245                 .off1   = offsetof(struct thread_options, bw_avg_time),
4246                 .help   = "Time window over which to calculate bandwidth"
4247                           " (msec)",
4248                 .def    = "500",
4249                 .parent = "write_bw_log",
4250                 .hide   = 1,
4251                 .interval = 100,
4252                 .category = FIO_OPT_C_LOG,
4253                 .group  = FIO_OPT_G_INVALID,
4254         },
4255         {
4256                 .name   = "iopsavgtime",
4257                 .lname  = "IOPS average time",
4258                 .type   = FIO_OPT_INT,
4259                 .off1   = offsetof(struct thread_options, iops_avg_time),
4260                 .help   = "Time window over which to calculate IOPS (msec)",
4261                 .def    = "500",
4262                 .parent = "write_iops_log",
4263                 .hide   = 1,
4264                 .interval = 100,
4265                 .category = FIO_OPT_C_LOG,
4266                 .group  = FIO_OPT_G_INVALID,
4267         },
4268         {
4269                 .name   = "group_reporting",
4270                 .lname  = "Group reporting",
4271                 .type   = FIO_OPT_STR_SET,
4272                 .off1   = offsetof(struct thread_options, group_reporting),
4273                 .help   = "Do reporting on a per-group basis",
4274                 .category = FIO_OPT_C_STAT,
4275                 .group  = FIO_OPT_G_INVALID,
4276         },
4277         {
4278                 .name   = "stats",
4279                 .lname  = "Stats",
4280                 .type   = FIO_OPT_BOOL,
4281                 .off1   = offsetof(struct thread_options, stats),
4282                 .help   = "Enable collection of stats",
4283                 .def    = "1",
4284                 .category = FIO_OPT_C_STAT,
4285                 .group  = FIO_OPT_G_INVALID,
4286         },
4287         {
4288                 .name   = "zero_buffers",
4289                 .lname  = "Zero I/O buffers",
4290                 .type   = FIO_OPT_STR_SET,
4291                 .off1   = offsetof(struct thread_options, zero_buffers),
4292                 .help   = "Init IO buffers to all zeroes",
4293                 .category = FIO_OPT_C_IO,
4294                 .group  = FIO_OPT_G_IO_BUF,
4295         },
4296         {
4297                 .name   = "refill_buffers",
4298                 .lname  = "Refill I/O buffers",
4299                 .type   = FIO_OPT_STR_SET,
4300                 .off1   = offsetof(struct thread_options, refill_buffers),
4301                 .help   = "Refill IO buffers on every IO submit",
4302                 .category = FIO_OPT_C_IO,
4303                 .group  = FIO_OPT_G_IO_BUF,
4304         },
4305         {
4306                 .name   = "scramble_buffers",
4307                 .lname  = "Scramble I/O buffers",
4308                 .type   = FIO_OPT_BOOL,
4309                 .off1   = offsetof(struct thread_options, scramble_buffers),
4310                 .help   = "Slightly scramble buffers on every IO submit",
4311                 .def    = "1",
4312                 .category = FIO_OPT_C_IO,
4313                 .group  = FIO_OPT_G_IO_BUF,
4314         },
4315         {
4316                 .name   = "buffer_pattern",
4317                 .lname  = "Buffer pattern",
4318                 .type   = FIO_OPT_STR,
4319                 .cb     = str_buffer_pattern_cb,
4320                 .off1   = offsetof(struct thread_options, buffer_pattern),
4321                 .help   = "Fill pattern for IO buffers",
4322                 .category = FIO_OPT_C_IO,
4323                 .group  = FIO_OPT_G_IO_BUF,
4324         },
4325         {
4326                 .name   = "buffer_compress_percentage",
4327                 .lname  = "Buffer compression percentage",
4328                 .type   = FIO_OPT_INT,
4329                 .cb     = str_buffer_compress_cb,
4330                 .off1   = offsetof(struct thread_options, compress_percentage),
4331                 .maxval = 100,
4332                 .minval = 0,
4333                 .help   = "How compressible the buffer is (approximately)",
4334                 .interval = 5,
4335                 .category = FIO_OPT_C_IO,
4336                 .group  = FIO_OPT_G_IO_BUF,
4337         },
4338         {
4339                 .name   = "buffer_compress_chunk",
4340                 .lname  = "Buffer compression chunk size",
4341                 .type   = FIO_OPT_INT,
4342                 .off1   = offsetof(struct thread_options, compress_chunk),
4343                 .parent = "buffer_compress_percentage",
4344                 .hide   = 1,
4345                 .help   = "Size of compressible region in buffer",
4346                 .def    = "512",
4347                 .interval = 256,
4348                 .category = FIO_OPT_C_IO,
4349                 .group  = FIO_OPT_G_IO_BUF,
4350         },
4351         {
4352                 .name   = "dedupe_percentage",
4353                 .lname  = "Dedupe percentage",
4354                 .type   = FIO_OPT_INT,
4355                 .cb     = str_dedupe_cb,
4356                 .off1   = offsetof(struct thread_options, dedupe_percentage),
4357                 .maxval = 100,
4358                 .minval = 0,
4359                 .help   = "Percentage of buffers that are dedupable",
4360                 .interval = 1,
4361                 .category = FIO_OPT_C_IO,
4362                 .group  = FIO_OPT_G_IO_BUF,
4363         },
4364         {
4365                 .name   = "clat_percentiles",
4366                 .lname  = "Completion latency percentiles",
4367                 .type   = FIO_OPT_BOOL,
4368                 .off1   = offsetof(struct thread_options, clat_percentiles),
4369                 .help   = "Enable the reporting of completion latency percentiles",
4370                 .def    = "1",
4371                 .category = FIO_OPT_C_STAT,
4372                 .group  = FIO_OPT_G_INVALID,
4373         },
4374         {
4375                 .name   = "lat_percentiles",
4376                 .lname  = "IO latency percentiles",
4377                 .type   = FIO_OPT_BOOL,
4378                 .off1   = offsetof(struct thread_options, lat_percentiles),
4379                 .help   = "Enable the reporting of IO latency percentiles",
4380                 .def    = "0",
4381                 .category = FIO_OPT_C_STAT,
4382                 .group  = FIO_OPT_G_INVALID,
4383         },
4384         {
4385                 .name   = "slat_percentiles",
4386                 .lname  = "Submission latency percentiles",
4387                 .type   = FIO_OPT_BOOL,
4388                 .off1   = offsetof(struct thread_options, slat_percentiles),
4389                 .help   = "Enable the reporting of submission latency percentiles",
4390                 .def    = "0",
4391                 .category = FIO_OPT_C_STAT,
4392                 .group  = FIO_OPT_G_INVALID,
4393         },
4394         {
4395                 .name   = "percentile_list",
4396                 .lname  = "Percentile list",
4397                 .type   = FIO_OPT_FLOAT_LIST,
4398                 .off1   = offsetof(struct thread_options, percentile_list),
4399                 .off2   = offsetof(struct thread_options, percentile_precision),
4400                 .help   = "Specify a custom list of percentiles to report for "
4401                           "completion latency and block errors",
4402                 .def    = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
4403                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4404                 .minfp  = 0.0,
4405                 .maxfp  = 100.0,
4406                 .category = FIO_OPT_C_STAT,
4407                 .group  = FIO_OPT_G_INVALID,
4408         },
4409         {
4410                 .name   = "significant_figures",
4411                 .lname  = "Significant figures",
4412                 .type   = FIO_OPT_INT,
4413                 .off1   = offsetof(struct thread_options, sig_figs),
4414                 .maxval = 10,
4415                 .minval = 1,
4416                 .help   = "Significant figures for output-format set to normal",
4417                 .def    = "4",
4418                 .interval = 1,
4419                 .category = FIO_OPT_C_STAT,
4420                 .group  = FIO_OPT_G_INVALID,
4421         },
4422
4423 #ifdef FIO_HAVE_DISK_UTIL
4424         {
4425                 .name   = "disk_util",
4426                 .lname  = "Disk utilization",
4427                 .type   = FIO_OPT_BOOL,
4428                 .off1   = offsetof(struct thread_options, do_disk_util),
4429                 .help   = "Log disk utilization statistics",
4430                 .def    = "1",
4431                 .category = FIO_OPT_C_STAT,
4432                 .group  = FIO_OPT_G_INVALID,
4433         },
4434 #else
4435         {
4436                 .name   = "disk_util",
4437                 .lname  = "Disk utilization",
4438                 .type   = FIO_OPT_UNSUPPORTED,
4439                 .help   = "Your platform does not support disk utilization",
4440         },
4441 #endif
4442         {
4443                 .name   = "gtod_reduce",
4444                 .lname  = "Reduce gettimeofday() calls",
4445                 .type   = FIO_OPT_BOOL,
4446                 .help   = "Greatly reduce number of gettimeofday() calls",
4447                 .cb     = str_gtod_reduce_cb,
4448                 .def    = "0",
4449                 .hide_on_set = 1,
4450                 .category = FIO_OPT_C_STAT,
4451                 .group  = FIO_OPT_G_INVALID,
4452         },
4453         {
4454                 .name   = "disable_lat",
4455                 .lname  = "Disable all latency stats",
4456                 .type   = FIO_OPT_BOOL,
4457                 .off1   = offsetof(struct thread_options, disable_lat),
4458                 .help   = "Disable latency numbers",
4459                 .parent = "gtod_reduce",
4460                 .hide   = 1,
4461                 .def    = "0",
4462                 .category = FIO_OPT_C_STAT,
4463                 .group  = FIO_OPT_G_INVALID,
4464         },
4465         {
4466                 .name   = "disable_clat",
4467                 .lname  = "Disable completion latency stats",
4468                 .type   = FIO_OPT_BOOL,
4469                 .off1   = offsetof(struct thread_options, disable_clat),
4470                 .help   = "Disable completion latency numbers",
4471                 .parent = "gtod_reduce",
4472                 .hide   = 1,
4473                 .def    = "0",
4474                 .category = FIO_OPT_C_STAT,
4475                 .group  = FIO_OPT_G_INVALID,
4476         },
4477         {
4478                 .name   = "disable_slat",
4479                 .lname  = "Disable submission latency stats",
4480                 .type   = FIO_OPT_BOOL,
4481                 .off1   = offsetof(struct thread_options, disable_slat),
4482                 .help   = "Disable submission latency numbers",
4483                 .parent = "gtod_reduce",
4484                 .hide   = 1,
4485                 .def    = "0",
4486                 .category = FIO_OPT_C_STAT,
4487                 .group  = FIO_OPT_G_INVALID,
4488         },
4489         {
4490                 .name   = "disable_bw_measurement",
4491                 .alias  = "disable_bw",
4492                 .lname  = "Disable bandwidth stats",
4493                 .type   = FIO_OPT_BOOL,
4494                 .off1   = offsetof(struct thread_options, disable_bw),
4495                 .help   = "Disable bandwidth logging",
4496                 .parent = "gtod_reduce",
4497                 .hide   = 1,
4498                 .def    = "0",
4499                 .category = FIO_OPT_C_STAT,
4500                 .group  = FIO_OPT_G_INVALID,
4501         },
4502         {
4503                 .name   = "gtod_cpu",
4504                 .lname  = "Dedicated gettimeofday() CPU",
4505                 .type   = FIO_OPT_INT,
4506                 .off1   = offsetof(struct thread_options, gtod_cpu),
4507                 .help   = "Set up dedicated gettimeofday() thread on this CPU",
4508                 .verify = gtod_cpu_verify,
4509                 .category = FIO_OPT_C_GENERAL,
4510                 .group  = FIO_OPT_G_CLOCK,
4511         },
4512         {
4513                 .name   = "unified_rw_reporting",
4514                 .lname  = "Unified RW Reporting",
4515                 .type   = FIO_OPT_BOOL,
4516                 .off1   = offsetof(struct thread_options, unified_rw_rep),
4517                 .help   = "Unify reporting across data direction",
4518                 .def    = "0",
4519                 .category = FIO_OPT_C_GENERAL,
4520                 .group  = FIO_OPT_G_INVALID,
4521         },
4522         {
4523                 .name   = "continue_on_error",
4524                 .lname  = "Continue on error",
4525                 .type   = FIO_OPT_STR,
4526                 .off1   = offsetof(struct thread_options, continue_on_error),
4527                 .help   = "Continue on non-fatal errors during IO",
4528                 .def    = "none",
4529                 .category = FIO_OPT_C_GENERAL,
4530                 .group  = FIO_OPT_G_ERR,
4531                 .posval = {
4532                           { .ival = "none",
4533                             .oval = ERROR_TYPE_NONE,
4534                             .help = "Exit when an error is encountered",
4535                           },
4536                           { .ival = "read",
4537                             .oval = ERROR_TYPE_READ,
4538                             .help = "Continue on read errors only",
4539                           },
4540                           { .ival = "write",
4541                             .oval = ERROR_TYPE_WRITE,
4542                             .help = "Continue on write errors only",
4543                           },
4544                           { .ival = "io",
4545                             .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4546                             .help = "Continue on any IO errors",
4547                           },
4548                           { .ival = "verify",
4549                             .oval = ERROR_TYPE_VERIFY,
4550                             .help = "Continue on verify errors only",
4551                           },
4552                           { .ival = "all",
4553                             .oval = ERROR_TYPE_ANY,
4554                             .help = "Continue on all io and verify errors",
4555                           },
4556                           { .ival = "0",
4557                             .oval = ERROR_TYPE_NONE,
4558                             .help = "Alias for 'none'",
4559                           },
4560                           { .ival = "1",
4561                             .oval = ERROR_TYPE_ANY,
4562                             .help = "Alias for 'all'",
4563                           },
4564                 },
4565         },
4566         {
4567                 .name   = "ignore_error",
4568                 .lname  = "Ignore Error",
4569                 .type   = FIO_OPT_STR,
4570                 .cb     = str_ignore_error_cb,
4571                 .off1   = offsetof(struct thread_options, ignore_error_nr),
4572                 .help   = "Set a specific list of errors to ignore",
4573                 .parent = "rw",
4574                 .category = FIO_OPT_C_GENERAL,
4575                 .group  = FIO_OPT_G_ERR,
4576         },
4577         {
4578                 .name   = "error_dump",
4579                 .lname  = "Error Dump",
4580                 .type   = FIO_OPT_BOOL,
4581                 .off1   = offsetof(struct thread_options, error_dump),
4582                 .def    = "0",
4583                 .help   = "Dump info on each error",
4584                 .category = FIO_OPT_C_GENERAL,
4585                 .group  = FIO_OPT_G_ERR,
4586         },
4587         {
4588                 .name   = "profile",
4589                 .lname  = "Profile",
4590                 .type   = FIO_OPT_STR_STORE,
4591                 .off1   = offsetof(struct thread_options, profile),
4592                 .help   = "Select a specific builtin performance test",
4593                 .category = FIO_OPT_C_PROFILE,
4594                 .group  = FIO_OPT_G_INVALID,
4595         },
4596         {
4597                 .name   = "cgroup",
4598                 .lname  = "Cgroup",
4599                 .type   = FIO_OPT_STR_STORE,
4600                 .off1   = offsetof(struct thread_options, cgroup),
4601                 .help   = "Add job to cgroup of this name",
4602                 .category = FIO_OPT_C_GENERAL,
4603                 .group  = FIO_OPT_G_CGROUP,
4604         },
4605         {
4606                 .name   = "cgroup_nodelete",
4607                 .lname  = "Cgroup no-delete",
4608                 .type   = FIO_OPT_BOOL,
4609                 .off1   = offsetof(struct thread_options, cgroup_nodelete),
4610                 .help   = "Do not delete cgroups after job completion",
4611                 .def    = "0",
4612                 .parent = "cgroup",
4613                 .category = FIO_OPT_C_GENERAL,
4614                 .group  = FIO_OPT_G_CGROUP,
4615         },
4616         {
4617                 .name   = "cgroup_weight",
4618                 .lname  = "Cgroup weight",
4619                 .type   = FIO_OPT_INT,
4620                 .off1   = offsetof(struct thread_options, cgroup_weight),
4621                 .help   = "Use given weight for cgroup",
4622                 .minval = 100,
4623                 .maxval = 1000,
4624                 .parent = "cgroup",
4625                 .category = FIO_OPT_C_GENERAL,
4626                 .group  = FIO_OPT_G_CGROUP,
4627         },
4628         {
4629                 .name   = "uid",
4630                 .lname  = "User ID",
4631                 .type   = FIO_OPT_INT,
4632                 .off1   = offsetof(struct thread_options, uid),
4633                 .help   = "Run job with this user ID",
4634                 .category = FIO_OPT_C_GENERAL,
4635                 .group  = FIO_OPT_G_CRED,
4636         },
4637         {
4638                 .name   = "gid",
4639                 .lname  = "Group ID",
4640                 .type   = FIO_OPT_INT,
4641                 .off1   = offsetof(struct thread_options, gid),
4642                 .help   = "Run job with this group ID",
4643                 .category = FIO_OPT_C_GENERAL,
4644                 .group  = FIO_OPT_G_CRED,
4645         },
4646         {
4647                 .name   = "kb_base",
4648                 .lname  = "KB Base",
4649                 .type   = FIO_OPT_STR,
4650                 .off1   = offsetof(struct thread_options, kb_base),
4651                 .prio   = 1,
4652                 .def    = "1024",
4653                 .posval = {
4654                           { .ival = "1024",
4655                             .oval = 1024,
4656                             .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
4657                           },
4658                           { .ival = "1000",
4659                             .oval = 1000,
4660                             .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
4661                           },
4662                 },
4663                 .help   = "Unit prefix interpretation for quantities of data (IEC and SI)",
4664                 .category = FIO_OPT_C_GENERAL,
4665                 .group  = FIO_OPT_G_INVALID,
4666         },
4667         {
4668                 .name   = "unit_base",
4669                 .lname  = "Unit for quantities of data (Bits or Bytes)",
4670                 .type   = FIO_OPT_STR,
4671                 .off1   = offsetof(struct thread_options, unit_base),
4672                 .prio   = 1,
4673                 .posval = {
4674                           { .ival = "0",
4675                             .oval = N2S_NONE,
4676                             .help = "Auto-detect",
4677                           },
4678                           { .ival = "8",
4679                             .oval = N2S_BYTEPERSEC,
4680                             .help = "Normal (byte based)",
4681                           },
4682                           { .ival = "1",
4683                             .oval = N2S_BITPERSEC,
4684                             .help = "Bit based",
4685                           },
4686                 },
4687                 .help   = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4688                 .category = FIO_OPT_C_GENERAL,
4689                 .group  = FIO_OPT_G_INVALID,
4690         },
4691         {
4692                 .name   = "hugepage-size",
4693                 .lname  = "Hugepage size",
4694                 .type   = FIO_OPT_INT,
4695                 .off1   = offsetof(struct thread_options, hugepage_size),
4696                 .help   = "When using hugepages, specify size of each page",
4697                 .def    = __fio_stringify(FIO_HUGE_PAGE),
4698                 .interval = 1024 * 1024,
4699                 .category = FIO_OPT_C_GENERAL,
4700                 .group  = FIO_OPT_G_INVALID,
4701         },
4702         {
4703                 .name   = "flow_id",
4704                 .lname  = "I/O flow ID",
4705                 .type   = FIO_OPT_INT,
4706                 .off1   = offsetof(struct thread_options, flow_id),
4707                 .help   = "The flow index ID to use",
4708                 .def    = "0",
4709                 .category = FIO_OPT_C_IO,
4710                 .group  = FIO_OPT_G_IO_FLOW,
4711         },
4712         {
4713                 .name   = "flow",
4714                 .lname  = "I/O flow weight",
4715                 .type   = FIO_OPT_INT,
4716                 .off1   = offsetof(struct thread_options, flow),
4717                 .help   = "Weight for flow control of this job",
4718                 .parent = "flow_id",
4719                 .hide   = 1,
4720                 .def    = "0",
4721                 .maxval = FLOW_MAX_WEIGHT,
4722                 .category = FIO_OPT_C_IO,
4723                 .group  = FIO_OPT_G_IO_FLOW,
4724         },
4725         {
4726                 .name   = "flow_watermark",
4727                 .lname  = "I/O flow watermark",
4728                 .type   = FIO_OPT_SOFT_DEPRECATED,
4729                 .category = FIO_OPT_C_IO,
4730                 .group  = FIO_OPT_G_IO_FLOW,
4731         },
4732         {
4733                 .name   = "flow_sleep",
4734                 .lname  = "I/O flow sleep",
4735                 .type   = FIO_OPT_INT,
4736                 .off1   = offsetof(struct thread_options, flow_sleep),
4737                 .help   = "How many microseconds to sleep after being held"
4738                         " back by the flow control mechanism",
4739                 .parent = "flow_id",
4740                 .hide   = 1,
4741                 .def    = "0",
4742                 .category = FIO_OPT_C_IO,
4743                 .group  = FIO_OPT_G_IO_FLOW,
4744         },
4745         {
4746                 .name   = "steadystate",
4747                 .lname  = "Steady state threshold",
4748                 .alias  = "ss",
4749                 .type   = FIO_OPT_STR,
4750                 .off1   = offsetof(struct thread_options, ss_state),
4751                 .cb     = str_steadystate_cb,
4752                 .help   = "Define the criterion and limit to judge when a job has reached steady state",
4753                 .def    = "iops_slope:0.01%",
4754                 .posval = {
4755                           { .ival = "iops",
4756                             .oval = FIO_SS_IOPS,
4757                             .help = "maximum mean deviation of IOPS measurements",
4758                           },
4759                           { .ival = "iops_slope",
4760                             .oval = FIO_SS_IOPS_SLOPE,
4761                             .help = "slope calculated from IOPS measurements",
4762                           },
4763                           { .ival = "bw",
4764                             .oval = FIO_SS_BW,
4765                             .help = "maximum mean deviation of bandwidth measurements",
4766                           },
4767                           {
4768                             .ival = "bw_slope",
4769                             .oval = FIO_SS_BW_SLOPE,
4770                             .help = "slope calculated from bandwidth measurements",
4771                           },
4772                 },
4773                 .category = FIO_OPT_C_GENERAL,
4774                 .group  = FIO_OPT_G_RUNTIME,
4775         },
4776         {
4777                 .name   = "steadystate_duration",
4778                 .lname  = "Steady state duration",
4779                 .alias  = "ss_dur",
4780                 .parent = "steadystate",
4781                 .type   = FIO_OPT_STR_VAL_TIME,
4782                 .off1   = offsetof(struct thread_options, ss_dur),
4783                 .help   = "Stop workload upon attaining steady state for specified duration",
4784                 .def    = "0",
4785                 .is_seconds = 1,
4786                 .is_time = 1,
4787                 .category = FIO_OPT_C_GENERAL,
4788                 .group  = FIO_OPT_G_RUNTIME,
4789         },
4790         {
4791                 .name   = "steadystate_ramp_time",
4792                 .lname  = "Steady state ramp time",
4793                 .alias  = "ss_ramp",
4794                 .parent = "steadystate",
4795                 .type   = FIO_OPT_STR_VAL_TIME,
4796                 .off1   = offsetof(struct thread_options, ss_ramp_time),
4797                 .help   = "Delay before initiation of data collection for steady state job termination testing",
4798                 .def    = "0",
4799                 .is_seconds = 1,
4800                 .is_time = 1,
4801                 .category = FIO_OPT_C_GENERAL,
4802                 .group  = FIO_OPT_G_RUNTIME,
4803         },
4804         {
4805                 .name = NULL,
4806         },
4807 };
4808
4809 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4810                         const char *name, int val)
4811 {
4812         lopt->name = (char *) name;
4813         lopt->val = val;
4814         if (o->type == FIO_OPT_STR_SET)
4815                 lopt->has_arg = optional_argument;
4816         else
4817                 lopt->has_arg = required_argument;
4818 }
4819
4820 static void options_to_lopts(struct fio_option *opts,
4821                               struct option *long_options,
4822                               int i, int option_type)
4823 {
4824         struct fio_option *o = &opts[0];
4825         while (o->name) {
4826                 add_to_lopt(&long_options[i], o, o->name, option_type);
4827                 if (o->alias) {
4828                         i++;
4829                         add_to_lopt(&long_options[i], o, o->alias, option_type);
4830                 }
4831
4832                 i++;
4833                 o++;
4834                 assert(i < FIO_NR_OPTIONS);
4835         }
4836 }
4837
4838 void fio_options_set_ioengine_opts(struct option *long_options,
4839                                    struct thread_data *td)
4840 {
4841         unsigned int i;
4842
4843         i = 0;
4844         while (long_options[i].name) {
4845                 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4846                         memset(&long_options[i], 0, sizeof(*long_options));
4847                         break;
4848                 }
4849                 i++;
4850         }
4851
4852         /*
4853          * Just clear out the prior ioengine options.
4854          */
4855         if (!td || !td->eo)
4856                 return;
4857
4858         options_to_lopts(td->io_ops->options, long_options, i,
4859                          FIO_GETOPT_IOENGINE);
4860 }
4861
4862 void fio_options_dup_and_init(struct option *long_options)
4863 {
4864         unsigned int i;
4865
4866         options_init(fio_options);
4867
4868         i = 0;
4869         while (long_options[i].name)
4870                 i++;
4871
4872         options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4873 }
4874
4875 struct fio_keyword {
4876         const char *word;
4877         const char *desc;
4878         char *replace;
4879 };
4880
4881 static struct fio_keyword fio_keywords[] = {
4882         {
4883                 .word   = "$pagesize",
4884                 .desc   = "Page size in the system",
4885         },
4886         {
4887                 .word   = "$mb_memory",
4888                 .desc   = "Megabytes of memory online",
4889         },
4890         {
4891                 .word   = "$ncpus",
4892                 .desc   = "Number of CPUs online in the system",
4893         },
4894         {
4895                 .word   = NULL,
4896         },
4897 };
4898
4899 void fio_keywords_exit(void)
4900 {
4901         struct fio_keyword *kw;
4902
4903         kw = &fio_keywords[0];
4904         while (kw->word) {
4905                 free(kw->replace);
4906                 kw->replace = NULL;
4907                 kw++;
4908         }
4909 }
4910
4911 void fio_keywords_init(void)
4912 {
4913         unsigned long long mb_memory;
4914         char buf[128];
4915         long l;
4916
4917         sprintf(buf, "%lu", (unsigned long) page_size);
4918         fio_keywords[0].replace = strdup(buf);
4919
4920         mb_memory = os_phys_mem() / (1024 * 1024);
4921         sprintf(buf, "%llu", mb_memory);
4922         fio_keywords[1].replace = strdup(buf);
4923
4924         l = cpus_online();
4925         sprintf(buf, "%lu", l);
4926         fio_keywords[2].replace = strdup(buf);
4927 }
4928
4929 #define BC_APP          "bc"
4930
4931 static char *bc_calc(char *str)
4932 {
4933         char buf[128], *tmp;
4934         FILE *f;
4935         int ret;
4936
4937         /*
4938          * No math, just return string
4939          */
4940         if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4941              !strchr(str, '/')) || strchr(str, '\''))
4942                 return str;
4943
4944         /*
4945          * Split option from value, we only need to calculate the value
4946          */
4947         tmp = strchr(str, '=');
4948         if (!tmp)
4949                 return str;
4950
4951         tmp++;
4952
4953         /*
4954          * Prevent buffer overflows; such a case isn't reasonable anyway
4955          */
4956         if (strlen(str) >= 128 || strlen(tmp) > 100)
4957                 return str;
4958
4959         sprintf(buf, "which %s > /dev/null", BC_APP);
4960         if (system(buf)) {
4961                 log_err("fio: bc is needed for performing math\n");
4962                 return NULL;
4963         }
4964
4965         sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4966         f = popen(buf, "r");
4967         if (!f)
4968                 return NULL;
4969
4970         ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4971         if (ret <= 0) {
4972                 pclose(f);
4973                 return NULL;
4974         }
4975
4976         pclose(f);
4977         buf[(tmp - str) + ret - 1] = '\0';
4978         memcpy(buf, str, tmp - str);
4979         free(str);
4980         return strdup(buf);
4981 }
4982
4983 /*
4984  * Return a copy of the input string with substrings of the form ${VARNAME}
4985  * substituted with the value of the environment variable VARNAME.  The
4986  * substitution always occurs, even if VARNAME is empty or the corresponding
4987  * environment variable undefined.
4988  */
4989 char *fio_option_dup_subs(const char *opt)
4990 {
4991         char out[OPT_LEN_MAX+1];
4992         char in[OPT_LEN_MAX+1];
4993         char *outptr = out;
4994         char *inptr = in;
4995         char *ch1, *ch2, *env;
4996         ssize_t nchr = OPT_LEN_MAX;
4997         size_t envlen;
4998
4999         if (strlen(opt) + 1 > OPT_LEN_MAX) {
5000                 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
5001                 return NULL;
5002         }
5003
5004         snprintf(in, sizeof(in), "%s", opt);
5005
5006         while (*inptr && nchr > 0) {
5007                 if (inptr[0] == '$' && inptr[1] == '{') {
5008                         ch2 = strchr(inptr, '}');
5009                         if (ch2 && inptr+1 < ch2) {
5010                                 ch1 = inptr+2;
5011                                 inptr = ch2+1;
5012                                 *ch2 = '\0';
5013
5014                                 env = getenv(ch1);
5015                                 if (env) {
5016                                         envlen = strlen(env);
5017                                         if (envlen <= nchr) {
5018                                                 memcpy(outptr, env, envlen);
5019                                                 outptr += envlen;
5020                                                 nchr -= envlen;
5021                                         }
5022                                 }
5023
5024                                 continue;
5025                         }
5026                 }
5027
5028                 *outptr++ = *inptr++;
5029                 --nchr;
5030         }
5031
5032         *outptr = '\0';
5033         return strdup(out);
5034 }
5035
5036 /*
5037  * Look for reserved variable names and replace them with real values
5038  */
5039 static char *fio_keyword_replace(char *opt)
5040 {
5041         char *s;
5042         int i;
5043         int docalc = 0;
5044
5045         for (i = 0; fio_keywords[i].word != NULL; i++) {
5046                 struct fio_keyword *kw = &fio_keywords[i];
5047
5048                 while ((s = strstr(opt, kw->word)) != NULL) {
5049                         char *new = malloc(strlen(opt) + 1);
5050                         char *o_org = opt;
5051                         int olen = s - opt;
5052                         int len;
5053
5054                         /*
5055                          * Copy part of the string before the keyword and
5056                          * sprintf() the replacement after it.
5057                          */
5058                         memcpy(new, opt, olen);
5059                         len = sprintf(new + olen, "%s", kw->replace);
5060
5061                         /*
5062                          * If there's more in the original string, copy that
5063                          * in too
5064                          */
5065                         opt += strlen(kw->word) + olen;
5066                         if (strlen(opt))
5067                                 memcpy(new + olen + len, opt, opt - o_org - 1);
5068
5069                         /*
5070                          * replace opt and free the old opt
5071                          */
5072                         opt = new;
5073                         free(o_org);
5074
5075                         docalc = 1;
5076                 }
5077         }
5078
5079         /*
5080          * Check for potential math and invoke bc, if possible
5081          */
5082         if (docalc)
5083                 opt = bc_calc(opt);
5084
5085         return opt;
5086 }
5087
5088 static char **dup_and_sub_options(char **opts, int num_opts)
5089 {
5090         int i;
5091         char **opts_copy = malloc(num_opts * sizeof(*opts));
5092         for (i = 0; i < num_opts; i++) {
5093                 opts_copy[i] = fio_option_dup_subs(opts[i]);
5094                 if (!opts_copy[i])
5095                         continue;
5096                 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
5097         }
5098         return opts_copy;
5099 }
5100
5101 static void show_closest_option(const char *opt)
5102 {
5103         int best_option, best_distance;
5104         int i, distance;
5105         char *name;
5106
5107         if (!strlen(opt))
5108                 return;
5109
5110         name = strdup(opt);
5111         i = 0;
5112         while (name[i] != '\0' && name[i] != '=')
5113                 i++;
5114         name[i] = '\0';
5115
5116         best_option = -1;
5117         best_distance = INT_MAX;
5118         i = 0;
5119         while (fio_options[i].name) {
5120                 distance = string_distance(name, fio_options[i].name);
5121                 if (distance < best_distance) {
5122                         best_distance = distance;
5123                         best_option = i;
5124                 }
5125                 i++;
5126         }
5127
5128         if (best_option != -1 && string_distance_ok(name, best_distance) &&
5129             fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
5130                 log_err("Did you mean %s?\n", fio_options[best_option].name);
5131
5132         free(name);
5133 }
5134
5135 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
5136 {
5137         int i, ret, unknown;
5138         char **opts_copy;
5139
5140         sort_options(opts, fio_options, num_opts);
5141         opts_copy = dup_and_sub_options(opts, num_opts);
5142
5143         for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
5144                 const struct fio_option *o;
5145                 int newret = parse_option(opts_copy[i], opts[i], fio_options,
5146                                                 &o, &td->o, &td->opt_list);
5147
5148                 if (!newret && o)
5149                         fio_option_mark_set(&td->o, o);
5150
5151                 if (opts_copy[i]) {
5152                         if (newret && !o) {
5153                                 unknown++;
5154                                 continue;
5155                         }
5156                         free(opts_copy[i]);
5157                         opts_copy[i] = NULL;
5158                 }
5159
5160                 ret |= newret;
5161         }
5162
5163         if (unknown) {
5164                 ret |= ioengine_load(td);
5165                 if (td->eo) {
5166                         sort_options(opts_copy, td->io_ops->options, num_opts);
5167                         opts = opts_copy;
5168                 }
5169                 for (i = 0; i < num_opts; i++) {
5170                         const struct fio_option *o = NULL;
5171                         int newret = 1;
5172
5173                         if (!opts_copy[i])
5174                                 continue;
5175
5176                         if (td->eo)
5177                                 newret = parse_option(opts_copy[i], opts[i],
5178                                                       td->io_ops->options, &o,
5179                                                       td->eo, &td->opt_list);
5180
5181                         ret |= newret;
5182                         if (!o) {
5183                                 log_err("Bad option <%s>\n", opts[i]);
5184                                 show_closest_option(opts[i]);
5185                         }
5186                         free(opts_copy[i]);
5187                         opts_copy[i] = NULL;
5188                 }
5189         }
5190
5191         free(opts_copy);
5192         return ret;
5193 }
5194
5195 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
5196 {
5197         int ret;
5198
5199         ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
5200         if (!ret) {
5201                 const struct fio_option *o;
5202
5203                 o = find_option_c(fio_options, opt);
5204                 if (o)
5205                         fio_option_mark_set(&td->o, o);
5206         }
5207
5208         return ret;
5209 }
5210
5211 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
5212                                 char *val)
5213 {
5214         return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
5215                                         &td->opt_list);
5216 }
5217
5218 void fio_fill_default_options(struct thread_data *td)
5219 {
5220         td->o.magic = OPT_MAGIC;
5221         fill_default_options(&td->o, fio_options);
5222 }
5223
5224 int fio_show_option_help(const char *opt)
5225 {
5226         return show_cmd_help(fio_options, opt);
5227 }
5228
5229 /*
5230  * dupe FIO_OPT_STR_STORE options
5231  */
5232 void fio_options_mem_dupe(struct thread_data *td)
5233 {
5234         options_mem_dupe(fio_options, &td->o);
5235
5236         if (td->eo && td->io_ops) {
5237                 void *oldeo = td->eo;
5238
5239                 td->eo = malloc(td->io_ops->option_struct_size);
5240                 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
5241                 options_mem_dupe(td->io_ops->options, td->eo);
5242         }
5243 }
5244
5245 unsigned int fio_get_kb_base(void *data)
5246 {
5247         struct thread_data *td = cb_data_to_td(data);
5248         struct thread_options *o = &td->o;
5249         unsigned int kb_base = 0;
5250
5251         /*
5252          * This is a hack... For private options, *data is not holding
5253          * a pointer to the thread_options, but to private data. This means
5254          * we can't safely dereference it, but magic is first so mem wise
5255          * it is valid. But this also means that if the job first sets
5256          * kb_base and expects that to be honored by private options,
5257          * it will be disappointed. We will return the global default
5258          * for this.
5259          */
5260         if (o && o->magic == OPT_MAGIC)
5261                 kb_base = o->kb_base;
5262         if (!kb_base)
5263                 kb_base = 1024;
5264
5265         return kb_base;
5266 }
5267
5268 int add_option(const struct fio_option *o)
5269 {
5270         struct fio_option *__o;
5271         int opt_index = 0;
5272
5273         __o = fio_options;
5274         while (__o->name) {
5275                 opt_index++;
5276                 __o++;
5277         }
5278
5279         if (opt_index + 1 == FIO_MAX_OPTS) {
5280                 log_err("fio: FIO_MAX_OPTS is too small\n");
5281                 return 1;
5282         }
5283
5284         memcpy(&fio_options[opt_index], o, sizeof(*o));
5285         fio_options[opt_index + 1].name = NULL;
5286         return 0;
5287 }
5288
5289 void invalidate_profile_options(const char *prof_name)
5290 {
5291         struct fio_option *o;
5292
5293         o = fio_options;
5294         while (o->name) {
5295                 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
5296                         o->type = FIO_OPT_INVALID;
5297                         o->prof_name = NULL;
5298                 }
5299                 o++;
5300         }
5301 }
5302
5303 void add_opt_posval(const char *optname, const char *ival, const char *help)
5304 {
5305         struct fio_option *o;
5306         unsigned int i;
5307
5308         o = find_option(fio_options, optname);
5309         if (!o)
5310                 return;
5311
5312         for (i = 0; i < PARSE_MAX_VP; i++) {
5313                 if (o->posval[i].ival)
5314                         continue;
5315
5316                 o->posval[i].ival = ival;
5317                 o->posval[i].help = help;
5318                 break;
5319         }
5320 }
5321
5322 void del_opt_posval(const char *optname, const char *ival)
5323 {
5324         struct fio_option *o;
5325         unsigned int i;
5326
5327         o = find_option(fio_options, optname);
5328         if (!o)
5329                 return;
5330
5331         for (i = 0; i < PARSE_MAX_VP; i++) {
5332                 if (!o->posval[i].ival)
5333                         continue;
5334                 if (strcmp(o->posval[i].ival, ival))
5335                         continue;
5336
5337                 o->posval[i].ival = NULL;
5338                 o->posval[i].help = NULL;
5339         }
5340 }
5341
5342 void fio_options_free(struct thread_data *td)
5343 {
5344         options_free(fio_options, &td->o);
5345         if (td->eo && td->io_ops && td->io_ops->options) {
5346                 options_free(td->io_ops->options, td->eo);
5347                 free(td->eo);
5348                 td->eo = NULL;
5349         }
5350 }
5351
5352 struct fio_option *fio_option_find(const char *name)
5353 {
5354         return find_option(fio_options, name);
5355 }
5356
5357 static struct fio_option *find_next_opt(struct fio_option *from,
5358                                         unsigned int off1)
5359 {
5360         struct fio_option *opt;
5361
5362         if (!from)
5363                 from = &fio_options[0];
5364         else
5365                 from++;
5366
5367         opt = NULL;
5368         do {
5369                 if (off1 == from->off1) {
5370                         opt = from;
5371                         break;
5372                 }
5373                 from++;
5374         } while (from->name);
5375
5376         return opt;
5377 }
5378
5379 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5380 {
5381         unsigned int opt_off, index, offset;
5382
5383         opt_off = opt - &fio_options[0];
5384         index = opt_off / (8 * sizeof(uint64_t));
5385         offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5386         return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
5387 }
5388
5389 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
5390 {
5391         struct fio_option *opt, *next;
5392
5393         next = NULL;
5394         while ((opt = find_next_opt(next, off1)) != NULL) {
5395                 if (opt_is_set(o, opt))
5396                         return true;
5397
5398                 next = opt;
5399         }
5400
5401         return false;
5402 }
5403
5404 void fio_option_mark_set(struct thread_options *o, const struct fio_option *opt)
5405 {
5406         unsigned int opt_off, index, offset;
5407
5408         opt_off = opt - &fio_options[0];
5409         index = opt_off / (8 * sizeof(uint64_t));
5410         offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5411         o->set_options[index] |= (uint64_t)1 << offset;
5412 }