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