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