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