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