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