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