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