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