README: update for newer client job file argument format
[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 },
10b023db
JA
965 { .ival = "readwrite",
966 .oval = TD_DDIR_RW,
967 .help = "Sequential read and write mix",
968 },
214e1eca
JA
969 { .ival = "randrw",
970 .oval = TD_DDIR_RANDRW,
971 .help = "Random read and write mix"
972 },
973 },
974 },
38dad62d
JA
975 {
976 .name = "rw_sequencer",
e8b0e958 977 .lname = "RW Sequencer",
38dad62d
JA
978 .type = FIO_OPT_STR,
979 .off1 = td_var_offset(rw_seq),
980 .help = "IO offset generator modifier",
981 .def = "sequential",
e8b0e958 982 .category = FIO_OPT_C_IO,
0626037e 983 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
984 .posval = {
985 { .ival = "sequential",
986 .oval = RW_SEQ_SEQ,
987 .help = "Generate sequential offsets",
988 },
989 { .ival = "identical",
990 .oval = RW_SEQ_IDENT,
991 .help = "Generate identical offsets",
992 },
993 },
994 },
995
214e1eca
JA
996 {
997 .name = "ioengine",
e8b0e958 998 .lname = "IO Engine",
214e1eca
JA
999 .type = FIO_OPT_STR_STORE,
1000 .off1 = td_var_offset(ioengine),
1001 .help = "IO engine to use",
58483fa4 1002 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1003 .category = FIO_OPT_C_IO,
0626037e 1004 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1005 .posval = {
1006 { .ival = "sync",
1007 .help = "Use read/write",
1008 },
a31041ea 1009 { .ival = "psync",
1010 .help = "Use pread/pwrite",
1011 },
1d2af02a 1012 { .ival = "vsync",
03e20d68 1013 .help = "Use readv/writev",
1d2af02a 1014 },
214e1eca
JA
1015#ifdef FIO_HAVE_LIBAIO
1016 { .ival = "libaio",
1017 .help = "Linux native asynchronous IO",
1018 },
1019#endif
1020#ifdef FIO_HAVE_POSIXAIO
1021 { .ival = "posixaio",
1022 .help = "POSIX asynchronous IO",
1023 },
417f0068
JA
1024#endif
1025#ifdef FIO_HAVE_SOLARISAIO
1026 { .ival = "solarisaio",
1027 .help = "Solaris native asynchronous IO",
1028 },
214e1eca 1029#endif
03e20d68
BC
1030#ifdef FIO_HAVE_WINDOWSAIO
1031 { .ival = "windowsaio",
3be80071 1032 .help = "Windows native asynchronous IO"
de890a1e 1033 },
3be80071 1034#endif
214e1eca 1035 { .ival = "mmap",
03e20d68 1036 .help = "Memory mapped IO"
214e1eca
JA
1037 },
1038#ifdef FIO_HAVE_SPLICE
1039 { .ival = "splice",
1040 .help = "splice/vmsplice based IO",
1041 },
9cce02e8
JA
1042 { .ival = "netsplice",
1043 .help = "splice/vmsplice to/from the network",
1044 },
214e1eca
JA
1045#endif
1046#ifdef FIO_HAVE_SGIO
1047 { .ival = "sg",
1048 .help = "SCSI generic v3 IO",
1049 },
1050#endif
1051 { .ival = "null",
1052 .help = "Testing engine (no data transfer)",
1053 },
1054 { .ival = "net",
1055 .help = "Network IO",
1056 },
1057#ifdef FIO_HAVE_SYSLET
1058 { .ival = "syslet-rw",
1059 .help = "syslet enabled async pread/pwrite IO",
1060 },
1061#endif
1062 { .ival = "cpuio",
03e20d68 1063 .help = "CPU cycle burner engine",
214e1eca 1064 },
b8c82a46
JA
1065#ifdef FIO_HAVE_GUASI
1066 { .ival = "guasi",
1067 .help = "GUASI IO engine",
1068 },
79a43187
JA
1069#endif
1070#ifdef FIO_HAVE_BINJECT
1071 { .ival = "binject",
1072 .help = "binject direct inject block engine",
1073 },
21b8aee8 1074#endif
1075#ifdef FIO_HAVE_RDMA
1076 { .ival = "rdma",
1077 .help = "RDMA IO engine",
1078 },
b8c82a46 1079#endif
214e1eca
JA
1080 { .ival = "external",
1081 .help = "Load external engine (append name)",
1082 },
1083 },
1084 },
1085 {
1086 .name = "iodepth",
e8b0e958 1087 .lname = "IO Depth",
214e1eca
JA
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(iodepth),
03e20d68 1090 .help = "Number of IO buffers to keep in flight",
757aff4f 1091 .minval = 1,
20eb06bd 1092 .interval = 1,
214e1eca 1093 .def = "1",
e8b0e958 1094 .category = FIO_OPT_C_IO,
0626037e 1095 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1096 },
1097 {
1098 .name = "iodepth_batch",
e8b0e958 1099 .lname = "IO Depth batch",
4950421a 1100 .alias = "iodepth_batch_submit",
214e1eca
JA
1101 .type = FIO_OPT_INT,
1102 .off1 = td_var_offset(iodepth_batch),
d65db441 1103 .help = "Number of IO buffers to submit in one go",
afdf9352 1104 .parent = "iodepth",
d71c154c 1105 .hide = 1,
a2e6f8ac 1106 .minval = 1,
20eb06bd 1107 .interval = 1,
a2e6f8ac 1108 .def = "1",
e8b0e958 1109 .category = FIO_OPT_C_IO,
0626037e 1110 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1111 },
1112 {
1113 .name = "iodepth_batch_complete",
e8b0e958 1114 .lname = "IO Depth batch complete",
4950421a
JA
1115 .type = FIO_OPT_INT,
1116 .off1 = td_var_offset(iodepth_batch_complete),
d65db441 1117 .help = "Number of IO buffers to retrieve in one go",
4950421a 1118 .parent = "iodepth",
d71c154c 1119 .hide = 1,
4950421a 1120 .minval = 0,
20eb06bd 1121 .interval = 1,
4950421a 1122 .def = "1",
e8b0e958 1123 .category = FIO_OPT_C_IO,
0626037e 1124 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1125 },
1126 {
1127 .name = "iodepth_low",
e8b0e958 1128 .lname = "IO Depth batch low",
214e1eca
JA
1129 .type = FIO_OPT_INT,
1130 .off1 = td_var_offset(iodepth_low),
1131 .help = "Low water mark for queuing depth",
afdf9352 1132 .parent = "iodepth",
d71c154c 1133 .hide = 1,
20eb06bd 1134 .interval = 1,
e8b0e958 1135 .category = FIO_OPT_C_IO,
0626037e 1136 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1137 },
1138 {
1139 .name = "size",
e8b0e958 1140 .lname = "Size",
214e1eca 1141 .type = FIO_OPT_STR_VAL,
7bb59102 1142 .cb = str_size_cb,
214e1eca 1143 .help = "Total size of device or files",
20eb06bd 1144 .interval = 1024 * 1024,
e8b0e958
JA
1145 .category = FIO_OPT_C_IO,
1146 .group = FIO_OPT_G_INVALID,
214e1eca 1147 },
aa31f1f1
SL
1148 {
1149 .name = "fill_device",
e8b0e958 1150 .lname = "Fill device",
74586c1e 1151 .alias = "fill_fs",
aa31f1f1
SL
1152 .type = FIO_OPT_BOOL,
1153 .off1 = td_var_offset(fill_device),
1154 .help = "Write until an ENOSPC error occurs",
1155 .def = "0",
e8b0e958
JA
1156 .category = FIO_OPT_C_FILE,
1157 .group = FIO_OPT_G_INVALID,
aa31f1f1 1158 },
214e1eca
JA
1159 {
1160 .name = "filesize",
e8b0e958 1161 .lname = "File size",
214e1eca
JA
1162 .type = FIO_OPT_STR_VAL,
1163 .off1 = td_var_offset(file_size_low),
1164 .off2 = td_var_offset(file_size_high),
c3edbdba 1165 .minval = 1,
214e1eca 1166 .help = "Size of individual files",
20eb06bd 1167 .interval = 1024 * 1024,
e8b0e958
JA
1168 .category = FIO_OPT_C_FILE,
1169 .group = FIO_OPT_G_INVALID,
214e1eca 1170 },
67a1000f
JA
1171 {
1172 .name = "offset",
e8b0e958 1173 .lname = "IO offset",
67a1000f
JA
1174 .alias = "fileoffset",
1175 .type = FIO_OPT_STR_VAL,
1176 .off1 = td_var_offset(start_offset),
1177 .help = "Start IO from this offset",
1178 .def = "0",
20eb06bd 1179 .interval = 1024 * 1024,
e8b0e958
JA
1180 .category = FIO_OPT_C_IO,
1181 .group = FIO_OPT_G_INVALID,
67a1000f 1182 },
2d7cd868
JA
1183 {
1184 .name = "offset_increment",
e8b0e958 1185 .lname = "IO offset increment",
2d7cd868
JA
1186 .type = FIO_OPT_STR_VAL,
1187 .off1 = td_var_offset(offset_increment),
1188 .help = "What is the increment from one offset to the next",
1189 .parent = "offset",
d71c154c 1190 .hide = 1,
2d7cd868 1191 .def = "0",
20eb06bd 1192 .interval = 1024 * 1024,
e8b0e958
JA
1193 .category = FIO_OPT_C_IO,
1194 .group = FIO_OPT_G_INVALID,
2d7cd868 1195 },
214e1eca
JA
1196 {
1197 .name = "bs",
e8b0e958 1198 .lname = "Block size",
d3aad8f2 1199 .alias = "blocksize",
e01b22b8 1200 .type = FIO_OPT_INT,
214e1eca
JA
1201 .off1 = td_var_offset(bs[DDIR_READ]),
1202 .off2 = td_var_offset(bs[DDIR_WRITE]),
c3edbdba 1203 .minval = 1,
214e1eca
JA
1204 .help = "Block size unit",
1205 .def = "4k",
67a1000f 1206 .parent = "rw",
d71c154c 1207 .hide = 1,
20eb06bd 1208 .interval = 512,
e8b0e958
JA
1209 .category = FIO_OPT_C_IO,
1210 .group = FIO_OPT_G_INVALID,
214e1eca 1211 },
2b7a01d0
JA
1212 {
1213 .name = "ba",
e8b0e958 1214 .lname = "Block size align",
2b7a01d0 1215 .alias = "blockalign",
e01b22b8 1216 .type = FIO_OPT_INT,
2b7a01d0
JA
1217 .off1 = td_var_offset(ba[DDIR_READ]),
1218 .off2 = td_var_offset(ba[DDIR_WRITE]),
1219 .minval = 1,
1220 .help = "IO block offset alignment",
1221 .parent = "rw",
d71c154c 1222 .hide = 1,
20eb06bd 1223 .interval = 512,
e8b0e958
JA
1224 .category = FIO_OPT_C_IO,
1225 .group = FIO_OPT_G_INVALID,
2b7a01d0 1226 },
214e1eca
JA
1227 {
1228 .name = "bsrange",
e8b0e958 1229 .lname = "Block size range",
d3aad8f2 1230 .alias = "blocksize_range",
214e1eca
JA
1231 .type = FIO_OPT_RANGE,
1232 .off1 = td_var_offset(min_bs[DDIR_READ]),
1233 .off2 = td_var_offset(max_bs[DDIR_READ]),
1234 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1235 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
c3edbdba 1236 .minval = 1,
214e1eca 1237 .help = "Set block size range (in more detail than bs)",
67a1000f 1238 .parent = "rw",
d71c154c 1239 .hide = 1,
20eb06bd 1240 .interval = 4096,
e8b0e958
JA
1241 .category = FIO_OPT_C_IO,
1242 .group = FIO_OPT_G_INVALID,
214e1eca 1243 },
564ca972
JA
1244 {
1245 .name = "bssplit",
e8b0e958 1246 .lname = "Block size split",
564ca972
JA
1247 .type = FIO_OPT_STR,
1248 .cb = str_bssplit_cb,
1249 .help = "Set a specific mix of block sizes",
1250 .parent = "rw",
d71c154c 1251 .hide = 1,
e8b0e958
JA
1252 .category = FIO_OPT_C_IO,
1253 .group = FIO_OPT_G_INVALID,
564ca972 1254 },
214e1eca
JA
1255 {
1256 .name = "bs_unaligned",
e8b0e958 1257 .lname = "Block size unaligned",
d3aad8f2 1258 .alias = "blocksize_unaligned",
214e1eca
JA
1259 .type = FIO_OPT_STR_SET,
1260 .off1 = td_var_offset(bs_unaligned),
1261 .help = "Don't sector align IO buffer sizes",
67a1000f 1262 .parent = "rw",
d71c154c 1263 .hide = 1,
e8b0e958
JA
1264 .category = FIO_OPT_C_IO,
1265 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1266 },
1267 {
1268 .name = "randrepeat",
e8b0e958 1269 .lname = "Random repeatable",
214e1eca
JA
1270 .type = FIO_OPT_BOOL,
1271 .off1 = td_var_offset(rand_repeatable),
1272 .help = "Use repeatable random IO pattern",
1273 .def = "1",
67a1000f 1274 .parent = "rw",
d71c154c 1275 .hide = 1,
e8b0e958 1276 .category = FIO_OPT_C_IO,
3ceb458f 1277 .group = FIO_OPT_G_RANDOM,
214e1eca 1278 },
2615cc4b
JA
1279 {
1280 .name = "use_os_rand",
e8b0e958 1281 .lname = "Use OS random",
2615cc4b
JA
1282 .type = FIO_OPT_BOOL,
1283 .off1 = td_var_offset(use_os_rand),
1284 .help = "Set to use OS random generator",
1285 .def = "0",
1286 .parent = "rw",
d71c154c 1287 .hide = 1,
e8b0e958 1288 .category = FIO_OPT_C_IO,
3ceb458f 1289 .group = FIO_OPT_G_RANDOM,
2615cc4b 1290 },
214e1eca
JA
1291 {
1292 .name = "norandommap",
e8b0e958 1293 .lname = "No randommap",
214e1eca
JA
1294 .type = FIO_OPT_STR_SET,
1295 .off1 = td_var_offset(norandommap),
1296 .help = "Accept potential duplicate random blocks",
67a1000f 1297 .parent = "rw",
d71c154c 1298 .hide = 1,
b2452a43 1299 .hide_on_set = 1,
e8b0e958 1300 .category = FIO_OPT_C_IO,
3ceb458f 1301 .group = FIO_OPT_G_RANDOM,
214e1eca 1302 },
2b386d25
JA
1303 {
1304 .name = "softrandommap",
e8b0e958 1305 .lname = "Soft randommap",
2b386d25
JA
1306 .type = FIO_OPT_BOOL,
1307 .off1 = td_var_offset(softrandommap),
f66ab3c8 1308 .help = "Set norandommap if randommap allocation fails",
2b386d25 1309 .parent = "norandommap",
d71c154c 1310 .hide = 1,
2b386d25 1311 .def = "0",
e8b0e958 1312 .category = FIO_OPT_C_IO,
3ceb458f 1313 .group = FIO_OPT_G_RANDOM,
2b386d25 1314 },
214e1eca
JA
1315 {
1316 .name = "nrfiles",
e8b0e958 1317 .lname = "Number of files",
d7c8be03 1318 .alias = "nr_files",
214e1eca
JA
1319 .type = FIO_OPT_INT,
1320 .off1 = td_var_offset(nr_files),
1321 .help = "Split job workload between this number of files",
1322 .def = "1",
20eb06bd 1323 .interval = 1,
e8b0e958
JA
1324 .category = FIO_OPT_C_FILE,
1325 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1326 },
1327 {
1328 .name = "openfiles",
e8b0e958 1329 .lname = "Number of open files",
214e1eca
JA
1330 .type = FIO_OPT_INT,
1331 .off1 = td_var_offset(open_files),
1332 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1333 .category = FIO_OPT_C_FILE,
1334 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1335 },
1336 {
1337 .name = "file_service_type",
e8b0e958 1338 .lname = "File service type",
214e1eca
JA
1339 .type = FIO_OPT_STR,
1340 .cb = str_fst_cb,
1341 .off1 = td_var_offset(file_service_type),
1342 .help = "How to select which file to service next",
1343 .def = "roundrobin",
e8b0e958
JA
1344 .category = FIO_OPT_C_FILE,
1345 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1346 .posval = {
1347 { .ival = "random",
1348 .oval = FIO_FSERVICE_RANDOM,
1349 .help = "Choose a file at random",
1350 },
1351 { .ival = "roundrobin",
1352 .oval = FIO_FSERVICE_RR,
1353 .help = "Round robin select files",
1354 },
a086c257
JA
1355 { .ival = "sequential",
1356 .oval = FIO_FSERVICE_SEQ,
1357 .help = "Finish one file before moving to the next",
1358 },
214e1eca 1359 },
67a1000f 1360 .parent = "nrfiles",
d71c154c 1361 .hide = 1,
67a1000f 1362 },
7bc8c2cf
JA
1363#ifdef FIO_HAVE_FALLOCATE
1364 {
1365 .name = "fallocate",
e8b0e958 1366 .lname = "Fallocate",
a596f047
EG
1367 .type = FIO_OPT_STR,
1368 .off1 = td_var_offset(fallocate_mode),
1369 .help = "Whether pre-allocation is performed when laying out files",
1370 .def = "posix",
e8b0e958
JA
1371 .category = FIO_OPT_C_FILE,
1372 .group = FIO_OPT_G_INVALID,
a596f047
EG
1373 .posval = {
1374 { .ival = "none",
1375 .oval = FIO_FALLOCATE_NONE,
1376 .help = "Do not pre-allocate space",
1377 },
1378 { .ival = "posix",
1379 .oval = FIO_FALLOCATE_POSIX,
1380 .help = "Use posix_fallocate()",
1381 },
1382#ifdef FIO_HAVE_LINUX_FALLOCATE
1383 { .ival = "keep",
1384 .oval = FIO_FALLOCATE_KEEP_SIZE,
1385 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1386 },
7bc8c2cf 1387#endif
a596f047
EG
1388 /* Compatibility with former boolean values */
1389 { .ival = "0",
1390 .oval = FIO_FALLOCATE_NONE,
1391 .help = "Alias for 'none'",
1392 },
1393 { .ival = "1",
1394 .oval = FIO_FALLOCATE_POSIX,
1395 .help = "Alias for 'posix'",
1396 },
1397 },
1398 },
1399#endif /* FIO_HAVE_FALLOCATE */
67a1000f
JA
1400 {
1401 .name = "fadvise_hint",
e8b0e958 1402 .lname = "Fadvise hint",
67a1000f
JA
1403 .type = FIO_OPT_BOOL,
1404 .off1 = td_var_offset(fadvise_hint),
1405 .help = "Use fadvise() to advise the kernel on IO pattern",
1406 .def = "1",
e8b0e958
JA
1407 .category = FIO_OPT_C_FILE,
1408 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1409 },
1410 {
1411 .name = "fsync",
e8b0e958 1412 .lname = "Fsync",
214e1eca
JA
1413 .type = FIO_OPT_INT,
1414 .off1 = td_var_offset(fsync_blocks),
1415 .help = "Issue fsync for writes every given number of blocks",
1416 .def = "0",
20eb06bd 1417 .interval = 1,
e8b0e958
JA
1418 .category = FIO_OPT_C_FILE,
1419 .group = FIO_OPT_G_INVALID,
214e1eca 1420 },
5f9099ea
JA
1421 {
1422 .name = "fdatasync",
e8b0e958 1423 .lname = "Fdatasync",
5f9099ea
JA
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(fdatasync_blocks),
1426 .help = "Issue fdatasync for writes every given number of blocks",
1427 .def = "0",
20eb06bd 1428 .interval = 1,
e8b0e958
JA
1429 .category = FIO_OPT_C_FILE,
1430 .group = FIO_OPT_G_INVALID,
5f9099ea 1431 },
1ef2b6be
JA
1432 {
1433 .name = "write_barrier",
e8b0e958 1434 .lname = "Write barrier",
1ef2b6be
JA
1435 .type = FIO_OPT_INT,
1436 .off1 = td_var_offset(barrier_blocks),
1437 .help = "Make every Nth write a barrier write",
1438 .def = "0",
20eb06bd 1439 .interval = 1,
e8b0e958
JA
1440 .category = FIO_OPT_C_IO,
1441 .group = FIO_OPT_G_INVALID,
1ef2b6be 1442 },
44f29692
JA
1443#ifdef FIO_HAVE_SYNC_FILE_RANGE
1444 {
1445 .name = "sync_file_range",
e8b0e958 1446 .lname = "Sync file range",
44f29692
JA
1447 .posval = {
1448 { .ival = "wait_before",
1449 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1450 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
3843deb3 1451 .or = 1,
44f29692
JA
1452 },
1453 { .ival = "write",
1454 .oval = SYNC_FILE_RANGE_WRITE,
1455 .help = "SYNC_FILE_RANGE_WRITE",
3843deb3 1456 .or = 1,
44f29692
JA
1457 },
1458 {
1459 .ival = "wait_after",
1460 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1461 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
3843deb3 1462 .or = 1,
44f29692
JA
1463 },
1464 },
3843deb3 1465 .type = FIO_OPT_STR_MULTI,
44f29692
JA
1466 .cb = str_sfr_cb,
1467 .off1 = td_var_offset(sync_file_range),
1468 .help = "Use sync_file_range()",
e8b0e958
JA
1469 .category = FIO_OPT_C_FILE,
1470 .group = FIO_OPT_G_INVALID,
44f29692
JA
1471 },
1472#endif
214e1eca
JA
1473 {
1474 .name = "direct",
e8b0e958 1475 .lname = "Direct I/O",
214e1eca
JA
1476 .type = FIO_OPT_BOOL,
1477 .off1 = td_var_offset(odirect),
1478 .help = "Use O_DIRECT IO (negates buffered)",
1479 .def = "0",
a01a1bc5 1480 .inverse = "buffered",
e8b0e958 1481 .category = FIO_OPT_C_IO,
3ceb458f 1482 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
1483 },
1484 {
1485 .name = "buffered",
e8b0e958 1486 .lname = "Buffered I/O",
214e1eca
JA
1487 .type = FIO_OPT_BOOL,
1488 .off1 = td_var_offset(odirect),
1489 .neg = 1,
1490 .help = "Use buffered IO (negates direct)",
1491 .def = "1",
a01a1bc5 1492 .inverse = "direct",
e8b0e958 1493 .category = FIO_OPT_C_IO,
3ceb458f 1494 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
1495 },
1496 {
1497 .name = "overwrite",
e8b0e958 1498 .lname = "Overwrite",
214e1eca
JA
1499 .type = FIO_OPT_BOOL,
1500 .off1 = td_var_offset(overwrite),
1501 .help = "When writing, set whether to overwrite current data",
1502 .def = "0",
e8b0e958
JA
1503 .category = FIO_OPT_C_FILE,
1504 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1505 },
1506 {
1507 .name = "loops",
e8b0e958 1508 .lname = "Loops",
214e1eca
JA
1509 .type = FIO_OPT_INT,
1510 .off1 = td_var_offset(loops),
1511 .help = "Number of times to run the job",
1512 .def = "1",
20eb06bd 1513 .interval = 1,
e8b0e958 1514 .category = FIO_OPT_C_GENERAL,
a1f6afec 1515 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1516 },
1517 {
1518 .name = "numjobs",
e8b0e958 1519 .lname = "Number of jobs",
214e1eca
JA
1520 .type = FIO_OPT_INT,
1521 .off1 = td_var_offset(numjobs),
1522 .help = "Duplicate this job this many times",
1523 .def = "1",
20eb06bd 1524 .interval = 1,
e8b0e958 1525 .category = FIO_OPT_C_GENERAL,
a1f6afec 1526 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1527 },
1528 {
1529 .name = "startdelay",
e8b0e958 1530 .lname = "Start delay",
a5737c93 1531 .type = FIO_OPT_STR_VAL_TIME,
214e1eca
JA
1532 .off1 = td_var_offset(start_delay),
1533 .help = "Only start job when this period has passed",
1534 .def = "0",
e8b0e958 1535 .category = FIO_OPT_C_GENERAL,
a1f6afec 1536 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1537 },
1538 {
1539 .name = "runtime",
e8b0e958 1540 .lname = "Runtime",
214e1eca
JA
1541 .alias = "timeout",
1542 .type = FIO_OPT_STR_VAL_TIME,
1543 .off1 = td_var_offset(timeout),
1544 .help = "Stop workload when this amount of time has passed",
1545 .def = "0",
e8b0e958 1546 .category = FIO_OPT_C_GENERAL,
a1f6afec 1547 .group = FIO_OPT_G_RUNTIME,
214e1eca 1548 },
cf4464ca
JA
1549 {
1550 .name = "time_based",
e8b0e958 1551 .lname = "Time based",
cf4464ca
JA
1552 .type = FIO_OPT_STR_SET,
1553 .off1 = td_var_offset(time_based),
1554 .help = "Keep running until runtime/timeout is met",
e8b0e958 1555 .category = FIO_OPT_C_GENERAL,
a1f6afec 1556 .group = FIO_OPT_G_RUNTIME,
cf4464ca 1557 },
721938ae
JA
1558 {
1559 .name = "ramp_time",
e8b0e958 1560 .lname = "Ramp time",
721938ae
JA
1561 .type = FIO_OPT_STR_VAL_TIME,
1562 .off1 = td_var_offset(ramp_time),
1563 .help = "Ramp up time before measuring performance",
e8b0e958 1564 .category = FIO_OPT_C_GENERAL,
a1f6afec 1565 .group = FIO_OPT_G_RUNTIME,
721938ae 1566 },
c223da83
JA
1567 {
1568 .name = "clocksource",
e8b0e958 1569 .lname = "Clock source",
c223da83
JA
1570 .type = FIO_OPT_STR,
1571 .cb = fio_clock_source_cb,
1572 .off1 = td_var_offset(clocksource),
1573 .help = "What type of timing source to use",
e8b0e958 1574 .category = FIO_OPT_C_GENERAL,
10860056 1575 .group = FIO_OPT_G_CLOCK,
c223da83
JA
1576 .posval = {
1577 { .ival = "gettimeofday",
1578 .oval = CS_GTOD,
1579 .help = "Use gettimeofday(2) for timing",
1580 },
1581 { .ival = "clock_gettime",
1582 .oval = CS_CGETTIME,
1583 .help = "Use clock_gettime(2) for timing",
1584 },
1585#ifdef ARCH_HAVE_CPU_CLOCK
1586 { .ival = "cpu",
1587 .oval = CS_CPUCLOCK,
1588 .help = "Use CPU private clock",
1589 },
1590#endif
1591 },
1592 },
214e1eca
JA
1593 {
1594 .name = "mem",
d3aad8f2 1595 .alias = "iomem",
e8b0e958 1596 .lname = "I/O Memory",
214e1eca
JA
1597 .type = FIO_OPT_STR,
1598 .cb = str_mem_cb,
1599 .off1 = td_var_offset(mem_type),
1600 .help = "Backing type for IO buffers",
1601 .def = "malloc",
e8b0e958
JA
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1604 .posval = {
1605 { .ival = "malloc",
1606 .oval = MEM_MALLOC,
1607 .help = "Use malloc(3) for IO buffers",
1608 },
37c8cdfe
JA
1609 { .ival = "shm",
1610 .oval = MEM_SHM,
1611 .help = "Use shared memory segments for IO buffers",
1612 },
214e1eca
JA
1613#ifdef FIO_HAVE_HUGETLB
1614 { .ival = "shmhuge",
1615 .oval = MEM_SHMHUGE,
1616 .help = "Like shm, but use huge pages",
1617 },
b370e46a 1618#endif
37c8cdfe
JA
1619 { .ival = "mmap",
1620 .oval = MEM_MMAP,
1621 .help = "Use mmap(2) (file or anon) for IO buffers",
1622 },
214e1eca
JA
1623#ifdef FIO_HAVE_HUGETLB
1624 { .ival = "mmaphuge",
1625 .oval = MEM_MMAPHUGE,
1626 .help = "Like mmap, but use huge pages",
1627 },
1628#endif
1629 },
1630 },
d529ee19
JA
1631 {
1632 .name = "iomem_align",
1633 .alias = "mem_align",
e8b0e958 1634 .lname = "I/O memory alignment",
d529ee19
JA
1635 .type = FIO_OPT_INT,
1636 .off1 = td_var_offset(mem_align),
1637 .minval = 0,
1638 .help = "IO memory buffer offset alignment",
1639 .def = "0",
1640 .parent = "iomem",
d71c154c 1641 .hide = 1,
e8b0e958
JA
1642 .category = FIO_OPT_C_IO,
1643 .group = FIO_OPT_G_INVALID,
d529ee19 1644 },
214e1eca
JA
1645 {
1646 .name = "verify",
e8b0e958 1647 .lname = "Verify",
214e1eca
JA
1648 .type = FIO_OPT_STR,
1649 .off1 = td_var_offset(verify),
1650 .help = "Verify data written",
1651 .def = "0",
e8b0e958 1652 .category = FIO_OPT_C_IO,
3ceb458f 1653 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
1654 .posval = {
1655 { .ival = "0",
1656 .oval = VERIFY_NONE,
1657 .help = "Don't do IO verification",
1658 },
fcca4b58
JA
1659 { .ival = "md5",
1660 .oval = VERIFY_MD5,
1661 .help = "Use md5 checksums for verification",
1662 },
d77a7af3
JA
1663 { .ival = "crc64",
1664 .oval = VERIFY_CRC64,
1665 .help = "Use crc64 checksums for verification",
1666 },
214e1eca
JA
1667 { .ival = "crc32",
1668 .oval = VERIFY_CRC32,
1669 .help = "Use crc32 checksums for verification",
1670 },
af497e6a 1671 { .ival = "crc32c-intel",
e3aaafc4
JA
1672 .oval = VERIFY_CRC32C,
1673 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 1674 },
bac39e0e
JA
1675 { .ival = "crc32c",
1676 .oval = VERIFY_CRC32C,
e3aaafc4 1677 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 1678 },
969f7ed3
JA
1679 { .ival = "crc16",
1680 .oval = VERIFY_CRC16,
1681 .help = "Use crc16 checksums for verification",
1682 },
1e154bdb
JA
1683 { .ival = "crc7",
1684 .oval = VERIFY_CRC7,
1685 .help = "Use crc7 checksums for verification",
1686 },
7c353ceb
JA
1687 { .ival = "sha1",
1688 .oval = VERIFY_SHA1,
1689 .help = "Use sha1 checksums for verification",
1690 },
cd14cc10
JA
1691 { .ival = "sha256",
1692 .oval = VERIFY_SHA256,
1693 .help = "Use sha256 checksums for verification",
1694 },
1695 { .ival = "sha512",
1696 .oval = VERIFY_SHA512,
1697 .help = "Use sha512 checksums for verification",
1698 },
7437ee87
SL
1699 { .ival = "meta",
1700 .oval = VERIFY_META,
1701 .help = "Use io information",
1702 },
36690c9b
JA
1703 {
1704 .ival = "null",
1705 .oval = VERIFY_NULL,
1706 .help = "Pretend to verify",
1707 },
214e1eca
JA
1708 },
1709 },
005c565a
JA
1710 {
1711 .name = "do_verify",
e8b0e958 1712 .lname = "Perform verify step",
68e1f29a 1713 .type = FIO_OPT_BOOL,
005c565a
JA
1714 .off1 = td_var_offset(do_verify),
1715 .help = "Run verification stage after write",
1716 .def = "1",
1717 .parent = "verify",
d71c154c 1718 .hide = 1,
e8b0e958
JA
1719 .category = FIO_OPT_C_IO,
1720 .group = FIO_OPT_G_VERIFY,
005c565a 1721 },
160b966d
JA
1722 {
1723 .name = "verifysort",
e8b0e958 1724 .lname = "Verify sort",
160b966d
JA
1725 .type = FIO_OPT_BOOL,
1726 .off1 = td_var_offset(verifysort),
1727 .help = "Sort written verify blocks for read back",
1728 .def = "1",
c83f2df1 1729 .parent = "verify",
d71c154c 1730 .hide = 1,
e8b0e958
JA
1731 .category = FIO_OPT_C_IO,
1732 .group = FIO_OPT_G_VERIFY,
160b966d 1733 },
3f9f4e26 1734 {
a59e170d 1735 .name = "verify_interval",
e8b0e958 1736 .lname = "Verify interval",
e01b22b8 1737 .type = FIO_OPT_INT,
a59e170d 1738 .off1 = td_var_offset(verify_interval),
819a9680 1739 .minval = 2 * sizeof(struct verify_header),
a59e170d 1740 .help = "Store verify buffer header every N bytes",
afdf9352 1741 .parent = "verify",
d71c154c 1742 .hide = 1,
20eb06bd 1743 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
1744 .category = FIO_OPT_C_IO,
1745 .group = FIO_OPT_G_VERIFY,
3f9f4e26 1746 },
546a9142 1747 {
a59e170d 1748 .name = "verify_offset",
e8b0e958 1749 .lname = "Verify offset",
e01b22b8 1750 .type = FIO_OPT_INT,
a59e170d 1751 .help = "Offset verify header location by N bytes",
203160d5
JA
1752 .off1 = td_var_offset(verify_offset),
1753 .minval = sizeof(struct verify_header),
afdf9352 1754 .parent = "verify",
d71c154c 1755 .hide = 1,
e8b0e958
JA
1756 .category = FIO_OPT_C_IO,
1757 .group = FIO_OPT_G_VERIFY,
546a9142 1758 },
e28218f3
SL
1759 {
1760 .name = "verify_pattern",
e8b0e958 1761 .lname = "Verify pattern",
0e92f873 1762 .type = FIO_OPT_STR,
e28218f3
SL
1763 .cb = str_verify_pattern_cb,
1764 .help = "Fill pattern for IO buffers",
1765 .parent = "verify",
d71c154c 1766 .hide = 1,
e8b0e958
JA
1767 .category = FIO_OPT_C_IO,
1768 .group = FIO_OPT_G_VERIFY,
e28218f3 1769 },
a12a3b4d
JA
1770 {
1771 .name = "verify_fatal",
e8b0e958 1772 .lname = "Verify fatal",
68e1f29a 1773 .type = FIO_OPT_BOOL,
a12a3b4d
JA
1774 .off1 = td_var_offset(verify_fatal),
1775 .def = "0",
1776 .help = "Exit on a single verify failure, don't continue",
1777 .parent = "verify",
d71c154c 1778 .hide = 1,
e8b0e958
JA
1779 .category = FIO_OPT_C_IO,
1780 .group = FIO_OPT_G_VERIFY,
a12a3b4d 1781 },
b463e936
JA
1782 {
1783 .name = "verify_dump",
e8b0e958 1784 .lname = "Verify dump",
b463e936
JA
1785 .type = FIO_OPT_BOOL,
1786 .off1 = td_var_offset(verify_dump),
ef71e317 1787 .def = "0",
b463e936
JA
1788 .help = "Dump contents of good and bad blocks on failure",
1789 .parent = "verify",
d71c154c 1790 .hide = 1,
e8b0e958
JA
1791 .category = FIO_OPT_C_IO,
1792 .group = FIO_OPT_G_VERIFY,
b463e936 1793 },
e8462bd8
JA
1794 {
1795 .name = "verify_async",
e8b0e958 1796 .lname = "Verify asynchronously",
e8462bd8
JA
1797 .type = FIO_OPT_INT,
1798 .off1 = td_var_offset(verify_async),
1799 .def = "0",
1800 .help = "Number of async verifier threads to use",
1801 .parent = "verify",
d71c154c 1802 .hide = 1,
e8b0e958
JA
1803 .category = FIO_OPT_C_IO,
1804 .group = FIO_OPT_G_VERIFY,
e8462bd8 1805 },
9e144189
JA
1806 {
1807 .name = "verify_backlog",
e8b0e958 1808 .lname = "Verify backlog",
9e144189
JA
1809 .type = FIO_OPT_STR_VAL,
1810 .off1 = td_var_offset(verify_backlog),
1811 .help = "Verify after this number of blocks are written",
1812 .parent = "verify",
d71c154c 1813 .hide = 1,
e8b0e958
JA
1814 .category = FIO_OPT_C_IO,
1815 .group = FIO_OPT_G_VERIFY,
9e144189
JA
1816 },
1817 {
1818 .name = "verify_backlog_batch",
e8b0e958 1819 .lname = "Verify backlog batch",
9e144189
JA
1820 .type = FIO_OPT_INT,
1821 .off1 = td_var_offset(verify_batch),
1822 .help = "Verify this number of IO blocks",
0d29de83 1823 .parent = "verify",
d71c154c 1824 .hide = 1,
e8b0e958
JA
1825 .category = FIO_OPT_C_IO,
1826 .group = FIO_OPT_G_VERIFY,
9e144189 1827 },
e8462bd8
JA
1828#ifdef FIO_HAVE_CPU_AFFINITY
1829 {
1830 .name = "verify_async_cpus",
e8b0e958 1831 .lname = "Async verify CPUs",
e8462bd8
JA
1832 .type = FIO_OPT_STR,
1833 .cb = str_verify_cpus_allowed_cb,
1834 .help = "Set CPUs allowed for async verify threads",
1835 .parent = "verify_async",
d71c154c 1836 .hide = 1,
e8b0e958
JA
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_VERIFY,
e8462bd8 1839 },
0d29de83
JA
1840#endif
1841#ifdef FIO_HAVE_TRIM
1842 {
1843 .name = "trim_percentage",
e8b0e958 1844 .lname = "Trim percentage",
0d29de83 1845 .type = FIO_OPT_INT,
203160d5 1846 .off1 = td_var_offset(trim_percentage),
20eb06bd 1847 .minval = 0,
0d29de83
JA
1848 .maxval = 100,
1849 .help = "Number of verify blocks to discard/trim",
1850 .parent = "verify",
1851 .def = "0",
20eb06bd 1852 .interval = 1,
d71c154c 1853 .hide = 1,
e8b0e958
JA
1854 .category = FIO_OPT_C_IO,
1855 .group = FIO_OPT_G_TRIM,
0d29de83
JA
1856 },
1857 {
1858 .name = "trim_verify_zero",
e8b0e958 1859 .lname = "Verify trim zero",
20eb06bd 1860 .type = FIO_OPT_BOOL,
0d29de83
JA
1861 .help = "Verify that trim/discarded blocks are returned as zeroes",
1862 .off1 = td_var_offset(trim_zero),
1863 .parent = "trim_percentage",
d71c154c 1864 .hide = 1,
0d29de83 1865 .def = "1",
e8b0e958
JA
1866 .category = FIO_OPT_C_IO,
1867 .group = FIO_OPT_G_TRIM,
0d29de83
JA
1868 },
1869 {
1870 .name = "trim_backlog",
e8b0e958 1871 .lname = "Trim backlog",
0d29de83
JA
1872 .type = FIO_OPT_STR_VAL,
1873 .off1 = td_var_offset(trim_backlog),
1874 .help = "Trim after this number of blocks are written",
1875 .parent = "trim_percentage",
d71c154c 1876 .hide = 1,
20eb06bd 1877 .interval = 1,
e8b0e958
JA
1878 .category = FIO_OPT_C_IO,
1879 .group = FIO_OPT_G_TRIM,
0d29de83
JA
1880 },
1881 {
1882 .name = "trim_backlog_batch",
e8b0e958 1883 .lname = "Trim backlog batch",
0d29de83
JA
1884 .type = FIO_OPT_INT,
1885 .off1 = td_var_offset(trim_batch),
1886 .help = "Trim this number of IO blocks",
1887 .parent = "trim_percentage",
d71c154c 1888 .hide = 1,
20eb06bd 1889 .interval = 1,
e8b0e958
JA
1890 .category = FIO_OPT_C_IO,
1891 .group = FIO_OPT_G_TRIM,
0d29de83 1892 },
e8462bd8 1893#endif
214e1eca
JA
1894 {
1895 .name = "write_iolog",
e8b0e958 1896 .lname = "Write I/O log",
214e1eca
JA
1897 .type = FIO_OPT_STR_STORE,
1898 .off1 = td_var_offset(write_iolog_file),
1899 .help = "Store IO pattern to file",
e8b0e958
JA
1900 .category = FIO_OPT_C_IO,
1901 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
1902 },
1903 {
1904 .name = "read_iolog",
e8b0e958 1905 .lname = "Read I/O log",
214e1eca
JA
1906 .type = FIO_OPT_STR_STORE,
1907 .off1 = td_var_offset(read_iolog_file),
1908 .help = "Playback IO pattern from file",
e8b0e958
JA
1909 .category = FIO_OPT_C_IO,
1910 .group = FIO_OPT_G_IOLOG,
214e1eca 1911 },
64bbb865
DN
1912 {
1913 .name = "replay_no_stall",
e8b0e958 1914 .lname = "Don't stall on replay",
20eb06bd 1915 .type = FIO_OPT_BOOL,
64bbb865
DN
1916 .off1 = td_var_offset(no_stall),
1917 .def = "0",
87e7a972 1918 .parent = "read_iolog",
d71c154c 1919 .hide = 1,
64bbb865 1920 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
1921 .category = FIO_OPT_C_IO,
1922 .group = FIO_OPT_G_IOLOG,
64bbb865 1923 },
d1c46c04
DN
1924 {
1925 .name = "replay_redirect",
e8b0e958 1926 .lname = "Redirect device for replay",
d1c46c04
DN
1927 .type = FIO_OPT_STR_STORE,
1928 .off1 = td_var_offset(replay_redirect),
1929 .parent = "read_iolog",
d71c154c 1930 .hide = 1,
d1c46c04 1931 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
1932 .category = FIO_OPT_C_IO,
1933 .group = FIO_OPT_G_IOLOG,
d1c46c04 1934 },
214e1eca
JA
1935 {
1936 .name = "exec_prerun",
e8b0e958 1937 .lname = "Pre-execute runnable",
214e1eca
JA
1938 .type = FIO_OPT_STR_STORE,
1939 .off1 = td_var_offset(exec_prerun),
1940 .help = "Execute this file prior to running job",
e8b0e958
JA
1941 .category = FIO_OPT_C_GENERAL,
1942 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1943 },
1944 {
1945 .name = "exec_postrun",
e8b0e958 1946 .lname = "Post-execute runnable",
214e1eca
JA
1947 .type = FIO_OPT_STR_STORE,
1948 .off1 = td_var_offset(exec_postrun),
1949 .help = "Execute this file after running job",
e8b0e958
JA
1950 .category = FIO_OPT_C_GENERAL,
1951 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1952 },
1953#ifdef FIO_HAVE_IOSCHED_SWITCH
1954 {
1955 .name = "ioscheduler",
e8b0e958 1956 .lname = "I/O scheduler",
214e1eca
JA
1957 .type = FIO_OPT_STR_STORE,
1958 .off1 = td_var_offset(ioscheduler),
1959 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
1960 .category = FIO_OPT_C_FILE,
1961 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1962 },
1963#endif
1964 {
1965 .name = "zonesize",
e8b0e958 1966 .lname = "Zone size",
214e1eca
JA
1967 .type = FIO_OPT_STR_VAL,
1968 .off1 = td_var_offset(zone_size),
ed335855
SN
1969 .help = "Amount of data to read per zone",
1970 .def = "0",
20eb06bd 1971 .interval = 1024 * 1024,
e8b0e958
JA
1972 .category = FIO_OPT_C_IO,
1973 .group = FIO_OPT_G_ZONE,
ed335855
SN
1974 },
1975 {
1976 .name = "zonerange",
e8b0e958 1977 .lname = "Zone range",
ed335855
SN
1978 .type = FIO_OPT_STR_VAL,
1979 .off1 = td_var_offset(zone_range),
214e1eca
JA
1980 .help = "Give size of an IO zone",
1981 .def = "0",
20eb06bd 1982 .interval = 1024 * 1024,
e8b0e958
JA
1983 .category = FIO_OPT_C_IO,
1984 .group = FIO_OPT_G_ZONE,
214e1eca
JA
1985 },
1986 {
1987 .name = "zoneskip",
e8b0e958 1988 .lname = "Zone skip",
214e1eca
JA
1989 .type = FIO_OPT_STR_VAL,
1990 .off1 = td_var_offset(zone_skip),
1991 .help = "Space between IO zones",
1992 .def = "0",
20eb06bd 1993 .interval = 1024 * 1024,
e8b0e958
JA
1994 .category = FIO_OPT_C_IO,
1995 .group = FIO_OPT_G_ZONE,
214e1eca
JA
1996 },
1997 {
1998 .name = "lockmem",
e8b0e958 1999 .lname = "Lock memory",
214e1eca 2000 .type = FIO_OPT_STR_VAL,
1b79a070 2001 .off1 = td_var_offset(lockmem),
214e1eca
JA
2002 .help = "Lock down this amount of memory",
2003 .def = "0",
20eb06bd 2004 .interval = 1024 * 1024,
e8b0e958
JA
2005 .category = FIO_OPT_C_GENERAL,
2006 .group = FIO_OPT_G_INVALID,
214e1eca 2007 },
214e1eca
JA
2008 {
2009 .name = "rwmixread",
e8b0e958 2010 .lname = "Read/write mix read",
214e1eca 2011 .type = FIO_OPT_INT,
cb499fc4 2012 .cb = str_rwmix_read_cb,
214e1eca
JA
2013 .maxval = 100,
2014 .help = "Percentage of mixed workload that is reads",
2015 .def = "50",
20eb06bd 2016 .interval = 5,
90265353 2017 .inverse = "rwmixwrite",
e8b0e958
JA
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2020 },
2021 {
2022 .name = "rwmixwrite",
e8b0e958 2023 .lname = "Read/write mix write",
214e1eca 2024 .type = FIO_OPT_INT,
cb499fc4 2025 .cb = str_rwmix_write_cb,
214e1eca
JA
2026 .maxval = 100,
2027 .help = "Percentage of mixed workload that is writes",
2028 .def = "50",
20eb06bd 2029 .interval = 5,
90265353 2030 .inverse = "rwmixread",
e8b0e958
JA
2031 .category = FIO_OPT_C_IO,
2032 .group = FIO_OPT_G_RWMIX,
214e1eca 2033 },
afdf9352
JA
2034 {
2035 .name = "rwmixcycle",
e8b0e958 2036 .lname = "Read/write mix cycle",
15ca150e 2037 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2038 .category = FIO_OPT_C_IO,
2039 .group = FIO_OPT_G_RWMIX,
afdf9352 2040 },
214e1eca
JA
2041 {
2042 .name = "nice",
e8b0e958 2043 .lname = "Nice",
214e1eca
JA
2044 .type = FIO_OPT_INT,
2045 .off1 = td_var_offset(nice),
2046 .help = "Set job CPU nice value",
2047 .minval = -19,
2048 .maxval = 20,
2049 .def = "0",
20eb06bd 2050 .interval = 1,
e8b0e958 2051 .category = FIO_OPT_C_GENERAL,
10860056 2052 .group = FIO_OPT_G_CRED,
214e1eca
JA
2053 },
2054#ifdef FIO_HAVE_IOPRIO
2055 {
2056 .name = "prio",
e8b0e958 2057 .lname = "I/O nice priority",
214e1eca 2058 .type = FIO_OPT_INT,
28727df7 2059 .off1 = td_var_offset(ioprio),
214e1eca
JA
2060 .help = "Set job IO priority value",
2061 .minval = 0,
2062 .maxval = 7,
20eb06bd 2063 .interval = 1,
e8b0e958 2064 .category = FIO_OPT_C_GENERAL,
10860056 2065 .group = FIO_OPT_G_CRED,
214e1eca
JA
2066 },
2067 {
2068 .name = "prioclass",
e8b0e958 2069 .lname = "I/O nice priority class",
214e1eca 2070 .type = FIO_OPT_INT,
28727df7 2071 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2072 .help = "Set job IO priority class",
2073 .minval = 0,
2074 .maxval = 3,
20eb06bd 2075 .interval = 1,
e8b0e958 2076 .category = FIO_OPT_C_GENERAL,
10860056 2077 .group = FIO_OPT_G_CRED,
214e1eca
JA
2078 },
2079#endif
2080 {
2081 .name = "thinktime",
e8b0e958 2082 .lname = "Thinktime",
214e1eca
JA
2083 .type = FIO_OPT_INT,
2084 .off1 = td_var_offset(thinktime),
2085 .help = "Idle time between IO buffers (usec)",
2086 .def = "0",
e8b0e958 2087 .category = FIO_OPT_C_IO,
3ceb458f 2088 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2089 },
2090 {
2091 .name = "thinktime_spin",
e8b0e958 2092 .lname = "Thinktime spin",
214e1eca
JA
2093 .type = FIO_OPT_INT,
2094 .off1 = td_var_offset(thinktime_spin),
2095 .help = "Start think time by spinning this amount (usec)",
2096 .def = "0",
afdf9352 2097 .parent = "thinktime",
d71c154c 2098 .hide = 1,
e8b0e958 2099 .category = FIO_OPT_C_IO,
3ceb458f 2100 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2101 },
2102 {
2103 .name = "thinktime_blocks",
e8b0e958 2104 .lname = "Thinktime blocks",
214e1eca
JA
2105 .type = FIO_OPT_INT,
2106 .off1 = td_var_offset(thinktime_blocks),
2107 .help = "IO buffer period between 'thinktime'",
2108 .def = "1",
afdf9352 2109 .parent = "thinktime",
d71c154c 2110 .hide = 1,
e8b0e958 2111 .category = FIO_OPT_C_IO,
3ceb458f 2112 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2113 },
2114 {
2115 .name = "rate",
e8b0e958 2116 .lname = "I/O rate",
e01b22b8 2117 .type = FIO_OPT_INT,
581e7141
JA
2118 .off1 = td_var_offset(rate[0]),
2119 .off2 = td_var_offset(rate[1]),
214e1eca 2120 .help = "Set bandwidth rate",
e8b0e958
JA
2121 .category = FIO_OPT_C_IO,
2122 .group = FIO_OPT_G_RATE,
214e1eca
JA
2123 },
2124 {
2125 .name = "ratemin",
e8b0e958 2126 .lname = "I/O min rate",
e01b22b8 2127 .type = FIO_OPT_INT,
581e7141
JA
2128 .off1 = td_var_offset(ratemin[0]),
2129 .off2 = td_var_offset(ratemin[1]),
4e991c23 2130 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2131 .parent = "rate",
d71c154c 2132 .hide = 1,
e8b0e958
JA
2133 .category = FIO_OPT_C_IO,
2134 .group = FIO_OPT_G_RATE,
4e991c23
JA
2135 },
2136 {
2137 .name = "rate_iops",
e8b0e958 2138 .lname = "I/O rate IOPS",
e01b22b8 2139 .type = FIO_OPT_INT,
581e7141
JA
2140 .off1 = td_var_offset(rate_iops[0]),
2141 .off2 = td_var_offset(rate_iops[1]),
4e991c23 2142 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2143 .hide = 1,
e8b0e958
JA
2144 .category = FIO_OPT_C_IO,
2145 .group = FIO_OPT_G_RATE,
4e991c23
JA
2146 },
2147 {
2148 .name = "rate_iops_min",
e8b0e958 2149 .lname = "I/O min rate IOPS",
e01b22b8 2150 .type = FIO_OPT_INT,
581e7141
JA
2151 .off1 = td_var_offset(rate_iops_min[0]),
2152 .off2 = td_var_offset(rate_iops_min[1]),
03e20d68 2153 .help = "Job must meet this rate or it will be shut down",
afdf9352 2154 .parent = "rate_iops",
d71c154c 2155 .hide = 1,
e8b0e958
JA
2156 .category = FIO_OPT_C_IO,
2157 .group = FIO_OPT_G_RATE,
214e1eca
JA
2158 },
2159 {
2160 .name = "ratecycle",
e8b0e958 2161 .lname = "I/O rate cycle",
214e1eca
JA
2162 .type = FIO_OPT_INT,
2163 .off1 = td_var_offset(ratecycle),
2164 .help = "Window average for rate limits (msec)",
2165 .def = "1000",
afdf9352 2166 .parent = "rate",
d71c154c 2167 .hide = 1,
e8b0e958
JA
2168 .category = FIO_OPT_C_IO,
2169 .group = FIO_OPT_G_RATE,
214e1eca
JA
2170 },
2171 {
2172 .name = "invalidate",
e8b0e958 2173 .lname = "Cache invalidate",
214e1eca
JA
2174 .type = FIO_OPT_BOOL,
2175 .off1 = td_var_offset(invalidate_cache),
2176 .help = "Invalidate buffer/page cache prior to running job",
2177 .def = "1",
e8b0e958 2178 .category = FIO_OPT_C_IO,
3ceb458f 2179 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2180 },
2181 {
2182 .name = "sync",
e8b0e958 2183 .lname = "Synchronous I/O",
214e1eca
JA
2184 .type = FIO_OPT_BOOL,
2185 .off1 = td_var_offset(sync_io),
2186 .help = "Use O_SYNC for buffered writes",
2187 .def = "0",
67a1000f 2188 .parent = "buffered",
d71c154c 2189 .hide = 1,
e8b0e958 2190 .category = FIO_OPT_C_IO,
3ceb458f 2191 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2192 },
214e1eca
JA
2193 {
2194 .name = "create_serialize",
e8b0e958 2195 .lname = "Create serialize",
214e1eca
JA
2196 .type = FIO_OPT_BOOL,
2197 .off1 = td_var_offset(create_serialize),
2198 .help = "Serialize creating of job files",
2199 .def = "1",
e8b0e958
JA
2200 .category = FIO_OPT_C_FILE,
2201 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2202 },
2203 {
2204 .name = "create_fsync",
e8b0e958 2205 .lname = "Create fsync",
214e1eca
JA
2206 .type = FIO_OPT_BOOL,
2207 .off1 = td_var_offset(create_fsync),
03e20d68 2208 .help = "fsync file after creation",
214e1eca 2209 .def = "1",
e8b0e958
JA
2210 .category = FIO_OPT_C_FILE,
2211 .group = FIO_OPT_G_INVALID,
214e1eca 2212 },
814452bd
JA
2213 {
2214 .name = "create_on_open",
e8b0e958 2215 .lname = "Create on open",
814452bd
JA
2216 .type = FIO_OPT_BOOL,
2217 .off1 = td_var_offset(create_on_open),
2218 .help = "Create files when they are opened for IO",
2219 .def = "0",
e8b0e958
JA
2220 .category = FIO_OPT_C_FILE,
2221 .group = FIO_OPT_G_INVALID,
814452bd 2222 },
25460cf6
JA
2223 {
2224 .name = "create_only",
2225 .type = FIO_OPT_BOOL,
2226 .off1 = td_var_offset(create_only),
2227 .help = "Only perform file creation phase",
d17fda71 2228 .category = FIO_OPT_C_FILE,
25460cf6
JA
2229 .def = "0",
2230 },
0b9d69ec 2231 {
afad68f7 2232 .name = "pre_read",
e8b0e958 2233 .lname = "Pre-read files",
afad68f7
ZY
2234 .type = FIO_OPT_BOOL,
2235 .off1 = td_var_offset(pre_read),
03e20d68 2236 .help = "Pre-read files before starting official testing",
afad68f7 2237 .def = "0",
e8b0e958
JA
2238 .category = FIO_OPT_C_FILE,
2239 .group = FIO_OPT_G_INVALID,
afad68f7 2240 },
214e1eca
JA
2241#ifdef FIO_HAVE_CPU_AFFINITY
2242 {
2243 .name = "cpumask",
e8b0e958 2244 .lname = "CPU mask",
214e1eca
JA
2245 .type = FIO_OPT_INT,
2246 .cb = str_cpumask_cb,
2247 .help = "CPU affinity mask",
e8b0e958 2248 .category = FIO_OPT_C_GENERAL,
10860056 2249 .group = FIO_OPT_G_CRED,
214e1eca 2250 },
d2e268b0
JA
2251 {
2252 .name = "cpus_allowed",
e8b0e958 2253 .lname = "CPUs allowed",
d2e268b0
JA
2254 .type = FIO_OPT_STR,
2255 .cb = str_cpus_allowed_cb,
2256 .help = "Set CPUs allowed",
e8b0e958 2257 .category = FIO_OPT_C_GENERAL,
10860056 2258 .group = FIO_OPT_G_CRED,
d2e268b0 2259 },
214e1eca
JA
2260#endif
2261 {
2262 .name = "end_fsync",
e8b0e958 2263 .lname = "End fsync",
214e1eca
JA
2264 .type = FIO_OPT_BOOL,
2265 .off1 = td_var_offset(end_fsync),
2266 .help = "Include fsync at the end of job",
2267 .def = "0",
e8b0e958
JA
2268 .category = FIO_OPT_C_FILE,
2269 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2270 },
2271 {
2272 .name = "fsync_on_close",
e8b0e958 2273 .lname = "Fsync on close",
214e1eca
JA
2274 .type = FIO_OPT_BOOL,
2275 .off1 = td_var_offset(fsync_on_close),
2276 .help = "fsync files on close",
2277 .def = "0",
e8b0e958
JA
2278 .category = FIO_OPT_C_FILE,
2279 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2280 },
2281 {
2282 .name = "unlink",
e8b0e958 2283 .lname = "Unlink file",
214e1eca
JA
2284 .type = FIO_OPT_BOOL,
2285 .off1 = td_var_offset(unlink),
2286 .help = "Unlink created files after job has completed",
2287 .def = "0",
e8b0e958
JA
2288 .category = FIO_OPT_C_FILE,
2289 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2290 },
2291 {
2292 .name = "exitall",
e8b0e958 2293 .lname = "Exit-all on terminate",
214e1eca
JA
2294 .type = FIO_OPT_STR_SET,
2295 .cb = str_exitall_cb,
2296 .help = "Terminate all jobs when one exits",
e8b0e958 2297 .category = FIO_OPT_C_GENERAL,
a1f6afec 2298 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2299 },
2300 {
2301 .name = "stonewall",
e8b0e958 2302 .lname = "Wait for previous",
d392365e 2303 .alias = "wait_for_previous",
214e1eca
JA
2304 .type = FIO_OPT_STR_SET,
2305 .off1 = td_var_offset(stonewall),
2306 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2307 .category = FIO_OPT_C_GENERAL,
a1f6afec 2308 .group = FIO_OPT_G_PROCESS,
214e1eca 2309 },
b3d62a75
JA
2310 {
2311 .name = "new_group",
e8b0e958 2312 .lname = "New group",
b3d62a75
JA
2313 .type = FIO_OPT_STR_SET,
2314 .off1 = td_var_offset(new_group),
2315 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2316 .category = FIO_OPT_C_GENERAL,
a1f6afec 2317 .group = FIO_OPT_G_PROCESS,
b3d62a75 2318 },
214e1eca
JA
2319 {
2320 .name = "thread",
e8b0e958 2321 .lname = "Thread",
214e1eca
JA
2322 .type = FIO_OPT_STR_SET,
2323 .off1 = td_var_offset(use_thread),
20eb06bd 2324 .help = "Use threads instead of processes",
e8b0e958 2325 .category = FIO_OPT_C_GENERAL,
a1f6afec 2326 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2327 },
2328 {
2329 .name = "write_bw_log",
e8b0e958 2330 .lname = "Write bandwidth log",
203160d5
JA
2331 .type = FIO_OPT_STR_STORE,
2332 .off1 = td_var_offset(bw_log_file),
214e1eca 2333 .help = "Write log of bandwidth during run",
e8b0e958
JA
2334 .category = FIO_OPT_C_LOG,
2335 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2336 },
2337 {
2338 .name = "write_lat_log",
e8b0e958 2339 .lname = "Write latency log",
203160d5
JA
2340 .type = FIO_OPT_STR_STORE,
2341 .off1 = td_var_offset(lat_log_file),
214e1eca 2342 .help = "Write log of latency during run",
e8b0e958
JA
2343 .category = FIO_OPT_C_LOG,
2344 .group = FIO_OPT_G_INVALID,
214e1eca 2345 },
c8eeb9df
JA
2346 {
2347 .name = "write_iops_log",
e8b0e958 2348 .lname = "Write IOPS log",
c8eeb9df 2349 .type = FIO_OPT_STR,
203160d5 2350 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2351 .help = "Write log of IOPS during run",
e8b0e958
JA
2352 .category = FIO_OPT_C_LOG,
2353 .group = FIO_OPT_G_INVALID,
c8eeb9df 2354 },
b8bc8cba
JA
2355 {
2356 .name = "log_avg_msec",
e8b0e958 2357 .lname = "Log averaging (msec)",
b8bc8cba
JA
2358 .type = FIO_OPT_INT,
2359 .off1 = td_var_offset(log_avg_msec),
2360 .help = "Average bw/iops/lat logs over this period of time",
2361 .def = "0",
e8b0e958
JA
2362 .category = FIO_OPT_C_LOG,
2363 .group = FIO_OPT_G_INVALID,
b8bc8cba 2364 },
c504ee55
JA
2365 {
2366 .name = "bwavgtime",
2367 .lname = "Bandwidth average time",
2368 .type = FIO_OPT_INT,
2369 .off1 = td_var_offset(bw_avg_time),
2370 .help = "Time window over which to calculate bandwidth"
2371 " (msec)",
2372 .def = "500",
2373 .parent = "write_bw_log",
2374 .hide = 1,
2375 .interval = 100,
2376 .category = FIO_OPT_C_LOG,
2377 .group = FIO_OPT_G_INVALID,
2378 },
2379 {
2380 .name = "iopsavgtime",
2381 .lname = "IOPS average time",
2382 .type = FIO_OPT_INT,
2383 .off1 = td_var_offset(iops_avg_time),
2384 .help = "Time window over which to calculate IOPS (msec)",
2385 .def = "500",
2386 .parent = "write_iops_log",
2387 .hide = 1,
2388 .interval = 100,
2389 .category = FIO_OPT_C_LOG,
2390 .group = FIO_OPT_G_INVALID,
2391 },
214e1eca
JA
2392 {
2393 .name = "group_reporting",
e8b0e958
JA
2394 .lname = "Group reporting",
2395 .type = FIO_OPT_BOOL,
214e1eca
JA
2396 .off1 = td_var_offset(group_reporting),
2397 .help = "Do reporting on a per-group basis",
e8b0e958 2398 .def = "1",
10860056 2399 .category = FIO_OPT_C_STAT,
e8b0e958 2400 .group = FIO_OPT_G_INVALID,
214e1eca 2401 },
e9459e5a
JA
2402 {
2403 .name = "zero_buffers",
e8b0e958 2404 .lname = "Zero I/O buffers",
e9459e5a
JA
2405 .type = FIO_OPT_STR_SET,
2406 .off1 = td_var_offset(zero_buffers),
2407 .help = "Init IO buffers to all zeroes",
e8b0e958 2408 .category = FIO_OPT_C_IO,
3ceb458f 2409 .group = FIO_OPT_G_IO_BUF,
e9459e5a 2410 },
5973cafb
JA
2411 {
2412 .name = "refill_buffers",
e8b0e958 2413 .lname = "Refill I/O buffers",
5973cafb
JA
2414 .type = FIO_OPT_STR_SET,
2415 .off1 = td_var_offset(refill_buffers),
2416 .help = "Refill IO buffers on every IO submit",
e8b0e958 2417 .category = FIO_OPT_C_IO,
3ceb458f 2418 .group = FIO_OPT_G_IO_BUF,
5973cafb 2419 },
fd68418e
JA
2420 {
2421 .name = "scramble_buffers",
e8b0e958 2422 .lname = "Scramble I/O buffers",
fd68418e
JA
2423 .type = FIO_OPT_BOOL,
2424 .off1 = td_var_offset(scramble_buffers),
2425 .help = "Slightly scramble buffers on every IO submit",
2426 .def = "1",
e8b0e958 2427 .category = FIO_OPT_C_IO,
3ceb458f 2428 .group = FIO_OPT_G_IO_BUF,
fd68418e 2429 },
9c42684e
JA
2430 {
2431 .name = "buffer_compress_percentage",
e8b0e958 2432 .lname = "Buffer compression percentage",
9c42684e
JA
2433 .type = FIO_OPT_INT,
2434 .off1 = td_var_offset(compress_percentage),
2435 .maxval = 100,
2436 .minval = 1,
2437 .help = "How compressible the buffer is (approximately)",
20eb06bd 2438 .interval = 5,
e8b0e958 2439 .category = FIO_OPT_C_IO,
3ceb458f 2440 .group = FIO_OPT_G_IO_BUF,
9c42684e 2441 },
f97a43a1
JA
2442 {
2443 .name = "buffer_compress_chunk",
e8b0e958 2444 .lname = "Buffer compression chunk size",
f97a43a1
JA
2445 .type = FIO_OPT_INT,
2446 .off1 = td_var_offset(compress_chunk),
207b18e4 2447 .parent = "buffer_compress_percentage",
d71c154c 2448 .hide = 1,
f97a43a1 2449 .help = "Size of compressible region in buffer",
20eb06bd 2450 .interval = 256,
e8b0e958 2451 .category = FIO_OPT_C_IO,
3ceb458f 2452 .group = FIO_OPT_G_IO_BUF,
f97a43a1 2453 },
83349190
YH
2454 {
2455 .name = "clat_percentiles",
e8b0e958 2456 .lname = "Completion latency percentiles",
83349190
YH
2457 .type = FIO_OPT_BOOL,
2458 .off1 = td_var_offset(clat_percentiles),
2459 .help = "Enable the reporting of completion latency percentiles",
467b35ed 2460 .def = "1",
e8b0e958
JA
2461 .category = FIO_OPT_C_STAT,
2462 .group = FIO_OPT_G_INVALID,
83349190
YH
2463 },
2464 {
2465 .name = "percentile_list",
e8b0e958 2466 .lname = "Completion latency percentile list",
83349190
YH
2467 .type = FIO_OPT_FLOAT_LIST,
2468 .off1 = td_var_offset(percentile_list),
2469 .off2 = td_var_offset(overwrite_plist),
2470 .help = "Specify a custom list of percentiles to report",
2471 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2472 .minfp = 0.0,
2473 .maxfp = 100.0,
e8b0e958
JA
2474 .category = FIO_OPT_C_STAT,
2475 .group = FIO_OPT_G_INVALID,
83349190
YH
2476 },
2477
0a839f30
JA
2478#ifdef FIO_HAVE_DISK_UTIL
2479 {
2480 .name = "disk_util",
e8b0e958 2481 .lname = "Disk utilization",
0a839f30
JA
2482 .type = FIO_OPT_BOOL,
2483 .off1 = td_var_offset(do_disk_util),
f66ab3c8 2484 .help = "Log disk utilization statistics",
0a839f30 2485 .def = "1",
e8b0e958
JA
2486 .category = FIO_OPT_C_STAT,
2487 .group = FIO_OPT_G_INVALID,
0a839f30
JA
2488 },
2489#endif
993bf48b
JA
2490 {
2491 .name = "gtod_reduce",
e8b0e958 2492 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
2493 .type = FIO_OPT_BOOL,
2494 .help = "Greatly reduce number of gettimeofday() calls",
2495 .cb = str_gtod_reduce_cb,
2496 .def = "0",
a4ed77fe 2497 .hide_on_set = 1,
e8b0e958
JA
2498 .category = FIO_OPT_C_STAT,
2499 .group = FIO_OPT_G_INVALID,
993bf48b 2500 },
02af0988
JA
2501 {
2502 .name = "disable_lat",
e8b0e958 2503 .lname = "Disable all latency stats",
02af0988
JA
2504 .type = FIO_OPT_BOOL,
2505 .off1 = td_var_offset(disable_lat),
2506 .help = "Disable latency numbers",
2507 .parent = "gtod_reduce",
d71c154c 2508 .hide = 1,
02af0988 2509 .def = "0",
e8b0e958
JA
2510 .category = FIO_OPT_C_STAT,
2511 .group = FIO_OPT_G_INVALID,
02af0988 2512 },
9520ebb9
JA
2513 {
2514 .name = "disable_clat",
e8b0e958 2515 .lname = "Disable completion latency stats",
9520ebb9
JA
2516 .type = FIO_OPT_BOOL,
2517 .off1 = td_var_offset(disable_clat),
2518 .help = "Disable completion 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_slat",
e8b0e958 2527 .lname = "Disable submission latency stats",
9520ebb9
JA
2528 .type = FIO_OPT_BOOL,
2529 .off1 = td_var_offset(disable_slat),
03e20d68 2530 .help = "Disable submission latency numbers",
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
JA
2536 },
2537 {
2538 .name = "disable_bw_measurement",
e8b0e958 2539 .lname = "Disable bandwidth stats",
9520ebb9
JA
2540 .type = FIO_OPT_BOOL,
2541 .off1 = td_var_offset(disable_bw),
2542 .help = "Disable bandwidth logging",
993bf48b 2543 .parent = "gtod_reduce",
d71c154c 2544 .hide = 1,
9520ebb9 2545 .def = "0",
e8b0e958
JA
2546 .category = FIO_OPT_C_STAT,
2547 .group = FIO_OPT_G_INVALID,
9520ebb9 2548 },
be4ecfdf
JA
2549 {
2550 .name = "gtod_cpu",
e8b0e958 2551 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
2552 .type = FIO_OPT_INT,
2553 .cb = str_gtod_cpu_cb,
03e20d68 2554 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 2555 .verify = gtod_cpu_verify,
e8b0e958 2556 .category = FIO_OPT_C_GENERAL,
10860056 2557 .group = FIO_OPT_G_CLOCK,
be4ecfdf 2558 },
f2bba182
RR
2559 {
2560 .name = "continue_on_error",
e8b0e958 2561 .lname = "Continue on error",
06842027 2562 .type = FIO_OPT_STR,
f2bba182 2563 .off1 = td_var_offset(continue_on_error),
03e20d68 2564 .help = "Continue on non-fatal errors during IO",
06842027 2565 .def = "none",
e8b0e958
JA
2566 .category = FIO_OPT_C_GENERAL,
2567 .group = FIO_OPT_G_INVALID,
06842027
SL
2568 .posval = {
2569 { .ival = "none",
2570 .oval = ERROR_TYPE_NONE,
2571 .help = "Exit when an error is encountered",
2572 },
2573 { .ival = "read",
2574 .oval = ERROR_TYPE_READ,
2575 .help = "Continue on read errors only",
2576 },
2577 { .ival = "write",
2578 .oval = ERROR_TYPE_WRITE,
2579 .help = "Continue on write errors only",
2580 },
2581 { .ival = "io",
2582 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2583 .help = "Continue on any IO errors",
2584 },
2585 { .ival = "verify",
2586 .oval = ERROR_TYPE_VERIFY,
2587 .help = "Continue on verify errors only",
2588 },
2589 { .ival = "all",
2590 .oval = ERROR_TYPE_ANY,
2591 .help = "Continue on all io and verify errors",
2592 },
2593 { .ival = "0",
2594 .oval = ERROR_TYPE_NONE,
2595 .help = "Alias for 'none'",
2596 },
2597 { .ival = "1",
2598 .oval = ERROR_TYPE_ANY,
2599 .help = "Alias for 'all'",
2600 },
2601 },
f2bba182 2602 },
9ac8a797
JA
2603 {
2604 .name = "profile",
e8b0e958 2605 .lname = "Profile",
79d16311 2606 .type = FIO_OPT_STR_STORE,
9ac8a797 2607 .off1 = td_var_offset(profile),
9ac8a797 2608 .help = "Select a specific builtin performance test",
13fca827 2609 .category = FIO_OPT_C_PROFILE,
e8b0e958 2610 .group = FIO_OPT_G_INVALID,
9ac8a797 2611 },
a696fa2a
JA
2612 {
2613 .name = "cgroup",
e8b0e958 2614 .lname = "Cgroup",
a696fa2a
JA
2615 .type = FIO_OPT_STR_STORE,
2616 .off1 = td_var_offset(cgroup),
2617 .help = "Add job to cgroup of this name",
e8b0e958 2618 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
2619 .group = FIO_OPT_G_CGROUP,
2620 },
2621 {
2622 .name = "cgroup_nodelete",
2623 .lname = "Cgroup no-delete",
2624 .type = FIO_OPT_BOOL,
2625 .off1 = td_var_offset(cgroup_nodelete),
2626 .help = "Do not delete cgroups after job completion",
2627 .def = "0",
2628 .parent = "cgroup",
2629 .category = FIO_OPT_C_GENERAL,
2630 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
2631 },
2632 {
2633 .name = "cgroup_weight",
e8b0e958 2634 .lname = "Cgroup weight",
a696fa2a
JA
2635 .type = FIO_OPT_INT,
2636 .off1 = td_var_offset(cgroup_weight),
2637 .help = "Use given weight for cgroup",
2638 .minval = 100,
2639 .maxval = 1000,
a1f6afec 2640 .parent = "cgroup",
e8b0e958 2641 .category = FIO_OPT_C_GENERAL,
a1f6afec 2642 .group = FIO_OPT_G_CGROUP,
7de87099 2643 },
e0b0d892
JA
2644 {
2645 .name = "uid",
e8b0e958 2646 .lname = "User ID",
e0b0d892
JA
2647 .type = FIO_OPT_INT,
2648 .off1 = td_var_offset(uid),
2649 .help = "Run job with this user ID",
e8b0e958 2650 .category = FIO_OPT_C_GENERAL,
10860056 2651 .group = FIO_OPT_G_CRED,
e0b0d892
JA
2652 },
2653 {
2654 .name = "gid",
e8b0e958 2655 .lname = "Group ID",
e0b0d892
JA
2656 .type = FIO_OPT_INT,
2657 .off1 = td_var_offset(gid),
2658 .help = "Run job with this group ID",
e8b0e958 2659 .category = FIO_OPT_C_GENERAL,
10860056 2660 .group = FIO_OPT_G_CRED,
e0b0d892 2661 },
a1f6afec
JA
2662 {
2663 .name = "kb_base",
2664 .lname = "KB Base",
2665 .type = FIO_OPT_INT,
2666 .off1 = td_var_offset(kb_base),
2667 .verify = kb_base_verify,
2668 .prio = 1,
2669 .def = "1024",
2670 .help = "How many bytes per KB for reporting (1000 or 1024)",
2671 .category = FIO_OPT_C_GENERAL,
2672 .group = FIO_OPT_G_INVALID,
2673 },
3ceb458f
JA
2674 {
2675 .name = "hugepage-size",
2676 .lname = "Hugepage size",
2677 .type = FIO_OPT_INT,
2678 .off1 = td_var_offset(hugepage_size),
2679 .help = "When using hugepages, specify size of each page",
2680 .def = __fio_stringify(FIO_HUGE_PAGE),
2681 .interval = 1024 * 1024,
2682 .category = FIO_OPT_C_GENERAL,
2683 .group = FIO_OPT_G_INVALID,
2684 },
9e684a49
DE
2685 {
2686 .name = "flow_id",
e8b0e958 2687 .lname = "I/O flow ID",
9e684a49
DE
2688 .type = FIO_OPT_INT,
2689 .off1 = td_var_offset(flow_id),
2690 .help = "The flow index ID to use",
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",
e8b0e958 2697 .lname = "I/O flow weight",
9e684a49
DE
2698 .type = FIO_OPT_INT,
2699 .off1 = td_var_offset(flow),
2700 .help = "Weight for flow control of this job",
2701 .parent = "flow_id",
d71c154c 2702 .hide = 1,
9e684a49 2703 .def = "0",
e8b0e958
JA
2704 .category = FIO_OPT_C_IO,
2705 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
2706 },
2707 {
2708 .name = "flow_watermark",
e8b0e958 2709 .lname = "I/O flow watermark",
9e684a49
DE
2710 .type = FIO_OPT_INT,
2711 .off1 = td_var_offset(flow_watermark),
2712 .help = "High watermark for flow control. This option"
2713 " should be set to the same value for all threads"
2714 " with non-zero flow.",
2715 .parent = "flow_id",
d71c154c 2716 .hide = 1,
9e684a49 2717 .def = "1024",
e8b0e958
JA
2718 .category = FIO_OPT_C_IO,
2719 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
2720 },
2721 {
2722 .name = "flow_sleep",
e8b0e958 2723 .lname = "I/O flow sleep",
9e684a49
DE
2724 .type = FIO_OPT_INT,
2725 .off1 = td_var_offset(flow_sleep),
2726 .help = "How many microseconds to sleep after being held"
2727 " back by the flow control mechanism",
2728 .parent = "flow_id",
d71c154c 2729 .hide = 1,
9e684a49 2730 .def = "0",
e8b0e958
JA
2731 .category = FIO_OPT_C_IO,
2732 .group = FIO_OPT_G_IO_FLOW,
9e684a49 2733 },
214e1eca
JA
2734 {
2735 .name = NULL,
2736 },
2737};
2738
17af15d4 2739static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 2740 const char *name, int val)
9f81736c 2741{
17af15d4 2742 lopt->name = (char *) name;
de890a1e 2743 lopt->val = val;
9f81736c
JA
2744 if (o->type == FIO_OPT_STR_SET)
2745 lopt->has_arg = no_argument;
2746 else
2747 lopt->has_arg = required_argument;
2748}
2749
de890a1e
SL
2750static void options_to_lopts(struct fio_option *opts,
2751 struct option *long_options,
2752 int i, int option_type)
214e1eca 2753{
de890a1e 2754 struct fio_option *o = &opts[0];
214e1eca 2755 while (o->name) {
de890a1e 2756 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
2757 if (o->alias) {
2758 i++;
de890a1e 2759 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 2760 }
214e1eca
JA
2761
2762 i++;
2763 o++;
2764 assert(i < FIO_NR_OPTIONS);
2765 }
2766}
2767
de890a1e
SL
2768void fio_options_set_ioengine_opts(struct option *long_options,
2769 struct thread_data *td)
2770{
2771 unsigned int i;
2772
2773 i = 0;
2774 while (long_options[i].name) {
2775 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2776 memset(&long_options[i], 0, sizeof(*long_options));
2777 break;
2778 }
2779 i++;
2780 }
2781
2782 /*
2783 * Just clear out the prior ioengine options.
2784 */
2785 if (!td || !td->eo)
2786 return;
2787
2788 options_to_lopts(td->io_ops->options, long_options, i,
2789 FIO_GETOPT_IOENGINE);
2790}
2791
2792void fio_options_dup_and_init(struct option *long_options)
2793{
2794 unsigned int i;
2795
9af4a244 2796 options_init(fio_options);
de890a1e
SL
2797
2798 i = 0;
2799 while (long_options[i].name)
2800 i++;
2801
9af4a244 2802 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
2803}
2804
74929ac2
JA
2805struct fio_keyword {
2806 const char *word;
2807 const char *desc;
2808 char *replace;
2809};
2810
2811static struct fio_keyword fio_keywords[] = {
2812 {
2813 .word = "$pagesize",
2814 .desc = "Page size in the system",
2815 },
2816 {
2817 .word = "$mb_memory",
2818 .desc = "Megabytes of memory online",
2819 },
2820 {
2821 .word = "$ncpus",
2822 .desc = "Number of CPUs online in the system",
2823 },
2824 {
2825 .word = NULL,
2826 },
2827};
2828
2829void fio_keywords_init(void)
2830{
3b2e1464 2831 unsigned long long mb_memory;
74929ac2
JA
2832 char buf[128];
2833 long l;
2834
2835 sprintf(buf, "%lu", page_size);
2836 fio_keywords[0].replace = strdup(buf);
2837
8eb016d3 2838 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 2839 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
2840 fio_keywords[1].replace = strdup(buf);
2841
c00a2289 2842 l = cpus_online();
74929ac2
JA
2843 sprintf(buf, "%lu", l);
2844 fio_keywords[2].replace = strdup(buf);
2845}
2846
892a6ffc
JA
2847#define BC_APP "bc"
2848
2849static char *bc_calc(char *str)
2850{
d0c814ec 2851 char buf[128], *tmp;
892a6ffc
JA
2852 FILE *f;
2853 int ret;
2854
2855 /*
2856 * No math, just return string
2857 */
d0c814ec
SL
2858 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2859 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
2860 return str;
2861
2862 /*
2863 * Split option from value, we only need to calculate the value
2864 */
2865 tmp = strchr(str, '=');
2866 if (!tmp)
2867 return str;
2868
2869 tmp++;
892a6ffc 2870
d0c814ec
SL
2871 /*
2872 * Prevent buffer overflows; such a case isn't reasonable anyway
2873 */
2874 if (strlen(str) >= 128 || strlen(tmp) > 100)
2875 return str;
892a6ffc
JA
2876
2877 sprintf(buf, "which %s > /dev/null", BC_APP);
2878 if (system(buf)) {
2879 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
2880 return NULL;
2881 }
2882
d0c814ec 2883 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 2884 f = popen(buf, "r");
3c3ed070 2885 if (!f)
892a6ffc 2886 return NULL;
892a6ffc 2887
d0c814ec 2888 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 2889 if (ret <= 0)
892a6ffc 2890 return NULL;
892a6ffc 2891
892a6ffc 2892 pclose(f);
d0c814ec
SL
2893 buf[(tmp - str) + ret - 1] = '\0';
2894 memcpy(buf, str, tmp - str);
892a6ffc 2895 free(str);
d0c814ec
SL
2896 return strdup(buf);
2897}
2898
2899/*
2900 * Return a copy of the input string with substrings of the form ${VARNAME}
2901 * substituted with the value of the environment variable VARNAME. The
2902 * substitution always occurs, even if VARNAME is empty or the corresponding
2903 * environment variable undefined.
2904 */
2905static char *option_dup_subs(const char *opt)
2906{
2907 char out[OPT_LEN_MAX+1];
2908 char in[OPT_LEN_MAX+1];
2909 char *outptr = out;
2910 char *inptr = in;
2911 char *ch1, *ch2, *env;
2912 ssize_t nchr = OPT_LEN_MAX;
2913 size_t envlen;
2914
2915 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2916 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2917 return NULL;
2918 }
2919
2920 in[OPT_LEN_MAX] = '\0';
2921 strncpy(in, opt, OPT_LEN_MAX);
2922
2923 while (*inptr && nchr > 0) {
2924 if (inptr[0] == '$' && inptr[1] == '{') {
2925 ch2 = strchr(inptr, '}');
2926 if (ch2 && inptr+1 < ch2) {
2927 ch1 = inptr+2;
2928 inptr = ch2+1;
2929 *ch2 = '\0';
2930
2931 env = getenv(ch1);
2932 if (env) {
2933 envlen = strlen(env);
2934 if (envlen <= nchr) {
2935 memcpy(outptr, env, envlen);
2936 outptr += envlen;
2937 nchr -= envlen;
2938 }
2939 }
2940
2941 continue;
2942 }
2943 }
2944
2945 *outptr++ = *inptr++;
2946 --nchr;
2947 }
2948
2949 *outptr = '\0';
2950 return strdup(out);
892a6ffc
JA
2951}
2952
74929ac2
JA
2953/*
2954 * Look for reserved variable names and replace them with real values
2955 */
2956static char *fio_keyword_replace(char *opt)
2957{
2958 char *s;
2959 int i;
d0c814ec 2960 int docalc = 0;
74929ac2
JA
2961
2962 for (i = 0; fio_keywords[i].word != NULL; i++) {
2963 struct fio_keyword *kw = &fio_keywords[i];
2964
2965 while ((s = strstr(opt, kw->word)) != NULL) {
2966 char *new = malloc(strlen(opt) + 1);
2967 char *o_org = opt;
2968 int olen = s - opt;
2969 int len;
2970
2971 /*
2972 * Copy part of the string before the keyword and
2973 * sprintf() the replacement after it.
2974 */
2975 memcpy(new, opt, olen);
2976 len = sprintf(new + olen, "%s", kw->replace);
2977
2978 /*
2979 * If there's more in the original string, copy that
2980 * in too
2981 */
2982 opt += strlen(kw->word) + olen;
2983 if (strlen(opt))
2984 memcpy(new + olen + len, opt, opt - o_org - 1);
2985
2986 /*
2987 * replace opt and free the old opt
2988 */
2989 opt = new;
d0c814ec 2990 free(o_org);
7a958bd5 2991
d0c814ec 2992 docalc = 1;
74929ac2
JA
2993 }
2994 }
2995
d0c814ec
SL
2996 /*
2997 * Check for potential math and invoke bc, if possible
2998 */
2999 if (docalc)
3000 opt = bc_calc(opt);
3001
7a958bd5 3002 return opt;
74929ac2
JA
3003}
3004
d0c814ec
SL
3005static char **dup_and_sub_options(char **opts, int num_opts)
3006{
3007 int i;
3008 char **opts_copy = malloc(num_opts * sizeof(*opts));
3009 for (i = 0; i < num_opts; i++) {
3010 opts_copy[i] = option_dup_subs(opts[i]);
3011 if (!opts_copy[i])
3012 continue;
3013 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3014 }
3015 return opts_copy;
3016}
3017
3b8b7135 3018int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 3019{
de890a1e 3020 int i, ret, unknown;
d0c814ec 3021 char **opts_copy;
3b8b7135 3022
9af4a244 3023 sort_options(opts, fio_options, num_opts);
d0c814ec 3024 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3025
de890a1e
SL
3026 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3027 struct fio_option *o;
9af4a244
JA
3028 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3029 &o, td);
d0c814ec 3030
de890a1e
SL
3031 if (opts_copy[i]) {
3032 if (newret && !o) {
3033 unknown++;
3034 continue;
3035 }
d0c814ec 3036 free(opts_copy[i]);
de890a1e
SL
3037 opts_copy[i] = NULL;
3038 }
3039
3040 ret |= newret;
3041 }
3042
3043 if (unknown) {
3044 ret |= ioengine_load(td);
3045 if (td->eo) {
3046 sort_options(opts_copy, td->io_ops->options, num_opts);
3047 opts = opts_copy;
3048 }
3049 for (i = 0; i < num_opts; i++) {
3050 struct fio_option *o = NULL;
3051 int newret = 1;
3052 if (!opts_copy[i])
3053 continue;
3054
3055 if (td->eo)
3056 newret = parse_option(opts_copy[i], opts[i],
3057 td->io_ops->options, &o,
3058 td->eo);
3059
3060 ret |= newret;
3061 if (!o)
3062 log_err("Bad option <%s>\n", opts[i]);
3063
3064 free(opts_copy[i]);
3065 opts_copy[i] = NULL;
3066 }
74929ac2 3067 }
3b8b7135 3068
d0c814ec 3069 free(opts_copy);
3b8b7135 3070 return ret;
214e1eca
JA
3071}
3072
3073int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3074{
9af4a244 3075 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3076}
3077
de890a1e
SL
3078int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3079 char *val)
3080{
3081 return parse_cmd_option(opt, val, td->io_ops->options, td);
3082}
3083
214e1eca
JA
3084void fio_fill_default_options(struct thread_data *td)
3085{
9af4a244 3086 fill_default_options(td, fio_options);
214e1eca
JA
3087}
3088
3089int fio_show_option_help(const char *opt)
3090{
9af4a244 3091 return show_cmd_help(fio_options, opt);
214e1eca 3092}
d23bb327 3093
de890a1e 3094void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3095{
de890a1e 3096 struct fio_option *o;
d23bb327 3097 char **ptr;
d23bb327 3098
de890a1e
SL
3099 for (o = &options[0]; o->name; o++) {
3100 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3101 continue;
3102
de890a1e 3103 ptr = td_var(data, o->off1);
7e356b2d
JA
3104 if (*ptr)
3105 *ptr = strdup(*ptr);
d23bb327
JA
3106 }
3107}
3108
de890a1e
SL
3109/*
3110 * dupe FIO_OPT_STR_STORE options
3111 */
3112void fio_options_mem_dupe(struct thread_data *td)
3113{
9af4a244 3114 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3115
3116 if (td->eo && td->io_ops) {
de890a1e 3117 void *oldeo = td->eo;
1647f592 3118
de890a1e
SL
3119 td->eo = malloc(td->io_ops->option_struct_size);
3120 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3121 options_mem_dupe(td->eo, td->io_ops->options);
3122 }
3123}
3124
d6978a32
JA
3125unsigned int fio_get_kb_base(void *data)
3126{
83ea422a 3127 struct thread_options *o = data;
d6978a32
JA
3128 unsigned int kb_base = 0;
3129
83ea422a
JA
3130 if (o)
3131 kb_base = o->kb_base;
d6978a32
JA
3132 if (!kb_base)
3133 kb_base = 1024;
3134
3135 return kb_base;
3136}
9f988e2e 3137
07b3232d 3138int add_option(struct fio_option *o)
9f988e2e 3139{
07b3232d
JA
3140 struct fio_option *__o;
3141 int opt_index = 0;
3142
9af4a244 3143 __o = fio_options;
07b3232d
JA
3144 while (__o->name) {
3145 opt_index++;
3146 __o++;
3147 }
3148
9af4a244 3149 memcpy(&fio_options[opt_index], o, sizeof(*o));
07b3232d 3150 return 0;
9f988e2e 3151}
e2de69da 3152
07b3232d 3153void invalidate_profile_options(const char *prof_name)
e2de69da 3154{
07b3232d 3155 struct fio_option *o;
e2de69da 3156
9af4a244 3157 o = fio_options;
07b3232d
JA
3158 while (o->name) {
3159 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3160 o->type = FIO_OPT_INVALID;
3161 o->prof_name = NULL;
3162 }
3163 o++;
e2de69da
JA
3164 }
3165}
f5b6bb85
JA
3166
3167void add_opt_posval(const char *optname, const char *ival, const char *help)
3168{
3169 struct fio_option *o;
3170 unsigned int i;
3171
9af4a244 3172 o = find_option(fio_options, optname);
f5b6bb85
JA
3173 if (!o)
3174 return;
3175
3176 for (i = 0; i < PARSE_MAX_VP; i++) {
3177 if (o->posval[i].ival)
3178 continue;
3179
3180 o->posval[i].ival = ival;
3181 o->posval[i].help = help;
3182 break;
3183 }
3184}
3185
3186void del_opt_posval(const char *optname, const char *ival)
3187{
3188 struct fio_option *o;
3189 unsigned int i;
3190
9af4a244 3191 o = find_option(fio_options, optname);
f5b6bb85
JA
3192 if (!o)
3193 return;
3194
3195 for (i = 0; i < PARSE_MAX_VP; i++) {
3196 if (!o->posval[i].ival)
3197 continue;
3198 if (strcmp(o->posval[i].ival, ival))
3199 continue;
3200
3201 o->posval[i].ival = NULL;
3202 o->posval[i].help = NULL;
3203 }
3204}
7e356b2d
JA
3205
3206void fio_options_free(struct thread_data *td)
3207{
9af4a244 3208 options_free(fio_options, td);
de890a1e
SL
3209 if (td->eo && td->io_ops && td->io_ops->options) {
3210 options_free(td->io_ops->options, td->eo);
3211 free(td->eo);
3212 td->eo = NULL;
3213 }
7e356b2d 3214}
c504ee55
JA
3215
3216struct fio_option *fio_option_find(const char *name)
3217{
3218 return find_option(fio_options, name);
3219}
3220