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