blktrace: load improvements
[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
0de5b26f 105 if (str_to_decimal(fname, &val, 1, o, 0)) {
564ca972 106 log_err("fio: bssplit conversion failed\n");
d8b97c8e 107 free(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;
6eaf09d6 168 char *str, *p, *odir, *ddir;
720e84ad
JA
169 int ret = 0;
170
52c0cea3
JA
171 if (parse_dryrun())
172 return 0;
173
720e84ad
JA
174 p = str = strdup(input);
175
176 strip_blank_front(&str);
177 strip_blank_end(str);
178
179 odir = strchr(str, ',');
180 if (odir) {
6eaf09d6
SL
181 ddir = strchr(odir + 1, ',');
182 if (ddir) {
d79db122 183 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
6eaf09d6
SL
184 if (!ret)
185 *ddir = '\0';
186 } else {
187 char *op;
188
189 op = strdup(odir + 1);
d79db122 190 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
191
192 free(op);
193 }
d79db122
JA
194 if (!ret)
195 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
720e84ad
JA
196 if (!ret) {
197 *odir = '\0';
83ea422a 198 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad
JA
199 }
200 } else {
201 char *op;
202
203 op = strdup(str);
d79db122 204 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
6eaf09d6 205 free(op);
720e84ad 206
6eaf09d6
SL
207 if (!ret) {
208 op = strdup(str);
d79db122 209 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
210 free(op);
211 }
83ea422a 212 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad 213 }
564ca972
JA
214
215 free(p);
720e84ad 216 return ret;
564ca972
JA
217}
218
8b28bd41
DM
219static int str2error(char *str)
220{
a94eb99a 221 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
8b28bd41
DM
222 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
223 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
224 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
225 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
226 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
227 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
a94eb99a 228 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
8b28bd41
DM
229 int i = 0, num = sizeof(err) / sizeof(void *);
230
a94eb99a 231 while (i < num) {
8b28bd41
DM
232 if (!strcmp(err[i], str))
233 return i + 1;
234 i++;
235 }
236 return 0;
237}
238
239static int ignore_error_type(struct thread_data *td, int etype, char *str)
240{
241 unsigned int i;
242 int *error;
243 char *fname;
244
245 if (etype >= ERROR_TYPE_CNT) {
246 log_err("Illegal error type\n");
247 return 1;
248 }
249
250 td->o.ignore_error_nr[etype] = 4;
251 error = malloc(4 * sizeof(struct bssplit));
252
253 i = 0;
254 while ((fname = strsep(&str, ":")) != NULL) {
255
256 if (!strlen(fname))
257 break;
258
259 /*
260 * grow struct buffer, if needed
261 */
262 if (i == td->o.ignore_error_nr[etype]) {
263 td->o.ignore_error_nr[etype] <<= 1;
264 error = realloc(error, td->o.ignore_error_nr[etype]
265 * sizeof(int));
266 }
267 if (fname[0] == 'E') {
268 error[i] = str2error(fname);
269 } else {
270 error[i] = atoi(fname);
271 if (error[i] < 0)
272 error[i] = error[i];
273 }
274 if (!error[i]) {
275 log_err("Unknown error %s, please use number value \n",
276 fname);
0fddbf7a 277 free(error);
8b28bd41
DM
278 return 1;
279 }
280 i++;
281 }
282 if (i) {
283 td->o.continue_on_error |= 1 << etype;
284 td->o.ignore_error_nr[etype] = i;
285 td->o.ignore_error[etype] = error;
286 }
287 return 0;
288
289}
290
291static int str_ignore_error_cb(void *data, const char *input)
292{
293 struct thread_data *td = data;
294 char *str, *p, *n;
295 int type = 0, ret = 1;
52c0cea3
JA
296
297 if (parse_dryrun())
298 return 0;
299
8b28bd41
DM
300 p = str = strdup(input);
301
302 strip_blank_front(&str);
303 strip_blank_end(str);
304
305 while (p) {
306 n = strchr(p, ',');
307 if (n)
308 *n++ = '\0';
309 ret = ignore_error_type(td, type, p);
310 if (ret)
311 break;
312 p = n;
313 type++;
314 }
315 free(str);
316 return ret;
317}
318
211097b2
JA
319static int str_rw_cb(void *data, const char *str)
320{
321 struct thread_data *td = data;
83ea422a 322 struct thread_options *o = &td->o;
211097b2
JA
323 char *nr = get_opt_postfix(str);
324
52c0cea3
JA
325 if (parse_dryrun())
326 return 0;
327
83ea422a
JA
328 o->ddir_seq_nr = 1;
329 o->ddir_seq_add = 0;
059b0802
JA
330
331 if (!nr)
332 return 0;
333
334 if (td_random(td))
83ea422a 335 o->ddir_seq_nr = atoi(nr);
059b0802
JA
336 else {
337 long long val;
338
0de5b26f 339 if (str_to_decimal(nr, &val, 1, o, 0)) {
059b0802
JA
340 log_err("fio: rw postfix parsing failed\n");
341 free(nr);
342 return 1;
343 }
344
83ea422a 345 o->ddir_seq_add = val;
182ec6ee 346 }
211097b2 347
059b0802 348 free(nr);
211097b2
JA
349 return 0;
350}
351
214e1eca
JA
352static int str_mem_cb(void *data, const char *mem)
353{
354 struct thread_data *td = data;
355
d9759b1e 356 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
836fcc0f 357 td->o.mmapfile = get_opt_postfix(mem);
214e1eca
JA
358
359 return 0;
360}
361
c223da83
JA
362static int fio_clock_source_cb(void *data, const char *str)
363{
364 struct thread_data *td = data;
365
366 fio_clock_source = td->o.clocksource;
fa80feae 367 fio_clock_source_set = 1;
01423eae 368 fio_clock_init();
c223da83
JA
369 return 0;
370}
371
85bc833b 372static int str_rwmix_read_cb(void *data, unsigned long long *val)
cb499fc4
JA
373{
374 struct thread_data *td = data;
375
376 td->o.rwmix[DDIR_READ] = *val;
377 td->o.rwmix[DDIR_WRITE] = 100 - *val;
378 return 0;
379}
380
85bc833b 381static int str_rwmix_write_cb(void *data, unsigned long long *val)
cb499fc4
JA
382{
383 struct thread_data *td = data;
384
385 td->o.rwmix[DDIR_WRITE] = *val;
386 td->o.rwmix[DDIR_READ] = 100 - *val;
387 return 0;
388}
389
214e1eca
JA
390static int str_exitall_cb(void)
391{
392 exitall_on_terminate = 1;
393 return 0;
394}
395
214e1eca 396#ifdef FIO_HAVE_CPU_AFFINITY
85bc833b 397static int str_cpumask_cb(void *data, unsigned long long *val)
d2e268b0
JA
398{
399 struct thread_data *td = data;
214e1eca 400 unsigned int i;
b03daafb 401 long max_cpu;
d2ce18b5
JA
402 int ret;
403
52c0cea3
JA
404 if (parse_dryrun())
405 return 0;
406
d2ce18b5
JA
407 ret = fio_cpuset_init(&td->o.cpumask);
408 if (ret < 0) {
409 log_err("fio: cpuset_init failed\n");
410 td_verror(td, ret, "fio_cpuset_init");
411 return 1;
412 }
214e1eca 413
c00a2289 414 max_cpu = cpus_online();
214e1eca 415
62a7273d
JA
416 for (i = 0; i < sizeof(int) * 8; i++) {
417 if ((1 << i) & *val) {
b03daafb
JA
418 if (i > max_cpu) {
419 log_err("fio: CPU %d too large (max=%ld)\n", i,
420 max_cpu);
421 return 1;
422 }
62a7273d 423 dprint(FD_PARSE, "set cpu allowed %d\n", i);
6d459ee7 424 fio_cpu_set(&td->o.cpumask, i);
62a7273d
JA
425 }
426 }
d2e268b0
JA
427
428 td->o.cpumask_set = 1;
429 return 0;
214e1eca
JA
430}
431
e8462bd8
JA
432static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
433 const char *input)
214e1eca 434{
d2e268b0 435 char *cpu, *str, *p;
b03daafb 436 long max_cpu;
19608d6c 437 int ret = 0;
d2e268b0 438
e8462bd8 439 ret = fio_cpuset_init(mask);
d2ce18b5
JA
440 if (ret < 0) {
441 log_err("fio: cpuset_init failed\n");
442 td_verror(td, ret, "fio_cpuset_init");
443 return 1;
444 }
d2e268b0
JA
445
446 p = str = strdup(input);
214e1eca 447
d2e268b0
JA
448 strip_blank_front(&str);
449 strip_blank_end(str);
450
c00a2289 451 max_cpu = cpus_online();
b03daafb 452
d2e268b0 453 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
454 char *str2, *cpu2;
455 int icpu, icpu2;
456
d2e268b0
JA
457 if (!strlen(cpu))
458 break;
62a7273d
JA
459
460 str2 = cpu;
461 icpu2 = -1;
462 while ((cpu2 = strsep(&str2, "-")) != NULL) {
463 if (!strlen(cpu2))
464 break;
465
466 icpu2 = atoi(cpu2);
467 }
468
469 icpu = atoi(cpu);
470 if (icpu2 == -1)
471 icpu2 = icpu;
472 while (icpu <= icpu2) {
6d459ee7 473 if (icpu >= FIO_MAX_CPUS) {
19608d6c 474 log_err("fio: your OS only supports up to"
6d459ee7 475 " %d CPUs\n", (int) FIO_MAX_CPUS);
19608d6c
JA
476 ret = 1;
477 break;
478 }
b03daafb
JA
479 if (icpu > max_cpu) {
480 log_err("fio: CPU %d too large (max=%ld)\n",
481 icpu, max_cpu);
482 ret = 1;
483 break;
484 }
0b9d69ec 485
62a7273d 486 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
e8462bd8 487 fio_cpu_set(mask, icpu);
62a7273d
JA
488 icpu++;
489 }
19608d6c
JA
490 if (ret)
491 break;
d2e268b0
JA
492 }
493
494 free(p);
19608d6c
JA
495 if (!ret)
496 td->o.cpumask_set = 1;
497 return ret;
214e1eca 498}
e8462bd8
JA
499
500static int str_cpus_allowed_cb(void *data, const char *input)
501{
502 struct thread_data *td = data;
503 int ret;
504
52c0cea3
JA
505 if (parse_dryrun())
506 return 0;
507
e8462bd8
JA
508 ret = set_cpus_allowed(td, &td->o.cpumask, input);
509 if (!ret)
510 td->o.cpumask_set = 1;
511
512 return ret;
513}
514
515static int str_verify_cpus_allowed_cb(void *data, const char *input)
516{
517 struct thread_data *td = data;
518 int ret;
519
520 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
521 if (!ret)
522 td->o.verify_cpumask_set = 1;
523
524 return ret;
525}
d2e268b0 526#endif
214e1eca 527
67bf9823 528#ifdef CONFIG_LIBNUMA
d0b937ed
YR
529static int str_numa_cpunodes_cb(void *data, char *input)
530{
531 struct thread_data *td = data;
532
52c0cea3
JA
533 if (parse_dryrun())
534 return 0;
535
d0b937ed
YR
536 /* numa_parse_nodestring() parses a character string list
537 * of nodes into a bit mask. The bit mask is allocated by
538 * numa_allocate_nodemask(), so it should be freed by
539 * numa_free_nodemask().
540 */
541 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
542 if (td->o.numa_cpunodesmask == NULL) {
543 log_err("fio: numa_parse_nodestring failed\n");
544 td_verror(td, 1, "str_numa_cpunodes_cb");
545 return 1;
546 }
547
548 td->o.numa_cpumask_set = 1;
549 return 0;
550}
551
552static int str_numa_mpol_cb(void *data, char *input)
553{
554 struct thread_data *td = data;
555 const char * const policy_types[] =
05d6f44b 556 { "default", "prefer", "bind", "interleave", "local", NULL };
d0b937ed 557 int i;
52c0cea3
JA
558 char *nodelist;
559
560 if (parse_dryrun())
561 return 0;
d0b937ed 562
52c0cea3 563 nodelist = strchr(input, ':');
d0b937ed
YR
564 if (nodelist) {
565 /* NUL-terminate mode */
566 *nodelist++ = '\0';
567 }
568
569 for (i = 0; i <= MPOL_LOCAL; i++) {
570 if (!strcmp(input, policy_types[i])) {
571 td->o.numa_mem_mode = i;
572 break;
573 }
574 }
575 if (i > MPOL_LOCAL) {
576 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
577 goto out;
578 }
579
580 switch (td->o.numa_mem_mode) {
581 case MPOL_PREFERRED:
582 /*
583 * Insist on a nodelist of one node only
584 */
585 if (nodelist) {
586 char *rest = nodelist;
587 while (isdigit(*rest))
588 rest++;
589 if (*rest) {
590 log_err("fio: one node only for \'prefer\'\n");
591 goto out;
592 }
593 } else {
594 log_err("fio: one node is needed for \'prefer\'\n");
595 goto out;
596 }
597 break;
598 case MPOL_INTERLEAVE:
599 /*
600 * Default to online nodes with memory if no nodelist
601 */
602 if (!nodelist)
603 nodelist = strdup("all");
604 break;
605 case MPOL_LOCAL:
606 case MPOL_DEFAULT:
607 /*
608 * Don't allow a nodelist
609 */
610 if (nodelist) {
611 log_err("fio: NO nodelist for \'local\'\n");
612 goto out;
613 }
614 break;
615 case MPOL_BIND:
616 /*
617 * Insist on a nodelist
618 */
619 if (!nodelist) {
620 log_err("fio: a nodelist is needed for \'bind\'\n");
621 goto out;
622 }
623 break;
624 }
625
626
627 /* numa_parse_nodestring() parses a character string list
628 * of nodes into a bit mask. The bit mask is allocated by
629 * numa_allocate_nodemask(), so it should be freed by
630 * numa_free_nodemask().
631 */
632 switch (td->o.numa_mem_mode) {
633 case MPOL_PREFERRED:
634 td->o.numa_mem_prefer_node = atoi(nodelist);
635 break;
636 case MPOL_INTERLEAVE:
637 case MPOL_BIND:
638 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
639 if (td->o.numa_memnodesmask == NULL) {
640 log_err("fio: numa_parse_nodestring failed\n");
641 td_verror(td, 1, "str_numa_memnodes_cb");
642 return 1;
643 }
644 break;
645 case MPOL_LOCAL:
646 case MPOL_DEFAULT:
647 default:
648 break;
649 }
650
651 td->o.numa_memmask_set = 1;
652 return 0;
653
654out:
655 return 1;
656}
657#endif
658
214e1eca
JA
659static int str_fst_cb(void *data, const char *str)
660{
661 struct thread_data *td = data;
662 char *nr = get_opt_postfix(str);
663
664 td->file_service_nr = 1;
182ec6ee 665 if (nr) {
214e1eca 666 td->file_service_nr = atoi(nr);
182ec6ee
JA
667 free(nr);
668 }
214e1eca
JA
669
670 return 0;
671}
672
67bf9823 673#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
674static int str_sfr_cb(void *data, const char *str)
675{
676 struct thread_data *td = data;
677 char *nr = get_opt_postfix(str);
678
679 td->sync_file_range_nr = 1;
680 if (nr) {
681 td->sync_file_range_nr = atoi(nr);
682 free(nr);
683 }
684
685 return 0;
686}
3ae06371 687#endif
44f29692 688
e25839d4
JA
689static int str_random_distribution_cb(void *data, const char *str)
690{
691 struct thread_data *td = data;
692 double val;
693 char *nr;
694
52c0cea3
JA
695 if (parse_dryrun())
696 return 0;
697
925fee33
JA
698 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
699 val = 1.1;
700 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
701 val = 0.2;
702 else
e25839d4
JA
703 return 0;
704
705 nr = get_opt_postfix(str);
925fee33 706 if (nr && !str_to_float(nr, &val)) {
e25839d4
JA
707 log_err("fio: random postfix parsing failed\n");
708 free(nr);
709 return 1;
710 }
711
078189c1
JA
712 free(nr);
713
18ded917
JA
714 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
715 if (val == 1.00) {
716 log_err("fio: zipf theta must different than 1.0\n");
717 return 1;
718 }
1e5324e7 719 td->o.zipf_theta.u.f = val;
18ded917 720 } else {
078189c1
JA
721 if (val <= 0.00 || val >= 1.00) {
722 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
723 return 1;
724 }
1e5324e7 725 td->o.pareto_h.u.f = val;
fcef0b35 726 }
921c766f
JA
727
728 return 0;
729}
730
8e827d35 731/*
bcbfeefa 732 * Return next name in the string. Files are separated with ':'. If the ':'
8e827d35
JA
733 * is escaped with a '\', then that ':' is part of the filename and does not
734 * indicate a new file.
735 */
bcbfeefa 736static char *get_next_name(char **ptr)
8e827d35
JA
737{
738 char *str = *ptr;
739 char *p, *start;
740
741 if (!str || !strlen(str))
742 return NULL;
743
744 start = str;
745 do {
746 /*
747 * No colon, we are done
748 */
749 p = strchr(str, ':');
750 if (!p) {
751 *ptr = NULL;
752 break;
753 }
754
755 /*
756 * We got a colon, but it's the first character. Skip and
757 * continue
758 */
759 if (p == start) {
760 str = ++start;
761 continue;
762 }
763
764 if (*(p - 1) != '\\') {
765 *p = '\0';
766 *ptr = p + 1;
767 break;
768 }
769
770 memmove(p - 1, p, strlen(p) + 1);
771 str = p;
772 } while (1);
773
774 return start;
775}
776
bcbfeefa
CE
777
778static int get_max_name_idx(char *input)
779{
780 unsigned int cur_idx;
781 char *str, *p;
782
783 p = str = strdup(input);
784 for (cur_idx = 0; ; cur_idx++)
785 if (get_next_name(&str) == NULL)
786 break;
787
788 free(p);
789 return cur_idx;
790}
791
792/*
793 * Returns the directory at the index, indexes > entires will be
794 * assigned via modulo division of the index
795 */
796int set_name_idx(char *target, char *input, int index)
797{
798 unsigned int cur_idx;
799 int len;
800 char *fname, *str, *p;
801
802 p = str = strdup(input);
803
804 index %= get_max_name_idx(input);
805 for (cur_idx = 0; cur_idx <= index; cur_idx++)
806 fname = get_next_name(&str);
807
808 len = sprintf(target, "%s/", fname);
809 free(p);
810
811 return len;
812}
813
214e1eca
JA
814static int str_filename_cb(void *data, const char *input)
815{
816 struct thread_data *td = data;
817 char *fname, *str, *p;
818
819 p = str = strdup(input);
820
821 strip_blank_front(&str);
822 strip_blank_end(str);
823
824 if (!td->files_index)
2dc1bbeb 825 td->o.nr_files = 0;
214e1eca 826
bcbfeefa 827 while ((fname = get_next_name(&str)) != NULL) {
214e1eca
JA
828 if (!strlen(fname))
829 break;
5903e7b7 830 add_file(td, fname, 0, 1);
214e1eca
JA
831 }
832
833 free(p);
834 return 0;
835}
836
bcbfeefa 837static int str_directory_cb(void *data, const char fio_unused *unused)
214e1eca
JA
838{
839 struct thread_data *td = data;
840 struct stat sb;
bcbfeefa
CE
841 char *dirname, *str, *p;
842 int ret = 0;
214e1eca 843
f9633d72
JA
844 if (parse_dryrun())
845 return 0;
846
bcbfeefa
CE
847 p = str = strdup(td->o.directory);
848 while ((dirname = get_next_name(&str)) != NULL) {
849 if (lstat(dirname, &sb) < 0) {
850 ret = errno;
921c766f 851
bcbfeefa
CE
852 log_err("fio: %s is not a directory\n", dirname);
853 td_verror(td, ret, "lstat");
854 goto out;
855 }
856 if (!S_ISDIR(sb.st_mode)) {
857 log_err("fio: %s is not a directory\n", dirname);
858 ret = 1;
859 goto out;
860 }
214e1eca
JA
861 }
862
bcbfeefa
CE
863out:
864 free(p);
865 return ret;
214e1eca
JA
866}
867
f2a2803a
JA
868static int str_lockfile_cb(void *data, const char fio_unused *str)
869{
870 struct thread_data *td = data;
871
872 if (td->files_index) {
873 log_err("fio: lockfile= option must precede filename=\n");
874 return 1;
875 }
876
877 return 0;
878}
879
214e1eca
JA
880static int str_opendir_cb(void *data, const char fio_unused *str)
881{
882 struct thread_data *td = data;
883
52c0cea3
JA
884 if (parse_dryrun())
885 return 0;
886
214e1eca 887 if (!td->files_index)
2dc1bbeb 888 td->o.nr_files = 0;
214e1eca 889
2dc1bbeb 890 return add_dir_files(td, td->o.opendir);
214e1eca
JA
891}
892
ce35b1ec
JA
893static int pattern_cb(char *pattern, unsigned int max_size,
894 const char *input, unsigned int *pattern_bytes)
90059d65 895{
0e92f873 896 long off;
ce35b1ec
JA
897 int i = 0, j = 0, len, k, base = 10;
898 uint32_t pattern_length;
3c3ed070 899 char *loc1, *loc2;
0e92f873
RR
900
901 loc1 = strstr(input, "0x");
902 loc2 = strstr(input, "0X");
903 if (loc1 || loc2)
904 base = 16;
905 off = strtol(input, NULL, base);
906 if (off != LONG_MAX || errno != ERANGE) {
907 while (off) {
ce35b1ec 908 pattern[i] = off & 0xff;
0e92f873
RR
909 off >>= 8;
910 i++;
911 }
912 } else {
913 len = strlen(input);
914 k = len - 1;
915 if (base == 16) {
916 if (loc1)
917 j = loc1 - input + 2;
918 else
919 j = loc2 - input + 2;
920 } else
921 return 1;
ce35b1ec 922 if (len - j < max_size * 2) {
0e92f873
RR
923 while (k >= j) {
924 off = converthexchartoint(input[k--]);
925 if (k >= j)
926 off += (converthexchartoint(input[k--])
927 * 16);
ce35b1ec 928 pattern[i++] = (char) off;
0e92f873
RR
929 }
930 }
931 }
efcd9dcc
SL
932
933 /*
934 * Fill the pattern all the way to the end. This greatly reduces
935 * the number of memcpy's we have to do when verifying the IO.
936 */
e078de4a 937 pattern_length = i;
ce35b1ec
JA
938 while (i > 1 && i * 2 <= max_size) {
939 memcpy(&pattern[i], &pattern[0], i);
efcd9dcc
SL
940 i *= 2;
941 }
e078de4a
JA
942
943 /*
944 * Fill remainder, if the pattern multiple ends up not being
ce35b1ec 945 * max_size.
e078de4a 946 */
ce35b1ec
JA
947 while (i > 1 && i < max_size) {
948 unsigned int b = min(pattern_length, max_size - i);
e078de4a 949
ce35b1ec 950 memcpy(&pattern[i], &pattern[0], b);
e078de4a
JA
951 i += b;
952 }
953
9a2a86d0
SL
954 if (i == 1) {
955 /*
956 * The code in verify_io_u_pattern assumes a single byte pattern
957 * fills the whole verify pattern buffer.
958 */
ce35b1ec
JA
959 memset(pattern, pattern[0], max_size);
960 }
961
962 *pattern_bytes = i;
963 return 0;
964}
965
966static int str_buffer_pattern_cb(void *data, const char *input)
967{
968 struct thread_data *td = data;
969 int ret;
970
971 ret = pattern_cb(td->o.buffer_pattern, MAX_PATTERN_SIZE, input,
972 &td->o.buffer_pattern_bytes);
973
974 if (!ret) {
975 td->o.refill_buffers = 0;
976 td->o.scramble_buffers = 0;
977 td->o.zero_buffers = 0;
9a2a86d0 978 }
efcd9dcc 979
ce35b1ec
JA
980 return ret;
981}
982
983static int str_verify_pattern_cb(void *data, const char *input)
984{
985 struct thread_data *td = data;
986 int ret;
987
988 ret = pattern_cb(td->o.verify_pattern, MAX_PATTERN_SIZE, input,
989 &td->o.verify_pattern_bytes);
efcd9dcc 990
92bf48d5
JA
991 /*
992 * VERIFY_META could already be set
993 */
ce35b1ec 994 if (!ret && td->o.verify == VERIFY_NONE)
92bf48d5 995 td->o.verify = VERIFY_PATTERN;
efcd9dcc 996
ce35b1ec 997 return ret;
90059d65 998}
214e1eca 999
993bf48b
JA
1000static int str_gtod_reduce_cb(void *data, int *il)
1001{
1002 struct thread_data *td = data;
1003 int val = *il;
1004
02af0988 1005 td->o.disable_lat = !!val;
993bf48b
JA
1006 td->o.disable_clat = !!val;
1007 td->o.disable_slat = !!val;
1008 td->o.disable_bw = !!val;
0dc1bc03 1009 td->o.clat_percentiles = !val;
993bf48b
JA
1010 if (val)
1011 td->tv_cache_mask = 63;
1012
1013 return 0;
1014}
1015
85bc833b 1016static int str_gtod_cpu_cb(void *data, long long *il)
be4ecfdf
JA
1017{
1018 struct thread_data *td = data;
1019 int val = *il;
1020
1021 td->o.gtod_cpu = val;
1022 td->o.gtod_offload = 1;
1023 return 0;
1024}
1025
7bb59102
JA
1026static int str_size_cb(void *data, unsigned long long *__val)
1027{
1028 struct thread_data *td = data;
1029 unsigned long long v = *__val;
1030
1031 if (parse_is_percent(v)) {
1032 td->o.size = 0;
1033 td->o.size_percent = -1ULL - v;
1034 } else
1035 td->o.size = v;
1036
1037 return 0;
1038}
1039
896cac2a
JA
1040static int rw_verify(struct fio_option *o, void *data)
1041{
1042 struct thread_data *td = data;
1043
1044 if (read_only && td_write(td)) {
1045 log_err("fio: job <%s> has write bit set, but fio is in"
1046 " read-only mode\n", td->o.name);
1047 return 1;
1048 }
1049
1050 return 0;
1051}
1052
276ca4f7 1053static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 1054{
276ca4f7 1055#ifndef FIO_HAVE_CPU_AFFINITY
29d43ff9
JA
1056 struct thread_data *td = data;
1057
29d43ff9
JA
1058 if (td->o.gtod_cpu) {
1059 log_err("fio: platform must support CPU affinity for"
1060 "gettimeofday() offloading\n");
1061 return 1;
1062 }
1063#endif
1064
1065 return 0;
1066}
1067
9af4a244
JA
1068/*
1069 * Option grouping
1070 */
1071static struct opt_group fio_opt_groups[] = {
1072 {
e8b0e958
JA
1073 .name = "General",
1074 .mask = FIO_OPT_C_GENERAL,
9af4a244
JA
1075 },
1076 {
e8b0e958
JA
1077 .name = "I/O",
1078 .mask = FIO_OPT_C_IO,
9af4a244
JA
1079 },
1080 {
e8b0e958
JA
1081 .name = "File",
1082 .mask = FIO_OPT_C_FILE,
9af4a244
JA
1083 },
1084 {
e8b0e958
JA
1085 .name = "Statistics",
1086 .mask = FIO_OPT_C_STAT,
9af4a244
JA
1087 },
1088 {
e8b0e958
JA
1089 .name = "Logging",
1090 .mask = FIO_OPT_C_LOG,
9af4a244 1091 },
13fca827
JA
1092 {
1093 .name = "Profiles",
1094 .mask = FIO_OPT_C_PROFILE,
1095 },
e231bbe6 1096 {
e8b0e958 1097 .name = NULL,
e231bbe6 1098 },
e8b0e958
JA
1099};
1100
1101static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1102 unsigned int inv_mask)
1103{
1104 struct opt_group *og;
1105 int i;
1106
1107 if (*mask == inv_mask || !*mask)
1108 return NULL;
1109
1110 for (i = 0; ogs[i].name; i++) {
1111 og = &ogs[i];
1112
1113 if (*mask & og->mask) {
1114 *mask &= ~(og->mask);
1115 return og;
1116 }
1117 }
1118
1119 return NULL;
1120}
1121
1122struct opt_group *opt_group_from_mask(unsigned int *mask)
1123{
1124 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1125}
1126
1127static struct opt_group fio_opt_cat_groups[] = {
3e260a46
JA
1128 {
1129 .name = "Latency profiling",
1130 .mask = FIO_OPT_G_LATPROF,
1131 },
9af4a244 1132 {
e8b0e958
JA
1133 .name = "Rate",
1134 .mask = FIO_OPT_G_RATE,
9af4a244
JA
1135 },
1136 {
e8b0e958
JA
1137 .name = "Zone",
1138 .mask = FIO_OPT_G_ZONE,
9af4a244
JA
1139 },
1140 {
e8b0e958
JA
1141 .name = "Read/write mix",
1142 .mask = FIO_OPT_G_RWMIX,
9af4a244
JA
1143 },
1144 {
1145 .name = "Verify",
1146 .mask = FIO_OPT_G_VERIFY,
1147 },
1148 {
e8b0e958
JA
1149 .name = "Trim",
1150 .mask = FIO_OPT_G_TRIM,
9af4a244
JA
1151 },
1152 {
e8b0e958
JA
1153 .name = "I/O Logging",
1154 .mask = FIO_OPT_G_IOLOG,
9af4a244
JA
1155 },
1156 {
e8b0e958
JA
1157 .name = "I/O Depth",
1158 .mask = FIO_OPT_G_IO_DEPTH,
9af4a244
JA
1159 },
1160 {
e8b0e958
JA
1161 .name = "I/O Flow",
1162 .mask = FIO_OPT_G_IO_FLOW,
9af4a244 1163 },
0626037e
JA
1164 {
1165 .name = "Description",
1166 .mask = FIO_OPT_G_DESC,
1167 },
1168 {
1169 .name = "Filename",
1170 .mask = FIO_OPT_G_FILENAME,
1171 },
1172 {
1173 .name = "General I/O",
1174 .mask = FIO_OPT_G_IO_BASIC,
1175 },
a1f6afec
JA
1176 {
1177 .name = "Cgroups",
1178 .mask = FIO_OPT_G_CGROUP,
1179 },
1180 {
1181 .name = "Runtime",
1182 .mask = FIO_OPT_G_RUNTIME,
1183 },
10860056
JA
1184 {
1185 .name = "Process",
1186 .mask = FIO_OPT_G_PROCESS,
1187 },
1188 {
1189 .name = "Job credentials / priority",
1190 .mask = FIO_OPT_G_CRED,
1191 },
1192 {
1193 .name = "Clock settings",
1194 .mask = FIO_OPT_G_CLOCK,
1195 },
3ceb458f
JA
1196 {
1197 .name = "I/O Type",
1198 .mask = FIO_OPT_G_IO_TYPE,
1199 },
1200 {
1201 .name = "I/O Thinktime",
1202 .mask = FIO_OPT_G_THINKTIME,
1203 },
1204 {
1205 .name = "Randomizations",
1206 .mask = FIO_OPT_G_RANDOM,
1207 },
1208 {
1209 .name = "I/O buffers",
1210 .mask = FIO_OPT_G_IO_BUF,
1211 },
13fca827
JA
1212 {
1213 .name = "Tiobench profile",
1214 .mask = FIO_OPT_G_TIOBENCH,
1215 },
1216
9af4a244
JA
1217 {
1218 .name = NULL,
e8b0e958 1219 }
9af4a244
JA
1220};
1221
e8b0e958 1222struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
9af4a244 1223{
e8b0e958 1224 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
9af4a244
JA
1225}
1226
214e1eca
JA
1227/*
1228 * Map of job/command line options
1229 */
9af4a244 1230struct fio_option fio_options[FIO_MAX_OPTS] = {
214e1eca
JA
1231 {
1232 .name = "description",
e8b0e958 1233 .lname = "Description of job",
214e1eca
JA
1234 .type = FIO_OPT_STR_STORE,
1235 .off1 = td_var_offset(description),
1236 .help = "Text job description",
e8b0e958 1237 .category = FIO_OPT_C_GENERAL,
0626037e 1238 .group = FIO_OPT_G_DESC,
214e1eca
JA
1239 },
1240 {
1241 .name = "name",
e8b0e958 1242 .lname = "Job name",
214e1eca
JA
1243 .type = FIO_OPT_STR_STORE,
1244 .off1 = td_var_offset(name),
1245 .help = "Name of this job",
e8b0e958 1246 .category = FIO_OPT_C_GENERAL,
0626037e 1247 .group = FIO_OPT_G_DESC,
214e1eca 1248 },
214e1eca
JA
1249 {
1250 .name = "filename",
e8b0e958 1251 .lname = "Filename(s)",
214e1eca
JA
1252 .type = FIO_OPT_STR_STORE,
1253 .off1 = td_var_offset(filename),
1254 .cb = str_filename_cb,
f0d524b0 1255 .prio = -1, /* must come after "directory" */
214e1eca 1256 .help = "File(s) to use for the workload",
e8b0e958 1257 .category = FIO_OPT_C_FILE,
0626037e 1258 .group = FIO_OPT_G_FILENAME,
214e1eca 1259 },
90fef2d1 1260 {
e8b0e958
JA
1261 .name = "directory",
1262 .lname = "Directory",
1263 .type = FIO_OPT_STR_STORE,
1264 .off1 = td_var_offset(directory),
1265 .cb = str_directory_cb,
1266 .help = "Directory to store files in",
1267 .category = FIO_OPT_C_FILE,
0626037e 1268 .group = FIO_OPT_G_FILENAME,
90fef2d1 1269 },
de98bd30
JA
1270 {
1271 .name = "filename_format",
1272 .type = FIO_OPT_STR_STORE,
1273 .off1 = td_var_offset(filename_format),
1274 .prio = -1, /* must come after "directory" */
1275 .help = "Override default $jobname.$jobnum.$filenum naming",
1276 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1277 .category = FIO_OPT_C_FILE,
1278 .group = FIO_OPT_G_FILENAME,
ad705bcb 1279 },
29c1349f
JA
1280 {
1281 .name = "lockfile",
e8b0e958 1282 .lname = "Lockfile",
4d4e80f2 1283 .type = FIO_OPT_STR,
4d4e80f2 1284 .off1 = td_var_offset(file_lock_mode),
29c1349f 1285 .help = "Lock file when doing IO to it",
bc6a0a5d 1286 .prio = 1,
29c1349f 1287 .parent = "filename",
d71c154c 1288 .hide = 0,
4d4e80f2 1289 .def = "none",
f2a2803a 1290 .cb = str_lockfile_cb,
e8b0e958 1291 .category = FIO_OPT_C_FILE,
0626037e 1292 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1293 .posval = {
1294 { .ival = "none",
1295 .oval = FILE_LOCK_NONE,
1296 .help = "No file locking",
1297 },
1298 { .ival = "exclusive",
1299 .oval = FILE_LOCK_EXCLUSIVE,
1300 .help = "Exclusive file lock",
1301 },
1302 {
1303 .ival = "readwrite",
1304 .oval = FILE_LOCK_READWRITE,
1305 .help = "Read vs write lock",
1306 },
1307 },
29c1349f 1308 },
214e1eca
JA
1309 {
1310 .name = "opendir",
e8b0e958 1311 .lname = "Open directory",
214e1eca
JA
1312 .type = FIO_OPT_STR_STORE,
1313 .off1 = td_var_offset(opendir),
1314 .cb = str_opendir_cb,
1315 .help = "Recursively add files from this directory and down",
e8b0e958 1316 .category = FIO_OPT_C_FILE,
0626037e 1317 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1318 },
1319 {
1320 .name = "rw",
e8b0e958 1321 .lname = "Read/write",
d3aad8f2 1322 .alias = "readwrite",
214e1eca 1323 .type = FIO_OPT_STR,
211097b2 1324 .cb = str_rw_cb,
214e1eca
JA
1325 .off1 = td_var_offset(td_ddir),
1326 .help = "IO direction",
1327 .def = "read",
896cac2a 1328 .verify = rw_verify,
e8b0e958 1329 .category = FIO_OPT_C_IO,
0626037e 1330 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1331 .posval = {
1332 { .ival = "read",
1333 .oval = TD_DDIR_READ,
1334 .help = "Sequential read",
1335 },
1336 { .ival = "write",
1337 .oval = TD_DDIR_WRITE,
1338 .help = "Sequential write",
1339 },
6eaf09d6
SL
1340 { .ival = "trim",
1341 .oval = TD_DDIR_TRIM,
1342 .help = "Sequential trim",
1343 },
214e1eca
JA
1344 { .ival = "randread",
1345 .oval = TD_DDIR_RANDREAD,
1346 .help = "Random read",
1347 },
1348 { .ival = "randwrite",
1349 .oval = TD_DDIR_RANDWRITE,
1350 .help = "Random write",
1351 },
6eaf09d6
SL
1352 { .ival = "randtrim",
1353 .oval = TD_DDIR_RANDTRIM,
1354 .help = "Random trim",
1355 },
214e1eca
JA
1356 { .ival = "rw",
1357 .oval = TD_DDIR_RW,
1358 .help = "Sequential read and write mix",
1359 },
10b023db
JA
1360 { .ival = "readwrite",
1361 .oval = TD_DDIR_RW,
1362 .help = "Sequential read and write mix",
1363 },
214e1eca
JA
1364 { .ival = "randrw",
1365 .oval = TD_DDIR_RANDRW,
1366 .help = "Random read and write mix"
1367 },
1368 },
1369 },
38dad62d
JA
1370 {
1371 .name = "rw_sequencer",
e8b0e958 1372 .lname = "RW Sequencer",
38dad62d
JA
1373 .type = FIO_OPT_STR,
1374 .off1 = td_var_offset(rw_seq),
1375 .help = "IO offset generator modifier",
1376 .def = "sequential",
e8b0e958 1377 .category = FIO_OPT_C_IO,
0626037e 1378 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1379 .posval = {
1380 { .ival = "sequential",
1381 .oval = RW_SEQ_SEQ,
1382 .help = "Generate sequential offsets",
1383 },
1384 { .ival = "identical",
1385 .oval = RW_SEQ_IDENT,
1386 .help = "Generate identical offsets",
1387 },
1388 },
1389 },
1390
214e1eca
JA
1391 {
1392 .name = "ioengine",
e8b0e958 1393 .lname = "IO Engine",
214e1eca
JA
1394 .type = FIO_OPT_STR_STORE,
1395 .off1 = td_var_offset(ioengine),
1396 .help = "IO engine to use",
58483fa4 1397 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1398 .category = FIO_OPT_C_IO,
0626037e 1399 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1400 .posval = {
1401 { .ival = "sync",
1402 .help = "Use read/write",
1403 },
a31041ea 1404 { .ival = "psync",
1405 .help = "Use pread/pwrite",
1406 },
1d2af02a 1407 { .ival = "vsync",
03e20d68 1408 .help = "Use readv/writev",
1d2af02a 1409 },
07fc0acd
JA
1410#ifdef CONFIG_PWRITEV
1411 { .ival = "pvsync",
1412 .help = "Use preadv/pwritev",
1413 },
1414#endif
67bf9823 1415#ifdef CONFIG_LIBAIO
214e1eca
JA
1416 { .ival = "libaio",
1417 .help = "Linux native asynchronous IO",
1418 },
1419#endif
67bf9823 1420#ifdef CONFIG_POSIXAIO
214e1eca
JA
1421 { .ival = "posixaio",
1422 .help = "POSIX asynchronous IO",
1423 },
417f0068 1424#endif
997843cb 1425#ifdef CONFIG_SOLARISAIO
417f0068
JA
1426 { .ival = "solarisaio",
1427 .help = "Solaris native asynchronous IO",
1428 },
214e1eca 1429#endif
4700b234 1430#ifdef CONFIG_WINDOWSAIO
03e20d68 1431 { .ival = "windowsaio",
3be80071 1432 .help = "Windows native asynchronous IO"
de890a1e 1433 },
fc5c0345
DG
1434#endif
1435#ifdef CONFIG_RBD
1436 { .ival = "rbd",
1437 .help = "Rados Block Device asynchronous IO"
1438 },
3be80071 1439#endif
214e1eca 1440 { .ival = "mmap",
03e20d68 1441 .help = "Memory mapped IO"
214e1eca 1442 },
67bf9823 1443#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1444 { .ival = "splice",
1445 .help = "splice/vmsplice based IO",
1446 },
9cce02e8
JA
1447 { .ival = "netsplice",
1448 .help = "splice/vmsplice to/from the network",
1449 },
214e1eca
JA
1450#endif
1451#ifdef FIO_HAVE_SGIO
1452 { .ival = "sg",
1453 .help = "SCSI generic v3 IO",
1454 },
1455#endif
1456 { .ival = "null",
1457 .help = "Testing engine (no data transfer)",
1458 },
1459 { .ival = "net",
1460 .help = "Network IO",
1461 },
214e1eca 1462 { .ival = "cpuio",
03e20d68 1463 .help = "CPU cycle burner engine",
214e1eca 1464 },
67bf9823 1465#ifdef CONFIG_GUASI
b8c82a46
JA
1466 { .ival = "guasi",
1467 .help = "GUASI IO engine",
1468 },
79a43187
JA
1469#endif
1470#ifdef FIO_HAVE_BINJECT
1471 { .ival = "binject",
1472 .help = "binject direct inject block engine",
1473 },
21b8aee8 1474#endif
67bf9823 1475#ifdef CONFIG_RDMA
21b8aee8 1476 { .ival = "rdma",
1477 .help = "RDMA IO engine",
1478 },
8200b8c7 1479#endif
67bf9823 1480#ifdef CONFIG_FUSION_AW
8200b8c7
JA
1481 { .ival = "fusion-aw-sync",
1482 .help = "Fusion-io atomic write engine",
1483 },
1ecc95ca 1484#endif
997843cb 1485#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1486 { .ival = "e4defrag",
1487 .help = "ext4 defrag engine",
1488 },
1489#endif
997843cb 1490#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1491 { .ival = "falloc",
1492 .help = "fallocate() file based engine",
1493 },
b8c82a46 1494#endif
214e1eca
JA
1495 { .ival = "external",
1496 .help = "Load external engine (append name)",
1497 },
1498 },
1499 },
1500 {
1501 .name = "iodepth",
e8b0e958 1502 .lname = "IO Depth",
214e1eca
JA
1503 .type = FIO_OPT_INT,
1504 .off1 = td_var_offset(iodepth),
03e20d68 1505 .help = "Number of IO buffers to keep in flight",
757aff4f 1506 .minval = 1,
20eb06bd 1507 .interval = 1,
214e1eca 1508 .def = "1",
e8b0e958 1509 .category = FIO_OPT_C_IO,
0626037e 1510 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1511 },
1512 {
1513 .name = "iodepth_batch",
e8b0e958 1514 .lname = "IO Depth batch",
4950421a 1515 .alias = "iodepth_batch_submit",
214e1eca
JA
1516 .type = FIO_OPT_INT,
1517 .off1 = td_var_offset(iodepth_batch),
d65db441 1518 .help = "Number of IO buffers to submit in one go",
afdf9352 1519 .parent = "iodepth",
d71c154c 1520 .hide = 1,
a2e6f8ac 1521 .minval = 1,
20eb06bd 1522 .interval = 1,
a2e6f8ac 1523 .def = "1",
e8b0e958 1524 .category = FIO_OPT_C_IO,
0626037e 1525 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1526 },
1527 {
1528 .name = "iodepth_batch_complete",
e8b0e958 1529 .lname = "IO Depth batch complete",
4950421a
JA
1530 .type = FIO_OPT_INT,
1531 .off1 = td_var_offset(iodepth_batch_complete),
d65db441 1532 .help = "Number of IO buffers to retrieve in one go",
4950421a 1533 .parent = "iodepth",
d71c154c 1534 .hide = 1,
4950421a 1535 .minval = 0,
20eb06bd 1536 .interval = 1,
4950421a 1537 .def = "1",
e8b0e958 1538 .category = FIO_OPT_C_IO,
0626037e 1539 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1540 },
1541 {
1542 .name = "iodepth_low",
e8b0e958 1543 .lname = "IO Depth batch low",
214e1eca
JA
1544 .type = FIO_OPT_INT,
1545 .off1 = td_var_offset(iodepth_low),
1546 .help = "Low water mark for queuing depth",
afdf9352 1547 .parent = "iodepth",
d71c154c 1548 .hide = 1,
20eb06bd 1549 .interval = 1,
e8b0e958 1550 .category = FIO_OPT_C_IO,
0626037e 1551 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1552 },
1553 {
1554 .name = "size",
e8b0e958 1555 .lname = "Size",
214e1eca 1556 .type = FIO_OPT_STR_VAL,
7bb59102 1557 .cb = str_size_cb,
214e1eca 1558 .help = "Total size of device or files",
20eb06bd 1559 .interval = 1024 * 1024,
e8b0e958
JA
1560 .category = FIO_OPT_C_IO,
1561 .group = FIO_OPT_G_INVALID,
214e1eca 1562 },
aa31f1f1
SL
1563 {
1564 .name = "fill_device",
e8b0e958 1565 .lname = "Fill device",
74586c1e 1566 .alias = "fill_fs",
aa31f1f1
SL
1567 .type = FIO_OPT_BOOL,
1568 .off1 = td_var_offset(fill_device),
1569 .help = "Write until an ENOSPC error occurs",
1570 .def = "0",
e8b0e958
JA
1571 .category = FIO_OPT_C_FILE,
1572 .group = FIO_OPT_G_INVALID,
aa31f1f1 1573 },
214e1eca
JA
1574 {
1575 .name = "filesize",
e8b0e958 1576 .lname = "File size",
214e1eca
JA
1577 .type = FIO_OPT_STR_VAL,
1578 .off1 = td_var_offset(file_size_low),
1579 .off2 = td_var_offset(file_size_high),
c3edbdba 1580 .minval = 1,
214e1eca 1581 .help = "Size of individual files",
20eb06bd 1582 .interval = 1024 * 1024,
e8b0e958
JA
1583 .category = FIO_OPT_C_FILE,
1584 .group = FIO_OPT_G_INVALID,
214e1eca 1585 },
67a1000f
JA
1586 {
1587 .name = "offset",
e8b0e958 1588 .lname = "IO offset",
67a1000f
JA
1589 .alias = "fileoffset",
1590 .type = FIO_OPT_STR_VAL,
1591 .off1 = td_var_offset(start_offset),
1592 .help = "Start IO from this offset",
1593 .def = "0",
20eb06bd 1594 .interval = 1024 * 1024,
e8b0e958
JA
1595 .category = FIO_OPT_C_IO,
1596 .group = FIO_OPT_G_INVALID,
67a1000f 1597 },
2d7cd868
JA
1598 {
1599 .name = "offset_increment",
e8b0e958 1600 .lname = "IO offset increment",
2d7cd868
JA
1601 .type = FIO_OPT_STR_VAL,
1602 .off1 = td_var_offset(offset_increment),
1603 .help = "What is the increment from one offset to the next",
1604 .parent = "offset",
d71c154c 1605 .hide = 1,
2d7cd868 1606 .def = "0",
20eb06bd 1607 .interval = 1024 * 1024,
e8b0e958
JA
1608 .category = FIO_OPT_C_IO,
1609 .group = FIO_OPT_G_INVALID,
2d7cd868 1610 },
ddf24e42
JA
1611 {
1612 .name = "number_ios",
1613 .lname = "Number of IOs to perform",
1614 .type = FIO_OPT_STR_VAL,
1615 .off1 = td_var_offset(number_ios),
1616 .help = "Force job completion of this number of IOs",
1617 .def = "0",
1618 .category = FIO_OPT_C_IO,
1619 .group = FIO_OPT_G_INVALID,
1620 },
214e1eca
JA
1621 {
1622 .name = "bs",
e8b0e958 1623 .lname = "Block size",
d3aad8f2 1624 .alias = "blocksize",
e01b22b8 1625 .type = FIO_OPT_INT,
214e1eca
JA
1626 .off1 = td_var_offset(bs[DDIR_READ]),
1627 .off2 = td_var_offset(bs[DDIR_WRITE]),
6eaf09d6 1628 .off3 = td_var_offset(bs[DDIR_TRIM]),
c3edbdba 1629 .minval = 1,
214e1eca
JA
1630 .help = "Block size unit",
1631 .def = "4k",
67a1000f 1632 .parent = "rw",
d71c154c 1633 .hide = 1,
20eb06bd 1634 .interval = 512,
e8b0e958
JA
1635 .category = FIO_OPT_C_IO,
1636 .group = FIO_OPT_G_INVALID,
214e1eca 1637 },
2b7a01d0
JA
1638 {
1639 .name = "ba",
e8b0e958 1640 .lname = "Block size align",
2b7a01d0 1641 .alias = "blockalign",
e01b22b8 1642 .type = FIO_OPT_INT,
2b7a01d0
JA
1643 .off1 = td_var_offset(ba[DDIR_READ]),
1644 .off2 = td_var_offset(ba[DDIR_WRITE]),
6eaf09d6 1645 .off3 = td_var_offset(ba[DDIR_TRIM]),
2b7a01d0
JA
1646 .minval = 1,
1647 .help = "IO block offset alignment",
1648 .parent = "rw",
d71c154c 1649 .hide = 1,
20eb06bd 1650 .interval = 512,
e8b0e958
JA
1651 .category = FIO_OPT_C_IO,
1652 .group = FIO_OPT_G_INVALID,
2b7a01d0 1653 },
214e1eca
JA
1654 {
1655 .name = "bsrange",
e8b0e958 1656 .lname = "Block size range",
d3aad8f2 1657 .alias = "blocksize_range",
214e1eca
JA
1658 .type = FIO_OPT_RANGE,
1659 .off1 = td_var_offset(min_bs[DDIR_READ]),
1660 .off2 = td_var_offset(max_bs[DDIR_READ]),
1661 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1662 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
6eaf09d6
SL
1663 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1664 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
c3edbdba 1665 .minval = 1,
214e1eca 1666 .help = "Set block size range (in more detail than bs)",
67a1000f 1667 .parent = "rw",
d71c154c 1668 .hide = 1,
20eb06bd 1669 .interval = 4096,
e8b0e958
JA
1670 .category = FIO_OPT_C_IO,
1671 .group = FIO_OPT_G_INVALID,
214e1eca 1672 },
564ca972
JA
1673 {
1674 .name = "bssplit",
e8b0e958 1675 .lname = "Block size split",
564ca972
JA
1676 .type = FIO_OPT_STR,
1677 .cb = str_bssplit_cb,
1678 .help = "Set a specific mix of block sizes",
1679 .parent = "rw",
d71c154c 1680 .hide = 1,
e8b0e958
JA
1681 .category = FIO_OPT_C_IO,
1682 .group = FIO_OPT_G_INVALID,
564ca972 1683 },
214e1eca
JA
1684 {
1685 .name = "bs_unaligned",
e8b0e958 1686 .lname = "Block size unaligned",
d3aad8f2 1687 .alias = "blocksize_unaligned",
214e1eca
JA
1688 .type = FIO_OPT_STR_SET,
1689 .off1 = td_var_offset(bs_unaligned),
1690 .help = "Don't sector align IO buffer sizes",
67a1000f 1691 .parent = "rw",
d71c154c 1692 .hide = 1,
e8b0e958
JA
1693 .category = FIO_OPT_C_IO,
1694 .group = FIO_OPT_G_INVALID,
214e1eca 1695 },
6aca9b3d
JA
1696 {
1697 .name = "bs_is_seq_rand",
1698 .lname = "Block size division is seq/random (not read/write)",
1699 .type = FIO_OPT_BOOL,
1700 .off1 = td_var_offset(bs_is_seq_rand),
1701 .help = "Consider any blocksize setting to be sequential,ramdom",
1702 .def = "0",
1703 .parent = "blocksize",
1704 .category = FIO_OPT_C_IO,
1705 .group = FIO_OPT_G_INVALID,
1706 },
214e1eca
JA
1707 {
1708 .name = "randrepeat",
e8b0e958 1709 .lname = "Random repeatable",
214e1eca
JA
1710 .type = FIO_OPT_BOOL,
1711 .off1 = td_var_offset(rand_repeatable),
1712 .help = "Use repeatable random IO pattern",
1713 .def = "1",
67a1000f 1714 .parent = "rw",
d71c154c 1715 .hide = 1,
e8b0e958 1716 .category = FIO_OPT_C_IO,
3ceb458f 1717 .group = FIO_OPT_G_RANDOM,
214e1eca 1718 },
04778baf
JA
1719 {
1720 .name = "randseed",
1721 .lname = "The random generator seed",
363cffa7 1722 .type = FIO_OPT_STR_VAL,
04778baf
JA
1723 .off1 = td_var_offset(rand_seed),
1724 .help = "Set the random generator seed value",
1725 .parent = "rw",
1726 .category = FIO_OPT_C_IO,
1727 .group = FIO_OPT_G_RANDOM,
1728 },
2615cc4b
JA
1729 {
1730 .name = "use_os_rand",
e8b0e958 1731 .lname = "Use OS random",
2615cc4b
JA
1732 .type = FIO_OPT_BOOL,
1733 .off1 = td_var_offset(use_os_rand),
1734 .help = "Set to use OS random generator",
1735 .def = "0",
1736 .parent = "rw",
d71c154c 1737 .hide = 1,
e8b0e958 1738 .category = FIO_OPT_C_IO,
3ceb458f 1739 .group = FIO_OPT_G_RANDOM,
2615cc4b 1740 },
214e1eca
JA
1741 {
1742 .name = "norandommap",
e8b0e958 1743 .lname = "No randommap",
214e1eca
JA
1744 .type = FIO_OPT_STR_SET,
1745 .off1 = td_var_offset(norandommap),
1746 .help = "Accept potential duplicate random blocks",
67a1000f 1747 .parent = "rw",
d71c154c 1748 .hide = 1,
b2452a43 1749 .hide_on_set = 1,
e8b0e958 1750 .category = FIO_OPT_C_IO,
3ceb458f 1751 .group = FIO_OPT_G_RANDOM,
214e1eca 1752 },
2b386d25
JA
1753 {
1754 .name = "softrandommap",
e8b0e958 1755 .lname = "Soft randommap",
2b386d25
JA
1756 .type = FIO_OPT_BOOL,
1757 .off1 = td_var_offset(softrandommap),
f66ab3c8 1758 .help = "Set norandommap if randommap allocation fails",
2b386d25 1759 .parent = "norandommap",
d71c154c 1760 .hide = 1,
2b386d25 1761 .def = "0",
e8b0e958 1762 .category = FIO_OPT_C_IO,
3ceb458f 1763 .group = FIO_OPT_G_RANDOM,
2b386d25 1764 },
8055e41d
JA
1765 {
1766 .name = "random_generator",
1767 .type = FIO_OPT_STR,
1768 .off1 = td_var_offset(random_generator),
1769 .help = "Type of random number generator to use",
1770 .def = "tausworthe",
1771 .posval = {
1772 { .ival = "tausworthe",
1773 .oval = FIO_RAND_GEN_TAUSWORTHE,
1774 .help = "Strong Tausworthe generator",
1775 },
1776 { .ival = "lfsr",
1777 .oval = FIO_RAND_GEN_LFSR,
1778 .help = "Variable length LFSR",
1779 },
1780 },
48107598
JA
1781 .category = FIO_OPT_C_IO,
1782 .group = FIO_OPT_G_RANDOM,
8055e41d 1783 },
e25839d4
JA
1784 {
1785 .name = "random_distribution",
1786 .type = FIO_OPT_STR,
1787 .off1 = td_var_offset(random_distribution),
1788 .cb = str_random_distribution_cb,
1789 .help = "Random offset distribution generator",
1790 .def = "random",
1791 .posval = {
1792 { .ival = "random",
1793 .oval = FIO_RAND_DIST_RANDOM,
1794 .help = "Completely random",
1795 },
1796 { .ival = "zipf",
1797 .oval = FIO_RAND_DIST_ZIPF,
1798 .help = "Zipf distribution",
1799 },
925fee33
JA
1800 { .ival = "pareto",
1801 .oval = FIO_RAND_DIST_PARETO,
1802 .help = "Pareto distribution",
1803 },
e25839d4 1804 },
48107598
JA
1805 .category = FIO_OPT_C_IO,
1806 .group = FIO_OPT_G_RANDOM,
e25839d4 1807 },
211c9b89
JA
1808 {
1809 .name = "percentage_random",
1810 .lname = "Percentage Random",
1811 .type = FIO_OPT_INT,
d9472271
JA
1812 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1813 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1814 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
211c9b89
JA
1815 .maxval = 100,
1816 .help = "Percentage of seq/random mix that should be random",
d9472271 1817 .def = "100,100,100",
211c9b89
JA
1818 .interval = 5,
1819 .inverse = "percentage_sequential",
1820 .category = FIO_OPT_C_IO,
1821 .group = FIO_OPT_G_RANDOM,
1822 },
1823 {
1824 .name = "percentage_sequential",
1825 .lname = "Percentage Sequential",
d9472271 1826 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
1827 .category = FIO_OPT_C_IO,
1828 .group = FIO_OPT_G_RANDOM,
1829 },
56e2a5fc
CE
1830 {
1831 .name = "allrandrepeat",
1832 .type = FIO_OPT_BOOL,
1833 .off1 = td_var_offset(allrand_repeatable),
1834 .help = "Use repeatable random numbers for everything",
1835 .def = "0",
a869d9c6
JA
1836 .category = FIO_OPT_C_IO,
1837 .group = FIO_OPT_G_RANDOM,
56e2a5fc 1838 },
214e1eca
JA
1839 {
1840 .name = "nrfiles",
e8b0e958 1841 .lname = "Number of files",
d7c8be03 1842 .alias = "nr_files",
214e1eca
JA
1843 .type = FIO_OPT_INT,
1844 .off1 = td_var_offset(nr_files),
1845 .help = "Split job workload between this number of files",
1846 .def = "1",
20eb06bd 1847 .interval = 1,
e8b0e958
JA
1848 .category = FIO_OPT_C_FILE,
1849 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1850 },
1851 {
1852 .name = "openfiles",
e8b0e958 1853 .lname = "Number of open files",
214e1eca
JA
1854 .type = FIO_OPT_INT,
1855 .off1 = td_var_offset(open_files),
1856 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1857 .category = FIO_OPT_C_FILE,
1858 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1859 },
1860 {
1861 .name = "file_service_type",
e8b0e958 1862 .lname = "File service type",
214e1eca
JA
1863 .type = FIO_OPT_STR,
1864 .cb = str_fst_cb,
1865 .off1 = td_var_offset(file_service_type),
1866 .help = "How to select which file to service next",
1867 .def = "roundrobin",
e8b0e958
JA
1868 .category = FIO_OPT_C_FILE,
1869 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1870 .posval = {
1871 { .ival = "random",
1872 .oval = FIO_FSERVICE_RANDOM,
1873 .help = "Choose a file at random",
1874 },
1875 { .ival = "roundrobin",
1876 .oval = FIO_FSERVICE_RR,
1877 .help = "Round robin select files",
1878 },
a086c257
JA
1879 { .ival = "sequential",
1880 .oval = FIO_FSERVICE_SEQ,
1881 .help = "Finish one file before moving to the next",
1882 },
214e1eca 1883 },
67a1000f 1884 .parent = "nrfiles",
d71c154c 1885 .hide = 1,
67a1000f 1886 },
97ac992c 1887#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
1888 {
1889 .name = "fallocate",
e8b0e958 1890 .lname = "Fallocate",
a596f047
EG
1891 .type = FIO_OPT_STR,
1892 .off1 = td_var_offset(fallocate_mode),
1893 .help = "Whether pre-allocation is performed when laying out files",
1894 .def = "posix",
e8b0e958
JA
1895 .category = FIO_OPT_C_FILE,
1896 .group = FIO_OPT_G_INVALID,
a596f047
EG
1897 .posval = {
1898 { .ival = "none",
1899 .oval = FIO_FALLOCATE_NONE,
1900 .help = "Do not pre-allocate space",
1901 },
1902 { .ival = "posix",
1903 .oval = FIO_FALLOCATE_POSIX,
1904 .help = "Use posix_fallocate()",
1905 },
97ac992c 1906#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
1907 { .ival = "keep",
1908 .oval = FIO_FALLOCATE_KEEP_SIZE,
1909 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1910 },
7bc8c2cf 1911#endif
a596f047
EG
1912 /* Compatibility with former boolean values */
1913 { .ival = "0",
1914 .oval = FIO_FALLOCATE_NONE,
1915 .help = "Alias for 'none'",
1916 },
1917 { .ival = "1",
1918 .oval = FIO_FALLOCATE_POSIX,
1919 .help = "Alias for 'posix'",
1920 },
1921 },
1922 },
97ac992c 1923#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
1924 {
1925 .name = "fadvise_hint",
e8b0e958 1926 .lname = "Fadvise hint",
67a1000f
JA
1927 .type = FIO_OPT_BOOL,
1928 .off1 = td_var_offset(fadvise_hint),
1929 .help = "Use fadvise() to advise the kernel on IO pattern",
1930 .def = "1",
e8b0e958
JA
1931 .category = FIO_OPT_C_FILE,
1932 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1933 },
1934 {
1935 .name = "fsync",
e8b0e958 1936 .lname = "Fsync",
214e1eca
JA
1937 .type = FIO_OPT_INT,
1938 .off1 = td_var_offset(fsync_blocks),
1939 .help = "Issue fsync for writes every given number of blocks",
1940 .def = "0",
20eb06bd 1941 .interval = 1,
e8b0e958
JA
1942 .category = FIO_OPT_C_FILE,
1943 .group = FIO_OPT_G_INVALID,
214e1eca 1944 },
5f9099ea
JA
1945 {
1946 .name = "fdatasync",
e8b0e958 1947 .lname = "Fdatasync",
5f9099ea
JA
1948 .type = FIO_OPT_INT,
1949 .off1 = td_var_offset(fdatasync_blocks),
1950 .help = "Issue fdatasync for writes every given number of blocks",
1951 .def = "0",
20eb06bd 1952 .interval = 1,
e8b0e958
JA
1953 .category = FIO_OPT_C_FILE,
1954 .group = FIO_OPT_G_INVALID,
5f9099ea 1955 },
1ef2b6be
JA
1956 {
1957 .name = "write_barrier",
e8b0e958 1958 .lname = "Write barrier",
1ef2b6be
JA
1959 .type = FIO_OPT_INT,
1960 .off1 = td_var_offset(barrier_blocks),
1961 .help = "Make every Nth write a barrier write",
1962 .def = "0",
20eb06bd 1963 .interval = 1,
e8b0e958
JA
1964 .category = FIO_OPT_C_IO,
1965 .group = FIO_OPT_G_INVALID,
1ef2b6be 1966 },
67bf9823 1967#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
1968 {
1969 .name = "sync_file_range",
e8b0e958 1970 .lname = "Sync file range",
44f29692
JA
1971 .posval = {
1972 { .ival = "wait_before",
1973 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1974 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 1975 .orval = 1,
44f29692
JA
1976 },
1977 { .ival = "write",
1978 .oval = SYNC_FILE_RANGE_WRITE,
1979 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 1980 .orval = 1,
44f29692
JA
1981 },
1982 {
1983 .ival = "wait_after",
1984 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1985 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 1986 .orval = 1,
44f29692
JA
1987 },
1988 },
3843deb3 1989 .type = FIO_OPT_STR_MULTI,
44f29692
JA
1990 .cb = str_sfr_cb,
1991 .off1 = td_var_offset(sync_file_range),
1992 .help = "Use sync_file_range()",
e8b0e958
JA
1993 .category = FIO_OPT_C_FILE,
1994 .group = FIO_OPT_G_INVALID,
44f29692
JA
1995 },
1996#endif
214e1eca
JA
1997 {
1998 .name = "direct",
e8b0e958 1999 .lname = "Direct I/O",
214e1eca
JA
2000 .type = FIO_OPT_BOOL,
2001 .off1 = td_var_offset(odirect),
2002 .help = "Use O_DIRECT IO (negates buffered)",
2003 .def = "0",
a01a1bc5 2004 .inverse = "buffered",
e8b0e958 2005 .category = FIO_OPT_C_IO,
3ceb458f 2006 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2007 },
d01612f3
CM
2008 {
2009 .name = "atomic",
2010 .lname = "Atomic I/O",
2011 .type = FIO_OPT_BOOL,
2012 .off1 = td_var_offset(oatomic),
2013 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2014 .def = "0",
2015 .category = FIO_OPT_C_IO,
2016 .group = FIO_OPT_G_IO_TYPE,
2017 },
214e1eca
JA
2018 {
2019 .name = "buffered",
e8b0e958 2020 .lname = "Buffered I/O",
214e1eca
JA
2021 .type = FIO_OPT_BOOL,
2022 .off1 = td_var_offset(odirect),
2023 .neg = 1,
2024 .help = "Use buffered IO (negates direct)",
2025 .def = "1",
a01a1bc5 2026 .inverse = "direct",
e8b0e958 2027 .category = FIO_OPT_C_IO,
3ceb458f 2028 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2029 },
2030 {
2031 .name = "overwrite",
e8b0e958 2032 .lname = "Overwrite",
214e1eca
JA
2033 .type = FIO_OPT_BOOL,
2034 .off1 = td_var_offset(overwrite),
2035 .help = "When writing, set whether to overwrite current data",
2036 .def = "0",
e8b0e958
JA
2037 .category = FIO_OPT_C_FILE,
2038 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2039 },
2040 {
2041 .name = "loops",
e8b0e958 2042 .lname = "Loops",
214e1eca
JA
2043 .type = FIO_OPT_INT,
2044 .off1 = td_var_offset(loops),
2045 .help = "Number of times to run the job",
2046 .def = "1",
20eb06bd 2047 .interval = 1,
e8b0e958 2048 .category = FIO_OPT_C_GENERAL,
a1f6afec 2049 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2050 },
2051 {
2052 .name = "numjobs",
e8b0e958 2053 .lname = "Number of jobs",
214e1eca
JA
2054 .type = FIO_OPT_INT,
2055 .off1 = td_var_offset(numjobs),
2056 .help = "Duplicate this job this many times",
2057 .def = "1",
20eb06bd 2058 .interval = 1,
e8b0e958 2059 .category = FIO_OPT_C_GENERAL,
a1f6afec 2060 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2061 },
2062 {
2063 .name = "startdelay",
e8b0e958 2064 .lname = "Start delay",
a5737c93 2065 .type = FIO_OPT_STR_VAL_TIME,
214e1eca 2066 .off1 = td_var_offset(start_delay),
23ed19b0 2067 .off2 = td_var_offset(start_delay_high),
214e1eca
JA
2068 .help = "Only start job when this period has passed",
2069 .def = "0",
0de5b26f 2070 .is_seconds = 1,
e8b0e958 2071 .category = FIO_OPT_C_GENERAL,
a1f6afec 2072 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2073 },
2074 {
2075 .name = "runtime",
e8b0e958 2076 .lname = "Runtime",
214e1eca
JA
2077 .alias = "timeout",
2078 .type = FIO_OPT_STR_VAL_TIME,
2079 .off1 = td_var_offset(timeout),
2080 .help = "Stop workload when this amount of time has passed",
2081 .def = "0",
0de5b26f 2082 .is_seconds = 1,
e8b0e958 2083 .category = FIO_OPT_C_GENERAL,
a1f6afec 2084 .group = FIO_OPT_G_RUNTIME,
214e1eca 2085 },
cf4464ca
JA
2086 {
2087 .name = "time_based",
e8b0e958 2088 .lname = "Time based",
cf4464ca
JA
2089 .type = FIO_OPT_STR_SET,
2090 .off1 = td_var_offset(time_based),
2091 .help = "Keep running until runtime/timeout is met",
e8b0e958 2092 .category = FIO_OPT_C_GENERAL,
a1f6afec 2093 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2094 },
62167762
JC
2095 {
2096 .name = "verify_only",
2097 .lname = "Verify only",
2098 .type = FIO_OPT_STR_SET,
2099 .off1 = td_var_offset(verify_only),
2100 .help = "Verifies previously written data is still valid",
2101 .category = FIO_OPT_C_GENERAL,
2102 .group = FIO_OPT_G_RUNTIME,
2103 },
721938ae
JA
2104 {
2105 .name = "ramp_time",
e8b0e958 2106 .lname = "Ramp time",
721938ae
JA
2107 .type = FIO_OPT_STR_VAL_TIME,
2108 .off1 = td_var_offset(ramp_time),
2109 .help = "Ramp up time before measuring performance",
0de5b26f 2110 .is_seconds = 1,
e8b0e958 2111 .category = FIO_OPT_C_GENERAL,
a1f6afec 2112 .group = FIO_OPT_G_RUNTIME,
721938ae 2113 },
c223da83
JA
2114 {
2115 .name = "clocksource",
e8b0e958 2116 .lname = "Clock source",
c223da83
JA
2117 .type = FIO_OPT_STR,
2118 .cb = fio_clock_source_cb,
2119 .off1 = td_var_offset(clocksource),
2120 .help = "What type of timing source to use",
e8b0e958 2121 .category = FIO_OPT_C_GENERAL,
10860056 2122 .group = FIO_OPT_G_CLOCK,
c223da83 2123 .posval = {
67bf9823 2124#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2125 { .ival = "gettimeofday",
2126 .oval = CS_GTOD,
2127 .help = "Use gettimeofday(2) for timing",
2128 },
67bf9823
JA
2129#endif
2130#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2131 { .ival = "clock_gettime",
2132 .oval = CS_CGETTIME,
2133 .help = "Use clock_gettime(2) for timing",
2134 },
67bf9823 2135#endif
c223da83
JA
2136#ifdef ARCH_HAVE_CPU_CLOCK
2137 { .ival = "cpu",
2138 .oval = CS_CPUCLOCK,
2139 .help = "Use CPU private clock",
2140 },
2141#endif
2142 },
2143 },
214e1eca
JA
2144 {
2145 .name = "mem",
d3aad8f2 2146 .alias = "iomem",
e8b0e958 2147 .lname = "I/O Memory",
214e1eca
JA
2148 .type = FIO_OPT_STR,
2149 .cb = str_mem_cb,
2150 .off1 = td_var_offset(mem_type),
2151 .help = "Backing type for IO buffers",
2152 .def = "malloc",
e8b0e958
JA
2153 .category = FIO_OPT_C_IO,
2154 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2155 .posval = {
2156 { .ival = "malloc",
2157 .oval = MEM_MALLOC,
2158 .help = "Use malloc(3) for IO buffers",
2159 },
37c8cdfe
JA
2160 { .ival = "shm",
2161 .oval = MEM_SHM,
2162 .help = "Use shared memory segments for IO buffers",
2163 },
214e1eca
JA
2164#ifdef FIO_HAVE_HUGETLB
2165 { .ival = "shmhuge",
2166 .oval = MEM_SHMHUGE,
2167 .help = "Like shm, but use huge pages",
2168 },
b370e46a 2169#endif
37c8cdfe
JA
2170 { .ival = "mmap",
2171 .oval = MEM_MMAP,
2172 .help = "Use mmap(2) (file or anon) for IO buffers",
2173 },
214e1eca
JA
2174#ifdef FIO_HAVE_HUGETLB
2175 { .ival = "mmaphuge",
2176 .oval = MEM_MMAPHUGE,
2177 .help = "Like mmap, but use huge pages",
2178 },
2179#endif
2180 },
2181 },
d529ee19
JA
2182 {
2183 .name = "iomem_align",
2184 .alias = "mem_align",
e8b0e958 2185 .lname = "I/O memory alignment",
d529ee19
JA
2186 .type = FIO_OPT_INT,
2187 .off1 = td_var_offset(mem_align),
2188 .minval = 0,
2189 .help = "IO memory buffer offset alignment",
2190 .def = "0",
2191 .parent = "iomem",
d71c154c 2192 .hide = 1,
e8b0e958
JA
2193 .category = FIO_OPT_C_IO,
2194 .group = FIO_OPT_G_INVALID,
d529ee19 2195 },
214e1eca
JA
2196 {
2197 .name = "verify",
e8b0e958 2198 .lname = "Verify",
214e1eca
JA
2199 .type = FIO_OPT_STR,
2200 .off1 = td_var_offset(verify),
2201 .help = "Verify data written",
2202 .def = "0",
e8b0e958 2203 .category = FIO_OPT_C_IO,
3ceb458f 2204 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2205 .posval = {
2206 { .ival = "0",
2207 .oval = VERIFY_NONE,
2208 .help = "Don't do IO verification",
2209 },
fcca4b58
JA
2210 { .ival = "md5",
2211 .oval = VERIFY_MD5,
2212 .help = "Use md5 checksums for verification",
2213 },
d77a7af3
JA
2214 { .ival = "crc64",
2215 .oval = VERIFY_CRC64,
2216 .help = "Use crc64 checksums for verification",
2217 },
214e1eca
JA
2218 { .ival = "crc32",
2219 .oval = VERIFY_CRC32,
2220 .help = "Use crc32 checksums for verification",
2221 },
af497e6a 2222 { .ival = "crc32c-intel",
e3aaafc4
JA
2223 .oval = VERIFY_CRC32C,
2224 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2225 },
bac39e0e
JA
2226 { .ival = "crc32c",
2227 .oval = VERIFY_CRC32C,
e3aaafc4 2228 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2229 },
969f7ed3
JA
2230 { .ival = "crc16",
2231 .oval = VERIFY_CRC16,
2232 .help = "Use crc16 checksums for verification",
2233 },
1e154bdb
JA
2234 { .ival = "crc7",
2235 .oval = VERIFY_CRC7,
2236 .help = "Use crc7 checksums for verification",
2237 },
7c353ceb
JA
2238 { .ival = "sha1",
2239 .oval = VERIFY_SHA1,
2240 .help = "Use sha1 checksums for verification",
2241 },
cd14cc10
JA
2242 { .ival = "sha256",
2243 .oval = VERIFY_SHA256,
2244 .help = "Use sha256 checksums for verification",
2245 },
2246 { .ival = "sha512",
2247 .oval = VERIFY_SHA512,
2248 .help = "Use sha512 checksums for verification",
2249 },
844ea602
JA
2250 { .ival = "xxhash",
2251 .oval = VERIFY_XXHASH,
2252 .help = "Use xxhash checksums for verification",
2253 },
7437ee87
SL
2254 { .ival = "meta",
2255 .oval = VERIFY_META,
2256 .help = "Use io information",
2257 },
36690c9b
JA
2258 {
2259 .ival = "null",
2260 .oval = VERIFY_NULL,
2261 .help = "Pretend to verify",
2262 },
214e1eca
JA
2263 },
2264 },
005c565a
JA
2265 {
2266 .name = "do_verify",
e8b0e958 2267 .lname = "Perform verify step",
68e1f29a 2268 .type = FIO_OPT_BOOL,
005c565a
JA
2269 .off1 = td_var_offset(do_verify),
2270 .help = "Run verification stage after write",
2271 .def = "1",
2272 .parent = "verify",
d71c154c 2273 .hide = 1,
e8b0e958
JA
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_VERIFY,
005c565a 2276 },
160b966d
JA
2277 {
2278 .name = "verifysort",
e8b0e958 2279 .lname = "Verify sort",
160b966d
JA
2280 .type = FIO_OPT_BOOL,
2281 .off1 = td_var_offset(verifysort),
2282 .help = "Sort written verify blocks for read back",
2283 .def = "1",
c83f2df1 2284 .parent = "verify",
d71c154c 2285 .hide = 1,
e8b0e958
JA
2286 .category = FIO_OPT_C_IO,
2287 .group = FIO_OPT_G_VERIFY,
160b966d 2288 },
1ae83d45
JA
2289 {
2290 .name = "verifysort_nr",
2291 .type = FIO_OPT_INT,
2292 .off1 = td_var_offset(verifysort_nr),
2293 .help = "Pre-load and sort verify blocks for a read workload",
2294 .minval = 0,
2295 .maxval = 131072,
2296 .def = "1024",
2297 .parent = "verify",
836fcc0f
JA
2298 .category = FIO_OPT_C_IO,
2299 .group = FIO_OPT_G_VERIFY,
1ae83d45 2300 },
3f9f4e26 2301 {
a59e170d 2302 .name = "verify_interval",
e8b0e958 2303 .lname = "Verify interval",
e01b22b8 2304 .type = FIO_OPT_INT,
a59e170d 2305 .off1 = td_var_offset(verify_interval),
819a9680 2306 .minval = 2 * sizeof(struct verify_header),
a59e170d 2307 .help = "Store verify buffer header every N bytes",
afdf9352 2308 .parent = "verify",
d71c154c 2309 .hide = 1,
20eb06bd 2310 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2311 .category = FIO_OPT_C_IO,
2312 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2313 },
546a9142 2314 {
a59e170d 2315 .name = "verify_offset",
e8b0e958 2316 .lname = "Verify offset",
e01b22b8 2317 .type = FIO_OPT_INT,
a59e170d 2318 .help = "Offset verify header location by N bytes",
203160d5
JA
2319 .off1 = td_var_offset(verify_offset),
2320 .minval = sizeof(struct verify_header),
afdf9352 2321 .parent = "verify",
d71c154c 2322 .hide = 1,
e8b0e958
JA
2323 .category = FIO_OPT_C_IO,
2324 .group = FIO_OPT_G_VERIFY,
546a9142 2325 },
e28218f3
SL
2326 {
2327 .name = "verify_pattern",
e8b0e958 2328 .lname = "Verify pattern",
0e92f873 2329 .type = FIO_OPT_STR,
e28218f3
SL
2330 .cb = str_verify_pattern_cb,
2331 .help = "Fill pattern for IO buffers",
2332 .parent = "verify",
d71c154c 2333 .hide = 1,
e8b0e958
JA
2334 .category = FIO_OPT_C_IO,
2335 .group = FIO_OPT_G_VERIFY,
e28218f3 2336 },
a12a3b4d
JA
2337 {
2338 .name = "verify_fatal",
e8b0e958 2339 .lname = "Verify fatal",
68e1f29a 2340 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2341 .off1 = td_var_offset(verify_fatal),
2342 .def = "0",
2343 .help = "Exit on a single verify failure, don't continue",
2344 .parent = "verify",
d71c154c 2345 .hide = 1,
e8b0e958
JA
2346 .category = FIO_OPT_C_IO,
2347 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2348 },
b463e936
JA
2349 {
2350 .name = "verify_dump",
e8b0e958 2351 .lname = "Verify dump",
b463e936
JA
2352 .type = FIO_OPT_BOOL,
2353 .off1 = td_var_offset(verify_dump),
ef71e317 2354 .def = "0",
b463e936
JA
2355 .help = "Dump contents of good and bad blocks on failure",
2356 .parent = "verify",
d71c154c 2357 .hide = 1,
e8b0e958
JA
2358 .category = FIO_OPT_C_IO,
2359 .group = FIO_OPT_G_VERIFY,
b463e936 2360 },
e8462bd8
JA
2361 {
2362 .name = "verify_async",
e8b0e958 2363 .lname = "Verify asynchronously",
e8462bd8
JA
2364 .type = FIO_OPT_INT,
2365 .off1 = td_var_offset(verify_async),
2366 .def = "0",
2367 .help = "Number of async verifier threads to use",
2368 .parent = "verify",
d71c154c 2369 .hide = 1,
e8b0e958
JA
2370 .category = FIO_OPT_C_IO,
2371 .group = FIO_OPT_G_VERIFY,
e8462bd8 2372 },
9e144189
JA
2373 {
2374 .name = "verify_backlog",
e8b0e958 2375 .lname = "Verify backlog",
9e144189
JA
2376 .type = FIO_OPT_STR_VAL,
2377 .off1 = td_var_offset(verify_backlog),
2378 .help = "Verify after this number of blocks are written",
2379 .parent = "verify",
d71c154c 2380 .hide = 1,
e8b0e958
JA
2381 .category = FIO_OPT_C_IO,
2382 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2383 },
2384 {
2385 .name = "verify_backlog_batch",
e8b0e958 2386 .lname = "Verify backlog batch",
9e144189
JA
2387 .type = FIO_OPT_INT,
2388 .off1 = td_var_offset(verify_batch),
2389 .help = "Verify this number of IO blocks",
0d29de83 2390 .parent = "verify",
d71c154c 2391 .hide = 1,
e8b0e958
JA
2392 .category = FIO_OPT_C_IO,
2393 .group = FIO_OPT_G_VERIFY,
9e144189 2394 },
e8462bd8
JA
2395#ifdef FIO_HAVE_CPU_AFFINITY
2396 {
2397 .name = "verify_async_cpus",
e8b0e958 2398 .lname = "Async verify CPUs",
e8462bd8
JA
2399 .type = FIO_OPT_STR,
2400 .cb = str_verify_cpus_allowed_cb,
2401 .help = "Set CPUs allowed for async verify threads",
2402 .parent = "verify_async",
d71c154c 2403 .hide = 1,
e8b0e958
JA
2404 .category = FIO_OPT_C_IO,
2405 .group = FIO_OPT_G_VERIFY,
e8462bd8 2406 },
0d29de83 2407#endif
51aa2da8
JA
2408 {
2409 .name = "experimental_verify",
2410 .off1 = td_var_offset(experimental_verify),
2411 .type = FIO_OPT_BOOL,
b31eaac9 2412 .help = "Enable experimental verification",
836fcc0f
JA
2413 .category = FIO_OPT_C_IO,
2414 .group = FIO_OPT_G_VERIFY,
51aa2da8 2415 },
0d29de83
JA
2416#ifdef FIO_HAVE_TRIM
2417 {
2418 .name = "trim_percentage",
e8b0e958 2419 .lname = "Trim percentage",
0d29de83 2420 .type = FIO_OPT_INT,
203160d5 2421 .off1 = td_var_offset(trim_percentage),
20eb06bd 2422 .minval = 0,
0d29de83
JA
2423 .maxval = 100,
2424 .help = "Number of verify blocks to discard/trim",
2425 .parent = "verify",
2426 .def = "0",
20eb06bd 2427 .interval = 1,
d71c154c 2428 .hide = 1,
e8b0e958
JA
2429 .category = FIO_OPT_C_IO,
2430 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2431 },
2432 {
2433 .name = "trim_verify_zero",
e8b0e958 2434 .lname = "Verify trim zero",
20eb06bd 2435 .type = FIO_OPT_BOOL,
0d29de83
JA
2436 .help = "Verify that trim/discarded blocks are returned as zeroes",
2437 .off1 = td_var_offset(trim_zero),
2438 .parent = "trim_percentage",
d71c154c 2439 .hide = 1,
0d29de83 2440 .def = "1",
e8b0e958
JA
2441 .category = FIO_OPT_C_IO,
2442 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2443 },
2444 {
2445 .name = "trim_backlog",
e8b0e958 2446 .lname = "Trim backlog",
0d29de83
JA
2447 .type = FIO_OPT_STR_VAL,
2448 .off1 = td_var_offset(trim_backlog),
2449 .help = "Trim after this number of blocks are written",
2450 .parent = "trim_percentage",
d71c154c 2451 .hide = 1,
20eb06bd 2452 .interval = 1,
e8b0e958
JA
2453 .category = FIO_OPT_C_IO,
2454 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2455 },
2456 {
2457 .name = "trim_backlog_batch",
e8b0e958 2458 .lname = "Trim backlog batch",
0d29de83
JA
2459 .type = FIO_OPT_INT,
2460 .off1 = td_var_offset(trim_batch),
2461 .help = "Trim this number of IO blocks",
2462 .parent = "trim_percentage",
d71c154c 2463 .hide = 1,
20eb06bd 2464 .interval = 1,
e8b0e958
JA
2465 .category = FIO_OPT_C_IO,
2466 .group = FIO_OPT_G_TRIM,
0d29de83 2467 },
e8462bd8 2468#endif
214e1eca
JA
2469 {
2470 .name = "write_iolog",
e8b0e958 2471 .lname = "Write I/O log",
214e1eca
JA
2472 .type = FIO_OPT_STR_STORE,
2473 .off1 = td_var_offset(write_iolog_file),
2474 .help = "Store IO pattern to file",
e8b0e958
JA
2475 .category = FIO_OPT_C_IO,
2476 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2477 },
2478 {
2479 .name = "read_iolog",
e8b0e958 2480 .lname = "Read I/O log",
214e1eca
JA
2481 .type = FIO_OPT_STR_STORE,
2482 .off1 = td_var_offset(read_iolog_file),
2483 .help = "Playback IO pattern from file",
e8b0e958
JA
2484 .category = FIO_OPT_C_IO,
2485 .group = FIO_OPT_G_IOLOG,
214e1eca 2486 },
64bbb865
DN
2487 {
2488 .name = "replay_no_stall",
e8b0e958 2489 .lname = "Don't stall on replay",
20eb06bd 2490 .type = FIO_OPT_BOOL,
64bbb865
DN
2491 .off1 = td_var_offset(no_stall),
2492 .def = "0",
87e7a972 2493 .parent = "read_iolog",
d71c154c 2494 .hide = 1,
64bbb865 2495 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2496 .category = FIO_OPT_C_IO,
2497 .group = FIO_OPT_G_IOLOG,
64bbb865 2498 },
d1c46c04
DN
2499 {
2500 .name = "replay_redirect",
e8b0e958 2501 .lname = "Redirect device for replay",
d1c46c04
DN
2502 .type = FIO_OPT_STR_STORE,
2503 .off1 = td_var_offset(replay_redirect),
2504 .parent = "read_iolog",
d71c154c 2505 .hide = 1,
d1c46c04 2506 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2507 .category = FIO_OPT_C_IO,
2508 .group = FIO_OPT_G_IOLOG,
d1c46c04 2509 },
214e1eca
JA
2510 {
2511 .name = "exec_prerun",
e8b0e958 2512 .lname = "Pre-execute runnable",
214e1eca
JA
2513 .type = FIO_OPT_STR_STORE,
2514 .off1 = td_var_offset(exec_prerun),
2515 .help = "Execute this file prior to running job",
e8b0e958
JA
2516 .category = FIO_OPT_C_GENERAL,
2517 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2518 },
2519 {
2520 .name = "exec_postrun",
e8b0e958 2521 .lname = "Post-execute runnable",
214e1eca
JA
2522 .type = FIO_OPT_STR_STORE,
2523 .off1 = td_var_offset(exec_postrun),
2524 .help = "Execute this file after running job",
e8b0e958
JA
2525 .category = FIO_OPT_C_GENERAL,
2526 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2527 },
2528#ifdef FIO_HAVE_IOSCHED_SWITCH
2529 {
2530 .name = "ioscheduler",
e8b0e958 2531 .lname = "I/O scheduler",
214e1eca
JA
2532 .type = FIO_OPT_STR_STORE,
2533 .off1 = td_var_offset(ioscheduler),
2534 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2535 .category = FIO_OPT_C_FILE,
2536 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2537 },
2538#endif
2539 {
2540 .name = "zonesize",
e8b0e958 2541 .lname = "Zone size",
214e1eca
JA
2542 .type = FIO_OPT_STR_VAL,
2543 .off1 = td_var_offset(zone_size),
ed335855
SN
2544 .help = "Amount of data to read per zone",
2545 .def = "0",
20eb06bd 2546 .interval = 1024 * 1024,
e8b0e958
JA
2547 .category = FIO_OPT_C_IO,
2548 .group = FIO_OPT_G_ZONE,
ed335855
SN
2549 },
2550 {
2551 .name = "zonerange",
e8b0e958 2552 .lname = "Zone range",
ed335855
SN
2553 .type = FIO_OPT_STR_VAL,
2554 .off1 = td_var_offset(zone_range),
214e1eca
JA
2555 .help = "Give size of an IO zone",
2556 .def = "0",
20eb06bd 2557 .interval = 1024 * 1024,
e8b0e958
JA
2558 .category = FIO_OPT_C_IO,
2559 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2560 },
2561 {
2562 .name = "zoneskip",
e8b0e958 2563 .lname = "Zone skip",
214e1eca
JA
2564 .type = FIO_OPT_STR_VAL,
2565 .off1 = td_var_offset(zone_skip),
2566 .help = "Space between IO zones",
2567 .def = "0",
20eb06bd 2568 .interval = 1024 * 1024,
e8b0e958
JA
2569 .category = FIO_OPT_C_IO,
2570 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2571 },
2572 {
2573 .name = "lockmem",
e8b0e958 2574 .lname = "Lock memory",
214e1eca 2575 .type = FIO_OPT_STR_VAL,
1b79a070 2576 .off1 = td_var_offset(lockmem),
81c6b6cd 2577 .help = "Lock down this amount of memory (per worker)",
214e1eca 2578 .def = "0",
20eb06bd 2579 .interval = 1024 * 1024,
e8b0e958
JA
2580 .category = FIO_OPT_C_GENERAL,
2581 .group = FIO_OPT_G_INVALID,
214e1eca 2582 },
214e1eca
JA
2583 {
2584 .name = "rwmixread",
e8b0e958 2585 .lname = "Read/write mix read",
214e1eca 2586 .type = FIO_OPT_INT,
cb499fc4 2587 .cb = str_rwmix_read_cb,
214e1eca
JA
2588 .maxval = 100,
2589 .help = "Percentage of mixed workload that is reads",
2590 .def = "50",
20eb06bd 2591 .interval = 5,
90265353 2592 .inverse = "rwmixwrite",
e8b0e958
JA
2593 .category = FIO_OPT_C_IO,
2594 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2595 },
2596 {
2597 .name = "rwmixwrite",
e8b0e958 2598 .lname = "Read/write mix write",
214e1eca 2599 .type = FIO_OPT_INT,
cb499fc4 2600 .cb = str_rwmix_write_cb,
214e1eca
JA
2601 .maxval = 100,
2602 .help = "Percentage of mixed workload that is writes",
2603 .def = "50",
20eb06bd 2604 .interval = 5,
90265353 2605 .inverse = "rwmixread",
e8b0e958
JA
2606 .category = FIO_OPT_C_IO,
2607 .group = FIO_OPT_G_RWMIX,
214e1eca 2608 },
afdf9352
JA
2609 {
2610 .name = "rwmixcycle",
e8b0e958 2611 .lname = "Read/write mix cycle",
15ca150e 2612 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2613 .category = FIO_OPT_C_IO,
2614 .group = FIO_OPT_G_RWMIX,
afdf9352 2615 },
214e1eca
JA
2616 {
2617 .name = "nice",
e8b0e958 2618 .lname = "Nice",
214e1eca
JA
2619 .type = FIO_OPT_INT,
2620 .off1 = td_var_offset(nice),
2621 .help = "Set job CPU nice value",
2622 .minval = -19,
2623 .maxval = 20,
2624 .def = "0",
20eb06bd 2625 .interval = 1,
e8b0e958 2626 .category = FIO_OPT_C_GENERAL,
10860056 2627 .group = FIO_OPT_G_CRED,
214e1eca
JA
2628 },
2629#ifdef FIO_HAVE_IOPRIO
2630 {
2631 .name = "prio",
e8b0e958 2632 .lname = "I/O nice priority",
214e1eca 2633 .type = FIO_OPT_INT,
28727df7 2634 .off1 = td_var_offset(ioprio),
214e1eca
JA
2635 .help = "Set job IO priority value",
2636 .minval = 0,
2637 .maxval = 7,
20eb06bd 2638 .interval = 1,
e8b0e958 2639 .category = FIO_OPT_C_GENERAL,
10860056 2640 .group = FIO_OPT_G_CRED,
214e1eca
JA
2641 },
2642 {
2643 .name = "prioclass",
e8b0e958 2644 .lname = "I/O nice priority class",
214e1eca 2645 .type = FIO_OPT_INT,
28727df7 2646 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2647 .help = "Set job IO priority class",
2648 .minval = 0,
2649 .maxval = 3,
20eb06bd 2650 .interval = 1,
e8b0e958 2651 .category = FIO_OPT_C_GENERAL,
10860056 2652 .group = FIO_OPT_G_CRED,
214e1eca
JA
2653 },
2654#endif
2655 {
2656 .name = "thinktime",
e8b0e958 2657 .lname = "Thinktime",
214e1eca
JA
2658 .type = FIO_OPT_INT,
2659 .off1 = td_var_offset(thinktime),
2660 .help = "Idle time between IO buffers (usec)",
2661 .def = "0",
e8b0e958 2662 .category = FIO_OPT_C_IO,
3ceb458f 2663 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2664 },
2665 {
2666 .name = "thinktime_spin",
e8b0e958 2667 .lname = "Thinktime spin",
214e1eca
JA
2668 .type = FIO_OPT_INT,
2669 .off1 = td_var_offset(thinktime_spin),
2670 .help = "Start think time by spinning this amount (usec)",
2671 .def = "0",
afdf9352 2672 .parent = "thinktime",
d71c154c 2673 .hide = 1,
e8b0e958 2674 .category = FIO_OPT_C_IO,
3ceb458f 2675 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2676 },
2677 {
2678 .name = "thinktime_blocks",
e8b0e958 2679 .lname = "Thinktime blocks",
214e1eca
JA
2680 .type = FIO_OPT_INT,
2681 .off1 = td_var_offset(thinktime_blocks),
2682 .help = "IO buffer period between 'thinktime'",
2683 .def = "1",
afdf9352 2684 .parent = "thinktime",
d71c154c 2685 .hide = 1,
e8b0e958 2686 .category = FIO_OPT_C_IO,
3ceb458f 2687 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2688 },
2689 {
2690 .name = "rate",
e8b0e958 2691 .lname = "I/O rate",
e01b22b8 2692 .type = FIO_OPT_INT,
6eaf09d6
SL
2693 .off1 = td_var_offset(rate[DDIR_READ]),
2694 .off2 = td_var_offset(rate[DDIR_WRITE]),
2695 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2696 .help = "Set bandwidth rate",
e8b0e958
JA
2697 .category = FIO_OPT_C_IO,
2698 .group = FIO_OPT_G_RATE,
214e1eca
JA
2699 },
2700 {
2701 .name = "ratemin",
e8b0e958 2702 .lname = "I/O min rate",
e01b22b8 2703 .type = FIO_OPT_INT,
6eaf09d6
SL
2704 .off1 = td_var_offset(ratemin[DDIR_READ]),
2705 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2706 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2707 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2708 .parent = "rate",
d71c154c 2709 .hide = 1,
e8b0e958
JA
2710 .category = FIO_OPT_C_IO,
2711 .group = FIO_OPT_G_RATE,
4e991c23
JA
2712 },
2713 {
2714 .name = "rate_iops",
e8b0e958 2715 .lname = "I/O rate IOPS",
e01b22b8 2716 .type = FIO_OPT_INT,
6eaf09d6
SL
2717 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2718 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2719 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2720 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2721 .hide = 1,
e8b0e958
JA
2722 .category = FIO_OPT_C_IO,
2723 .group = FIO_OPT_G_RATE,
4e991c23
JA
2724 },
2725 {
2726 .name = "rate_iops_min",
e8b0e958 2727 .lname = "I/O min rate IOPS",
e01b22b8 2728 .type = FIO_OPT_INT,
6eaf09d6
SL
2729 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2730 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2731 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2732 .help = "Job must meet this rate or it will be shut down",
afdf9352 2733 .parent = "rate_iops",
d71c154c 2734 .hide = 1,
e8b0e958
JA
2735 .category = FIO_OPT_C_IO,
2736 .group = FIO_OPT_G_RATE,
214e1eca
JA
2737 },
2738 {
2739 .name = "ratecycle",
e8b0e958 2740 .lname = "I/O rate cycle",
214e1eca
JA
2741 .type = FIO_OPT_INT,
2742 .off1 = td_var_offset(ratecycle),
2743 .help = "Window average for rate limits (msec)",
2744 .def = "1000",
afdf9352 2745 .parent = "rate",
d71c154c 2746 .hide = 1,
e8b0e958
JA
2747 .category = FIO_OPT_C_IO,
2748 .group = FIO_OPT_G_RATE,
214e1eca 2749 },
15501535
JA
2750 {
2751 .name = "max_latency",
2752 .type = FIO_OPT_INT,
2753 .off1 = td_var_offset(max_latency),
2754 .help = "Maximum tolerated IO latency (usec)",
1e5324e7 2755 .category = FIO_OPT_C_IO,
3e260a46
JA
2756 .group = FIO_OPT_G_LATPROF,
2757 },
2758 {
2759 .name = "latency_target",
2760 .lname = "Latency Target (usec)",
2761 .type = FIO_OPT_STR_VAL_TIME,
2762 .off1 = td_var_offset(latency_target),
2763 .help = "Ramp to max queue depth supporting this latency",
2764 .category = FIO_OPT_C_IO,
2765 .group = FIO_OPT_G_LATPROF,
2766 },
2767 {
2768 .name = "latency_window",
2769 .lname = "Latency Window (usec)",
2770 .type = FIO_OPT_STR_VAL_TIME,
2771 .off1 = td_var_offset(latency_window),
2772 .help = "Time to sustain latency_target",
2773 .category = FIO_OPT_C_IO,
2774 .group = FIO_OPT_G_LATPROF,
2775 },
2776 {
2777 .name = "latency_percentile",
2778 .lname = "Latency Percentile",
2779 .type = FIO_OPT_FLOAT_LIST,
2780 .off1 = td_var_offset(latency_percentile),
2781 .help = "Percentile of IOs must be below latency_target",
2782 .def = "100",
2783 .maxlen = 1,
2784 .minfp = 0.0,
2785 .maxfp = 100.0,
2786 .category = FIO_OPT_C_IO,
2787 .group = FIO_OPT_G_LATPROF,
15501535 2788 },
214e1eca
JA
2789 {
2790 .name = "invalidate",
e8b0e958 2791 .lname = "Cache invalidate",
214e1eca
JA
2792 .type = FIO_OPT_BOOL,
2793 .off1 = td_var_offset(invalidate_cache),
2794 .help = "Invalidate buffer/page cache prior to running job",
2795 .def = "1",
e8b0e958 2796 .category = FIO_OPT_C_IO,
3ceb458f 2797 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2798 },
2799 {
2800 .name = "sync",
e8b0e958 2801 .lname = "Synchronous I/O",
214e1eca
JA
2802 .type = FIO_OPT_BOOL,
2803 .off1 = td_var_offset(sync_io),
2804 .help = "Use O_SYNC for buffered writes",
2805 .def = "0",
67a1000f 2806 .parent = "buffered",
d71c154c 2807 .hide = 1,
e8b0e958 2808 .category = FIO_OPT_C_IO,
3ceb458f 2809 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2810 },
214e1eca
JA
2811 {
2812 .name = "create_serialize",
e8b0e958 2813 .lname = "Create serialize",
214e1eca
JA
2814 .type = FIO_OPT_BOOL,
2815 .off1 = td_var_offset(create_serialize),
2816 .help = "Serialize creating of job files",
2817 .def = "1",
e8b0e958
JA
2818 .category = FIO_OPT_C_FILE,
2819 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2820 },
2821 {
2822 .name = "create_fsync",
e8b0e958 2823 .lname = "Create fsync",
214e1eca
JA
2824 .type = FIO_OPT_BOOL,
2825 .off1 = td_var_offset(create_fsync),
03e20d68 2826 .help = "fsync file after creation",
214e1eca 2827 .def = "1",
e8b0e958
JA
2828 .category = FIO_OPT_C_FILE,
2829 .group = FIO_OPT_G_INVALID,
214e1eca 2830 },
814452bd
JA
2831 {
2832 .name = "create_on_open",
e8b0e958 2833 .lname = "Create on open",
814452bd
JA
2834 .type = FIO_OPT_BOOL,
2835 .off1 = td_var_offset(create_on_open),
2836 .help = "Create files when they are opened for IO",
2837 .def = "0",
e8b0e958
JA
2838 .category = FIO_OPT_C_FILE,
2839 .group = FIO_OPT_G_INVALID,
814452bd 2840 },
25460cf6
JA
2841 {
2842 .name = "create_only",
2843 .type = FIO_OPT_BOOL,
2844 .off1 = td_var_offset(create_only),
2845 .help = "Only perform file creation phase",
d17fda71 2846 .category = FIO_OPT_C_FILE,
25460cf6
JA
2847 .def = "0",
2848 },
0b9d69ec 2849 {
afad68f7 2850 .name = "pre_read",
e8b0e958 2851 .lname = "Pre-read files",
afad68f7
ZY
2852 .type = FIO_OPT_BOOL,
2853 .off1 = td_var_offset(pre_read),
03e20d68 2854 .help = "Pre-read files before starting official testing",
afad68f7 2855 .def = "0",
e8b0e958
JA
2856 .category = FIO_OPT_C_FILE,
2857 .group = FIO_OPT_G_INVALID,
afad68f7 2858 },
214e1eca
JA
2859#ifdef FIO_HAVE_CPU_AFFINITY
2860 {
2861 .name = "cpumask",
e8b0e958 2862 .lname = "CPU mask",
214e1eca
JA
2863 .type = FIO_OPT_INT,
2864 .cb = str_cpumask_cb,
2865 .help = "CPU affinity mask",
e8b0e958 2866 .category = FIO_OPT_C_GENERAL,
10860056 2867 .group = FIO_OPT_G_CRED,
214e1eca 2868 },
d2e268b0
JA
2869 {
2870 .name = "cpus_allowed",
e8b0e958 2871 .lname = "CPUs allowed",
d2e268b0
JA
2872 .type = FIO_OPT_STR,
2873 .cb = str_cpus_allowed_cb,
2874 .help = "Set CPUs allowed",
e8b0e958 2875 .category = FIO_OPT_C_GENERAL,
10860056 2876 .group = FIO_OPT_G_CRED,
d2e268b0 2877 },
d0b937ed 2878#endif
67bf9823 2879#ifdef CONFIG_LIBNUMA
d0b937ed
YR
2880 {
2881 .name = "numa_cpu_nodes",
2882 .type = FIO_OPT_STR,
2883 .cb = str_numa_cpunodes_cb,
2884 .help = "NUMA CPU nodes bind",
6be54b2d
JA
2885 .category = FIO_OPT_C_GENERAL,
2886 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2887 },
2888 {
2889 .name = "numa_mem_policy",
2890 .type = FIO_OPT_STR,
2891 .cb = str_numa_mpol_cb,
2892 .help = "NUMA memory policy setup",
6be54b2d
JA
2893 .category = FIO_OPT_C_GENERAL,
2894 .group = FIO_OPT_G_INVALID,
d0b937ed 2895 },
214e1eca
JA
2896#endif
2897 {
2898 .name = "end_fsync",
e8b0e958 2899 .lname = "End fsync",
214e1eca
JA
2900 .type = FIO_OPT_BOOL,
2901 .off1 = td_var_offset(end_fsync),
2902 .help = "Include fsync at the end of job",
2903 .def = "0",
e8b0e958
JA
2904 .category = FIO_OPT_C_FILE,
2905 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2906 },
2907 {
2908 .name = "fsync_on_close",
e8b0e958 2909 .lname = "Fsync on close",
214e1eca
JA
2910 .type = FIO_OPT_BOOL,
2911 .off1 = td_var_offset(fsync_on_close),
2912 .help = "fsync files on close",
2913 .def = "0",
e8b0e958
JA
2914 .category = FIO_OPT_C_FILE,
2915 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2916 },
2917 {
2918 .name = "unlink",
e8b0e958 2919 .lname = "Unlink file",
214e1eca
JA
2920 .type = FIO_OPT_BOOL,
2921 .off1 = td_var_offset(unlink),
2922 .help = "Unlink created files after job has completed",
2923 .def = "0",
e8b0e958
JA
2924 .category = FIO_OPT_C_FILE,
2925 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2926 },
2927 {
2928 .name = "exitall",
e8b0e958 2929 .lname = "Exit-all on terminate",
214e1eca
JA
2930 .type = FIO_OPT_STR_SET,
2931 .cb = str_exitall_cb,
2932 .help = "Terminate all jobs when one exits",
e8b0e958 2933 .category = FIO_OPT_C_GENERAL,
a1f6afec 2934 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2935 },
2936 {
2937 .name = "stonewall",
e8b0e958 2938 .lname = "Wait for previous",
d392365e 2939 .alias = "wait_for_previous",
214e1eca
JA
2940 .type = FIO_OPT_STR_SET,
2941 .off1 = td_var_offset(stonewall),
2942 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2943 .category = FIO_OPT_C_GENERAL,
a1f6afec 2944 .group = FIO_OPT_G_PROCESS,
214e1eca 2945 },
b3d62a75
JA
2946 {
2947 .name = "new_group",
e8b0e958 2948 .lname = "New group",
b3d62a75
JA
2949 .type = FIO_OPT_STR_SET,
2950 .off1 = td_var_offset(new_group),
2951 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2952 .category = FIO_OPT_C_GENERAL,
a1f6afec 2953 .group = FIO_OPT_G_PROCESS,
b3d62a75 2954 },
214e1eca
JA
2955 {
2956 .name = "thread",
e8b0e958 2957 .lname = "Thread",
214e1eca
JA
2958 .type = FIO_OPT_STR_SET,
2959 .off1 = td_var_offset(use_thread),
20eb06bd 2960 .help = "Use threads instead of processes",
e8b0e958 2961 .category = FIO_OPT_C_GENERAL,
a1f6afec 2962 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2963 },
2964 {
2965 .name = "write_bw_log",
e8b0e958 2966 .lname = "Write bandwidth log",
203160d5
JA
2967 .type = FIO_OPT_STR_STORE,
2968 .off1 = td_var_offset(bw_log_file),
214e1eca 2969 .help = "Write log of bandwidth during run",
e8b0e958
JA
2970 .category = FIO_OPT_C_LOG,
2971 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2972 },
2973 {
2974 .name = "write_lat_log",
e8b0e958 2975 .lname = "Write latency log",
203160d5
JA
2976 .type = FIO_OPT_STR_STORE,
2977 .off1 = td_var_offset(lat_log_file),
214e1eca 2978 .help = "Write log of latency during run",
e8b0e958
JA
2979 .category = FIO_OPT_C_LOG,
2980 .group = FIO_OPT_G_INVALID,
214e1eca 2981 },
c8eeb9df
JA
2982 {
2983 .name = "write_iops_log",
e8b0e958 2984 .lname = "Write IOPS log",
577c83bd 2985 .type = FIO_OPT_STR_STORE,
203160d5 2986 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2987 .help = "Write log of IOPS during run",
e8b0e958
JA
2988 .category = FIO_OPT_C_LOG,
2989 .group = FIO_OPT_G_INVALID,
c8eeb9df 2990 },
b8bc8cba
JA
2991 {
2992 .name = "log_avg_msec",
e8b0e958 2993 .lname = "Log averaging (msec)",
b8bc8cba
JA
2994 .type = FIO_OPT_INT,
2995 .off1 = td_var_offset(log_avg_msec),
2996 .help = "Average bw/iops/lat logs over this period of time",
2997 .def = "0",
e8b0e958
JA
2998 .category = FIO_OPT_C_LOG,
2999 .group = FIO_OPT_G_INVALID,
b8bc8cba 3000 },
c504ee55
JA
3001 {
3002 .name = "bwavgtime",
3003 .lname = "Bandwidth average time",
3004 .type = FIO_OPT_INT,
3005 .off1 = td_var_offset(bw_avg_time),
3006 .help = "Time window over which to calculate bandwidth"
3007 " (msec)",
3008 .def = "500",
3009 .parent = "write_bw_log",
3010 .hide = 1,
3011 .interval = 100,
3012 .category = FIO_OPT_C_LOG,
3013 .group = FIO_OPT_G_INVALID,
3014 },
3015 {
3016 .name = "iopsavgtime",
3017 .lname = "IOPS average time",
3018 .type = FIO_OPT_INT,
3019 .off1 = td_var_offset(iops_avg_time),
3020 .help = "Time window over which to calculate IOPS (msec)",
3021 .def = "500",
3022 .parent = "write_iops_log",
3023 .hide = 1,
3024 .interval = 100,
3025 .category = FIO_OPT_C_LOG,
3026 .group = FIO_OPT_G_INVALID,
3027 },
214e1eca
JA
3028 {
3029 .name = "group_reporting",
e8b0e958 3030 .lname = "Group reporting",
d2507043 3031 .type = FIO_OPT_STR_SET,
214e1eca
JA
3032 .off1 = td_var_offset(group_reporting),
3033 .help = "Do reporting on a per-group basis",
10860056 3034 .category = FIO_OPT_C_STAT,
e8b0e958 3035 .group = FIO_OPT_G_INVALID,
214e1eca 3036 },
e9459e5a
JA
3037 {
3038 .name = "zero_buffers",
e8b0e958 3039 .lname = "Zero I/O buffers",
e9459e5a
JA
3040 .type = FIO_OPT_STR_SET,
3041 .off1 = td_var_offset(zero_buffers),
3042 .help = "Init IO buffers to all zeroes",
e8b0e958 3043 .category = FIO_OPT_C_IO,
3ceb458f 3044 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3045 },
5973cafb
JA
3046 {
3047 .name = "refill_buffers",
e8b0e958 3048 .lname = "Refill I/O buffers",
5973cafb
JA
3049 .type = FIO_OPT_STR_SET,
3050 .off1 = td_var_offset(refill_buffers),
3051 .help = "Refill IO buffers on every IO submit",
e8b0e958 3052 .category = FIO_OPT_C_IO,
3ceb458f 3053 .group = FIO_OPT_G_IO_BUF,
5973cafb 3054 },
fd68418e
JA
3055 {
3056 .name = "scramble_buffers",
e8b0e958 3057 .lname = "Scramble I/O buffers",
fd68418e
JA
3058 .type = FIO_OPT_BOOL,
3059 .off1 = td_var_offset(scramble_buffers),
3060 .help = "Slightly scramble buffers on every IO submit",
3061 .def = "1",
e8b0e958 3062 .category = FIO_OPT_C_IO,
3ceb458f 3063 .group = FIO_OPT_G_IO_BUF,
fd68418e 3064 },
ce35b1ec
JA
3065 {
3066 .name = "buffer_pattern",
3067 .lname = "Buffer pattern",
3068 .type = FIO_OPT_STR,
3069 .cb = str_buffer_pattern_cb,
3070 .help = "Fill pattern for IO buffers",
3071 .category = FIO_OPT_C_IO,
3072 .group = FIO_OPT_G_IO_BUF,
3073 },
9c42684e
JA
3074 {
3075 .name = "buffer_compress_percentage",
e8b0e958 3076 .lname = "Buffer compression percentage",
9c42684e
JA
3077 .type = FIO_OPT_INT,
3078 .off1 = td_var_offset(compress_percentage),
3079 .maxval = 100,
e7f5de90 3080 .minval = 0,
9c42684e 3081 .help = "How compressible the buffer is (approximately)",
20eb06bd 3082 .interval = 5,
e8b0e958 3083 .category = FIO_OPT_C_IO,
3ceb458f 3084 .group = FIO_OPT_G_IO_BUF,
9c42684e 3085 },
f97a43a1
JA
3086 {
3087 .name = "buffer_compress_chunk",
e8b0e958 3088 .lname = "Buffer compression chunk size",
f97a43a1
JA
3089 .type = FIO_OPT_INT,
3090 .off1 = td_var_offset(compress_chunk),
207b18e4 3091 .parent = "buffer_compress_percentage",
d71c154c 3092 .hide = 1,
f97a43a1 3093 .help = "Size of compressible region in buffer",
20eb06bd 3094 .interval = 256,
e8b0e958 3095 .category = FIO_OPT_C_IO,
3ceb458f 3096 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3097 },
83349190
YH
3098 {
3099 .name = "clat_percentiles",
e8b0e958 3100 .lname = "Completion latency percentiles",
83349190
YH
3101 .type = FIO_OPT_BOOL,
3102 .off1 = td_var_offset(clat_percentiles),
3103 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3104 .def = "1",
e8b0e958
JA
3105 .category = FIO_OPT_C_STAT,
3106 .group = FIO_OPT_G_INVALID,
83349190
YH
3107 },
3108 {
3109 .name = "percentile_list",
e8b0e958 3110 .lname = "Completion latency percentile list",
83349190
YH
3111 .type = FIO_OPT_FLOAT_LIST,
3112 .off1 = td_var_offset(percentile_list),
435d195a 3113 .off2 = td_var_offset(percentile_precision),
83349190 3114 .help = "Specify a custom list of percentiles to report",
fd112d34 3115 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3116 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3117 .minfp = 0.0,
3118 .maxfp = 100.0,
e8b0e958
JA
3119 .category = FIO_OPT_C_STAT,
3120 .group = FIO_OPT_G_INVALID,
83349190
YH
3121 },
3122
0a839f30
JA
3123#ifdef FIO_HAVE_DISK_UTIL
3124 {
3125 .name = "disk_util",
e8b0e958 3126 .lname = "Disk utilization",
0a839f30
JA
3127 .type = FIO_OPT_BOOL,
3128 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3129 .help = "Log disk utilization statistics",
0a839f30 3130 .def = "1",
e8b0e958
JA
3131 .category = FIO_OPT_C_STAT,
3132 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3133 },
3134#endif
993bf48b
JA
3135 {
3136 .name = "gtod_reduce",
e8b0e958 3137 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3138 .type = FIO_OPT_BOOL,
3139 .help = "Greatly reduce number of gettimeofday() calls",
3140 .cb = str_gtod_reduce_cb,
3141 .def = "0",
a4ed77fe 3142 .hide_on_set = 1,
e8b0e958
JA
3143 .category = FIO_OPT_C_STAT,
3144 .group = FIO_OPT_G_INVALID,
993bf48b 3145 },
02af0988
JA
3146 {
3147 .name = "disable_lat",
e8b0e958 3148 .lname = "Disable all latency stats",
02af0988
JA
3149 .type = FIO_OPT_BOOL,
3150 .off1 = td_var_offset(disable_lat),
3151 .help = "Disable latency numbers",
3152 .parent = "gtod_reduce",
d71c154c 3153 .hide = 1,
02af0988 3154 .def = "0",
e8b0e958
JA
3155 .category = FIO_OPT_C_STAT,
3156 .group = FIO_OPT_G_INVALID,
02af0988 3157 },
9520ebb9
JA
3158 {
3159 .name = "disable_clat",
e8b0e958 3160 .lname = "Disable completion latency stats",
9520ebb9
JA
3161 .type = FIO_OPT_BOOL,
3162 .off1 = td_var_offset(disable_clat),
3163 .help = "Disable completion latency numbers",
993bf48b 3164 .parent = "gtod_reduce",
d71c154c 3165 .hide = 1,
9520ebb9 3166 .def = "0",
e8b0e958
JA
3167 .category = FIO_OPT_C_STAT,
3168 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3169 },
3170 {
3171 .name = "disable_slat",
e8b0e958 3172 .lname = "Disable submission latency stats",
9520ebb9
JA
3173 .type = FIO_OPT_BOOL,
3174 .off1 = td_var_offset(disable_slat),
03e20d68 3175 .help = "Disable submission latency numbers",
993bf48b 3176 .parent = "gtod_reduce",
d71c154c 3177 .hide = 1,
9520ebb9 3178 .def = "0",
e8b0e958
JA
3179 .category = FIO_OPT_C_STAT,
3180 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3181 },
3182 {
3183 .name = "disable_bw_measurement",
e8b0e958 3184 .lname = "Disable bandwidth stats",
9520ebb9
JA
3185 .type = FIO_OPT_BOOL,
3186 .off1 = td_var_offset(disable_bw),
3187 .help = "Disable bandwidth logging",
993bf48b 3188 .parent = "gtod_reduce",
d71c154c 3189 .hide = 1,
9520ebb9 3190 .def = "0",
e8b0e958
JA
3191 .category = FIO_OPT_C_STAT,
3192 .group = FIO_OPT_G_INVALID,
9520ebb9 3193 },
be4ecfdf
JA
3194 {
3195 .name = "gtod_cpu",
e8b0e958 3196 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
3197 .type = FIO_OPT_INT,
3198 .cb = str_gtod_cpu_cb,
03e20d68 3199 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3200 .verify = gtod_cpu_verify,
e8b0e958 3201 .category = FIO_OPT_C_GENERAL,
10860056 3202 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3203 },
771e58be
JA
3204 {
3205 .name = "unified_rw_reporting",
3206 .type = FIO_OPT_BOOL,
3207 .off1 = td_var_offset(unified_rw_rep),
3208 .help = "Unify reporting across data direction",
3209 .def = "0",
90b7a96d
JA
3210 .category = FIO_OPT_C_GENERAL,
3211 .group = FIO_OPT_G_INVALID,
771e58be 3212 },
f2bba182
RR
3213 {
3214 .name = "continue_on_error",
e8b0e958 3215 .lname = "Continue on error",
06842027 3216 .type = FIO_OPT_STR,
f2bba182 3217 .off1 = td_var_offset(continue_on_error),
03e20d68 3218 .help = "Continue on non-fatal errors during IO",
06842027 3219 .def = "none",
e8b0e958 3220 .category = FIO_OPT_C_GENERAL,
bc3f552f 3221 .group = FIO_OPT_G_ERR,
06842027
SL
3222 .posval = {
3223 { .ival = "none",
3224 .oval = ERROR_TYPE_NONE,
3225 .help = "Exit when an error is encountered",
3226 },
3227 { .ival = "read",
3228 .oval = ERROR_TYPE_READ,
3229 .help = "Continue on read errors only",
3230 },
3231 { .ival = "write",
3232 .oval = ERROR_TYPE_WRITE,
3233 .help = "Continue on write errors only",
3234 },
3235 { .ival = "io",
3236 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3237 .help = "Continue on any IO errors",
3238 },
3239 { .ival = "verify",
3240 .oval = ERROR_TYPE_VERIFY,
3241 .help = "Continue on verify errors only",
3242 },
3243 { .ival = "all",
3244 .oval = ERROR_TYPE_ANY,
3245 .help = "Continue on all io and verify errors",
3246 },
3247 { .ival = "0",
3248 .oval = ERROR_TYPE_NONE,
3249 .help = "Alias for 'none'",
3250 },
3251 { .ival = "1",
3252 .oval = ERROR_TYPE_ANY,
3253 .help = "Alias for 'all'",
3254 },
3255 },
f2bba182 3256 },
8b28bd41
DM
3257 {
3258 .name = "ignore_error",
3259 .type = FIO_OPT_STR,
3260 .cb = str_ignore_error_cb,
3261 .help = "Set a specific list of errors to ignore",
3262 .parent = "rw",
a94eb99a 3263 .category = FIO_OPT_C_GENERAL,
bc3f552f 3264 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3265 },
3266 {
3267 .name = "error_dump",
3268 .type = FIO_OPT_BOOL,
3269 .off1 = td_var_offset(error_dump),
3270 .def = "0",
3271 .help = "Dump info on each error",
a94eb99a 3272 .category = FIO_OPT_C_GENERAL,
bc3f552f 3273 .group = FIO_OPT_G_ERR,
8b28bd41 3274 },
9ac8a797
JA
3275 {
3276 .name = "profile",
e8b0e958 3277 .lname = "Profile",
79d16311 3278 .type = FIO_OPT_STR_STORE,
9ac8a797 3279 .off1 = td_var_offset(profile),
9ac8a797 3280 .help = "Select a specific builtin performance test",
13fca827 3281 .category = FIO_OPT_C_PROFILE,
e8b0e958 3282 .group = FIO_OPT_G_INVALID,
9ac8a797 3283 },
a696fa2a
JA
3284 {
3285 .name = "cgroup",
e8b0e958 3286 .lname = "Cgroup",
a696fa2a
JA
3287 .type = FIO_OPT_STR_STORE,
3288 .off1 = td_var_offset(cgroup),
3289 .help = "Add job to cgroup of this name",
e8b0e958 3290 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3291 .group = FIO_OPT_G_CGROUP,
3292 },
3293 {
3294 .name = "cgroup_nodelete",
3295 .lname = "Cgroup no-delete",
3296 .type = FIO_OPT_BOOL,
3297 .off1 = td_var_offset(cgroup_nodelete),
3298 .help = "Do not delete cgroups after job completion",
3299 .def = "0",
3300 .parent = "cgroup",
3301 .category = FIO_OPT_C_GENERAL,
3302 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3303 },
3304 {
3305 .name = "cgroup_weight",
e8b0e958 3306 .lname = "Cgroup weight",
a696fa2a
JA
3307 .type = FIO_OPT_INT,
3308 .off1 = td_var_offset(cgroup_weight),
3309 .help = "Use given weight for cgroup",
3310 .minval = 100,
3311 .maxval = 1000,
a1f6afec 3312 .parent = "cgroup",
e8b0e958 3313 .category = FIO_OPT_C_GENERAL,
a1f6afec 3314 .group = FIO_OPT_G_CGROUP,
7de87099 3315 },
e0b0d892
JA
3316 {
3317 .name = "uid",
e8b0e958 3318 .lname = "User ID",
e0b0d892
JA
3319 .type = FIO_OPT_INT,
3320 .off1 = td_var_offset(uid),
3321 .help = "Run job with this user ID",
e8b0e958 3322 .category = FIO_OPT_C_GENERAL,
10860056 3323 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3324 },
3325 {
3326 .name = "gid",
e8b0e958 3327 .lname = "Group ID",
e0b0d892
JA
3328 .type = FIO_OPT_INT,
3329 .off1 = td_var_offset(gid),
3330 .help = "Run job with this group ID",
e8b0e958 3331 .category = FIO_OPT_C_GENERAL,
10860056 3332 .group = FIO_OPT_G_CRED,
e0b0d892 3333 },
a1f6afec
JA
3334 {
3335 .name = "kb_base",
3336 .lname = "KB Base",
3337 .type = FIO_OPT_INT,
3338 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3339 .prio = 1,
3340 .def = "1024",
ba9c7219
JA
3341 .posval = {
3342 { .ival = "1024",
3343 .oval = 1024,
3344 .help = "Use 1024 as the K base",
3345 },
3346 { .ival = "1000",
3347 .oval = 1000,
3348 .help = "Use 1000 as the K base",
3349 },
3350 },
a1f6afec
JA
3351 .help = "How many bytes per KB for reporting (1000 or 1024)",
3352 .category = FIO_OPT_C_GENERAL,
3353 .group = FIO_OPT_G_INVALID,
3354 },
cf3a0518
JA
3355 {
3356 .name = "unit_base",
ba9c7219 3357 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3358 .type = FIO_OPT_INT,
3359 .off1 = td_var_offset(unit_base),
cf3a0518 3360 .prio = 1,
71a08258
JA
3361 .posval = {
3362 { .ival = "0",
3363 .oval = 0,
3364 .help = "Auto-detect",
3365 },
3366 { .ival = "8",
3367 .oval = 8,
3368 .help = "Normal (byte based)",
3369 },
3370 { .ival = "1",
3371 .oval = 1,
3372 .help = "Bit based",
3373 },
3374 },
cf3a0518
JA
3375 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3376 .category = FIO_OPT_C_GENERAL,
3377 .group = FIO_OPT_G_INVALID,
3378 },
3ceb458f
JA
3379 {
3380 .name = "hugepage-size",
3381 .lname = "Hugepage size",
3382 .type = FIO_OPT_INT,
3383 .off1 = td_var_offset(hugepage_size),
3384 .help = "When using hugepages, specify size of each page",
3385 .def = __fio_stringify(FIO_HUGE_PAGE),
3386 .interval = 1024 * 1024,
3387 .category = FIO_OPT_C_GENERAL,
3388 .group = FIO_OPT_G_INVALID,
3389 },
9e684a49
DE
3390 {
3391 .name = "flow_id",
e8b0e958 3392 .lname = "I/O flow ID",
9e684a49
DE
3393 .type = FIO_OPT_INT,
3394 .off1 = td_var_offset(flow_id),
3395 .help = "The flow index ID to use",
3396 .def = "0",
e8b0e958
JA
3397 .category = FIO_OPT_C_IO,
3398 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3399 },
3400 {
3401 .name = "flow",
e8b0e958 3402 .lname = "I/O flow weight",
9e684a49
DE
3403 .type = FIO_OPT_INT,
3404 .off1 = td_var_offset(flow),
3405 .help = "Weight for flow control of this job",
3406 .parent = "flow_id",
d71c154c 3407 .hide = 1,
9e684a49 3408 .def = "0",
e8b0e958
JA
3409 .category = FIO_OPT_C_IO,
3410 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3411 },
3412 {
3413 .name = "flow_watermark",
e8b0e958 3414 .lname = "I/O flow watermark",
9e684a49
DE
3415 .type = FIO_OPT_INT,
3416 .off1 = td_var_offset(flow_watermark),
3417 .help = "High watermark for flow control. This option"
3418 " should be set to the same value for all threads"
3419 " with non-zero flow.",
3420 .parent = "flow_id",
d71c154c 3421 .hide = 1,
9e684a49 3422 .def = "1024",
e8b0e958
JA
3423 .category = FIO_OPT_C_IO,
3424 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3425 },
3426 {
3427 .name = "flow_sleep",
e8b0e958 3428 .lname = "I/O flow sleep",
9e684a49
DE
3429 .type = FIO_OPT_INT,
3430 .off1 = td_var_offset(flow_sleep),
3431 .help = "How many microseconds to sleep after being held"
3432 " back by the flow control mechanism",
3433 .parent = "flow_id",
d71c154c 3434 .hide = 1,
9e684a49 3435 .def = "0",
e8b0e958
JA
3436 .category = FIO_OPT_C_IO,
3437 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3438 },
214e1eca
JA
3439 {
3440 .name = NULL,
3441 },
3442};
3443
17af15d4 3444static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3445 const char *name, int val)
9f81736c 3446{
17af15d4 3447 lopt->name = (char *) name;
de890a1e 3448 lopt->val = val;
9f81736c 3449 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3450 lopt->has_arg = optional_argument;
9f81736c
JA
3451 else
3452 lopt->has_arg = required_argument;
3453}
3454
de890a1e
SL
3455static void options_to_lopts(struct fio_option *opts,
3456 struct option *long_options,
3457 int i, int option_type)
214e1eca 3458{
de890a1e 3459 struct fio_option *o = &opts[0];
214e1eca 3460 while (o->name) {
de890a1e 3461 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3462 if (o->alias) {
3463 i++;
de890a1e 3464 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3465 }
214e1eca
JA
3466
3467 i++;
3468 o++;
3469 assert(i < FIO_NR_OPTIONS);
3470 }
3471}
3472
de890a1e
SL
3473void fio_options_set_ioengine_opts(struct option *long_options,
3474 struct thread_data *td)
3475{
3476 unsigned int i;
3477
3478 i = 0;
3479 while (long_options[i].name) {
3480 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3481 memset(&long_options[i], 0, sizeof(*long_options));
3482 break;
3483 }
3484 i++;
3485 }
3486
3487 /*
3488 * Just clear out the prior ioengine options.
3489 */
3490 if (!td || !td->eo)
3491 return;
3492
3493 options_to_lopts(td->io_ops->options, long_options, i,
3494 FIO_GETOPT_IOENGINE);
3495}
3496
3497void fio_options_dup_and_init(struct option *long_options)
3498{
3499 unsigned int i;
3500
9af4a244 3501 options_init(fio_options);
de890a1e
SL
3502
3503 i = 0;
3504 while (long_options[i].name)
3505 i++;
3506
9af4a244 3507 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3508}
3509
74929ac2
JA
3510struct fio_keyword {
3511 const char *word;
3512 const char *desc;
3513 char *replace;
3514};
3515
3516static struct fio_keyword fio_keywords[] = {
3517 {
3518 .word = "$pagesize",
3519 .desc = "Page size in the system",
3520 },
3521 {
3522 .word = "$mb_memory",
3523 .desc = "Megabytes of memory online",
3524 },
3525 {
3526 .word = "$ncpus",
3527 .desc = "Number of CPUs online in the system",
3528 },
3529 {
3530 .word = NULL,
3531 },
3532};
3533
3534void fio_keywords_init(void)
3535{
3b2e1464 3536 unsigned long long mb_memory;
74929ac2
JA
3537 char buf[128];
3538 long l;
3539
a4cfc477 3540 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3541 fio_keywords[0].replace = strdup(buf);
3542
8eb016d3 3543 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3544 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3545 fio_keywords[1].replace = strdup(buf);
3546
c00a2289 3547 l = cpus_online();
74929ac2
JA
3548 sprintf(buf, "%lu", l);
3549 fio_keywords[2].replace = strdup(buf);
3550}
3551
892a6ffc
JA
3552#define BC_APP "bc"
3553
3554static char *bc_calc(char *str)
3555{
d0c814ec 3556 char buf[128], *tmp;
892a6ffc
JA
3557 FILE *f;
3558 int ret;
3559
3560 /*
3561 * No math, just return string
3562 */
d0c814ec
SL
3563 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3564 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3565 return str;
3566
3567 /*
3568 * Split option from value, we only need to calculate the value
3569 */
3570 tmp = strchr(str, '=');
3571 if (!tmp)
3572 return str;
3573
3574 tmp++;
892a6ffc 3575
d0c814ec
SL
3576 /*
3577 * Prevent buffer overflows; such a case isn't reasonable anyway
3578 */
3579 if (strlen(str) >= 128 || strlen(tmp) > 100)
3580 return str;
892a6ffc
JA
3581
3582 sprintf(buf, "which %s > /dev/null", BC_APP);
3583 if (system(buf)) {
3584 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3585 return NULL;
3586 }
3587
d0c814ec 3588 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3589 f = popen(buf, "r");
3c3ed070 3590 if (!f)
892a6ffc 3591 return NULL;
892a6ffc 3592
d0c814ec 3593 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 3594 if (ret <= 0)
892a6ffc 3595 return NULL;
892a6ffc 3596
892a6ffc 3597 pclose(f);
d0c814ec
SL
3598 buf[(tmp - str) + ret - 1] = '\0';
3599 memcpy(buf, str, tmp - str);
892a6ffc 3600 free(str);
d0c814ec
SL
3601 return strdup(buf);
3602}
3603
3604/*
3605 * Return a copy of the input string with substrings of the form ${VARNAME}
3606 * substituted with the value of the environment variable VARNAME. The
3607 * substitution always occurs, even if VARNAME is empty or the corresponding
3608 * environment variable undefined.
3609 */
3610static char *option_dup_subs(const char *opt)
3611{
3612 char out[OPT_LEN_MAX+1];
3613 char in[OPT_LEN_MAX+1];
3614 char *outptr = out;
3615 char *inptr = in;
3616 char *ch1, *ch2, *env;
3617 ssize_t nchr = OPT_LEN_MAX;
3618 size_t envlen;
3619
3620 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3621 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3622 return NULL;
3623 }
3624
3625 in[OPT_LEN_MAX] = '\0';
3626 strncpy(in, opt, OPT_LEN_MAX);
3627
3628 while (*inptr && nchr > 0) {
3629 if (inptr[0] == '$' && inptr[1] == '{') {
3630 ch2 = strchr(inptr, '}');
3631 if (ch2 && inptr+1 < ch2) {
3632 ch1 = inptr+2;
3633 inptr = ch2+1;
3634 *ch2 = '\0';
3635
3636 env = getenv(ch1);
3637 if (env) {
3638 envlen = strlen(env);
3639 if (envlen <= nchr) {
3640 memcpy(outptr, env, envlen);
3641 outptr += envlen;
3642 nchr -= envlen;
3643 }
3644 }
3645
3646 continue;
3647 }
3648 }
3649
3650 *outptr++ = *inptr++;
3651 --nchr;
3652 }
3653
3654 *outptr = '\0';
3655 return strdup(out);
892a6ffc
JA
3656}
3657
74929ac2
JA
3658/*
3659 * Look for reserved variable names and replace them with real values
3660 */
3661static char *fio_keyword_replace(char *opt)
3662{
3663 char *s;
3664 int i;
d0c814ec 3665 int docalc = 0;
74929ac2
JA
3666
3667 for (i = 0; fio_keywords[i].word != NULL; i++) {
3668 struct fio_keyword *kw = &fio_keywords[i];
3669
3670 while ((s = strstr(opt, kw->word)) != NULL) {
3671 char *new = malloc(strlen(opt) + 1);
3672 char *o_org = opt;
3673 int olen = s - opt;
3674 int len;
3675
3676 /*
3677 * Copy part of the string before the keyword and
3678 * sprintf() the replacement after it.
3679 */
3680 memcpy(new, opt, olen);
3681 len = sprintf(new + olen, "%s", kw->replace);
3682
3683 /*
3684 * If there's more in the original string, copy that
3685 * in too
3686 */
3687 opt += strlen(kw->word) + olen;
3688 if (strlen(opt))
3689 memcpy(new + olen + len, opt, opt - o_org - 1);
3690
3691 /*
3692 * replace opt and free the old opt
3693 */
3694 opt = new;
d0c814ec 3695 free(o_org);
7a958bd5 3696
d0c814ec 3697 docalc = 1;
74929ac2
JA
3698 }
3699 }
3700
d0c814ec
SL
3701 /*
3702 * Check for potential math and invoke bc, if possible
3703 */
3704 if (docalc)
3705 opt = bc_calc(opt);
3706
7a958bd5 3707 return opt;
74929ac2
JA
3708}
3709
d0c814ec
SL
3710static char **dup_and_sub_options(char **opts, int num_opts)
3711{
3712 int i;
3713 char **opts_copy = malloc(num_opts * sizeof(*opts));
3714 for (i = 0; i < num_opts; i++) {
3715 opts_copy[i] = option_dup_subs(opts[i]);
3716 if (!opts_copy[i])
3717 continue;
3718 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3719 }
3720 return opts_copy;
3721}
3722
292cc475
JA
3723int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3724 int dump_cmdline)
214e1eca 3725{
de890a1e 3726 int i, ret, unknown;
d0c814ec 3727 char **opts_copy;
3b8b7135 3728
9af4a244 3729 sort_options(opts, fio_options, num_opts);
d0c814ec 3730 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3731
de890a1e
SL
3732 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3733 struct fio_option *o;
9af4a244 3734 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 3735 &o, td, dump_cmdline);
d0c814ec 3736
de890a1e
SL
3737 if (opts_copy[i]) {
3738 if (newret && !o) {
3739 unknown++;
3740 continue;
3741 }
d0c814ec 3742 free(opts_copy[i]);
de890a1e
SL
3743 opts_copy[i] = NULL;
3744 }
3745
3746 ret |= newret;
3747 }
3748
3749 if (unknown) {
3750 ret |= ioengine_load(td);
3751 if (td->eo) {
3752 sort_options(opts_copy, td->io_ops->options, num_opts);
3753 opts = opts_copy;
3754 }
3755 for (i = 0; i < num_opts; i++) {
3756 struct fio_option *o = NULL;
3757 int newret = 1;
3758 if (!opts_copy[i])
3759 continue;
3760
3761 if (td->eo)
3762 newret = parse_option(opts_copy[i], opts[i],
3763 td->io_ops->options, &o,
292cc475 3764 td->eo, dump_cmdline);
de890a1e
SL
3765
3766 ret |= newret;
3767 if (!o)
3768 log_err("Bad option <%s>\n", opts[i]);
3769
3770 free(opts_copy[i]);
3771 opts_copy[i] = NULL;
3772 }
74929ac2 3773 }
3b8b7135 3774
d0c814ec 3775 free(opts_copy);
3b8b7135 3776 return ret;
214e1eca
JA
3777}
3778
3779int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3780{
9af4a244 3781 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3782}
3783
de890a1e
SL
3784int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3785 char *val)
3786{
8a96c80e 3787 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
de890a1e
SL
3788}
3789
214e1eca
JA
3790void fio_fill_default_options(struct thread_data *td)
3791{
cb1402d6 3792 td->o.magic = OPT_MAGIC;
9af4a244 3793 fill_default_options(td, fio_options);
214e1eca
JA
3794}
3795
3796int fio_show_option_help(const char *opt)
3797{
9af4a244 3798 return show_cmd_help(fio_options, opt);
214e1eca 3799}
d23bb327 3800
de890a1e 3801void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3802{
de890a1e 3803 struct fio_option *o;
d23bb327 3804 char **ptr;
d23bb327 3805
de890a1e
SL
3806 for (o = &options[0]; o->name; o++) {
3807 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3808 continue;
3809
f0fdbcaf 3810 ptr = td_var(data, o, o->off1);
7e356b2d
JA
3811 if (*ptr)
3812 *ptr = strdup(*ptr);
d23bb327
JA
3813 }
3814}
3815
de890a1e
SL
3816/*
3817 * dupe FIO_OPT_STR_STORE options
3818 */
3819void fio_options_mem_dupe(struct thread_data *td)
3820{
9af4a244 3821 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3822
3823 if (td->eo && td->io_ops) {
de890a1e 3824 void *oldeo = td->eo;
1647f592 3825
de890a1e
SL
3826 td->eo = malloc(td->io_ops->option_struct_size);
3827 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3828 options_mem_dupe(td->eo, td->io_ops->options);
3829 }
3830}
3831
d6978a32
JA
3832unsigned int fio_get_kb_base(void *data)
3833{
83ea422a 3834 struct thread_options *o = data;
d6978a32
JA
3835 unsigned int kb_base = 0;
3836
cb1402d6
JA
3837 /*
3838 * This is a hack... For private options, *data is not holding
3839 * a pointer to the thread_options, but to private data. This means
3840 * we can't safely dereference it, but magic is first so mem wise
3841 * it is valid. But this also means that if the job first sets
3842 * kb_base and expects that to be honored by private options,
3843 * it will be disappointed. We will return the global default
3844 * for this.
3845 */
3846 if (o && o->magic == OPT_MAGIC)
83ea422a 3847 kb_base = o->kb_base;
d6978a32
JA
3848 if (!kb_base)
3849 kb_base = 1024;
3850
3851 return kb_base;
3852}
9f988e2e 3853
07b3232d 3854int add_option(struct fio_option *o)
9f988e2e 3855{
07b3232d
JA
3856 struct fio_option *__o;
3857 int opt_index = 0;
3858
9af4a244 3859 __o = fio_options;
07b3232d
JA
3860 while (__o->name) {
3861 opt_index++;
3862 __o++;
3863 }
3864
7b504edd
JA
3865 if (opt_index + 1 == FIO_MAX_OPTS) {
3866 log_err("fio: FIO_MAX_OPTS is too small\n");
3867 return 1;
3868 }
3869
9af4a244 3870 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 3871 fio_options[opt_index + 1].name = NULL;
07b3232d 3872 return 0;
9f988e2e 3873}
e2de69da 3874
07b3232d 3875void invalidate_profile_options(const char *prof_name)
e2de69da 3876{
07b3232d 3877 struct fio_option *o;
e2de69da 3878
9af4a244 3879 o = fio_options;
07b3232d
JA
3880 while (o->name) {
3881 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3882 o->type = FIO_OPT_INVALID;
3883 o->prof_name = NULL;
3884 }
3885 o++;
e2de69da
JA
3886 }
3887}
f5b6bb85
JA
3888
3889void add_opt_posval(const char *optname, const char *ival, const char *help)
3890{
3891 struct fio_option *o;
3892 unsigned int i;
3893
9af4a244 3894 o = find_option(fio_options, optname);
f5b6bb85
JA
3895 if (!o)
3896 return;
3897
3898 for (i = 0; i < PARSE_MAX_VP; i++) {
3899 if (o->posval[i].ival)
3900 continue;
3901
3902 o->posval[i].ival = ival;
3903 o->posval[i].help = help;
3904 break;
3905 }
3906}
3907
3908void del_opt_posval(const char *optname, const char *ival)
3909{
3910 struct fio_option *o;
3911 unsigned int i;
3912
9af4a244 3913 o = find_option(fio_options, optname);
f5b6bb85
JA
3914 if (!o)
3915 return;
3916
3917 for (i = 0; i < PARSE_MAX_VP; i++) {
3918 if (!o->posval[i].ival)
3919 continue;
3920 if (strcmp(o->posval[i].ival, ival))
3921 continue;
3922
3923 o->posval[i].ival = NULL;
3924 o->posval[i].help = NULL;
3925 }
3926}
7e356b2d
JA
3927
3928void fio_options_free(struct thread_data *td)
3929{
9af4a244 3930 options_free(fio_options, td);
de890a1e
SL
3931 if (td->eo && td->io_ops && td->io_ops->options) {
3932 options_free(td->io_ops->options, td->eo);
3933 free(td->eo);
3934 td->eo = NULL;
3935 }
7e356b2d 3936}
c504ee55
JA
3937
3938struct fio_option *fio_option_find(const char *name)
3939{
3940 return find_option(fio_options, name);
3941}
3942