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