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