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