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