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