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