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