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