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