Fix filling verify pattern for byte sizes of 3, 5, 7, ...
[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 807 long off;
e078de4a 808 int i = 0, j = 0, len, k, base = 10, pattern_length;
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 */
e078de4a 847 pattern_length = i;
efcd9dcc
SL
848 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
849 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
850 i *= 2;
851 }
e078de4a
JA
852
853 /*
854 * Fill remainder, if the pattern multiple ends up not being
855 * MAX_PATTERN_SIZE.
856 */
857 while (i > 1 && i < MAX_PATTERN_SIZE) {
858 unsigned int b = min(pattern_length, MAX_PATTERN_SIZE - i);
859
860 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], b);
861 i += b;
862 }
863
9a2a86d0
SL
864 if (i == 1) {
865 /*
866 * The code in verify_io_u_pattern assumes a single byte pattern
867 * fills the whole verify pattern buffer.
868 */
869 memset(td->o.verify_pattern, td->o.verify_pattern[0],
870 MAX_PATTERN_SIZE);
871 }
efcd9dcc 872
0e92f873 873 td->o.verify_pattern_bytes = i;
efcd9dcc 874
92bf48d5
JA
875 /*
876 * VERIFY_META could already be set
877 */
878 if (td->o.verify == VERIFY_NONE)
879 td->o.verify = VERIFY_PATTERN;
efcd9dcc 880
90059d65
JA
881 return 0;
882}
214e1eca 883
993bf48b
JA
884static int str_gtod_reduce_cb(void *data, int *il)
885{
886 struct thread_data *td = data;
887 int val = *il;
888
02af0988 889 td->o.disable_lat = !!val;
993bf48b
JA
890 td->o.disable_clat = !!val;
891 td->o.disable_slat = !!val;
892 td->o.disable_bw = !!val;
0dc1bc03 893 td->o.clat_percentiles = !val;
993bf48b
JA
894 if (val)
895 td->tv_cache_mask = 63;
896
897 return 0;
898}
899
85bc833b 900static int str_gtod_cpu_cb(void *data, long long *il)
be4ecfdf
JA
901{
902 struct thread_data *td = data;
903 int val = *il;
904
905 td->o.gtod_cpu = val;
906 td->o.gtod_offload = 1;
907 return 0;
908}
909
7bb59102
JA
910static int str_size_cb(void *data, unsigned long long *__val)
911{
912 struct thread_data *td = data;
913 unsigned long long v = *__val;
914
915 if (parse_is_percent(v)) {
916 td->o.size = 0;
917 td->o.size_percent = -1ULL - v;
918 } else
919 td->o.size = v;
920
921 return 0;
922}
923
896cac2a
JA
924static int rw_verify(struct fio_option *o, void *data)
925{
926 struct thread_data *td = data;
927
928 if (read_only && td_write(td)) {
929 log_err("fio: job <%s> has write bit set, but fio is in"
930 " read-only mode\n", td->o.name);
931 return 1;
932 }
933
934 return 0;
935}
936
276ca4f7 937static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 938{
276ca4f7 939#ifndef FIO_HAVE_CPU_AFFINITY
29d43ff9
JA
940 struct thread_data *td = data;
941
29d43ff9
JA
942 if (td->o.gtod_cpu) {
943 log_err("fio: platform must support CPU affinity for"
944 "gettimeofday() offloading\n");
945 return 1;
946 }
947#endif
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",
93bb626a
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),
81c6b6cd 2356 .help = "Lock down this amount of memory (per worker)",
214e1eca 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",
6be54b2d
JA
2633 .category = FIO_OPT_C_GENERAL,
2634 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2635 },
2636 {
2637 .name = "numa_mem_policy",
2638 .type = FIO_OPT_STR,
2639 .cb = str_numa_mpol_cb,
2640 .help = "NUMA memory policy setup",
6be54b2d
JA
2641 .category = FIO_OPT_C_GENERAL,
2642 .group = FIO_OPT_G_INVALID,
d0b937ed 2643 },
214e1eca
JA
2644#endif
2645 {
2646 .name = "end_fsync",
e8b0e958 2647 .lname = "End fsync",
214e1eca
JA
2648 .type = FIO_OPT_BOOL,
2649 .off1 = td_var_offset(end_fsync),
2650 .help = "Include fsync at the end of job",
2651 .def = "0",
e8b0e958
JA
2652 .category = FIO_OPT_C_FILE,
2653 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2654 },
2655 {
2656 .name = "fsync_on_close",
e8b0e958 2657 .lname = "Fsync on close",
214e1eca
JA
2658 .type = FIO_OPT_BOOL,
2659 .off1 = td_var_offset(fsync_on_close),
2660 .help = "fsync files on close",
2661 .def = "0",
e8b0e958
JA
2662 .category = FIO_OPT_C_FILE,
2663 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2664 },
2665 {
2666 .name = "unlink",
e8b0e958 2667 .lname = "Unlink file",
214e1eca
JA
2668 .type = FIO_OPT_BOOL,
2669 .off1 = td_var_offset(unlink),
2670 .help = "Unlink created files after job has completed",
2671 .def = "0",
e8b0e958
JA
2672 .category = FIO_OPT_C_FILE,
2673 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2674 },
2675 {
2676 .name = "exitall",
e8b0e958 2677 .lname = "Exit-all on terminate",
214e1eca
JA
2678 .type = FIO_OPT_STR_SET,
2679 .cb = str_exitall_cb,
2680 .help = "Terminate all jobs when one exits",
e8b0e958 2681 .category = FIO_OPT_C_GENERAL,
a1f6afec 2682 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2683 },
2684 {
2685 .name = "stonewall",
e8b0e958 2686 .lname = "Wait for previous",
d392365e 2687 .alias = "wait_for_previous",
214e1eca
JA
2688 .type = FIO_OPT_STR_SET,
2689 .off1 = td_var_offset(stonewall),
2690 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2691 .category = FIO_OPT_C_GENERAL,
a1f6afec 2692 .group = FIO_OPT_G_PROCESS,
214e1eca 2693 },
b3d62a75
JA
2694 {
2695 .name = "new_group",
e8b0e958 2696 .lname = "New group",
b3d62a75
JA
2697 .type = FIO_OPT_STR_SET,
2698 .off1 = td_var_offset(new_group),
2699 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2700 .category = FIO_OPT_C_GENERAL,
a1f6afec 2701 .group = FIO_OPT_G_PROCESS,
b3d62a75 2702 },
214e1eca
JA
2703 {
2704 .name = "thread",
e8b0e958 2705 .lname = "Thread",
214e1eca
JA
2706 .type = FIO_OPT_STR_SET,
2707 .off1 = td_var_offset(use_thread),
20eb06bd 2708 .help = "Use threads instead of processes",
e8b0e958 2709 .category = FIO_OPT_C_GENERAL,
a1f6afec 2710 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2711 },
2712 {
2713 .name = "write_bw_log",
e8b0e958 2714 .lname = "Write bandwidth log",
203160d5
JA
2715 .type = FIO_OPT_STR_STORE,
2716 .off1 = td_var_offset(bw_log_file),
214e1eca 2717 .help = "Write log of bandwidth during run",
e8b0e958
JA
2718 .category = FIO_OPT_C_LOG,
2719 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2720 },
2721 {
2722 .name = "write_lat_log",
e8b0e958 2723 .lname = "Write latency log",
203160d5
JA
2724 .type = FIO_OPT_STR_STORE,
2725 .off1 = td_var_offset(lat_log_file),
214e1eca 2726 .help = "Write log of latency during run",
e8b0e958
JA
2727 .category = FIO_OPT_C_LOG,
2728 .group = FIO_OPT_G_INVALID,
214e1eca 2729 },
c8eeb9df
JA
2730 {
2731 .name = "write_iops_log",
e8b0e958 2732 .lname = "Write IOPS log",
c8eeb9df 2733 .type = FIO_OPT_STR,
203160d5 2734 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2735 .help = "Write log of IOPS during run",
e8b0e958
JA
2736 .category = FIO_OPT_C_LOG,
2737 .group = FIO_OPT_G_INVALID,
c8eeb9df 2738 },
b8bc8cba
JA
2739 {
2740 .name = "log_avg_msec",
e8b0e958 2741 .lname = "Log averaging (msec)",
b8bc8cba
JA
2742 .type = FIO_OPT_INT,
2743 .off1 = td_var_offset(log_avg_msec),
2744 .help = "Average bw/iops/lat logs over this period of time",
2745 .def = "0",
e8b0e958
JA
2746 .category = FIO_OPT_C_LOG,
2747 .group = FIO_OPT_G_INVALID,
b8bc8cba 2748 },
c504ee55
JA
2749 {
2750 .name = "bwavgtime",
2751 .lname = "Bandwidth average time",
2752 .type = FIO_OPT_INT,
2753 .off1 = td_var_offset(bw_avg_time),
2754 .help = "Time window over which to calculate bandwidth"
2755 " (msec)",
2756 .def = "500",
2757 .parent = "write_bw_log",
2758 .hide = 1,
2759 .interval = 100,
2760 .category = FIO_OPT_C_LOG,
2761 .group = FIO_OPT_G_INVALID,
2762 },
2763 {
2764 .name = "iopsavgtime",
2765 .lname = "IOPS average time",
2766 .type = FIO_OPT_INT,
2767 .off1 = td_var_offset(iops_avg_time),
2768 .help = "Time window over which to calculate IOPS (msec)",
2769 .def = "500",
2770 .parent = "write_iops_log",
2771 .hide = 1,
2772 .interval = 100,
2773 .category = FIO_OPT_C_LOG,
2774 .group = FIO_OPT_G_INVALID,
2775 },
214e1eca
JA
2776 {
2777 .name = "group_reporting",
e8b0e958
JA
2778 .lname = "Group reporting",
2779 .type = FIO_OPT_BOOL,
214e1eca
JA
2780 .off1 = td_var_offset(group_reporting),
2781 .help = "Do reporting on a per-group basis",
10860056 2782 .category = FIO_OPT_C_STAT,
e8b0e958 2783 .group = FIO_OPT_G_INVALID,
214e1eca 2784 },
e9459e5a
JA
2785 {
2786 .name = "zero_buffers",
e8b0e958 2787 .lname = "Zero I/O buffers",
e9459e5a
JA
2788 .type = FIO_OPT_STR_SET,
2789 .off1 = td_var_offset(zero_buffers),
2790 .help = "Init IO buffers to all zeroes",
e8b0e958 2791 .category = FIO_OPT_C_IO,
3ceb458f 2792 .group = FIO_OPT_G_IO_BUF,
e9459e5a 2793 },
5973cafb
JA
2794 {
2795 .name = "refill_buffers",
e8b0e958 2796 .lname = "Refill I/O buffers",
5973cafb
JA
2797 .type = FIO_OPT_STR_SET,
2798 .off1 = td_var_offset(refill_buffers),
2799 .help = "Refill IO buffers on every IO submit",
e8b0e958 2800 .category = FIO_OPT_C_IO,
3ceb458f 2801 .group = FIO_OPT_G_IO_BUF,
5973cafb 2802 },
fd68418e
JA
2803 {
2804 .name = "scramble_buffers",
e8b0e958 2805 .lname = "Scramble I/O buffers",
fd68418e
JA
2806 .type = FIO_OPT_BOOL,
2807 .off1 = td_var_offset(scramble_buffers),
2808 .help = "Slightly scramble buffers on every IO submit",
2809 .def = "1",
e8b0e958 2810 .category = FIO_OPT_C_IO,
3ceb458f 2811 .group = FIO_OPT_G_IO_BUF,
fd68418e 2812 },
9c42684e
JA
2813 {
2814 .name = "buffer_compress_percentage",
e8b0e958 2815 .lname = "Buffer compression percentage",
9c42684e
JA
2816 .type = FIO_OPT_INT,
2817 .off1 = td_var_offset(compress_percentage),
2818 .maxval = 100,
2819 .minval = 1,
2820 .help = "How compressible the buffer is (approximately)",
20eb06bd 2821 .interval = 5,
e8b0e958 2822 .category = FIO_OPT_C_IO,
3ceb458f 2823 .group = FIO_OPT_G_IO_BUF,
9c42684e 2824 },
f97a43a1
JA
2825 {
2826 .name = "buffer_compress_chunk",
e8b0e958 2827 .lname = "Buffer compression chunk size",
f97a43a1
JA
2828 .type = FIO_OPT_INT,
2829 .off1 = td_var_offset(compress_chunk),
207b18e4 2830 .parent = "buffer_compress_percentage",
d71c154c 2831 .hide = 1,
f97a43a1 2832 .help = "Size of compressible region in buffer",
20eb06bd 2833 .interval = 256,
e8b0e958 2834 .category = FIO_OPT_C_IO,
3ceb458f 2835 .group = FIO_OPT_G_IO_BUF,
f97a43a1 2836 },
83349190
YH
2837 {
2838 .name = "clat_percentiles",
e8b0e958 2839 .lname = "Completion latency percentiles",
83349190
YH
2840 .type = FIO_OPT_BOOL,
2841 .off1 = td_var_offset(clat_percentiles),
2842 .help = "Enable the reporting of completion latency percentiles",
467b35ed 2843 .def = "1",
e8b0e958
JA
2844 .category = FIO_OPT_C_STAT,
2845 .group = FIO_OPT_G_INVALID,
83349190
YH
2846 },
2847 {
2848 .name = "percentile_list",
e8b0e958 2849 .lname = "Completion latency percentile list",
83349190
YH
2850 .type = FIO_OPT_FLOAT_LIST,
2851 .off1 = td_var_offset(percentile_list),
435d195a 2852 .off2 = td_var_offset(percentile_precision),
83349190 2853 .help = "Specify a custom list of percentiles to report",
fd112d34 2854 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
2855 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2856 .minfp = 0.0,
2857 .maxfp = 100.0,
e8b0e958
JA
2858 .category = FIO_OPT_C_STAT,
2859 .group = FIO_OPT_G_INVALID,
83349190
YH
2860 },
2861
0a839f30
JA
2862#ifdef FIO_HAVE_DISK_UTIL
2863 {
2864 .name = "disk_util",
e8b0e958 2865 .lname = "Disk utilization",
0a839f30
JA
2866 .type = FIO_OPT_BOOL,
2867 .off1 = td_var_offset(do_disk_util),
f66ab3c8 2868 .help = "Log disk utilization statistics",
0a839f30 2869 .def = "1",
e8b0e958
JA
2870 .category = FIO_OPT_C_STAT,
2871 .group = FIO_OPT_G_INVALID,
0a839f30
JA
2872 },
2873#endif
993bf48b
JA
2874 {
2875 .name = "gtod_reduce",
e8b0e958 2876 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
2877 .type = FIO_OPT_BOOL,
2878 .help = "Greatly reduce number of gettimeofday() calls",
2879 .cb = str_gtod_reduce_cb,
2880 .def = "0",
a4ed77fe 2881 .hide_on_set = 1,
e8b0e958
JA
2882 .category = FIO_OPT_C_STAT,
2883 .group = FIO_OPT_G_INVALID,
993bf48b 2884 },
02af0988
JA
2885 {
2886 .name = "disable_lat",
e8b0e958 2887 .lname = "Disable all latency stats",
02af0988
JA
2888 .type = FIO_OPT_BOOL,
2889 .off1 = td_var_offset(disable_lat),
2890 .help = "Disable latency numbers",
2891 .parent = "gtod_reduce",
d71c154c 2892 .hide = 1,
02af0988 2893 .def = "0",
e8b0e958
JA
2894 .category = FIO_OPT_C_STAT,
2895 .group = FIO_OPT_G_INVALID,
02af0988 2896 },
9520ebb9
JA
2897 {
2898 .name = "disable_clat",
e8b0e958 2899 .lname = "Disable completion latency stats",
9520ebb9
JA
2900 .type = FIO_OPT_BOOL,
2901 .off1 = td_var_offset(disable_clat),
2902 .help = "Disable completion latency numbers",
993bf48b 2903 .parent = "gtod_reduce",
d71c154c 2904 .hide = 1,
9520ebb9 2905 .def = "0",
e8b0e958
JA
2906 .category = FIO_OPT_C_STAT,
2907 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
2908 },
2909 {
2910 .name = "disable_slat",
e8b0e958 2911 .lname = "Disable submission latency stats",
9520ebb9
JA
2912 .type = FIO_OPT_BOOL,
2913 .off1 = td_var_offset(disable_slat),
03e20d68 2914 .help = "Disable submission latency numbers",
993bf48b 2915 .parent = "gtod_reduce",
d71c154c 2916 .hide = 1,
9520ebb9 2917 .def = "0",
e8b0e958
JA
2918 .category = FIO_OPT_C_STAT,
2919 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
2920 },
2921 {
2922 .name = "disable_bw_measurement",
e8b0e958 2923 .lname = "Disable bandwidth stats",
9520ebb9
JA
2924 .type = FIO_OPT_BOOL,
2925 .off1 = td_var_offset(disable_bw),
2926 .help = "Disable bandwidth logging",
993bf48b 2927 .parent = "gtod_reduce",
d71c154c 2928 .hide = 1,
9520ebb9 2929 .def = "0",
e8b0e958
JA
2930 .category = FIO_OPT_C_STAT,
2931 .group = FIO_OPT_G_INVALID,
9520ebb9 2932 },
be4ecfdf
JA
2933 {
2934 .name = "gtod_cpu",
e8b0e958 2935 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
2936 .type = FIO_OPT_INT,
2937 .cb = str_gtod_cpu_cb,
03e20d68 2938 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 2939 .verify = gtod_cpu_verify,
e8b0e958 2940 .category = FIO_OPT_C_GENERAL,
10860056 2941 .group = FIO_OPT_G_CLOCK,
be4ecfdf 2942 },
771e58be
JA
2943 {
2944 .name = "unified_rw_reporting",
2945 .type = FIO_OPT_BOOL,
2946 .off1 = td_var_offset(unified_rw_rep),
2947 .help = "Unify reporting across data direction",
2948 .def = "0",
90b7a96d
JA
2949 .category = FIO_OPT_C_GENERAL,
2950 .group = FIO_OPT_G_INVALID,
771e58be 2951 },
f2bba182
RR
2952 {
2953 .name = "continue_on_error",
e8b0e958 2954 .lname = "Continue on error",
06842027 2955 .type = FIO_OPT_STR,
f2bba182 2956 .off1 = td_var_offset(continue_on_error),
03e20d68 2957 .help = "Continue on non-fatal errors during IO",
06842027 2958 .def = "none",
e8b0e958 2959 .category = FIO_OPT_C_GENERAL,
bc3f552f 2960 .group = FIO_OPT_G_ERR,
06842027
SL
2961 .posval = {
2962 { .ival = "none",
2963 .oval = ERROR_TYPE_NONE,
2964 .help = "Exit when an error is encountered",
2965 },
2966 { .ival = "read",
2967 .oval = ERROR_TYPE_READ,
2968 .help = "Continue on read errors only",
2969 },
2970 { .ival = "write",
2971 .oval = ERROR_TYPE_WRITE,
2972 .help = "Continue on write errors only",
2973 },
2974 { .ival = "io",
2975 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2976 .help = "Continue on any IO errors",
2977 },
2978 { .ival = "verify",
2979 .oval = ERROR_TYPE_VERIFY,
2980 .help = "Continue on verify errors only",
2981 },
2982 { .ival = "all",
2983 .oval = ERROR_TYPE_ANY,
2984 .help = "Continue on all io and verify errors",
2985 },
2986 { .ival = "0",
2987 .oval = ERROR_TYPE_NONE,
2988 .help = "Alias for 'none'",
2989 },
2990 { .ival = "1",
2991 .oval = ERROR_TYPE_ANY,
2992 .help = "Alias for 'all'",
2993 },
2994 },
f2bba182 2995 },
8b28bd41
DM
2996 {
2997 .name = "ignore_error",
2998 .type = FIO_OPT_STR,
2999 .cb = str_ignore_error_cb,
3000 .help = "Set a specific list of errors to ignore",
3001 .parent = "rw",
a94eb99a 3002 .category = FIO_OPT_C_GENERAL,
bc3f552f 3003 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3004 },
3005 {
3006 .name = "error_dump",
3007 .type = FIO_OPT_BOOL,
3008 .off1 = td_var_offset(error_dump),
3009 .def = "0",
3010 .help = "Dump info on each error",
a94eb99a 3011 .category = FIO_OPT_C_GENERAL,
bc3f552f 3012 .group = FIO_OPT_G_ERR,
8b28bd41 3013 },
9ac8a797
JA
3014 {
3015 .name = "profile",
e8b0e958 3016 .lname = "Profile",
79d16311 3017 .type = FIO_OPT_STR_STORE,
9ac8a797 3018 .off1 = td_var_offset(profile),
9ac8a797 3019 .help = "Select a specific builtin performance test",
13fca827 3020 .category = FIO_OPT_C_PROFILE,
e8b0e958 3021 .group = FIO_OPT_G_INVALID,
9ac8a797 3022 },
a696fa2a
JA
3023 {
3024 .name = "cgroup",
e8b0e958 3025 .lname = "Cgroup",
a696fa2a
JA
3026 .type = FIO_OPT_STR_STORE,
3027 .off1 = td_var_offset(cgroup),
3028 .help = "Add job to cgroup of this name",
e8b0e958 3029 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3030 .group = FIO_OPT_G_CGROUP,
3031 },
3032 {
3033 .name = "cgroup_nodelete",
3034 .lname = "Cgroup no-delete",
3035 .type = FIO_OPT_BOOL,
3036 .off1 = td_var_offset(cgroup_nodelete),
3037 .help = "Do not delete cgroups after job completion",
3038 .def = "0",
3039 .parent = "cgroup",
3040 .category = FIO_OPT_C_GENERAL,
3041 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3042 },
3043 {
3044 .name = "cgroup_weight",
e8b0e958 3045 .lname = "Cgroup weight",
a696fa2a
JA
3046 .type = FIO_OPT_INT,
3047 .off1 = td_var_offset(cgroup_weight),
3048 .help = "Use given weight for cgroup",
3049 .minval = 100,
3050 .maxval = 1000,
a1f6afec 3051 .parent = "cgroup",
e8b0e958 3052 .category = FIO_OPT_C_GENERAL,
a1f6afec 3053 .group = FIO_OPT_G_CGROUP,
7de87099 3054 },
e0b0d892
JA
3055 {
3056 .name = "uid",
e8b0e958 3057 .lname = "User ID",
e0b0d892
JA
3058 .type = FIO_OPT_INT,
3059 .off1 = td_var_offset(uid),
3060 .help = "Run job with this user ID",
e8b0e958 3061 .category = FIO_OPT_C_GENERAL,
10860056 3062 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3063 },
3064 {
3065 .name = "gid",
e8b0e958 3066 .lname = "Group ID",
e0b0d892
JA
3067 .type = FIO_OPT_INT,
3068 .off1 = td_var_offset(gid),
3069 .help = "Run job with this group ID",
e8b0e958 3070 .category = FIO_OPT_C_GENERAL,
10860056 3071 .group = FIO_OPT_G_CRED,
e0b0d892 3072 },
a1f6afec
JA
3073 {
3074 .name = "kb_base",
3075 .lname = "KB Base",
3076 .type = FIO_OPT_INT,
3077 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3078 .prio = 1,
3079 .def = "1024",
ba9c7219
JA
3080 .posval = {
3081 { .ival = "1024",
3082 .oval = 1024,
3083 .help = "Use 1024 as the K base",
3084 },
3085 { .ival = "1000",
3086 .oval = 1000,
3087 .help = "Use 1000 as the K base",
3088 },
3089 },
a1f6afec
JA
3090 .help = "How many bytes per KB for reporting (1000 or 1024)",
3091 .category = FIO_OPT_C_GENERAL,
3092 .group = FIO_OPT_G_INVALID,
3093 },
cf3a0518
JA
3094 {
3095 .name = "unit_base",
ba9c7219 3096 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3097 .type = FIO_OPT_INT,
3098 .off1 = td_var_offset(unit_base),
cf3a0518 3099 .prio = 1,
71a08258
JA
3100 .posval = {
3101 { .ival = "0",
3102 .oval = 0,
3103 .help = "Auto-detect",
3104 },
3105 { .ival = "8",
3106 .oval = 8,
3107 .help = "Normal (byte based)",
3108 },
3109 { .ival = "1",
3110 .oval = 1,
3111 .help = "Bit based",
3112 },
3113 },
cf3a0518
JA
3114 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3115 .category = FIO_OPT_C_GENERAL,
3116 .group = FIO_OPT_G_INVALID,
3117 },
3ceb458f
JA
3118 {
3119 .name = "hugepage-size",
3120 .lname = "Hugepage size",
3121 .type = FIO_OPT_INT,
3122 .off1 = td_var_offset(hugepage_size),
3123 .help = "When using hugepages, specify size of each page",
3124 .def = __fio_stringify(FIO_HUGE_PAGE),
3125 .interval = 1024 * 1024,
3126 .category = FIO_OPT_C_GENERAL,
3127 .group = FIO_OPT_G_INVALID,
3128 },
9e684a49
DE
3129 {
3130 .name = "flow_id",
e8b0e958 3131 .lname = "I/O flow ID",
9e684a49
DE
3132 .type = FIO_OPT_INT,
3133 .off1 = td_var_offset(flow_id),
3134 .help = "The flow index ID to use",
3135 .def = "0",
e8b0e958
JA
3136 .category = FIO_OPT_C_IO,
3137 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3138 },
3139 {
3140 .name = "flow",
e8b0e958 3141 .lname = "I/O flow weight",
9e684a49
DE
3142 .type = FIO_OPT_INT,
3143 .off1 = td_var_offset(flow),
3144 .help = "Weight for flow control of this job",
3145 .parent = "flow_id",
d71c154c 3146 .hide = 1,
9e684a49 3147 .def = "0",
e8b0e958
JA
3148 .category = FIO_OPT_C_IO,
3149 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3150 },
3151 {
3152 .name = "flow_watermark",
e8b0e958 3153 .lname = "I/O flow watermark",
9e684a49
DE
3154 .type = FIO_OPT_INT,
3155 .off1 = td_var_offset(flow_watermark),
3156 .help = "High watermark for flow control. This option"
3157 " should be set to the same value for all threads"
3158 " with non-zero flow.",
3159 .parent = "flow_id",
d71c154c 3160 .hide = 1,
9e684a49 3161 .def = "1024",
e8b0e958
JA
3162 .category = FIO_OPT_C_IO,
3163 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3164 },
3165 {
3166 .name = "flow_sleep",
e8b0e958 3167 .lname = "I/O flow sleep",
9e684a49
DE
3168 .type = FIO_OPT_INT,
3169 .off1 = td_var_offset(flow_sleep),
3170 .help = "How many microseconds to sleep after being held"
3171 " back by the flow control mechanism",
3172 .parent = "flow_id",
d71c154c 3173 .hide = 1,
9e684a49 3174 .def = "0",
e8b0e958
JA
3175 .category = FIO_OPT_C_IO,
3176 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3177 },
214e1eca
JA
3178 {
3179 .name = NULL,
3180 },
3181};
3182
17af15d4 3183static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3184 const char *name, int val)
9f81736c 3185{
17af15d4 3186 lopt->name = (char *) name;
de890a1e 3187 lopt->val = val;
9f81736c
JA
3188 if (o->type == FIO_OPT_STR_SET)
3189 lopt->has_arg = no_argument;
3190 else
3191 lopt->has_arg = required_argument;
3192}
3193
de890a1e
SL
3194static void options_to_lopts(struct fio_option *opts,
3195 struct option *long_options,
3196 int i, int option_type)
214e1eca 3197{
de890a1e 3198 struct fio_option *o = &opts[0];
214e1eca 3199 while (o->name) {
de890a1e 3200 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3201 if (o->alias) {
3202 i++;
de890a1e 3203 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3204 }
214e1eca
JA
3205
3206 i++;
3207 o++;
3208 assert(i < FIO_NR_OPTIONS);
3209 }
3210}
3211
de890a1e
SL
3212void fio_options_set_ioengine_opts(struct option *long_options,
3213 struct thread_data *td)
3214{
3215 unsigned int i;
3216
3217 i = 0;
3218 while (long_options[i].name) {
3219 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3220 memset(&long_options[i], 0, sizeof(*long_options));
3221 break;
3222 }
3223 i++;
3224 }
3225
3226 /*
3227 * Just clear out the prior ioengine options.
3228 */
3229 if (!td || !td->eo)
3230 return;
3231
3232 options_to_lopts(td->io_ops->options, long_options, i,
3233 FIO_GETOPT_IOENGINE);
3234}
3235
3236void fio_options_dup_and_init(struct option *long_options)
3237{
3238 unsigned int i;
3239
9af4a244 3240 options_init(fio_options);
de890a1e
SL
3241
3242 i = 0;
3243 while (long_options[i].name)
3244 i++;
3245
9af4a244 3246 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3247}
3248
74929ac2
JA
3249struct fio_keyword {
3250 const char *word;
3251 const char *desc;
3252 char *replace;
3253};
3254
3255static struct fio_keyword fio_keywords[] = {
3256 {
3257 .word = "$pagesize",
3258 .desc = "Page size in the system",
3259 },
3260 {
3261 .word = "$mb_memory",
3262 .desc = "Megabytes of memory online",
3263 },
3264 {
3265 .word = "$ncpus",
3266 .desc = "Number of CPUs online in the system",
3267 },
3268 {
3269 .word = NULL,
3270 },
3271};
3272
3273void fio_keywords_init(void)
3274{
3b2e1464 3275 unsigned long long mb_memory;
74929ac2
JA
3276 char buf[128];
3277 long l;
3278
a4cfc477 3279 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3280 fio_keywords[0].replace = strdup(buf);
3281
8eb016d3 3282 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3283 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3284 fio_keywords[1].replace = strdup(buf);
3285
c00a2289 3286 l = cpus_online();
74929ac2
JA
3287 sprintf(buf, "%lu", l);
3288 fio_keywords[2].replace = strdup(buf);
3289}
3290
892a6ffc
JA
3291#define BC_APP "bc"
3292
3293static char *bc_calc(char *str)
3294{
d0c814ec 3295 char buf[128], *tmp;
892a6ffc
JA
3296 FILE *f;
3297 int ret;
3298
3299 /*
3300 * No math, just return string
3301 */
d0c814ec
SL
3302 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3303 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3304 return str;
3305
3306 /*
3307 * Split option from value, we only need to calculate the value
3308 */
3309 tmp = strchr(str, '=');
3310 if (!tmp)
3311 return str;
3312
3313 tmp++;
892a6ffc 3314
d0c814ec
SL
3315 /*
3316 * Prevent buffer overflows; such a case isn't reasonable anyway
3317 */
3318 if (strlen(str) >= 128 || strlen(tmp) > 100)
3319 return str;
892a6ffc
JA
3320
3321 sprintf(buf, "which %s > /dev/null", BC_APP);
3322 if (system(buf)) {
3323 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3324 return NULL;
3325 }
3326
d0c814ec 3327 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3328 f = popen(buf, "r");
3c3ed070 3329 if (!f)
892a6ffc 3330 return NULL;
892a6ffc 3331
d0c814ec 3332 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 3333 if (ret <= 0)
892a6ffc 3334 return NULL;
892a6ffc 3335
892a6ffc 3336 pclose(f);
d0c814ec
SL
3337 buf[(tmp - str) + ret - 1] = '\0';
3338 memcpy(buf, str, tmp - str);
892a6ffc 3339 free(str);
d0c814ec
SL
3340 return strdup(buf);
3341}
3342
3343/*
3344 * Return a copy of the input string with substrings of the form ${VARNAME}
3345 * substituted with the value of the environment variable VARNAME. The
3346 * substitution always occurs, even if VARNAME is empty or the corresponding
3347 * environment variable undefined.
3348 */
3349static char *option_dup_subs(const char *opt)
3350{
3351 char out[OPT_LEN_MAX+1];
3352 char in[OPT_LEN_MAX+1];
3353 char *outptr = out;
3354 char *inptr = in;
3355 char *ch1, *ch2, *env;
3356 ssize_t nchr = OPT_LEN_MAX;
3357 size_t envlen;
3358
3359 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3360 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3361 return NULL;
3362 }
3363
3364 in[OPT_LEN_MAX] = '\0';
3365 strncpy(in, opt, OPT_LEN_MAX);
3366
3367 while (*inptr && nchr > 0) {
3368 if (inptr[0] == '$' && inptr[1] == '{') {
3369 ch2 = strchr(inptr, '}');
3370 if (ch2 && inptr+1 < ch2) {
3371 ch1 = inptr+2;
3372 inptr = ch2+1;
3373 *ch2 = '\0';
3374
3375 env = getenv(ch1);
3376 if (env) {
3377 envlen = strlen(env);
3378 if (envlen <= nchr) {
3379 memcpy(outptr, env, envlen);
3380 outptr += envlen;
3381 nchr -= envlen;
3382 }
3383 }
3384
3385 continue;
3386 }
3387 }
3388
3389 *outptr++ = *inptr++;
3390 --nchr;
3391 }
3392
3393 *outptr = '\0';
3394 return strdup(out);
892a6ffc
JA
3395}
3396
74929ac2
JA
3397/*
3398 * Look for reserved variable names and replace them with real values
3399 */
3400static char *fio_keyword_replace(char *opt)
3401{
3402 char *s;
3403 int i;
d0c814ec 3404 int docalc = 0;
74929ac2
JA
3405
3406 for (i = 0; fio_keywords[i].word != NULL; i++) {
3407 struct fio_keyword *kw = &fio_keywords[i];
3408
3409 while ((s = strstr(opt, kw->word)) != NULL) {
3410 char *new = malloc(strlen(opt) + 1);
3411 char *o_org = opt;
3412 int olen = s - opt;
3413 int len;
3414
3415 /*
3416 * Copy part of the string before the keyword and
3417 * sprintf() the replacement after it.
3418 */
3419 memcpy(new, opt, olen);
3420 len = sprintf(new + olen, "%s", kw->replace);
3421
3422 /*
3423 * If there's more in the original string, copy that
3424 * in too
3425 */
3426 opt += strlen(kw->word) + olen;
3427 if (strlen(opt))
3428 memcpy(new + olen + len, opt, opt - o_org - 1);
3429
3430 /*
3431 * replace opt and free the old opt
3432 */
3433 opt = new;
d0c814ec 3434 free(o_org);
7a958bd5 3435
d0c814ec 3436 docalc = 1;
74929ac2
JA
3437 }
3438 }
3439
d0c814ec
SL
3440 /*
3441 * Check for potential math and invoke bc, if possible
3442 */
3443 if (docalc)
3444 opt = bc_calc(opt);
3445
7a958bd5 3446 return opt;
74929ac2
JA
3447}
3448
d0c814ec
SL
3449static char **dup_and_sub_options(char **opts, int num_opts)
3450{
3451 int i;
3452 char **opts_copy = malloc(num_opts * sizeof(*opts));
3453 for (i = 0; i < num_opts; i++) {
3454 opts_copy[i] = option_dup_subs(opts[i]);
3455 if (!opts_copy[i])
3456 continue;
3457 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3458 }
3459 return opts_copy;
3460}
3461
3b8b7135 3462int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 3463{
de890a1e 3464 int i, ret, unknown;
d0c814ec 3465 char **opts_copy;
3b8b7135 3466
9af4a244 3467 sort_options(opts, fio_options, num_opts);
d0c814ec 3468 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3469
de890a1e
SL
3470 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3471 struct fio_option *o;
9af4a244
JA
3472 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3473 &o, td);
d0c814ec 3474
de890a1e
SL
3475 if (opts_copy[i]) {
3476 if (newret && !o) {
3477 unknown++;
3478 continue;
3479 }
d0c814ec 3480 free(opts_copy[i]);
de890a1e
SL
3481 opts_copy[i] = NULL;
3482 }
3483
3484 ret |= newret;
3485 }
3486
3487 if (unknown) {
3488 ret |= ioengine_load(td);
3489 if (td->eo) {
3490 sort_options(opts_copy, td->io_ops->options, num_opts);
3491 opts = opts_copy;
3492 }
3493 for (i = 0; i < num_opts; i++) {
3494 struct fio_option *o = NULL;
3495 int newret = 1;
3496 if (!opts_copy[i])
3497 continue;
3498
3499 if (td->eo)
3500 newret = parse_option(opts_copy[i], opts[i],
3501 td->io_ops->options, &o,
3502 td->eo);
3503
3504 ret |= newret;
3505 if (!o)
3506 log_err("Bad option <%s>\n", opts[i]);
3507
3508 free(opts_copy[i]);
3509 opts_copy[i] = NULL;
3510 }
74929ac2 3511 }
3b8b7135 3512
d0c814ec 3513 free(opts_copy);
3b8b7135 3514 return ret;
214e1eca
JA
3515}
3516
3517int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3518{
9af4a244 3519 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3520}
3521
de890a1e
SL
3522int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3523 char *val)
3524{
3525 return parse_cmd_option(opt, val, td->io_ops->options, td);
3526}
3527
214e1eca
JA
3528void fio_fill_default_options(struct thread_data *td)
3529{
9af4a244 3530 fill_default_options(td, fio_options);
214e1eca
JA
3531}
3532
3533int fio_show_option_help(const char *opt)
3534{
9af4a244 3535 return show_cmd_help(fio_options, opt);
214e1eca 3536}
d23bb327 3537
de890a1e 3538void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3539{
de890a1e 3540 struct fio_option *o;
d23bb327 3541 char **ptr;
d23bb327 3542
de890a1e
SL
3543 for (o = &options[0]; o->name; o++) {
3544 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3545 continue;
3546
de890a1e 3547 ptr = td_var(data, o->off1);
7e356b2d
JA
3548 if (*ptr)
3549 *ptr = strdup(*ptr);
d23bb327
JA
3550 }
3551}
3552
de890a1e
SL
3553/*
3554 * dupe FIO_OPT_STR_STORE options
3555 */
3556void fio_options_mem_dupe(struct thread_data *td)
3557{
9af4a244 3558 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3559
3560 if (td->eo && td->io_ops) {
de890a1e 3561 void *oldeo = td->eo;
1647f592 3562
de890a1e
SL
3563 td->eo = malloc(td->io_ops->option_struct_size);
3564 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3565 options_mem_dupe(td->eo, td->io_ops->options);
3566 }
3567}
3568
d6978a32
JA
3569unsigned int fio_get_kb_base(void *data)
3570{
83ea422a 3571 struct thread_options *o = data;
d6978a32
JA
3572 unsigned int kb_base = 0;
3573
83ea422a
JA
3574 if (o)
3575 kb_base = o->kb_base;