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