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