c273da761457435fef000668e2167cc0e50418d0
[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 <getopt.h>
7 #include <assert.h>
8 #include <libgen.h>
9 #include <fcntl.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12
13 #include "fio.h"
14 #include "verify.h"
15 #include "parse.h"
16 #include "lib/fls.h"
17
18 #define td_var_offset(var)      ((size_t) &((struct thread_options *)0)->var)
19
20 /*
21  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22  */
23 static char *get_opt_postfix(const char *str)
24 {
25         char *p = strstr(str, ":");
26
27         if (!p)
28                 return NULL;
29
30         p++;
31         strip_blank_front(&p);
32         strip_blank_end(p);
33         return strdup(p);
34 }
35
36 static int bs_cmp(const void *p1, const void *p2)
37 {
38         const struct bssplit *bsp1 = p1;
39         const struct bssplit *bsp2 = p2;
40
41         return bsp1->perc < bsp2->perc;
42 }
43
44 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
45 {
46         struct bssplit *bssplit;
47         unsigned int i, perc, perc_missing;
48         unsigned int max_bs, min_bs;
49         long long val;
50         char *fname;
51
52         td->o.bssplit_nr[ddir] = 4;
53         bssplit = malloc(4 * sizeof(struct bssplit));
54
55         i = 0;
56         max_bs = 0;
57         min_bs = -1;
58         while ((fname = strsep(&str, ":")) != NULL) {
59                 char *perc_str;
60
61                 if (!strlen(fname))
62                         break;
63
64                 /*
65                  * grow struct buffer, if needed
66                  */
67                 if (i == td->o.bssplit_nr[ddir]) {
68                         td->o.bssplit_nr[ddir] <<= 1;
69                         bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
70                                                   * sizeof(struct bssplit));
71                 }
72
73                 perc_str = strstr(fname, "/");
74                 if (perc_str) {
75                         *perc_str = '\0';
76                         perc_str++;
77                         perc = atoi(perc_str);
78                         if (perc > 100)
79                                 perc = 100;
80                         else if (!perc)
81                                 perc = -1;
82                 } else
83                         perc = -1;
84
85                 if (str_to_decimal(fname, &val, 1)) {
86                         log_err("fio: bssplit conversion failed\n");
87                         free(td->o.bssplit);
88                         return 1;
89                 }
90
91                 if (val > max_bs)
92                         max_bs = val;
93                 if (val < min_bs)
94                         min_bs = val;
95
96                 bssplit[i].bs = val;
97                 bssplit[i].perc = perc;
98                 i++;
99         }
100
101         td->o.bssplit_nr[ddir] = i;
102
103         /*
104          * Now check if the percentages add up, and how much is missing
105          */
106         perc = perc_missing = 0;
107         for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108                 struct bssplit *bsp = &bssplit[i];
109
110                 if (bsp->perc == (unsigned char) -1)
111                         perc_missing++;
112                 else
113                         perc += bsp->perc;
114         }
115
116         if (perc > 100) {
117                 log_err("fio: bssplit percentages add to more than 100%%\n");
118                 free(bssplit);
119                 return 1;
120         }
121         /*
122          * If values didn't have a percentage set, divide the remains between
123          * them.
124          */
125         if (perc_missing) {
126                 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127                         struct bssplit *bsp = &bssplit[i];
128
129                         if (bsp->perc == (unsigned char) -1)
130                                 bsp->perc = (100 - perc) / perc_missing;
131                 }
132         }
133
134         td->o.min_bs[ddir] = min_bs;
135         td->o.max_bs[ddir] = max_bs;
136
137         /*
138          * now sort based on percentages, for ease of lookup
139          */
140         qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141         td->o.bssplit[ddir] = bssplit;
142         return 0;
143
144 }
145
146 static int str_bssplit_cb(void *data, const char *input)
147 {
148         struct thread_data *td = data;
149         char *str, *p, *odir;
150         int ret = 0;
151
152         p = str = strdup(input);
153
154         strip_blank_front(&str);
155         strip_blank_end(str);
156
157         odir = strchr(str, ',');
158         if (odir) {
159                 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
160                 if (!ret) {
161                         *odir = '\0';
162                         ret = bssplit_ddir(td, DDIR_READ, str);
163                 }
164         } else {
165                 char *op;
166
167                 op = strdup(str);
168
169                 ret = bssplit_ddir(td, DDIR_READ, str);
170                 if (!ret)
171                         ret = bssplit_ddir(td, DDIR_WRITE, op);
172
173                 free(op);
174         }
175
176         free(p);
177         return ret;
178 }
179
180 static int str_rw_cb(void *data, const char *str)
181 {
182         struct thread_data *td = data;
183         char *nr = get_opt_postfix(str);
184
185         td->o.ddir_nr = 1;
186         if (nr) {
187                 td->o.ddir_nr = atoi(nr);
188                 free(nr);
189         }
190
191         return 0;
192 }
193
194 static int str_mem_cb(void *data, const char *mem)
195 {
196         struct thread_data *td = data;
197
198         if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
199                 td->mmapfile = get_opt_postfix(mem);
200                 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
201                         log_err("fio: mmaphuge:/path/to/file\n");
202                         return 1;
203                 }
204         }
205
206         return 0;
207 }
208
209 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
210 {
211         mlock_size = *val;
212         return 0;
213 }
214
215 static int str_rwmix_read_cb(void *data, unsigned int *val)
216 {
217         struct thread_data *td = data;
218
219         td->o.rwmix[DDIR_READ] = *val;
220         td->o.rwmix[DDIR_WRITE] = 100 - *val;
221         return 0;
222 }
223
224 static int str_rwmix_write_cb(void *data, unsigned int *val)
225 {
226         struct thread_data *td = data;
227
228         td->o.rwmix[DDIR_WRITE] = *val;
229         td->o.rwmix[DDIR_READ] = 100 - *val;
230         return 0;
231 }
232
233 #ifdef FIO_HAVE_IOPRIO
234 static int str_prioclass_cb(void *data, unsigned int *val)
235 {
236         struct thread_data *td = data;
237         unsigned short mask;
238
239         /*
240          * mask off old class bits, str_prio_cb() may have set a default class
241          */
242         mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
243         td->ioprio &= mask;
244
245         td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
246         td->ioprio_set = 1;
247         return 0;
248 }
249
250 static int str_prio_cb(void *data, unsigned int *val)
251 {
252         struct thread_data *td = data;
253
254         td->ioprio |= *val;
255
256         /*
257          * If no class is set, assume BE
258          */
259         if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260                 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
261
262         td->ioprio_set = 1;
263         return 0;
264 }
265 #endif
266
267 static int str_exitall_cb(void)
268 {
269         exitall_on_terminate = 1;
270         return 0;
271 }
272
273 #ifdef FIO_HAVE_CPU_AFFINITY
274 static int str_cpumask_cb(void *data, unsigned int *val)
275 {
276         struct thread_data *td = data;
277         unsigned int i;
278         long max_cpu;
279         int ret;
280
281         ret = fio_cpuset_init(&td->o.cpumask);
282         if (ret < 0) {
283                 log_err("fio: cpuset_init failed\n");
284                 td_verror(td, ret, "fio_cpuset_init");
285                 return 1;
286         }
287
288         max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
289
290         for (i = 0; i < sizeof(int) * 8; i++) {
291                 if ((1 << i) & *val) {
292                         if (i > max_cpu) {
293                                 log_err("fio: CPU %d too large (max=%ld)\n", i,
294                                                                 max_cpu);
295                                 return 1;
296                         }
297                         dprint(FD_PARSE, "set cpu allowed %d\n", i);
298                         fio_cpu_set(&td->o.cpumask, i);
299                 }
300         }
301
302         td->o.cpumask_set = 1;
303         return 0;
304 }
305
306 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
307                             const char *input)
308 {
309         char *cpu, *str, *p;
310         long max_cpu;
311         int ret = 0;
312
313         ret = fio_cpuset_init(mask);
314         if (ret < 0) {
315                 log_err("fio: cpuset_init failed\n");
316                 td_verror(td, ret, "fio_cpuset_init");
317                 return 1;
318         }
319
320         p = str = strdup(input);
321
322         strip_blank_front(&str);
323         strip_blank_end(str);
324
325         max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
326
327         while ((cpu = strsep(&str, ",")) != NULL) {
328                 char *str2, *cpu2;
329                 int icpu, icpu2;
330
331                 if (!strlen(cpu))
332                         break;
333
334                 str2 = cpu;
335                 icpu2 = -1;
336                 while ((cpu2 = strsep(&str2, "-")) != NULL) {
337                         if (!strlen(cpu2))
338                                 break;
339
340                         icpu2 = atoi(cpu2);
341                 }
342
343                 icpu = atoi(cpu);
344                 if (icpu2 == -1)
345                         icpu2 = icpu;
346                 while (icpu <= icpu2) {
347                         if (icpu >= FIO_MAX_CPUS) {
348                                 log_err("fio: your OS only supports up to"
349                                         " %d CPUs\n", (int) FIO_MAX_CPUS);
350                                 ret = 1;
351                                 break;
352                         }
353                         if (icpu > max_cpu) {
354                                 log_err("fio: CPU %d too large (max=%ld)\n",
355                                                         icpu, max_cpu);
356                                 ret = 1;
357                                 break;
358                         }
359         
360                         dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
361                         fio_cpu_set(mask, icpu);
362                         icpu++;
363                 }
364                 if (ret)
365                         break;
366         }
367
368         free(p);
369         if (!ret)
370                 td->o.cpumask_set = 1;
371         return ret;
372 }
373
374 static int str_cpus_allowed_cb(void *data, const char *input)
375 {
376         struct thread_data *td = data;
377         int ret;
378
379         ret = set_cpus_allowed(td, &td->o.cpumask, input);
380         if (!ret)
381                 td->o.cpumask_set = 1;
382
383         return ret;
384 }
385
386 static int str_verify_cpus_allowed_cb(void *data, const char *input)
387 {
388         struct thread_data *td = data;
389         int ret;
390
391         ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
392         if (!ret)
393                 td->o.verify_cpumask_set = 1;
394
395         return ret;
396 }
397 #endif
398
399 static int str_fst_cb(void *data, const char *str)
400 {
401         struct thread_data *td = data;
402         char *nr = get_opt_postfix(str);
403
404         td->file_service_nr = 1;
405         if (nr) {
406                 td->file_service_nr = atoi(nr);
407                 free(nr);
408         }
409
410         return 0;
411 }
412
413 static int check_dir(struct thread_data *td, char *fname)
414 {
415         char file[PATH_MAX], *dir;
416         int elen = 0;
417
418         if (td->o.directory) {
419                 strcpy(file, td->o.directory);
420                 strcat(file, "/");
421                 elen = strlen(file);
422         }
423
424         sprintf(file + elen, "%s", fname);
425         dir = dirname(file);
426
427 #if 0
428         {
429         struct stat sb;
430         /*
431          * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
432          * yet, so we can't do this check right here...
433          */
434         if (lstat(dir, &sb) < 0) {
435                 int ret = errno;
436
437                 log_err("fio: %s is not a directory\n", dir);
438                 td_verror(td, ret, "lstat");
439                 return 1;
440         }
441
442         if (!S_ISDIR(sb.st_mode)) {
443                 log_err("fio: %s is not a directory\n", dir);
444                 return 1;
445         }
446         }
447 #endif
448
449         return 0;
450 }
451
452 static int str_filename_cb(void *data, const char *input)
453 {
454         struct thread_data *td = data;
455         char *fname, *str, *p;
456
457         p = str = strdup(input);
458
459         strip_blank_front(&str);
460         strip_blank_end(str);
461
462         if (!td->files_index)
463                 td->o.nr_files = 0;
464
465         while ((fname = strsep(&str, ":")) != NULL) {
466                 if (!strlen(fname))
467                         break;
468                 if (check_dir(td, fname)) {
469                         free(p);
470                         return 1;
471                 }
472                 add_file(td, fname);
473                 td->o.nr_files++;
474         }
475
476         free(p);
477         return 0;
478 }
479
480 static int str_directory_cb(void *data, const char fio_unused *str)
481 {
482         struct thread_data *td = data;
483         struct stat sb;
484
485         if (lstat(td->o.directory, &sb) < 0) {
486                 int ret = errno;
487
488                 log_err("fio: %s is not a directory\n", td->o.directory);
489                 td_verror(td, ret, "lstat");
490                 return 1;
491         }
492         if (!S_ISDIR(sb.st_mode)) {
493                 log_err("fio: %s is not a directory\n", td->o.directory);
494                 return 1;
495         }
496
497         return 0;
498 }
499
500 static int str_opendir_cb(void *data, const char fio_unused *str)
501 {
502         struct thread_data *td = data;
503
504         if (!td->files_index)
505                 td->o.nr_files = 0;
506
507         return add_dir_files(td, td->o.opendir);
508 }
509
510 static int str_verify_offset_cb(void *data, unsigned int *off)
511 {
512         struct thread_data *td = data;
513
514         if (*off && *off < sizeof(struct verify_header)) {
515                 log_err("fio: verify_offset too small\n");
516                 return 1;
517         }
518
519         td->o.verify_offset = *off;
520         return 0;
521 }
522
523 static int str_verify_pattern_cb(void *data, unsigned int *off)
524 {
525         struct thread_data *td = data;
526         unsigned int msb;
527
528         msb = __fls(*off);
529         if (msb <= 8)
530                 td->o.verify_pattern_bytes = 1;
531         else if (msb <= 16)
532                 td->o.verify_pattern_bytes = 2;
533         else if (msb <= 24)
534                 td->o.verify_pattern_bytes = 3;
535         else
536                 td->o.verify_pattern_bytes = 4;
537
538         td->o.verify_pattern = *off;
539         return 0;
540 }
541
542 static int str_lockfile_cb(void *data, const char *str)
543 {
544         struct thread_data *td = data;
545         char *nr = get_opt_postfix(str);
546
547         td->o.lockfile_batch = 1;
548         if (nr) {
549                 td->o.lockfile_batch = atoi(nr);
550                 free(nr);
551         }
552
553         return 0;
554 }
555
556 static int str_write_bw_log_cb(void *data, const char *str)
557 {
558         struct thread_data *td = data;
559
560         if (str)
561                 td->o.bw_log_file = strdup(str);
562
563         td->o.write_bw_log = 1;
564         return 0;
565 }
566
567 static int str_write_lat_log_cb(void *data, const char *str)
568 {
569         struct thread_data *td = data;
570
571         if (str)
572                 td->o.lat_log_file = strdup(str);
573
574         td->o.write_lat_log = 1;
575         return 0;
576 }
577
578 static int str_gtod_reduce_cb(void *data, int *il)
579 {
580         struct thread_data *td = data;
581         int val = *il;
582
583         td->o.disable_clat = !!val;
584         td->o.disable_slat = !!val;
585         td->o.disable_bw = !!val;
586         if (val)
587                 td->tv_cache_mask = 63;
588
589         return 0;
590 }
591
592 static int str_gtod_cpu_cb(void *data, int *il)
593 {
594         struct thread_data *td = data;
595         int val = *il;
596
597         td->o.gtod_cpu = val;
598         td->o.gtod_offload = 1;
599         return 0;
600 }
601
602 static int rw_verify(struct fio_option *o, void *data)
603 {
604         struct thread_data *td = data;
605
606         if (read_only && td_write(td)) {
607                 log_err("fio: job <%s> has write bit set, but fio is in"
608                         " read-only mode\n", td->o.name);
609                 return 1;
610         }
611
612         return 0;
613 }
614
615 static int gtod_cpu_verify(struct fio_option *o, void *data)
616 {
617 #ifndef FIO_HAVE_CPU_AFFINITY
618         struct thread_data *td = data;
619
620         if (td->o.gtod_cpu) {
621                 log_err("fio: platform must support CPU affinity for"
622                         "gettimeofday() offloading\n");
623                 return 1;
624         }
625 #endif
626
627         return 0;
628 }
629
630 static int kb_base_verify(struct fio_option *o, void *data)
631 {
632         struct thread_data *td = data;
633
634         if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
635                 log_err("fio: kb_base set to nonsensical value: %u\n",
636                                 td->o.kb_base);
637                 return 1;
638         }
639
640         return 0;
641 }
642
643 #define __stringify_1(x)        #x
644 #define __stringify(x)          __stringify_1(x)
645
646 /*
647  * Map of job/command line options
648  */
649 static struct fio_option options[] = {
650         {
651                 .name   = "description",
652                 .type   = FIO_OPT_STR_STORE,
653                 .off1   = td_var_offset(description),
654                 .help   = "Text job description",
655         },
656         {
657                 .name   = "name",
658                 .type   = FIO_OPT_STR_STORE,
659                 .off1   = td_var_offset(name),
660                 .help   = "Name of this job",
661         },
662         {
663                 .name   = "directory",
664                 .type   = FIO_OPT_STR_STORE,
665                 .off1   = td_var_offset(directory),
666                 .cb     = str_directory_cb,
667                 .help   = "Directory to store files in",
668         },
669         {
670                 .name   = "filename",
671                 .type   = FIO_OPT_STR_STORE,
672                 .off1   = td_var_offset(filename),
673                 .cb     = str_filename_cb,
674                 .prio   = -1, /* must come after "directory" */
675                 .help   = "File(s) to use for the workload",
676         },
677         {
678                 .name   = "kb_base",
679                 .type   = FIO_OPT_INT,
680                 .off1   = td_var_offset(kb_base),
681                 .help   = "How many bytes per KB for reporting (1000 or 1024)",
682                 .verify = kb_base_verify,
683                 .def    = "1024",
684         },
685         {
686                 .name   = "lockfile",
687                 .type   = FIO_OPT_STR,
688                 .cb     = str_lockfile_cb,
689                 .off1   = td_var_offset(file_lock_mode),
690                 .help   = "Lock file when doing IO to it",
691                 .parent = "filename",
692                 .def    = "none",
693                 .posval = {
694                           { .ival = "none",
695                             .oval = FILE_LOCK_NONE,
696                             .help = "No file locking",
697                           },
698                           { .ival = "exclusive",
699                             .oval = FILE_LOCK_EXCLUSIVE,
700                             .help = "Exclusive file lock",
701                           },
702                           {
703                             .ival = "readwrite",
704                             .oval = FILE_LOCK_READWRITE,
705                             .help = "Read vs write lock",
706                           },
707                 },
708         },
709         {
710                 .name   = "opendir",
711                 .type   = FIO_OPT_STR_STORE,
712                 .off1   = td_var_offset(opendir),
713                 .cb     = str_opendir_cb,
714                 .help   = "Recursively add files from this directory and down",
715         },
716         {
717                 .name   = "rw",
718                 .alias  = "readwrite",
719                 .type   = FIO_OPT_STR,
720                 .cb     = str_rw_cb,
721                 .off1   = td_var_offset(td_ddir),
722                 .help   = "IO direction",
723                 .def    = "read",
724                 .verify = rw_verify,
725                 .posval = {
726                           { .ival = "read",
727                             .oval = TD_DDIR_READ,
728                             .help = "Sequential read",
729                           },
730                           { .ival = "write",
731                             .oval = TD_DDIR_WRITE,
732                             .help = "Sequential write",
733                           },
734                           { .ival = "randread",
735                             .oval = TD_DDIR_RANDREAD,
736                             .help = "Random read",
737                           },
738                           { .ival = "randwrite",
739                             .oval = TD_DDIR_RANDWRITE,
740                             .help = "Random write",
741                           },
742                           { .ival = "rw",
743                             .oval = TD_DDIR_RW,
744                             .help = "Sequential read and write mix",
745                           },
746                           { .ival = "randrw",
747                             .oval = TD_DDIR_RANDRW,
748                             .help = "Random read and write mix"
749                           },
750                 },
751         },
752         {
753                 .name   = "ioengine",
754                 .type   = FIO_OPT_STR_STORE,
755                 .off1   = td_var_offset(ioengine),
756                 .help   = "IO engine to use",
757                 .def    = "sync",
758                 .posval = {
759                           { .ival = "sync",
760                             .help = "Use read/write",
761                           },
762                           { .ival = "psync",
763                             .help = "Use pread/pwrite",
764                           },
765                           { .ival = "vsync",
766                              .help = "Use readv/writev",
767                           },
768 #ifdef FIO_HAVE_LIBAIO
769                           { .ival = "libaio",
770                             .help = "Linux native asynchronous IO",
771                           },
772 #endif
773 #ifdef FIO_HAVE_POSIXAIO
774                           { .ival = "posixaio",
775                             .help = "POSIX asynchronous IO",
776                           },
777 #endif
778 #ifdef FIO_HAVE_SOLARISAIO
779                           { .ival = "solarisaio",
780                             .help = "Solaris native asynchronous IO",
781                           },
782 #endif
783                           { .ival = "mmap",
784                             .help = "Memory mapped IO",
785                           },
786 #ifdef FIO_HAVE_SPLICE
787                           { .ival = "splice",
788                             .help = "splice/vmsplice based IO",
789                           },
790                           { .ival = "netsplice",
791                             .help = "splice/vmsplice to/from the network",
792                           },
793 #endif
794 #ifdef FIO_HAVE_SGIO
795                           { .ival = "sg",
796                             .help = "SCSI generic v3 IO",
797                           },
798 #endif
799                           { .ival = "null",
800                             .help = "Testing engine (no data transfer)",
801                           },
802                           { .ival = "net",
803                             .help = "Network IO",
804                           },
805 #ifdef FIO_HAVE_SYSLET
806                           { .ival = "syslet-rw",
807                             .help = "syslet enabled async pread/pwrite IO",
808                           },
809 #endif
810                           { .ival = "cpuio",
811                             .help = "CPU cycler burner engine",
812                           },
813 #ifdef FIO_HAVE_GUASI
814                           { .ival = "guasi",
815                             .help = "GUASI IO engine",
816                           },
817 #endif
818                           { .ival = "external",
819                             .help = "Load external engine (append name)",
820                           },
821                 },
822         },
823         {
824                 .name   = "iodepth",
825                 .type   = FIO_OPT_INT,
826                 .off1   = td_var_offset(iodepth),
827                 .help   = "Amount of IO buffers to keep in flight",
828                 .minval = 1,
829                 .def    = "1",
830         },
831         {
832                 .name   = "iodepth_batch",
833                 .alias  = "iodepth_batch_submit",
834                 .type   = FIO_OPT_INT,
835                 .off1   = td_var_offset(iodepth_batch),
836                 .help   = "Number of IO buffers to submit in one go",
837                 .parent = "iodepth",
838                 .minval = 1,
839                 .def    = "1",
840         },
841         {
842                 .name   = "iodepth_batch_complete",
843                 .type   = FIO_OPT_INT,
844                 .off1   = td_var_offset(iodepth_batch_complete),
845                 .help   = "Number of IO buffers to retrieve in one go",
846                 .parent = "iodepth",
847                 .minval = 0,
848                 .def    = "1",
849         },
850         {
851                 .name   = "iodepth_low",
852                 .type   = FIO_OPT_INT,
853                 .off1   = td_var_offset(iodepth_low),
854                 .help   = "Low water mark for queuing depth",
855                 .parent = "iodepth",
856         },
857         {
858                 .name   = "size",
859                 .type   = FIO_OPT_STR_VAL,
860                 .off1   = td_var_offset(size),
861                 .minval = 1,
862                 .help   = "Total size of device or files",
863         },
864         {
865                 .name   = "fill_device",
866                 .type   = FIO_OPT_BOOL,
867                 .off1   = td_var_offset(fill_device),
868                 .help   = "Write until an ENOSPC error occurs",
869                 .def    = "0",
870         },
871         {
872                 .name   = "filesize",
873                 .type   = FIO_OPT_STR_VAL,
874                 .off1   = td_var_offset(file_size_low),
875                 .off2   = td_var_offset(file_size_high),
876                 .minval = 1,
877                 .help   = "Size of individual files",
878         },
879         {
880                 .name   = "offset",
881                 .alias  = "fileoffset",
882                 .type   = FIO_OPT_STR_VAL,
883                 .off1   = td_var_offset(start_offset),
884                 .help   = "Start IO from this offset",
885                 .def    = "0",
886         },
887         {
888                 .name   = "bs",
889                 .alias  = "blocksize",
890                 .type   = FIO_OPT_INT,
891                 .off1   = td_var_offset(bs[DDIR_READ]),
892                 .off2   = td_var_offset(bs[DDIR_WRITE]),
893                 .minval = 1,
894                 .help   = "Block size unit",
895                 .def    = "4k",
896                 .parent = "rw",
897         },
898         {
899                 .name   = "ba",
900                 .alias  = "blockalign",
901                 .type   = FIO_OPT_INT,
902                 .off1   = td_var_offset(ba[DDIR_READ]),
903                 .off2   = td_var_offset(ba[DDIR_WRITE]),
904                 .minval = 1,
905                 .help   = "IO block offset alignment",
906                 .parent = "rw",
907         },
908         {
909                 .name   = "bsrange",
910                 .alias  = "blocksize_range",
911                 .type   = FIO_OPT_RANGE,
912                 .off1   = td_var_offset(min_bs[DDIR_READ]),
913                 .off2   = td_var_offset(max_bs[DDIR_READ]),
914                 .off3   = td_var_offset(min_bs[DDIR_WRITE]),
915                 .off4   = td_var_offset(max_bs[DDIR_WRITE]),
916                 .minval = 1,
917                 .help   = "Set block size range (in more detail than bs)",
918                 .parent = "rw",
919         },
920         {
921                 .name   = "bssplit",
922                 .type   = FIO_OPT_STR,
923                 .cb     = str_bssplit_cb,
924                 .help   = "Set a specific mix of block sizes",
925                 .parent = "rw",
926         },
927         {
928                 .name   = "bs_unaligned",
929                 .alias  = "blocksize_unaligned",
930                 .type   = FIO_OPT_STR_SET,
931                 .off1   = td_var_offset(bs_unaligned),
932                 .help   = "Don't sector align IO buffer sizes",
933                 .parent = "rw",
934         },
935         {
936                 .name   = "randrepeat",
937                 .type   = FIO_OPT_BOOL,
938                 .off1   = td_var_offset(rand_repeatable),
939                 .help   = "Use repeatable random IO pattern",
940                 .def    = "1",
941                 .parent = "rw",
942         },
943         {
944                 .name   = "norandommap",
945                 .type   = FIO_OPT_STR_SET,
946                 .off1   = td_var_offset(norandommap),
947                 .help   = "Accept potential duplicate random blocks",
948                 .parent = "rw",
949         },
950         {
951                 .name   = "softrandommap",
952                 .type   = FIO_OPT_BOOL,
953                 .off1   = td_var_offset(softrandommap),
954                 .help   = "Set norandommap if randommap allocation fails",
955                 .parent = "norandommap",
956                 .def    = "0",
957         },
958         {
959                 .name   = "nrfiles",
960                 .type   = FIO_OPT_INT,
961                 .off1   = td_var_offset(nr_files),
962                 .help   = "Split job workload between this number of files",
963                 .def    = "1",
964         },
965         {
966                 .name   = "openfiles",
967                 .type   = FIO_OPT_INT,
968                 .off1   = td_var_offset(open_files),
969                 .help   = "Number of files to keep open at the same time",
970         },
971         {
972                 .name   = "file_service_type",
973                 .type   = FIO_OPT_STR,
974                 .cb     = str_fst_cb,
975                 .off1   = td_var_offset(file_service_type),
976                 .help   = "How to select which file to service next",
977                 .def    = "roundrobin",
978                 .posval = {
979                           { .ival = "random",
980                             .oval = FIO_FSERVICE_RANDOM,
981                             .help = "Choose a file at random",
982                           },
983                           { .ival = "roundrobin",
984                             .oval = FIO_FSERVICE_RR,
985                             .help = "Round robin select files",
986                           },
987                           { .ival = "sequential",
988                             .oval = FIO_FSERVICE_SEQ,
989                             .help = "Finish one file before moving to the next",
990                           },
991                 },
992                 .parent = "nrfiles",
993         },
994         {
995                 .name   = "fadvise_hint",
996                 .type   = FIO_OPT_BOOL,
997                 .off1   = td_var_offset(fadvise_hint),
998                 .help   = "Use fadvise() to advise the kernel on IO pattern",
999                 .def    = "1",
1000         },
1001         {
1002                 .name   = "fsync",
1003                 .type   = FIO_OPT_INT,
1004                 .off1   = td_var_offset(fsync_blocks),
1005                 .help   = "Issue fsync for writes every given number of blocks",
1006                 .def    = "0",
1007         },
1008         {
1009                 .name   = "fdatasync",
1010                 .type   = FIO_OPT_INT,
1011                 .off1   = td_var_offset(fdatasync_blocks),
1012                 .help   = "Issue fdatasync for writes every given number of blocks",
1013                 .def    = "0",
1014         },
1015         {
1016                 .name   = "direct",
1017                 .type   = FIO_OPT_BOOL,
1018                 .off1   = td_var_offset(odirect),
1019                 .help   = "Use O_DIRECT IO (negates buffered)",
1020                 .def    = "0",
1021         },
1022         {
1023                 .name   = "buffered",
1024                 .type   = FIO_OPT_BOOL,
1025                 .off1   = td_var_offset(odirect),
1026                 .neg    = 1,
1027                 .help   = "Use buffered IO (negates direct)",
1028                 .def    = "1",
1029         },
1030         {
1031                 .name   = "overwrite",
1032                 .type   = FIO_OPT_BOOL,
1033                 .off1   = td_var_offset(overwrite),
1034                 .help   = "When writing, set whether to overwrite current data",
1035                 .def    = "0",
1036         },
1037         {
1038                 .name   = "loops",
1039                 .type   = FIO_OPT_INT,
1040                 .off1   = td_var_offset(loops),
1041                 .help   = "Number of times to run the job",
1042                 .def    = "1",
1043         },
1044         {
1045                 .name   = "numjobs",
1046                 .type   = FIO_OPT_INT,
1047                 .off1   = td_var_offset(numjobs),
1048                 .help   = "Duplicate this job this many times",
1049                 .def    = "1",
1050         },
1051         {
1052                 .name   = "startdelay",
1053                 .type   = FIO_OPT_INT,
1054                 .off1   = td_var_offset(start_delay),
1055                 .help   = "Only start job when this period has passed",
1056                 .def    = "0",
1057         },
1058         {
1059                 .name   = "runtime",
1060                 .alias  = "timeout",
1061                 .type   = FIO_OPT_STR_VAL_TIME,
1062                 .off1   = td_var_offset(timeout),
1063                 .help   = "Stop workload when this amount of time has passed",
1064                 .def    = "0",
1065         },
1066         {
1067                 .name   = "time_based",
1068                 .type   = FIO_OPT_STR_SET,
1069                 .off1   = td_var_offset(time_based),
1070                 .help   = "Keep running until runtime/timeout is met",
1071         },
1072         {
1073                 .name   = "ramp_time",
1074                 .type   = FIO_OPT_STR_VAL_TIME,
1075                 .off1   = td_var_offset(ramp_time),
1076                 .help   = "Ramp up time before measuring performance",
1077         },
1078         {
1079                 .name   = "mem",
1080                 .alias  = "iomem",
1081                 .type   = FIO_OPT_STR,
1082                 .cb     = str_mem_cb,
1083                 .off1   = td_var_offset(mem_type),
1084                 .help   = "Backing type for IO buffers",
1085                 .def    = "malloc",
1086                 .posval = {
1087                           { .ival = "malloc",
1088                             .oval = MEM_MALLOC,
1089                             .help = "Use malloc(3) for IO buffers",
1090                           },
1091                           { .ival = "shm",
1092                             .oval = MEM_SHM,
1093                             .help = "Use shared memory segments for IO buffers",
1094                           },
1095 #ifdef FIO_HAVE_HUGETLB
1096                           { .ival = "shmhuge",
1097                             .oval = MEM_SHMHUGE,
1098                             .help = "Like shm, but use huge pages",
1099                           },
1100 #endif
1101                           { .ival = "mmap",
1102                             .oval = MEM_MMAP,
1103                             .help = "Use mmap(2) (file or anon) for IO buffers",
1104                           },
1105 #ifdef FIO_HAVE_HUGETLB
1106                           { .ival = "mmaphuge",
1107                             .oval = MEM_MMAPHUGE,
1108                             .help = "Like mmap, but use huge pages",
1109                           },
1110 #endif
1111                   },
1112         },
1113         {
1114                 .name   = "iomem_align",
1115                 .alias  = "mem_align",
1116                 .type   = FIO_OPT_INT,
1117                 .off1   = td_var_offset(mem_align),
1118                 .minval = 0,
1119                 .help   = "IO memory buffer offset alignment",
1120                 .def    = "0",
1121                 .parent = "iomem",
1122         },
1123         {
1124                 .name   = "verify",
1125                 .type   = FIO_OPT_STR,
1126                 .off1   = td_var_offset(verify),
1127                 .help   = "Verify data written",
1128                 .def    = "0",
1129                 .posval = {
1130                           { .ival = "0",
1131                             .oval = VERIFY_NONE,
1132                             .help = "Don't do IO verification",
1133                           },
1134                           { .ival = "md5",
1135                             .oval = VERIFY_MD5,
1136                             .help = "Use md5 checksums for verification",
1137                           },
1138                           { .ival = "crc64",
1139                             .oval = VERIFY_CRC64,
1140                             .help = "Use crc64 checksums for verification",
1141                           },
1142                           { .ival = "crc32",
1143                             .oval = VERIFY_CRC32,
1144                             .help = "Use crc32 checksums for verification",
1145                           },
1146                           { .ival = "crc32c-intel",
1147                             .oval = VERIFY_CRC32C_INTEL,
1148                             .help = "Use hw crc32c checksums for verification",
1149                           },
1150                           { .ival = "crc32c",
1151                             .oval = VERIFY_CRC32C,
1152                             .help = "Use crc32c checksums for verification",
1153                           },
1154                           { .ival = "crc16",
1155                             .oval = VERIFY_CRC16,
1156                             .help = "Use crc16 checksums for verification",
1157                           },
1158                           { .ival = "crc7",
1159                             .oval = VERIFY_CRC7,
1160                             .help = "Use crc7 checksums for verification",
1161                           },
1162                           { .ival = "sha256",
1163                             .oval = VERIFY_SHA256,
1164                             .help = "Use sha256 checksums for verification",
1165                           },
1166                           { .ival = "sha512",
1167                             .oval = VERIFY_SHA512,
1168                             .help = "Use sha512 checksums for verification",
1169                           },
1170                           { .ival = "meta",
1171                             .oval = VERIFY_META,
1172                             .help = "Use io information",
1173                           },
1174                           {
1175                             .ival = "null",
1176                             .oval = VERIFY_NULL,
1177                             .help = "Pretend to verify",
1178                           },
1179                 },
1180         },
1181         {
1182                 .name   = "do_verify",
1183                 .type   = FIO_OPT_BOOL,
1184                 .off1   = td_var_offset(do_verify),
1185                 .help   = "Run verification stage after write",
1186                 .def    = "1",
1187                 .parent = "verify",
1188         },
1189         {
1190                 .name   = "verifysort",
1191                 .type   = FIO_OPT_BOOL,
1192                 .off1   = td_var_offset(verifysort),
1193                 .help   = "Sort written verify blocks for read back",
1194                 .def    = "1",
1195                 .parent = "verify",
1196         },
1197         {
1198                 .name   = "verify_interval",
1199                 .type   = FIO_OPT_INT,
1200                 .off1   = td_var_offset(verify_interval),
1201                 .minval = 2 * sizeof(struct verify_header),
1202                 .help   = "Store verify buffer header every N bytes",
1203                 .parent = "verify",
1204         },
1205         {
1206                 .name   = "verify_offset",
1207                 .type   = FIO_OPT_INT,
1208                 .help   = "Offset verify header location by N bytes",
1209                 .def    = "0",
1210                 .cb     = str_verify_offset_cb,
1211                 .parent = "verify",
1212         },
1213         {
1214                 .name   = "verify_pattern",
1215                 .type   = FIO_OPT_INT,
1216                 .cb     = str_verify_pattern_cb,
1217                 .help   = "Fill pattern for IO buffers",
1218                 .parent = "verify",
1219         },
1220         {
1221                 .name   = "verify_fatal",
1222                 .type   = FIO_OPT_BOOL,
1223                 .off1   = td_var_offset(verify_fatal),
1224                 .def    = "0",
1225                 .help   = "Exit on a single verify failure, don't continue",
1226                 .parent = "verify",
1227         },
1228         {
1229                 .name   = "verify_async",
1230                 .type   = FIO_OPT_INT,
1231                 .off1   = td_var_offset(verify_async),
1232                 .def    = "0",
1233                 .help   = "Number of async verifier threads to use",
1234                 .parent = "verify",
1235         },
1236 #ifdef FIO_HAVE_CPU_AFFINITY
1237         {
1238                 .name   = "verify_async_cpus",
1239                 .type   = FIO_OPT_STR,
1240                 .cb     = str_verify_cpus_allowed_cb,
1241                 .help   = "Set CPUs allowed for async verify threads",
1242                 .parent = "verify_async",
1243         },
1244 #endif
1245         {
1246                 .name   = "write_iolog",
1247                 .type   = FIO_OPT_STR_STORE,
1248                 .off1   = td_var_offset(write_iolog_file),
1249                 .help   = "Store IO pattern to file",
1250         },
1251         {
1252                 .name   = "read_iolog",
1253                 .type   = FIO_OPT_STR_STORE,
1254                 .off1   = td_var_offset(read_iolog_file),
1255                 .help   = "Playback IO pattern from file",
1256         },
1257         {
1258                 .name   = "exec_prerun",
1259                 .type   = FIO_OPT_STR_STORE,
1260                 .off1   = td_var_offset(exec_prerun),
1261                 .help   = "Execute this file prior to running job",
1262         },
1263         {
1264                 .name   = "exec_postrun",
1265                 .type   = FIO_OPT_STR_STORE,
1266                 .off1   = td_var_offset(exec_postrun),
1267                 .help   = "Execute this file after running job",
1268         },
1269 #ifdef FIO_HAVE_IOSCHED_SWITCH
1270         {
1271                 .name   = "ioscheduler",
1272                 .type   = FIO_OPT_STR_STORE,
1273                 .off1   = td_var_offset(ioscheduler),
1274                 .help   = "Use this IO scheduler on the backing device",
1275         },
1276 #endif
1277         {
1278                 .name   = "zonesize",
1279                 .type   = FIO_OPT_STR_VAL,
1280                 .off1   = td_var_offset(zone_size),
1281                 .help   = "Give size of an IO zone",
1282                 .def    = "0",
1283         },
1284         {
1285                 .name   = "zoneskip",
1286                 .type   = FIO_OPT_STR_VAL,
1287                 .off1   = td_var_offset(zone_skip),
1288                 .help   = "Space between IO zones",
1289                 .def    = "0",
1290         },
1291         {
1292                 .name   = "lockmem",
1293                 .type   = FIO_OPT_STR_VAL,
1294                 .cb     = str_lockmem_cb,
1295                 .help   = "Lock down this amount of memory",
1296                 .def    = "0",
1297         },
1298         {
1299                 .name   = "rwmixread",
1300                 .type   = FIO_OPT_INT,
1301                 .cb     = str_rwmix_read_cb,
1302                 .maxval = 100,
1303                 .help   = "Percentage of mixed workload that is reads",
1304                 .def    = "50",
1305         },
1306         {
1307                 .name   = "rwmixwrite",
1308                 .type   = FIO_OPT_INT,
1309                 .cb     = str_rwmix_write_cb,
1310                 .maxval = 100,
1311                 .help   = "Percentage of mixed workload that is writes",
1312                 .def    = "50",
1313         },
1314         {
1315                 .name   = "rwmixcycle",
1316                 .type   = FIO_OPT_DEPRECATED,
1317         },
1318         {
1319                 .name   = "nice",
1320                 .type   = FIO_OPT_INT,
1321                 .off1   = td_var_offset(nice),
1322                 .help   = "Set job CPU nice value",
1323                 .minval = -19,
1324                 .maxval = 20,
1325                 .def    = "0",
1326         },
1327 #ifdef FIO_HAVE_IOPRIO
1328         {
1329                 .name   = "prio",
1330                 .type   = FIO_OPT_INT,
1331                 .cb     = str_prio_cb,
1332                 .help   = "Set job IO priority value",
1333                 .minval = 0,
1334                 .maxval = 7,
1335         },
1336         {
1337                 .name   = "prioclass",
1338                 .type   = FIO_OPT_INT,
1339                 .cb     = str_prioclass_cb,
1340                 .help   = "Set job IO priority class",
1341                 .minval = 0,
1342                 .maxval = 3,
1343         },
1344 #endif
1345         {
1346                 .name   = "thinktime",
1347                 .type   = FIO_OPT_INT,
1348                 .off1   = td_var_offset(thinktime),
1349                 .help   = "Idle time between IO buffers (usec)",
1350                 .def    = "0",
1351         },
1352         {
1353                 .name   = "thinktime_spin",
1354                 .type   = FIO_OPT_INT,
1355                 .off1   = td_var_offset(thinktime_spin),
1356                 .help   = "Start think time by spinning this amount (usec)",
1357                 .def    = "0",
1358                 .parent = "thinktime",
1359         },
1360         {
1361                 .name   = "thinktime_blocks",
1362                 .type   = FIO_OPT_INT,
1363                 .off1   = td_var_offset(thinktime_blocks),
1364                 .help   = "IO buffer period between 'thinktime'",
1365                 .def    = "1",
1366                 .parent = "thinktime",
1367         },
1368         {
1369                 .name   = "rate",
1370                 .type   = FIO_OPT_INT,
1371                 .off1   = td_var_offset(rate[0]),
1372                 .off2   = td_var_offset(rate[1]),
1373                 .help   = "Set bandwidth rate",
1374         },
1375         {
1376                 .name   = "ratemin",
1377                 .type   = FIO_OPT_INT,
1378                 .off1   = td_var_offset(ratemin[0]),
1379                 .off2   = td_var_offset(ratemin[1]),
1380                 .help   = "Job must meet this rate or it will be shutdown",
1381                 .parent = "rate",
1382         },
1383         {
1384                 .name   = "rate_iops",
1385                 .type   = FIO_OPT_INT,
1386                 .off1   = td_var_offset(rate_iops[0]),
1387                 .off2   = td_var_offset(rate_iops[1]),
1388                 .help   = "Limit IO used to this number of IO operations/sec",
1389         },
1390         {
1391                 .name   = "rate_iops_min",
1392                 .type   = FIO_OPT_INT,
1393                 .off1   = td_var_offset(rate_iops_min[0]),
1394                 .off2   = td_var_offset(rate_iops_min[1]),
1395                 .help   = "Job must meet this rate or it will be shutdown",
1396                 .parent = "rate_iops",
1397         },
1398         {
1399                 .name   = "ratecycle",
1400                 .type   = FIO_OPT_INT,
1401                 .off1   = td_var_offset(ratecycle),
1402                 .help   = "Window average for rate limits (msec)",
1403                 .def    = "1000",
1404                 .parent = "rate",
1405         },
1406         {
1407                 .name   = "invalidate",
1408                 .type   = FIO_OPT_BOOL,
1409                 .off1   = td_var_offset(invalidate_cache),
1410                 .help   = "Invalidate buffer/page cache prior to running job",
1411                 .def    = "1",
1412         },
1413         {
1414                 .name   = "sync",
1415                 .type   = FIO_OPT_BOOL,
1416                 .off1   = td_var_offset(sync_io),
1417                 .help   = "Use O_SYNC for buffered writes",
1418                 .def    = "0",
1419                 .parent = "buffered",
1420         },
1421         {
1422                 .name   = "bwavgtime",
1423                 .type   = FIO_OPT_INT,
1424                 .off1   = td_var_offset(bw_avg_time),
1425                 .help   = "Time window over which to calculate bandwidth"
1426                           " (msec)",
1427                 .def    = "500",
1428         },
1429         {
1430                 .name   = "create_serialize",
1431                 .type   = FIO_OPT_BOOL,
1432                 .off1   = td_var_offset(create_serialize),
1433                 .help   = "Serialize creating of job files",
1434                 .def    = "1",
1435         },
1436         {
1437                 .name   = "create_fsync",
1438                 .type   = FIO_OPT_BOOL,
1439                 .off1   = td_var_offset(create_fsync),
1440                 .help   = "Fsync file after creation",
1441                 .def    = "1",
1442         },
1443         {
1444                 .name   = "create_on_open",
1445                 .type   = FIO_OPT_BOOL,
1446                 .off1   = td_var_offset(create_on_open),
1447                 .help   = "Create files when they are opened for IO",
1448                 .def    = "0",
1449         },
1450         {
1451                 .name   = "pre_read",
1452                 .type   = FIO_OPT_BOOL,
1453                 .off1   = td_var_offset(pre_read),
1454                 .help   = "Preread files before starting official testing",
1455                 .def    = "0",
1456         },
1457         {
1458                 .name   = "cpuload",
1459                 .type   = FIO_OPT_INT,
1460                 .off1   = td_var_offset(cpuload),
1461                 .help   = "Use this percentage of CPU",
1462         },
1463         {
1464                 .name   = "cpuchunks",
1465                 .type   = FIO_OPT_INT,
1466                 .off1   = td_var_offset(cpucycle),
1467                 .help   = "Length of the CPU burn cycles (usecs)",
1468                 .def    = "50000",
1469                 .parent = "cpuload",
1470         },
1471 #ifdef FIO_HAVE_CPU_AFFINITY
1472         {
1473                 .name   = "cpumask",
1474                 .type   = FIO_OPT_INT,
1475                 .cb     = str_cpumask_cb,
1476                 .help   = "CPU affinity mask",
1477         },
1478         {
1479                 .name   = "cpus_allowed",
1480                 .type   = FIO_OPT_STR,
1481                 .cb     = str_cpus_allowed_cb,
1482                 .help   = "Set CPUs allowed",
1483         },
1484 #endif
1485         {
1486                 .name   = "end_fsync",
1487                 .type   = FIO_OPT_BOOL,
1488                 .off1   = td_var_offset(end_fsync),
1489                 .help   = "Include fsync at the end of job",
1490                 .def    = "0",
1491         },
1492         {
1493                 .name   = "fsync_on_close",
1494                 .type   = FIO_OPT_BOOL,
1495                 .off1   = td_var_offset(fsync_on_close),
1496                 .help   = "fsync files on close",
1497                 .def    = "0",
1498         },
1499         {
1500                 .name   = "unlink",
1501                 .type   = FIO_OPT_BOOL,
1502                 .off1   = td_var_offset(unlink),
1503                 .help   = "Unlink created files after job has completed",
1504                 .def    = "0",
1505         },
1506         {
1507                 .name   = "exitall",
1508                 .type   = FIO_OPT_STR_SET,
1509                 .cb     = str_exitall_cb,
1510                 .help   = "Terminate all jobs when one exits",
1511         },
1512         {
1513                 .name   = "stonewall",
1514                 .type   = FIO_OPT_STR_SET,
1515                 .off1   = td_var_offset(stonewall),
1516                 .help   = "Insert a hard barrier between this job and previous",
1517         },
1518         {
1519                 .name   = "new_group",
1520                 .type   = FIO_OPT_STR_SET,
1521                 .off1   = td_var_offset(new_group),
1522                 .help   = "Mark the start of a new group (for reporting)",
1523         },
1524         {
1525                 .name   = "thread",
1526                 .type   = FIO_OPT_STR_SET,
1527                 .off1   = td_var_offset(use_thread),
1528                 .help   = "Use threads instead of forks",
1529         },
1530         {
1531                 .name   = "write_bw_log",
1532                 .type   = FIO_OPT_STR,
1533                 .off1   = td_var_offset(write_bw_log),
1534                 .cb     = str_write_bw_log_cb,
1535                 .help   = "Write log of bandwidth during run",
1536         },
1537         {
1538                 .name   = "write_lat_log",
1539                 .type   = FIO_OPT_STR,
1540                 .off1   = td_var_offset(write_lat_log),
1541                 .cb     = str_write_lat_log_cb,
1542                 .help   = "Write log of latency during run",
1543         },
1544         {
1545                 .name   = "hugepage-size",
1546                 .type   = FIO_OPT_INT,
1547                 .off1   = td_var_offset(hugepage_size),
1548                 .help   = "When using hugepages, specify size of each page",
1549                 .def    = __stringify(FIO_HUGE_PAGE),
1550         },
1551         {
1552                 .name   = "group_reporting",
1553                 .type   = FIO_OPT_STR_SET,
1554                 .off1   = td_var_offset(group_reporting),
1555                 .help   = "Do reporting on a per-group basis",
1556         },
1557         {
1558                 .name   = "zero_buffers",
1559                 .type   = FIO_OPT_STR_SET,
1560                 .off1   = td_var_offset(zero_buffers),
1561                 .help   = "Init IO buffers to all zeroes",
1562         },
1563         {
1564                 .name   = "refill_buffers",
1565                 .type   = FIO_OPT_STR_SET,
1566                 .off1   = td_var_offset(refill_buffers),
1567                 .help   = "Refill IO buffers on every IO submit",
1568         },
1569 #ifdef FIO_HAVE_DISK_UTIL
1570         {
1571                 .name   = "disk_util",
1572                 .type   = FIO_OPT_BOOL,
1573                 .off1   = td_var_offset(do_disk_util),
1574                 .help   = "Log disk utilization statistics",
1575                 .def    = "1",
1576         },
1577 #endif
1578         {
1579                 .name   = "gtod_reduce",
1580                 .type   = FIO_OPT_BOOL,
1581                 .help   = "Greatly reduce number of gettimeofday() calls",
1582                 .cb     = str_gtod_reduce_cb,
1583                 .def    = "0",
1584         },
1585         {
1586                 .name   = "disable_clat",
1587                 .type   = FIO_OPT_BOOL,
1588                 .off1   = td_var_offset(disable_clat),
1589                 .help   = "Disable completion latency numbers",
1590                 .parent = "gtod_reduce",
1591                 .def    = "0",
1592         },
1593         {
1594                 .name   = "disable_slat",
1595                 .type   = FIO_OPT_BOOL,
1596                 .off1   = td_var_offset(disable_slat),
1597                 .help   = "Disable submissionn latency numbers",
1598                 .parent = "gtod_reduce",
1599                 .def    = "0",
1600         },
1601         {
1602                 .name   = "disable_bw_measurement",
1603                 .type   = FIO_OPT_BOOL,
1604                 .off1   = td_var_offset(disable_bw),
1605                 .help   = "Disable bandwidth logging",
1606                 .parent = "gtod_reduce",
1607                 .def    = "0",
1608         },
1609         {
1610                 .name   = "gtod_cpu",
1611                 .type   = FIO_OPT_INT,
1612                 .cb     = str_gtod_cpu_cb,
1613                 .help   = "Setup dedicated gettimeofday() thread on this CPU",
1614                 .verify = gtod_cpu_verify,
1615         },
1616         {
1617                 .name   = "continue_on_error",
1618                 .type   = FIO_OPT_BOOL,
1619                 .off1   = td_var_offset(continue_on_error),
1620                 .help   = "Continue on non-fatal errors during I/O",
1621                 .def    = "0",
1622         },
1623         {
1624                 .name = NULL,
1625         },
1626 };
1627
1628 void fio_options_dup_and_init(struct option *long_options)
1629 {
1630         struct fio_option *o;
1631         unsigned int i;
1632
1633         options_init(options);
1634
1635         i = 0;
1636         while (long_options[i].name)
1637                 i++;
1638
1639         o = &options[0];
1640         while (o->name) {
1641                 long_options[i].name = (char *) o->name;
1642                 long_options[i].val = FIO_GETOPT_JOB;
1643                 if (o->type == FIO_OPT_STR_SET)
1644                         long_options[i].has_arg = no_argument;
1645                 else
1646                         long_options[i].has_arg = required_argument;
1647
1648                 i++;
1649                 o++;
1650                 assert(i < FIO_NR_OPTIONS);
1651         }
1652 }
1653
1654 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1655 {
1656         int i, ret;
1657
1658         sort_options(opts, options, num_opts);
1659
1660         for (ret = 0, i = 0; i < num_opts; i++)
1661                 ret |= parse_option(opts[i], options, td);
1662
1663         return ret;
1664 }
1665
1666 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1667 {
1668         return parse_cmd_option(opt, val, options, td);
1669 }
1670
1671 void fio_fill_default_options(struct thread_data *td)
1672 {
1673         fill_default_options(td, options);
1674 }
1675
1676 int fio_show_option_help(const char *opt)
1677 {
1678         return show_cmd_help(options, opt);
1679 }
1680
1681 static void __options_mem(struct thread_data *td, int alloc)
1682 {
1683         struct thread_options *o = &td->o;
1684         struct fio_option *opt;
1685         char **ptr;
1686         int i;
1687
1688         for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1689                 if (opt->type != FIO_OPT_STR_STORE)
1690                         continue;
1691
1692                 ptr = (void *) o + opt->off1;
1693                 if (*ptr) {
1694                         if (alloc)
1695                                 *ptr = strdup(*ptr);
1696                         else {
1697                                 free(*ptr);
1698                                 *ptr = NULL;
1699                         }
1700                 }
1701         }
1702 }
1703
1704 /*
1705  * dupe FIO_OPT_STR_STORE options
1706  */
1707 void options_mem_dupe(struct thread_data *td)
1708 {
1709         __options_mem(td, 1);
1710 }
1711
1712 void options_mem_free(struct thread_data fio_unused *td)
1713 {
1714 #if 0
1715         __options_mem(td, 0);
1716 #endif
1717 }