Add support for the Google xxhash checksumming function
[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",
1837 },
214e1eca
JA
1838 {
1839 .name = "nrfiles",
e8b0e958 1840 .lname = "Number of files",
d7c8be03 1841 .alias = "nr_files",
214e1eca
JA
1842 .type = FIO_OPT_INT,
1843 .off1 = td_var_offset(nr_files),
1844 .help = "Split job workload between this number of files",
1845 .def = "1",
20eb06bd 1846 .interval = 1,
e8b0e958
JA
1847 .category = FIO_OPT_C_FILE,
1848 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1849 },
1850 {
1851 .name = "openfiles",
e8b0e958 1852 .lname = "Number of open files",
214e1eca
JA
1853 .type = FIO_OPT_INT,
1854 .off1 = td_var_offset(open_files),
1855 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1856 .category = FIO_OPT_C_FILE,
1857 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1858 },
1859 {
1860 .name = "file_service_type",
e8b0e958 1861 .lname = "File service type",
214e1eca
JA
1862 .type = FIO_OPT_STR,
1863 .cb = str_fst_cb,
1864 .off1 = td_var_offset(file_service_type),
1865 .help = "How to select which file to service next",
1866 .def = "roundrobin",
e8b0e958
JA
1867 .category = FIO_OPT_C_FILE,
1868 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1869 .posval = {
1870 { .ival = "random",
1871 .oval = FIO_FSERVICE_RANDOM,
1872 .help = "Choose a file at random",
1873 },
1874 { .ival = "roundrobin",
1875 .oval = FIO_FSERVICE_RR,
1876 .help = "Round robin select files",
1877 },
a086c257
JA
1878 { .ival = "sequential",
1879 .oval = FIO_FSERVICE_SEQ,
1880 .help = "Finish one file before moving to the next",
1881 },
214e1eca 1882 },
67a1000f 1883 .parent = "nrfiles",
d71c154c 1884 .hide = 1,
67a1000f 1885 },
97ac992c 1886#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
1887 {
1888 .name = "fallocate",
e8b0e958 1889 .lname = "Fallocate",
a596f047
EG
1890 .type = FIO_OPT_STR,
1891 .off1 = td_var_offset(fallocate_mode),
1892 .help = "Whether pre-allocation is performed when laying out files",
1893 .def = "posix",
e8b0e958
JA
1894 .category = FIO_OPT_C_FILE,
1895 .group = FIO_OPT_G_INVALID,
a596f047
EG
1896 .posval = {
1897 { .ival = "none",
1898 .oval = FIO_FALLOCATE_NONE,
1899 .help = "Do not pre-allocate space",
1900 },
1901 { .ival = "posix",
1902 .oval = FIO_FALLOCATE_POSIX,
1903 .help = "Use posix_fallocate()",
1904 },
97ac992c 1905#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
1906 { .ival = "keep",
1907 .oval = FIO_FALLOCATE_KEEP_SIZE,
1908 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1909 },
7bc8c2cf 1910#endif
a596f047
EG
1911 /* Compatibility with former boolean values */
1912 { .ival = "0",
1913 .oval = FIO_FALLOCATE_NONE,
1914 .help = "Alias for 'none'",
1915 },
1916 { .ival = "1",
1917 .oval = FIO_FALLOCATE_POSIX,
1918 .help = "Alias for 'posix'",
1919 },
1920 },
1921 },
97ac992c 1922#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
1923 {
1924 .name = "fadvise_hint",
e8b0e958 1925 .lname = "Fadvise hint",
67a1000f
JA
1926 .type = FIO_OPT_BOOL,
1927 .off1 = td_var_offset(fadvise_hint),
1928 .help = "Use fadvise() to advise the kernel on IO pattern",
1929 .def = "1",
e8b0e958
JA
1930 .category = FIO_OPT_C_FILE,
1931 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1932 },
1933 {
1934 .name = "fsync",
e8b0e958 1935 .lname = "Fsync",
214e1eca
JA
1936 .type = FIO_OPT_INT,
1937 .off1 = td_var_offset(fsync_blocks),
1938 .help = "Issue fsync for writes every given number of blocks",
1939 .def = "0",
20eb06bd 1940 .interval = 1,
e8b0e958
JA
1941 .category = FIO_OPT_C_FILE,
1942 .group = FIO_OPT_G_INVALID,
214e1eca 1943 },
5f9099ea
JA
1944 {
1945 .name = "fdatasync",
e8b0e958 1946 .lname = "Fdatasync",
5f9099ea
JA
1947 .type = FIO_OPT_INT,
1948 .off1 = td_var_offset(fdatasync_blocks),
1949 .help = "Issue fdatasync for writes every given number of blocks",
1950 .def = "0",
20eb06bd 1951 .interval = 1,
e8b0e958
JA
1952 .category = FIO_OPT_C_FILE,
1953 .group = FIO_OPT_G_INVALID,
5f9099ea 1954 },
1ef2b6be
JA
1955 {
1956 .name = "write_barrier",
e8b0e958 1957 .lname = "Write barrier",
1ef2b6be
JA
1958 .type = FIO_OPT_INT,
1959 .off1 = td_var_offset(barrier_blocks),
1960 .help = "Make every Nth write a barrier write",
1961 .def = "0",
20eb06bd 1962 .interval = 1,
e8b0e958
JA
1963 .category = FIO_OPT_C_IO,
1964 .group = FIO_OPT_G_INVALID,
1ef2b6be 1965 },
67bf9823 1966#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
1967 {
1968 .name = "sync_file_range",
e8b0e958 1969 .lname = "Sync file range",
44f29692
JA
1970 .posval = {
1971 { .ival = "wait_before",
1972 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1973 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 1974 .orval = 1,
44f29692
JA
1975 },
1976 { .ival = "write",
1977 .oval = SYNC_FILE_RANGE_WRITE,
1978 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 1979 .orval = 1,
44f29692
JA
1980 },
1981 {
1982 .ival = "wait_after",
1983 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1984 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 1985 .orval = 1,
44f29692
JA
1986 },
1987 },
3843deb3 1988 .type = FIO_OPT_STR_MULTI,
44f29692
JA
1989 .cb = str_sfr_cb,
1990 .off1 = td_var_offset(sync_file_range),
1991 .help = "Use sync_file_range()",
e8b0e958
JA
1992 .category = FIO_OPT_C_FILE,
1993 .group = FIO_OPT_G_INVALID,
44f29692
JA
1994 },
1995#endif
214e1eca
JA
1996 {
1997 .name = "direct",
e8b0e958 1998 .lname = "Direct I/O",
214e1eca
JA
1999 .type = FIO_OPT_BOOL,
2000 .off1 = td_var_offset(odirect),
2001 .help = "Use O_DIRECT IO (negates buffered)",
2002 .def = "0",
a01a1bc5 2003 .inverse = "buffered",
e8b0e958 2004 .category = FIO_OPT_C_IO,
3ceb458f 2005 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2006 },
d01612f3
CM
2007 {
2008 .name = "atomic",
2009 .lname = "Atomic I/O",
2010 .type = FIO_OPT_BOOL,
2011 .off1 = td_var_offset(oatomic),
2012 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2013 .def = "0",
2014 .category = FIO_OPT_C_IO,
2015 .group = FIO_OPT_G_IO_TYPE,
2016 },
214e1eca
JA
2017 {
2018 .name = "buffered",
e8b0e958 2019 .lname = "Buffered I/O",
214e1eca
JA
2020 .type = FIO_OPT_BOOL,
2021 .off1 = td_var_offset(odirect),
2022 .neg = 1,
2023 .help = "Use buffered IO (negates direct)",
2024 .def = "1",
a01a1bc5 2025 .inverse = "direct",
e8b0e958 2026 .category = FIO_OPT_C_IO,
3ceb458f 2027 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2028 },
2029 {
2030 .name = "overwrite",
e8b0e958 2031 .lname = "Overwrite",
214e1eca
JA
2032 .type = FIO_OPT_BOOL,
2033 .off1 = td_var_offset(overwrite),
2034 .help = "When writing, set whether to overwrite current data",
2035 .def = "0",
e8b0e958
JA
2036 .category = FIO_OPT_C_FILE,
2037 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2038 },
2039 {
2040 .name = "loops",
e8b0e958 2041 .lname = "Loops",
214e1eca
JA
2042 .type = FIO_OPT_INT,
2043 .off1 = td_var_offset(loops),
2044 .help = "Number of times to run the job",
2045 .def = "1",
20eb06bd 2046 .interval = 1,
e8b0e958 2047 .category = FIO_OPT_C_GENERAL,
a1f6afec 2048 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2049 },
2050 {
2051 .name = "numjobs",
e8b0e958 2052 .lname = "Number of jobs",
214e1eca
JA
2053 .type = FIO_OPT_INT,
2054 .off1 = td_var_offset(numjobs),
2055 .help = "Duplicate this job this many times",
2056 .def = "1",
20eb06bd 2057 .interval = 1,
e8b0e958 2058 .category = FIO_OPT_C_GENERAL,
a1f6afec 2059 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2060 },
2061 {
2062 .name = "startdelay",
e8b0e958 2063 .lname = "Start delay",
a5737c93 2064 .type = FIO_OPT_STR_VAL_TIME,
214e1eca 2065 .off1 = td_var_offset(start_delay),
23ed19b0 2066 .off2 = td_var_offset(start_delay_high),
214e1eca
JA
2067 .help = "Only start job when this period has passed",
2068 .def = "0",
e8b0e958 2069 .category = FIO_OPT_C_GENERAL,
a1f6afec 2070 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2071 },
2072 {
2073 .name = "runtime",
e8b0e958 2074 .lname = "Runtime",
214e1eca
JA
2075 .alias = "timeout",
2076 .type = FIO_OPT_STR_VAL_TIME,
2077 .off1 = td_var_offset(timeout),
2078 .help = "Stop workload when this amount of time has passed",
2079 .def = "0",
e8b0e958 2080 .category = FIO_OPT_C_GENERAL,
a1f6afec 2081 .group = FIO_OPT_G_RUNTIME,
214e1eca 2082 },
cf4464ca
JA
2083 {
2084 .name = "time_based",
e8b0e958 2085 .lname = "Time based",
cf4464ca
JA
2086 .type = FIO_OPT_STR_SET,
2087 .off1 = td_var_offset(time_based),
2088 .help = "Keep running until runtime/timeout is met",
e8b0e958 2089 .category = FIO_OPT_C_GENERAL,
a1f6afec 2090 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2091 },
62167762
JC
2092 {
2093 .name = "verify_only",
2094 .lname = "Verify only",
2095 .type = FIO_OPT_STR_SET,
2096 .off1 = td_var_offset(verify_only),
2097 .help = "Verifies previously written data is still valid",
2098 .category = FIO_OPT_C_GENERAL,
2099 .group = FIO_OPT_G_RUNTIME,
2100 },
721938ae
JA
2101 {
2102 .name = "ramp_time",
e8b0e958 2103 .lname = "Ramp time",
721938ae
JA
2104 .type = FIO_OPT_STR_VAL_TIME,
2105 .off1 = td_var_offset(ramp_time),
2106 .help = "Ramp up time before measuring performance",
e8b0e958 2107 .category = FIO_OPT_C_GENERAL,
a1f6afec 2108 .group = FIO_OPT_G_RUNTIME,
721938ae 2109 },
c223da83
JA
2110 {
2111 .name = "clocksource",
e8b0e958 2112 .lname = "Clock source",
c223da83
JA
2113 .type = FIO_OPT_STR,
2114 .cb = fio_clock_source_cb,
2115 .off1 = td_var_offset(clocksource),
2116 .help = "What type of timing source to use",
e8b0e958 2117 .category = FIO_OPT_C_GENERAL,
10860056 2118 .group = FIO_OPT_G_CLOCK,
c223da83 2119 .posval = {
67bf9823 2120#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2121 { .ival = "gettimeofday",
2122 .oval = CS_GTOD,
2123 .help = "Use gettimeofday(2) for timing",
2124 },
67bf9823
JA
2125#endif
2126#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2127 { .ival = "clock_gettime",
2128 .oval = CS_CGETTIME,
2129 .help = "Use clock_gettime(2) for timing",
2130 },
67bf9823 2131#endif
c223da83
JA
2132#ifdef ARCH_HAVE_CPU_CLOCK
2133 { .ival = "cpu",
2134 .oval = CS_CPUCLOCK,
2135 .help = "Use CPU private clock",
2136 },
2137#endif
2138 },
2139 },
214e1eca
JA
2140 {
2141 .name = "mem",
d3aad8f2 2142 .alias = "iomem",
e8b0e958 2143 .lname = "I/O Memory",
214e1eca
JA
2144 .type = FIO_OPT_STR,
2145 .cb = str_mem_cb,
2146 .off1 = td_var_offset(mem_type),
2147 .help = "Backing type for IO buffers",
2148 .def = "malloc",
e8b0e958
JA
2149 .category = FIO_OPT_C_IO,
2150 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2151 .posval = {
2152 { .ival = "malloc",
2153 .oval = MEM_MALLOC,
2154 .help = "Use malloc(3) for IO buffers",
2155 },
37c8cdfe
JA
2156 { .ival = "shm",
2157 .oval = MEM_SHM,
2158 .help = "Use shared memory segments for IO buffers",
2159 },
214e1eca
JA
2160#ifdef FIO_HAVE_HUGETLB
2161 { .ival = "shmhuge",
2162 .oval = MEM_SHMHUGE,
2163 .help = "Like shm, but use huge pages",
2164 },
b370e46a 2165#endif
37c8cdfe
JA
2166 { .ival = "mmap",
2167 .oval = MEM_MMAP,
2168 .help = "Use mmap(2) (file or anon) for IO buffers",
2169 },
214e1eca
JA
2170#ifdef FIO_HAVE_HUGETLB
2171 { .ival = "mmaphuge",
2172 .oval = MEM_MMAPHUGE,
2173 .help = "Like mmap, but use huge pages",
2174 },
2175#endif
2176 },
2177 },
d529ee19
JA
2178 {
2179 .name = "iomem_align",
2180 .alias = "mem_align",
e8b0e958 2181 .lname = "I/O memory alignment",
d529ee19
JA
2182 .type = FIO_OPT_INT,
2183 .off1 = td_var_offset(mem_align),
2184 .minval = 0,
2185 .help = "IO memory buffer offset alignment",
2186 .def = "0",
2187 .parent = "iomem",
d71c154c 2188 .hide = 1,
e8b0e958
JA
2189 .category = FIO_OPT_C_IO,
2190 .group = FIO_OPT_G_INVALID,
d529ee19 2191 },
214e1eca
JA
2192 {
2193 .name = "verify",
e8b0e958 2194 .lname = "Verify",
214e1eca
JA
2195 .type = FIO_OPT_STR,
2196 .off1 = td_var_offset(verify),
2197 .help = "Verify data written",
2198 .def = "0",
e8b0e958 2199 .category = FIO_OPT_C_IO,
3ceb458f 2200 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2201 .posval = {
2202 { .ival = "0",
2203 .oval = VERIFY_NONE,
2204 .help = "Don't do IO verification",
2205 },
fcca4b58
JA
2206 { .ival = "md5",
2207 .oval = VERIFY_MD5,
2208 .help = "Use md5 checksums for verification",
2209 },
d77a7af3
JA
2210 { .ival = "crc64",
2211 .oval = VERIFY_CRC64,
2212 .help = "Use crc64 checksums for verification",
2213 },
214e1eca
JA
2214 { .ival = "crc32",
2215 .oval = VERIFY_CRC32,
2216 .help = "Use crc32 checksums for verification",
2217 },
af497e6a 2218 { .ival = "crc32c-intel",
e3aaafc4
JA
2219 .oval = VERIFY_CRC32C,
2220 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2221 },
bac39e0e
JA
2222 { .ival = "crc32c",
2223 .oval = VERIFY_CRC32C,
e3aaafc4 2224 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2225 },
969f7ed3
JA
2226 { .ival = "crc16",
2227 .oval = VERIFY_CRC16,
2228 .help = "Use crc16 checksums for verification",
2229 },
1e154bdb
JA
2230 { .ival = "crc7",
2231 .oval = VERIFY_CRC7,
2232 .help = "Use crc7 checksums for verification",
2233 },
7c353ceb
JA
2234 { .ival = "sha1",
2235 .oval = VERIFY_SHA1,
2236 .help = "Use sha1 checksums for verification",
2237 },
cd14cc10
JA
2238 { .ival = "sha256",
2239 .oval = VERIFY_SHA256,
2240 .help = "Use sha256 checksums for verification",
2241 },
2242 { .ival = "sha512",
2243 .oval = VERIFY_SHA512,
2244 .help = "Use sha512 checksums for verification",
2245 },
844ea602
JA
2246 { .ival = "xxhash",
2247 .oval = VERIFY_XXHASH,
2248 .help = "Use xxhash checksums for verification",
2249 },
7437ee87
SL
2250 { .ival = "meta",
2251 .oval = VERIFY_META,
2252 .help = "Use io information",
2253 },
36690c9b
JA
2254 {
2255 .ival = "null",
2256 .oval = VERIFY_NULL,
2257 .help = "Pretend to verify",
2258 },
214e1eca
JA
2259 },
2260 },
005c565a
JA
2261 {
2262 .name = "do_verify",
e8b0e958 2263 .lname = "Perform verify step",
68e1f29a 2264 .type = FIO_OPT_BOOL,
005c565a
JA
2265 .off1 = td_var_offset(do_verify),
2266 .help = "Run verification stage after write",
2267 .def = "1",
2268 .parent = "verify",
d71c154c 2269 .hide = 1,
e8b0e958
JA
2270 .category = FIO_OPT_C_IO,
2271 .group = FIO_OPT_G_VERIFY,
005c565a 2272 },
160b966d
JA
2273 {
2274 .name = "verifysort",
e8b0e958 2275 .lname = "Verify sort",
160b966d
JA
2276 .type = FIO_OPT_BOOL,
2277 .off1 = td_var_offset(verifysort),
2278 .help = "Sort written verify blocks for read back",
2279 .def = "1",
c83f2df1 2280 .parent = "verify",
d71c154c 2281 .hide = 1,
e8b0e958
JA
2282 .category = FIO_OPT_C_IO,
2283 .group = FIO_OPT_G_VERIFY,
160b966d 2284 },
1ae83d45
JA
2285 {
2286 .name = "verifysort_nr",
2287 .type = FIO_OPT_INT,
2288 .off1 = td_var_offset(verifysort_nr),
2289 .help = "Pre-load and sort verify blocks for a read workload",
2290 .minval = 0,
2291 .maxval = 131072,
2292 .def = "1024",
2293 .parent = "verify",
836fcc0f
JA
2294 .category = FIO_OPT_C_IO,
2295 .group = FIO_OPT_G_VERIFY,
1ae83d45 2296 },
3f9f4e26 2297 {
a59e170d 2298 .name = "verify_interval",
e8b0e958 2299 .lname = "Verify interval",
e01b22b8 2300 .type = FIO_OPT_INT,
a59e170d 2301 .off1 = td_var_offset(verify_interval),
819a9680 2302 .minval = 2 * sizeof(struct verify_header),
a59e170d 2303 .help = "Store verify buffer header every N bytes",
afdf9352 2304 .parent = "verify",
d71c154c 2305 .hide = 1,
20eb06bd 2306 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2307 .category = FIO_OPT_C_IO,
2308 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2309 },
546a9142 2310 {
a59e170d 2311 .name = "verify_offset",
e8b0e958 2312 .lname = "Verify offset",
e01b22b8 2313 .type = FIO_OPT_INT,
a59e170d 2314 .help = "Offset verify header location by N bytes",
203160d5
JA
2315 .off1 = td_var_offset(verify_offset),
2316 .minval = sizeof(struct verify_header),
afdf9352 2317 .parent = "verify",
d71c154c 2318 .hide = 1,
e8b0e958
JA
2319 .category = FIO_OPT_C_IO,
2320 .group = FIO_OPT_G_VERIFY,
546a9142 2321 },
e28218f3
SL
2322 {
2323 .name = "verify_pattern",
e8b0e958 2324 .lname = "Verify pattern",
0e92f873 2325 .type = FIO_OPT_STR,
e28218f3
SL
2326 .cb = str_verify_pattern_cb,
2327 .help = "Fill pattern for IO buffers",
2328 .parent = "verify",
d71c154c 2329 .hide = 1,
e8b0e958
JA
2330 .category = FIO_OPT_C_IO,
2331 .group = FIO_OPT_G_VERIFY,
e28218f3 2332 },
a12a3b4d
JA
2333 {
2334 .name = "verify_fatal",
e8b0e958 2335 .lname = "Verify fatal",
68e1f29a 2336 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2337 .off1 = td_var_offset(verify_fatal),
2338 .def = "0",
2339 .help = "Exit on a single verify failure, don't continue",
2340 .parent = "verify",
d71c154c 2341 .hide = 1,
e8b0e958
JA
2342 .category = FIO_OPT_C_IO,
2343 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2344 },
b463e936
JA
2345 {
2346 .name = "verify_dump",
e8b0e958 2347 .lname = "Verify dump",
b463e936
JA
2348 .type = FIO_OPT_BOOL,
2349 .off1 = td_var_offset(verify_dump),
ef71e317 2350 .def = "0",
b463e936
JA
2351 .help = "Dump contents of good and bad blocks on failure",
2352 .parent = "verify",
d71c154c 2353 .hide = 1,
e8b0e958
JA
2354 .category = FIO_OPT_C_IO,
2355 .group = FIO_OPT_G_VERIFY,
b463e936 2356 },
e8462bd8
JA
2357 {
2358 .name = "verify_async",
e8b0e958 2359 .lname = "Verify asynchronously",
e8462bd8
JA
2360 .type = FIO_OPT_INT,
2361 .off1 = td_var_offset(verify_async),
2362 .def = "0",
2363 .help = "Number of async verifier threads to use",
2364 .parent = "verify",
d71c154c 2365 .hide = 1,
e8b0e958
JA
2366 .category = FIO_OPT_C_IO,
2367 .group = FIO_OPT_G_VERIFY,
e8462bd8 2368 },
9e144189
JA
2369 {
2370 .name = "verify_backlog",
e8b0e958 2371 .lname = "Verify backlog",
9e144189
JA
2372 .type = FIO_OPT_STR_VAL,
2373 .off1 = td_var_offset(verify_backlog),
2374 .help = "Verify after this number of blocks are written",
2375 .parent = "verify",
d71c154c 2376 .hide = 1,
e8b0e958
JA
2377 .category = FIO_OPT_C_IO,
2378 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2379 },
2380 {
2381 .name = "verify_backlog_batch",
e8b0e958 2382 .lname = "Verify backlog batch",
9e144189
JA
2383 .type = FIO_OPT_INT,
2384 .off1 = td_var_offset(verify_batch),
2385 .help = "Verify this number of IO blocks",
0d29de83 2386 .parent = "verify",
d71c154c 2387 .hide = 1,
e8b0e958
JA
2388 .category = FIO_OPT_C_IO,
2389 .group = FIO_OPT_G_VERIFY,
9e144189 2390 },
e8462bd8
JA
2391#ifdef FIO_HAVE_CPU_AFFINITY
2392 {
2393 .name = "verify_async_cpus",
e8b0e958 2394 .lname = "Async verify CPUs",
e8462bd8
JA
2395 .type = FIO_OPT_STR,
2396 .cb = str_verify_cpus_allowed_cb,
2397 .help = "Set CPUs allowed for async verify threads",
2398 .parent = "verify_async",
d71c154c 2399 .hide = 1,
e8b0e958
JA
2400 .category = FIO_OPT_C_IO,
2401 .group = FIO_OPT_G_VERIFY,
e8462bd8 2402 },
0d29de83 2403#endif
51aa2da8
JA
2404 {
2405 .name = "experimental_verify",
2406 .off1 = td_var_offset(experimental_verify),
2407 .type = FIO_OPT_BOOL,
b31eaac9 2408 .help = "Enable experimental verification",
836fcc0f
JA
2409 .category = FIO_OPT_C_IO,
2410 .group = FIO_OPT_G_VERIFY,
51aa2da8 2411 },
0d29de83
JA
2412#ifdef FIO_HAVE_TRIM
2413 {
2414 .name = "trim_percentage",
e8b0e958 2415 .lname = "Trim percentage",
0d29de83 2416 .type = FIO_OPT_INT,
203160d5 2417 .off1 = td_var_offset(trim_percentage),
20eb06bd 2418 .minval = 0,
0d29de83
JA
2419 .maxval = 100,
2420 .help = "Number of verify blocks to discard/trim",
2421 .parent = "verify",
2422 .def = "0",
20eb06bd 2423 .interval = 1,
d71c154c 2424 .hide = 1,
e8b0e958
JA
2425 .category = FIO_OPT_C_IO,
2426 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2427 },
2428 {
2429 .name = "trim_verify_zero",
e8b0e958 2430 .lname = "Verify trim zero",
20eb06bd 2431 .type = FIO_OPT_BOOL,
0d29de83
JA
2432 .help = "Verify that trim/discarded blocks are returned as zeroes",
2433 .off1 = td_var_offset(trim_zero),
2434 .parent = "trim_percentage",
d71c154c 2435 .hide = 1,
0d29de83 2436 .def = "1",
e8b0e958
JA
2437 .category = FIO_OPT_C_IO,
2438 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2439 },
2440 {
2441 .name = "trim_backlog",
e8b0e958 2442 .lname = "Trim backlog",
0d29de83
JA
2443 .type = FIO_OPT_STR_VAL,
2444 .off1 = td_var_offset(trim_backlog),
2445 .help = "Trim after this number of blocks are written",
2446 .parent = "trim_percentage",
d71c154c 2447 .hide = 1,
20eb06bd 2448 .interval = 1,
e8b0e958
JA
2449 .category = FIO_OPT_C_IO,
2450 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2451 },
2452 {
2453 .name = "trim_backlog_batch",
e8b0e958 2454 .lname = "Trim backlog batch",
0d29de83
JA
2455 .type = FIO_OPT_INT,
2456 .off1 = td_var_offset(trim_batch),
2457 .help = "Trim this number of IO blocks",
2458 .parent = "trim_percentage",
d71c154c 2459 .hide = 1,
20eb06bd 2460 .interval = 1,
e8b0e958
JA
2461 .category = FIO_OPT_C_IO,
2462 .group = FIO_OPT_G_TRIM,
0d29de83 2463 },
e8462bd8 2464#endif
214e1eca
JA
2465 {
2466 .name = "write_iolog",
e8b0e958 2467 .lname = "Write I/O log",
214e1eca
JA
2468 .type = FIO_OPT_STR_STORE,
2469 .off1 = td_var_offset(write_iolog_file),
2470 .help = "Store IO pattern to file",
e8b0e958
JA
2471 .category = FIO_OPT_C_IO,
2472 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2473 },
2474 {
2475 .name = "read_iolog",
e8b0e958 2476 .lname = "Read I/O log",
214e1eca
JA
2477 .type = FIO_OPT_STR_STORE,
2478 .off1 = td_var_offset(read_iolog_file),
2479 .help = "Playback IO pattern from file",
e8b0e958
JA
2480 .category = FIO_OPT_C_IO,
2481 .group = FIO_OPT_G_IOLOG,
214e1eca 2482 },
64bbb865
DN
2483 {
2484 .name = "replay_no_stall",
e8b0e958 2485 .lname = "Don't stall on replay",
20eb06bd 2486 .type = FIO_OPT_BOOL,
64bbb865
DN
2487 .off1 = td_var_offset(no_stall),
2488 .def = "0",
87e7a972 2489 .parent = "read_iolog",
d71c154c 2490 .hide = 1,
64bbb865 2491 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2492 .category = FIO_OPT_C_IO,
2493 .group = FIO_OPT_G_IOLOG,
64bbb865 2494 },
d1c46c04
DN
2495 {
2496 .name = "replay_redirect",
e8b0e958 2497 .lname = "Redirect device for replay",
d1c46c04
DN
2498 .type = FIO_OPT_STR_STORE,
2499 .off1 = td_var_offset(replay_redirect),
2500 .parent = "read_iolog",
d71c154c 2501 .hide = 1,
d1c46c04 2502 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2503 .category = FIO_OPT_C_IO,
2504 .group = FIO_OPT_G_IOLOG,
d1c46c04 2505 },
214e1eca
JA
2506 {
2507 .name = "exec_prerun",
e8b0e958 2508 .lname = "Pre-execute runnable",
214e1eca
JA
2509 .type = FIO_OPT_STR_STORE,
2510 .off1 = td_var_offset(exec_prerun),
2511 .help = "Execute this file prior to running job",
e8b0e958
JA
2512 .category = FIO_OPT_C_GENERAL,
2513 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2514 },
2515 {
2516 .name = "exec_postrun",
e8b0e958 2517 .lname = "Post-execute runnable",
214e1eca
JA
2518 .type = FIO_OPT_STR_STORE,
2519 .off1 = td_var_offset(exec_postrun),
2520 .help = "Execute this file after running job",
e8b0e958
JA
2521 .category = FIO_OPT_C_GENERAL,
2522 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2523 },
2524#ifdef FIO_HAVE_IOSCHED_SWITCH
2525 {
2526 .name = "ioscheduler",
e8b0e958 2527 .lname = "I/O scheduler",
214e1eca
JA
2528 .type = FIO_OPT_STR_STORE,
2529 .off1 = td_var_offset(ioscheduler),
2530 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2531 .category = FIO_OPT_C_FILE,
2532 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2533 },
2534#endif
2535 {
2536 .name = "zonesize",
e8b0e958 2537 .lname = "Zone size",
214e1eca
JA
2538 .type = FIO_OPT_STR_VAL,
2539 .off1 = td_var_offset(zone_size),
ed335855
SN
2540 .help = "Amount of data to read per zone",
2541 .def = "0",
20eb06bd 2542 .interval = 1024 * 1024,
e8b0e958
JA
2543 .category = FIO_OPT_C_IO,
2544 .group = FIO_OPT_G_ZONE,
ed335855
SN
2545 },
2546 {
2547 .name = "zonerange",
e8b0e958 2548 .lname = "Zone range",
ed335855
SN
2549 .type = FIO_OPT_STR_VAL,
2550 .off1 = td_var_offset(zone_range),
214e1eca
JA
2551 .help = "Give size of an IO zone",
2552 .def = "0",
20eb06bd 2553 .interval = 1024 * 1024,
e8b0e958
JA
2554 .category = FIO_OPT_C_IO,
2555 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2556 },
2557 {
2558 .name = "zoneskip",
e8b0e958 2559 .lname = "Zone skip",
214e1eca
JA
2560 .type = FIO_OPT_STR_VAL,
2561 .off1 = td_var_offset(zone_skip),
2562 .help = "Space between IO zones",
2563 .def = "0",
20eb06bd 2564 .interval = 1024 * 1024,
e8b0e958
JA
2565 .category = FIO_OPT_C_IO,
2566 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2567 },
2568 {
2569 .name = "lockmem",
e8b0e958 2570 .lname = "Lock memory",
214e1eca 2571 .type = FIO_OPT_STR_VAL,
1b79a070 2572 .off1 = td_var_offset(lockmem),
81c6b6cd 2573 .help = "Lock down this amount of memory (per worker)",
214e1eca 2574 .def = "0",
20eb06bd 2575 .interval = 1024 * 1024,
e8b0e958
JA
2576 .category = FIO_OPT_C_GENERAL,
2577 .group = FIO_OPT_G_INVALID,
214e1eca 2578 },
214e1eca
JA
2579 {
2580 .name = "rwmixread",
e8b0e958 2581 .lname = "Read/write mix read",
214e1eca 2582 .type = FIO_OPT_INT,
cb499fc4 2583 .cb = str_rwmix_read_cb,
214e1eca
JA
2584 .maxval = 100,
2585 .help = "Percentage of mixed workload that is reads",
2586 .def = "50",
20eb06bd 2587 .interval = 5,
90265353 2588 .inverse = "rwmixwrite",
e8b0e958
JA
2589 .category = FIO_OPT_C_IO,
2590 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2591 },
2592 {
2593 .name = "rwmixwrite",
e8b0e958 2594 .lname = "Read/write mix write",
214e1eca 2595 .type = FIO_OPT_INT,
cb499fc4 2596 .cb = str_rwmix_write_cb,
214e1eca
JA
2597 .maxval = 100,
2598 .help = "Percentage of mixed workload that is writes",
2599 .def = "50",
20eb06bd 2600 .interval = 5,
90265353 2601 .inverse = "rwmixread",
e8b0e958
JA
2602 .category = FIO_OPT_C_IO,
2603 .group = FIO_OPT_G_RWMIX,
214e1eca 2604 },
afdf9352
JA
2605 {
2606 .name = "rwmixcycle",
e8b0e958 2607 .lname = "Read/write mix cycle",
15ca150e 2608 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2609 .category = FIO_OPT_C_IO,
2610 .group = FIO_OPT_G_RWMIX,
afdf9352 2611 },
214e1eca
JA
2612 {
2613 .name = "nice",
e8b0e958 2614 .lname = "Nice",
214e1eca
JA
2615 .type = FIO_OPT_INT,
2616 .off1 = td_var_offset(nice),
2617 .help = "Set job CPU nice value",
2618 .minval = -19,
2619 .maxval = 20,
2620 .def = "0",
20eb06bd 2621 .interval = 1,
e8b0e958 2622 .category = FIO_OPT_C_GENERAL,
10860056 2623 .group = FIO_OPT_G_CRED,
214e1eca
JA
2624 },
2625#ifdef FIO_HAVE_IOPRIO
2626 {
2627 .name = "prio",
e8b0e958 2628 .lname = "I/O nice priority",
214e1eca 2629 .type = FIO_OPT_INT,
28727df7 2630 .off1 = td_var_offset(ioprio),
214e1eca
JA
2631 .help = "Set job IO priority value",
2632 .minval = 0,
2633 .maxval = 7,
20eb06bd 2634 .interval = 1,
e8b0e958 2635 .category = FIO_OPT_C_GENERAL,
10860056 2636 .group = FIO_OPT_G_CRED,
214e1eca
JA
2637 },
2638 {
2639 .name = "prioclass",
e8b0e958 2640 .lname = "I/O nice priority class",
214e1eca 2641 .type = FIO_OPT_INT,
28727df7 2642 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2643 .help = "Set job IO priority class",
2644 .minval = 0,
2645 .maxval = 3,
20eb06bd 2646 .interval = 1,
e8b0e958 2647 .category = FIO_OPT_C_GENERAL,
10860056 2648 .group = FIO_OPT_G_CRED,
214e1eca
JA
2649 },
2650#endif
2651 {
2652 .name = "thinktime",
e8b0e958 2653 .lname = "Thinktime",
214e1eca
JA
2654 .type = FIO_OPT_INT,
2655 .off1 = td_var_offset(thinktime),
2656 .help = "Idle time between IO buffers (usec)",
2657 .def = "0",
e8b0e958 2658 .category = FIO_OPT_C_IO,
3ceb458f 2659 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2660 },
2661 {
2662 .name = "thinktime_spin",
e8b0e958 2663 .lname = "Thinktime spin",
214e1eca
JA
2664 .type = FIO_OPT_INT,
2665 .off1 = td_var_offset(thinktime_spin),
2666 .help = "Start think time by spinning this amount (usec)",
2667 .def = "0",
afdf9352 2668 .parent = "thinktime",
d71c154c 2669 .hide = 1,
e8b0e958 2670 .category = FIO_OPT_C_IO,
3ceb458f 2671 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2672 },
2673 {
2674 .name = "thinktime_blocks",
e8b0e958 2675 .lname = "Thinktime blocks",
214e1eca
JA
2676 .type = FIO_OPT_INT,
2677 .off1 = td_var_offset(thinktime_blocks),
2678 .help = "IO buffer period between 'thinktime'",
2679 .def = "1",
afdf9352 2680 .parent = "thinktime",
d71c154c 2681 .hide = 1,
e8b0e958 2682 .category = FIO_OPT_C_IO,
3ceb458f 2683 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2684 },
2685 {
2686 .name = "rate",
e8b0e958 2687 .lname = "I/O rate",
e01b22b8 2688 .type = FIO_OPT_INT,
6eaf09d6
SL
2689 .off1 = td_var_offset(rate[DDIR_READ]),
2690 .off2 = td_var_offset(rate[DDIR_WRITE]),
2691 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2692 .help = "Set bandwidth rate",
e8b0e958
JA
2693 .category = FIO_OPT_C_IO,
2694 .group = FIO_OPT_G_RATE,
214e1eca
JA
2695 },
2696 {
2697 .name = "ratemin",
e8b0e958 2698 .lname = "I/O min rate",
e01b22b8 2699 .type = FIO_OPT_INT,
6eaf09d6
SL
2700 .off1 = td_var_offset(ratemin[DDIR_READ]),
2701 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2702 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2703 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2704 .parent = "rate",
d71c154c 2705 .hide = 1,
e8b0e958
JA
2706 .category = FIO_OPT_C_IO,
2707 .group = FIO_OPT_G_RATE,
4e991c23
JA
2708 },
2709 {
2710 .name = "rate_iops",
e8b0e958 2711 .lname = "I/O rate IOPS",
e01b22b8 2712 .type = FIO_OPT_INT,
6eaf09d6
SL
2713 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2714 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2715 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2716 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2717 .hide = 1,
e8b0e958
JA
2718 .category = FIO_OPT_C_IO,
2719 .group = FIO_OPT_G_RATE,
4e991c23
JA
2720 },
2721 {
2722 .name = "rate_iops_min",
e8b0e958 2723 .lname = "I/O min rate IOPS",
e01b22b8 2724 .type = FIO_OPT_INT,
6eaf09d6
SL
2725 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2726 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2727 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2728 .help = "Job must meet this rate or it will be shut down",
afdf9352 2729 .parent = "rate_iops",
d71c154c 2730 .hide = 1,
e8b0e958
JA
2731 .category = FIO_OPT_C_IO,
2732 .group = FIO_OPT_G_RATE,
214e1eca
JA
2733 },
2734 {
2735 .name = "ratecycle",
e8b0e958 2736 .lname = "I/O rate cycle",
214e1eca
JA
2737 .type = FIO_OPT_INT,
2738 .off1 = td_var_offset(ratecycle),
2739 .help = "Window average for rate limits (msec)",
2740 .def = "1000",
afdf9352 2741 .parent = "rate",
d71c154c 2742 .hide = 1,
e8b0e958
JA
2743 .category = FIO_OPT_C_IO,
2744 .group = FIO_OPT_G_RATE,
214e1eca 2745 },
15501535
JA
2746 {
2747 .name = "max_latency",
2748 .type = FIO_OPT_INT,
2749 .off1 = td_var_offset(max_latency),
2750 .help = "Maximum tolerated IO latency (usec)",
1e5324e7 2751 .category = FIO_OPT_C_IO,
3e260a46
JA
2752 .group = FIO_OPT_G_LATPROF,
2753 },
2754 {
2755 .name = "latency_target",
2756 .lname = "Latency Target (usec)",
2757 .type = FIO_OPT_STR_VAL_TIME,
2758 .off1 = td_var_offset(latency_target),
2759 .help = "Ramp to max queue depth supporting this latency",
2760 .category = FIO_OPT_C_IO,
2761 .group = FIO_OPT_G_LATPROF,
2762 },
2763 {
2764 .name = "latency_window",
2765 .lname = "Latency Window (usec)",
2766 .type = FIO_OPT_STR_VAL_TIME,
2767 .off1 = td_var_offset(latency_window),
2768 .help = "Time to sustain latency_target",
2769 .category = FIO_OPT_C_IO,
2770 .group = FIO_OPT_G_LATPROF,
2771 },
2772 {
2773 .name = "latency_percentile",
2774 .lname = "Latency Percentile",
2775 .type = FIO_OPT_FLOAT_LIST,
2776 .off1 = td_var_offset(latency_percentile),
2777 .help = "Percentile of IOs must be below latency_target",
2778 .def = "100",
2779 .maxlen = 1,
2780 .minfp = 0.0,
2781 .maxfp = 100.0,
2782 .category = FIO_OPT_C_IO,
2783 .group = FIO_OPT_G_LATPROF,
15501535 2784 },
214e1eca
JA
2785 {
2786 .name = "invalidate",
e8b0e958 2787 .lname = "Cache invalidate",
214e1eca
JA
2788 .type = FIO_OPT_BOOL,
2789 .off1 = td_var_offset(invalidate_cache),
2790 .help = "Invalidate buffer/page cache prior to running job",
2791 .def = "1",
e8b0e958 2792 .category = FIO_OPT_C_IO,
3ceb458f 2793 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2794 },
2795 {
2796 .name = "sync",
e8b0e958 2797 .lname = "Synchronous I/O",
214e1eca
JA
2798 .type = FIO_OPT_BOOL,
2799 .off1 = td_var_offset(sync_io),
2800 .help = "Use O_SYNC for buffered writes",
2801 .def = "0",
67a1000f 2802 .parent = "buffered",
d71c154c 2803 .hide = 1,
e8b0e958 2804 .category = FIO_OPT_C_IO,
3ceb458f 2805 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2806 },
214e1eca
JA
2807 {
2808 .name = "create_serialize",
e8b0e958 2809 .lname = "Create serialize",
214e1eca
JA
2810 .type = FIO_OPT_BOOL,
2811 .off1 = td_var_offset(create_serialize),
2812 .help = "Serialize creating of job files",
2813 .def = "1",
e8b0e958
JA
2814 .category = FIO_OPT_C_FILE,
2815 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2816 },
2817 {
2818 .name = "create_fsync",
e8b0e958 2819 .lname = "Create fsync",
214e1eca
JA
2820 .type = FIO_OPT_BOOL,
2821 .off1 = td_var_offset(create_fsync),
03e20d68 2822 .help = "fsync file after creation",
214e1eca 2823 .def = "1",
e8b0e958
JA
2824 .category = FIO_OPT_C_FILE,
2825 .group = FIO_OPT_G_INVALID,
214e1eca 2826 },
814452bd
JA
2827 {
2828 .name = "create_on_open",
e8b0e958 2829 .lname = "Create on open",
814452bd
JA
2830 .type = FIO_OPT_BOOL,
2831 .off1 = td_var_offset(create_on_open),
2832 .help = "Create files when they are opened for IO",
2833 .def = "0",
e8b0e958
JA
2834 .category = FIO_OPT_C_FILE,
2835 .group = FIO_OPT_G_INVALID,
814452bd 2836 },
25460cf6
JA
2837 {
2838 .name = "create_only",
2839 .type = FIO_OPT_BOOL,
2840 .off1 = td_var_offset(create_only),
2841 .help = "Only perform file creation phase",
d17fda71 2842 .category = FIO_OPT_C_FILE,
25460cf6
JA
2843 .def = "0",
2844 },
0b9d69ec 2845 {
afad68f7 2846 .name = "pre_read",
e8b0e958 2847 .lname = "Pre-read files",
afad68f7
ZY
2848 .type = FIO_OPT_BOOL,
2849 .off1 = td_var_offset(pre_read),
03e20d68 2850 .help = "Pre-read files before starting official testing",
afad68f7 2851 .def = "0",
e8b0e958
JA
2852 .category = FIO_OPT_C_FILE,
2853 .group = FIO_OPT_G_INVALID,
afad68f7 2854 },
214e1eca
JA
2855#ifdef FIO_HAVE_CPU_AFFINITY
2856 {
2857 .name = "cpumask",
e8b0e958 2858 .lname = "CPU mask",
214e1eca
JA
2859 .type = FIO_OPT_INT,
2860 .cb = str_cpumask_cb,
2861 .help = "CPU affinity mask",
e8b0e958 2862 .category = FIO_OPT_C_GENERAL,
10860056 2863 .group = FIO_OPT_G_CRED,
214e1eca 2864 },
d2e268b0
JA
2865 {
2866 .name = "cpus_allowed",
e8b0e958 2867 .lname = "CPUs allowed",
d2e268b0
JA
2868 .type = FIO_OPT_STR,
2869 .cb = str_cpus_allowed_cb,
2870 .help = "Set CPUs allowed",
e8b0e958 2871 .category = FIO_OPT_C_GENERAL,
10860056 2872 .group = FIO_OPT_G_CRED,
d2e268b0 2873 },
d0b937ed 2874#endif
67bf9823 2875#ifdef CONFIG_LIBNUMA
d0b937ed
YR
2876 {
2877 .name = "numa_cpu_nodes",
2878 .type = FIO_OPT_STR,
2879 .cb = str_numa_cpunodes_cb,
2880 .help = "NUMA CPU nodes bind",
6be54b2d
JA
2881 .category = FIO_OPT_C_GENERAL,
2882 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2883 },
2884 {
2885 .name = "numa_mem_policy",
2886 .type = FIO_OPT_STR,
2887 .cb = str_numa_mpol_cb,
2888 .help = "NUMA memory policy setup",
6be54b2d
JA
2889 .category = FIO_OPT_C_GENERAL,
2890 .group = FIO_OPT_G_INVALID,
d0b937ed 2891 },
214e1eca
JA
2892#endif
2893 {
2894 .name = "end_fsync",
e8b0e958 2895 .lname = "End fsync",
214e1eca
JA
2896 .type = FIO_OPT_BOOL,
2897 .off1 = td_var_offset(end_fsync),
2898 .help = "Include fsync at the end of job",
2899 .def = "0",
e8b0e958
JA
2900 .category = FIO_OPT_C_FILE,
2901 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2902 },
2903 {
2904 .name = "fsync_on_close",
e8b0e958 2905 .lname = "Fsync on close",
214e1eca
JA
2906 .type = FIO_OPT_BOOL,
2907 .off1 = td_var_offset(fsync_on_close),
2908 .help = "fsync files on close",
2909 .def = "0",
e8b0e958
JA
2910 .category = FIO_OPT_C_FILE,
2911 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2912 },
2913 {
2914 .name = "unlink",
e8b0e958 2915 .lname = "Unlink file",
214e1eca
JA
2916 .type = FIO_OPT_BOOL,
2917 .off1 = td_var_offset(unlink),
2918 .help = "Unlink created files after job has completed",
2919 .def = "0",
e8b0e958
JA
2920 .category = FIO_OPT_C_FILE,
2921 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2922 },
2923 {
2924 .name = "exitall",
e8b0e958 2925 .lname = "Exit-all on terminate",
214e1eca
JA
2926 .type = FIO_OPT_STR_SET,
2927 .cb = str_exitall_cb,
2928 .help = "Terminate all jobs when one exits",
e8b0e958 2929 .category = FIO_OPT_C_GENERAL,
a1f6afec 2930 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2931 },
2932 {
2933 .name = "stonewall",
e8b0e958 2934 .lname = "Wait for previous",
d392365e 2935 .alias = "wait_for_previous",
214e1eca
JA
2936 .type = FIO_OPT_STR_SET,
2937 .off1 = td_var_offset(stonewall),
2938 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2939 .category = FIO_OPT_C_GENERAL,
a1f6afec 2940 .group = FIO_OPT_G_PROCESS,
214e1eca 2941 },
b3d62a75
JA
2942 {
2943 .name = "new_group",
e8b0e958 2944 .lname = "New group",
b3d62a75
JA
2945 .type = FIO_OPT_STR_SET,
2946 .off1 = td_var_offset(new_group),
2947 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2948 .category = FIO_OPT_C_GENERAL,
a1f6afec 2949 .group = FIO_OPT_G_PROCESS,
b3d62a75 2950 },
214e1eca
JA
2951 {
2952 .name = "thread",
e8b0e958 2953 .lname = "Thread",
214e1eca
JA
2954 .type = FIO_OPT_STR_SET,
2955 .off1 = td_var_offset(use_thread),
20eb06bd 2956 .help = "Use threads instead of processes",
e8b0e958 2957 .category = FIO_OPT_C_GENERAL,
a1f6afec 2958 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2959 },
2960 {
2961 .name = "write_bw_log",
e8b0e958 2962 .lname = "Write bandwidth log",
203160d5
JA
2963 .type = FIO_OPT_STR_STORE,
2964 .off1 = td_var_offset(bw_log_file),
214e1eca 2965 .help = "Write log of bandwidth during run",
e8b0e958
JA
2966 .category = FIO_OPT_C_LOG,
2967 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2968 },
2969 {
2970 .name = "write_lat_log",
e8b0e958 2971 .lname = "Write latency log",
203160d5
JA
2972 .type = FIO_OPT_STR_STORE,
2973 .off1 = td_var_offset(lat_log_file),
214e1eca 2974 .help = "Write log of latency during run",
e8b0e958
JA
2975 .category = FIO_OPT_C_LOG,
2976 .group = FIO_OPT_G_INVALID,
214e1eca 2977 },
c8eeb9df
JA
2978 {
2979 .name = "write_iops_log",
e8b0e958 2980 .lname = "Write IOPS log",
577c83bd 2981 .type = FIO_OPT_STR_STORE,
203160d5 2982 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2983 .help = "Write log of IOPS during run",
e8b0e958
JA
2984 .category = FIO_OPT_C_LOG,
2985 .group = FIO_OPT_G_INVALID,
c8eeb9df 2986 },
b8bc8cba
JA
2987 {
2988 .name = "log_avg_msec",
e8b0e958 2989 .lname = "Log averaging (msec)",
b8bc8cba
JA
2990 .type = FIO_OPT_INT,
2991 .off1 = td_var_offset(log_avg_msec),
2992 .help = "Average bw/iops/lat logs over this period of time",
2993 .def = "0",
e8b0e958
JA
2994 .category = FIO_OPT_C_LOG,
2995 .group = FIO_OPT_G_INVALID,
b8bc8cba 2996 },
c504ee55
JA
2997 {
2998 .name = "bwavgtime",
2999 .lname = "Bandwidth average time",
3000 .type = FIO_OPT_INT,
3001 .off1 = td_var_offset(bw_avg_time),
3002 .help = "Time window over which to calculate bandwidth"
3003 " (msec)",
3004 .def = "500",
3005 .parent = "write_bw_log",
3006 .hide = 1,
3007 .interval = 100,
3008 .category = FIO_OPT_C_LOG,
3009 .group = FIO_OPT_G_INVALID,
3010 },
3011 {
3012 .name = "iopsavgtime",
3013 .lname = "IOPS average time",
3014 .type = FIO_OPT_INT,
3015 .off1 = td_var_offset(iops_avg_time),
3016 .help = "Time window over which to calculate IOPS (msec)",
3017 .def = "500",
3018 .parent = "write_iops_log",
3019 .hide = 1,
3020 .interval = 100,
3021 .category = FIO_OPT_C_LOG,
3022 .group = FIO_OPT_G_INVALID,
3023 },
214e1eca
JA
3024 {
3025 .name = "group_reporting",
e8b0e958 3026 .lname = "Group reporting",
d2507043 3027 .type = FIO_OPT_STR_SET,
214e1eca
JA
3028 .off1 = td_var_offset(group_reporting),
3029 .help = "Do reporting on a per-group basis",
10860056 3030 .category = FIO_OPT_C_STAT,
e8b0e958 3031 .group = FIO_OPT_G_INVALID,
214e1eca 3032 },
e9459e5a
JA
3033 {
3034 .name = "zero_buffers",
e8b0e958 3035 .lname = "Zero I/O buffers",
e9459e5a
JA
3036 .type = FIO_OPT_STR_SET,
3037 .off1 = td_var_offset(zero_buffers),
3038 .help = "Init IO buffers to all zeroes",
e8b0e958 3039 .category = FIO_OPT_C_IO,
3ceb458f 3040 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3041 },
5973cafb
JA
3042 {
3043 .name = "refill_buffers",
e8b0e958 3044 .lname = "Refill I/O buffers",
5973cafb
JA
3045 .type = FIO_OPT_STR_SET,
3046 .off1 = td_var_offset(refill_buffers),
3047 .help = "Refill IO buffers on every IO submit",
e8b0e958 3048 .category = FIO_OPT_C_IO,
3ceb458f 3049 .group = FIO_OPT_G_IO_BUF,
5973cafb 3050 },
fd68418e
JA
3051 {
3052 .name = "scramble_buffers",
e8b0e958 3053 .lname = "Scramble I/O buffers",
fd68418e
JA
3054 .type = FIO_OPT_BOOL,
3055 .off1 = td_var_offset(scramble_buffers),
3056 .help = "Slightly scramble buffers on every IO submit",
3057 .def = "1",
e8b0e958 3058 .category = FIO_OPT_C_IO,
3ceb458f 3059 .group = FIO_OPT_G_IO_BUF,
fd68418e 3060 },
ce35b1ec
JA
3061 {
3062 .name = "buffer_pattern",
3063 .lname = "Buffer pattern",
3064 .type = FIO_OPT_STR,
3065 .cb = str_buffer_pattern_cb,
3066 .help = "Fill pattern for IO buffers",
3067 .category = FIO_OPT_C_IO,
3068 .group = FIO_OPT_G_IO_BUF,
3069 },
9c42684e
JA
3070 {
3071 .name = "buffer_compress_percentage",
e8b0e958 3072 .lname = "Buffer compression percentage",
9c42684e
JA
3073 .type = FIO_OPT_INT,
3074 .off1 = td_var_offset(compress_percentage),
3075 .maxval = 100,
e7f5de90 3076 .minval = 0,
9c42684e 3077 .help = "How compressible the buffer is (approximately)",
20eb06bd 3078 .interval = 5,
e8b0e958 3079 .category = FIO_OPT_C_IO,
3ceb458f 3080 .group = FIO_OPT_G_IO_BUF,
9c42684e 3081 },
f97a43a1
JA
3082 {
3083 .name = "buffer_compress_chunk",
e8b0e958 3084 .lname = "Buffer compression chunk size",
f97a43a1
JA
3085 .type = FIO_OPT_INT,
3086 .off1 = td_var_offset(compress_chunk),
207b18e4 3087 .parent = "buffer_compress_percentage",
d71c154c 3088 .hide = 1,
f97a43a1 3089 .help = "Size of compressible region in buffer",
20eb06bd 3090 .interval = 256,
e8b0e958 3091 .category = FIO_OPT_C_IO,
3ceb458f 3092 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3093 },
83349190
YH
3094 {
3095 .name = "clat_percentiles",
e8b0e958 3096 .lname = "Completion latency percentiles",
83349190
YH
3097 .type = FIO_OPT_BOOL,
3098 .off1 = td_var_offset(clat_percentiles),
3099 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3100 .def = "1",
e8b0e958
JA
3101 .category = FIO_OPT_C_STAT,
3102 .group = FIO_OPT_G_INVALID,
83349190
YH
3103 },
3104 {
3105 .name = "percentile_list",
e8b0e958 3106 .lname = "Completion latency percentile list",
83349190
YH
3107 .type = FIO_OPT_FLOAT_LIST,
3108 .off1 = td_var_offset(percentile_list),
435d195a 3109 .off2 = td_var_offset(percentile_precision),
83349190 3110 .help = "Specify a custom list of percentiles to report",
fd112d34 3111 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3112 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3113 .minfp = 0.0,
3114 .maxfp = 100.0,
e8b0e958
JA
3115 .category = FIO_OPT_C_STAT,
3116 .group = FIO_OPT_G_INVALID,
83349190
YH
3117 },
3118
0a839f30
JA
3119#ifdef FIO_HAVE_DISK_UTIL
3120 {
3121 .name = "disk_util",
e8b0e958 3122 .lname = "Disk utilization",
0a839f30
JA
3123 .type = FIO_OPT_BOOL,
3124 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3125 .help = "Log disk utilization statistics",
0a839f30 3126 .def = "1",
e8b0e958
JA
3127 .category = FIO_OPT_C_STAT,
3128 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3129 },
3130#endif
993bf48b
JA
3131 {
3132 .name = "gtod_reduce",
e8b0e958 3133 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3134 .type = FIO_OPT_BOOL,
3135 .help = "Greatly reduce number of gettimeofday() calls",
3136 .cb = str_gtod_reduce_cb,
3137 .def = "0",
a4ed77fe 3138 .hide_on_set = 1,
e8b0e958
JA
3139 .category = FIO_OPT_C_STAT,
3140 .group = FIO_OPT_G_INVALID,
993bf48b 3141 },
02af0988
JA
3142 {
3143 .name = "disable_lat",
e8b0e958 3144 .lname = "Disable all latency stats",
02af0988
JA
3145 .type = FIO_OPT_BOOL,
3146 .off1 = td_var_offset(disable_lat),
3147 .help = "Disable latency numbers",
3148 .parent = "gtod_reduce",
d71c154c 3149 .hide = 1,
02af0988 3150 .def = "0",
e8b0e958
JA
3151 .category = FIO_OPT_C_STAT,
3152 .group = FIO_OPT_G_INVALID,
02af0988 3153 },
9520ebb9
JA
3154 {
3155 .name = "disable_clat",
e8b0e958 3156 .lname = "Disable completion latency stats",
9520ebb9
JA
3157 .type = FIO_OPT_BOOL,
3158 .off1 = td_var_offset(disable_clat),
3159 .help = "Disable completion latency numbers",
993bf48b 3160 .parent = "gtod_reduce",
d71c154c 3161 .hide = 1,
9520ebb9 3162 .def = "0",
e8b0e958
JA
3163 .category = FIO_OPT_C_STAT,
3164 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3165 },
3166 {
3167 .name = "disable_slat",
e8b0e958 3168 .lname = "Disable submission latency stats",
9520ebb9
JA
3169 .type = FIO_OPT_BOOL,
3170 .off1 = td_var_offset(disable_slat),
03e20d68 3171 .help = "Disable submission latency numbers",
993bf48b 3172 .parent = "gtod_reduce",
d71c154c 3173 .hide = 1,
9520ebb9 3174 .def = "0",
e8b0e958
JA
3175 .category = FIO_OPT_C_STAT,
3176 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3177 },
3178 {
3179 .name = "disable_bw_measurement",
e8b0e958 3180 .lname = "Disable bandwidth stats",
9520ebb9
JA
3181 .type = FIO_OPT_BOOL,
3182 .off1 = td_var_offset(disable_bw),
3183 .help = "Disable bandwidth logging",
993bf48b 3184 .parent = "gtod_reduce",
d71c154c 3185 .hide = 1,
9520ebb9 3186 .def = "0",
e8b0e958
JA
3187 .category = FIO_OPT_C_STAT,
3188 .group = FIO_OPT_G_INVALID,
9520ebb9 3189 },
be4ecfdf
JA
3190 {
3191 .name = "gtod_cpu",
e8b0e958 3192 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
3193 .type = FIO_OPT_INT,
3194 .cb = str_gtod_cpu_cb,
03e20d68 3195 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3196 .verify = gtod_cpu_verify,
e8b0e958 3197 .category = FIO_OPT_C_GENERAL,
10860056 3198 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3199 },
771e58be
JA
3200 {
3201 .name = "unified_rw_reporting",
3202 .type = FIO_OPT_BOOL,
3203 .off1 = td_var_offset(unified_rw_rep),
3204 .help = "Unify reporting across data direction",
3205 .def = "0",
90b7a96d
JA
3206 .category = FIO_OPT_C_GENERAL,
3207 .group = FIO_OPT_G_INVALID,
771e58be 3208 },
f2bba182
RR
3209 {
3210 .name = "continue_on_error",
e8b0e958 3211 .lname = "Continue on error",
06842027 3212 .type = FIO_OPT_STR,
f2bba182 3213 .off1 = td_var_offset(continue_on_error),
03e20d68 3214 .help = "Continue on non-fatal errors during IO",
06842027 3215 .def = "none",
e8b0e958 3216 .category = FIO_OPT_C_GENERAL,
bc3f552f 3217 .group = FIO_OPT_G_ERR,
06842027
SL
3218 .posval = {
3219 { .ival = "none",
3220 .oval = ERROR_TYPE_NONE,
3221 .help = "Exit when an error is encountered",
3222 },
3223 { .ival = "read",
3224 .oval = ERROR_TYPE_READ,
3225 .help = "Continue on read errors only",
3226 },
3227 { .ival = "write",
3228 .oval = ERROR_TYPE_WRITE,
3229 .help = "Continue on write errors only",
3230 },
3231 { .ival = "io",
3232 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3233 .help = "Continue on any IO errors",
3234 },
3235 { .ival = "verify",
3236 .oval = ERROR_TYPE_VERIFY,
3237 .help = "Continue on verify errors only",
3238 },
3239 { .ival = "all",
3240 .oval = ERROR_TYPE_ANY,
3241 .help = "Continue on all io and verify errors",
3242 },
3243 { .ival = "0",
3244 .oval = ERROR_TYPE_NONE,
3245 .help = "Alias for 'none'",
3246 },
3247 { .ival = "1",
3248 .oval = ERROR_TYPE_ANY,
3249 .help = "Alias for 'all'",
3250 },
3251 },
f2bba182 3252 },
8b28bd41
DM
3253 {
3254 .name = "ignore_error",
3255 .type = FIO_OPT_STR,
3256 .cb = str_ignore_error_cb,
3257 .help = "Set a specific list of errors to ignore",
3258 .parent = "rw",
a94eb99a 3259 .category = FIO_OPT_C_GENERAL,
bc3f552f 3260 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3261 },
3262 {
3263 .name = "error_dump",
3264 .type = FIO_OPT_BOOL,
3265 .off1 = td_var_offset(error_dump),
3266 .def = "0",
3267 .help = "Dump info on each error",
a94eb99a 3268 .category = FIO_OPT_C_GENERAL,
bc3f552f 3269 .group = FIO_OPT_G_ERR,
8b28bd41 3270 },
9ac8a797
JA
3271 {
3272 .name = "profile",
e8b0e958 3273 .lname = "Profile",
79d16311 3274 .type = FIO_OPT_STR_STORE,
9ac8a797 3275 .off1 = td_var_offset(profile),
9ac8a797 3276 .help = "Select a specific builtin performance test",
13fca827 3277 .category = FIO_OPT_C_PROFILE,
e8b0e958 3278 .group = FIO_OPT_G_INVALID,
9ac8a797 3279 },
a696fa2a
JA
3280 {
3281 .name = "cgroup",
e8b0e958 3282 .lname = "Cgroup",
a696fa2a
JA
3283 .type = FIO_OPT_STR_STORE,
3284 .off1 = td_var_offset(cgroup),
3285 .help = "Add job to cgroup of this name",
e8b0e958 3286 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3287 .group = FIO_OPT_G_CGROUP,
3288 },
3289 {
3290 .name = "cgroup_nodelete",
3291 .lname = "Cgroup no-delete",
3292 .type = FIO_OPT_BOOL,
3293 .off1 = td_var_offset(cgroup_nodelete),
3294 .help = "Do not delete cgroups after job completion",
3295 .def = "0",
3296 .parent = "cgroup",
3297 .category = FIO_OPT_C_GENERAL,
3298 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3299 },
3300 {
3301 .name = "cgroup_weight",
e8b0e958 3302 .lname = "Cgroup weight",
a696fa2a
JA
3303 .type = FIO_OPT_INT,
3304 .off1 = td_var_offset(cgroup_weight),
3305 .help = "Use given weight for cgroup",
3306 .minval = 100,
3307 .maxval = 1000,
a1f6afec 3308 .parent = "cgroup",
e8b0e958 3309 .category = FIO_OPT_C_GENERAL,
a1f6afec 3310 .group = FIO_OPT_G_CGROUP,
7de87099 3311 },
e0b0d892
JA
3312 {
3313 .name = "uid",
e8b0e958 3314 .lname = "User ID",
e0b0d892
JA
3315 .type = FIO_OPT_INT,
3316 .off1 = td_var_offset(uid),
3317 .help = "Run job with this user ID",
e8b0e958 3318 .category = FIO_OPT_C_GENERAL,
10860056 3319 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3320 },
3321 {
3322 .name = "gid",
e8b0e958 3323 .lname = "Group ID",
e0b0d892
JA
3324 .type = FIO_OPT_INT,
3325 .off1 = td_var_offset(gid),
3326 .help = "Run job with this group ID",
e8b0e958 3327 .category = FIO_OPT_C_GENERAL,
10860056 3328 .group = FIO_OPT_G_CRED,
e0b0d892 3329 },
a1f6afec
JA
3330 {
3331 .name = "kb_base",
3332 .lname = "KB Base",
3333 .type = FIO_OPT_INT,
3334 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3335 .prio = 1,
3336 .def = "1024",
ba9c7219
JA
3337 .posval = {
3338 { .ival = "1024",
3339 .oval = 1024,
3340 .help = "Use 1024 as the K base",
3341 },
3342 { .ival = "1000",
3343 .oval = 1000,
3344 .help = "Use 1000 as the K base",
3345 },
3346 },
a1f6afec
JA
3347 .help = "How many bytes per KB for reporting (1000 or 1024)",
3348 .category = FIO_OPT_C_GENERAL,
3349 .group = FIO_OPT_G_INVALID,
3350 },
cf3a0518
JA
3351 {
3352 .name = "unit_base",
ba9c7219 3353 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3354 .type = FIO_OPT_INT,
3355 .off1 = td_var_offset(unit_base),
cf3a0518 3356 .prio = 1,
71a08258
JA
3357 .posval = {
3358 { .ival = "0",
3359 .oval = 0,
3360 .help = "Auto-detect",
3361 },
3362 { .ival = "8",
3363 .oval = 8,
3364 .help = "Normal (byte based)",
3365 },
3366 { .ival = "1",
3367 .oval = 1,
3368 .help = "Bit based",
3369 },
3370 },
cf3a0518
JA
3371 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3372 .category = FIO_OPT_C_GENERAL,
3373 .group = FIO_OPT_G_INVALID,
3374 },
3ceb458f
JA
3375 {
3376 .name = "hugepage-size",
3377 .lname = "Hugepage size",
3378 .type = FIO_OPT_INT,
3379 .off1 = td_var_offset(hugepage_size),
3380 .help = "When using hugepages, specify size of each page",
3381 .def = __fio_stringify(FIO_HUGE_PAGE),
3382 .interval = 1024 * 1024,
3383 .category = FIO_OPT_C_GENERAL,
3384 .group = FIO_OPT_G_INVALID,
3385 },
9e684a49
DE
3386 {
3387 .name = "flow_id",
e8b0e958 3388 .lname = "I/O flow ID",
9e684a49
DE
3389 .type = FIO_OPT_INT,
3390 .off1 = td_var_offset(flow_id),
3391 .help = "The flow index ID to use",
3392 .def = "0",
e8b0e958
JA
3393 .category = FIO_OPT_C_IO,
3394 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3395 },
3396 {
3397 .name = "flow",
e8b0e958 3398 .lname = "I/O flow weight",
9e684a49
DE
3399 .type = FIO_OPT_INT,
3400 .off1 = td_var_offset(flow),
3401 .help = "Weight for flow control of this job",
3402 .parent = "flow_id",
d71c154c 3403 .hide = 1,
9e684a49 3404 .def = "0",
e8b0e958
JA
3405 .category = FIO_OPT_C_IO,
3406 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3407 },
3408 {
3409 .name = "flow_watermark",
e8b0e958 3410 .lname = "I/O flow watermark",
9e684a49
DE
3411 .type = FIO_OPT_INT,
3412 .off1 = td_var_offset(flow_watermark),
3413 .help = "High watermark for flow control. This option"
3414 " should be set to the same value for all threads"
3415 " with non-zero flow.",
3416 .parent = "flow_id",
d71c154c 3417 .hide = 1,
9e684a49 3418 .def = "1024",
e8b0e958
JA
3419 .category = FIO_OPT_C_IO,
3420 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3421 },
3422 {
3423 .name = "flow_sleep",
e8b0e958 3424 .lname = "I/O flow sleep",
9e684a49
DE
3425 .type = FIO_OPT_INT,
3426 .off1 = td_var_offset(flow_sleep),
3427 .help = "How many microseconds to sleep after being held"
3428 " back by the flow control mechanism",
3429 .parent = "flow_id",
d71c154c 3430 .hide = 1,
9e684a49 3431 .def = "0",
e8b0e958
JA
3432 .category = FIO_OPT_C_IO,
3433 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3434 },
214e1eca
JA
3435 {
3436 .name = NULL,
3437 },
3438};
3439
17af15d4 3440static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3441 const char *name, int val)
9f81736c 3442{
17af15d4 3443 lopt->name = (char *) name;
de890a1e 3444 lopt->val = val;
9f81736c 3445 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3446 lopt->has_arg = optional_argument;
9f81736c
JA
3447 else
3448 lopt->has_arg = required_argument;
3449}
3450
de890a1e
SL
3451static void options_to_lopts(struct fio_option *opts,
3452 struct option *long_options,
3453 int i, int option_type)
214e1eca 3454{
de890a1e 3455 struct fio_option *o = &opts[0];
214e1eca 3456 while (o->name) {
de890a1e 3457 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3458 if (o->alias) {
3459 i++;
de890a1e 3460 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3461 }
214e1eca
JA
3462
3463 i++;
3464 o++;
3465 assert(i < FIO_NR_OPTIONS);
3466 }
3467}
3468
de890a1e
SL
3469void fio_options_set_ioengine_opts(struct option *long_options,
3470 struct thread_data *td)
3471{
3472 unsigned int i;
3473
3474 i = 0;
3475 while (long_options[i].name) {
3476 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3477 memset(&long_options[i], 0, sizeof(*long_options));
3478 break;
3479 }
3480 i++;
3481 }
3482
3483 /*
3484 * Just clear out the prior ioengine options.
3485 */
3486 if (!td || !td->eo)
3487 return;
3488
3489 options_to_lopts(td->io_ops->options, long_options, i,
3490 FIO_GETOPT_IOENGINE);
3491}
3492
3493void fio_options_dup_and_init(struct option *long_options)
3494{
3495 unsigned int i;
3496
9af4a244 3497 options_init(fio_options);
de890a1e
SL
3498
3499 i = 0;
3500 while (long_options[i].name)
3501 i++;
3502
9af4a244 3503 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3504}
3505
74929ac2
JA
3506struct fio_keyword {
3507 const char *word;
3508 const char *desc;
3509 char *replace;
3510};
3511
3512static struct fio_keyword fio_keywords[] = {
3513 {
3514 .word = "$pagesize",
3515 .desc = "Page size in the system",
3516 },
3517 {
3518 .word = "$mb_memory",
3519 .desc = "Megabytes of memory online",
3520 },
3521 {
3522 .word = "$ncpus",
3523 .desc = "Number of CPUs online in the system",
3524 },
3525 {
3526 .word = NULL,
3527 },
3528};
3529
3530void fio_keywords_init(void)
3531{
3b2e1464 3532 unsigned long long mb_memory;
74929ac2
JA
3533 char buf[128];
3534 long l;
3535
a4cfc477 3536 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3537 fio_keywords[0].replace = strdup(buf);
3538
8eb016d3 3539 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3540 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3541 fio_keywords[1].replace = strdup(buf);
3542
c00a2289 3543 l = cpus_online();
74929ac2
JA
3544 sprintf(buf, "%lu", l);
3545 fio_keywords[2].replace = strdup(buf);
3546}
3547
892a6ffc
JA
3548#define BC_APP "bc"
3549
3550static char *bc_calc(char *str)
3551{
d0c814ec 3552 char buf[128], *tmp;
892a6ffc
JA
3553 FILE *f;
3554 int ret;
3555
3556 /*
3557 * No math, just return string
3558 */
d0c814ec
SL
3559 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3560 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3561 return str;
3562
3563 /*
3564 * Split option from value, we only need to calculate the value
3565 */
3566 tmp = strchr(str, '=');
3567 if (!tmp)
3568 return str;
3569
3570 tmp++;
892a6ffc 3571
d0c814ec
SL
3572 /*
3573 * Prevent buffer overflows; such a case isn't reasonable anyway
3574 */
3575 if (strlen(str) >= 128 || strlen(tmp) > 100)
3576 return str;
892a6ffc
JA
3577
3578 sprintf(buf, "which %s > /dev/null", BC_APP);
3579 if (system(buf)) {
3580 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3581 return NULL;
3582 }
3583
d0c814ec 3584 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3585 f = popen(buf, "r");
3c3ed070 3586 if (!f)
892a6ffc 3587 return NULL;
892a6ffc 3588
d0c814ec 3589 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 3590 if (ret <= 0)
892a6ffc 3591 return NULL;
892a6ffc 3592
892a6ffc 3593 pclose(f);
d0c814ec
SL
3594 buf[(tmp - str) + ret - 1] = '\0';
3595 memcpy(buf, str, tmp - str);
892a6ffc 3596 free(str);
d0c814ec
SL
3597 return strdup(buf);
3598}
3599
3600/*
3601 * Return a copy of the input string with substrings of the form ${VARNAME}
3602 * substituted with the value of the environment variable VARNAME. The
3603 * substitution always occurs, even if VARNAME is empty or the corresponding
3604 * environment variable undefined.
3605 */
3606static char *option_dup_subs(const char *opt)
3607{
3608 char out[OPT_LEN_MAX+1];
3609 char in[OPT_LEN_MAX+1];
3610 char *outptr = out;
3611 char *inptr = in;
3612 char *ch1, *ch2, *env;
3613 ssize_t nchr = OPT_LEN_MAX;
3614 size_t envlen;
3615
3616 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3617 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3618 return NULL;
3619 }
3620
3621 in[OPT_LEN_MAX] = '\0';
3622 strncpy(in, opt, OPT_LEN_MAX);
3623
3624 while (*inptr && nchr > 0) {
3625 if (inptr[0] == '$' && inptr[1] == '{') {
3626 ch2 = strchr(inptr, '}');
3627 if (ch2 && inptr+1 < ch2) {
3628 ch1 = inptr+2;
3629 inptr = ch2+1;
3630 *ch2 = '\0';
3631
3632 env = getenv(ch1);
3633 if (env) {
3634 envlen = strlen(env);
3635 if (envlen <= nchr) {
3636 memcpy(outptr, env, envlen);
3637 outptr += envlen;
3638 nchr -= envlen;
3639 }
3640 }
3641
3642 continue;
3643 }
3644 }
3645
3646 *outptr++ = *inptr++;
3647 --nchr;
3648 }
3649
3650 *outptr = '\0';
3651 return strdup(out);
892a6ffc
JA
3652}
3653
74929ac2
JA
3654/*
3655 * Look for reserved variable names and replace them with real values
3656 */
3657static char *fio_keyword_replace(char *opt)
3658{
3659 char *s;
3660 int i;
d0c814ec 3661 int docalc = 0;
74929ac2
JA
3662
3663 for (i = 0; fio_keywords[i].word != NULL; i++) {
3664 struct fio_keyword *kw = &fio_keywords[i];
3665
3666 while ((s = strstr(opt, kw->word)) != NULL) {
3667 char *new = malloc(strlen(opt) + 1);
3668 char *o_org = opt;
3669 int olen = s - opt;
3670 int len;
3671
3672 /*
3673 * Copy part of the string before the keyword and
3674 * sprintf() the replacement after it.
3675 */
3676 memcpy(new, opt, olen);
3677 len = sprintf(new + olen, "%s", kw->replace);
3678
3679 /*
3680 * If there's more in the original string, copy that
3681 * in too
3682 */
3683 opt += strlen(kw->word) + olen;
3684 if (strlen(opt))
3685 memcpy(new + olen + len, opt, opt - o_org - 1);
3686
3687 /*
3688 * replace opt and free the old opt
3689 */
3690 opt = new;
d0c814ec 3691 free(o_org);
7a958bd5 3692
d0c814ec 3693 docalc = 1;
74929ac2
JA
3694 }
3695 }
3696
d0c814ec
SL
3697 /*
3698 * Check for potential math and invoke bc, if possible
3699 */
3700 if (docalc)
3701 opt = bc_calc(opt);
3702
7a958bd5 3703 return opt;
74929ac2
JA
3704}
3705
d0c814ec
SL
3706static char **dup_and_sub_options(char **opts, int num_opts)
3707{
3708 int i;
3709 char **opts_copy = malloc(num_opts * sizeof(*opts));
3710 for (i = 0; i < num_opts; i++) {
3711 opts_copy[i] = option_dup_subs(opts[i]);
3712 if (!opts_copy[i])
3713 continue;
3714 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3715 }
3716 return opts_copy;
3717}
3718
292cc475
JA
3719int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3720 int dump_cmdline)
214e1eca 3721{
de890a1e 3722 int i, ret, unknown;
d0c814ec 3723 char **opts_copy;
3b8b7135 3724
9af4a244 3725 sort_options(opts, fio_options, num_opts);
d0c814ec 3726 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3727
de890a1e
SL
3728 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3729 struct fio_option *o;
9af4a244 3730 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 3731 &o, td, dump_cmdline);
d0c814ec 3732
de890a1e
SL
3733 if (opts_copy[i]) {
3734 if (newret && !o) {
3735 unknown++;
3736 continue;
3737 }
d0c814ec 3738 free(opts_copy[i]);
de890a1e
SL
3739 opts_copy[i] = NULL;
3740 }
3741
3742 ret |= newret;
3743 }
3744
3745 if (unknown) {
3746 ret |= ioengine_load(td);
3747 if (td->eo) {
3748 sort_options(opts_copy, td->io_ops->options, num_opts);
3749 opts = opts_copy;
3750 }
3751 for (i = 0; i < num_opts; i++) {
3752 struct fio_option *o = NULL;
3753 int newret = 1;
3754 if (!opts_copy[i])
3755 continue;
3756
3757 if (td->eo)
3758 newret = parse_option(opts_copy[i], opts[i],
3759 td->io_ops->options, &o,
292cc475 3760 td->eo, dump_cmdline);
de890a1e
SL
3761
3762 ret |= newret;
3763 if (!o)
3764 log_err("Bad option <%s>\n", opts[i]);
3765
3766 free(opts_copy[i]);
3767 opts_copy[i] = NULL;
3768 }
74929ac2 3769 }
3b8b7135 3770
d0c814ec 3771 free(opts_copy);
3b8b7135 3772 return ret;
214e1eca
JA
3773}
3774
3775int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3776{
9af4a244 3777 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3778}
3779
de890a1e
SL
3780int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3781 char *val)
3782{
8a96c80e 3783 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
de890a1e
SL
3784}
3785
214e1eca
JA
3786void fio_fill_default_options(struct thread_data *td)
3787{
9af4a244 3788 fill_default_options(td, fio_options);
214e1eca
JA
3789}
3790
3791int fio_show_option_help(const char *opt)
3792{
9af4a244 3793 return show_cmd_help(fio_options, opt);
214e1eca 3794}
d23bb327 3795
de890a1e 3796void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3797{
de890a1e 3798 struct fio_option *o;
d23bb327 3799 char **ptr;
d23bb327 3800
de890a1e
SL
3801 for (o = &options[0]; o->name; o++) {
3802 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3803 continue;
3804
f0fdbcaf 3805 ptr = td_var(data, o, o->off1);
7e356b2d
JA
3806 if (*ptr)
3807 *ptr = strdup(*ptr);
d23bb327
JA
3808 }
3809}
3810
de890a1e
SL
3811/*
3812 * dupe FIO_OPT_STR_STORE options
3813 */
3814void fio_options_mem_dupe(struct thread_data *td)
3815{
9af4a244 3816 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3817
3818 if (td->eo && td->io_ops) {
de890a1e 3819 void *oldeo = td->eo;
1647f592 3820
de890a1e
SL
3821 td->eo = malloc(td->io_ops->option_struct_size);
3822 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3823 options_mem_dupe(td->eo, td->io_ops->options);
3824 }
3825}
3826
d6978a32
JA
3827unsigned int fio_get_kb_base(void *data)
3828{
83ea422a 3829 struct thread_options *o = data;
d6978a32
JA
3830 unsigned int kb_base = 0;
3831
83ea422a
JA
3832 if (o)
3833 kb_base = o->kb_base;
d6978a32
JA
3834 if (!kb_base)
3835 kb_base = 1024;
3836
3837 return kb_base;
3838}
9f988e2e 3839
07b3232d 3840int add_option(struct fio_option *o)
9f988e2e 3841{
07b3232d
JA
3842 struct fio_option *__o;
3843 int opt_index = 0;
3844
9af4a244 3845 __o = fio_options;
07b3232d
JA
3846 while (__o->name) {
3847 opt_index++;
3848 __o++;
3849 }
3850
7b504edd
JA
3851 if (opt_index + 1 == FIO_MAX_OPTS) {
3852 log_err("fio: FIO_MAX_OPTS is too small\n");
3853 return 1;
3854 }
3855
9af4a244 3856 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 3857 fio_options[opt_index + 1].name = NULL;
07b3232d 3858 return 0;
9f988e2e 3859}
e2de69da 3860
07b3232d 3861void invalidate_profile_options(const char *prof_name)
e2de69da 3862{
07b3232d 3863 struct fio_option *o;
e2de69da 3864
9af4a244 3865 o = fio_options;
07b3232d
JA
3866 while (o->name) {
3867 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3868 o->type = FIO_OPT_INVALID;
3869 o->prof_name = NULL;
3870 }
3871 o++;
e2de69da
JA
3872 }
3873}
f5b6bb85
JA
3874
3875void add_opt_posval(const char *optname, const char *ival, const char *help)
3876{
3877 struct fio_option *o;
3878 unsigned int i;
3879
9af4a244 3880 o = find_option(fio_options, optname);
f5b6bb85
JA
3881 if (!o)
3882 return;
3883
3884 for (i = 0; i < PARSE_MAX_VP; i++) {
3885 if (o->posval[i].ival)
3886 continue;
3887
3888 o->posval[i].ival = ival;
3889 o->posval[i].help = help;
3890 break;
3891 }
3892}
3893
3894void del_opt_posval(const char *optname, const char *ival)
3895{
3896 struct fio_option *o;
3897 unsigned int i;
3898
9af4a244 3899 o = find_option(fio_options, optname);
f5b6bb85
JA
3900 if (!o)
3901 return;
3902
3903 for (i = 0; i < PARSE_MAX_VP; i++) {
3904 if (!o->posval[i].ival)
3905 continue;
3906 if (strcmp(o->posval[i].ival, ival))
3907 continue;
3908
3909 o->posval[i].ival = NULL;
3910 o->posval[i].help = NULL;
3911 }
3912}
7e356b2d
JA
3913
3914void fio_options_free(struct thread_data *td)
3915{
9af4a244 3916 options_free(fio_options, td);
de890a1e
SL
3917 if (td->eo && td->io_ops && td->io_ops->options) {
3918 options_free(td->io_ops->options, td->eo);
3919 free(td->eo);
3920 td->eo = NULL;
3921 }
7e356b2d 3922}
c504ee55
JA
3923
3924struct fio_option *fio_option_find(const char *name)
3925{
3926 return find_option(fio_options, name);
3927}
3928