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