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