f67969eace72c7301b8c872ce16d643d68c5226b
[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 <libgen.h>
8 #include <fcntl.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <netinet/in.h>
12
13 #include "fio.h"
14 #include "verify.h"
15 #include "parse.h"
16 #include "lib/fls.h"
17 #include "lib/pattern.h"
18 #include "options.h"
19
20 #include "crc/crc32c.h"
21
22 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
23
24 struct pattern_fmt_desc fmt_desc[] = {
25         {
26                 .fmt   = "%o",
27                 .len   = FIELD_SIZE(struct io_u *, offset),
28                 .paste = paste_blockoff
29         }
30 };
31
32 /*
33  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
34  */
35 static char *get_opt_postfix(const char *str)
36 {
37         char *p = strstr(str, ":");
38
39         if (!p)
40                 return NULL;
41
42         p++;
43         strip_blank_front(&p);
44         strip_blank_end(p);
45         return strdup(p);
46 }
47
48 static int bs_cmp(const void *p1, const void *p2)
49 {
50         const struct bssplit *bsp1 = p1;
51         const struct bssplit *bsp2 = p2;
52
53         return bsp1->perc < bsp2->perc;
54 }
55
56 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
57 {
58         struct bssplit *bssplit;
59         unsigned int i, perc, perc_missing;
60         unsigned int max_bs, min_bs;
61         long long val;
62         char *fname;
63
64         o->bssplit_nr[ddir] = 4;
65         bssplit = malloc(4 * sizeof(struct bssplit));
66
67         i = 0;
68         max_bs = 0;
69         min_bs = -1;
70         while ((fname = strsep(&str, ":")) != NULL) {
71                 char *perc_str;
72
73                 if (!strlen(fname))
74                         break;
75
76                 /*
77                  * grow struct buffer, if needed
78                  */
79                 if (i == o->bssplit_nr[ddir]) {
80                         o->bssplit_nr[ddir] <<= 1;
81                         bssplit = realloc(bssplit, o->bssplit_nr[ddir]
82                                                   * sizeof(struct bssplit));
83                 }
84
85                 perc_str = strstr(fname, "/");
86                 if (perc_str) {
87                         *perc_str = '\0';
88                         perc_str++;
89                         perc = atoi(perc_str);
90                         if (perc > 100)
91                                 perc = 100;
92                         else if (!perc)
93                                 perc = -1U;
94                 } else
95                         perc = -1U;
96
97                 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
98                         log_err("fio: bssplit conversion failed\n");
99                         free(bssplit);
100                         return 1;
101                 }
102
103                 if (val > max_bs)
104                         max_bs = val;
105                 if (val < min_bs)
106                         min_bs = val;
107
108                 bssplit[i].bs = val;
109                 bssplit[i].perc = perc;
110                 i++;
111         }
112
113         o->bssplit_nr[ddir] = i;
114
115         /*
116          * Now check if the percentages add up, and how much is missing
117          */
118         perc = perc_missing = 0;
119         for (i = 0; i < o->bssplit_nr[ddir]; i++) {
120                 struct bssplit *bsp = &bssplit[i];
121
122                 if (bsp->perc == -1U)
123                         perc_missing++;
124                 else
125                         perc += bsp->perc;
126         }
127
128         if (perc > 100 && perc_missing > 1) {
129                 log_err("fio: bssplit percentages add to more than 100%%\n");
130                 free(bssplit);
131                 return 1;
132         }
133
134         /*
135          * If values didn't have a percentage set, divide the remains between
136          * them.
137          */
138         if (perc_missing) {
139                 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
140                         perc = 100;
141                 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
142                         struct bssplit *bsp = &bssplit[i];
143
144                         if (bsp->perc == -1U)
145                                 bsp->perc = (100 - perc) / perc_missing;
146                 }
147         }
148
149         o->min_bs[ddir] = min_bs;
150         o->max_bs[ddir] = max_bs;
151
152         /*
153          * now sort based on percentages, for ease of lookup
154          */
155         qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
156         o->bssplit[ddir] = bssplit;
157         return 0;
158 }
159
160 static int str_bssplit_cb(void *data, const char *input)
161 {
162         struct thread_data *td = data;
163         char *str, *p, *odir, *ddir;
164         int ret = 0;
165
166         if (parse_dryrun())
167                 return 0;
168
169         p = str = strdup(input);
170
171         strip_blank_front(&str);
172         strip_blank_end(str);
173
174         odir = strchr(str, ',');
175         if (odir) {
176                 ddir = strchr(odir + 1, ',');
177                 if (ddir) {
178                         ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
179                         if (!ret)
180                                 *ddir = '\0';
181                 } else {
182                         char *op;
183
184                         op = strdup(odir + 1);
185                         ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
186
187                         free(op);
188                 }
189                 if (!ret)
190                         ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
191                 if (!ret) {
192                         *odir = '\0';
193                         ret = bssplit_ddir(&td->o, DDIR_READ, str);
194                 }
195         } else {
196                 char *op;
197
198                 op = strdup(str);
199                 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
200                 free(op);
201
202                 if (!ret) {
203                         op = strdup(str);
204                         ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
205                         free(op);
206                 }
207                 if (!ret)
208                         ret = bssplit_ddir(&td->o, DDIR_READ, str);
209         }
210
211         free(p);
212         return ret;
213 }
214
215 static int str2error(char *str)
216 {
217         const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
218                             "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
219                             "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
220                             "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
221                             "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
222                             "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
223                             "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
224                             "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
225         int i = 0, num = sizeof(err) / sizeof(void *);
226
227         while (i < num) {
228                 if (!strcmp(err[i], str))
229                         return i + 1;
230                 i++;
231         }
232         return 0;
233 }
234
235 static int ignore_error_type(struct thread_data *td, int etype, char *str)
236 {
237         unsigned int i;
238         int *error;
239         char *fname;
240
241         if (etype >= ERROR_TYPE_CNT) {
242                 log_err("Illegal error type\n");
243                 return 1;
244         }
245
246         td->o.ignore_error_nr[etype] = 4;
247         error = malloc(4 * sizeof(struct bssplit));
248
249         i = 0;
250         while ((fname = strsep(&str, ":")) != NULL) {
251
252                 if (!strlen(fname))
253                         break;
254
255                 /*
256                  * grow struct buffer, if needed
257                  */
258                 if (i == td->o.ignore_error_nr[etype]) {
259                         td->o.ignore_error_nr[etype] <<= 1;
260                         error = realloc(error, td->o.ignore_error_nr[etype]
261                                                   * sizeof(int));
262                 }
263                 if (fname[0] == 'E') {
264                         error[i] = str2error(fname);
265                 } else {
266                         error[i] = atoi(fname);
267                         if (error[i] < 0)
268                                 error[i] = -error[i];
269                 }
270                 if (!error[i]) {
271                         log_err("Unknown error %s, please use number value \n",
272                                   fname);
273                         free(error);
274                         return 1;
275                 }
276                 i++;
277         }
278         if (i) {
279                 td->o.continue_on_error |= 1 << etype;
280                 td->o.ignore_error_nr[etype] = i;
281                 td->o.ignore_error[etype] = error;
282         } else
283                 free(error);
284
285         return 0;
286
287 }
288
289 static int str_ignore_error_cb(void *data, const char *input)
290 {
291         struct thread_data *td = data;
292         char *str, *p, *n;
293         int type = 0, ret = 1;
294
295         if (parse_dryrun())
296                 return 0;
297
298         p = str = strdup(input);
299
300         strip_blank_front(&str);
301         strip_blank_end(str);
302
303         while (p) {
304                 n = strchr(p, ',');
305                 if (n)
306                         *n++ = '\0';
307                 ret = ignore_error_type(td, type, p);
308                 if (ret)
309                         break;
310                 p = n;
311                 type++;
312         }
313         free(str);
314         return ret;
315 }
316
317 static int str_rw_cb(void *data, const char *str)
318 {
319         struct thread_data *td = data;
320         struct thread_options *o = &td->o;
321         char *nr;
322
323         if (parse_dryrun())
324                 return 0;
325
326         o->ddir_seq_nr = 1;
327         o->ddir_seq_add = 0;
328
329         nr = get_opt_postfix(str);
330         if (!nr)
331                 return 0;
332
333         if (td_random(td))
334                 o->ddir_seq_nr = atoi(nr);
335         else {
336                 long long val;
337
338                 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
339                         log_err("fio: rw postfix parsing failed\n");
340                         free(nr);
341                         return 1;
342                 }
343
344                 o->ddir_seq_add = val;
345         }
346
347         free(nr);
348         return 0;
349 }
350
351 static int str_mem_cb(void *data, const char *mem)
352 {
353         struct thread_data *td = data;
354
355         if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
356             td->o.mem_type == MEM_MMAPSHARED)
357                 td->o.mmapfile = get_opt_postfix(mem);
358
359         return 0;
360 }
361
362 static int fio_clock_source_cb(void *data, const char *str)
363 {
364         struct thread_data *td = data;
365
366         fio_clock_source = td->o.clocksource;
367         fio_clock_source_set = 1;
368         fio_clock_init();
369         return 0;
370 }
371
372 static int str_rwmix_read_cb(void *data, unsigned long long *val)
373 {
374         struct thread_data *td = data;
375
376         td->o.rwmix[DDIR_READ] = *val;
377         td->o.rwmix[DDIR_WRITE] = 100 - *val;
378         return 0;
379 }
380
381 static int str_rwmix_write_cb(void *data, unsigned long long *val)
382 {
383         struct thread_data *td = data;
384
385         td->o.rwmix[DDIR_WRITE] = *val;
386         td->o.rwmix[DDIR_READ] = 100 - *val;
387         return 0;
388 }
389
390 static int str_exitall_cb(void)
391 {
392         exitall_on_terminate = 1;
393         return 0;
394 }
395
396 #ifdef FIO_HAVE_CPU_AFFINITY
397 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
398 {
399         unsigned int i, index, cpus_in_mask;
400         const long max_cpu = cpus_online();
401
402         cpus_in_mask = fio_cpu_count(mask);
403         cpu_index = cpu_index % cpus_in_mask;
404
405         index = 0;
406         for (i = 0; i < max_cpu; i++) {
407                 if (!fio_cpu_isset(mask, i))
408                         continue;
409
410                 if (cpu_index != index)
411                         fio_cpu_clear(mask, i);
412
413                 index++;
414         }
415
416         return fio_cpu_count(mask);
417 }
418
419 static int str_cpumask_cb(void *data, unsigned long long *val)
420 {
421         struct thread_data *td = data;
422         unsigned int i;
423         long max_cpu;
424         int ret;
425
426         if (parse_dryrun())
427                 return 0;
428
429         ret = fio_cpuset_init(&td->o.cpumask);
430         if (ret < 0) {
431                 log_err("fio: cpuset_init failed\n");
432                 td_verror(td, ret, "fio_cpuset_init");
433                 return 1;
434         }
435
436         max_cpu = cpus_online();
437
438         for (i = 0; i < sizeof(int) * 8; i++) {
439                 if ((1 << i) & *val) {
440                         if (i >= max_cpu) {
441                                 log_err("fio: CPU %d too large (max=%ld)\n", i,
442                                                                 max_cpu - 1);
443                                 return 1;
444                         }
445                         dprint(FD_PARSE, "set cpu allowed %d\n", i);
446                         fio_cpu_set(&td->o.cpumask, i);
447                 }
448         }
449
450         return 0;
451 }
452
453 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
454                             const char *input)
455 {
456         char *cpu, *str, *p;
457         long max_cpu;
458         int ret = 0;
459
460         ret = fio_cpuset_init(mask);
461         if (ret < 0) {
462                 log_err("fio: cpuset_init failed\n");
463                 td_verror(td, ret, "fio_cpuset_init");
464                 return 1;
465         }
466
467         p = str = strdup(input);
468
469         strip_blank_front(&str);
470         strip_blank_end(str);
471
472         max_cpu = cpus_online();
473
474         while ((cpu = strsep(&str, ",")) != NULL) {
475                 char *str2, *cpu2;
476                 int icpu, icpu2;
477
478                 if (!strlen(cpu))
479                         break;
480
481                 str2 = cpu;
482                 icpu2 = -1;
483                 while ((cpu2 = strsep(&str2, "-")) != NULL) {
484                         if (!strlen(cpu2))
485                                 break;
486
487                         icpu2 = atoi(cpu2);
488                 }
489
490                 icpu = atoi(cpu);
491                 if (icpu2 == -1)
492                         icpu2 = icpu;
493                 while (icpu <= icpu2) {
494                         if (icpu >= FIO_MAX_CPUS) {
495                                 log_err("fio: your OS only supports up to"
496                                         " %d CPUs\n", (int) FIO_MAX_CPUS);
497                                 ret = 1;
498                                 break;
499                         }
500                         if (icpu >= max_cpu) {
501                                 log_err("fio: CPU %d too large (max=%ld)\n",
502                                                         icpu, max_cpu - 1);
503                                 ret = 1;
504                                 break;
505                         }
506
507                         dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
508                         fio_cpu_set(mask, icpu);
509                         icpu++;
510                 }
511                 if (ret)
512                         break;
513         }
514
515         free(p);
516         return ret;
517 }
518
519 static int str_cpus_allowed_cb(void *data, const char *input)
520 {
521         struct thread_data *td = data;
522
523         if (parse_dryrun())
524                 return 0;
525
526         return set_cpus_allowed(td, &td->o.cpumask, input);
527 }
528
529 static int str_verify_cpus_allowed_cb(void *data, const char *input)
530 {
531         struct thread_data *td = data;
532
533         if (parse_dryrun())
534                 return 0;
535
536         return set_cpus_allowed(td, &td->o.verify_cpumask, input);
537 }
538
539 #ifdef CONFIG_ZLIB
540 static int str_log_cpus_allowed_cb(void *data, const char *input)
541 {
542         struct thread_data *td = data;
543
544         if (parse_dryrun())
545                 return 0;
546
547         return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
548 }
549 #endif /* CONFIG_ZLIB */
550
551 #endif /* FIO_HAVE_CPU_AFFINITY */
552
553 #ifdef CONFIG_LIBNUMA
554 static int str_numa_cpunodes_cb(void *data, char *input)
555 {
556         struct thread_data *td = data;
557         struct bitmask *verify_bitmask;
558
559         if (parse_dryrun())
560                 return 0;
561
562         /* numa_parse_nodestring() parses a character string list
563          * of nodes into a bit mask. The bit mask is allocated by
564          * numa_allocate_nodemask(), so it should be freed by
565          * numa_free_nodemask().
566          */
567         verify_bitmask = numa_parse_nodestring(input);
568         if (verify_bitmask == NULL) {
569                 log_err("fio: numa_parse_nodestring failed\n");
570                 td_verror(td, 1, "str_numa_cpunodes_cb");
571                 return 1;
572         }
573         numa_free_nodemask(verify_bitmask);
574
575         td->o.numa_cpunodes = strdup(input);
576         return 0;
577 }
578
579 static int str_numa_mpol_cb(void *data, char *input)
580 {
581         struct thread_data *td = data;
582         const char * const policy_types[] =
583                 { "default", "prefer", "bind", "interleave", "local", NULL };
584         int i;
585         char *nodelist;
586         struct bitmask *verify_bitmask;
587
588         if (parse_dryrun())
589                 return 0;
590
591         nodelist = strchr(input, ':');
592         if (nodelist) {
593                 /* NUL-terminate mode */
594                 *nodelist++ = '\0';
595         }
596
597         for (i = 0; i <= MPOL_LOCAL; i++) {
598                 if (!strcmp(input, policy_types[i])) {
599                         td->o.numa_mem_mode = i;
600                         break;
601                 }
602         }
603         if (i > MPOL_LOCAL) {
604                 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
605                 goto out;
606         }
607
608         switch (td->o.numa_mem_mode) {
609         case MPOL_PREFERRED:
610                 /*
611                  * Insist on a nodelist of one node only
612                  */
613                 if (nodelist) {
614                         char *rest = nodelist;
615                         while (isdigit(*rest))
616                                 rest++;
617                         if (*rest) {
618                                 log_err("fio: one node only for \'prefer\'\n");
619                                 goto out;
620                         }
621                 } else {
622                         log_err("fio: one node is needed for \'prefer\'\n");
623                         goto out;
624                 }
625                 break;
626         case MPOL_INTERLEAVE:
627                 /*
628                  * Default to online nodes with memory if no nodelist
629                  */
630                 if (!nodelist)
631                         nodelist = strdup("all");
632                 break;
633         case MPOL_LOCAL:
634         case MPOL_DEFAULT:
635                 /*
636                  * Don't allow a nodelist
637                  */
638                 if (nodelist) {
639                         log_err("fio: NO nodelist for \'local\'\n");
640                         goto out;
641                 }
642                 break;
643         case MPOL_BIND:
644                 /*
645                  * Insist on a nodelist
646                  */
647                 if (!nodelist) {
648                         log_err("fio: a nodelist is needed for \'bind\'\n");
649                         goto out;
650                 }
651                 break;
652         }
653
654
655         /* numa_parse_nodestring() parses a character string list
656          * of nodes into a bit mask. The bit mask is allocated by
657          * numa_allocate_nodemask(), so it should be freed by
658          * numa_free_nodemask().
659          */
660         switch (td->o.numa_mem_mode) {
661         case MPOL_PREFERRED:
662                 td->o.numa_mem_prefer_node = atoi(nodelist);
663                 break;
664         case MPOL_INTERLEAVE:
665         case MPOL_BIND:
666                 verify_bitmask = numa_parse_nodestring(nodelist);
667                 if (verify_bitmask == NULL) {
668                         log_err("fio: numa_parse_nodestring failed\n");
669                         td_verror(td, 1, "str_numa_memnodes_cb");
670                         return 1;
671                 }
672                 td->o.numa_memnodes = strdup(nodelist);
673                 numa_free_nodemask(verify_bitmask);
674
675                 break;
676         case MPOL_LOCAL:
677         case MPOL_DEFAULT:
678         default:
679                 break;
680         }
681
682         return 0;
683 out:
684         return 1;
685 }
686 #endif
687
688 static int str_fst_cb(void *data, const char *str)
689 {
690         struct thread_data *td = data;
691         char *nr = get_opt_postfix(str);
692
693         td->file_service_nr = 1;
694         if (nr) {
695                 td->file_service_nr = atoi(nr);
696                 free(nr);
697         }
698
699         return 0;
700 }
701
702 #ifdef CONFIG_SYNC_FILE_RANGE
703 static int str_sfr_cb(void *data, const char *str)
704 {
705         struct thread_data *td = data;
706         char *nr = get_opt_postfix(str);
707
708         td->sync_file_range_nr = 1;
709         if (nr) {
710                 td->sync_file_range_nr = atoi(nr);
711                 free(nr);
712         }
713
714         return 0;
715 }
716 #endif
717
718 static int str_random_distribution_cb(void *data, const char *str)
719 {
720         struct thread_data *td = data;
721         double val;
722         char *nr;
723
724         if (parse_dryrun())
725                 return 0;
726
727         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
728                 val = FIO_DEF_ZIPF;
729         else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
730                 val = FIO_DEF_PARETO;
731         else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
732                 val = 0.0;
733         else
734                 return 0;
735
736         nr = get_opt_postfix(str);
737         if (nr && !str_to_float(nr, &val, 0)) {
738                 log_err("fio: random postfix parsing failed\n");
739                 free(nr);
740                 return 1;
741         }
742
743         free(nr);
744
745         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
746                 if (val == 1.00) {
747                         log_err("fio: zipf theta must different than 1.0\n");
748                         return 1;
749                 }
750                 td->o.zipf_theta.u.f = val;
751         } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
752                 if (val <= 0.00 || val >= 1.00) {
753                         log_err("fio: pareto input out of range (0 < input < 1.0)\n");
754                         return 1;
755                 }
756                 td->o.pareto_h.u.f = val;
757         } else {
758                 if (val <= 0.00 || val >= 100.0) {
759                         log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
760                         return 1;
761                 }
762                 td->o.gauss_dev.u.f = val;
763         }
764
765         return 0;
766 }
767
768 /*
769  * Return next name in the string. Files are separated with ':'. If the ':'
770  * is escaped with a '\', then that ':' is part of the filename and does not
771  * indicate a new file.
772  */
773 static char *get_next_name(char **ptr)
774 {
775         char *str = *ptr;
776         char *p, *start;
777
778         if (!str || !strlen(str))
779                 return NULL;
780
781         start = str;
782         do {
783                 /*
784                  * No colon, we are done
785                  */
786                 p = strchr(str, ':');
787                 if (!p) {
788                         *ptr = NULL;
789                         break;
790                 }
791
792                 /*
793                  * We got a colon, but it's the first character. Skip and
794                  * continue
795                  */
796                 if (p == start) {
797                         str = ++start;
798                         continue;
799                 }
800
801                 if (*(p - 1) != '\\') {
802                         *p = '\0';
803                         *ptr = p + 1;
804                         break;
805                 }
806
807                 memmove(p - 1, p, strlen(p) + 1);
808                 str = p;
809         } while (1);
810
811         return start;
812 }
813
814
815 static int get_max_name_idx(char *input)
816 {
817         unsigned int cur_idx;
818         char *str, *p;
819
820         p = str = strdup(input);
821         for (cur_idx = 0; ; cur_idx++)
822                 if (get_next_name(&str) == NULL)
823                         break;
824
825         free(p);
826         return cur_idx;
827 }
828
829 /*
830  * Returns the directory at the index, indexes > entires will be
831  * assigned via modulo division of the index
832  */
833 int set_name_idx(char *target, size_t tlen, char *input, int index)
834 {
835         unsigned int cur_idx;
836         int len;
837         char *fname, *str, *p;
838
839         p = str = strdup(input);
840
841         index %= get_max_name_idx(input);
842         for (cur_idx = 0; cur_idx <= index; cur_idx++)
843                 fname = get_next_name(&str);
844
845         if (client_sockaddr_str[0]) {
846                 len = snprintf(target, tlen, "%s/%s.", fname,
847                                 client_sockaddr_str);
848         } else
849                 len = snprintf(target, tlen, "%s/", fname);
850
851         target[tlen - 1] = '\0';
852         free(p);
853
854         return len;
855 }
856
857 static int str_filename_cb(void *data, const char *input)
858 {
859         struct thread_data *td = data;
860         char *fname, *str, *p;
861
862         p = str = strdup(input);
863
864         strip_blank_front(&str);
865         strip_blank_end(str);
866
867         if (!td->files_index)
868                 td->o.nr_files = 0;
869
870         while ((fname = get_next_name(&str)) != NULL) {
871                 if (!strlen(fname))
872                         break;
873                 add_file(td, fname, 0, 1);
874         }
875
876         free(p);
877         return 0;
878 }
879
880 static int str_directory_cb(void *data, const char fio_unused *unused)
881 {
882         struct thread_data *td = data;
883         struct stat sb;
884         char *dirname, *str, *p;
885         int ret = 0;
886
887         if (parse_dryrun())
888                 return 0;
889
890         p = str = strdup(td->o.directory);
891         while ((dirname = get_next_name(&str)) != NULL) {
892                 if (lstat(dirname, &sb) < 0) {
893                         ret = errno;
894
895                         log_err("fio: %s is not a directory\n", dirname);
896                         td_verror(td, ret, "lstat");
897                         goto out;
898                 }
899                 if (!S_ISDIR(sb.st_mode)) {
900                         log_err("fio: %s is not a directory\n", dirname);
901                         ret = 1;
902                         goto out;
903                 }
904         }
905
906 out:
907         free(p);
908         return ret;
909 }
910
911 static int str_opendir_cb(void *data, const char fio_unused *str)
912 {
913         struct thread_data *td = data;
914
915         if (parse_dryrun())
916                 return 0;
917
918         if (!td->files_index)
919                 td->o.nr_files = 0;
920
921         return add_dir_files(td, td->o.opendir);
922 }
923
924 static int str_buffer_pattern_cb(void *data, const char *input)
925 {
926         struct thread_data *td = data;
927         int ret;
928
929         /* FIXME: for now buffer pattern does not support formats */
930         ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
931                                      MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
932         if (ret < 0)
933                 return 1;
934
935         assert(ret != 0);
936         td->o.buffer_pattern_bytes = ret;
937         if (!td->o.compress_percentage)
938                 td->o.refill_buffers = 0;
939         td->o.scramble_buffers = 0;
940         td->o.zero_buffers = 0;
941
942         return 0;
943 }
944
945 static int str_buffer_compress_cb(void *data, unsigned long long *il)
946 {
947         struct thread_data *td = data;
948
949         td->flags |= TD_F_COMPRESS;
950         td->o.compress_percentage = *il;
951         return 0;
952 }
953
954 static int str_dedupe_cb(void *data, unsigned long long *il)
955 {
956         struct thread_data *td = data;
957
958         td->flags |= TD_F_COMPRESS;
959         td->o.dedupe_percentage = *il;
960         td->o.refill_buffers = 1;
961         return 0;
962 }
963
964 static int str_verify_pattern_cb(void *data, const char *input)
965 {
966         struct thread_data *td = data;
967         int ret;
968
969         td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
970         ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
971                                      MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
972                                      td->o.verify_fmt, &td->o.verify_fmt_sz);
973         if (ret < 0)
974                 return 1;
975
976         assert(ret != 0);
977         td->o.verify_pattern_bytes = ret;
978         /*
979          * VERIFY_* could already be set
980          */
981         if (!fio_option_is_set(&td->o, verify))
982                 td->o.verify = VERIFY_PATTERN;
983
984         return 0;
985 }
986
987 static int str_gtod_reduce_cb(void *data, int *il)
988 {
989         struct thread_data *td = data;
990         int val = *il;
991
992         td->o.disable_lat = !!val;
993         td->o.disable_clat = !!val;
994         td->o.disable_slat = !!val;
995         td->o.disable_bw = !!val;
996         td->o.clat_percentiles = !val;
997         if (val)
998                 td->tv_cache_mask = 63;
999
1000         return 0;
1001 }
1002
1003 static int str_size_cb(void *data, unsigned long long *__val)
1004 {
1005         struct thread_data *td = data;
1006         unsigned long long v = *__val;
1007
1008         if (parse_is_percent(v)) {
1009                 td->o.size = 0;
1010                 td->o.size_percent = -1ULL - v;
1011         } else
1012                 td->o.size = v;
1013
1014         return 0;
1015 }
1016
1017 static int rw_verify(struct fio_option *o, void *data)
1018 {
1019         struct thread_data *td = data;
1020
1021         if (read_only && td_write(td)) {
1022                 log_err("fio: job <%s> has write bit set, but fio is in"
1023                         " read-only mode\n", td->o.name);
1024                 return 1;
1025         }
1026
1027         return 0;
1028 }
1029
1030 static int gtod_cpu_verify(struct fio_option *o, void *data)
1031 {
1032 #ifndef FIO_HAVE_CPU_AFFINITY
1033         struct thread_data *td = data;
1034
1035         if (td->o.gtod_cpu) {
1036                 log_err("fio: platform must support CPU affinity for"
1037                         "gettimeofday() offloading\n");
1038                 return 1;
1039         }
1040 #endif
1041
1042         return 0;
1043 }
1044
1045 /*
1046  * Option grouping
1047  */
1048 static const struct opt_group fio_opt_groups[] = {
1049         {
1050                 .name   = "General",
1051                 .mask   = FIO_OPT_C_GENERAL,
1052         },
1053         {
1054                 .name   = "I/O",
1055                 .mask   = FIO_OPT_C_IO,
1056         },
1057         {
1058                 .name   = "File",
1059                 .mask   = FIO_OPT_C_FILE,
1060         },
1061         {
1062                 .name   = "Statistics",
1063                 .mask   = FIO_OPT_C_STAT,
1064         },
1065         {
1066                 .name   = "Logging",
1067                 .mask   = FIO_OPT_C_LOG,
1068         },
1069         {
1070                 .name   = "Profiles",
1071                 .mask   = FIO_OPT_C_PROFILE,
1072         },
1073         {
1074                 .name   = NULL,
1075         },
1076 };
1077
1078 static const struct opt_group *group_from_mask(const struct opt_group *ogs,
1079                                                uint64_t *mask,
1080                                                uint64_t inv_mask)
1081 {
1082         int i;
1083
1084         if (*mask == inv_mask || !*mask)
1085                 return NULL;
1086
1087         for (i = 0; ogs[i].name; i++) {
1088                 const struct opt_group *og = &ogs[i];
1089
1090                 if (*mask & og->mask) {
1091                         *mask &= ~(og->mask);
1092                         return og;
1093                 }
1094         }
1095
1096         return NULL;
1097 }
1098
1099 const struct opt_group *opt_group_from_mask(uint64_t *mask)
1100 {
1101         return group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1102 }
1103
1104 static const struct opt_group fio_opt_cat_groups[] = {
1105         {
1106                 .name   = "Latency profiling",
1107                 .mask   = FIO_OPT_G_LATPROF,
1108         },
1109         {
1110                 .name   = "Rate",
1111                 .mask   = FIO_OPT_G_RATE,
1112         },
1113         {
1114                 .name   = "Zone",
1115                 .mask   = FIO_OPT_G_ZONE,
1116         },
1117         {
1118                 .name   = "Read/write mix",
1119                 .mask   = FIO_OPT_G_RWMIX,
1120         },
1121         {
1122                 .name   = "Verify",
1123                 .mask   = FIO_OPT_G_VERIFY,
1124         },
1125         {
1126                 .name   = "Trim",
1127                 .mask   = FIO_OPT_G_TRIM,
1128         },
1129         {
1130                 .name   = "I/O Logging",
1131                 .mask   = FIO_OPT_G_IOLOG,
1132         },
1133         {
1134                 .name   = "I/O Depth",
1135                 .mask   = FIO_OPT_G_IO_DEPTH,
1136         },
1137         {
1138                 .name   = "I/O Flow",
1139                 .mask   = FIO_OPT_G_IO_FLOW,
1140         },
1141         {
1142                 .name   = "Description",
1143                 .mask   = FIO_OPT_G_DESC,
1144         },
1145         {
1146                 .name   = "Filename",
1147                 .mask   = FIO_OPT_G_FILENAME,
1148         },
1149         {
1150                 .name   = "General I/O",
1151                 .mask   = FIO_OPT_G_IO_BASIC,
1152         },
1153         {
1154                 .name   = "Cgroups",
1155                 .mask   = FIO_OPT_G_CGROUP,
1156         },
1157         {
1158                 .name   = "Runtime",
1159                 .mask   = FIO_OPT_G_RUNTIME,
1160         },
1161         {
1162                 .name   = "Process",
1163                 .mask   = FIO_OPT_G_PROCESS,
1164         },
1165         {
1166                 .name   = "Job credentials / priority",
1167                 .mask   = FIO_OPT_G_CRED,
1168         },
1169         {
1170                 .name   = "Clock settings",
1171                 .mask   = FIO_OPT_G_CLOCK,
1172         },
1173         {
1174                 .name   = "I/O Type",
1175                 .mask   = FIO_OPT_G_IO_TYPE,
1176         },
1177         {
1178                 .name   = "I/O Thinktime",
1179                 .mask   = FIO_OPT_G_THINKTIME,
1180         },
1181         {
1182                 .name   = "Randomizations",
1183                 .mask   = FIO_OPT_G_RANDOM,
1184         },
1185         {
1186                 .name   = "I/O buffers",
1187                 .mask   = FIO_OPT_G_IO_BUF,
1188         },
1189         {
1190                 .name   = "Tiobench profile",
1191                 .mask   = FIO_OPT_G_TIOBENCH,
1192         },
1193         {
1194                 .name   = "MTD",
1195                 .mask   = FIO_OPT_G_MTD,
1196         },
1197
1198         {
1199                 .name   = NULL,
1200         }
1201 };
1202
1203 const struct opt_group *opt_group_cat_from_mask(uint64_t *mask)
1204 {
1205         return group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1206 }
1207
1208 /*
1209  * Map of job/command line options
1210  */
1211 struct fio_option fio_options[FIO_MAX_OPTS] = {
1212         {
1213                 .name   = "description",
1214                 .lname  = "Description of job",
1215                 .type   = FIO_OPT_STR_STORE,
1216                 .off1   = td_var_offset(description),
1217                 .help   = "Text job description",
1218                 .category = FIO_OPT_C_GENERAL,
1219                 .group  = FIO_OPT_G_DESC,
1220         },
1221         {
1222                 .name   = "name",
1223                 .lname  = "Job name",
1224                 .type   = FIO_OPT_STR_STORE,
1225                 .off1   = td_var_offset(name),
1226                 .help   = "Name of this job",
1227                 .category = FIO_OPT_C_GENERAL,
1228                 .group  = FIO_OPT_G_DESC,
1229         },
1230         {
1231                 .name   = "wait_for",
1232                 .lname  = "Waitee name",
1233                 .type   = FIO_OPT_STR_STORE,
1234                 .off1   = td_var_offset(wait_for),
1235                 .help   = "Name of the job this one wants to wait for before starting",
1236                 .category = FIO_OPT_C_GENERAL,
1237                 .group  = FIO_OPT_G_DESC,
1238         },
1239         {
1240                 .name   = "filename",
1241                 .lname  = "Filename(s)",
1242                 .type   = FIO_OPT_STR_STORE,
1243                 .off1   = td_var_offset(filename),
1244                 .cb     = str_filename_cb,
1245                 .prio   = -1, /* must come after "directory" */
1246                 .help   = "File(s) to use for the workload",
1247                 .category = FIO_OPT_C_FILE,
1248                 .group  = FIO_OPT_G_FILENAME,
1249         },
1250         {
1251                 .name   = "directory",
1252                 .lname  = "Directory",
1253                 .type   = FIO_OPT_STR_STORE,
1254                 .off1   = td_var_offset(directory),
1255                 .cb     = str_directory_cb,
1256                 .help   = "Directory to store files in",
1257                 .category = FIO_OPT_C_FILE,
1258                 .group  = FIO_OPT_G_FILENAME,
1259         },
1260         {
1261                 .name   = "filename_format",
1262                 .type   = FIO_OPT_STR_STORE,
1263                 .off1   = td_var_offset(filename_format),
1264                 .prio   = -1, /* must come after "directory" */
1265                 .help   = "Override default $jobname.$jobnum.$filenum naming",
1266                 .def    = "$jobname.$jobnum.$filenum",
1267                 .category = FIO_OPT_C_FILE,
1268                 .group  = FIO_OPT_G_FILENAME,
1269         },
1270         {
1271                 .name   = "lockfile",
1272                 .lname  = "Lockfile",
1273                 .type   = FIO_OPT_STR,
1274                 .off1   = td_var_offset(file_lock_mode),
1275                 .help   = "Lock file when doing IO to it",
1276                 .prio   = 1,
1277                 .parent = "filename",
1278                 .hide   = 0,
1279                 .def    = "none",
1280                 .category = FIO_OPT_C_FILE,
1281                 .group  = FIO_OPT_G_FILENAME,
1282                 .posval = {
1283                           { .ival = "none",
1284                             .oval = FILE_LOCK_NONE,
1285                             .help = "No file locking",
1286                           },
1287                           { .ival = "exclusive",
1288                             .oval = FILE_LOCK_EXCLUSIVE,
1289                             .help = "Exclusive file lock",
1290                           },
1291                           {
1292                             .ival = "readwrite",
1293                             .oval = FILE_LOCK_READWRITE,
1294                             .help = "Read vs write lock",
1295                           },
1296                 },
1297         },
1298         {
1299                 .name   = "opendir",
1300                 .lname  = "Open directory",
1301                 .type   = FIO_OPT_STR_STORE,
1302                 .off1   = td_var_offset(opendir),
1303                 .cb     = str_opendir_cb,
1304                 .help   = "Recursively add files from this directory and down",
1305                 .category = FIO_OPT_C_FILE,
1306                 .group  = FIO_OPT_G_FILENAME,
1307         },
1308         {
1309                 .name   = "rw",
1310                 .lname  = "Read/write",
1311                 .alias  = "readwrite",
1312                 .type   = FIO_OPT_STR,
1313                 .cb     = str_rw_cb,
1314                 .off1   = td_var_offset(td_ddir),
1315                 .help   = "IO direction",
1316                 .def    = "read",
1317                 .verify = rw_verify,
1318                 .category = FIO_OPT_C_IO,
1319                 .group  = FIO_OPT_G_IO_BASIC,
1320                 .posval = {
1321                           { .ival = "read",
1322                             .oval = TD_DDIR_READ,
1323                             .help = "Sequential read",
1324                           },
1325                           { .ival = "write",
1326                             .oval = TD_DDIR_WRITE,
1327                             .help = "Sequential write",
1328                           },
1329                           { .ival = "trim",
1330                             .oval = TD_DDIR_TRIM,
1331                             .help = "Sequential trim",
1332                           },
1333                           { .ival = "randread",
1334                             .oval = TD_DDIR_RANDREAD,
1335                             .help = "Random read",
1336                           },
1337                           { .ival = "randwrite",
1338                             .oval = TD_DDIR_RANDWRITE,
1339                             .help = "Random write",
1340                           },
1341                           { .ival = "randtrim",
1342                             .oval = TD_DDIR_RANDTRIM,
1343                             .help = "Random trim",
1344                           },
1345                           { .ival = "rw",
1346                             .oval = TD_DDIR_RW,
1347                             .help = "Sequential read and write mix",
1348                           },
1349                           { .ival = "readwrite",
1350                             .oval = TD_DDIR_RW,
1351                             .help = "Sequential read and write mix",
1352                           },
1353                           { .ival = "randrw",
1354                             .oval = TD_DDIR_RANDRW,
1355                             .help = "Random read and write mix"
1356                           },
1357                           { .ival = "trimwrite",
1358                             .oval = TD_DDIR_TRIMWRITE,
1359                             .help = "Trim and write mix, trims preceding writes"
1360                           },
1361                 },
1362         },
1363         {
1364                 .name   = "rw_sequencer",
1365                 .lname  = "RW Sequencer",
1366                 .type   = FIO_OPT_STR,
1367                 .off1   = td_var_offset(rw_seq),
1368                 .help   = "IO offset generator modifier",
1369                 .def    = "sequential",
1370                 .category = FIO_OPT_C_IO,
1371                 .group  = FIO_OPT_G_IO_BASIC,
1372                 .posval = {
1373                           { .ival = "sequential",
1374                             .oval = RW_SEQ_SEQ,
1375                             .help = "Generate sequential offsets",
1376                           },
1377                           { .ival = "identical",
1378                             .oval = RW_SEQ_IDENT,
1379                             .help = "Generate identical offsets",
1380                           },
1381                 },
1382         },
1383
1384         {
1385                 .name   = "ioengine",
1386                 .lname  = "IO Engine",
1387                 .type   = FIO_OPT_STR_STORE,
1388                 .off1   = td_var_offset(ioengine),
1389                 .help   = "IO engine to use",
1390                 .def    = FIO_PREFERRED_ENGINE,
1391                 .category = FIO_OPT_C_IO,
1392                 .group  = FIO_OPT_G_IO_BASIC,
1393                 .posval = {
1394                           { .ival = "sync",
1395                             .help = "Use read/write",
1396                           },
1397                           { .ival = "psync",
1398                             .help = "Use pread/pwrite",
1399                           },
1400                           { .ival = "vsync",
1401                             .help = "Use readv/writev",
1402                           },
1403 #ifdef CONFIG_PWRITEV
1404                           { .ival = "pvsync",
1405                             .help = "Use preadv/pwritev",
1406                           },
1407 #endif
1408 #ifdef CONFIG_LIBAIO
1409                           { .ival = "libaio",
1410                             .help = "Linux native asynchronous IO",
1411                           },
1412 #endif
1413 #ifdef CONFIG_POSIXAIO
1414                           { .ival = "posixaio",
1415                             .help = "POSIX asynchronous IO",
1416                           },
1417 #endif
1418 #ifdef CONFIG_SOLARISAIO
1419                           { .ival = "solarisaio",
1420                             .help = "Solaris native asynchronous IO",
1421                           },
1422 #endif
1423 #ifdef CONFIG_WINDOWSAIO
1424                           { .ival = "windowsaio",
1425                             .help = "Windows native asynchronous IO"
1426                           },
1427 #endif
1428 #ifdef CONFIG_RBD
1429                           { .ival = "rbd",
1430                             .help = "Rados Block Device asynchronous IO"
1431                           },
1432 #endif
1433                           { .ival = "mmap",
1434                             .help = "Memory mapped IO"
1435                           },
1436 #ifdef CONFIG_LINUX_SPLICE
1437                           { .ival = "splice",
1438                             .help = "splice/vmsplice based IO",
1439                           },
1440                           { .ival = "netsplice",
1441                             .help = "splice/vmsplice to/from the network",
1442                           },
1443 #endif
1444 #ifdef FIO_HAVE_SGIO
1445                           { .ival = "sg",
1446                             .help = "SCSI generic v3 IO",
1447                           },
1448 #endif
1449                           { .ival = "null",
1450                             .help = "Testing engine (no data transfer)",
1451                           },
1452                           { .ival = "net",
1453                             .help = "Network IO",
1454                           },
1455                           { .ival = "cpuio",
1456                             .help = "CPU cycle burner engine",
1457                           },
1458 #ifdef CONFIG_GUASI
1459                           { .ival = "guasi",
1460                             .help = "GUASI IO engine",
1461                           },
1462 #endif
1463 #ifdef FIO_HAVE_BINJECT
1464                           { .ival = "binject",
1465                             .help = "binject direct inject block engine",
1466                           },
1467 #endif
1468 #ifdef CONFIG_RDMA
1469                           { .ival = "rdma",
1470                             .help = "RDMA IO engine",
1471                           },
1472 #endif
1473 #ifdef CONFIG_FUSION_AW
1474                           { .ival = "fusion-aw-sync",
1475                             .help = "Fusion-io atomic write engine",
1476                           },
1477 #endif
1478 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1479                           { .ival = "e4defrag",
1480                             .help = "ext4 defrag engine",
1481                           },
1482 #endif
1483 #ifdef CONFIG_LINUX_FALLOCATE
1484                           { .ival = "falloc",
1485                             .help = "fallocate() file based engine",
1486                           },
1487 #endif
1488 #ifdef CONFIG_GFAPI
1489                           { .ival = "gfapi",
1490                             .help = "Glusterfs libgfapi(sync) based engine"
1491                           },
1492                           { .ival = "gfapi_async",
1493                             .help = "Glusterfs libgfapi(async) based engine"
1494                           },
1495 #endif
1496 #ifdef CONFIG_LIBHDFS
1497                           { .ival = "libhdfs",
1498                             .help = "Hadoop Distributed Filesystem (HDFS) engine"
1499                           },
1500 #endif
1501                           { .ival = "external",
1502                             .help = "Load external engine (append name)",
1503                           },
1504                 },
1505         },
1506         {
1507                 .name   = "iodepth",
1508                 .lname  = "IO Depth",
1509                 .type   = FIO_OPT_INT,
1510                 .off1   = td_var_offset(iodepth),
1511                 .help   = "Number of IO buffers to keep in flight",
1512                 .minval = 1,
1513                 .interval = 1,
1514                 .def    = "1",
1515                 .category = FIO_OPT_C_IO,
1516                 .group  = FIO_OPT_G_IO_BASIC,
1517         },
1518         {
1519                 .name   = "iodepth_batch",
1520                 .lname  = "IO Depth batch",
1521                 .alias  = "iodepth_batch_submit",
1522                 .type   = FIO_OPT_INT,
1523                 .off1   = td_var_offset(iodepth_batch),
1524                 .help   = "Number of IO buffers to submit in one go",
1525                 .parent = "iodepth",
1526                 .hide   = 1,
1527                 .minval = 1,
1528                 .interval = 1,
1529                 .def    = "1",
1530                 .category = FIO_OPT_C_IO,
1531                 .group  = FIO_OPT_G_IO_BASIC,
1532         },
1533         {
1534                 .name   = "iodepth_batch_complete_min",
1535                 .lname  = "Min IO depth batch complete",
1536                 .alias  = "iodepth_batch_complete",
1537                 .type   = FIO_OPT_INT,
1538                 .off1   = td_var_offset(iodepth_batch_complete_min),
1539                 .help   = "Min number of IO buffers to retrieve in one go",
1540                 .parent = "iodepth",
1541                 .hide   = 1,
1542                 .minval = 0,
1543                 .interval = 1,
1544                 .def    = "1",
1545                 .category = FIO_OPT_C_IO,
1546                 .group  = FIO_OPT_G_IO_BASIC,
1547         },
1548         {
1549                 .name   = "iodepth_batch_complete_max",
1550                 .lname  = "Max IO depth batch complete",
1551                 .type   = FIO_OPT_INT,
1552                 .off1   = td_var_offset(iodepth_batch_complete_max),
1553                 .help   = "Max number of IO buffers to retrieve in one go",
1554                 .parent = "iodepth",
1555                 .hide   = 1,
1556                 .minval = 0,
1557                 .interval = 1,
1558                 .category = FIO_OPT_C_IO,
1559                 .group  = FIO_OPT_G_IO_BASIC,
1560         },
1561         {
1562                 .name   = "iodepth_low",
1563                 .lname  = "IO Depth batch low",
1564                 .type   = FIO_OPT_INT,
1565                 .off1   = td_var_offset(iodepth_low),
1566                 .help   = "Low water mark for queuing depth",
1567                 .parent = "iodepth",
1568                 .hide   = 1,
1569                 .interval = 1,
1570                 .category = FIO_OPT_C_IO,
1571                 .group  = FIO_OPT_G_IO_BASIC,
1572         },
1573         {
1574                 .name   = "io_submit_mode",
1575                 .lname  = "IO submit mode",
1576                 .type   = FIO_OPT_STR,
1577                 .off1   = td_var_offset(io_submit_mode),
1578                 .help   = "How IO submissions and completions are done",
1579                 .def    = "inline",
1580                 .category = FIO_OPT_C_IO,
1581                 .group  = FIO_OPT_G_IO_BASIC,
1582                 .posval = {
1583                           { .ival = "inline",
1584                             .oval = IO_MODE_INLINE,
1585                             .help = "Submit and complete IO inline",
1586                           },
1587                           { .ival = "offload",
1588                             .oval = IO_MODE_OFFLOAD,
1589                             .help = "Offload submit and complete to threads",
1590                           },
1591                 },
1592         },
1593         {
1594                 .name   = "size",
1595                 .lname  = "Size",
1596                 .type   = FIO_OPT_STR_VAL,
1597                 .cb     = str_size_cb,
1598                 .off1   = td_var_offset(size),
1599                 .help   = "Total size of device or files",
1600                 .interval = 1024 * 1024,
1601                 .category = FIO_OPT_C_IO,
1602                 .group  = FIO_OPT_G_INVALID,
1603         },
1604         {
1605                 .name   = "io_size",
1606                 .alias  = "io_limit",
1607                 .lname  = "IO Size",
1608                 .type   = FIO_OPT_STR_VAL,
1609                 .off1   = td_var_offset(io_limit),
1610                 .interval = 1024 * 1024,
1611                 .category = FIO_OPT_C_IO,
1612                 .group  = FIO_OPT_G_INVALID,
1613         },
1614         {
1615                 .name   = "fill_device",
1616                 .lname  = "Fill device",
1617                 .alias  = "fill_fs",
1618                 .type   = FIO_OPT_BOOL,
1619                 .off1   = td_var_offset(fill_device),
1620                 .help   = "Write until an ENOSPC error occurs",
1621                 .def    = "0",
1622                 .category = FIO_OPT_C_FILE,
1623                 .group  = FIO_OPT_G_INVALID,
1624         },
1625         {
1626                 .name   = "filesize",
1627                 .lname  = "File size",
1628                 .type   = FIO_OPT_STR_VAL,
1629                 .off1   = td_var_offset(file_size_low),
1630                 .off2   = td_var_offset(file_size_high),
1631                 .minval = 1,
1632                 .help   = "Size of individual files",
1633                 .interval = 1024 * 1024,
1634                 .category = FIO_OPT_C_FILE,
1635                 .group  = FIO_OPT_G_INVALID,
1636         },
1637         {
1638                 .name   = "file_append",
1639                 .lname  = "File append",
1640                 .type   = FIO_OPT_BOOL,
1641                 .off1   = td_var_offset(file_append),
1642                 .help   = "IO will start at the end of the file(s)",
1643                 .def    = "0",
1644                 .category = FIO_OPT_C_FILE,
1645                 .group  = FIO_OPT_G_INVALID,
1646         },
1647         {
1648                 .name   = "offset",
1649                 .lname  = "IO offset",
1650                 .alias  = "fileoffset",
1651                 .type   = FIO_OPT_STR_VAL,
1652                 .off1   = td_var_offset(start_offset),
1653                 .help   = "Start IO from this offset",
1654                 .def    = "0",
1655                 .interval = 1024 * 1024,
1656                 .category = FIO_OPT_C_IO,
1657                 .group  = FIO_OPT_G_INVALID,
1658         },
1659         {
1660                 .name   = "offset_increment",
1661                 .lname  = "IO offset increment",
1662                 .type   = FIO_OPT_STR_VAL,
1663                 .off1   = td_var_offset(offset_increment),
1664                 .help   = "What is the increment from one offset to the next",
1665                 .parent = "offset",
1666                 .hide   = 1,
1667                 .def    = "0",
1668                 .interval = 1024 * 1024,
1669                 .category = FIO_OPT_C_IO,
1670                 .group  = FIO_OPT_G_INVALID,
1671         },
1672         {
1673                 .name   = "number_ios",
1674                 .lname  = "Number of IOs to perform",
1675                 .type   = FIO_OPT_STR_VAL,
1676                 .off1   = td_var_offset(number_ios),
1677                 .help   = "Force job completion after this number of IOs",
1678                 .def    = "0",
1679                 .category = FIO_OPT_C_IO,
1680                 .group  = FIO_OPT_G_INVALID,
1681         },
1682         {
1683                 .name   = "bs",
1684                 .lname  = "Block size",
1685                 .alias  = "blocksize",
1686                 .type   = FIO_OPT_INT,
1687                 .off1   = td_var_offset(bs[DDIR_READ]),
1688                 .off2   = td_var_offset(bs[DDIR_WRITE]),
1689                 .off3   = td_var_offset(bs[DDIR_TRIM]),
1690                 .minval = 1,
1691                 .help   = "Block size unit",
1692                 .def    = "4k",
1693                 .parent = "rw",
1694                 .hide   = 1,
1695                 .interval = 512,
1696                 .category = FIO_OPT_C_IO,
1697                 .group  = FIO_OPT_G_INVALID,
1698         },
1699         {
1700                 .name   = "ba",
1701                 .lname  = "Block size align",
1702                 .alias  = "blockalign",
1703                 .type   = FIO_OPT_INT,
1704                 .off1   = td_var_offset(ba[DDIR_READ]),
1705                 .off2   = td_var_offset(ba[DDIR_WRITE]),
1706                 .off3   = td_var_offset(ba[DDIR_TRIM]),
1707                 .minval = 1,
1708                 .help   = "IO block offset alignment",
1709                 .parent = "rw",
1710                 .hide   = 1,
1711                 .interval = 512,
1712                 .category = FIO_OPT_C_IO,
1713                 .group  = FIO_OPT_G_INVALID,
1714         },
1715         {
1716                 .name   = "bsrange",
1717                 .lname  = "Block size range",
1718                 .alias  = "blocksize_range",
1719                 .type   = FIO_OPT_RANGE,
1720                 .off1   = td_var_offset(min_bs[DDIR_READ]),
1721                 .off2   = td_var_offset(max_bs[DDIR_READ]),
1722                 .off3   = td_var_offset(min_bs[DDIR_WRITE]),
1723                 .off4   = td_var_offset(max_bs[DDIR_WRITE]),
1724                 .off5   = td_var_offset(min_bs[DDIR_TRIM]),
1725                 .off6   = td_var_offset(max_bs[DDIR_TRIM]),
1726                 .minval = 1,
1727                 .help   = "Set block size range (in more detail than bs)",
1728                 .parent = "rw",
1729                 .hide   = 1,
1730                 .interval = 4096,
1731                 .category = FIO_OPT_C_IO,
1732                 .group  = FIO_OPT_G_INVALID,
1733         },
1734         {
1735                 .name   = "bssplit",
1736                 .lname  = "Block size split",
1737                 .type   = FIO_OPT_STR,
1738                 .cb     = str_bssplit_cb,
1739                 .off1   = td_var_offset(bssplit),
1740                 .help   = "Set a specific mix of block sizes",
1741                 .parent = "rw",
1742                 .hide   = 1,
1743                 .category = FIO_OPT_C_IO,
1744                 .group  = FIO_OPT_G_INVALID,
1745         },
1746         {
1747                 .name   = "bs_unaligned",
1748                 .lname  = "Block size unaligned",
1749                 .alias  = "blocksize_unaligned",
1750                 .type   = FIO_OPT_STR_SET,
1751                 .off1   = td_var_offset(bs_unaligned),
1752                 .help   = "Don't sector align IO buffer sizes",
1753                 .parent = "rw",
1754                 .hide   = 1,
1755                 .category = FIO_OPT_C_IO,
1756                 .group  = FIO_OPT_G_INVALID,
1757         },
1758         {
1759                 .name   = "bs_is_seq_rand",
1760                 .lname  = "Block size division is seq/random (not read/write)",
1761                 .type   = FIO_OPT_BOOL,
1762                 .off1   = td_var_offset(bs_is_seq_rand),
1763                 .help   = "Consider any blocksize setting to be sequential,random",
1764                 .def    = "0",
1765                 .parent = "blocksize",
1766                 .category = FIO_OPT_C_IO,
1767                 .group  = FIO_OPT_G_INVALID,
1768         },
1769         {
1770                 .name   = "randrepeat",
1771                 .lname  = "Random repeatable",
1772                 .type   = FIO_OPT_BOOL,
1773                 .off1   = td_var_offset(rand_repeatable),
1774                 .help   = "Use repeatable random IO pattern",
1775                 .def    = "1",
1776                 .parent = "rw",
1777                 .hide   = 1,
1778                 .category = FIO_OPT_C_IO,
1779                 .group  = FIO_OPT_G_RANDOM,
1780         },
1781         {
1782                 .name   = "randseed",
1783                 .lname  = "The random generator seed",
1784                 .type   = FIO_OPT_STR_VAL,
1785                 .off1   = td_var_offset(rand_seed),
1786                 .help   = "Set the random generator seed value",
1787                 .def    = "0x89",
1788                 .parent = "rw",
1789                 .category = FIO_OPT_C_IO,
1790                 .group  = FIO_OPT_G_RANDOM,
1791         },
1792         {
1793                 .name   = "use_os_rand",
1794                 .lname  = "Use OS random",
1795                 .type   = FIO_OPT_DEPRECATED,
1796                 .off1   = td_var_offset(dep_use_os_rand),
1797                 .category = FIO_OPT_C_IO,
1798                 .group  = FIO_OPT_G_RANDOM,
1799         },
1800         {
1801                 .name   = "norandommap",
1802                 .lname  = "No randommap",
1803                 .type   = FIO_OPT_STR_SET,
1804                 .off1   = td_var_offset(norandommap),
1805                 .help   = "Accept potential duplicate random blocks",
1806                 .parent = "rw",
1807                 .hide   = 1,
1808                 .hide_on_set = 1,
1809                 .category = FIO_OPT_C_IO,
1810                 .group  = FIO_OPT_G_RANDOM,
1811         },
1812         {
1813                 .name   = "softrandommap",
1814                 .lname  = "Soft randommap",
1815                 .type   = FIO_OPT_BOOL,
1816                 .off1   = td_var_offset(softrandommap),
1817                 .help   = "Set norandommap if randommap allocation fails",
1818                 .parent = "norandommap",
1819                 .hide   = 1,
1820                 .def    = "0",
1821                 .category = FIO_OPT_C_IO,
1822                 .group  = FIO_OPT_G_RANDOM,
1823         },
1824         {
1825                 .name   = "random_generator",
1826                 .type   = FIO_OPT_STR,
1827                 .off1   = td_var_offset(random_generator),
1828                 .help   = "Type of random number generator to use",
1829                 .def    = "tausworthe",
1830                 .posval = {
1831                           { .ival = "tausworthe",
1832                             .oval = FIO_RAND_GEN_TAUSWORTHE,
1833                             .help = "Strong Tausworthe generator",
1834                           },
1835                           { .ival = "lfsr",
1836                             .oval = FIO_RAND_GEN_LFSR,
1837                             .help = "Variable length LFSR",
1838                           },
1839                           {
1840                             .ival = "tausworthe64",
1841                             .oval = FIO_RAND_GEN_TAUSWORTHE64,
1842                             .help = "64-bit Tausworthe variant",
1843                           },
1844                 },
1845                 .category = FIO_OPT_C_IO,
1846                 .group  = FIO_OPT_G_RANDOM,
1847         },
1848         {
1849                 .name   = "random_distribution",
1850                 .type   = FIO_OPT_STR,
1851                 .off1   = td_var_offset(random_distribution),
1852                 .cb     = str_random_distribution_cb,
1853                 .help   = "Random offset distribution generator",
1854                 .def    = "random",
1855                 .posval = {
1856                           { .ival = "random",
1857                             .oval = FIO_RAND_DIST_RANDOM,
1858                             .help = "Completely random",
1859                           },
1860                           { .ival = "zipf",
1861                             .oval = FIO_RAND_DIST_ZIPF,
1862                             .help = "Zipf distribution",
1863                           },
1864                           { .ival = "pareto",
1865                             .oval = FIO_RAND_DIST_PARETO,
1866                             .help = "Pareto distribution",
1867                           },
1868                           { .ival = "normal",
1869                             .oval = FIO_RAND_DIST_GAUSS,
1870                             .help = "Normal (gaussian) distribution",
1871                           },
1872                 },
1873                 .category = FIO_OPT_C_IO,
1874                 .group  = FIO_OPT_G_RANDOM,
1875         },
1876         {
1877                 .name   = "percentage_random",
1878                 .lname  = "Percentage Random",
1879                 .type   = FIO_OPT_INT,
1880                 .off1   = td_var_offset(perc_rand[DDIR_READ]),
1881                 .off2   = td_var_offset(perc_rand[DDIR_WRITE]),
1882                 .off3   = td_var_offset(perc_rand[DDIR_TRIM]),
1883                 .maxval = 100,
1884                 .help   = "Percentage of seq/random mix that should be random",
1885                 .def    = "100,100,100",
1886                 .interval = 5,
1887                 .inverse = "percentage_sequential",
1888                 .category = FIO_OPT_C_IO,
1889                 .group  = FIO_OPT_G_RANDOM,
1890         },
1891         {
1892                 .name   = "percentage_sequential",
1893                 .lname  = "Percentage Sequential",
1894                 .type   = FIO_OPT_DEPRECATED,
1895                 .category = FIO_OPT_C_IO,
1896                 .group  = FIO_OPT_G_RANDOM,
1897         },
1898         {
1899                 .name   = "allrandrepeat",
1900                 .type   = FIO_OPT_BOOL,
1901                 .off1   = td_var_offset(allrand_repeatable),
1902                 .help   = "Use repeatable random numbers for everything",
1903                 .def    = "0",
1904                 .category = FIO_OPT_C_IO,
1905                 .group  = FIO_OPT_G_RANDOM,
1906         },
1907         {
1908                 .name   = "nrfiles",
1909                 .lname  = "Number of files",
1910                 .alias  = "nr_files",
1911                 .type   = FIO_OPT_INT,
1912                 .off1   = td_var_offset(nr_files),
1913                 .help   = "Split job workload between this number of files",
1914                 .def    = "1",
1915                 .interval = 1,
1916                 .category = FIO_OPT_C_FILE,
1917                 .group  = FIO_OPT_G_INVALID,
1918         },
1919         {
1920                 .name   = "openfiles",
1921                 .lname  = "Number of open files",
1922                 .type   = FIO_OPT_INT,
1923                 .off1   = td_var_offset(open_files),
1924                 .help   = "Number of files to keep open at the same time",
1925                 .category = FIO_OPT_C_FILE,
1926                 .group  = FIO_OPT_G_INVALID,
1927         },
1928         {
1929                 .name   = "file_service_type",
1930                 .lname  = "File service type",
1931                 .type   = FIO_OPT_STR,
1932                 .cb     = str_fst_cb,
1933                 .off1   = td_var_offset(file_service_type),
1934                 .help   = "How to select which file to service next",
1935                 .def    = "roundrobin",
1936                 .category = FIO_OPT_C_FILE,
1937                 .group  = FIO_OPT_G_INVALID,
1938                 .posval = {
1939                           { .ival = "random",
1940                             .oval = FIO_FSERVICE_RANDOM,
1941                             .help = "Choose a file at random",
1942                           },
1943                           { .ival = "roundrobin",
1944                             .oval = FIO_FSERVICE_RR,
1945                             .help = "Round robin select files",
1946                           },
1947                           { .ival = "sequential",
1948                             .oval = FIO_FSERVICE_SEQ,
1949                             .help = "Finish one file before moving to the next",
1950                           },
1951                 },
1952                 .parent = "nrfiles",
1953                 .hide   = 1,
1954         },
1955 #ifdef CONFIG_POSIX_FALLOCATE
1956         {
1957                 .name   = "fallocate",
1958                 .lname  = "Fallocate",
1959                 .type   = FIO_OPT_STR,
1960                 .off1   = td_var_offset(fallocate_mode),
1961                 .help   = "Whether pre-allocation is performed when laying out files",
1962                 .def    = "posix",
1963                 .category = FIO_OPT_C_FILE,
1964                 .group  = FIO_OPT_G_INVALID,
1965                 .posval = {
1966                           { .ival = "none",
1967                             .oval = FIO_FALLOCATE_NONE,
1968                             .help = "Do not pre-allocate space",
1969                           },
1970                           { .ival = "posix",
1971                             .oval = FIO_FALLOCATE_POSIX,
1972                             .help = "Use posix_fallocate()",
1973                           },
1974 #ifdef CONFIG_LINUX_FALLOCATE
1975                           { .ival = "keep",
1976                             .oval = FIO_FALLOCATE_KEEP_SIZE,
1977                             .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1978                           },
1979 #endif
1980                           /* Compatibility with former boolean values */
1981                           { .ival = "0",
1982                             .oval = FIO_FALLOCATE_NONE,
1983                             .help = "Alias for 'none'",
1984                           },
1985                           { .ival = "1",
1986                             .oval = FIO_FALLOCATE_POSIX,
1987                             .help = "Alias for 'posix'",
1988                           },
1989                 },
1990         },
1991 #endif  /* CONFIG_POSIX_FALLOCATE */
1992         {
1993                 .name   = "fadvise_hint",
1994                 .lname  = "Fadvise hint",
1995                 .type   = FIO_OPT_BOOL,
1996                 .off1   = td_var_offset(fadvise_hint),
1997                 .help   = "Use fadvise() to advise the kernel on IO pattern",
1998                 .def    = "1",
1999                 .category = FIO_OPT_C_FILE,
2000                 .group  = FIO_OPT_G_INVALID,
2001         },
2002 #ifdef FIO_HAVE_STREAMID
2003         {
2004                 .name   = "fadvise_stream",
2005                 .lname  = "Fadvise stream",
2006                 .type   = FIO_OPT_INT,
2007                 .off1   = td_var_offset(fadvise_stream),
2008                 .help   = "Use fadvise() to set stream ID",
2009                 .category = FIO_OPT_C_FILE,
2010                 .group  = FIO_OPT_G_INVALID,
2011         },
2012 #endif
2013         {
2014                 .name   = "fsync",
2015                 .lname  = "Fsync",
2016                 .type   = FIO_OPT_INT,
2017                 .off1   = td_var_offset(fsync_blocks),
2018                 .help   = "Issue fsync for writes every given number of blocks",
2019                 .def    = "0",
2020                 .interval = 1,
2021                 .category = FIO_OPT_C_FILE,
2022                 .group  = FIO_OPT_G_INVALID,
2023         },
2024         {
2025                 .name   = "fdatasync",
2026                 .lname  = "Fdatasync",
2027                 .type   = FIO_OPT_INT,
2028                 .off1   = td_var_offset(fdatasync_blocks),
2029                 .help   = "Issue fdatasync for writes every given number of blocks",
2030                 .def    = "0",
2031                 .interval = 1,
2032                 .category = FIO_OPT_C_FILE,
2033                 .group  = FIO_OPT_G_INVALID,
2034         },
2035         {
2036                 .name   = "write_barrier",
2037                 .lname  = "Write barrier",
2038                 .type   = FIO_OPT_INT,
2039                 .off1   = td_var_offset(barrier_blocks),
2040                 .help   = "Make every Nth write a barrier write",
2041                 .def    = "0",
2042                 .interval = 1,
2043                 .category = FIO_OPT_C_IO,
2044                 .group  = FIO_OPT_G_INVALID,
2045         },
2046 #ifdef CONFIG_SYNC_FILE_RANGE
2047         {
2048                 .name   = "sync_file_range",
2049                 .lname  = "Sync file range",
2050                 .posval = {
2051                           { .ival = "wait_before",
2052                             .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2053                             .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2054                             .orval  = 1,
2055                           },
2056                           { .ival = "write",
2057                             .oval = SYNC_FILE_RANGE_WRITE,
2058                             .help = "SYNC_FILE_RANGE_WRITE",
2059                             .orval  = 1,
2060                           },
2061                           {
2062                             .ival = "wait_after",
2063                             .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2064                             .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2065                             .orval  = 1,
2066                           },
2067                 },
2068                 .type   = FIO_OPT_STR_MULTI,
2069                 .cb     = str_sfr_cb,
2070                 .off1   = td_var_offset(sync_file_range),
2071                 .help   = "Use sync_file_range()",
2072                 .category = FIO_OPT_C_FILE,
2073                 .group  = FIO_OPT_G_INVALID,
2074         },
2075 #endif
2076         {
2077                 .name   = "direct",
2078                 .lname  = "Direct I/O",
2079                 .type   = FIO_OPT_BOOL,
2080                 .off1   = td_var_offset(odirect),
2081                 .help   = "Use O_DIRECT IO (negates buffered)",
2082                 .def    = "0",
2083                 .inverse = "buffered",
2084                 .category = FIO_OPT_C_IO,
2085                 .group  = FIO_OPT_G_IO_TYPE,
2086         },
2087         {
2088                 .name   = "atomic",
2089                 .lname  = "Atomic I/O",
2090                 .type   = FIO_OPT_BOOL,
2091                 .off1   = td_var_offset(oatomic),
2092                 .help   = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2093                 .def    = "0",
2094                 .category = FIO_OPT_C_IO,
2095                 .group  = FIO_OPT_G_IO_TYPE,
2096         },
2097         {
2098                 .name   = "buffered",
2099                 .lname  = "Buffered I/O",
2100                 .type   = FIO_OPT_BOOL,
2101                 .off1   = td_var_offset(odirect),
2102                 .neg    = 1,
2103                 .help   = "Use buffered IO (negates direct)",
2104                 .def    = "1",
2105                 .inverse = "direct",
2106                 .category = FIO_OPT_C_IO,
2107                 .group  = FIO_OPT_G_IO_TYPE,
2108         },
2109         {
2110                 .name   = "overwrite",
2111                 .lname  = "Overwrite",
2112                 .type   = FIO_OPT_BOOL,
2113                 .off1   = td_var_offset(overwrite),
2114                 .help   = "When writing, set whether to overwrite current data",
2115                 .def    = "0",
2116                 .category = FIO_OPT_C_FILE,
2117                 .group  = FIO_OPT_G_INVALID,
2118         },
2119         {
2120                 .name   = "loops",
2121                 .lname  = "Loops",
2122                 .type   = FIO_OPT_INT,
2123                 .off1   = td_var_offset(loops),
2124                 .help   = "Number of times to run the job",
2125                 .def    = "1",
2126                 .interval = 1,
2127                 .category = FIO_OPT_C_GENERAL,
2128                 .group  = FIO_OPT_G_RUNTIME,
2129         },
2130         {
2131                 .name   = "numjobs",
2132                 .lname  = "Number of jobs",
2133                 .type   = FIO_OPT_INT,
2134                 .off1   = td_var_offset(numjobs),
2135                 .help   = "Duplicate this job this many times",
2136                 .def    = "1",
2137                 .interval = 1,
2138                 .category = FIO_OPT_C_GENERAL,
2139                 .group  = FIO_OPT_G_RUNTIME,
2140         },
2141         {
2142                 .name   = "startdelay",
2143                 .lname  = "Start delay",
2144                 .type   = FIO_OPT_STR_VAL_TIME,
2145                 .off1   = td_var_offset(start_delay),
2146                 .off2   = td_var_offset(start_delay_high),
2147                 .help   = "Only start job when this period has passed",
2148                 .def    = "0",
2149                 .is_seconds = 1,
2150                 .is_time = 1,
2151                 .category = FIO_OPT_C_GENERAL,
2152                 .group  = FIO_OPT_G_RUNTIME,
2153         },
2154         {
2155                 .name   = "runtime",
2156                 .lname  = "Runtime",
2157                 .alias  = "timeout",
2158                 .type   = FIO_OPT_STR_VAL_TIME,
2159                 .off1   = td_var_offset(timeout),
2160                 .help   = "Stop workload when this amount of time has passed",
2161                 .def    = "0",
2162                 .is_seconds = 1,
2163                 .is_time = 1,
2164                 .category = FIO_OPT_C_GENERAL,
2165                 .group  = FIO_OPT_G_RUNTIME,
2166         },
2167         {
2168                 .name   = "time_based",
2169                 .lname  = "Time based",
2170                 .type   = FIO_OPT_STR_SET,
2171                 .off1   = td_var_offset(time_based),
2172                 .help   = "Keep running until runtime/timeout is met",
2173                 .category = FIO_OPT_C_GENERAL,
2174                 .group  = FIO_OPT_G_RUNTIME,
2175         },
2176         {
2177                 .name   = "verify_only",
2178                 .lname  = "Verify only",
2179                 .type   = FIO_OPT_STR_SET,
2180                 .off1   = td_var_offset(verify_only),
2181                 .help   = "Verifies previously written data is still valid",
2182                 .category = FIO_OPT_C_GENERAL,
2183                 .group  = FIO_OPT_G_RUNTIME,
2184         },
2185         {
2186                 .name   = "ramp_time",
2187                 .lname  = "Ramp time",
2188                 .type   = FIO_OPT_STR_VAL_TIME,
2189                 .off1   = td_var_offset(ramp_time),
2190                 .help   = "Ramp up time before measuring performance",
2191                 .is_seconds = 1,
2192                 .is_time = 1,
2193                 .category = FIO_OPT_C_GENERAL,
2194                 .group  = FIO_OPT_G_RUNTIME,
2195         },
2196         {
2197                 .name   = "clocksource",
2198                 .lname  = "Clock source",
2199                 .type   = FIO_OPT_STR,
2200                 .cb     = fio_clock_source_cb,
2201                 .off1   = td_var_offset(clocksource),
2202                 .help   = "What type of timing source to use",
2203                 .category = FIO_OPT_C_GENERAL,
2204                 .group  = FIO_OPT_G_CLOCK,
2205                 .posval = {
2206 #ifdef CONFIG_GETTIMEOFDAY
2207                           { .ival = "gettimeofday",
2208                             .oval = CS_GTOD,
2209                             .help = "Use gettimeofday(2) for timing",
2210                           },
2211 #endif
2212 #ifdef CONFIG_CLOCK_GETTIME
2213                           { .ival = "clock_gettime",
2214                             .oval = CS_CGETTIME,
2215                             .help = "Use clock_gettime(2) for timing",
2216                           },
2217 #endif
2218 #ifdef ARCH_HAVE_CPU_CLOCK
2219                           { .ival = "cpu",
2220                             .oval = CS_CPUCLOCK,
2221                             .help = "Use CPU private clock",
2222                           },
2223 #endif
2224                 },
2225         },
2226         {
2227                 .name   = "mem",
2228                 .alias  = "iomem",
2229                 .lname  = "I/O Memory",
2230                 .type   = FIO_OPT_STR,
2231                 .cb     = str_mem_cb,
2232                 .off1   = td_var_offset(mem_type),
2233                 .help   = "Backing type for IO buffers",
2234                 .def    = "malloc",
2235                 .category = FIO_OPT_C_IO,
2236                 .group  = FIO_OPT_G_INVALID,
2237                 .posval = {
2238                           { .ival = "malloc",
2239                             .oval = MEM_MALLOC,
2240                             .help = "Use malloc(3) for IO buffers",
2241                           },
2242 #ifndef CONFIG_NO_SHM
2243                           { .ival = "shm",
2244                             .oval = MEM_SHM,
2245                             .help = "Use shared memory segments for IO buffers",
2246                           },
2247 #ifdef FIO_HAVE_HUGETLB
2248                           { .ival = "shmhuge",
2249                             .oval = MEM_SHMHUGE,
2250                             .help = "Like shm, but use huge pages",
2251                           },
2252 #endif
2253 #endif
2254                           { .ival = "mmap",
2255                             .oval = MEM_MMAP,
2256                             .help = "Use mmap(2) (file or anon) for IO buffers",
2257                           },
2258                           { .ival = "mmapshared",
2259                             .oval = MEM_MMAPSHARED,
2260                             .help = "Like mmap, but use the shared flag",
2261                           },
2262 #ifdef FIO_HAVE_HUGETLB
2263                           { .ival = "mmaphuge",
2264                             .oval = MEM_MMAPHUGE,
2265                             .help = "Like mmap, but use huge pages",
2266                           },
2267 #endif
2268                   },
2269         },
2270         {
2271                 .name   = "iomem_align",
2272                 .alias  = "mem_align",
2273                 .lname  = "I/O memory alignment",
2274                 .type   = FIO_OPT_INT,
2275                 .off1   = td_var_offset(mem_align),
2276                 .minval = 0,
2277                 .help   = "IO memory buffer offset alignment",
2278                 .def    = "0",
2279                 .parent = "iomem",
2280                 .hide   = 1,
2281                 .category = FIO_OPT_C_IO,
2282                 .group  = FIO_OPT_G_INVALID,
2283         },
2284         {
2285                 .name   = "verify",
2286                 .lname  = "Verify",
2287                 .type   = FIO_OPT_STR,
2288                 .off1   = td_var_offset(verify),
2289                 .help   = "Verify data written",
2290                 .def    = "0",
2291                 .category = FIO_OPT_C_IO,
2292                 .group  = FIO_OPT_G_VERIFY,
2293                 .posval = {
2294                           { .ival = "0",
2295                             .oval = VERIFY_NONE,
2296                             .help = "Don't do IO verification",
2297                           },
2298                           { .ival = "md5",
2299                             .oval = VERIFY_MD5,
2300                             .help = "Use md5 checksums for verification",
2301                           },
2302                           { .ival = "crc64",
2303                             .oval = VERIFY_CRC64,
2304                             .help = "Use crc64 checksums for verification",
2305                           },
2306                           { .ival = "crc32",
2307                             .oval = VERIFY_CRC32,
2308                             .help = "Use crc32 checksums for verification",
2309                           },
2310                           { .ival = "crc32c-intel",
2311                             .oval = VERIFY_CRC32C,
2312                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2313                           },
2314                           { .ival = "crc32c",
2315                             .oval = VERIFY_CRC32C,
2316                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2317                           },
2318                           { .ival = "crc16",
2319                             .oval = VERIFY_CRC16,
2320                             .help = "Use crc16 checksums for verification",
2321                           },
2322                           { .ival = "crc7",
2323                             .oval = VERIFY_CRC7,
2324                             .help = "Use crc7 checksums for verification",
2325                           },
2326                           { .ival = "sha1",
2327                             .oval = VERIFY_SHA1,
2328                             .help = "Use sha1 checksums for verification",
2329                           },
2330                           { .ival = "sha256",
2331                             .oval = VERIFY_SHA256,
2332                             .help = "Use sha256 checksums for verification",
2333                           },
2334                           { .ival = "sha512",
2335                             .oval = VERIFY_SHA512,
2336                             .help = "Use sha512 checksums for verification",
2337                           },
2338                           { .ival = "xxhash",
2339                             .oval = VERIFY_XXHASH,
2340                             .help = "Use xxhash checksums for verification",
2341                           },
2342                           /* Meta information was included into verify_header,
2343                            * 'meta' verification is implied by default. */
2344                           { .ival = "meta",
2345                             .oval = VERIFY_HDR_ONLY,
2346                             .help = "Use io information for verification. "
2347                                     "Now is implied by default, thus option is obsolete, "
2348                                     "don't use it",
2349                           },
2350                           { .ival = "pattern",
2351                             .oval = VERIFY_PATTERN_NO_HDR,
2352                             .help = "Verify strict pattern",
2353                           },
2354                           {
2355                             .ival = "null",
2356                             .oval = VERIFY_NULL,
2357                             .help = "Pretend to verify",
2358                           },
2359                 },
2360         },
2361         {
2362                 .name   = "do_verify",
2363                 .lname  = "Perform verify step",
2364                 .type   = FIO_OPT_BOOL,
2365                 .off1   = td_var_offset(do_verify),
2366                 .help   = "Run verification stage after write",
2367                 .def    = "1",
2368                 .parent = "verify",
2369                 .hide   = 1,
2370                 .category = FIO_OPT_C_IO,
2371                 .group  = FIO_OPT_G_VERIFY,
2372         },
2373         {
2374                 .name   = "verifysort",
2375                 .lname  = "Verify sort",
2376                 .type   = FIO_OPT_BOOL,
2377                 .off1   = td_var_offset(verifysort),
2378                 .help   = "Sort written verify blocks for read back",
2379                 .def    = "1",
2380                 .parent = "verify",
2381                 .hide   = 1,
2382                 .category = FIO_OPT_C_IO,
2383                 .group  = FIO_OPT_G_VERIFY,
2384         },
2385         {
2386                 .name   = "verifysort_nr",
2387                 .type   = FIO_OPT_INT,
2388                 .off1   = td_var_offset(verifysort_nr),
2389                 .help   = "Pre-load and sort verify blocks for a read workload",
2390                 .minval = 0,
2391                 .maxval = 131072,
2392                 .def    = "1024",
2393                 .parent = "verify",
2394                 .category = FIO_OPT_C_IO,
2395                 .group  = FIO_OPT_G_VERIFY,
2396         },
2397         {
2398                 .name   = "verify_interval",
2399                 .lname  = "Verify interval",
2400                 .type   = FIO_OPT_INT,
2401                 .off1   = td_var_offset(verify_interval),
2402                 .minval = 2 * sizeof(struct verify_header),
2403                 .help   = "Store verify buffer header every N bytes",
2404                 .parent = "verify",
2405                 .hide   = 1,
2406                 .interval = 2 * sizeof(struct verify_header),
2407                 .category = FIO_OPT_C_IO,
2408                 .group  = FIO_OPT_G_VERIFY,
2409         },
2410         {
2411                 .name   = "verify_offset",
2412                 .lname  = "Verify offset",
2413                 .type   = FIO_OPT_INT,
2414                 .help   = "Offset verify header location by N bytes",
2415                 .off1   = td_var_offset(verify_offset),
2416                 .minval = sizeof(struct verify_header),
2417                 .parent = "verify",
2418                 .hide   = 1,
2419                 .category = FIO_OPT_C_IO,
2420                 .group  = FIO_OPT_G_VERIFY,
2421         },
2422         {
2423                 .name   = "verify_pattern",
2424                 .lname  = "Verify pattern",
2425                 .type   = FIO_OPT_STR,
2426                 .cb     = str_verify_pattern_cb,
2427                 .off1   = td_var_offset(verify_pattern),
2428                 .help   = "Fill pattern for IO buffers",
2429                 .parent = "verify",
2430                 .hide   = 1,
2431                 .category = FIO_OPT_C_IO,
2432                 .group  = FIO_OPT_G_VERIFY,
2433         },
2434         {
2435                 .name   = "verify_fatal",
2436                 .lname  = "Verify fatal",
2437                 .type   = FIO_OPT_BOOL,
2438                 .off1   = td_var_offset(verify_fatal),
2439                 .def    = "0",
2440                 .help   = "Exit on a single verify failure, don't continue",
2441                 .parent = "verify",
2442                 .hide   = 1,
2443                 .category = FIO_OPT_C_IO,
2444                 .group  = FIO_OPT_G_VERIFY,
2445         },
2446         {
2447                 .name   = "verify_dump",
2448                 .lname  = "Verify dump",
2449                 .type   = FIO_OPT_BOOL,
2450                 .off1   = td_var_offset(verify_dump),
2451                 .def    = "0",
2452                 .help   = "Dump contents of good and bad blocks on failure",
2453                 .parent = "verify",
2454                 .hide   = 1,
2455                 .category = FIO_OPT_C_IO,
2456                 .group  = FIO_OPT_G_VERIFY,
2457         },
2458         {
2459                 .name   = "verify_async",
2460                 .lname  = "Verify asynchronously",
2461                 .type   = FIO_OPT_INT,
2462                 .off1   = td_var_offset(verify_async),
2463                 .def    = "0",
2464                 .help   = "Number of async verifier threads to use",
2465                 .parent = "verify",
2466                 .hide   = 1,
2467                 .category = FIO_OPT_C_IO,
2468                 .group  = FIO_OPT_G_VERIFY,
2469         },
2470         {
2471                 .name   = "verify_backlog",
2472                 .lname  = "Verify backlog",
2473                 .type   = FIO_OPT_STR_VAL,
2474                 .off1   = td_var_offset(verify_backlog),
2475                 .help   = "Verify after this number of blocks are written",
2476                 .parent = "verify",
2477                 .hide   = 1,
2478                 .category = FIO_OPT_C_IO,
2479                 .group  = FIO_OPT_G_VERIFY,
2480         },
2481         {
2482                 .name   = "verify_backlog_batch",
2483                 .lname  = "Verify backlog batch",
2484                 .type   = FIO_OPT_INT,
2485                 .off1   = td_var_offset(verify_batch),
2486                 .help   = "Verify this number of IO blocks",
2487                 .parent = "verify",
2488                 .hide   = 1,
2489                 .category = FIO_OPT_C_IO,
2490                 .group  = FIO_OPT_G_VERIFY,
2491         },
2492 #ifdef FIO_HAVE_CPU_AFFINITY
2493         {
2494                 .name   = "verify_async_cpus",
2495                 .lname  = "Async verify CPUs",
2496                 .type   = FIO_OPT_STR,
2497                 .cb     = str_verify_cpus_allowed_cb,
2498                 .off1   = td_var_offset(verify_cpumask),
2499                 .help   = "Set CPUs allowed for async verify threads",
2500                 .parent = "verify_async",
2501                 .hide   = 1,
2502                 .category = FIO_OPT_C_IO,
2503                 .group  = FIO_OPT_G_VERIFY,
2504         },
2505 #endif
2506         {
2507                 .name   = "experimental_verify",
2508                 .off1   = td_var_offset(experimental_verify),
2509                 .type   = FIO_OPT_BOOL,
2510                 .help   = "Enable experimental verification",
2511                 .parent = "verify",
2512                 .category = FIO_OPT_C_IO,
2513                 .group  = FIO_OPT_G_VERIFY,
2514         },
2515         {
2516                 .name   = "verify_state_load",
2517                 .lname  = "Load verify state",
2518                 .off1   = td_var_offset(verify_state),
2519                 .type   = FIO_OPT_BOOL,
2520                 .help   = "Load verify termination state",
2521                 .parent = "verify",
2522                 .category = FIO_OPT_C_IO,
2523                 .group  = FIO_OPT_G_VERIFY,
2524         },
2525         {
2526                 .name   = "verify_state_save",
2527                 .lname  = "Save verify state",
2528                 .off1   = td_var_offset(verify_state_save),
2529                 .type   = FIO_OPT_BOOL,
2530                 .def    = "1",
2531                 .help   = "Save verify state on termination",
2532                 .parent = "verify",
2533                 .category = FIO_OPT_C_IO,
2534                 .group  = FIO_OPT_G_VERIFY,
2535         },
2536 #ifdef FIO_HAVE_TRIM
2537         {
2538                 .name   = "trim_percentage",
2539                 .lname  = "Trim percentage",
2540                 .type   = FIO_OPT_INT,
2541                 .off1   = td_var_offset(trim_percentage),
2542                 .minval = 0,
2543                 .maxval = 100,
2544                 .help   = "Number of verify blocks to discard/trim",
2545                 .parent = "verify",
2546                 .def    = "0",
2547                 .interval = 1,
2548                 .hide   = 1,
2549                 .category = FIO_OPT_C_IO,
2550                 .group  = FIO_OPT_G_TRIM,
2551         },
2552         {
2553                 .name   = "trim_verify_zero",
2554                 .lname  = "Verify trim zero",
2555                 .type   = FIO_OPT_BOOL,
2556                 .help   = "Verify that trim/discarded blocks are returned as zeroes",
2557                 .off1   = td_var_offset(trim_zero),
2558                 .parent = "trim_percentage",
2559                 .hide   = 1,
2560                 .def    = "1",
2561                 .category = FIO_OPT_C_IO,
2562                 .group  = FIO_OPT_G_TRIM,
2563         },
2564         {
2565                 .name   = "trim_backlog",
2566                 .lname  = "Trim backlog",
2567                 .type   = FIO_OPT_STR_VAL,
2568                 .off1   = td_var_offset(trim_backlog),
2569                 .help   = "Trim after this number of blocks are written",
2570                 .parent = "trim_percentage",
2571                 .hide   = 1,
2572                 .interval = 1,
2573                 .category = FIO_OPT_C_IO,
2574                 .group  = FIO_OPT_G_TRIM,
2575         },
2576         {
2577                 .name   = "trim_backlog_batch",
2578                 .lname  = "Trim backlog batch",
2579                 .type   = FIO_OPT_INT,
2580                 .off1   = td_var_offset(trim_batch),
2581                 .help   = "Trim this number of IO blocks",
2582                 .parent = "trim_percentage",
2583                 .hide   = 1,
2584                 .interval = 1,
2585                 .category = FIO_OPT_C_IO,
2586                 .group  = FIO_OPT_G_TRIM,
2587         },
2588 #endif
2589         {
2590                 .name   = "write_iolog",
2591                 .lname  = "Write I/O log",
2592                 .type   = FIO_OPT_STR_STORE,
2593                 .off1   = td_var_offset(write_iolog_file),
2594                 .help   = "Store IO pattern to file",
2595                 .category = FIO_OPT_C_IO,
2596                 .group  = FIO_OPT_G_IOLOG,
2597         },
2598         {
2599                 .name   = "read_iolog",
2600                 .lname  = "Read I/O log",
2601                 .type   = FIO_OPT_STR_STORE,
2602                 .off1   = td_var_offset(read_iolog_file),
2603                 .help   = "Playback IO pattern from file",
2604                 .category = FIO_OPT_C_IO,
2605                 .group  = FIO_OPT_G_IOLOG,
2606         },
2607         {
2608                 .name   = "replay_no_stall",
2609                 .lname  = "Don't stall on replay",
2610                 .type   = FIO_OPT_BOOL,
2611                 .off1   = td_var_offset(no_stall),
2612                 .def    = "0",
2613                 .parent = "read_iolog",
2614                 .hide   = 1,
2615                 .help   = "Playback IO pattern file as fast as possible without stalls",
2616                 .category = FIO_OPT_C_IO,
2617                 .group  = FIO_OPT_G_IOLOG,
2618         },
2619         {
2620                 .name   = "replay_redirect",
2621                 .lname  = "Redirect device for replay",
2622                 .type   = FIO_OPT_STR_STORE,
2623                 .off1   = td_var_offset(replay_redirect),
2624                 .parent = "read_iolog",
2625                 .hide   = 1,
2626                 .help   = "Replay all I/O onto this device, regardless of trace device",
2627                 .category = FIO_OPT_C_IO,
2628                 .group  = FIO_OPT_G_IOLOG,
2629         },
2630         {
2631                 .name   = "replay_scale",
2632                 .lname  = "Replace offset scale factor",
2633                 .type   = FIO_OPT_INT,
2634                 .off1   = td_var_offset(replay_scale),
2635                 .parent = "read_iolog",
2636                 .def    = "1",
2637                 .help   = "Align offsets to this blocksize",
2638                 .category = FIO_OPT_C_IO,
2639                 .group  = FIO_OPT_G_IOLOG,
2640         },
2641         {
2642                 .name   = "replay_align",
2643                 .lname  = "Replace alignment",
2644                 .type   = FIO_OPT_INT,
2645                 .off1   = td_var_offset(replay_align),
2646                 .parent = "read_iolog",
2647                 .help   = "Scale offset down by this factor",
2648                 .category = FIO_OPT_C_IO,
2649                 .group  = FIO_OPT_G_IOLOG,
2650                 .pow2   = 1,
2651         },
2652         {
2653                 .name   = "exec_prerun",
2654                 .lname  = "Pre-execute runnable",
2655                 .type   = FIO_OPT_STR_STORE,
2656                 .off1   = td_var_offset(exec_prerun),
2657                 .help   = "Execute this file prior to running job",
2658                 .category = FIO_OPT_C_GENERAL,
2659                 .group  = FIO_OPT_G_INVALID,
2660         },
2661         {
2662                 .name   = "exec_postrun",
2663                 .lname  = "Post-execute runnable",
2664                 .type   = FIO_OPT_STR_STORE,
2665                 .off1   = td_var_offset(exec_postrun),
2666                 .help   = "Execute this file after running job",
2667                 .category = FIO_OPT_C_GENERAL,
2668                 .group  = FIO_OPT_G_INVALID,
2669         },
2670 #ifdef FIO_HAVE_IOSCHED_SWITCH
2671         {
2672                 .name   = "ioscheduler",
2673                 .lname  = "I/O scheduler",
2674                 .type   = FIO_OPT_STR_STORE,
2675                 .off1   = td_var_offset(ioscheduler),
2676                 .help   = "Use this IO scheduler on the backing device",
2677                 .category = FIO_OPT_C_FILE,
2678                 .group  = FIO_OPT_G_INVALID,
2679         },
2680 #endif
2681         {
2682                 .name   = "zonesize",
2683                 .lname  = "Zone size",
2684                 .type   = FIO_OPT_STR_VAL,
2685                 .off1   = td_var_offset(zone_size),
2686                 .help   = "Amount of data to read per zone",
2687                 .def    = "0",
2688                 .interval = 1024 * 1024,
2689                 .category = FIO_OPT_C_IO,
2690                 .group  = FIO_OPT_G_ZONE,
2691         },
2692         {
2693                 .name   = "zonerange",
2694                 .lname  = "Zone range",
2695                 .type   = FIO_OPT_STR_VAL,
2696                 .off1   = td_var_offset(zone_range),
2697                 .help   = "Give size of an IO zone",
2698                 .def    = "0",
2699                 .interval = 1024 * 1024,
2700                 .category = FIO_OPT_C_IO,
2701                 .group  = FIO_OPT_G_ZONE,
2702         },
2703         {
2704                 .name   = "zoneskip",
2705                 .lname  = "Zone skip",
2706                 .type   = FIO_OPT_STR_VAL,
2707                 .off1   = td_var_offset(zone_skip),
2708                 .help   = "Space between IO zones",
2709                 .def    = "0",
2710                 .interval = 1024 * 1024,
2711                 .category = FIO_OPT_C_IO,
2712                 .group  = FIO_OPT_G_ZONE,
2713         },
2714         {
2715                 .name   = "lockmem",
2716                 .lname  = "Lock memory",
2717                 .type   = FIO_OPT_STR_VAL,
2718                 .off1   = td_var_offset(lockmem),
2719                 .help   = "Lock down this amount of memory (per worker)",
2720                 .def    = "0",
2721                 .interval = 1024 * 1024,
2722                 .category = FIO_OPT_C_GENERAL,
2723                 .group  = FIO_OPT_G_INVALID,
2724         },
2725         {
2726                 .name   = "rwmixread",
2727                 .lname  = "Read/write mix read",
2728                 .type   = FIO_OPT_INT,
2729                 .cb     = str_rwmix_read_cb,
2730                 .off1   = td_var_offset(rwmix[DDIR_READ]),
2731                 .maxval = 100,
2732                 .help   = "Percentage of mixed workload that is reads",
2733                 .def    = "50",
2734                 .interval = 5,
2735                 .inverse = "rwmixwrite",
2736                 .category = FIO_OPT_C_IO,
2737                 .group  = FIO_OPT_G_RWMIX,
2738         },
2739         {
2740                 .name   = "rwmixwrite",
2741                 .lname  = "Read/write mix write",
2742                 .type   = FIO_OPT_INT,
2743                 .cb     = str_rwmix_write_cb,
2744                 .off1   = td_var_offset(rwmix[DDIR_WRITE]),
2745                 .maxval = 100,
2746                 .help   = "Percentage of mixed workload that is writes",
2747                 .def    = "50",
2748                 .interval = 5,
2749                 .inverse = "rwmixread",
2750                 .category = FIO_OPT_C_IO,
2751                 .group  = FIO_OPT_G_RWMIX,
2752         },
2753         {
2754                 .name   = "rwmixcycle",
2755                 .lname  = "Read/write mix cycle",
2756                 .type   = FIO_OPT_DEPRECATED,
2757                 .category = FIO_OPT_C_IO,
2758                 .group  = FIO_OPT_G_RWMIX,
2759         },
2760         {
2761                 .name   = "nice",
2762                 .lname  = "Nice",
2763                 .type   = FIO_OPT_INT,
2764                 .off1   = td_var_offset(nice),
2765                 .help   = "Set job CPU nice value",
2766                 .minval = -19,
2767                 .maxval = 20,
2768                 .def    = "0",
2769                 .interval = 1,
2770                 .category = FIO_OPT_C_GENERAL,
2771                 .group  = FIO_OPT_G_CRED,
2772         },
2773 #ifdef FIO_HAVE_IOPRIO
2774         {
2775                 .name   = "prio",
2776                 .lname  = "I/O nice priority",
2777                 .type   = FIO_OPT_INT,
2778                 .off1   = td_var_offset(ioprio),
2779                 .help   = "Set job IO priority value",
2780                 .minval = 0,
2781                 .maxval = 7,
2782                 .interval = 1,
2783                 .category = FIO_OPT_C_GENERAL,
2784                 .group  = FIO_OPT_G_CRED,
2785         },
2786         {
2787                 .name   = "prioclass",
2788                 .lname  = "I/O nice priority class",
2789                 .type   = FIO_OPT_INT,
2790                 .off1   = td_var_offset(ioprio_class),
2791                 .help   = "Set job IO priority class",
2792                 .minval = 0,
2793                 .maxval = 3,
2794                 .interval = 1,
2795                 .category = FIO_OPT_C_GENERAL,
2796                 .group  = FIO_OPT_G_CRED,
2797         },
2798 #endif
2799         {
2800                 .name   = "thinktime",
2801                 .lname  = "Thinktime",
2802                 .type   = FIO_OPT_INT,
2803                 .off1   = td_var_offset(thinktime),
2804                 .help   = "Idle time between IO buffers (usec)",
2805                 .def    = "0",
2806                 .is_time = 1,
2807                 .category = FIO_OPT_C_IO,
2808                 .group  = FIO_OPT_G_THINKTIME,
2809         },
2810         {
2811                 .name   = "thinktime_spin",
2812                 .lname  = "Thinktime spin",
2813                 .type   = FIO_OPT_INT,
2814                 .off1   = td_var_offset(thinktime_spin),
2815                 .help   = "Start think time by spinning this amount (usec)",
2816                 .def    = "0",
2817                 .is_time = 1,
2818                 .parent = "thinktime",
2819                 .hide   = 1,
2820                 .category = FIO_OPT_C_IO,
2821                 .group  = FIO_OPT_G_THINKTIME,
2822         },
2823         {
2824                 .name   = "thinktime_blocks",
2825                 .lname  = "Thinktime blocks",
2826                 .type   = FIO_OPT_INT,
2827                 .off1   = td_var_offset(thinktime_blocks),
2828                 .help   = "IO buffer period between 'thinktime'",
2829                 .def    = "1",
2830                 .parent = "thinktime",
2831                 .hide   = 1,
2832                 .category = FIO_OPT_C_IO,
2833                 .group  = FIO_OPT_G_THINKTIME,
2834         },
2835         {
2836                 .name   = "rate",
2837                 .lname  = "I/O rate",
2838                 .type   = FIO_OPT_INT,
2839                 .off1   = td_var_offset(rate[DDIR_READ]),
2840                 .off2   = td_var_offset(rate[DDIR_WRITE]),
2841                 .off3   = td_var_offset(rate[DDIR_TRIM]),
2842                 .help   = "Set bandwidth rate",
2843                 .category = FIO_OPT_C_IO,
2844                 .group  = FIO_OPT_G_RATE,
2845         },
2846         {
2847                 .name   = "rate_min",
2848                 .alias  = "ratemin",
2849                 .lname  = "I/O min rate",
2850                 .type   = FIO_OPT_INT,
2851                 .off1   = td_var_offset(ratemin[DDIR_READ]),
2852                 .off2   = td_var_offset(ratemin[DDIR_WRITE]),
2853                 .off3   = td_var_offset(ratemin[DDIR_TRIM]),
2854                 .help   = "Job must meet this rate or it will be shutdown",
2855                 .parent = "rate",
2856                 .hide   = 1,
2857                 .category = FIO_OPT_C_IO,
2858                 .group  = FIO_OPT_G_RATE,
2859         },
2860         {
2861                 .name   = "rate_iops",
2862                 .lname  = "I/O rate IOPS",
2863                 .type   = FIO_OPT_INT,
2864                 .off1   = td_var_offset(rate_iops[DDIR_READ]),
2865                 .off2   = td_var_offset(rate_iops[DDIR_WRITE]),
2866                 .off3   = td_var_offset(rate_iops[DDIR_TRIM]),
2867                 .help   = "Limit IO used to this number of IO operations/sec",
2868                 .hide   = 1,
2869                 .category = FIO_OPT_C_IO,
2870                 .group  = FIO_OPT_G_RATE,
2871         },
2872         {
2873                 .name   = "rate_iops_min",
2874                 .lname  = "I/O min rate IOPS",
2875                 .type   = FIO_OPT_INT,
2876                 .off1   = td_var_offset(rate_iops_min[DDIR_READ]),
2877                 .off2   = td_var_offset(rate_iops_min[DDIR_WRITE]),
2878                 .off3   = td_var_offset(rate_iops_min[DDIR_TRIM]),
2879                 .help   = "Job must meet this rate or it will be shut down",
2880                 .parent = "rate_iops",
2881                 .hide   = 1,
2882                 .category = FIO_OPT_C_IO,
2883                 .group  = FIO_OPT_G_RATE,
2884         },
2885         {
2886                 .name   = "rate_process",
2887                 .lname  = "Rate Process",
2888                 .type   = FIO_OPT_STR,
2889                 .off1   = td_var_offset(rate_process),
2890                 .help   = "What process controls how rated IO is managed",
2891                 .def    = "linear",
2892                 .category = FIO_OPT_C_IO,
2893                 .group  = FIO_OPT_G_RATE,
2894                 .posval = {
2895                           { .ival = "linear",
2896                             .oval = RATE_PROCESS_LINEAR,
2897                             .help = "Linear rate of IO",
2898                           },
2899                           {
2900                             .ival = "poisson",
2901                             .oval = RATE_PROCESS_POISSON,
2902                             .help = "Rate follows Poisson process",
2903                           },
2904                 },
2905                 .parent = "rate",
2906         },
2907         {
2908                 .name   = "rate_cycle",
2909                 .alias  = "ratecycle",
2910                 .lname  = "I/O rate cycle",
2911                 .type   = FIO_OPT_INT,
2912                 .off1   = td_var_offset(ratecycle),
2913                 .help   = "Window average for rate limits (msec)",
2914                 .def    = "1000",
2915                 .parent = "rate",
2916                 .hide   = 1,
2917                 .category = FIO_OPT_C_IO,
2918                 .group  = FIO_OPT_G_RATE,
2919         },
2920         {
2921                 .name   = "max_latency",
2922                 .type   = FIO_OPT_INT,
2923                 .off1   = td_var_offset(max_latency),
2924                 .help   = "Maximum tolerated IO latency (usec)",
2925                 .is_time = 1,
2926                 .category = FIO_OPT_C_IO,
2927                 .group = FIO_OPT_G_LATPROF,
2928         },
2929         {
2930                 .name   = "latency_target",
2931                 .lname  = "Latency Target (usec)",
2932                 .type   = FIO_OPT_STR_VAL_TIME,
2933                 .off1   = td_var_offset(latency_target),
2934                 .help   = "Ramp to max queue depth supporting this latency",
2935                 .is_time = 1,
2936                 .category = FIO_OPT_C_IO,
2937                 .group  = FIO_OPT_G_LATPROF,
2938         },
2939         {
2940                 .name   = "latency_window",
2941                 .lname  = "Latency Window (usec)",
2942                 .type   = FIO_OPT_STR_VAL_TIME,
2943                 .off1   = td_var_offset(latency_window),
2944                 .help   = "Time to sustain latency_target",
2945                 .is_time = 1,
2946                 .category = FIO_OPT_C_IO,
2947                 .group  = FIO_OPT_G_LATPROF,
2948         },
2949         {
2950                 .name   = "latency_percentile",
2951                 .lname  = "Latency Percentile",
2952                 .type   = FIO_OPT_FLOAT_LIST,
2953                 .off1   = td_var_offset(latency_percentile),
2954                 .help   = "Percentile of IOs must be below latency_target",
2955                 .def    = "100",
2956                 .maxlen = 1,
2957                 .minfp  = 0.0,
2958                 .maxfp  = 100.0,
2959                 .category = FIO_OPT_C_IO,
2960                 .group  = FIO_OPT_G_LATPROF,
2961         },
2962         {
2963                 .name   = "invalidate",
2964                 .lname  = "Cache invalidate",
2965                 .type   = FIO_OPT_BOOL,
2966                 .off1   = td_var_offset(invalidate_cache),
2967                 .help   = "Invalidate buffer/page cache prior to running job",
2968                 .def    = "1",
2969                 .category = FIO_OPT_C_IO,
2970                 .group  = FIO_OPT_G_IO_TYPE,
2971         },
2972         {
2973                 .name   = "sync",
2974                 .lname  = "Synchronous I/O",
2975                 .type   = FIO_OPT_BOOL,
2976                 .off1   = td_var_offset(sync_io),
2977                 .help   = "Use O_SYNC for buffered writes",
2978                 .def    = "0",
2979                 .parent = "buffered",
2980                 .hide   = 1,
2981                 .category = FIO_OPT_C_IO,
2982                 .group  = FIO_OPT_G_IO_TYPE,
2983         },
2984         {
2985                 .name   = "create_serialize",
2986                 .lname  = "Create serialize",
2987                 .type   = FIO_OPT_BOOL,
2988                 .off1   = td_var_offset(create_serialize),
2989                 .help   = "Serialize creating of job files",
2990                 .def    = "1",
2991                 .category = FIO_OPT_C_FILE,
2992                 .group  = FIO_OPT_G_INVALID,
2993         },
2994         {
2995                 .name   = "create_fsync",
2996                 .lname  = "Create fsync",
2997                 .type   = FIO_OPT_BOOL,
2998                 .off1   = td_var_offset(create_fsync),
2999                 .help   = "fsync file after creation",
3000                 .def    = "1",
3001                 .category = FIO_OPT_C_FILE,
3002                 .group  = FIO_OPT_G_INVALID,
3003         },
3004         {
3005                 .name   = "create_on_open",
3006                 .lname  = "Create on open",
3007                 .type   = FIO_OPT_BOOL,
3008                 .off1   = td_var_offset(create_on_open),
3009                 .help   = "Create files when they are opened for IO",
3010                 .def    = "0",
3011                 .category = FIO_OPT_C_FILE,
3012                 .group  = FIO_OPT_G_INVALID,
3013         },
3014         {
3015                 .name   = "create_only",
3016                 .type   = FIO_OPT_BOOL,
3017                 .off1   = td_var_offset(create_only),
3018                 .help   = "Only perform file creation phase",
3019                 .category = FIO_OPT_C_FILE,
3020                 .def    = "0",
3021         },
3022         {
3023                 .name   = "allow_file_create",
3024                 .lname  = "Allow file create",
3025                 .type   = FIO_OPT_BOOL,
3026                 .off1   = td_var_offset(allow_create),
3027                 .help   = "Permit fio to create files, if they don't exist",
3028                 .def    = "1",
3029                 .category = FIO_OPT_C_FILE,
3030                 .group  = FIO_OPT_G_FILENAME,
3031         },
3032         {
3033                 .name   = "allow_mounted_write",
3034                 .lname  = "Allow mounted write",
3035                 .type   = FIO_OPT_BOOL,
3036                 .off1   = td_var_offset(allow_mounted_write),
3037                 .help   = "Allow writes to a mounted partition",
3038                 .def    = "0",
3039                 .category = FIO_OPT_C_FILE,
3040                 .group  = FIO_OPT_G_FILENAME,
3041         },
3042         {
3043                 .name   = "pre_read",
3044                 .lname  = "Pre-read files",
3045                 .type   = FIO_OPT_BOOL,
3046                 .off1   = td_var_offset(pre_read),
3047                 .help   = "Pre-read files before starting official testing",
3048                 .def    = "0",
3049                 .category = FIO_OPT_C_FILE,
3050                 .group  = FIO_OPT_G_INVALID,
3051         },
3052 #ifdef FIO_HAVE_CPU_AFFINITY
3053         {
3054                 .name   = "cpumask",
3055                 .lname  = "CPU mask",
3056                 .type   = FIO_OPT_INT,
3057                 .cb     = str_cpumask_cb,
3058                 .off1   = td_var_offset(cpumask),
3059                 .help   = "CPU affinity mask",
3060                 .category = FIO_OPT_C_GENERAL,
3061                 .group  = FIO_OPT_G_CRED,
3062         },
3063         {
3064                 .name   = "cpus_allowed",
3065                 .lname  = "CPUs allowed",
3066                 .type   = FIO_OPT_STR,
3067                 .cb     = str_cpus_allowed_cb,
3068                 .off1   = td_var_offset(cpumask),
3069                 .help   = "Set CPUs allowed",
3070                 .category = FIO_OPT_C_GENERAL,
3071                 .group  = FIO_OPT_G_CRED,
3072         },
3073         {
3074                 .name   = "cpus_allowed_policy",
3075                 .lname  = "CPUs allowed distribution policy",
3076                 .type   = FIO_OPT_STR,
3077                 .off1   = td_var_offset(cpus_allowed_policy),
3078                 .help   = "Distribution policy for cpus_allowed",
3079                 .parent = "cpus_allowed",
3080                 .prio   = 1,
3081                 .posval = {
3082                           { .ival = "shared",
3083                             .oval = FIO_CPUS_SHARED,
3084                             .help = "Mask shared between threads",
3085                           },
3086                           { .ival = "split",
3087                             .oval = FIO_CPUS_SPLIT,
3088                             .help = "Mask split between threads",
3089                           },
3090                 },
3091                 .category = FIO_OPT_C_GENERAL,
3092                 .group  = FIO_OPT_G_CRED,
3093         },
3094 #endif
3095 #ifdef CONFIG_LIBNUMA
3096         {
3097                 .name   = "numa_cpu_nodes",
3098                 .type   = FIO_OPT_STR,
3099                 .cb     = str_numa_cpunodes_cb,
3100                 .off1   = td_var_offset(numa_cpunodes),
3101                 .help   = "NUMA CPU nodes bind",
3102                 .category = FIO_OPT_C_GENERAL,
3103                 .group  = FIO_OPT_G_INVALID,
3104         },
3105         {
3106                 .name   = "numa_mem_policy",
3107                 .type   = FIO_OPT_STR,
3108                 .cb     = str_numa_mpol_cb,
3109                 .off1   = td_var_offset(numa_memnodes),
3110                 .help   = "NUMA memory policy setup",
3111                 .category = FIO_OPT_C_GENERAL,
3112                 .group  = FIO_OPT_G_INVALID,
3113         },
3114 #endif
3115         {
3116                 .name   = "end_fsync",
3117                 .lname  = "End fsync",
3118                 .type   = FIO_OPT_BOOL,
3119                 .off1   = td_var_offset(end_fsync),
3120                 .help   = "Include fsync at the end of job",
3121                 .def    = "0",
3122                 .category = FIO_OPT_C_FILE,
3123                 .group  = FIO_OPT_G_INVALID,
3124         },
3125         {
3126                 .name   = "fsync_on_close",
3127                 .lname  = "Fsync on close",
3128                 .type   = FIO_OPT_BOOL,
3129                 .off1   = td_var_offset(fsync_on_close),
3130                 .help   = "fsync files on close",
3131                 .def    = "0",
3132                 .category = FIO_OPT_C_FILE,
3133                 .group  = FIO_OPT_G_INVALID,
3134         },
3135         {
3136                 .name   = "unlink",
3137                 .lname  = "Unlink file",
3138                 .type   = FIO_OPT_BOOL,
3139                 .off1   = td_var_offset(unlink),
3140                 .help   = "Unlink created files after job has completed",
3141                 .def    = "0",
3142                 .category = FIO_OPT_C_FILE,
3143                 .group  = FIO_OPT_G_INVALID,
3144         },
3145         {
3146                 .name   = "exitall",
3147                 .lname  = "Exit-all on terminate",
3148                 .type   = FIO_OPT_STR_SET,
3149                 .cb     = str_exitall_cb,
3150                 .help   = "Terminate all jobs when one exits",
3151                 .category = FIO_OPT_C_GENERAL,
3152                 .group  = FIO_OPT_G_PROCESS,
3153         },
3154         {
3155                 .name   = "exitall_on_error",
3156                 .lname  = "Exit-all on terminate in error",
3157                 .type   = FIO_OPT_BOOL,
3158                 .off1   = td_var_offset(unlink),
3159                 .help   = "Terminate all jobs when one exits in error",
3160                 .category = FIO_OPT_C_GENERAL,
3161                 .group  = FIO_OPT_G_PROCESS,
3162         },
3163         {
3164                 .name   = "stonewall",
3165                 .lname  = "Wait for previous",
3166                 .alias  = "wait_for_previous",
3167                 .type   = FIO_OPT_STR_SET,
3168                 .off1   = td_var_offset(stonewall),
3169                 .help   = "Insert a hard barrier between this job and previous",
3170                 .category = FIO_OPT_C_GENERAL,
3171                 .group  = FIO_OPT_G_PROCESS,
3172         },
3173         {
3174                 .name   = "new_group",
3175                 .lname  = "New group",
3176                 .type   = FIO_OPT_STR_SET,
3177                 .off1   = td_var_offset(new_group),
3178                 .help   = "Mark the start of a new group (for reporting)",
3179                 .category = FIO_OPT_C_GENERAL,
3180                 .group  = FIO_OPT_G_PROCESS,
3181         },
3182         {
3183                 .name   = "thread",
3184                 .lname  = "Thread",
3185                 .type   = FIO_OPT_STR_SET,
3186                 .off1   = td_var_offset(use_thread),
3187                 .help   = "Use threads instead of processes",
3188 #ifdef CONFIG_NO_SHM
3189                 .def    = "1",
3190                 .no_warn_def = 1,
3191 #endif
3192                 .category = FIO_OPT_C_GENERAL,
3193                 .group  = FIO_OPT_G_PROCESS,
3194         },
3195         {
3196                 .name   = "per_job_logs",
3197                 .type   = FIO_OPT_BOOL,
3198                 .off1   = td_var_offset(per_job_logs),
3199                 .help   = "Include job number in generated log files or not",
3200                 .def    = "1",
3201                 .category = FIO_OPT_C_LOG,
3202                 .group  = FIO_OPT_G_INVALID,
3203         },
3204         {
3205                 .name   = "write_bw_log",
3206                 .lname  = "Write bandwidth log",
3207                 .type   = FIO_OPT_STR_STORE,
3208                 .off1   = td_var_offset(bw_log_file),
3209                 .help   = "Write log of bandwidth during run",
3210                 .category = FIO_OPT_C_LOG,
3211                 .group  = FIO_OPT_G_INVALID,
3212         },
3213         {
3214                 .name   = "write_lat_log",
3215                 .lname  = "Write latency log",
3216                 .type   = FIO_OPT_STR_STORE,
3217                 .off1   = td_var_offset(lat_log_file),
3218                 .help   = "Write log of latency during run",
3219                 .category = FIO_OPT_C_LOG,
3220                 .group  = FIO_OPT_G_INVALID,
3221         },
3222         {
3223                 .name   = "write_iops_log",
3224                 .lname  = "Write IOPS log",
3225                 .type   = FIO_OPT_STR_STORE,
3226                 .off1   = td_var_offset(iops_log_file),
3227                 .help   = "Write log of IOPS during run",
3228                 .category = FIO_OPT_C_LOG,
3229                 .group  = FIO_OPT_G_INVALID,
3230         },
3231         {
3232                 .name   = "log_avg_msec",
3233                 .lname  = "Log averaging (msec)",
3234                 .type   = FIO_OPT_INT,
3235                 .off1   = td_var_offset(log_avg_msec),
3236                 .help   = "Average bw/iops/lat logs over this period of time",
3237                 .def    = "0",
3238                 .category = FIO_OPT_C_LOG,
3239                 .group  = FIO_OPT_G_INVALID,
3240         },
3241         {
3242                 .name   = "log_offset",
3243                 .lname  = "Log offset of IO",
3244                 .type   = FIO_OPT_BOOL,
3245                 .off1   = td_var_offset(log_offset),
3246                 .help   = "Include offset of IO for each log entry",
3247                 .def    = "0",
3248                 .category = FIO_OPT_C_LOG,
3249                 .group  = FIO_OPT_G_INVALID,
3250         },
3251 #ifdef CONFIG_ZLIB
3252         {
3253                 .name   = "log_compression",
3254                 .lname  = "Log compression",
3255                 .type   = FIO_OPT_INT,
3256                 .off1   = td_var_offset(log_gz),
3257                 .help   = "Log in compressed chunks of this size",
3258                 .minval = 1024ULL,
3259                 .maxval = 512 * 1024 * 1024ULL,
3260                 .category = FIO_OPT_C_LOG,
3261                 .group  = FIO_OPT_G_INVALID,
3262         },
3263 #ifdef FIO_HAVE_CPU_AFFINITY
3264         {
3265                 .name   = "log_compression_cpus",
3266                 .lname  = "Log Compression CPUs",
3267                 .type   = FIO_OPT_STR,
3268                 .cb     = str_log_cpus_allowed_cb,
3269                 .off1   = td_var_offset(log_gz_cpumask),
3270                 .parent = "log_compression",
3271                 .help   = "Limit log compression to these CPUs",
3272                 .category = FIO_OPT_C_LOG,
3273                 .group  = FIO_OPT_G_INVALID,
3274         },
3275 #endif
3276         {
3277                 .name   = "log_store_compressed",
3278                 .lname  = "Log store compressed",
3279                 .type   = FIO_OPT_BOOL,
3280                 .off1   = td_var_offset(log_gz_store),
3281                 .help   = "Store logs in a compressed format",
3282                 .category = FIO_OPT_C_LOG,
3283                 .group  = FIO_OPT_G_INVALID,
3284         },
3285 #endif
3286         {
3287                 .name   = "block_error_percentiles",
3288                 .lname  = "Block error percentiles",
3289                 .type   = FIO_OPT_BOOL,
3290                 .off1   = td_var_offset(block_error_hist),
3291                 .help   = "Record trim block errors and make a histogram",
3292                 .def    = "0",
3293                 .category = FIO_OPT_C_LOG,
3294                 .group  = FIO_OPT_G_INVALID,
3295         },
3296         {
3297                 .name   = "bwavgtime",
3298                 .lname  = "Bandwidth average time",
3299                 .type   = FIO_OPT_INT,
3300                 .off1   = td_var_offset(bw_avg_time),
3301                 .help   = "Time window over which to calculate bandwidth"
3302                           " (msec)",
3303                 .def    = "500",
3304                 .parent = "write_bw_log",
3305                 .hide   = 1,
3306                 .interval = 100,
3307                 .category = FIO_OPT_C_LOG,
3308                 .group  = FIO_OPT_G_INVALID,
3309         },
3310         {
3311                 .name   = "iopsavgtime",
3312                 .lname  = "IOPS average time",
3313                 .type   = FIO_OPT_INT,
3314                 .off1   = td_var_offset(iops_avg_time),
3315                 .help   = "Time window over which to calculate IOPS (msec)",
3316                 .def    = "500",
3317                 .parent = "write_iops_log",
3318                 .hide   = 1,
3319                 .interval = 100,
3320                 .category = FIO_OPT_C_LOG,
3321                 .group  = FIO_OPT_G_INVALID,
3322         },
3323         {
3324                 .name   = "group_reporting",
3325                 .lname  = "Group reporting",
3326                 .type   = FIO_OPT_STR_SET,
3327                 .off1   = td_var_offset(group_reporting),
3328                 .help   = "Do reporting on a per-group basis",
3329                 .category = FIO_OPT_C_STAT,
3330                 .group  = FIO_OPT_G_INVALID,
3331         },
3332         {
3333                 .name   = "zero_buffers",
3334                 .lname  = "Zero I/O buffers",
3335                 .type   = FIO_OPT_STR_SET,
3336                 .off1   = td_var_offset(zero_buffers),
3337                 .help   = "Init IO buffers to all zeroes",
3338                 .category = FIO_OPT_C_IO,
3339                 .group  = FIO_OPT_G_IO_BUF,
3340         },
3341         {
3342                 .name   = "refill_buffers",
3343                 .lname  = "Refill I/O buffers",
3344                 .type   = FIO_OPT_STR_SET,
3345                 .off1   = td_var_offset(refill_buffers),
3346                 .help   = "Refill IO buffers on every IO submit",
3347                 .category = FIO_OPT_C_IO,
3348                 .group  = FIO_OPT_G_IO_BUF,
3349         },
3350         {
3351                 .name   = "scramble_buffers",
3352                 .lname  = "Scramble I/O buffers",
3353                 .type   = FIO_OPT_BOOL,
3354                 .off1   = td_var_offset(scramble_buffers),
3355                 .help   = "Slightly scramble buffers on every IO submit",
3356                 .def    = "1",
3357                 .category = FIO_OPT_C_IO,
3358                 .group  = FIO_OPT_G_IO_BUF,
3359         },
3360         {
3361                 .name   = "buffer_pattern",
3362                 .lname  = "Buffer pattern",
3363                 .type   = FIO_OPT_STR,
3364                 .cb     = str_buffer_pattern_cb,
3365                 .off1   = td_var_offset(buffer_pattern),
3366                 .help   = "Fill pattern for IO buffers",
3367                 .category = FIO_OPT_C_IO,
3368                 .group  = FIO_OPT_G_IO_BUF,
3369         },
3370         {
3371                 .name   = "buffer_compress_percentage",
3372                 .lname  = "Buffer compression percentage",
3373                 .type   = FIO_OPT_INT,
3374                 .cb     = str_buffer_compress_cb,
3375                 .off1   = td_var_offset(compress_percentage),
3376                 .maxval = 100,
3377                 .minval = 0,
3378                 .help   = "How compressible the buffer is (approximately)",
3379                 .interval = 5,
3380                 .category = FIO_OPT_C_IO,
3381                 .group  = FIO_OPT_G_IO_BUF,
3382         },
3383         {
3384                 .name   = "buffer_compress_chunk",
3385                 .lname  = "Buffer compression chunk size",
3386                 .type   = FIO_OPT_INT,
3387                 .off1   = td_var_offset(compress_chunk),
3388                 .parent = "buffer_compress_percentage",
3389                 .hide   = 1,
3390                 .help   = "Size of compressible region in buffer",
3391                 .interval = 256,
3392                 .category = FIO_OPT_C_IO,
3393                 .group  = FIO_OPT_G_IO_BUF,
3394         },
3395         {
3396                 .name   = "dedupe_percentage",
3397                 .lname  = "Dedupe percentage",
3398                 .type   = FIO_OPT_INT,
3399                 .cb     = str_dedupe_cb,
3400                 .off1   = td_var_offset(dedupe_percentage),
3401                 .maxval = 100,
3402                 .minval = 0,
3403                 .help   = "Percentage of buffers that are dedupable",
3404                 .interval = 1,
3405                 .category = FIO_OPT_C_IO,
3406                 .group  = FIO_OPT_G_IO_BUF,
3407         },
3408         {
3409                 .name   = "clat_percentiles",
3410                 .lname  = "Completion latency percentiles",
3411                 .type   = FIO_OPT_BOOL,
3412                 .off1   = td_var_offset(clat_percentiles),
3413                 .help   = "Enable the reporting of completion latency percentiles",
3414                 .def    = "1",
3415                 .category = FIO_OPT_C_STAT,
3416                 .group  = FIO_OPT_G_INVALID,
3417         },
3418         {
3419                 .name   = "percentile_list",
3420                 .lname  = "Percentile list",
3421                 .type   = FIO_OPT_FLOAT_LIST,
3422                 .off1   = td_var_offset(percentile_list),
3423                 .off2   = td_var_offset(percentile_precision),
3424                 .help   = "Specify a custom list of percentiles to report for "
3425                           "completion latency and block errors",
3426                 .def    = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3427                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3428                 .minfp  = 0.0,
3429                 .maxfp  = 100.0,
3430                 .category = FIO_OPT_C_STAT,
3431                 .group  = FIO_OPT_G_INVALID,
3432         },
3433
3434 #ifdef FIO_HAVE_DISK_UTIL
3435         {
3436                 .name   = "disk_util",
3437                 .lname  = "Disk utilization",
3438                 .type   = FIO_OPT_BOOL,
3439                 .off1   = td_var_offset(do_disk_util),
3440                 .help   = "Log disk utilization statistics",
3441                 .def    = "1",
3442                 .category = FIO_OPT_C_STAT,
3443                 .group  = FIO_OPT_G_INVALID,
3444         },
3445 #endif
3446         {
3447                 .name   = "gtod_reduce",
3448                 .lname  = "Reduce gettimeofday() calls",
3449                 .type   = FIO_OPT_BOOL,
3450                 .help   = "Greatly reduce number of gettimeofday() calls",
3451                 .cb     = str_gtod_reduce_cb,
3452                 .def    = "0",
3453                 .hide_on_set = 1,
3454                 .category = FIO_OPT_C_STAT,
3455                 .group  = FIO_OPT_G_INVALID,
3456         },
3457         {
3458                 .name   = "disable_lat",
3459                 .lname  = "Disable all latency stats",
3460                 .type   = FIO_OPT_BOOL,
3461                 .off1   = td_var_offset(disable_lat),
3462                 .help   = "Disable latency numbers",
3463                 .parent = "gtod_reduce",
3464                 .hide   = 1,
3465                 .def    = "0",
3466                 .category = FIO_OPT_C_STAT,
3467                 .group  = FIO_OPT_G_INVALID,
3468         },
3469         {
3470                 .name   = "disable_clat",
3471                 .lname  = "Disable completion latency stats",
3472                 .type   = FIO_OPT_BOOL,
3473                 .off1   = td_var_offset(disable_clat),
3474                 .help   = "Disable completion latency numbers",
3475                 .parent = "gtod_reduce",
3476                 .hide   = 1,
3477                 .def    = "0",
3478                 .category = FIO_OPT_C_STAT,
3479                 .group  = FIO_OPT_G_INVALID,
3480         },
3481         {
3482                 .name   = "disable_slat",
3483                 .lname  = "Disable submission latency stats",
3484                 .type   = FIO_OPT_BOOL,
3485                 .off1   = td_var_offset(disable_slat),
3486                 .help   = "Disable submission latency numbers",
3487                 .parent = "gtod_reduce",
3488                 .hide   = 1,
3489                 .def    = "0",
3490                 .category = FIO_OPT_C_STAT,
3491                 .group  = FIO_OPT_G_INVALID,
3492         },
3493         {
3494                 .name   = "disable_bw_measurement",
3495                 .lname  = "Disable bandwidth stats",
3496                 .type   = FIO_OPT_BOOL,
3497                 .off1   = td_var_offset(disable_bw),
3498                 .help   = "Disable bandwidth logging",
3499                 .parent = "gtod_reduce",
3500                 .hide   = 1,
3501                 .def    = "0",
3502                 .category = FIO_OPT_C_STAT,
3503                 .group  = FIO_OPT_G_INVALID,
3504         },
3505         {
3506                 .name   = "gtod_cpu",
3507                 .lname  = "Dedicated gettimeofday() CPU",
3508                 .type   = FIO_OPT_INT,
3509                 .off1   = td_var_offset(gtod_cpu),
3510                 .help   = "Set up dedicated gettimeofday() thread on this CPU",
3511                 .verify = gtod_cpu_verify,
3512                 .category = FIO_OPT_C_GENERAL,
3513                 .group  = FIO_OPT_G_CLOCK,
3514         },
3515         {
3516                 .name   = "unified_rw_reporting",
3517                 .type   = FIO_OPT_BOOL,
3518                 .off1   = td_var_offset(unified_rw_rep),
3519                 .help   = "Unify reporting across data direction",
3520                 .def    = "0",
3521                 .category = FIO_OPT_C_GENERAL,
3522                 .group  = FIO_OPT_G_INVALID,
3523         },
3524         {
3525                 .name   = "continue_on_error",
3526                 .lname  = "Continue on error",
3527                 .type   = FIO_OPT_STR,
3528                 .off1   = td_var_offset(continue_on_error),
3529                 .help   = "Continue on non-fatal errors during IO",
3530                 .def    = "none",
3531                 .category = FIO_OPT_C_GENERAL,
3532                 .group  = FIO_OPT_G_ERR,
3533                 .posval = {
3534                           { .ival = "none",
3535                             .oval = ERROR_TYPE_NONE,
3536                             .help = "Exit when an error is encountered",
3537                           },
3538                           { .ival = "read",
3539                             .oval = ERROR_TYPE_READ,
3540                             .help = "Continue on read errors only",
3541                           },
3542                           { .ival = "write",
3543                             .oval = ERROR_TYPE_WRITE,
3544                             .help = "Continue on write errors only",
3545                           },
3546                           { .ival = "io",
3547                             .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3548                             .help = "Continue on any IO errors",
3549                           },
3550                           { .ival = "verify",
3551                             .oval = ERROR_TYPE_VERIFY,
3552                             .help = "Continue on verify errors only",
3553                           },
3554                           { .ival = "all",
3555                             .oval = ERROR_TYPE_ANY,
3556                             .help = "Continue on all io and verify errors",
3557                           },
3558                           { .ival = "0",
3559                             .oval = ERROR_TYPE_NONE,
3560                             .help = "Alias for 'none'",
3561                           },
3562                           { .ival = "1",
3563                             .oval = ERROR_TYPE_ANY,
3564                             .help = "Alias for 'all'",
3565                           },
3566                 },
3567         },
3568         {
3569                 .name   = "ignore_error",
3570                 .type   = FIO_OPT_STR,
3571                 .cb     = str_ignore_error_cb,
3572                 .off1   = td_var_offset(ignore_error_nr),
3573                 .help   = "Set a specific list of errors to ignore",
3574                 .parent = "rw",
3575                 .category = FIO_OPT_C_GENERAL,
3576                 .group  = FIO_OPT_G_ERR,
3577         },
3578         {
3579                 .name   = "error_dump",
3580                 .type   = FIO_OPT_BOOL,
3581                 .off1   = td_var_offset(error_dump),
3582                 .def    = "0",
3583                 .help   = "Dump info on each error",
3584                 .category = FIO_OPT_C_GENERAL,
3585                 .group  = FIO_OPT_G_ERR,
3586         },
3587         {
3588                 .name   = "profile",
3589                 .lname  = "Profile",
3590                 .type   = FIO_OPT_STR_STORE,
3591                 .off1   = td_var_offset(profile),
3592                 .help   = "Select a specific builtin performance test",
3593                 .category = FIO_OPT_C_PROFILE,
3594                 .group  = FIO_OPT_G_INVALID,
3595         },
3596         {
3597                 .name   = "cgroup",
3598                 .lname  = "Cgroup",
3599                 .type   = FIO_OPT_STR_STORE,
3600                 .off1   = td_var_offset(cgroup),
3601                 .help   = "Add job to cgroup of this name",
3602                 .category = FIO_OPT_C_GENERAL,
3603                 .group  = FIO_OPT_G_CGROUP,
3604         },
3605         {
3606                 .name   = "cgroup_nodelete",
3607                 .lname  = "Cgroup no-delete",
3608                 .type   = FIO_OPT_BOOL,
3609                 .off1   = td_var_offset(cgroup_nodelete),
3610                 .help   = "Do not delete cgroups after job completion",
3611                 .def    = "0",
3612                 .parent = "cgroup",
3613                 .category = FIO_OPT_C_GENERAL,
3614                 .group  = FIO_OPT_G_CGROUP,
3615         },
3616         {
3617                 .name   = "cgroup_weight",
3618                 .lname  = "Cgroup weight",
3619                 .type   = FIO_OPT_INT,
3620                 .off1   = td_var_offset(cgroup_weight),
3621                 .help   = "Use given weight for cgroup",
3622                 .minval = 100,
3623                 .maxval = 1000,
3624                 .parent = "cgroup",
3625                 .category = FIO_OPT_C_GENERAL,
3626                 .group  = FIO_OPT_G_CGROUP,
3627         },
3628         {
3629                 .name   = "uid",
3630                 .lname  = "User ID",
3631                 .type   = FIO_OPT_INT,
3632                 .off1   = td_var_offset(uid),
3633                 .help   = "Run job with this user ID",
3634                 .category = FIO_OPT_C_GENERAL,
3635                 .group  = FIO_OPT_G_CRED,
3636         },
3637         {
3638                 .name   = "gid",
3639                 .lname  = "Group ID",
3640                 .type   = FIO_OPT_INT,
3641                 .off1   = td_var_offset(gid),
3642                 .help   = "Run job with this group ID",
3643                 .category = FIO_OPT_C_GENERAL,
3644                 .group  = FIO_OPT_G_CRED,
3645         },
3646         {
3647                 .name   = "kb_base",
3648                 .lname  = "KB Base",
3649                 .type   = FIO_OPT_INT,
3650                 .off1   = td_var_offset(kb_base),
3651                 .prio   = 1,
3652                 .def    = "1024",
3653                 .posval = {
3654                           { .ival = "1024",
3655                             .oval = 1024,
3656                             .help = "Use 1024 as the K base",
3657                           },
3658                           { .ival = "1000",
3659                             .oval = 1000,
3660                             .help = "Use 1000 as the K base",
3661                           },
3662                 },
3663                 .help   = "How many bytes per KB for reporting (1000 or 1024)",
3664                 .category = FIO_OPT_C_GENERAL,
3665                 .group  = FIO_OPT_G_INVALID,
3666         },
3667         {
3668                 .name   = "unit_base",
3669                 .lname  = "Base unit for reporting (Bits or Bytes)",
3670                 .type   = FIO_OPT_INT,
3671                 .off1   = td_var_offset(unit_base),
3672                 .prio   = 1,
3673                 .posval = {
3674                           { .ival = "0",
3675                             .oval = 0,
3676                             .help = "Auto-detect",
3677                           },
3678                           { .ival = "8",
3679                             .oval = 8,
3680                             .help = "Normal (byte based)",
3681                           },
3682                           { .ival = "1",
3683                             .oval = 1,
3684                             .help = "Bit based",
3685                           },
3686                 },
3687                 .help   = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3688                 .category = FIO_OPT_C_GENERAL,
3689                 .group  = FIO_OPT_G_INVALID,
3690         },
3691         {
3692                 .name   = "hugepage-size",
3693                 .lname  = "Hugepage size",
3694                 .type   = FIO_OPT_INT,
3695                 .off1   = td_var_offset(hugepage_size),
3696                 .help   = "When using hugepages, specify size of each page",
3697                 .def    = __fio_stringify(FIO_HUGE_PAGE),
3698                 .interval = 1024 * 1024,
3699                 .category = FIO_OPT_C_GENERAL,
3700                 .group  = FIO_OPT_G_INVALID,
3701         },
3702         {
3703                 .name   = "flow_id",
3704                 .lname  = "I/O flow ID",
3705                 .type   = FIO_OPT_INT,
3706                 .off1   = td_var_offset(flow_id),
3707                 .help   = "The flow index ID to use",
3708                 .def    = "0",
3709                 .category = FIO_OPT_C_IO,
3710                 .group  = FIO_OPT_G_IO_FLOW,
3711         },
3712         {
3713                 .name   = "flow",
3714                 .lname  = "I/O flow weight",
3715                 .type   = FIO_OPT_INT,
3716                 .off1   = td_var_offset(flow),
3717                 .help   = "Weight for flow control of this job",
3718                 .parent = "flow_id",
3719                 .hide   = 1,
3720                 .def    = "0",
3721                 .category = FIO_OPT_C_IO,
3722                 .group  = FIO_OPT_G_IO_FLOW,
3723         },
3724         {
3725                 .name   = "flow_watermark",
3726                 .lname  = "I/O flow watermark",
3727                 .type   = FIO_OPT_INT,
3728                 .off1   = td_var_offset(flow_watermark),
3729                 .help   = "High watermark for flow control. This option"
3730                         " should be set to the same value for all threads"
3731                         " with non-zero flow.",
3732                 .parent = "flow_id",
3733                 .hide   = 1,
3734                 .def    = "1024",
3735                 .category = FIO_OPT_C_IO,
3736                 .group  = FIO_OPT_G_IO_FLOW,
3737         },
3738         {
3739                 .name   = "flow_sleep",
3740                 .lname  = "I/O flow sleep",
3741                 .type   = FIO_OPT_INT,
3742                 .off1   = td_var_offset(flow_sleep),
3743                 .help   = "How many microseconds to sleep after being held"
3744                         " back by the flow control mechanism",
3745                 .parent = "flow_id",
3746                 .hide   = 1,
3747                 .def    = "0",
3748                 .category = FIO_OPT_C_IO,
3749                 .group  = FIO_OPT_G_IO_FLOW,
3750         },
3751         {
3752                 .name   = "skip_bad",
3753                 .lname  = "Skip operations against bad blocks",
3754                 .type   = FIO_OPT_BOOL,
3755                 .off1   = td_var_offset(skip_bad),
3756                 .help   = "Skip operations against known bad blocks.",
3757                 .hide   = 1,
3758                 .def    = "0",
3759                 .category = FIO_OPT_C_IO,
3760                 .group  = FIO_OPT_G_MTD,
3761         },
3762         {
3763                 .name = NULL,
3764         },
3765 };
3766
3767 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3768                         const char *name, int val)
3769 {
3770         lopt->name = (char *) name;
3771         lopt->val = val;
3772         if (o->type == FIO_OPT_STR_SET)
3773                 lopt->has_arg = optional_argument;
3774         else
3775                 lopt->has_arg = required_argument;
3776 }
3777
3778 static void options_to_lopts(struct fio_option *opts,
3779                               struct option *long_options,
3780                               int i, int option_type)
3781 {
3782         struct fio_option *o = &opts[0];
3783         while (o->name) {
3784                 add_to_lopt(&long_options[i], o, o->name, option_type);
3785                 if (o->alias) {
3786                         i++;
3787                         add_to_lopt(&long_options[i], o, o->alias, option_type);
3788                 }
3789
3790                 i++;
3791                 o++;
3792                 assert(i < FIO_NR_OPTIONS);
3793         }
3794 }
3795
3796 void fio_options_set_ioengine_opts(struct option *long_options,
3797                                    struct thread_data *td)
3798 {
3799         unsigned int i;
3800
3801         i = 0;
3802         while (long_options[i].name) {
3803                 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3804                         memset(&long_options[i], 0, sizeof(*long_options));
3805                         break;
3806                 }
3807                 i++;
3808         }
3809
3810         /*
3811          * Just clear out the prior ioengine options.
3812          */
3813         if (!td || !td->eo)
3814                 return;
3815
3816         options_to_lopts(td->io_ops->options, long_options, i,
3817                          FIO_GETOPT_IOENGINE);
3818 }
3819
3820 void fio_options_dup_and_init(struct option *long_options)
3821 {
3822         unsigned int i;
3823
3824         options_init(fio_options);
3825
3826         i = 0;
3827         while (long_options[i].name)
3828                 i++;
3829
3830         options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3831 }
3832
3833 struct fio_keyword {
3834         const char *word;
3835         const char *desc;
3836         char *replace;
3837 };
3838
3839 static struct fio_keyword fio_keywords[] = {
3840         {
3841                 .word   = "$pagesize",
3842                 .desc   = "Page size in the system",
3843         },
3844         {
3845                 .word   = "$mb_memory",
3846                 .desc   = "Megabytes of memory online",
3847         },
3848         {
3849                 .word   = "$ncpus",
3850                 .desc   = "Number of CPUs online in the system",
3851         },
3852         {
3853                 .word   = NULL,
3854         },
3855 };
3856
3857 void fio_keywords_exit(void)
3858 {
3859         struct fio_keyword *kw;
3860
3861         kw = &fio_keywords[0];
3862         while (kw->word) {
3863                 free(kw->replace);
3864                 kw->replace = NULL;
3865                 kw++;
3866         }
3867 }
3868
3869 void fio_keywords_init(void)
3870 {
3871         unsigned long long mb_memory;
3872         char buf[128];
3873         long l;
3874
3875         sprintf(buf, "%lu", (unsigned long) page_size);
3876         fio_keywords[0].replace = strdup(buf);
3877
3878         mb_memory = os_phys_mem() / (1024 * 1024);
3879         sprintf(buf, "%llu", mb_memory);
3880         fio_keywords[1].replace = strdup(buf);
3881
3882         l = cpus_online();
3883         sprintf(buf, "%lu", l);
3884         fio_keywords[2].replace = strdup(buf);
3885 }
3886
3887 #define BC_APP          "bc"
3888
3889 static char *bc_calc(char *str)
3890 {
3891         char buf[128], *tmp;
3892         FILE *f;
3893         int ret;
3894
3895         /*
3896          * No math, just return string
3897          */
3898         if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&