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