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