backend: only terminate multiple loops if we did no IO
[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 */
1048static struct opt_group fio_opt_groups[] = {
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
1078static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1079 unsigned int inv_mask)
1080{
1081 struct opt_group *og;
1082 int i;
1083
1084 if (*mask == inv_mask || !*mask)
1085 return NULL;
1086
1087 for (i = 0; ogs[i].name; i++) {
1088 og = &ogs[i];
1089
1090 if (*mask & og->mask) {
1091 *mask &= ~(og->mask);
1092 return og;
1093 }
1094 }
1095
1096 return NULL;
1097}
1098
1099struct opt_group *opt_group_from_mask(unsigned int *mask)
1100{
1101 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1102}
1103
1104static 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
e8b0e958 1203struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
9af4a244 1204{
e8b0e958 1205 return __opt_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 },
214e1eca
JA
1230 {
1231 .name = "filename",
e8b0e958 1232 .lname = "Filename(s)",
214e1eca
JA
1233 .type = FIO_OPT_STR_STORE,
1234 .off1 = td_var_offset(filename),
1235 .cb = str_filename_cb,
f0d524b0 1236 .prio = -1, /* must come after "directory" */
214e1eca 1237 .help = "File(s) to use for the workload",
e8b0e958 1238 .category = FIO_OPT_C_FILE,
0626037e 1239 .group = FIO_OPT_G_FILENAME,
214e1eca 1240 },
90fef2d1 1241 {
e8b0e958
JA
1242 .name = "directory",
1243 .lname = "Directory",
1244 .type = FIO_OPT_STR_STORE,
1245 .off1 = td_var_offset(directory),
1246 .cb = str_directory_cb,
1247 .help = "Directory to store files in",
1248 .category = FIO_OPT_C_FILE,
0626037e 1249 .group = FIO_OPT_G_FILENAME,
90fef2d1 1250 },
de98bd30
JA
1251 {
1252 .name = "filename_format",
1253 .type = FIO_OPT_STR_STORE,
1254 .off1 = td_var_offset(filename_format),
1255 .prio = -1, /* must come after "directory" */
1256 .help = "Override default $jobname.$jobnum.$filenum naming",
1257 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1258 .category = FIO_OPT_C_FILE,
1259 .group = FIO_OPT_G_FILENAME,
ad705bcb 1260 },
29c1349f
JA
1261 {
1262 .name = "lockfile",
e8b0e958 1263 .lname = "Lockfile",
4d4e80f2 1264 .type = FIO_OPT_STR,
4d4e80f2 1265 .off1 = td_var_offset(file_lock_mode),
29c1349f 1266 .help = "Lock file when doing IO to it",
bc6a0a5d 1267 .prio = 1,
29c1349f 1268 .parent = "filename",
d71c154c 1269 .hide = 0,
4d4e80f2 1270 .def = "none",
e8b0e958 1271 .category = FIO_OPT_C_FILE,
0626037e 1272 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1273 .posval = {
1274 { .ival = "none",
1275 .oval = FILE_LOCK_NONE,
1276 .help = "No file locking",
1277 },
1278 { .ival = "exclusive",
1279 .oval = FILE_LOCK_EXCLUSIVE,
1280 .help = "Exclusive file lock",
1281 },
1282 {
1283 .ival = "readwrite",
1284 .oval = FILE_LOCK_READWRITE,
1285 .help = "Read vs write lock",
1286 },
1287 },
29c1349f 1288 },
214e1eca
JA
1289 {
1290 .name = "opendir",
e8b0e958 1291 .lname = "Open directory",
214e1eca
JA
1292 .type = FIO_OPT_STR_STORE,
1293 .off1 = td_var_offset(opendir),
1294 .cb = str_opendir_cb,
1295 .help = "Recursively add files from this directory and down",
e8b0e958 1296 .category = FIO_OPT_C_FILE,
0626037e 1297 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1298 },
1299 {
1300 .name = "rw",
e8b0e958 1301 .lname = "Read/write",
d3aad8f2 1302 .alias = "readwrite",
214e1eca 1303 .type = FIO_OPT_STR,
211097b2 1304 .cb = str_rw_cb,
214e1eca
JA
1305 .off1 = td_var_offset(td_ddir),
1306 .help = "IO direction",
1307 .def = "read",
896cac2a 1308 .verify = rw_verify,
e8b0e958 1309 .category = FIO_OPT_C_IO,
0626037e 1310 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1311 .posval = {
1312 { .ival = "read",
1313 .oval = TD_DDIR_READ,
1314 .help = "Sequential read",
1315 },
1316 { .ival = "write",
1317 .oval = TD_DDIR_WRITE,
1318 .help = "Sequential write",
1319 },
6eaf09d6
SL
1320 { .ival = "trim",
1321 .oval = TD_DDIR_TRIM,
1322 .help = "Sequential trim",
1323 },
214e1eca
JA
1324 { .ival = "randread",
1325 .oval = TD_DDIR_RANDREAD,
1326 .help = "Random read",
1327 },
1328 { .ival = "randwrite",
1329 .oval = TD_DDIR_RANDWRITE,
1330 .help = "Random write",
1331 },
6eaf09d6
SL
1332 { .ival = "randtrim",
1333 .oval = TD_DDIR_RANDTRIM,
1334 .help = "Random trim",
1335 },
214e1eca
JA
1336 { .ival = "rw",
1337 .oval = TD_DDIR_RW,
1338 .help = "Sequential read and write mix",
1339 },
10b023db
JA
1340 { .ival = "readwrite",
1341 .oval = TD_DDIR_RW,
1342 .help = "Sequential read and write mix",
1343 },
214e1eca
JA
1344 { .ival = "randrw",
1345 .oval = TD_DDIR_RANDRW,
1346 .help = "Random read and write mix"
1347 },
82a90686
JA
1348 { .ival = "trimwrite",
1349 .oval = TD_DDIR_TRIMWRITE,
1350 .help = "Trim and write mix, trims preceding writes"
0e4dd95c 1351 },
214e1eca
JA
1352 },
1353 },
38dad62d
JA
1354 {
1355 .name = "rw_sequencer",
e8b0e958 1356 .lname = "RW Sequencer",
38dad62d
JA
1357 .type = FIO_OPT_STR,
1358 .off1 = td_var_offset(rw_seq),
1359 .help = "IO offset generator modifier",
1360 .def = "sequential",
e8b0e958 1361 .category = FIO_OPT_C_IO,
0626037e 1362 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1363 .posval = {
1364 { .ival = "sequential",
1365 .oval = RW_SEQ_SEQ,
1366 .help = "Generate sequential offsets",
1367 },
1368 { .ival = "identical",
1369 .oval = RW_SEQ_IDENT,
1370 .help = "Generate identical offsets",
1371 },
1372 },
1373 },
1374
214e1eca
JA
1375 {
1376 .name = "ioengine",
e8b0e958 1377 .lname = "IO Engine",
214e1eca
JA
1378 .type = FIO_OPT_STR_STORE,
1379 .off1 = td_var_offset(ioengine),
1380 .help = "IO engine to use",
58483fa4 1381 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1382 .category = FIO_OPT_C_IO,
0626037e 1383 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1384 .posval = {
1385 { .ival = "sync",
1386 .help = "Use read/write",
1387 },
a31041ea 1388 { .ival = "psync",
1389 .help = "Use pread/pwrite",
1390 },
1d2af02a 1391 { .ival = "vsync",
03e20d68 1392 .help = "Use readv/writev",
1d2af02a 1393 },
07fc0acd
JA
1394#ifdef CONFIG_PWRITEV
1395 { .ival = "pvsync",
1396 .help = "Use preadv/pwritev",
1397 },
1398#endif
67bf9823 1399#ifdef CONFIG_LIBAIO
214e1eca
JA
1400 { .ival = "libaio",
1401 .help = "Linux native asynchronous IO",
1402 },
1403#endif
67bf9823 1404#ifdef CONFIG_POSIXAIO
214e1eca
JA
1405 { .ival = "posixaio",
1406 .help = "POSIX asynchronous IO",
1407 },
417f0068 1408#endif
997843cb 1409#ifdef CONFIG_SOLARISAIO
417f0068
JA
1410 { .ival = "solarisaio",
1411 .help = "Solaris native asynchronous IO",
1412 },
214e1eca 1413#endif
4700b234 1414#ifdef CONFIG_WINDOWSAIO
03e20d68 1415 { .ival = "windowsaio",
3be80071 1416 .help = "Windows native asynchronous IO"
de890a1e 1417 },
fc5c0345
DG
1418#endif
1419#ifdef CONFIG_RBD
1420 { .ival = "rbd",
1421 .help = "Rados Block Device asynchronous IO"
1422 },
3be80071 1423#endif
214e1eca 1424 { .ival = "mmap",
03e20d68 1425 .help = "Memory mapped IO"
214e1eca 1426 },
67bf9823 1427#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1428 { .ival = "splice",
1429 .help = "splice/vmsplice based IO",
1430 },
9cce02e8
JA
1431 { .ival = "netsplice",
1432 .help = "splice/vmsplice to/from the network",
1433 },
214e1eca
JA
1434#endif
1435#ifdef FIO_HAVE_SGIO
1436 { .ival = "sg",
1437 .help = "SCSI generic v3 IO",
1438 },
1439#endif
1440 { .ival = "null",
1441 .help = "Testing engine (no data transfer)",
1442 },
1443 { .ival = "net",
1444 .help = "Network IO",
1445 },
214e1eca 1446 { .ival = "cpuio",
03e20d68 1447 .help = "CPU cycle burner engine",
214e1eca 1448 },
67bf9823 1449#ifdef CONFIG_GUASI
b8c82a46
JA
1450 { .ival = "guasi",
1451 .help = "GUASI IO engine",
1452 },
79a43187
JA
1453#endif
1454#ifdef FIO_HAVE_BINJECT
1455 { .ival = "binject",
1456 .help = "binject direct inject block engine",
1457 },
21b8aee8 1458#endif
67bf9823 1459#ifdef CONFIG_RDMA
21b8aee8 1460 { .ival = "rdma",
1461 .help = "RDMA IO engine",
1462 },
8200b8c7 1463#endif
67bf9823 1464#ifdef CONFIG_FUSION_AW
8200b8c7
JA
1465 { .ival = "fusion-aw-sync",
1466 .help = "Fusion-io atomic write engine",
1467 },
1ecc95ca 1468#endif
997843cb 1469#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1470 { .ival = "e4defrag",
1471 .help = "ext4 defrag engine",
1472 },
1473#endif
997843cb 1474#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1475 { .ival = "falloc",
1476 .help = "fallocate() file based engine",
1477 },
b8c82a46 1478#endif
a7c386f4 1479#ifdef CONFIG_GFAPI
1480 { .ival = "gfapi",
cc47f094 1481 .help = "Glusterfs libgfapi(sync) based engine"
1482 },
1483 { .ival = "gfapi_async",
1484 .help = "Glusterfs libgfapi(async) based engine"
a7c386f4 1485 },
1486#endif
1b10477b 1487#ifdef CONFIG_LIBHDFS
b74e419e 1488 { .ival = "libhdfs",
1b10477b
MM
1489 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1490 },
1491#endif
214e1eca
JA
1492 { .ival = "external",
1493 .help = "Load external engine (append name)",
1494 },
1495 },
1496 },
1497 {
1498 .name = "iodepth",
e8b0e958 1499 .lname = "IO Depth",
214e1eca
JA
1500 .type = FIO_OPT_INT,
1501 .off1 = td_var_offset(iodepth),
03e20d68 1502 .help = "Number of IO buffers to keep in flight",
757aff4f 1503 .minval = 1,
20eb06bd 1504 .interval = 1,
214e1eca 1505 .def = "1",
e8b0e958 1506 .category = FIO_OPT_C_IO,
0626037e 1507 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1508 },
1509 {
1510 .name = "iodepth_batch",
e8b0e958 1511 .lname = "IO Depth batch",
4950421a 1512 .alias = "iodepth_batch_submit",
214e1eca
JA
1513 .type = FIO_OPT_INT,
1514 .off1 = td_var_offset(iodepth_batch),
d65db441 1515 .help = "Number of IO buffers to submit in one go",
afdf9352 1516 .parent = "iodepth",
d71c154c 1517 .hide = 1,
a2e6f8ac 1518 .minval = 1,
20eb06bd 1519 .interval = 1,
a2e6f8ac 1520 .def = "1",
e8b0e958 1521 .category = FIO_OPT_C_IO,
0626037e 1522 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1523 },
1524 {
82407585
RP
1525 .name = "iodepth_batch_complete_min",
1526 .lname = "Min IO depth batch complete",
1527 .alias = "iodepth_batch_complete",
4950421a 1528 .type = FIO_OPT_INT,
82407585
RP
1529 .off1 = td_var_offset(iodepth_batch_complete_min),
1530 .help = "Min number of IO buffers to retrieve in one go",
4950421a 1531 .parent = "iodepth",
d71c154c 1532 .hide = 1,
4950421a 1533 .minval = 0,
20eb06bd 1534 .interval = 1,
4950421a 1535 .def = "1",
e8b0e958 1536 .category = FIO_OPT_C_IO,
0626037e 1537 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1538 },
82407585
RP
1539 {
1540 .name = "iodepth_batch_complete_max",
1541 .lname = "Max IO depth batch complete",
1542 .type = FIO_OPT_INT,
1543 .off1 = td_var_offset(iodepth_batch_complete_max),
1544 .help = "Max number of IO buffers to retrieve in one go",
1545 .parent = "iodepth",
1546 .hide = 1,
1547 .minval = 0,
1548 .interval = 1,
1549 .category = FIO_OPT_C_IO,
1550 .group = FIO_OPT_G_IO_BASIC,
1551 },
214e1eca
JA
1552 {
1553 .name = "iodepth_low",
e8b0e958 1554 .lname = "IO Depth batch low",
214e1eca
JA
1555 .type = FIO_OPT_INT,
1556 .off1 = td_var_offset(iodepth_low),
1557 .help = "Low water mark for queuing depth",
afdf9352 1558 .parent = "iodepth",
d71c154c 1559 .hide = 1,
20eb06bd 1560 .interval = 1,
e8b0e958 1561 .category = FIO_OPT_C_IO,
0626037e 1562 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1563 },
a9da8ab2
JA
1564 {
1565 .name = "io_submit_mode",
1566 .lname = "IO submit mode",
1567 .type = FIO_OPT_STR,
1568 .off1 = td_var_offset(io_submit_mode),
1569 .help = "How IO submissions and completions are done",
1570 .def = "inline",
1571 .category = FIO_OPT_C_IO,
1572 .group = FIO_OPT_G_IO_BASIC,
1573 .posval = {
1574 { .ival = "inline",
1575 .oval = IO_MODE_INLINE,
1576 .help = "Submit and complete IO inline",
1577 },
1578 { .ival = "offload",
1579 .oval = IO_MODE_OFFLOAD,
1580 .help = "Offload submit and complete to threads",
1581 },
1582 },
1583 },
214e1eca
JA
1584 {
1585 .name = "size",
e8b0e958 1586 .lname = "Size",
214e1eca 1587 .type = FIO_OPT_STR_VAL,
7bb59102 1588 .cb = str_size_cb,
a8523a6a 1589 .off1 = td_var_offset(size),
214e1eca 1590 .help = "Total size of device or files",
20eb06bd 1591 .interval = 1024 * 1024,
e8b0e958
JA
1592 .category = FIO_OPT_C_IO,
1593 .group = FIO_OPT_G_INVALID,
214e1eca 1594 },
77731b29 1595 {
a4d3b4db
JA
1596 .name = "io_size",
1597 .alias = "io_limit",
1598 .lname = "IO Size",
77731b29
JA
1599 .type = FIO_OPT_STR_VAL,
1600 .off1 = td_var_offset(io_limit),
1601 .interval = 1024 * 1024,
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
1604 },
aa31f1f1
SL
1605 {
1606 .name = "fill_device",
e8b0e958 1607 .lname = "Fill device",
74586c1e 1608 .alias = "fill_fs",
aa31f1f1
SL
1609 .type = FIO_OPT_BOOL,
1610 .off1 = td_var_offset(fill_device),
1611 .help = "Write until an ENOSPC error occurs",
1612 .def = "0",
e8b0e958
JA
1613 .category = FIO_OPT_C_FILE,
1614 .group = FIO_OPT_G_INVALID,
aa31f1f1 1615 },
214e1eca
JA
1616 {
1617 .name = "filesize",
e8b0e958 1618 .lname = "File size",
214e1eca
JA
1619 .type = FIO_OPT_STR_VAL,
1620 .off1 = td_var_offset(file_size_low),
1621 .off2 = td_var_offset(file_size_high),
c3edbdba 1622 .minval = 1,
214e1eca 1623 .help = "Size of individual files",
20eb06bd 1624 .interval = 1024 * 1024,
e8b0e958
JA
1625 .category = FIO_OPT_C_FILE,
1626 .group = FIO_OPT_G_INVALID,
214e1eca 1627 },
bedc9dc2
JA
1628 {
1629 .name = "file_append",
1630 .lname = "File append",
1631 .type = FIO_OPT_BOOL,
1632 .off1 = td_var_offset(file_append),
1633 .help = "IO will start at the end of the file(s)",
1634 .def = "0",
1635 .category = FIO_OPT_C_FILE,
1636 .group = FIO_OPT_G_INVALID,
1637 },
67a1000f
JA
1638 {
1639 .name = "offset",
e8b0e958 1640 .lname = "IO offset",
67a1000f
JA
1641 .alias = "fileoffset",
1642 .type = FIO_OPT_STR_VAL,
1643 .off1 = td_var_offset(start_offset),
1644 .help = "Start IO from this offset",
1645 .def = "0",
20eb06bd 1646 .interval = 1024 * 1024,
e8b0e958
JA
1647 .category = FIO_OPT_C_IO,
1648 .group = FIO_OPT_G_INVALID,
67a1000f 1649 },
2d7cd868
JA
1650 {
1651 .name = "offset_increment",
e8b0e958 1652 .lname = "IO offset increment",
2d7cd868
JA
1653 .type = FIO_OPT_STR_VAL,
1654 .off1 = td_var_offset(offset_increment),
1655 .help = "What is the increment from one offset to the next",
1656 .parent = "offset",
d71c154c 1657 .hide = 1,
2d7cd868 1658 .def = "0",
20eb06bd 1659 .interval = 1024 * 1024,
e8b0e958
JA
1660 .category = FIO_OPT_C_IO,
1661 .group = FIO_OPT_G_INVALID,
2d7cd868 1662 },
ddf24e42
JA
1663 {
1664 .name = "number_ios",
1665 .lname = "Number of IOs to perform",
1666 .type = FIO_OPT_STR_VAL,
1667 .off1 = td_var_offset(number_ios),
be3fec7d 1668 .help = "Force job completion after this number of IOs",
ddf24e42
JA
1669 .def = "0",
1670 .category = FIO_OPT_C_IO,
1671 .group = FIO_OPT_G_INVALID,
1672 },
214e1eca
JA
1673 {
1674 .name = "bs",
e8b0e958 1675 .lname = "Block size",
d3aad8f2 1676 .alias = "blocksize",
e01b22b8 1677 .type = FIO_OPT_INT,
214e1eca
JA
1678 .off1 = td_var_offset(bs[DDIR_READ]),
1679 .off2 = td_var_offset(bs[DDIR_WRITE]),
6eaf09d6 1680 .off3 = td_var_offset(bs[DDIR_TRIM]),
c3edbdba 1681 .minval = 1,
214e1eca
JA
1682 .help = "Block size unit",
1683 .def = "4k",
67a1000f 1684 .parent = "rw",
d71c154c 1685 .hide = 1,
20eb06bd 1686 .interval = 512,
e8b0e958
JA
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_INVALID,
214e1eca 1689 },
2b7a01d0
JA
1690 {
1691 .name = "ba",
e8b0e958 1692 .lname = "Block size align",
2b7a01d0 1693 .alias = "blockalign",
e01b22b8 1694 .type = FIO_OPT_INT,
2b7a01d0
JA
1695 .off1 = td_var_offset(ba[DDIR_READ]),
1696 .off2 = td_var_offset(ba[DDIR_WRITE]),
6eaf09d6 1697 .off3 = td_var_offset(ba[DDIR_TRIM]),
2b7a01d0
JA
1698 .minval = 1,
1699 .help = "IO block offset alignment",
1700 .parent = "rw",
d71c154c 1701 .hide = 1,
20eb06bd 1702 .interval = 512,
e8b0e958
JA
1703 .category = FIO_OPT_C_IO,
1704 .group = FIO_OPT_G_INVALID,
2b7a01d0 1705 },
214e1eca
JA
1706 {
1707 .name = "bsrange",
e8b0e958 1708 .lname = "Block size range",
d3aad8f2 1709 .alias = "blocksize_range",
214e1eca
JA
1710 .type = FIO_OPT_RANGE,
1711 .off1 = td_var_offset(min_bs[DDIR_READ]),
1712 .off2 = td_var_offset(max_bs[DDIR_READ]),
1713 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1714 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
6eaf09d6
SL
1715 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1716 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
c3edbdba 1717 .minval = 1,
214e1eca 1718 .help = "Set block size range (in more detail than bs)",
67a1000f 1719 .parent = "rw",
d71c154c 1720 .hide = 1,
20eb06bd 1721 .interval = 4096,
e8b0e958
JA
1722 .category = FIO_OPT_C_IO,
1723 .group = FIO_OPT_G_INVALID,
214e1eca 1724 },
564ca972
JA
1725 {
1726 .name = "bssplit",
e8b0e958 1727 .lname = "Block size split",
564ca972
JA
1728 .type = FIO_OPT_STR,
1729 .cb = str_bssplit_cb,
a8523a6a 1730 .off1 = td_var_offset(bssplit),
564ca972
JA
1731 .help = "Set a specific mix of block sizes",
1732 .parent = "rw",
d71c154c 1733 .hide = 1,
e8b0e958
JA
1734 .category = FIO_OPT_C_IO,
1735 .group = FIO_OPT_G_INVALID,
564ca972 1736 },
214e1eca
JA
1737 {
1738 .name = "bs_unaligned",
e8b0e958 1739 .lname = "Block size unaligned",
d3aad8f2 1740 .alias = "blocksize_unaligned",
214e1eca
JA
1741 .type = FIO_OPT_STR_SET,
1742 .off1 = td_var_offset(bs_unaligned),
1743 .help = "Don't sector align IO buffer sizes",
67a1000f 1744 .parent = "rw",
d71c154c 1745 .hide = 1,
e8b0e958
JA
1746 .category = FIO_OPT_C_IO,
1747 .group = FIO_OPT_G_INVALID,
214e1eca 1748 },
6aca9b3d
JA
1749 {
1750 .name = "bs_is_seq_rand",
1751 .lname = "Block size division is seq/random (not read/write)",
1752 .type = FIO_OPT_BOOL,
1753 .off1 = td_var_offset(bs_is_seq_rand),
86d59660 1754 .help = "Consider any blocksize setting to be sequential,random",
6aca9b3d
JA
1755 .def = "0",
1756 .parent = "blocksize",
1757 .category = FIO_OPT_C_IO,
1758 .group = FIO_OPT_G_INVALID,
1759 },
214e1eca
JA
1760 {
1761 .name = "randrepeat",
e8b0e958 1762 .lname = "Random repeatable",
214e1eca
JA
1763 .type = FIO_OPT_BOOL,
1764 .off1 = td_var_offset(rand_repeatable),
1765 .help = "Use repeatable random IO pattern",
1766 .def = "1",
67a1000f 1767 .parent = "rw",
d71c154c 1768 .hide = 1,
e8b0e958 1769 .category = FIO_OPT_C_IO,
3ceb458f 1770 .group = FIO_OPT_G_RANDOM,
214e1eca 1771 },
04778baf
JA
1772 {
1773 .name = "randseed",
1774 .lname = "The random generator seed",
363cffa7 1775 .type = FIO_OPT_STR_VAL,
04778baf
JA
1776 .off1 = td_var_offset(rand_seed),
1777 .help = "Set the random generator seed value",
40fe5e7b 1778 .def = "0x89",
04778baf
JA
1779 .parent = "rw",
1780 .category = FIO_OPT_C_IO,
1781 .group = FIO_OPT_G_RANDOM,
1782 },
2615cc4b
JA
1783 {
1784 .name = "use_os_rand",
e8b0e958 1785 .lname = "Use OS random",
54a21917
JA
1786 .type = FIO_OPT_DEPRECATED,
1787 .off1 = td_var_offset(dep_use_os_rand),
e8b0e958 1788 .category = FIO_OPT_C_IO,
3ceb458f 1789 .group = FIO_OPT_G_RANDOM,
2615cc4b 1790 },
214e1eca
JA
1791 {
1792 .name = "norandommap",
e8b0e958 1793 .lname = "No randommap",
214e1eca
JA
1794 .type = FIO_OPT_STR_SET,
1795 .off1 = td_var_offset(norandommap),
1796 .help = "Accept potential duplicate random blocks",
67a1000f 1797 .parent = "rw",
d71c154c 1798 .hide = 1,
b2452a43 1799 .hide_on_set = 1,
e8b0e958 1800 .category = FIO_OPT_C_IO,
3ceb458f 1801 .group = FIO_OPT_G_RANDOM,
214e1eca 1802 },
2b386d25
JA
1803 {
1804 .name = "softrandommap",
e8b0e958 1805 .lname = "Soft randommap",
2b386d25
JA
1806 .type = FIO_OPT_BOOL,
1807 .off1 = td_var_offset(softrandommap),
f66ab3c8 1808 .help = "Set norandommap if randommap allocation fails",
2b386d25 1809 .parent = "norandommap",
d71c154c 1810 .hide = 1,
2b386d25 1811 .def = "0",
e8b0e958 1812 .category = FIO_OPT_C_IO,
3ceb458f 1813 .group = FIO_OPT_G_RANDOM,
2b386d25 1814 },
8055e41d
JA
1815 {
1816 .name = "random_generator",
1817 .type = FIO_OPT_STR,
1818 .off1 = td_var_offset(random_generator),
1819 .help = "Type of random number generator to use",
1820 .def = "tausworthe",
1821 .posval = {
1822 { .ival = "tausworthe",
1823 .oval = FIO_RAND_GEN_TAUSWORTHE,
1824 .help = "Strong Tausworthe generator",
1825 },
1826 { .ival = "lfsr",
1827 .oval = FIO_RAND_GEN_LFSR,
1828 .help = "Variable length LFSR",
1829 },
c3546b53
JA
1830 {
1831 .ival = "tausworthe64",
1832 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1833 .help = "64-bit Tausworthe variant",
1834 },
8055e41d 1835 },
48107598
JA
1836 .category = FIO_OPT_C_IO,
1837 .group = FIO_OPT_G_RANDOM,
8055e41d 1838 },
e25839d4
JA
1839 {
1840 .name = "random_distribution",
1841 .type = FIO_OPT_STR,
1842 .off1 = td_var_offset(random_distribution),
1843 .cb = str_random_distribution_cb,
1844 .help = "Random offset distribution generator",
1845 .def = "random",
1846 .posval = {
1847 { .ival = "random",
1848 .oval = FIO_RAND_DIST_RANDOM,
1849 .help = "Completely random",
1850 },
1851 { .ival = "zipf",
1852 .oval = FIO_RAND_DIST_ZIPF,
1853 .help = "Zipf distribution",
1854 },
925fee33
JA
1855 { .ival = "pareto",
1856 .oval = FIO_RAND_DIST_PARETO,
1857 .help = "Pareto distribution",
1858 },
56d9fa4b
JA
1859 { .ival = "normal",
1860 .oval = FIO_RAND_DIST_GAUSS,
1861 .help = "Normal (gaussian) distribution",
1862 },
e25839d4 1863 },
48107598
JA
1864 .category = FIO_OPT_C_IO,
1865 .group = FIO_OPT_G_RANDOM,
e25839d4 1866 },
211c9b89
JA
1867 {
1868 .name = "percentage_random",
1869 .lname = "Percentage Random",
1870 .type = FIO_OPT_INT,
d9472271
JA
1871 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1872 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1873 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
211c9b89
JA
1874 .maxval = 100,
1875 .help = "Percentage of seq/random mix that should be random",
d9472271 1876 .def = "100,100,100",
211c9b89
JA
1877 .interval = 5,
1878 .inverse = "percentage_sequential",
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_RANDOM,
1881 },
1882 {
1883 .name = "percentage_sequential",
1884 .lname = "Percentage Sequential",
d9472271 1885 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
1886 .category = FIO_OPT_C_IO,
1887 .group = FIO_OPT_G_RANDOM,
1888 },
56e2a5fc
CE
1889 {
1890 .name = "allrandrepeat",
1891 .type = FIO_OPT_BOOL,
1892 .off1 = td_var_offset(allrand_repeatable),
1893 .help = "Use repeatable random numbers for everything",
1894 .def = "0",
a869d9c6
JA
1895 .category = FIO_OPT_C_IO,
1896 .group = FIO_OPT_G_RANDOM,
56e2a5fc 1897 },
214e1eca
JA
1898 {
1899 .name = "nrfiles",
e8b0e958 1900 .lname = "Number of files",
d7c8be03 1901 .alias = "nr_files",
214e1eca
JA
1902 .type = FIO_OPT_INT,
1903 .off1 = td_var_offset(nr_files),
1904 .help = "Split job workload between this number of files",
1905 .def = "1",
20eb06bd 1906 .interval = 1,
e8b0e958
JA
1907 .category = FIO_OPT_C_FILE,
1908 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1909 },
1910 {
1911 .name = "openfiles",
e8b0e958 1912 .lname = "Number of open files",
214e1eca
JA
1913 .type = FIO_OPT_INT,
1914 .off1 = td_var_offset(open_files),
1915 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1916 .category = FIO_OPT_C_FILE,
1917 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1918 },
1919 {
1920 .name = "file_service_type",
e8b0e958 1921 .lname = "File service type",
214e1eca
JA
1922 .type = FIO_OPT_STR,
1923 .cb = str_fst_cb,
1924 .off1 = td_var_offset(file_service_type),
1925 .help = "How to select which file to service next",
1926 .def = "roundrobin",
e8b0e958
JA
1927 .category = FIO_OPT_C_FILE,
1928 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1929 .posval = {
1930 { .ival = "random",
1931 .oval = FIO_FSERVICE_RANDOM,
1932 .help = "Choose a file at random",
1933 },
1934 { .ival = "roundrobin",
1935 .oval = FIO_FSERVICE_RR,
1936 .help = "Round robin select files",
1937 },
a086c257
JA
1938 { .ival = "sequential",
1939 .oval = FIO_FSERVICE_SEQ,
1940 .help = "Finish one file before moving to the next",
1941 },
214e1eca 1942 },
67a1000f 1943 .parent = "nrfiles",
d71c154c 1944 .hide = 1,
67a1000f 1945 },
97ac992c 1946#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
1947 {
1948 .name = "fallocate",
e8b0e958 1949 .lname = "Fallocate",
a596f047
EG
1950 .type = FIO_OPT_STR,
1951 .off1 = td_var_offset(fallocate_mode),
1952 .help = "Whether pre-allocation is performed when laying out files",
1953 .def = "posix",
e8b0e958
JA
1954 .category = FIO_OPT_C_FILE,
1955 .group = FIO_OPT_G_INVALID,
a596f047
EG
1956 .posval = {
1957 { .ival = "none",
1958 .oval = FIO_FALLOCATE_NONE,
1959 .help = "Do not pre-allocate space",
1960 },
1961 { .ival = "posix",
1962 .oval = FIO_FALLOCATE_POSIX,
1963 .help = "Use posix_fallocate()",
1964 },
97ac992c 1965#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
1966 { .ival = "keep",
1967 .oval = FIO_FALLOCATE_KEEP_SIZE,
1968 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1969 },
7bc8c2cf 1970#endif
a596f047
EG
1971 /* Compatibility with former boolean values */
1972 { .ival = "0",
1973 .oval = FIO_FALLOCATE_NONE,
1974 .help = "Alias for 'none'",
1975 },
1976 { .ival = "1",
1977 .oval = FIO_FALLOCATE_POSIX,
1978 .help = "Alias for 'posix'",
1979 },
1980 },
1981 },
97ac992c 1982#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
1983 {
1984 .name = "fadvise_hint",
e8b0e958 1985 .lname = "Fadvise hint",
67a1000f
JA
1986 .type = FIO_OPT_BOOL,
1987 .off1 = td_var_offset(fadvise_hint),
1988 .help = "Use fadvise() to advise the kernel on IO pattern",
1989 .def = "1",
e8b0e958
JA
1990 .category = FIO_OPT_C_FILE,
1991 .group = FIO_OPT_G_INVALID,
214e1eca 1992 },
37659335
JA
1993#ifdef FIO_HAVE_STREAMID
1994 {
1995 .name = "fadvise_stream",
1996 .lname = "Fadvise stream",
1997 .type = FIO_OPT_INT,
1998 .off1 = td_var_offset(fadvise_stream),
1999 .help = "Use fadvise() to set stream ID",
2000 .category = FIO_OPT_C_FILE,
2001 .group = FIO_OPT_G_INVALID,
2002 },
2003#endif
214e1eca
JA
2004 {
2005 .name = "fsync",
e8b0e958 2006 .lname = "Fsync",
214e1eca
JA
2007 .type = FIO_OPT_INT,
2008 .off1 = td_var_offset(fsync_blocks),
2009 .help = "Issue fsync for writes every given number of blocks",
2010 .def = "0",
20eb06bd 2011 .interval = 1,
e8b0e958
JA
2012 .category = FIO_OPT_C_FILE,
2013 .group = FIO_OPT_G_INVALID,
214e1eca 2014 },
5f9099ea
JA
2015 {
2016 .name = "fdatasync",
e8b0e958 2017 .lname = "Fdatasync",
5f9099ea
JA
2018 .type = FIO_OPT_INT,
2019 .off1 = td_var_offset(fdatasync_blocks),
2020 .help = "Issue fdatasync for writes every given number of blocks",
2021 .def = "0",
20eb06bd 2022 .interval = 1,
e8b0e958
JA
2023 .category = FIO_OPT_C_FILE,
2024 .group = FIO_OPT_G_INVALID,
5f9099ea 2025 },
1ef2b6be
JA
2026 {
2027 .name = "write_barrier",
e8b0e958 2028 .lname = "Write barrier",
1ef2b6be
JA
2029 .type = FIO_OPT_INT,
2030 .off1 = td_var_offset(barrier_blocks),
2031 .help = "Make every Nth write a barrier write",
2032 .def = "0",
20eb06bd 2033 .interval = 1,
e8b0e958
JA
2034 .category = FIO_OPT_C_IO,
2035 .group = FIO_OPT_G_INVALID,
1ef2b6be 2036 },
67bf9823 2037#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2038 {
2039 .name = "sync_file_range",
e8b0e958 2040 .lname = "Sync file range",
44f29692
JA
2041 .posval = {
2042 { .ival = "wait_before",
2043 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2044 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2045 .orval = 1,
44f29692
JA
2046 },
2047 { .ival = "write",
2048 .oval = SYNC_FILE_RANGE_WRITE,
2049 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2050 .orval = 1,
44f29692
JA
2051 },
2052 {
2053 .ival = "wait_after",
2054 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2055 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2056 .orval = 1,
44f29692
JA
2057 },
2058 },
3843deb3 2059 .type = FIO_OPT_STR_MULTI,
44f29692
JA
2060 .cb = str_sfr_cb,
2061 .off1 = td_var_offset(sync_file_range),
2062 .help = "Use sync_file_range()",
e8b0e958
JA
2063 .category = FIO_OPT_C_FILE,
2064 .group = FIO_OPT_G_INVALID,
44f29692
JA
2065 },
2066#endif
214e1eca
JA
2067 {
2068 .name = "direct",
e8b0e958 2069 .lname = "Direct I/O",
214e1eca
JA
2070 .type = FIO_OPT_BOOL,
2071 .off1 = td_var_offset(odirect),
2072 .help = "Use O_DIRECT IO (negates buffered)",
2073 .def = "0",
a01a1bc5 2074 .inverse = "buffered",
e8b0e958 2075 .category = FIO_OPT_C_IO,
3ceb458f 2076 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2077 },
d01612f3
CM
2078 {
2079 .name = "atomic",
2080 .lname = "Atomic I/O",
2081 .type = FIO_OPT_BOOL,
2082 .off1 = td_var_offset(oatomic),
2083 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2084 .def = "0",
2085 .category = FIO_OPT_C_IO,
2086 .group = FIO_OPT_G_IO_TYPE,
2087 },
214e1eca
JA
2088 {
2089 .name = "buffered",
e8b0e958 2090 .lname = "Buffered I/O",
214e1eca
JA
2091 .type = FIO_OPT_BOOL,
2092 .off1 = td_var_offset(odirect),
2093 .neg = 1,
2094 .help = "Use buffered IO (negates direct)",
2095 .def = "1",
a01a1bc5 2096 .inverse = "direct",
e8b0e958 2097 .category = FIO_OPT_C_IO,
3ceb458f 2098 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2099 },
2100 {
2101 .name = "overwrite",
e8b0e958 2102 .lname = "Overwrite",
214e1eca
JA
2103 .type = FIO_OPT_BOOL,
2104 .off1 = td_var_offset(overwrite),
2105 .help = "When writing, set whether to overwrite current data",
2106 .def = "0",
e8b0e958
JA
2107 .category = FIO_OPT_C_FILE,
2108 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2109 },
2110 {
2111 .name = "loops",
e8b0e958 2112 .lname = "Loops",
214e1eca
JA
2113 .type = FIO_OPT_INT,
2114 .off1 = td_var_offset(loops),
2115 .help = "Number of times to run the job",
2116 .def = "1",
20eb06bd 2117 .interval = 1,
e8b0e958 2118 .category = FIO_OPT_C_GENERAL,
a1f6afec 2119 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2120 },
2121 {
2122 .name = "numjobs",
e8b0e958 2123 .lname = "Number of jobs",
214e1eca
JA
2124 .type = FIO_OPT_INT,
2125 .off1 = td_var_offset(numjobs),
2126 .help = "Duplicate this job this many times",
2127 .def = "1",
20eb06bd 2128 .interval = 1,
e8b0e958 2129 .category = FIO_OPT_C_GENERAL,
a1f6afec 2130 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2131 },
2132 {
2133 .name = "startdelay",
e8b0e958 2134 .lname = "Start delay",
a5737c93 2135 .type = FIO_OPT_STR_VAL_TIME,
214e1eca 2136 .off1 = td_var_offset(start_delay),
23ed19b0 2137 .off2 = td_var_offset(start_delay_high),
214e1eca
JA
2138 .help = "Only start job when this period has passed",
2139 .def = "0",
0de5b26f 2140 .is_seconds = 1,
88038bc7 2141 .is_time = 1,
e8b0e958 2142 .category = FIO_OPT_C_GENERAL,
a1f6afec 2143 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2144 },
2145 {
2146 .name = "runtime",
e8b0e958 2147 .lname = "Runtime",
214e1eca
JA
2148 .alias = "timeout",
2149 .type = FIO_OPT_STR_VAL_TIME,
2150 .off1 = td_var_offset(timeout),
2151 .help = "Stop workload when this amount of time has passed",
2152 .def = "0",
0de5b26f 2153 .is_seconds = 1,
88038bc7 2154 .is_time = 1,
e8b0e958 2155 .category = FIO_OPT_C_GENERAL,
a1f6afec 2156 .group = FIO_OPT_G_RUNTIME,
214e1eca 2157 },
cf4464ca
JA
2158 {
2159 .name = "time_based",
e8b0e958 2160 .lname = "Time based",
cf4464ca
JA
2161 .type = FIO_OPT_STR_SET,
2162 .off1 = td_var_offset(time_based),
2163 .help = "Keep running until runtime/timeout is met",
e8b0e958 2164 .category = FIO_OPT_C_GENERAL,
a1f6afec 2165 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2166 },
62167762
JC
2167 {
2168 .name = "verify_only",
2169 .lname = "Verify only",
2170 .type = FIO_OPT_STR_SET,
2171 .off1 = td_var_offset(verify_only),
2172 .help = "Verifies previously written data is still valid",
2173 .category = FIO_OPT_C_GENERAL,
2174 .group = FIO_OPT_G_RUNTIME,
2175 },
721938ae
JA
2176 {
2177 .name = "ramp_time",
e8b0e958 2178 .lname = "Ramp time",
721938ae
JA
2179 .type = FIO_OPT_STR_VAL_TIME,
2180 .off1 = td_var_offset(ramp_time),
2181 .help = "Ramp up time before measuring performance",
0de5b26f 2182 .is_seconds = 1,
88038bc7 2183 .is_time = 1,
e8b0e958 2184 .category = FIO_OPT_C_GENERAL,
a1f6afec 2185 .group = FIO_OPT_G_RUNTIME,
721938ae 2186 },
c223da83
JA
2187 {
2188 .name = "clocksource",
e8b0e958 2189 .lname = "Clock source",
c223da83
JA
2190 .type = FIO_OPT_STR,
2191 .cb = fio_clock_source_cb,
2192 .off1 = td_var_offset(clocksource),
2193 .help = "What type of timing source to use",
e8b0e958 2194 .category = FIO_OPT_C_GENERAL,
10860056 2195 .group = FIO_OPT_G_CLOCK,
c223da83 2196 .posval = {
67bf9823 2197#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2198 { .ival = "gettimeofday",
2199 .oval = CS_GTOD,
2200 .help = "Use gettimeofday(2) for timing",
2201 },
67bf9823
JA
2202#endif
2203#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2204 { .ival = "clock_gettime",
2205 .oval = CS_CGETTIME,
2206 .help = "Use clock_gettime(2) for timing",
2207 },
67bf9823 2208#endif
c223da83
JA
2209#ifdef ARCH_HAVE_CPU_CLOCK
2210 { .ival = "cpu",
2211 .oval = CS_CPUCLOCK,
2212 .help = "Use CPU private clock",
2213 },
2214#endif
2215 },
2216 },
214e1eca
JA
2217 {
2218 .name = "mem",
d3aad8f2 2219 .alias = "iomem",
e8b0e958 2220 .lname = "I/O Memory",
214e1eca
JA
2221 .type = FIO_OPT_STR,
2222 .cb = str_mem_cb,
2223 .off1 = td_var_offset(mem_type),
2224 .help = "Backing type for IO buffers",
2225 .def = "malloc",
e8b0e958
JA
2226 .category = FIO_OPT_C_IO,
2227 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2228 .posval = {
2229 { .ival = "malloc",
2230 .oval = MEM_MALLOC,
2231 .help = "Use malloc(3) for IO buffers",
2232 },
c8931876 2233#ifndef CONFIG_NO_SHM
37c8cdfe
JA
2234 { .ival = "shm",
2235 .oval = MEM_SHM,
2236 .help = "Use shared memory segments for IO buffers",
2237 },
214e1eca
JA
2238#ifdef FIO_HAVE_HUGETLB
2239 { .ival = "shmhuge",
2240 .oval = MEM_SHMHUGE,
2241 .help = "Like shm, but use huge pages",
2242 },
c8931876 2243#endif
b370e46a 2244#endif
37c8cdfe
JA
2245 { .ival = "mmap",
2246 .oval = MEM_MMAP,
2247 .help = "Use mmap(2) (file or anon) for IO buffers",
2248 },
217b0f1d
LG
2249 { .ival = "mmapshared",
2250 .oval = MEM_MMAPSHARED,
2251 .help = "Like mmap, but use the shared flag",
2252 },
214e1eca
JA
2253#ifdef FIO_HAVE_HUGETLB
2254 { .ival = "mmaphuge",
2255 .oval = MEM_MMAPHUGE,
2256 .help = "Like mmap, but use huge pages",
2257 },
2258#endif
2259 },
2260 },
d529ee19
JA
2261 {
2262 .name = "iomem_align",
2263 .alias = "mem_align",
e8b0e958 2264 .lname = "I/O memory alignment",
d529ee19
JA
2265 .type = FIO_OPT_INT,
2266 .off1 = td_var_offset(mem_align),
2267 .minval = 0,
2268 .help = "IO memory buffer offset alignment",
2269 .def = "0",
2270 .parent = "iomem",
d71c154c 2271 .hide = 1,
e8b0e958
JA
2272 .category = FIO_OPT_C_IO,
2273 .group = FIO_OPT_G_INVALID,
d529ee19 2274 },
214e1eca
JA
2275 {
2276 .name = "verify",
e8b0e958 2277 .lname = "Verify",
214e1eca
JA
2278 .type = FIO_OPT_STR,
2279 .off1 = td_var_offset(verify),
2280 .help = "Verify data written",
2281 .def = "0",
e8b0e958 2282 .category = FIO_OPT_C_IO,
3ceb458f 2283 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2284 .posval = {
2285 { .ival = "0",
2286 .oval = VERIFY_NONE,
2287 .help = "Don't do IO verification",
2288 },
fcca4b58
JA
2289 { .ival = "md5",
2290 .oval = VERIFY_MD5,
2291 .help = "Use md5 checksums for verification",
2292 },
d77a7af3
JA
2293 { .ival = "crc64",
2294 .oval = VERIFY_CRC64,
2295 .help = "Use crc64 checksums for verification",
2296 },
214e1eca
JA
2297 { .ival = "crc32",
2298 .oval = VERIFY_CRC32,
2299 .help = "Use crc32 checksums for verification",
2300 },
af497e6a 2301 { .ival = "crc32c-intel",
e3aaafc4
JA
2302 .oval = VERIFY_CRC32C,
2303 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2304 },
bac39e0e
JA
2305 { .ival = "crc32c",
2306 .oval = VERIFY_CRC32C,
e3aaafc4 2307 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2308 },
969f7ed3
JA
2309 { .ival = "crc16",
2310 .oval = VERIFY_CRC16,
2311 .help = "Use crc16 checksums for verification",
2312 },
1e154bdb
JA
2313 { .ival = "crc7",
2314 .oval = VERIFY_CRC7,
2315 .help = "Use crc7 checksums for verification",
2316 },
7c353ceb
JA
2317 { .ival = "sha1",
2318 .oval = VERIFY_SHA1,
2319 .help = "Use sha1 checksums for verification",
2320 },
cd14cc10
JA
2321 { .ival = "sha256",
2322 .oval = VERIFY_SHA256,
2323 .help = "Use sha256 checksums for verification",
2324 },
2325 { .ival = "sha512",
2326 .oval = VERIFY_SHA512,
2327 .help = "Use sha512 checksums for verification",
2328 },
844ea602
JA
2329 { .ival = "xxhash",
2330 .oval = VERIFY_XXHASH,
2331 .help = "Use xxhash checksums for verification",
2332 },
b638d82f
RP
2333 /* Meta information was included into verify_header,
2334 * 'meta' verification is implied by default. */
7437ee87 2335 { .ival = "meta",
b638d82f
RP
2336 .oval = VERIFY_HDR_ONLY,
2337 .help = "Use io information for verification. "
2338 "Now is implied by default, thus option is obsolete, "
2339 "don't use it",
7437ee87 2340 },
59245381
JA
2341 { .ival = "pattern",
2342 .oval = VERIFY_PATTERN_NO_HDR,
2343 .help = "Verify strict pattern",
2344 },
36690c9b
JA
2345 {
2346 .ival = "null",
2347 .oval = VERIFY_NULL,
2348 .help = "Pretend to verify",
2349 },
214e1eca
JA
2350 },
2351 },
005c565a
JA
2352 {
2353 .name = "do_verify",
e8b0e958 2354 .lname = "Perform verify step",
68e1f29a 2355 .type = FIO_OPT_BOOL,
005c565a
JA
2356 .off1 = td_var_offset(do_verify),
2357 .help = "Run verification stage after write",
2358 .def = "1",
2359 .parent = "verify",
d71c154c 2360 .hide = 1,
e8b0e958
JA
2361 .category = FIO_OPT_C_IO,
2362 .group = FIO_OPT_G_VERIFY,
005c565a 2363 },
160b966d
JA
2364 {
2365 .name = "verifysort",
e8b0e958 2366 .lname = "Verify sort",
160b966d
JA
2367 .type = FIO_OPT_BOOL,
2368 .off1 = td_var_offset(verifysort),
2369 .help = "Sort written verify blocks for read back",
2370 .def = "1",
c83f2df1 2371 .parent = "verify",
d71c154c 2372 .hide = 1,
e8b0e958
JA
2373 .category = FIO_OPT_C_IO,
2374 .group = FIO_OPT_G_VERIFY,
160b966d 2375 },
1ae83d45
JA
2376 {
2377 .name = "verifysort_nr",
2378 .type = FIO_OPT_INT,
2379 .off1 = td_var_offset(verifysort_nr),
2380 .help = "Pre-load and sort verify blocks for a read workload",
2381 .minval = 0,
2382 .maxval = 131072,
2383 .def = "1024",
2384 .parent = "verify",
836fcc0f
JA
2385 .category = FIO_OPT_C_IO,
2386 .group = FIO_OPT_G_VERIFY,
1ae83d45 2387 },
3f9f4e26 2388 {
a59e170d 2389 .name = "verify_interval",
e8b0e958 2390 .lname = "Verify interval",
e01b22b8 2391 .type = FIO_OPT_INT,
a59e170d 2392 .off1 = td_var_offset(verify_interval),
819a9680 2393 .minval = 2 * sizeof(struct verify_header),
a59e170d 2394 .help = "Store verify buffer header every N bytes",
afdf9352 2395 .parent = "verify",
d71c154c 2396 .hide = 1,
20eb06bd 2397 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2398 .category = FIO_OPT_C_IO,
2399 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2400 },
546a9142 2401 {
a59e170d 2402 .name = "verify_offset",
e8b0e958 2403 .lname = "Verify offset",
e01b22b8 2404 .type = FIO_OPT_INT,
a59e170d 2405 .help = "Offset verify header location by N bytes",
203160d5
JA
2406 .off1 = td_var_offset(verify_offset),
2407 .minval = sizeof(struct verify_header),
afdf9352 2408 .parent = "verify",
d71c154c 2409 .hide = 1,
e8b0e958
JA
2410 .category = FIO_OPT_C_IO,
2411 .group = FIO_OPT_G_VERIFY,
546a9142 2412 },
e28218f3
SL
2413 {
2414 .name = "verify_pattern",
e8b0e958 2415 .lname = "Verify pattern",
0e92f873 2416 .type = FIO_OPT_STR,
e28218f3 2417 .cb = str_verify_pattern_cb,
a8523a6a 2418 .off1 = td_var_offset(verify_pattern),
e28218f3
SL
2419 .help = "Fill pattern for IO buffers",
2420 .parent = "verify",
d71c154c 2421 .hide = 1,
e8b0e958
JA
2422 .category = FIO_OPT_C_IO,
2423 .group = FIO_OPT_G_VERIFY,
e28218f3 2424 },
a12a3b4d
JA
2425 {
2426 .name = "verify_fatal",
e8b0e958 2427 .lname = "Verify fatal",
68e1f29a 2428 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2429 .off1 = td_var_offset(verify_fatal),
2430 .def = "0",
2431 .help = "Exit on a single verify failure, don't continue",
2432 .parent = "verify",
d71c154c 2433 .hide = 1,
e8b0e958
JA
2434 .category = FIO_OPT_C_IO,
2435 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2436 },
b463e936
JA
2437 {
2438 .name = "verify_dump",
e8b0e958 2439 .lname = "Verify dump",
b463e936
JA
2440 .type = FIO_OPT_BOOL,
2441 .off1 = td_var_offset(verify_dump),
ef71e317 2442 .def = "0",
b463e936
JA
2443 .help = "Dump contents of good and bad blocks on failure",
2444 .parent = "verify",
d71c154c 2445 .hide = 1,
e8b0e958
JA
2446 .category = FIO_OPT_C_IO,
2447 .group = FIO_OPT_G_VERIFY,
b463e936 2448 },
e8462bd8
JA
2449 {
2450 .name = "verify_async",
e8b0e958 2451 .lname = "Verify asynchronously",
e8462bd8
JA
2452 .type = FIO_OPT_INT,
2453 .off1 = td_var_offset(verify_async),
2454 .def = "0",
2455 .help = "Number of async verifier threads to use",
2456 .parent = "verify",
d71c154c 2457 .hide = 1,
e8b0e958
JA
2458 .category = FIO_OPT_C_IO,
2459 .group = FIO_OPT_G_VERIFY,
e8462bd8 2460 },
9e144189
JA
2461 {
2462 .name = "verify_backlog",
e8b0e958 2463 .lname = "Verify backlog",
9e144189
JA
2464 .type = FIO_OPT_STR_VAL,
2465 .off1 = td_var_offset(verify_backlog),
2466 .help = "Verify after this number of blocks are written",
2467 .parent = "verify",
d71c154c 2468 .hide = 1,
e8b0e958
JA
2469 .category = FIO_OPT_C_IO,
2470 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2471 },
2472 {
2473 .name = "verify_backlog_batch",
e8b0e958 2474 .lname = "Verify backlog batch",
9e144189
JA
2475 .type = FIO_OPT_INT,
2476 .off1 = td_var_offset(verify_batch),
2477 .help = "Verify this number of IO blocks",
0d29de83 2478 .parent = "verify",
d71c154c 2479 .hide = 1,
e8b0e958
JA
2480 .category = FIO_OPT_C_IO,
2481 .group = FIO_OPT_G_VERIFY,
9e144189 2482 },
e8462bd8
JA
2483#ifdef FIO_HAVE_CPU_AFFINITY
2484 {
2485 .name = "verify_async_cpus",
e8b0e958 2486 .lname = "Async verify CPUs",
e8462bd8
JA
2487 .type = FIO_OPT_STR,
2488 .cb = str_verify_cpus_allowed_cb,
a8523a6a 2489 .off1 = td_var_offset(verify_cpumask),
e8462bd8
JA
2490 .help = "Set CPUs allowed for async verify threads",
2491 .parent = "verify_async",
d71c154c 2492 .hide = 1,
e8b0e958
JA
2493 .category = FIO_OPT_C_IO,
2494 .group = FIO_OPT_G_VERIFY,
e8462bd8 2495 },
0d29de83 2496#endif
51aa2da8
JA
2497 {
2498 .name = "experimental_verify",
2499 .off1 = td_var_offset(experimental_verify),
2500 .type = FIO_OPT_BOOL,
b31eaac9 2501 .help = "Enable experimental verification",
ca09be4b
JA
2502 .parent = "verify",
2503 .category = FIO_OPT_C_IO,
2504 .group = FIO_OPT_G_VERIFY,
2505 },
2506 {
2507 .name = "verify_state_load",
2508 .lname = "Load verify state",
2509 .off1 = td_var_offset(verify_state),
2510 .type = FIO_OPT_BOOL,
2511 .help = "Load verify termination state",
2512 .parent = "verify",
2513 .category = FIO_OPT_C_IO,
2514 .group = FIO_OPT_G_VERIFY,
2515 },
2516 {
2517 .name = "verify_state_save",
2518 .lname = "Save verify state",
2519 .off1 = td_var_offset(verify_state_save),
2520 .type = FIO_OPT_BOOL,
2521 .def = "1",
2522 .help = "Save verify state on termination",
2523 .parent = "verify",
836fcc0f
JA
2524 .category = FIO_OPT_C_IO,
2525 .group = FIO_OPT_G_VERIFY,
51aa2da8 2526 },
0d29de83
JA
2527#ifdef FIO_HAVE_TRIM
2528 {
2529 .name = "trim_percentage",
e8b0e958 2530 .lname = "Trim percentage",
0d29de83 2531 .type = FIO_OPT_INT,
203160d5 2532 .off1 = td_var_offset(trim_percentage),
20eb06bd 2533 .minval = 0,
0d29de83
JA
2534 .maxval = 100,
2535 .help = "Number of verify blocks to discard/trim",
2536 .parent = "verify",
2537 .def = "0",
20eb06bd 2538 .interval = 1,
d71c154c 2539 .hide = 1,
e8b0e958
JA
2540 .category = FIO_OPT_C_IO,
2541 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2542 },
2543 {
2544 .name = "trim_verify_zero",
e8b0e958 2545 .lname = "Verify trim zero",
20eb06bd 2546 .type = FIO_OPT_BOOL,
0d29de83
JA
2547 .help = "Verify that trim/discarded blocks are returned as zeroes",
2548 .off1 = td_var_offset(trim_zero),
2549 .parent = "trim_percentage",
d71c154c 2550 .hide = 1,
0d29de83 2551 .def = "1",
e8b0e958
JA
2552 .category = FIO_OPT_C_IO,
2553 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2554 },
2555 {
2556 .name = "trim_backlog",
e8b0e958 2557 .lname = "Trim backlog",
0d29de83
JA
2558 .type = FIO_OPT_STR_VAL,
2559 .off1 = td_var_offset(trim_backlog),
2560 .help = "Trim after this number of blocks are written",
2561 .parent = "trim_percentage",
d71c154c 2562 .hide = 1,
20eb06bd 2563 .interval = 1,
e8b0e958
JA
2564 .category = FIO_OPT_C_IO,
2565 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2566 },
2567 {
2568 .name = "trim_backlog_batch",
e8b0e958 2569 .lname = "Trim backlog batch",
0d29de83
JA
2570 .type = FIO_OPT_INT,
2571 .off1 = td_var_offset(trim_batch),
2572 .help = "Trim this number of IO blocks",
2573 .parent = "trim_percentage",
d71c154c 2574 .hide = 1,
20eb06bd 2575 .interval = 1,
e8b0e958
JA
2576 .category = FIO_OPT_C_IO,
2577 .group = FIO_OPT_G_TRIM,
0d29de83 2578 },
e8462bd8 2579#endif
214e1eca
JA
2580 {
2581 .name = "write_iolog",
e8b0e958 2582 .lname = "Write I/O log",
214e1eca
JA
2583 .type = FIO_OPT_STR_STORE,
2584 .off1 = td_var_offset(write_iolog_file),
2585 .help = "Store IO pattern to file",
e8b0e958
JA
2586 .category = FIO_OPT_C_IO,
2587 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2588 },
2589 {
2590 .name = "read_iolog",
e8b0e958 2591 .lname = "Read I/O log",
214e1eca
JA
2592 .type = FIO_OPT_STR_STORE,
2593 .off1 = td_var_offset(read_iolog_file),
2594 .help = "Playback IO pattern from file",
e8b0e958
JA
2595 .category = FIO_OPT_C_IO,
2596 .group = FIO_OPT_G_IOLOG,
214e1eca 2597 },
64bbb865
DN
2598 {
2599 .name = "replay_no_stall",
e8b0e958 2600 .lname = "Don't stall on replay",
20eb06bd 2601 .type = FIO_OPT_BOOL,
64bbb865
DN
2602 .off1 = td_var_offset(no_stall),
2603 .def = "0",
87e7a972 2604 .parent = "read_iolog",
d71c154c 2605 .hide = 1,
64bbb865 2606 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2607 .category = FIO_OPT_C_IO,
2608 .group = FIO_OPT_G_IOLOG,
64bbb865 2609 },
d1c46c04
DN
2610 {
2611 .name = "replay_redirect",
e8b0e958 2612 .lname = "Redirect device for replay",
d1c46c04
DN
2613 .type = FIO_OPT_STR_STORE,
2614 .off1 = td_var_offset(replay_redirect),
2615 .parent = "read_iolog",
d71c154c 2616 .hide = 1,
d1c46c04 2617 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2618 .category = FIO_OPT_C_IO,
2619 .group = FIO_OPT_G_IOLOG,
d1c46c04 2620 },
0c63576e
JA
2621 {
2622 .name = "replay_scale",
2623 .lname = "Replace offset scale factor",
2624 .type = FIO_OPT_INT,
2625 .off1 = td_var_offset(replay_scale),
2626 .parent = "read_iolog",
2627 .def = "1",
2628 .help = "Align offsets to this blocksize",
2629 .category = FIO_OPT_C_IO,
2630 .group = FIO_OPT_G_IOLOG,
2631 },
2632 {
2633 .name = "replay_align",
2634 .lname = "Replace alignment",
2635 .type = FIO_OPT_INT,
2636 .off1 = td_var_offset(replay_align),
2637 .parent = "read_iolog",
2638 .help = "Scale offset down by this factor",
2639 .category = FIO_OPT_C_IO,
2640 .group = FIO_OPT_G_IOLOG,
2641 .pow2 = 1,
2642 },
214e1eca
JA
2643 {
2644 .name = "exec_prerun",
e8b0e958 2645 .lname = "Pre-execute runnable",
214e1eca
JA
2646 .type = FIO_OPT_STR_STORE,
2647 .off1 = td_var_offset(exec_prerun),
2648 .help = "Execute this file prior to running job",
e8b0e958
JA
2649 .category = FIO_OPT_C_GENERAL,
2650 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2651 },
2652 {
2653 .name = "exec_postrun",
e8b0e958 2654 .lname = "Post-execute runnable",
214e1eca
JA
2655 .type = FIO_OPT_STR_STORE,
2656 .off1 = td_var_offset(exec_postrun),
2657 .help = "Execute this file after running job",
e8b0e958
JA
2658 .category = FIO_OPT_C_GENERAL,
2659 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2660 },
2661#ifdef FIO_HAVE_IOSCHED_SWITCH
2662 {
2663 .name = "ioscheduler",
e8b0e958 2664 .lname = "I/O scheduler",
214e1eca
JA
2665 .type = FIO_OPT_STR_STORE,
2666 .off1 = td_var_offset(ioscheduler),
2667 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2668 .category = FIO_OPT_C_FILE,
2669 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2670 },
2671#endif
2672 {
2673 .name = "zonesize",
e8b0e958 2674 .lname = "Zone size",
214e1eca
JA
2675 .type = FIO_OPT_STR_VAL,
2676 .off1 = td_var_offset(zone_size),
ed335855
SN
2677 .help = "Amount of data to read per zone",
2678 .def = "0",
20eb06bd 2679 .interval = 1024 * 1024,
e8b0e958
JA
2680 .category = FIO_OPT_C_IO,
2681 .group = FIO_OPT_G_ZONE,
ed335855
SN
2682 },
2683 {
2684 .name = "zonerange",
e8b0e958 2685 .lname = "Zone range",
ed335855
SN
2686 .type = FIO_OPT_STR_VAL,
2687 .off1 = td_var_offset(zone_range),
214e1eca
JA
2688 .help = "Give size of an IO zone",
2689 .def = "0",
20eb06bd 2690 .interval = 1024 * 1024,
e8b0e958
JA
2691 .category = FIO_OPT_C_IO,
2692 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2693 },
2694 {
2695 .name = "zoneskip",
e8b0e958 2696 .lname = "Zone skip",
214e1eca
JA
2697 .type = FIO_OPT_STR_VAL,
2698 .off1 = td_var_offset(zone_skip),
2699 .help = "Space between IO zones",
2700 .def = "0",
20eb06bd 2701 .interval = 1024 * 1024,
e8b0e958
JA
2702 .category = FIO_OPT_C_IO,
2703 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2704 },
2705 {
2706 .name = "lockmem",
e8b0e958 2707 .lname = "Lock memory",
214e1eca 2708 .type = FIO_OPT_STR_VAL,
1b79a070 2709 .off1 = td_var_offset(lockmem),
81c6b6cd 2710 .help = "Lock down this amount of memory (per worker)",
214e1eca 2711 .def = "0",
20eb06bd 2712 .interval = 1024 * 1024,
e8b0e958
JA
2713 .category = FIO_OPT_C_GENERAL,
2714 .group = FIO_OPT_G_INVALID,
214e1eca 2715 },
214e1eca
JA
2716 {
2717 .name = "rwmixread",
e8b0e958 2718 .lname = "Read/write mix read",
214e1eca 2719 .type = FIO_OPT_INT,
cb499fc4 2720 .cb = str_rwmix_read_cb,
a8523a6a 2721 .off1 = td_var_offset(rwmix[DDIR_READ]),
214e1eca
JA
2722 .maxval = 100,
2723 .help = "Percentage of mixed workload that is reads",
2724 .def = "50",
20eb06bd 2725 .interval = 5,
90265353 2726 .inverse = "rwmixwrite",
e8b0e958
JA
2727 .category = FIO_OPT_C_IO,
2728 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2729 },
2730 {
2731 .name = "rwmixwrite",
e8b0e958 2732 .lname = "Read/write mix write",
214e1eca 2733 .type = FIO_OPT_INT,
cb499fc4 2734 .cb = str_rwmix_write_cb,
a8523a6a 2735 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
214e1eca
JA
2736 .maxval = 100,
2737 .help = "Percentage of mixed workload that is writes",
2738 .def = "50",
20eb06bd 2739 .interval = 5,
90265353 2740 .inverse = "rwmixread",
e8b0e958
JA
2741 .category = FIO_OPT_C_IO,
2742 .group = FIO_OPT_G_RWMIX,
214e1eca 2743 },
afdf9352
JA
2744 {
2745 .name = "rwmixcycle",
e8b0e958 2746 .lname = "Read/write mix cycle",
15ca150e 2747 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2748 .category = FIO_OPT_C_IO,
2749 .group = FIO_OPT_G_RWMIX,
afdf9352 2750 },
214e1eca
JA
2751 {
2752 .name = "nice",
e8b0e958 2753 .lname = "Nice",
214e1eca
JA
2754 .type = FIO_OPT_INT,
2755 .off1 = td_var_offset(nice),
2756 .help = "Set job CPU nice value",
2757 .minval = -19,
2758 .maxval = 20,
2759 .def = "0",
20eb06bd 2760 .interval = 1,
e8b0e958 2761 .category = FIO_OPT_C_GENERAL,
10860056 2762 .group = FIO_OPT_G_CRED,
214e1eca
JA
2763 },
2764#ifdef FIO_HAVE_IOPRIO
2765 {
2766 .name = "prio",
e8b0e958 2767 .lname = "I/O nice priority",
214e1eca 2768 .type = FIO_OPT_INT,
28727df7 2769 .off1 = td_var_offset(ioprio),
214e1eca
JA
2770 .help = "Set job IO priority value",
2771 .minval = 0,
2772 .maxval = 7,
20eb06bd 2773 .interval = 1,
e8b0e958 2774 .category = FIO_OPT_C_GENERAL,
10860056 2775 .group = FIO_OPT_G_CRED,
214e1eca
JA
2776 },
2777 {
2778 .name = "prioclass",
e8b0e958 2779 .lname = "I/O nice priority class",
214e1eca 2780 .type = FIO_OPT_INT,
28727df7 2781 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2782 .help = "Set job IO priority class",
2783 .minval = 0,
2784 .maxval = 3,
20eb06bd 2785 .interval = 1,
e8b0e958 2786 .category = FIO_OPT_C_GENERAL,
10860056 2787 .group = FIO_OPT_G_CRED,
214e1eca
JA
2788 },
2789#endif
2790 {
2791 .name = "thinktime",
e8b0e958 2792 .lname = "Thinktime",
214e1eca
JA
2793 .type = FIO_OPT_INT,
2794 .off1 = td_var_offset(thinktime),
2795 .help = "Idle time between IO buffers (usec)",
2796 .def = "0",
88038bc7 2797 .is_time = 1,
e8b0e958 2798 .category = FIO_OPT_C_IO,
3ceb458f 2799 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2800 },
2801 {
2802 .name = "thinktime_spin",
e8b0e958 2803 .lname = "Thinktime spin",
214e1eca
JA
2804 .type = FIO_OPT_INT,
2805 .off1 = td_var_offset(thinktime_spin),
2806 .help = "Start think time by spinning this amount (usec)",
2807 .def = "0",
88038bc7 2808 .is_time = 1,
afdf9352 2809 .parent = "thinktime",
d71c154c 2810 .hide = 1,
e8b0e958 2811 .category = FIO_OPT_C_IO,
3ceb458f 2812 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2813 },
2814 {
2815 .name = "thinktime_blocks",
e8b0e958 2816 .lname = "Thinktime blocks",
214e1eca
JA
2817 .type = FIO_OPT_INT,
2818 .off1 = td_var_offset(thinktime_blocks),
2819 .help = "IO buffer period between 'thinktime'",
2820 .def = "1",
afdf9352 2821 .parent = "thinktime",
d71c154c 2822 .hide = 1,
e8b0e958 2823 .category = FIO_OPT_C_IO,
3ceb458f 2824 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2825 },
2826 {
2827 .name = "rate",
e8b0e958 2828 .lname = "I/O rate",
e01b22b8 2829 .type = FIO_OPT_INT,
6eaf09d6
SL
2830 .off1 = td_var_offset(rate[DDIR_READ]),
2831 .off2 = td_var_offset(rate[DDIR_WRITE]),
2832 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2833 .help = "Set bandwidth rate",
e8b0e958
JA
2834 .category = FIO_OPT_C_IO,
2835 .group = FIO_OPT_G_RATE,
214e1eca
JA
2836 },
2837 {
6d428bcd
JA
2838 .name = "rate_min",
2839 .alias = "ratemin",
e8b0e958 2840 .lname = "I/O min rate",
e01b22b8 2841 .type = FIO_OPT_INT,
6eaf09d6
SL
2842 .off1 = td_var_offset(ratemin[DDIR_READ]),
2843 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2844 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2845 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2846 .parent = "rate",
d71c154c 2847 .hide = 1,
e8b0e958
JA
2848 .category = FIO_OPT_C_IO,
2849 .group = FIO_OPT_G_RATE,
4e991c23
JA
2850 },
2851 {
2852 .name = "rate_iops",
e8b0e958 2853 .lname = "I/O rate IOPS",
e01b22b8 2854 .type = FIO_OPT_INT,
6eaf09d6
SL
2855 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2856 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2857 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2858 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2859 .hide = 1,
e8b0e958
JA
2860 .category = FIO_OPT_C_IO,
2861 .group = FIO_OPT_G_RATE,
4e991c23
JA
2862 },
2863 {
2864 .name = "rate_iops_min",
e8b0e958 2865 .lname = "I/O min rate IOPS",
e01b22b8 2866 .type = FIO_OPT_INT,
6eaf09d6
SL
2867 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2868 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2869 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2870 .help = "Job must meet this rate or it will be shut down",
afdf9352 2871 .parent = "rate_iops",
d71c154c 2872 .hide = 1,
e8b0e958
JA
2873 .category = FIO_OPT_C_IO,
2874 .group = FIO_OPT_G_RATE,
214e1eca 2875 },
ff6bb260 2876 {
6de65959
JA
2877 .name = "rate_process",
2878 .lname = "Rate Process",
2879 .type = FIO_OPT_STR,
2880 .off1 = td_var_offset(rate_process),
2881 .help = "What process controls how rated IO is managed",
2882 .def = "linear",
ff6bb260
SL
2883 .category = FIO_OPT_C_IO,
2884 .group = FIO_OPT_G_RATE,
6de65959
JA
2885 .posval = {
2886 { .ival = "linear",
2887 .oval = RATE_PROCESS_LINEAR,
2888 .help = "Linear rate of IO",
2889 },
2890 {
2891 .ival = "poisson",
2892 .oval = RATE_PROCESS_POISSON,
2893 .help = "Rate follows Poisson process",
2894 },
2895 },
2896 .parent = "rate",
ff6bb260 2897 },
214e1eca 2898 {
6d428bcd
JA
2899 .name = "rate_cycle",
2900 .alias = "ratecycle",
e8b0e958 2901 .lname = "I/O rate cycle",
214e1eca
JA
2902 .type = FIO_OPT_INT,
2903 .off1 = td_var_offset(ratecycle),
2904 .help = "Window average for rate limits (msec)",
2905 .def = "1000",
afdf9352 2906 .parent = "rate",
d71c154c 2907 .hide = 1,
e8b0e958
JA
2908 .category = FIO_OPT_C_IO,
2909 .group = FIO_OPT_G_RATE,
214e1eca 2910 },
15501535
JA
2911 {
2912 .name = "max_latency",
2913 .type = FIO_OPT_INT,
2914 .off1 = td_var_offset(max_latency),
2915 .help = "Maximum tolerated IO latency (usec)",
88038bc7 2916 .is_time = 1,
1e5324e7 2917 .category = FIO_OPT_C_IO,
3e260a46
JA
2918 .group = FIO_OPT_G_LATPROF,
2919 },
2920 {
2921 .name = "latency_target",
2922 .lname = "Latency Target (usec)",
2923 .type = FIO_OPT_STR_VAL_TIME,
2924 .off1 = td_var_offset(latency_target),
2925 .help = "Ramp to max queue depth supporting this latency",
88038bc7 2926 .is_time = 1,
3e260a46
JA
2927 .category = FIO_OPT_C_IO,
2928 .group = FIO_OPT_G_LATPROF,
2929 },
2930 {
2931 .name = "latency_window",
2932 .lname = "Latency Window (usec)",
2933 .type = FIO_OPT_STR_VAL_TIME,
2934 .off1 = td_var_offset(latency_window),
2935 .help = "Time to sustain latency_target",
88038bc7 2936 .is_time = 1,
3e260a46
JA
2937 .category = FIO_OPT_C_IO,
2938 .group = FIO_OPT_G_LATPROF,
2939 },
2940 {
2941 .name = "latency_percentile",
2942 .lname = "Latency Percentile",
2943 .type = FIO_OPT_FLOAT_LIST,
2944 .off1 = td_var_offset(latency_percentile),
2945 .help = "Percentile of IOs must be below latency_target",
2946 .def = "100",
2947 .maxlen = 1,
2948 .minfp = 0.0,
2949 .maxfp = 100.0,
2950 .category = FIO_OPT_C_IO,
2951 .group = FIO_OPT_G_LATPROF,
15501535 2952 },
214e1eca
JA
2953 {
2954 .name = "invalidate",
e8b0e958 2955 .lname = "Cache invalidate",
214e1eca
JA
2956 .type = FIO_OPT_BOOL,
2957 .off1 = td_var_offset(invalidate_cache),
2958 .help = "Invalidate buffer/page cache prior to running job",
2959 .def = "1",
e8b0e958 2960 .category = FIO_OPT_C_IO,
3ceb458f 2961 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2962 },
2963 {
2964 .name = "sync",
e8b0e958 2965 .lname = "Synchronous I/O",
214e1eca
JA
2966 .type = FIO_OPT_BOOL,
2967 .off1 = td_var_offset(sync_io),
2968 .help = "Use O_SYNC for buffered writes",
2969 .def = "0",
67a1000f 2970 .parent = "buffered",
d71c154c 2971 .hide = 1,
e8b0e958 2972 .category = FIO_OPT_C_IO,
3ceb458f 2973 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2974 },
214e1eca
JA
2975 {
2976 .name = "create_serialize",
e8b0e958 2977 .lname = "Create serialize",
214e1eca
JA
2978 .type = FIO_OPT_BOOL,
2979 .off1 = td_var_offset(create_serialize),
2980 .help = "Serialize creating of job files",
2981 .def = "1",
e8b0e958
JA
2982 .category = FIO_OPT_C_FILE,
2983 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2984 },
2985 {
2986 .name = "create_fsync",
e8b0e958 2987 .lname = "Create fsync",
214e1eca
JA
2988 .type = FIO_OPT_BOOL,
2989 .off1 = td_var_offset(create_fsync),
03e20d68 2990 .help = "fsync file after creation",
214e1eca 2991 .def = "1",
e8b0e958
JA
2992 .category = FIO_OPT_C_FILE,
2993 .group = FIO_OPT_G_INVALID,
214e1eca 2994 },
814452bd
JA
2995 {
2996 .name = "create_on_open",
e8b0e958 2997 .lname = "Create on open",
814452bd
JA
2998 .type = FIO_OPT_BOOL,
2999 .off1 = td_var_offset(create_on_open),
3000 .help = "Create files when they are opened for IO",
3001 .def = "0",
e8b0e958
JA
3002 .category = FIO_OPT_C_FILE,
3003 .group = FIO_OPT_G_INVALID,
814452bd 3004 },
25460cf6
JA
3005 {
3006 .name = "create_only",
3007 .type = FIO_OPT_BOOL,
3008 .off1 = td_var_offset(create_only),
3009 .help = "Only perform file creation phase",
d17fda71 3010 .category = FIO_OPT_C_FILE,
25460cf6
JA
3011 .def = "0",
3012 },
2378826d
JA
3013 {
3014 .name = "allow_file_create",
e81ecca3 3015 .lname = "Allow file create",
2378826d
JA
3016 .type = FIO_OPT_BOOL,
3017 .off1 = td_var_offset(allow_create),
3018 .help = "Permit fio to create files, if they don't exist",
3019 .def = "1",
3020 .category = FIO_OPT_C_FILE,
3021 .group = FIO_OPT_G_FILENAME,
3022 },
e81ecca3
JA
3023 {
3024 .name = "allow_mounted_write",
3025 .lname = "Allow mounted write",
3026 .type = FIO_OPT_BOOL,
3027 .off1 = td_var_offset(allow_mounted_write),
3028 .help = "Allow writes to a mounted partition",
3029 .def = "0",
3030 .category = FIO_OPT_C_FILE,
3031 .group = FIO_OPT_G_FILENAME,
3032 },
0b9d69ec 3033 {
afad68f7 3034 .name = "pre_read",
e8b0e958 3035 .lname = "Pre-read files",
afad68f7
ZY
3036 .type = FIO_OPT_BOOL,
3037 .off1 = td_var_offset(pre_read),
03e20d68 3038 .help = "Pre-read files before starting official testing",
afad68f7 3039 .def = "0",
e8b0e958
JA
3040 .category = FIO_OPT_C_FILE,
3041 .group = FIO_OPT_G_INVALID,
afad68f7 3042 },
214e1eca
JA
3043#ifdef FIO_HAVE_CPU_AFFINITY
3044 {
3045 .name = "cpumask",
e8b0e958 3046 .lname = "CPU mask",
214e1eca
JA
3047 .type = FIO_OPT_INT,
3048 .cb = str_cpumask_cb,
a8523a6a 3049 .off1 = td_var_offset(cpumask),
214e1eca 3050 .help = "CPU affinity mask",
e8b0e958 3051 .category = FIO_OPT_C_GENERAL,
10860056 3052 .group = FIO_OPT_G_CRED,
214e1eca 3053 },
d2e268b0
JA
3054 {
3055 .name = "cpus_allowed",
e8b0e958 3056 .lname = "CPUs allowed",
d2e268b0
JA
3057 .type = FIO_OPT_STR,
3058 .cb = str_cpus_allowed_cb,
a8523a6a 3059 .off1 = td_var_offset(cpumask),
d2e268b0 3060 .help = "Set CPUs allowed",
e8b0e958 3061 .category = FIO_OPT_C_GENERAL,
10860056 3062 .group = FIO_OPT_G_CRED,
d2e268b0 3063 },
c2acfbac
JA
3064 {
3065 .name = "cpus_allowed_policy",
3066 .lname = "CPUs allowed distribution policy",
3067 .type = FIO_OPT_STR,
3068 .off1 = td_var_offset(cpus_allowed_policy),
3069 .help = "Distribution policy for cpus_allowed",
3070 .parent = "cpus_allowed",
3071 .prio = 1,
3072 .posval = {
3073 { .ival = "shared",
3074 .oval = FIO_CPUS_SHARED,
3075 .help = "Mask shared between threads",
3076 },
3077 { .ival = "split",
3078 .oval = FIO_CPUS_SPLIT,
3079 .help = "Mask split between threads",
3080 },
3081 },
3082 .category = FIO_OPT_C_GENERAL,
3083 .group = FIO_OPT_G_CRED,
3084 },
d0b937ed 3085#endif
67bf9823 3086#ifdef CONFIG_LIBNUMA
d0b937ed
YR
3087 {
3088 .name = "numa_cpu_nodes",
3089 .type = FIO_OPT_STR,
3090 .cb = str_numa_cpunodes_cb,
b2a9e649 3091 .off1 = td_var_offset(numa_cpunodes),
d0b937ed 3092 .help = "NUMA CPU nodes bind",
6be54b2d
JA
3093 .category = FIO_OPT_C_GENERAL,
3094 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
3095 },
3096 {
3097 .name = "numa_mem_policy",
3098 .type = FIO_OPT_STR,
3099 .cb = str_numa_mpol_cb,
b2a9e649 3100 .off1 = td_var_offset(numa_memnodes),
d0b937ed 3101 .help = "NUMA memory policy setup",
6be54b2d
JA
3102 .category = FIO_OPT_C_GENERAL,
3103 .group = FIO_OPT_G_INVALID,
d0b937ed 3104 },
214e1eca
JA
3105#endif
3106 {
3107 .name = "end_fsync",
e8b0e958 3108 .lname = "End fsync",
214e1eca
JA
3109 .type = FIO_OPT_BOOL,
3110 .off1 = td_var_offset(end_fsync),
3111 .help = "Include fsync at the end of job",
3112 .def = "0",
e8b0e958
JA
3113 .category = FIO_OPT_C_FILE,
3114 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3115 },
3116 {
3117 .name = "fsync_on_close",
e8b0e958 3118 .lname = "Fsync on close",
214e1eca
JA
3119 .type = FIO_OPT_BOOL,
3120 .off1 = td_var_offset(fsync_on_close),
3121 .help = "fsync files on close",
3122 .def = "0",
e8b0e958
JA
3123 .category = FIO_OPT_C_FILE,
3124 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3125 },
3126 {
3127 .name = "unlink",
e8b0e958 3128 .lname = "Unlink file",
214e1eca
JA
3129 .type = FIO_OPT_BOOL,
3130 .off1 = td_var_offset(unlink),
3131 .help = "Unlink created files after job has completed",
3132 .def = "0",
e8b0e958
JA
3133 .category = FIO_OPT_C_FILE,
3134 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3135 },
3136 {
3137 .name = "exitall",
e8b0e958 3138 .lname = "Exit-all on terminate",
214e1eca
JA
3139 .type = FIO_OPT_STR_SET,
3140 .cb = str_exitall_cb,
3141 .help = "Terminate all jobs when one exits",
e8b0e958 3142 .category = FIO_OPT_C_GENERAL,
a1f6afec 3143 .group = FIO_OPT_G_PROCESS,
214e1eca 3144 },
f9cafb12
JA
3145 {
3146 .name = "exitall_on_error",
3147 .lname = "Exit-all on terminate in error",
3148 .type = FIO_OPT_BOOL,
3149 .off1 = td_var_offset(unlink),
3150 .help = "Terminate all jobs when one exits in error",
3151 .category = FIO_OPT_C_GENERAL,
3152 .group = FIO_OPT_G_PROCESS,
3153 },
214e1eca
JA
3154 {
3155 .name = "stonewall",
e8b0e958 3156 .lname = "Wait for previous",
d392365e 3157 .alias = "wait_for_previous",
214e1eca
JA
3158 .type = FIO_OPT_STR_SET,
3159 .off1 = td_var_offset(stonewall),
3160 .help = "Insert a hard barrier between this job and previous",
e8b0e958 3161 .category = FIO_OPT_C_GENERAL,
a1f6afec 3162 .group = FIO_OPT_G_PROCESS,
214e1eca 3163 },
b3d62a75
JA
3164 {
3165 .name = "new_group",
e8b0e958 3166 .lname = "New group",
b3d62a75
JA
3167 .type = FIO_OPT_STR_SET,
3168 .off1 = td_var_offset(new_group),
3169 .help = "Mark the start of a new group (for reporting)",
e8b0e958 3170 .category = FIO_OPT_C_GENERAL,
a1f6afec 3171 .group = FIO_OPT_G_PROCESS,
b3d62a75 3172 },
214e1eca
JA
3173 {
3174 .name = "thread",
e8b0e958 3175 .lname = "Thread",
214e1eca
JA
3176 .type = FIO_OPT_STR_SET,
3177 .off1 = td_var_offset(use_thread),
20eb06bd 3178 .help = "Use threads instead of processes",
c8931876
JA
3179#ifdef CONFIG_NO_SHM
3180 .def = "1",
3181 .no_warn_def = 1,
3182#endif
e8b0e958 3183 .category = FIO_OPT_C_GENERAL,
a1f6afec 3184 .group = FIO_OPT_G_PROCESS,
214e1eca 3185 },
3a5db920
JA
3186 {
3187 .name = "per_job_logs",
3188 .type = FIO_OPT_BOOL,
3189 .off1 = td_var_offset(per_job_logs),
3190 .help = "Include job number in generated log files or not",
3191 .def = "1",
3192 .category = FIO_OPT_C_LOG,
3193 .group = FIO_OPT_G_INVALID,
3194 },
214e1eca
JA
3195 {
3196 .name = "write_bw_log",
e8b0e958 3197 .lname = "Write bandwidth log",
203160d5
JA
3198 .type = FIO_OPT_STR_STORE,
3199 .off1 = td_var_offset(bw_log_file),
214e1eca 3200 .help = "Write log of bandwidth during run",
e8b0e958
JA
3201 .category = FIO_OPT_C_LOG,
3202 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3203 },
3204 {
3205 .name = "write_lat_log",
e8b0e958 3206 .lname = "Write latency log",
203160d5
JA
3207 .type = FIO_OPT_STR_STORE,
3208 .off1 = td_var_offset(lat_log_file),
214e1eca 3209 .help = "Write log of latency during run",
e8b0e958
JA
3210 .category = FIO_OPT_C_LOG,
3211 .group = FIO_OPT_G_INVALID,
214e1eca 3212 },
c8eeb9df
JA
3213 {
3214 .name = "write_iops_log",
e8b0e958 3215 .lname = "Write IOPS log",
577c83bd 3216 .type = FIO_OPT_STR_STORE,
203160d5 3217 .off1 = td_var_offset(iops_log_file),
c8eeb9df 3218 .help = "Write log of IOPS during run",
e8b0e958
JA
3219 .category = FIO_OPT_C_LOG,
3220 .group = FIO_OPT_G_INVALID,
c8eeb9df 3221 },
b8bc8cba
JA
3222 {
3223 .name = "log_avg_msec",
e8b0e958 3224 .lname = "Log averaging (msec)",
b8bc8cba
JA
3225 .type = FIO_OPT_INT,
3226 .off1 = td_var_offset(log_avg_msec),
3227 .help = "Average bw/iops/lat logs over this period of time",
3228 .def = "0",
e8b0e958
JA
3229 .category = FIO_OPT_C_LOG,
3230 .group = FIO_OPT_G_INVALID,
b8bc8cba 3231 },
ae588852
JA
3232 {
3233 .name = "log_offset",
3234 .lname = "Log offset of IO",
3235 .type = FIO_OPT_BOOL,
3236 .off1 = td_var_offset(log_offset),
3237 .help = "Include offset of IO for each log entry",
3238 .def = "0",
3239 .category = FIO_OPT_C_LOG,
3240 .group = FIO_OPT_G_INVALID,
3241 },
aee2ab67
JA
3242#ifdef CONFIG_ZLIB
3243 {
3244 .name = "log_compression",
3245 .lname = "Log compression",
3246 .type = FIO_OPT_INT,
3247 .off1 = td_var_offset(log_gz),
3248 .help = "Log in compressed chunks of this size",
9919b27b 3249 .minval = 1024ULL,
aee2ab67
JA
3250 .maxval = 512 * 1024 * 1024ULL,
3251 .category = FIO_OPT_C_LOG,
3252 .group = FIO_OPT_G_INVALID,
3253 },
c08f9fe2
JA
3254#ifdef FIO_HAVE_CPU_AFFINITY
3255 {
3256 .name = "log_compression_cpus",
3257 .lname = "Log Compression CPUs",
3258 .type = FIO_OPT_STR,
3259 .cb = str_log_cpus_allowed_cb,
3260 .off1 = td_var_offset(log_gz_cpumask),
3261 .parent = "log_compression",
3262 .help = "Limit log compression to these CPUs",
3263 .category = FIO_OPT_C_LOG,
3264 .group = FIO_OPT_G_INVALID,
3265 },
3266#endif
b26317c9
JA
3267 {
3268 .name = "log_store_compressed",
3269 .lname = "Log store compressed",
3270 .type = FIO_OPT_BOOL,
3271 .off1 = td_var_offset(log_gz_store),
3272 .help = "Store logs in a compressed format",
3273 .category = FIO_OPT_C_LOG,
3274 .group = FIO_OPT_G_INVALID,
3275 },
aee2ab67 3276#endif
66347cfa
DE
3277 {
3278 .name = "block_error_percentiles",
3279 .lname = "Block error percentiles",
3280 .type = FIO_OPT_BOOL,
3281 .off1 = td_var_offset(block_error_hist),
3282 .help = "Record trim block errors and make a histogram",
3283 .def = "0",
3284 .category = FIO_OPT_C_LOG,
3285 .group = FIO_OPT_G_INVALID,
3286 },
c504ee55
JA
3287 {
3288 .name = "bwavgtime",
3289 .lname = "Bandwidth average time",
3290 .type = FIO_OPT_INT,
3291 .off1 = td_var_offset(bw_avg_time),
3292 .help = "Time window over which to calculate bandwidth"
3293 " (msec)",
3294 .def = "500",
3295 .parent = "write_bw_log",
3296 .hide = 1,
3297 .interval = 100,
3298 .category = FIO_OPT_C_LOG,
3299 .group = FIO_OPT_G_INVALID,
3300 },
3301 {
3302 .name = "iopsavgtime",
3303 .lname = "IOPS average time",
3304 .type = FIO_OPT_INT,
3305 .off1 = td_var_offset(iops_avg_time),
3306 .help = "Time window over which to calculate IOPS (msec)",
3307 .def = "500",
3308 .parent = "write_iops_log",
3309 .hide = 1,
3310 .interval = 100,
3311 .category = FIO_OPT_C_LOG,
3312 .group = FIO_OPT_G_INVALID,
3313 },
214e1eca
JA
3314 {
3315 .name = "group_reporting",
e8b0e958 3316 .lname = "Group reporting",
d2507043 3317 .type = FIO_OPT_STR_SET,
214e1eca
JA
3318 .off1 = td_var_offset(group_reporting),
3319 .help = "Do reporting on a per-group basis",
10860056 3320 .category = FIO_OPT_C_STAT,
e8b0e958 3321 .group = FIO_OPT_G_INVALID,
214e1eca 3322 },
e9459e5a
JA
3323 {
3324 .name = "zero_buffers",
e8b0e958 3325 .lname = "Zero I/O buffers",
e9459e5a
JA
3326 .type = FIO_OPT_STR_SET,
3327 .off1 = td_var_offset(zero_buffers),
3328 .help = "Init IO buffers to all zeroes",
e8b0e958 3329 .category = FIO_OPT_C_IO,
3ceb458f 3330 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3331 },
5973cafb
JA
3332 {
3333 .name = "refill_buffers",
e8b0e958 3334 .lname = "Refill I/O buffers",
5973cafb
JA
3335 .type = FIO_OPT_STR_SET,
3336 .off1 = td_var_offset(refill_buffers),
3337 .help = "Refill IO buffers on every IO submit",
e8b0e958 3338 .category = FIO_OPT_C_IO,
3ceb458f 3339 .group = FIO_OPT_G_IO_BUF,
5973cafb 3340 },
fd68418e
JA
3341 {
3342 .name = "scramble_buffers",
e8b0e958 3343 .lname = "Scramble I/O buffers",
fd68418e
JA
3344 .type = FIO_OPT_BOOL,
3345 .off1 = td_var_offset(scramble_buffers),
3346 .help = "Slightly scramble buffers on every IO submit",
3347 .def = "1",
e8b0e958 3348 .category = FIO_OPT_C_IO,
3ceb458f 3349 .group = FIO_OPT_G_IO_BUF,
fd68418e 3350 },
ce35b1ec
JA
3351 {
3352 .name = "buffer_pattern",
3353 .lname = "Buffer pattern",
3354 .type = FIO_OPT_STR,
3355 .cb = str_buffer_pattern_cb,
a8523a6a 3356 .off1 = td_var_offset(buffer_pattern),
ce35b1ec
JA
3357 .help = "Fill pattern for IO buffers",
3358 .category = FIO_OPT_C_IO,
3359 .group = FIO_OPT_G_IO_BUF,
3360 },
9c42684e
JA
3361 {
3362 .name = "buffer_compress_percentage",
e8b0e958 3363 .lname = "Buffer compression percentage",
9c42684e 3364 .type = FIO_OPT_INT,
bedc9dc2 3365 .cb = str_buffer_compress_cb,
a8523a6a 3366 .off1 = td_var_offset(compress_percentage),
9c42684e 3367 .maxval = 100,
e7f5de90 3368 .minval = 0,
9c42684e 3369 .help = "How compressible the buffer is (approximately)",
20eb06bd 3370 .interval = 5,
e8b0e958 3371 .category = FIO_OPT_C_IO,
3ceb458f 3372 .group = FIO_OPT_G_IO_BUF,
9c42684e 3373 },
f97a43a1
JA
3374 {
3375 .name = "buffer_compress_chunk",
e8b0e958 3376 .lname = "Buffer compression chunk size",
f97a43a1
JA
3377 .type = FIO_OPT_INT,
3378 .off1 = td_var_offset(compress_chunk),
207b18e4 3379 .parent = "buffer_compress_percentage",
d71c154c 3380 .hide = 1,
f97a43a1 3381 .help = "Size of compressible region in buffer",
20eb06bd 3382 .interval = 256,
e8b0e958 3383 .category = FIO_OPT_C_IO,
3ceb458f 3384 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3385 },
5c94b008
JA
3386 {
3387 .name = "dedupe_percentage",
3388 .lname = "Dedupe percentage",
3389 .type = FIO_OPT_INT,
3390 .cb = str_dedupe_cb,
a8523a6a 3391 .off1 = td_var_offset(dedupe_percentage),
5c94b008
JA
3392 .maxval = 100,
3393 .minval = 0,
3394 .help = "Percentage of buffers that are dedupable",
3395 .interval = 1,
3396 .category = FIO_OPT_C_IO,
3397 .group = FIO_OPT_G_IO_BUF,
3398 },
83349190
YH
3399 {
3400 .name = "clat_percentiles",
e8b0e958 3401 .lname = "Completion latency percentiles",
83349190
YH
3402 .type = FIO_OPT_BOOL,
3403 .off1 = td_var_offset(clat_percentiles),
3404 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3405 .def = "1",
e8b0e958
JA
3406 .category = FIO_OPT_C_STAT,
3407 .group = FIO_OPT_G_INVALID,
83349190
YH
3408 },
3409 {
3410 .name = "percentile_list",
66347cfa 3411 .lname = "Percentile list",
83349190
YH
3412 .type = FIO_OPT_FLOAT_LIST,
3413 .off1 = td_var_offset(percentile_list),
435d195a 3414 .off2 = td_var_offset(percentile_precision),
66347cfa
DE
3415 .help = "Specify a custom list of percentiles to report for "
3416 "completion latency and block errors",
fd112d34 3417 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3418 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3419 .minfp = 0.0,
3420 .maxfp = 100.0,
e8b0e958
JA
3421 .category = FIO_OPT_C_STAT,
3422 .group = FIO_OPT_G_INVALID,
83349190
YH
3423 },
3424
0a839f30
JA
3425#ifdef FIO_HAVE_DISK_UTIL
3426 {
3427 .name = "disk_util",
e8b0e958 3428 .lname = "Disk utilization",
0a839f30
JA
3429 .type = FIO_OPT_BOOL,
3430 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3431 .help = "Log disk utilization statistics",
0a839f30 3432 .def = "1",
e8b0e958
JA
3433 .category = FIO_OPT_C_STAT,
3434 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3435 },
3436#endif
993bf48b
JA
3437 {
3438 .name = "gtod_reduce",
e8b0e958 3439 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3440 .type = FIO_OPT_BOOL,
3441 .help = "Greatly reduce number of gettimeofday() calls",
3442 .cb = str_gtod_reduce_cb,
3443 .def = "0",
a4ed77fe 3444 .hide_on_set = 1,
e8b0e958
JA
3445 .category = FIO_OPT_C_STAT,
3446 .group = FIO_OPT_G_INVALID,
993bf48b 3447 },
02af0988
JA
3448 {
3449 .name = "disable_lat",
e8b0e958 3450 .lname = "Disable all latency stats",
02af0988
JA
3451 .type = FIO_OPT_BOOL,
3452 .off1 = td_var_offset(disable_lat),
3453 .help = "Disable latency numbers",
3454 .parent = "gtod_reduce",
d71c154c 3455 .hide = 1,
02af0988 3456 .def = "0",
e8b0e958
JA
3457 .category = FIO_OPT_C_STAT,
3458 .group = FIO_OPT_G_INVALID,
02af0988 3459 },
9520ebb9
JA
3460 {
3461 .name = "disable_clat",
e8b0e958 3462 .lname = "Disable completion latency stats",
9520ebb9
JA
3463 .type = FIO_OPT_BOOL,
3464 .off1 = td_var_offset(disable_clat),
3465 .help = "Disable completion latency numbers",
993bf48b 3466 .parent = "gtod_reduce",
d71c154c 3467 .hide = 1,
9520ebb9 3468 .def = "0",
e8b0e958
JA
3469 .category = FIO_OPT_C_STAT,
3470 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3471 },
3472 {
3473 .name = "disable_slat",
e8b0e958 3474 .lname = "Disable submission latency stats",
9520ebb9
JA
3475 .type = FIO_OPT_BOOL,
3476 .off1 = td_var_offset(disable_slat),
03e20d68 3477 .help = "Disable submission latency numbers",
993bf48b 3478 .parent = "gtod_reduce",
d71c154c 3479 .hide = 1,
9520ebb9 3480 .def = "0",
e8b0e958
JA
3481 .category = FIO_OPT_C_STAT,
3482 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3483 },
3484 {
3485 .name = "disable_bw_measurement",
e8b0e958 3486 .lname = "Disable bandwidth stats",
9520ebb9
JA
3487 .type = FIO_OPT_BOOL,
3488 .off1 = td_var_offset(disable_bw),
3489 .help = "Disable bandwidth logging",
993bf48b 3490 .parent = "gtod_reduce",
d71c154c 3491 .hide = 1,
9520ebb9 3492 .def = "0",
e8b0e958
JA
3493 .category = FIO_OPT_C_STAT,
3494 .group = FIO_OPT_G_INVALID,
9520ebb9 3495 },
be4ecfdf
JA
3496 {
3497 .name = "gtod_cpu",
e8b0e958 3498 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf 3499 .type = FIO_OPT_INT,
79c896a1 3500 .off1 = td_var_offset(gtod_cpu),
03e20d68 3501 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3502 .verify = gtod_cpu_verify,
e8b0e958 3503 .category = FIO_OPT_C_GENERAL,
10860056 3504 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3505 },
771e58be
JA
3506 {
3507 .name = "unified_rw_reporting",
3508 .type = FIO_OPT_BOOL,
3509 .off1 = td_var_offset(unified_rw_rep),
3510 .help = "Unify reporting across data direction",
3511 .def = "0",
90b7a96d
JA
3512 .category = FIO_OPT_C_GENERAL,
3513 .group = FIO_OPT_G_INVALID,
771e58be 3514 },
f2bba182
RR
3515 {
3516 .name = "continue_on_error",
e8b0e958 3517 .lname = "Continue on error",
06842027 3518 .type = FIO_OPT_STR,
f2bba182 3519 .off1 = td_var_offset(continue_on_error),
03e20d68 3520 .help = "Continue on non-fatal errors during IO",
06842027 3521 .def = "none",
e8b0e958 3522 .category = FIO_OPT_C_GENERAL,
bc3f552f 3523 .group = FIO_OPT_G_ERR,
06842027
SL
3524 .posval = {
3525 { .ival = "none",
3526 .oval = ERROR_TYPE_NONE,
3527 .help = "Exit when an error is encountered",
3528 },
3529 { .ival = "read",
3530 .oval = ERROR_TYPE_READ,
3531 .help = "Continue on read errors only",
3532 },
3533 { .ival = "write",
3534 .oval = ERROR_TYPE_WRITE,
3535 .help = "Continue on write errors only",
3536 },
3537 { .ival = "io",
3538 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3539 .help = "Continue on any IO errors",
3540 },
3541 { .ival = "verify",
3542 .oval = ERROR_TYPE_VERIFY,
3543 .help = "Continue on verify errors only",
3544 },
3545 { .ival = "all",
3546 .oval = ERROR_TYPE_ANY,
3547 .help = "Continue on all io and verify errors",
3548 },
3549 { .ival = "0",
3550 .oval = ERROR_TYPE_NONE,
3551 .help = "Alias for 'none'",
3552 },
3553 { .ival = "1",
3554 .oval = ERROR_TYPE_ANY,
3555 .help = "Alias for 'all'",
3556 },
3557 },
f2bba182 3558 },
8b28bd41
DM
3559 {
3560 .name = "ignore_error",
3561 .type = FIO_OPT_STR,
3562 .cb = str_ignore_error_cb,
a8523a6a 3563 .off1 = td_var_offset(ignore_error_nr),
8b28bd41
DM
3564 .help = "Set a specific list of errors to ignore",
3565 .parent = "rw",
a94eb99a 3566 .category = FIO_OPT_C_GENERAL,
bc3f552f 3567 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3568 },
3569 {
3570 .name = "error_dump",
3571 .type = FIO_OPT_BOOL,
3572 .off1 = td_var_offset(error_dump),
3573 .def = "0",
3574 .help = "Dump info on each error",
a94eb99a 3575 .category = FIO_OPT_C_GENERAL,
bc3f552f 3576 .group = FIO_OPT_G_ERR,
8b28bd41 3577 },
9ac8a797
JA
3578 {
3579 .name = "profile",
e8b0e958 3580 .lname = "Profile",
79d16311 3581 .type = FIO_OPT_STR_STORE,
9ac8a797 3582 .off1 = td_var_offset(profile),
9ac8a797 3583 .help = "Select a specific builtin performance test",
13fca827 3584 .category = FIO_OPT_C_PROFILE,
e8b0e958 3585 .group = FIO_OPT_G_INVALID,
9ac8a797 3586 },
a696fa2a
JA
3587 {
3588 .name = "cgroup",
e8b0e958 3589 .lname = "Cgroup",
a696fa2a
JA
3590 .type = FIO_OPT_STR_STORE,
3591 .off1 = td_var_offset(cgroup),
3592 .help = "Add job to cgroup of this name",
e8b0e958 3593 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3594 .group = FIO_OPT_G_CGROUP,
3595 },
3596 {
3597 .name = "cgroup_nodelete",
3598 .lname = "Cgroup no-delete",
3599 .type = FIO_OPT_BOOL,
3600 .off1 = td_var_offset(cgroup_nodelete),
3601 .help = "Do not delete cgroups after job completion",
3602 .def = "0",
3603 .parent = "cgroup",
3604 .category = FIO_OPT_C_GENERAL,
3605 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3606 },
3607 {
3608 .name = "cgroup_weight",
e8b0e958 3609 .lname = "Cgroup weight",
a696fa2a
JA
3610 .type = FIO_OPT_INT,
3611 .off1 = td_var_offset(cgroup_weight),
3612 .help = "Use given weight for cgroup",
3613 .minval = 100,
3614 .maxval = 1000,
a1f6afec 3615 .parent = "cgroup",
e8b0e958 3616 .category = FIO_OPT_C_GENERAL,
a1f6afec 3617 .group = FIO_OPT_G_CGROUP,
7de87099 3618 },
e0b0d892
JA
3619 {
3620 .name = "uid",
e8b0e958 3621 .lname = "User ID",
e0b0d892
JA
3622 .type = FIO_OPT_INT,
3623 .off1 = td_var_offset(uid),
3624 .help = "Run job with this user ID",
e8b0e958 3625 .category = FIO_OPT_C_GENERAL,
10860056 3626 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3627 },
3628 {
3629 .name = "gid",
e8b0e958 3630 .lname = "Group ID",
e0b0d892
JA
3631 .type = FIO_OPT_INT,
3632 .off1 = td_var_offset(gid),
3633 .help = "Run job with this group ID",
e8b0e958 3634 .category = FIO_OPT_C_GENERAL,
10860056 3635 .group = FIO_OPT_G_CRED,
e0b0d892 3636 },
a1f6afec
JA
3637 {
3638 .name = "kb_base",
3639 .lname = "KB Base",
3640 .type = FIO_OPT_INT,
3641 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3642 .prio = 1,
3643 .def = "1024",
ba9c7219
JA
3644 .posval = {
3645 { .ival = "1024",
3646 .oval = 1024,
3647 .help = "Use 1024 as the K base",
3648 },
3649 { .ival = "1000",
3650 .oval = 1000,
3651 .help = "Use 1000 as the K base",
3652 },
3653 },
a1f6afec
JA
3654 .help = "How many bytes per KB for reporting (1000 or 1024)",
3655 .category = FIO_OPT_C_GENERAL,
3656 .group = FIO_OPT_G_INVALID,
3657 },
cf3a0518
JA
3658 {
3659 .name = "unit_base",
ba9c7219 3660 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3661 .type = FIO_OPT_INT,
3662 .off1 = td_var_offset(unit_base),
cf3a0518 3663 .prio = 1,
71a08258
JA
3664 .posval = {
3665 { .ival = "0",
3666 .oval = 0,
3667 .help = "Auto-detect",
3668 },
3669 { .ival = "8",
3670 .oval = 8,
3671 .help = "Normal (byte based)",
3672 },
3673 { .ival = "1",
3674 .oval = 1,
3675 .help = "Bit based",
3676 },
3677 },
cf3a0518
JA
3678 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3679 .category = FIO_OPT_C_GENERAL,
3680 .group = FIO_OPT_G_INVALID,
3681 },
3ceb458f
JA
3682 {
3683 .name = "hugepage-size",
3684 .lname = "Hugepage size",
3685 .type = FIO_OPT_INT,
3686 .off1 = td_var_offset(hugepage_size),
3687 .help = "When using hugepages, specify size of each page",
3688 .def = __fio_stringify(FIO_HUGE_PAGE),
3689 .interval = 1024 * 1024,
3690 .category = FIO_OPT_C_GENERAL,
3691 .group = FIO_OPT_G_INVALID,
3692 },
9e684a49
DE
3693 {
3694 .name = "flow_id",
e8b0e958 3695 .lname = "I/O flow ID",
9e684a49
DE
3696 .type = FIO_OPT_INT,
3697 .off1 = td_var_offset(flow_id),
3698 .help = "The flow index ID to use",
3699 .def = "0",
e8b0e958
JA
3700 .category = FIO_OPT_C_IO,
3701 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3702 },
3703 {
3704 .name = "flow",
e8b0e958 3705 .lname = "I/O flow weight",
9e684a49
DE
3706 .type = FIO_OPT_INT,
3707 .off1 = td_var_offset(flow),
3708 .help = "Weight for flow control of this job",
3709 .parent = "flow_id",
d71c154c 3710 .hide = 1,
9e684a49 3711 .def = "0",
e8b0e958
JA
3712 .category = FIO_OPT_C_IO,
3713 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3714 },
3715 {
3716 .name = "flow_watermark",
e8b0e958 3717 .lname = "I/O flow watermark",
9e684a49
DE
3718 .type = FIO_OPT_INT,
3719 .off1 = td_var_offset(flow_watermark),
3720 .help = "High watermark for flow control. This option"
3721 " should be set to the same value for all threads"
3722 " with non-zero flow.",
3723 .parent = "flow_id",
d71c154c 3724 .hide = 1,
9e684a49 3725 .def = "1024",
e8b0e958
JA
3726 .category = FIO_OPT_C_IO,
3727 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3728 },
3729 {
3730 .name = "flow_sleep",
e8b0e958 3731 .lname = "I/O flow sleep",
9e684a49
DE
3732 .type = FIO_OPT_INT,
3733 .off1 = td_var_offset(flow_sleep),
3734 .help = "How many microseconds to sleep after being held"
3735 " back by the flow control mechanism",
3736 .parent = "flow_id",
d71c154c 3737 .hide = 1,
9e684a49 3738 .def = "0",
e8b0e958
JA
3739 .category = FIO_OPT_C_IO,
3740 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3741 },
65fa28ca
DE
3742 {
3743 .name = "skip_bad",
3744 .lname = "Skip operations against bad blocks",
3745 .type = FIO_OPT_BOOL,
3746 .off1 = td_var_offset(skip_bad),
3747 .help = "Skip operations against known bad blocks.",
3748 .hide = 1,
3749 .def = "0",
3750 .category = FIO_OPT_C_IO,
3751 .group = FIO_OPT_G_MTD,
3752 },
214e1eca
JA
3753 {
3754 .name = NULL,
3755 },
3756};
3757
17af15d4 3758static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3759 const char *name, int val)
9f81736c 3760{
17af15d4 3761 lopt->name = (char *) name;
de890a1e 3762 lopt->val = val;
9f81736c 3763 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3764 lopt->has_arg = optional_argument;
9f81736c
JA
3765 else
3766 lopt->has_arg = required_argument;
3767}
3768
de890a1e
SL
3769static void options_to_lopts(struct fio_option *opts,
3770 struct option *long_options,
3771 int i, int option_type)
214e1eca 3772{
de890a1e 3773 struct fio_option *o = &opts[0];
214e1eca 3774 while (o->name) {
de890a1e 3775 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3776 if (o->alias) {
3777 i++;
de890a1e 3778 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3779 }
214e1eca
JA
3780
3781 i++;
3782 o++;
3783 assert(i < FIO_NR_OPTIONS);
3784 }
3785}
3786
de890a1e
SL
3787void fio_options_set_ioengine_opts(struct option *long_options,
3788 struct thread_data *td)
3789{
3790 unsigned int i;
3791
3792 i = 0;
3793 while (long_options[i].name) {
3794 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3795 memset(&long_options[i], 0, sizeof(*long_options));
3796 break;
3797 }
3798 i++;
3799 }
3800
3801 /*
3802 * Just clear out the prior ioengine options.
3803 */
3804 if (!td || !td->eo)
3805 return;
3806
3807 options_to_lopts(td->io_ops->options, long_options, i,
3808 FIO_GETOPT_IOENGINE);
3809}
3810
3811void fio_options_dup_and_init(struct option *long_options)
3812{
3813 unsigned int i;
3814
9af4a244 3815 options_init(fio_options);
de890a1e
SL
3816
3817 i = 0;
3818 while (long_options[i].name)
3819 i++;
3820
9af4a244 3821 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3822}
3823
74929ac2
JA
3824struct fio_keyword {
3825 const char *word;
3826 const char *desc;
3827 char *replace;
3828};
3829
3830static struct fio_keyword fio_keywords[] = {
3831 {
3832 .word = "$pagesize",
3833 .desc = "Page size in the system",
3834 },
3835 {
3836 .word = "$mb_memory",
3837 .desc = "Megabytes of memory online",
3838 },
3839 {
3840 .word = "$ncpus",
3841 .desc = "Number of CPUs online in the system",
3842 },
3843 {
3844 .word = NULL,
3845 },
3846};
3847
af1dc266
JA
3848void fio_keywords_exit(void)
3849{
3850 struct fio_keyword *kw;
3851
3852 kw = &fio_keywords[0];
3853 while (kw->word) {
3854 free(kw->replace);
3855 kw->replace = NULL;
3856 kw++;
3857 }
3858}
3859
74929ac2
JA
3860void fio_keywords_init(void)
3861{
3b2e1464 3862 unsigned long long mb_memory;
74929ac2
JA
3863 char buf[128];
3864 long l;
3865
a4cfc477 3866 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3867 fio_keywords[0].replace = strdup(buf);
3868
8eb016d3 3869 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3870 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3871 fio_keywords[1].replace = strdup(buf);
3872
c00a2289 3873 l = cpus_online();
74929ac2
JA
3874 sprintf(buf, "%lu", l);
3875 fio_keywords[2].replace = strdup(buf);
3876}
3877
892a6ffc
JA
3878#define BC_APP "bc"
3879
3880static char *bc_calc(char *str)
3881{
d0c814ec 3882 char buf[128], *tmp;
892a6ffc
JA
3883 FILE *f;
3884 int ret;
3885
3886 /*
3887 * No math, just return string
3888 */
d0c814ec
SL
3889 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3890 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3891 return str;
3892
3893 /*
3894 * Split option from value, we only need to calculate the value
3895 */
3896 tmp = strchr(str, '=');
3897 if (!tmp)
3898 return str;
3899
3900 tmp++;
892a6ffc 3901
d0c814ec
SL
3902 /*
3903 * Prevent buffer overflows; such a case isn't reasonable anyway
3904 */
3905 if (strlen(str) >= 128 || strlen(tmp) > 100)
3906 return str;
892a6ffc
JA
3907
3908 sprintf(buf, "which %s > /dev/null", BC_APP);
3909 if (system(buf)) {
3910 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3911 return NULL;
3912 }
3913
d0c814ec 3914 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3915 f = popen(buf, "r");
3c3ed070 3916 if (!f)
892a6ffc 3917 return NULL;
892a6ffc 3918
d0c814ec 3919 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
1d824f37
JA
3920 if (ret <= 0) {
3921 pclose(f);
892a6ffc 3922 return NULL;
1d824f37 3923 }
892a6ffc 3924
892a6ffc 3925 pclose(f);
d0c814ec
SL
3926 buf[(tmp - str) + ret - 1] = '\0';
3927 memcpy(buf, str, tmp - str);
892a6ffc 3928 free(str);
d0c814ec
SL
3929 return strdup(buf);
3930}
3931
3932/*
3933 * Return a copy of the input string with substrings of the form ${VARNAME}
3934 * substituted with the value of the environment variable VARNAME. The
3935 * substitution always occurs, even if VARNAME is empty or the corresponding
3936 * environment variable undefined.
3937 */
3938static char *option_dup_subs(const char *opt)
3939{
3940 char out[OPT_LEN_MAX+1];
3941 char in[OPT_LEN_MAX+1];
3942 char *outptr = out;
3943 char *inptr = in;
3944 char *ch1, *ch2, *env;
3945 ssize_t nchr = OPT_LEN_MAX;
3946 size_t envlen;
3947
3948 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3949 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3950 return NULL;
3951 }
3952
3953 in[OPT_LEN_MAX] = '\0';
3954 strncpy(in, opt, OPT_LEN_MAX);
3955
3956 while (*inptr && nchr > 0) {
3957 if (inptr[0] == '$' && inptr[1] == '{') {
3958 ch2 = strchr(inptr, '}');
3959 if (ch2 && inptr+1 < ch2) {
3960 ch1 = inptr+2;
3961 inptr = ch2+1;
3962 *ch2 = '\0';
3963
3964 env = getenv(ch1);
3965 if (env) {
3966 envlen = strlen(env);
3967 if (envlen <= nchr) {
3968 memcpy(outptr, env, envlen);
3969 outptr += envlen;
3970 nchr -= envlen;
3971 }
3972 }
3973
3974 continue;
3975 }
3976 }
3977
3978 *outptr++ = *inptr++;
3979 --nchr;
3980 }
3981
3982 *outptr = '\0';
3983 return strdup(out);
892a6ffc
JA
3984}
3985
74929ac2
JA
3986/*
3987 * Look for reserved variable names and replace them with real values
3988 */
3989static char *fio_keyword_replace(char *opt)
3990{
3991 char *s;
3992 int i;
d0c814ec 3993 int docalc = 0;
74929ac2
JA
3994
3995 for (i = 0; fio_keywords[i].word != NULL; i++) {
3996 struct fio_keyword *kw = &fio_keywords[i];
3997
3998 while ((s = strstr(opt, kw->word)) != NULL) {
3999 char *new = malloc(strlen(opt) + 1);
4000 char *o_org = opt;
4001 int olen = s - opt;
4002 int len;
4003
4004 /*
4005 * Copy part of the string before the keyword and
4006 * sprintf() the replacement after it.
4007 */
4008 memcpy(new, opt, olen);
4009 len = sprintf(new + olen, "%s", kw->replace);
4010
4011 /*
4012 * If there's more in the original string, copy that
4013 * in too
4014 */
4015 opt += strlen(kw->word) + olen;
4016 if (strlen(opt))
4017 memcpy(new + olen + len, opt, opt - o_org - 1);
4018
4019 /*
4020 * replace opt and free the old opt
4021 */
4022 opt = new;
d0c814ec 4023 free(o_org);
7a958bd5 4024
d0c814ec 4025 docalc = 1;
74929ac2
JA
4026 }
4027 }
4028
d0c814ec
SL
4029 /*
4030 * Check for potential math and invoke bc, if possible
4031 */
4032 if (docalc)
4033 opt = bc_calc(opt);
4034
7a958bd5 4035 return opt;
74929ac2
JA
4036}
4037
d0c814ec
SL
4038static char **dup_and_sub_options(char **opts, int num_opts)
4039{
4040 int i;
4041 char **opts_copy = malloc(num_opts * sizeof(*opts));
4042 for (i = 0; i < num_opts; i++) {
4043 opts_copy[i] = option_dup_subs(opts[i]);
4044 if (!opts_copy[i])
4045 continue;
4046 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4047 }
4048 return opts_copy;
4049}
4050
e15b023b 4051static void show_closest_option(const char *opt)
a2d027b9
JA
4052{
4053 int best_option, best_distance;
4054 int i, distance;
e15b023b
JA
4055 char *name;
4056
4057 if (!strlen(opt))
4058 return;
4059
4060 name = strdup(opt);
4061 i = 0;
4062 while (name[i] != '\0' && name[i] != '=')
4063 i++;
4064 name[i] = '\0';
a2d027b9
JA
4065
4066 best_option = -1;
4067 best_distance = INT_MAX;
4068 i = 0;
4069 while (fio_options[i].name) {
4070 distance = string_distance(name, fio_options[i].name);
4071 if (distance < best_distance) {
4072 best_distance = distance;
4073 best_option = i;
4074 }
4075 i++;
4076 }
4077
3701636d 4078 if (best_option != -1 && string_distance_ok(name, best_distance))
a2d027b9 4079 log_err("Did you mean %s?\n", fio_options[best_option].name);
e15b023b
JA
4080
4081 free(name);
a2d027b9
JA
4082}
4083
c2292325 4084int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 4085{
de890a1e 4086 int i, ret, unknown;
d0c814ec 4087 char **opts_copy;
3b8b7135 4088
9af4a244 4089 sort_options(opts, fio_options, num_opts);
d0c814ec 4090 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 4091
de890a1e
SL
4092 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4093 struct fio_option *o;
9af4a244 4094 int newret = parse_option(opts_copy[i], opts[i], fio_options,
66e19a38 4095 &o, td, &td->opt_list);
d0c814ec 4096
a8523a6a
JA
4097 if (!newret && o)
4098 fio_option_mark_set(&td->o, o);
4099
de890a1e
SL
4100 if (opts_copy[i]) {
4101 if (newret && !o) {
4102 unknown++;
4103 continue;
4104 }
d0c814ec 4105 free(opts_copy[i]);
de890a1e
SL
4106 opts_copy[i] = NULL;
4107 }
4108
4109 ret |= newret;
4110 }
4111
4112 if (unknown) {
4113 ret |= ioengine_load(td);
4114 if (td->eo) {
4115 sort_options(opts_copy, td->io_ops->options, num_opts);
4116 opts = opts_copy;
4117 }
4118 for (i = 0; i < num_opts; i++) {
4119 struct fio_option *o = NULL;
4120 int newret = 1;
a2d027b9 4121
de890a1e
SL
4122 if (!opts_copy[i])
4123 continue;
4124
4125 if (td->eo)
4126 newret = parse_option(opts_copy[i], opts[i],
4127 td->io_ops->options, &o,
66e19a38 4128 td->eo, &td->opt_list);
de890a1e
SL
4129
4130 ret |= newret;
a2d027b9 4131 if (!o) {
de890a1e 4132 log_err("Bad option <%s>\n", opts[i]);
a2d027b9
JA
4133 show_closest_option(opts[i]);
4134 }
de890a1e
SL
4135 free(opts_copy[i]);
4136 opts_copy[i] = NULL;
4137 }
74929ac2 4138 }
3b8b7135 4139
d0c814ec 4140 free(opts_copy);
3b8b7135 4141 return ret;
214e1eca
JA
4142}
4143
4144int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4145{
a8523a6a
JA
4146 int ret;
4147
d8b4f395 4148 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
a8523a6a
JA
4149 if (!ret) {
4150 struct fio_option *o;
4151
4152 o = find_option(fio_options, opt);
4153 if (o)
4154 fio_option_mark_set(&td->o, o);
4155 }
4156
4157 return ret;
214e1eca
JA
4158}
4159
de890a1e
SL
4160int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4161 char *val)
4162{
d8b4f395
JA
4163 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4164 &td->opt_list);
de890a1e
SL
4165}
4166
214e1eca
JA
4167void fio_fill_default_options(struct thread_data *td)
4168{
cb1402d6 4169 td->o.magic = OPT_MAGIC;
9af4a244 4170 fill_default_options(td, fio_options);
214e1eca
JA
4171}
4172
4173int fio_show_option_help(const char *opt)
4174{
9af4a244 4175 return show_cmd_help(fio_options, opt);
214e1eca 4176}
d23bb327 4177
de890a1e 4178void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 4179{
de890a1e 4180 struct fio_option *o;
d23bb327 4181 char **ptr;
d23bb327 4182
de890a1e
SL
4183 for (o = &options[0]; o->name; o++) {
4184 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
4185 continue;
4186
f0fdbcaf 4187 ptr = td_var(data, o, o->off1);
7e356b2d
JA
4188 if (*ptr)
4189 *ptr = strdup(*ptr);
d23bb327
JA
4190 }
4191}
4192
de890a1e
SL
4193/*
4194 * dupe FIO_OPT_STR_STORE options
4195 */
4196void fio_options_mem_dupe(struct thread_data *td)
4197{
9af4a244 4198 options_mem_dupe(&td->o, fio_options);
1647f592
JA
4199
4200 if (td->eo && td->io_ops) {
de890a1e 4201 void *oldeo = td->eo;
1647f592 4202
de890a1e
SL
4203 td->eo = malloc(td->io_ops->option_struct_size);
4204 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4205 options_mem_dupe(td->eo, td->io_ops->options);
4206 }
4207}
4208
d6978a32
JA
4209unsigned int fio_get_kb_base(void *data)
4210{
83ea422a 4211 struct thread_options *o = data;
d6978a32
JA
4212 unsigned int kb_base = 0;
4213
cb1402d6
JA
4214 /*
4215 * This is a hack... For private options, *data is not holding
4216 * a pointer to the thread_options, but to private data. This means
4217 * we can't safely dereference it, but magic is first so mem wise
4218 * it is valid. But this also means that if the job first sets
4219 * kb_base and expects that to be honored by private options,
4220 * it will be disappointed. We will return the global default
4221 * for this.
4222 */
4223 if (o && o->magic == OPT_MAGIC)
83ea422a 4224 kb_base = o->kb_base;
d6978a32
JA
4225 if (!kb_base)
4226 kb_base = 1024;
4227
4228 return kb_base;
4229}
9f988e2e 4230
07b3232d 4231int add_option(struct fio_option *o)
9f988e2e 4232{
07b3232d
JA
4233 struct fio_option *__o;
4234 int opt_index = 0;
4235
9af4a244 4236 __o = fio_options;
07b3232d
JA
4237 while (__o->name) {
4238 opt_index++;
4239 __o++;
4240 }
4241
7b504edd
JA
4242 if (opt_index + 1 == FIO_MAX_OPTS) {
4243 log_err("fio: FIO_MAX_OPTS is too small\n");
4244 return 1;
4245 }
4246
9af4a244 4247 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 4248 fio_options[opt_index + 1].name = NULL;
07b3232d 4249 return 0;
9f988e2e 4250}
e2de69da 4251
07b3232d 4252void invalidate_profile_options(const char *prof_name)
e2de69da 4253{
07b3232d 4254 struct fio_option *o;
e2de69da 4255
9af4a244 4256 o = fio_options;
07b3232d
JA
4257 while (o->name) {
4258 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4259 o->type = FIO_OPT_INVALID;
4260 o->prof_name = NULL;
4261 }
4262 o++;
e2de69da
JA
4263 }
4264}
f5b6bb85
JA
4265
4266void add_opt_posval(const char *optname, const char *ival, const char *help)
4267{
4268 struct fio_option *o;
4269 unsigned int i;
4270
9af4a244 4271 o = find_option(fio_options, optname);
f5b6bb85
JA
4272 if (!o)
4273 return;
4274
4275 for (i = 0; i < PARSE_MAX_VP; i++) {
4276 if (o->posval[i].ival)
4277 continue;
4278
4279 o->posval[i].ival = ival;
4280 o->posval[i].help = help;
4281 break;
4282 }
4283}
4284
4285void del_opt_posval(const char *optname, const char *ival)
4286{
4287 struct fio_option *o;
4288 unsigned int i;
4289
9af4a244 4290 o = find_option(fio_options, optname);
f5b6bb85
JA
4291 if (!o)
4292 return;
4293
4294 for (i = 0; i < PARSE_MAX_VP; i++) {
4295 if (!o->posval[i].ival)
4296 continue;
4297 if (strcmp(o->posval[i].ival, ival))
4298 continue;
4299
4300 o->posval[i].ival = NULL;
4301 o->posval[i].help = NULL;
4302 }
4303}
7e356b2d
JA
4304
4305void fio_options_free(struct thread_data *td)
4306{
9af4a244 4307 options_free(fio_options, td);
de890a1e
SL
4308 if (td->eo && td->io_ops && td->io_ops->options) {
4309 options_free(td->io_ops->options, td->eo);
4310 free(td->eo);
4311 td->eo = NULL;
4312 }
7e356b2d 4313}
c504ee55
JA
4314
4315struct fio_option *fio_option_find(const char *name)
4316{
4317 return find_option(fio_options, name);
4318}
4319
f0e7f45a
JA
4320static struct fio_option *find_next_opt(struct thread_options *o,
4321 struct fio_option *from,
4322 unsigned int off1)
a8523a6a 4323{
f0e7f45a 4324 struct fio_option *opt;
a8523a6a 4325
f0e7f45a
JA
4326 if (!from)
4327 from = &fio_options[0];
4328 else
4329 from++;
4330
4331 opt = NULL;
4332 do {
4333 if (off1 == from->off1) {
4334 opt = from;
a8523a6a
JA
4335 break;
4336 }
f0e7f45a
JA
4337 from++;
4338 } while (from->name);
a8523a6a 4339
f0e7f45a
JA
4340 return opt;
4341}
4342
4343static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4344{
4345 unsigned int opt_off, index, offset;
a8523a6a
JA
4346
4347 opt_off = opt - &fio_options[0];
4348 index = opt_off / (8 * sizeof(uint64_t));
4349 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4350 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
a8523a6a
JA
4351}
4352
f0e7f45a
JA
4353int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4354{
4355 struct fio_option *opt, *next;
4356
4357 next = NULL;
4358 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4359 if (opt_is_set(o, opt))
4360 return 1;
4361
4362 next = opt;
4363 }
4364
4365 return 0;
4366}
4367
a8523a6a
JA
4368void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4369{
4370 unsigned int opt_off, index, offset;
4371
4372 opt_off = opt - &fio_options[0];
4373 index = opt_off / (8 * sizeof(uint64_t));
4374 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4375 o->set_options[index] |= (uint64_t)1 << offset;
a8523a6a 4376}