t/io_uring: don't print BW numbers for do_nop
[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>
5921e80c 7#include <sys/stat.h>
e13c3b50 8#include <netinet/in.h>
214e1eca
JA
9
10#include "fio.h"
4f5af7b2 11#include "verify.h"
214e1eca 12#include "parse.h"
61b9861d 13#include "lib/pattern.h"
9f988e2e 14#include "options.h"
d220c761 15#include "optgroup.h"
b7694961 16#include "zbd.h"
214e1eca 17
e13c3b50 18char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
72a703da 19
a609f12a
JA
20#define cb_data_to_td(data) container_of(data, struct thread_data, o)
21
26f14c31 22static const struct pattern_fmt_desc fmt_desc[] = {
4205998f
JA
23 {
24 .fmt = "%o",
59f94d26 25 .len = FIO_FIELD_SIZE(struct io_u *, offset),
4205998f 26 .paste = paste_blockoff
969b9fbb
BVA
27 },
28 { }
4205998f
JA
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
a87c90fd
AK
47static bool split_parse_distr(const char *str, double *val, double *center)
48{
49 char *cp, *p;
50 bool r;
51
52 p = strdup(str);
53 if (!p)
54 return false;
55
56 cp = strstr(p, ":");
57 r = true;
58 if (cp) {
59 *cp = '\0';
60 cp++;
61 r = str_to_float(cp, center, 0);
62 }
63 r = r && str_to_float(p, val, 0);
64 free(p);
65 return r;
66}
67
564ca972
JA
68static int bs_cmp(const void *p1, const void *p2)
69{
70 const struct bssplit *bsp1 = p1;
71 const struct bssplit *bsp2 = p2;
72
a7cd478d 73 return (int) bsp1->perc - (int) bsp2->perc;
564ca972
JA
74}
75
f311f5f3 76int split_parse_ddir(struct thread_options *o, struct split *split,
517c9c72 77 char *str, bool absolute, unsigned int max_splits)
564ca972 78{
59466396
JA
79 unsigned long long perc;
80 unsigned int i;
564ca972 81 long long val;
720e84ad 82 char *fname;
564ca972 83
d2835319 84 split->nr = 0;
564ca972
JA
85
86 i = 0;
564ca972
JA
87 while ((fname = strsep(&str, ":")) != NULL) {
88 char *perc_str;
89
90 if (!strlen(fname))
91 break;
92
564ca972
JA
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
59466396
JA
97 if (absolute) {
98 if (str_to_decimal(perc_str, &val, 1, o, 0, 0)) {
99 log_err("fio: split conversion failed\n");
100 return 1;
101 }
102 perc = val;
103 } else {
104 perc = atoi(perc_str);
105 if (perc > 100)
106 perc = 100;
107 else if (!perc)
108 perc = -1U;
109 }
110 } else {
111 if (absolute)
112 perc = 0;
113 else
d711cce5 114 perc = -1U;
59466396 115 }
564ca972 116
88038bc7 117 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
59466396 118 log_err("fio: split conversion failed\n");
564ca972
JA
119 return 1;
120 }
121
d2835319
JA
122 split->val1[i] = val;
123 split->val2[i] = perc;
564ca972 124 i++;
c32e1a09
JA
125 if (i == max_splits) {
126 log_err("fio: hit max of %d split entries\n", i);
d2835319 127 break;
c32e1a09 128 }
564ca972
JA
129 }
130
d2835319
JA
131 split->nr = i;
132 return 0;
133}
134
f311f5f3
DLM
135static int bssplit_ddir(struct thread_options *o, void *eo,
136 enum fio_ddir ddir, char *str, bool data)
d2835319
JA
137{
138 unsigned int i, perc, perc_missing;
5fff9543 139 unsigned long long max_bs, min_bs;
d2835319
JA
140 struct split split;
141
142 memset(&split, 0, sizeof(split));
143
517c9c72 144 if (split_parse_ddir(o, &split, str, data, BSSPLIT_MAX))
d2835319
JA
145 return 1;
146 if (!split.nr)
147 return 0;
148
149 max_bs = 0;
150 min_bs = -1;
151 o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
152 o->bssplit_nr[ddir] = split.nr;
153 for (i = 0; i < split.nr; i++) {
154 if (split.val1[i] > max_bs)
155 max_bs = split.val1[i];
156 if (split.val1[i] < min_bs)
157 min_bs = split.val1[i];
158
159 o->bssplit[ddir][i].bs = split.val1[i];
160 o->bssplit[ddir][i].perc =split.val2[i];
161 }
564ca972
JA
162
163 /*
164 * Now check if the percentages add up, and how much is missing
165 */
166 perc = perc_missing = 0;
83ea422a 167 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
d2835319 168 struct bssplit *bsp = &o->bssplit[ddir][i];
564ca972 169
d711cce5 170 if (bsp->perc == -1U)
564ca972
JA
171 perc_missing++;
172 else
173 perc += bsp->perc;
174 }
175
40bafa33 176 if (perc > 100 && perc_missing > 1) {
564ca972 177 log_err("fio: bssplit percentages add to more than 100%%\n");
d2835319
JA
178 free(o->bssplit[ddir]);
179 o->bssplit[ddir] = NULL;
564ca972
JA
180 return 1;
181 }
d711cce5 182
564ca972
JA
183 /*
184 * If values didn't have a percentage set, divide the remains between
185 * them.
186 */
187 if (perc_missing) {
d711cce5 188 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
40bafa33 189 perc = 100;
83ea422a 190 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
d2835319 191 struct bssplit *bsp = &o->bssplit[ddir][i];
564ca972 192
d711cce5 193 if (bsp->perc == -1U)
564ca972
JA
194 bsp->perc = (100 - perc) / perc_missing;
195 }
196 }
197
83ea422a
JA
198 o->min_bs[ddir] = min_bs;
199 o->max_bs[ddir] = max_bs;
564ca972
JA
200
201 /*
202 * now sort based on percentages, for ease of lookup
203 */
d2835319 204 qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
720e84ad 205 return 0;
720e84ad
JA
206}
207
f311f5f3
DLM
208int str_split_parse(struct thread_data *td, char *str,
209 split_parse_fn *fn, void *eo, bool data)
720e84ad 210{
764593c0 211 char *odir, *ddir;
720e84ad
JA
212 int ret = 0;
213
720e84ad
JA
214 odir = strchr(str, ',');
215 if (odir) {
6eaf09d6
SL
216 ddir = strchr(odir + 1, ',');
217 if (ddir) {
f311f5f3 218 ret = fn(&td->o, eo, DDIR_TRIM, ddir + 1, data);
6eaf09d6
SL
219 if (!ret)
220 *ddir = '\0';
221 } else {
222 char *op;
223
224 op = strdup(odir + 1);
f311f5f3 225 ret = fn(&td->o, eo, DDIR_TRIM, op, data);
6eaf09d6
SL
226
227 free(op);
228 }
d79db122 229 if (!ret)
f311f5f3 230 ret = fn(&td->o, eo, DDIR_WRITE, odir + 1, data);
720e84ad
JA
231 if (!ret) {
232 *odir = '\0';
f311f5f3 233 ret = fn(&td->o, eo, DDIR_READ, str, data);
720e84ad
JA
234 }
235 } else {
236 char *op;
237
238 op = strdup(str);
f311f5f3 239 ret = fn(&td->o, eo, DDIR_WRITE, op, data);
6eaf09d6 240 free(op);
720e84ad 241
6eaf09d6
SL
242 if (!ret) {
243 op = strdup(str);
f311f5f3 244 ret = fn(&td->o, eo, DDIR_TRIM, op, data);
6eaf09d6
SL
245 free(op);
246 }
f0c9c217 247 if (!ret)
f311f5f3 248 ret = fn(&td->o, eo, DDIR_READ, str, data);
720e84ad 249 }
564ca972 250
764593c0
JA
251 return ret;
252}
253
254static int str_bssplit_cb(void *data, const char *input)
255{
a609f12a 256 struct thread_data *td = cb_data_to_td(data);
764593c0
JA
257 char *str, *p;
258 int ret = 0;
259
764593c0
JA
260 p = str = strdup(input);
261
262 strip_blank_front(&str);
263 strip_blank_end(str);
264
f311f5f3 265 ret = str_split_parse(td, str, bssplit_ddir, NULL, false);
764593c0 266
55baca06
JA
267 if (parse_dryrun()) {
268 int i;
269
270 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
271 free(td->o.bssplit[i]);
272 td->o.bssplit[i] = NULL;
273 td->o.bssplit_nr[i] = 0;
274 }
275 }
276
564ca972 277 free(p);
720e84ad 278 return ret;
564ca972
JA
279}
280
8b28bd41
DM
281static int str2error(char *str)
282{
a94eb99a 283 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
8b28bd41
DM
284 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
285 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
286 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
287 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
288 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
289 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
a94eb99a 290 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
7fe481b4 291 int i = 0, num = sizeof(err) / sizeof(char *);
8b28bd41 292
a94eb99a 293 while (i < num) {
8b28bd41
DM
294 if (!strcmp(err[i], str))
295 return i + 1;
296 i++;
297 }
298 return 0;
299}
300
3ed673c6
TK
301static int ignore_error_type(struct thread_data *td, enum error_type_bit etype,
302 char *str)
8b28bd41
DM
303{
304 unsigned int i;
305 int *error;
306 char *fname;
307
308 if (etype >= ERROR_TYPE_CNT) {
309 log_err("Illegal error type\n");
310 return 1;
311 }
312
313 td->o.ignore_error_nr[etype] = 4;
685ffd57 314 error = calloc(4, sizeof(int));
8b28bd41
DM
315
316 i = 0;
317 while ((fname = strsep(&str, ":")) != NULL) {
318
319 if (!strlen(fname))
320 break;
321
322 /*
323 * grow struct buffer, if needed
324 */
325 if (i == td->o.ignore_error_nr[etype]) {
326 td->o.ignore_error_nr[etype] <<= 1;
327 error = realloc(error, td->o.ignore_error_nr[etype]
328 * sizeof(int));
329 }
330 if (fname[0] == 'E') {
331 error[i] = str2error(fname);
332 } else {
333 error[i] = atoi(fname);
334 if (error[i] < 0)
1616e025 335 error[i] = -error[i];
8b28bd41
DM
336 }
337 if (!error[i]) {
d503e281 338 log_err("Unknown error %s, please use number value\n",
8b28bd41 339 fname);
d503e281 340 td->o.ignore_error_nr[etype] = 0;
0fddbf7a 341 free(error);
8b28bd41
DM
342 return 1;
343 }
344 i++;
345 }
346 if (i) {
347 td->o.continue_on_error |= 1 << etype;
348 td->o.ignore_error_nr[etype] = i;
349 td->o.ignore_error[etype] = error;
d503e281
TK
350 } else {
351 td->o.ignore_error_nr[etype] = 0;
c7b086be 352 free(error);
d503e281 353 }
c7b086be 354
8b28bd41
DM
355 return 0;
356
357}
358
d7235efb
JA
359static int str_replay_skip_cb(void *data, const char *input)
360{
361 struct thread_data *td = cb_data_to_td(data);
362 char *str, *p, *n;
363 int ret = 0;
364
365 if (parse_dryrun())
366 return 0;
367
368 p = str = strdup(input);
369
370 strip_blank_front(&str);
371 strip_blank_end(str);
372
373 while (p) {
374 n = strchr(p, ',');
375 if (n)
376 *n++ = '\0';
377 if (!strcmp(p, "read"))
378 td->o.replay_skip |= 1u << DDIR_READ;
379 else if (!strcmp(p, "write"))
380 td->o.replay_skip |= 1u << DDIR_WRITE;
381 else if (!strcmp(p, "trim"))
382 td->o.replay_skip |= 1u << DDIR_TRIM;
383 else if (!strcmp(p, "sync"))
384 td->o.replay_skip |= 1u << DDIR_SYNC;
385 else {
386 log_err("Unknown skip type: %s\n", p);
387 ret = 1;
388 break;
389 }
390 p = n;
391 }
392 free(str);
393 return ret;
394}
395
8b28bd41
DM
396static int str_ignore_error_cb(void *data, const char *input)
397{
a609f12a 398 struct thread_data *td = cb_data_to_td(data);
8b28bd41 399 char *str, *p, *n;
3ed673c6
TK
400 int ret = 1;
401 enum error_type_bit type = 0;
52c0cea3
JA
402
403 if (parse_dryrun())
404 return 0;
405
8b28bd41
DM
406 p = str = strdup(input);
407
408 strip_blank_front(&str);
409 strip_blank_end(str);
410
411 while (p) {
412 n = strchr(p, ',');
413 if (n)
414 *n++ = '\0';
415 ret = ignore_error_type(td, type, p);
416 if (ret)
417 break;
418 p = n;
419 type++;
420 }
421 free(str);
422 return ret;
423}
424
211097b2
JA
425static int str_rw_cb(void *data, const char *str)
426{
a609f12a 427 struct thread_data *td = cb_data_to_td(data);
83ea422a 428 struct thread_options *o = &td->o;
27ca949f 429 char *nr;
211097b2 430
52c0cea3
JA
431 if (parse_dryrun())
432 return 0;
433
83ea422a
JA
434 o->ddir_seq_nr = 1;
435 o->ddir_seq_add = 0;
059b0802 436
27ca949f 437 nr = get_opt_postfix(str);
059b0802
JA
438 if (!nr)
439 return 0;
440
441 if (td_random(td))
83ea422a 442 o->ddir_seq_nr = atoi(nr);
059b0802
JA
443 else {
444 long long val;
445
88038bc7 446 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
059b0802
JA
447 log_err("fio: rw postfix parsing failed\n");
448 free(nr);
449 return 1;
450 }
451
83ea422a 452 o->ddir_seq_add = val;
182ec6ee 453 }
211097b2 454
059b0802 455 free(nr);
211097b2
JA
456 return 0;
457}
458
214e1eca
JA
459static int str_mem_cb(void *data, const char *mem)
460{
a609f12a 461 struct thread_data *td = cb_data_to_td(data);
214e1eca 462
217b0f1d
LG
463 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
464 td->o.mem_type == MEM_MMAPSHARED)
836fcc0f 465 td->o.mmapfile = get_opt_postfix(mem);
214e1eca
JA
466
467 return 0;
468}
469
c223da83
JA
470static int fio_clock_source_cb(void *data, const char *str)
471{
a609f12a 472 struct thread_data *td = cb_data_to_td(data);
c223da83
JA
473
474 fio_clock_source = td->o.clocksource;
fa80feae 475 fio_clock_source_set = 1;
01423eae 476 fio_clock_init();
c223da83
JA
477 return 0;
478}
479
85bc833b 480static int str_rwmix_read_cb(void *data, unsigned long long *val)
cb499fc4 481{
a609f12a 482 struct thread_data *td = cb_data_to_td(data);
cb499fc4
JA
483
484 td->o.rwmix[DDIR_READ] = *val;
485 td->o.rwmix[DDIR_WRITE] = 100 - *val;
486 return 0;
487}
488
85bc833b 489static int str_rwmix_write_cb(void *data, unsigned long long *val)
cb499fc4 490{
a609f12a 491 struct thread_data *td = cb_data_to_td(data);
cb499fc4
JA
492
493 td->o.rwmix[DDIR_WRITE] = *val;
494 td->o.rwmix[DDIR_READ] = 100 - *val;
495 return 0;
496}
497
214e1eca
JA
498static int str_exitall_cb(void)
499{
f1867a7f 500 exitall_on_terminate = true;
214e1eca
JA
501 return 0;
502}
503
214e1eca 504#ifdef FIO_HAVE_CPU_AFFINITY
50b5860b 505int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
c2acfbac 506{
50b5860b 507 unsigned int i, index, cpus_in_mask;
c2acfbac 508 const long max_cpu = cpus_online();
c2acfbac 509
50b5860b 510 cpus_in_mask = fio_cpu_count(mask);
3a294b87
VF
511 if (!cpus_in_mask)
512 return 0;
513
50b5860b
JA
514 cpu_index = cpu_index % cpus_in_mask;
515
516 index = 0;
c2acfbac 517 for (i = 0; i < max_cpu; i++) {
50b5860b 518 if (!fio_cpu_isset(mask, i))
c2acfbac 519 continue;
50b5860b
JA
520
521 if (cpu_index != index)
522 fio_cpu_clear(mask, i);
523
524 index++;
c2acfbac
JA
525 }
526
527 return fio_cpu_count(mask);
528}
529
85bc833b 530static int str_cpumask_cb(void *data, unsigned long long *val)
d2e268b0 531{
a609f12a 532 struct thread_data *td = cb_data_to_td(data);
214e1eca 533 unsigned int i;
b03daafb 534 long max_cpu;
d2ce18b5
JA
535 int ret;
536
52c0cea3
JA
537 if (parse_dryrun())
538 return 0;
539
d2ce18b5
JA
540 ret = fio_cpuset_init(&td->o.cpumask);
541 if (ret < 0) {
542 log_err("fio: cpuset_init failed\n");
543 td_verror(td, ret, "fio_cpuset_init");
544 return 1;
545 }
214e1eca 546
c00a2289 547 max_cpu = cpus_online();
214e1eca 548
62a7273d
JA
549 for (i = 0; i < sizeof(int) * 8; i++) {
550 if ((1 << i) & *val) {
b8411399 551 if (i >= max_cpu) {
b03daafb 552 log_err("fio: CPU %d too large (max=%ld)\n", i,
b8411399 553 max_cpu - 1);
b03daafb
JA
554 return 1;
555 }
62a7273d 556 dprint(FD_PARSE, "set cpu allowed %d\n", i);
6d459ee7 557 fio_cpu_set(&td->o.cpumask, i);
62a7273d
JA
558 }
559 }
d2e268b0 560
d2e268b0 561 return 0;
214e1eca
JA
562}
563
e8462bd8
JA
564static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
565 const char *input)
214e1eca 566{
d2e268b0 567 char *cpu, *str, *p;
b03daafb 568 long max_cpu;
19608d6c 569 int ret = 0;
d2e268b0 570
e8462bd8 571 ret = fio_cpuset_init(mask);
d2ce18b5
JA
572 if (ret < 0) {
573 log_err("fio: cpuset_init failed\n");
574 td_verror(td, ret, "fio_cpuset_init");
575 return 1;
576 }
d2e268b0
JA
577
578 p = str = strdup(input);
214e1eca 579
d2e268b0
JA
580 strip_blank_front(&str);
581 strip_blank_end(str);
582
c00a2289 583 max_cpu = cpus_online();
b03daafb 584
d2e268b0 585 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
586 char *str2, *cpu2;
587 int icpu, icpu2;
588
d2e268b0
JA
589 if (!strlen(cpu))
590 break;
62a7273d
JA
591
592 str2 = cpu;
593 icpu2 = -1;
594 while ((cpu2 = strsep(&str2, "-")) != NULL) {
595 if (!strlen(cpu2))
596 break;
597
598 icpu2 = atoi(cpu2);
599 }
600
601 icpu = atoi(cpu);
602 if (icpu2 == -1)
603 icpu2 = icpu;
604 while (icpu <= icpu2) {
6d459ee7 605 if (icpu >= FIO_MAX_CPUS) {
19608d6c 606 log_err("fio: your OS only supports up to"
6d459ee7 607 " %d CPUs\n", (int) FIO_MAX_CPUS);
19608d6c
JA
608 ret = 1;
609 break;
610 }
9e986889 611 if (icpu >= max_cpu) {
b03daafb 612 log_err("fio: CPU %d too large (max=%ld)\n",
9e986889 613 icpu, max_cpu - 1);
b03daafb
JA
614 ret = 1;
615 break;
616 }
0b9d69ec 617
62a7273d 618 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
e8462bd8 619 fio_cpu_set(mask, icpu);
62a7273d
JA
620 icpu++;
621 }
19608d6c
JA
622 if (ret)
623 break;
d2e268b0
JA
624 }
625
626 free(p);
19608d6c 627 return ret;
214e1eca 628}
e8462bd8
JA
629
630static int str_cpus_allowed_cb(void *data, const char *input)
631{
a609f12a 632 struct thread_data *td = cb_data_to_td(data);
e8462bd8 633
52c0cea3
JA
634 if (parse_dryrun())
635 return 0;
636
b2a9e649 637 return set_cpus_allowed(td, &td->o.cpumask, input);
e8462bd8
JA
638}
639
640static int str_verify_cpus_allowed_cb(void *data, const char *input)
641{
a609f12a 642 struct thread_data *td = cb_data_to_td(data);
e8462bd8 643
466155e2
JA
644 if (parse_dryrun())
645 return 0;
646
b2a9e649 647 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
e8462bd8 648}
c08f9fe2 649
105157ad 650#ifdef CONFIG_ZLIB
c08f9fe2
JA
651static int str_log_cpus_allowed_cb(void *data, const char *input)
652{
a609f12a 653 struct thread_data *td = cb_data_to_td(data);
c08f9fe2
JA
654
655 if (parse_dryrun())
656 return 0;
657
658 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
659}
105157ad 660#endif /* CONFIG_ZLIB */
c08f9fe2 661
105157ad 662#endif /* FIO_HAVE_CPU_AFFINITY */
214e1eca 663
67bf9823 664#ifdef CONFIG_LIBNUMA
d0b937ed
YR
665static int str_numa_cpunodes_cb(void *data, char *input)
666{
a609f12a 667 struct thread_data *td = cb_data_to_td(data);
43522848 668 struct bitmask *verify_bitmask;
d0b937ed 669
52c0cea3
JA
670 if (parse_dryrun())
671 return 0;
672
d0b937ed
YR
673 /* numa_parse_nodestring() parses a character string list
674 * of nodes into a bit mask. The bit mask is allocated by
675 * numa_allocate_nodemask(), so it should be freed by
676 * numa_free_nodemask().
677 */
43522848
DG
678 verify_bitmask = numa_parse_nodestring(input);
679 if (verify_bitmask == NULL) {
d0b937ed
YR
680 log_err("fio: numa_parse_nodestring failed\n");
681 td_verror(td, 1, "str_numa_cpunodes_cb");
682 return 1;
683 }
43522848 684 numa_free_nodemask(verify_bitmask);
d0b937ed 685
43522848 686 td->o.numa_cpunodes = strdup(input);
d0b937ed
YR
687 return 0;
688}
689
690static int str_numa_mpol_cb(void *data, char *input)
691{
a609f12a 692 struct thread_data *td = cb_data_to_td(data);
d0b937ed 693 const char * const policy_types[] =
05d6f44b 694 { "default", "prefer", "bind", "interleave", "local", NULL };
d0b937ed 695 int i;
52c0cea3 696 char *nodelist;
43522848 697 struct bitmask *verify_bitmask;
52c0cea3
JA
698
699 if (parse_dryrun())
700 return 0;
d0b937ed 701
52c0cea3 702 nodelist = strchr(input, ':');
d0b937ed
YR
703 if (nodelist) {
704 /* NUL-terminate mode */
705 *nodelist++ = '\0';
706 }
707
708 for (i = 0; i <= MPOL_LOCAL; i++) {
709 if (!strcmp(input, policy_types[i])) {
710 td->o.numa_mem_mode = i;
711 break;
712 }
713 }
714 if (i > MPOL_LOCAL) {
715 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
716 goto out;
717 }
718
719 switch (td->o.numa_mem_mode) {
720 case MPOL_PREFERRED:
721 /*
722 * Insist on a nodelist of one node only
723 */
724 if (nodelist) {
725 char *rest = nodelist;
726 while (isdigit(*rest))
727 rest++;
728 if (*rest) {
729 log_err("fio: one node only for \'prefer\'\n");
730 goto out;
731 }
732 } else {
733 log_err("fio: one node is needed for \'prefer\'\n");
734 goto out;
735 }
736 break;
737 case MPOL_INTERLEAVE:
738 /*
739 * Default to online nodes with memory if no nodelist
740 */
741 if (!nodelist)
742 nodelist = strdup("all");
743 break;
744 case MPOL_LOCAL:
745 case MPOL_DEFAULT:
746 /*
747 * Don't allow a nodelist
748 */
749 if (nodelist) {
750 log_err("fio: NO nodelist for \'local\'\n");
751 goto out;
752 }
753 break;
754 case MPOL_BIND:
755 /*
756 * Insist on a nodelist
757 */
758 if (!nodelist) {
759 log_err("fio: a nodelist is needed for \'bind\'\n");
760 goto out;
761 }
762 break;
763 }
764
765
766 /* numa_parse_nodestring() parses a character string list
767 * of nodes into a bit mask. The bit mask is allocated by
768 * numa_allocate_nodemask(), so it should be freed by
769 * numa_free_nodemask().
770 */
771 switch (td->o.numa_mem_mode) {
772 case MPOL_PREFERRED:
773 td->o.numa_mem_prefer_node = atoi(nodelist);
774 break;
775 case MPOL_INTERLEAVE:
776 case MPOL_BIND:
43522848
DG
777 verify_bitmask = numa_parse_nodestring(nodelist);
778 if (verify_bitmask == NULL) {
d0b937ed
YR
779 log_err("fio: numa_parse_nodestring failed\n");
780 td_verror(td, 1, "str_numa_memnodes_cb");
781 return 1;
782 }
43522848
DG
783 td->o.numa_memnodes = strdup(nodelist);
784 numa_free_nodemask(verify_bitmask);
b74e419e 785
d0b937ed
YR
786 break;
787 case MPOL_LOCAL:
788 case MPOL_DEFAULT:
789 default:
790 break;
791 }
792
d0b937ed 793 return 0;
d0b937ed
YR
794out:
795 return 1;
796}
797#endif
798
214e1eca
JA
799static int str_fst_cb(void *data, const char *str)
800{
a609f12a 801 struct thread_data *td = cb_data_to_td(data);
8c07860d 802 double val;
a87c90fd 803 double center = -1;
8c07860d
JA
804 bool done = false;
805 char *nr;
214e1eca
JA
806
807 td->file_service_nr = 1;
8c07860d
JA
808
809 switch (td->o.file_service_type) {
810 case FIO_FSERVICE_RANDOM:
811 case FIO_FSERVICE_RR:
812 case FIO_FSERVICE_SEQ:
813 nr = get_opt_postfix(str);
814 if (nr) {
815 td->file_service_nr = atoi(nr);
816 free(nr);
817 }
818 done = true;
819 break;
820 case FIO_FSERVICE_ZIPF:
821 val = FIO_DEF_ZIPF;
822 break;
823 case FIO_FSERVICE_PARETO:
824 val = FIO_DEF_PARETO;
825 break;
826 case FIO_FSERVICE_GAUSS:
827 val = 0.0;
828 break;
829 default:
830 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
831 return 1;
832 }
833
834 if (done)
835 return 0;
836
837 nr = get_opt_postfix(str);
a87c90fd 838 if (nr && !split_parse_distr(nr, &val, &center)) {
8c07860d 839 log_err("fio: file service type random postfix parsing failed\n");
182ec6ee 840 free(nr);
8c07860d
JA
841 return 1;
842 }
843
844 free(nr);
845
a87c90fd
AK
846 if (center != -1 && (center < 0.00 || center > 1.00)) {
847 log_err("fio: distribution center out of range (0 <= center <= 1.0)\n");
848 return 1;
849 }
850 td->random_center = center;
851
8c07860d
JA
852 switch (td->o.file_service_type) {
853 case FIO_FSERVICE_ZIPF:
854 if (val == 1.00) {
855 log_err("fio: zipf theta must be different than 1.0\n");
856 return 1;
857 }
858 if (parse_dryrun())
859 return 0;
860 td->zipf_theta = val;
861 break;
862 case FIO_FSERVICE_PARETO:
863 if (val <= 0.00 || val >= 1.00) {
864 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
865 return 1;
866 }
867 if (parse_dryrun())
868 return 0;
869 td->pareto_h = val;
870 break;
871 case FIO_FSERVICE_GAUSS:
872 if (val < 0.00 || val >= 100.00) {
99c94a6b 873 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
8c07860d
JA
874 return 1;
875 }
876 if (parse_dryrun())
877 return 0;
878 td->gauss_dev = val;
879 break;
182ec6ee 880 }
214e1eca
JA
881
882 return 0;
883}
884
67bf9823 885#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
886static int str_sfr_cb(void *data, const char *str)
887{
a609f12a 888 struct thread_data *td = cb_data_to_td(data);
44f29692
JA
889 char *nr = get_opt_postfix(str);
890
891 td->sync_file_range_nr = 1;
892 if (nr) {
893 td->sync_file_range_nr = atoi(nr);
894 free(nr);
895 }
896
897 return 0;
898}
3ae06371 899#endif
44f29692 900
f311f5f3
DLM
901static int zone_split_ddir(struct thread_options *o, void *eo,
902 enum fio_ddir ddir, char *str, bool absolute)
e0a04ac1 903{
e0a04ac1 904 unsigned int i, perc, perc_missing, sperc, sperc_missing;
d2835319 905 struct split split;
e0a04ac1 906
d2835319 907 memset(&split, 0, sizeof(split));
e0a04ac1 908
517c9c72 909 if (split_parse_ddir(o, &split, str, absolute, ZONESPLIT_MAX))
d2835319
JA
910 return 1;
911 if (!split.nr)
912 return 0;
e0a04ac1 913
d2835319
JA
914 o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
915 o->zone_split_nr[ddir] = split.nr;
916 for (i = 0; i < split.nr; i++) {
917 o->zone_split[ddir][i].access_perc = split.val1[i];
59466396
JA
918 if (absolute)
919 o->zone_split[ddir][i].size = split.val2[i];
920 else
921 o->zone_split[ddir][i].size_perc = split.val2[i];
e0a04ac1
JA
922 }
923
e0a04ac1
JA
924 /*
925 * Now check if the percentages add up, and how much is missing
926 */
927 perc = perc_missing = 0;
928 sperc = sperc_missing = 0;
929 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
d2835319 930 struct zone_split *zsp = &o->zone_split[ddir][i];
e0a04ac1
JA
931
932 if (zsp->access_perc == (uint8_t) -1U)
933 perc_missing++;
934 else
935 perc += zsp->access_perc;
936
59466396
JA
937 if (!absolute) {
938 if (zsp->size_perc == (uint8_t) -1U)
939 sperc_missing++;
940 else
941 sperc += zsp->size_perc;
942 }
e0a04ac1
JA
943 }
944
945 if (perc > 100 || sperc > 100) {
946 log_err("fio: zone_split percentages add to more than 100%%\n");
d2835319
JA
947 free(o->zone_split[ddir]);
948 o->zone_split[ddir] = NULL;
e0a04ac1
JA
949 return 1;
950 }
951 if (perc < 100) {
952 log_err("fio: access percentage don't add up to 100 for zoned "
953 "random distribution (got=%u)\n", perc);
d2835319
JA
954 free(o->zone_split[ddir]);
955 o->zone_split[ddir] = NULL;
e0a04ac1
JA
956 return 1;
957 }
958
959 /*
960 * If values didn't have a percentage set, divide the remains between
961 * them.
962 */
963 if (perc_missing) {
964 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
965 perc = 100;
966 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
d2835319 967 struct zone_split *zsp = &o->zone_split[ddir][i];
e0a04ac1
JA
968
969 if (zsp->access_perc == (uint8_t) -1U)
970 zsp->access_perc = (100 - perc) / perc_missing;
971 }
972 }
973 if (sperc_missing) {
974 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
975 sperc = 100;
976 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
d2835319 977 struct zone_split *zsp = &o->zone_split[ddir][i];
e0a04ac1
JA
978
979 if (zsp->size_perc == (uint8_t) -1U)
980 zsp->size_perc = (100 - sperc) / sperc_missing;
981 }
982 }
983
e0a04ac1
JA
984 return 0;
985}
986
59466396
JA
987static int parse_zoned_distribution(struct thread_data *td, const char *input,
988 bool absolute)
e0a04ac1 989{
59466396 990 const char *pre = absolute ? "zoned_abs:" : "zoned:";
764593c0 991 char *str, *p;
e0a04ac1
JA
992 int i, ret = 0;
993
994 p = str = strdup(input);
995
996 strip_blank_front(&str);
997 strip_blank_end(str);
998
999 /* We expect it to start like that, bail if not */
59466396 1000 if (strncmp(str, pre, strlen(pre))) {
e0a04ac1
JA
1001 log_err("fio: mismatch in zoned input <%s>\n", str);
1002 free(p);
1003 return 1;
1004 }
59466396 1005 str += strlen(pre);
e0a04ac1 1006
f311f5f3 1007 ret = str_split_parse(td, str, zone_split_ddir, NULL, absolute);
e0a04ac1
JA
1008
1009 free(p);
1010
1011 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1012 int j;
1013
1014 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
1015
1016 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
1017 struct zone_split *zsp = &td->o.zone_split[i][j];
1018
59466396
JA
1019 if (absolute) {
1020 dprint(FD_PARSE, "\t%d: %u/%llu\n", j,
1021 zsp->access_perc,
1022 (unsigned long long) zsp->size);
1023 } else {
1024 dprint(FD_PARSE, "\t%d: %u/%u\n", j,
1025 zsp->access_perc,
1026 zsp->size_perc);
1027 }
e0a04ac1
JA
1028 }
1029 }
1030
55baca06 1031 if (parse_dryrun()) {
55baca06
JA
1032 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1033 free(td->o.zone_split[i]);
1034 td->o.zone_split[i] = NULL;
1035 td->o.zone_split_nr[i] = 0;
1036 }
1037
1038 return ret;
1039 }
1040
81bdb791 1041 if (ret) {
dc4bffb8
JA
1042 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1043 td->o.zone_split_nr[i] = 0;
1044 }
e0a04ac1
JA
1045
1046 return ret;
1047}
1048
e25839d4
JA
1049static int str_random_distribution_cb(void *data, const char *str)
1050{
a609f12a 1051 struct thread_data *td = cb_data_to_td(data);
e25839d4 1052 double val;
a87c90fd 1053 double center = -1;
e25839d4
JA
1054 char *nr;
1055
925fee33 1056 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
c95f9404 1057 val = FIO_DEF_ZIPF;
925fee33 1058 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
c95f9404 1059 val = FIO_DEF_PARETO;
56d9fa4b
JA
1060 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1061 val = 0.0;
e0a04ac1 1062 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
59466396
JA
1063 return parse_zoned_distribution(td, str, false);
1064 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED_ABS)
1065 return parse_zoned_distribution(td, str, true);
925fee33 1066 else
e25839d4
JA
1067 return 0;
1068
1069 nr = get_opt_postfix(str);
a87c90fd 1070 if (nr && !split_parse_distr(nr, &val, &center)) {
e25839d4
JA
1071 log_err("fio: random postfix parsing failed\n");
1072 free(nr);
1073 return 1;
1074 }
1075
078189c1
JA
1076 free(nr);
1077
a87c90fd
AK
1078 if (center != -1 && (center < 0.00 || center > 1.00)) {
1079 log_err("fio: distribution center out of range (0 <= center <= 1.0)\n");
1080 return 1;
1081 }
1082 td->o.random_center.u.f = center;
1083
18ded917
JA
1084 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1085 if (val == 1.00) {
1086 log_err("fio: zipf theta must different than 1.0\n");
1087 return 1;
1088 }
55baca06
JA
1089 if (parse_dryrun())
1090 return 0;
1e5324e7 1091 td->o.zipf_theta.u.f = val;
56d9fa4b 1092 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
078189c1
JA
1093 if (val <= 0.00 || val >= 1.00) {
1094 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1095 return 1;
1096 }
55baca06
JA
1097 if (parse_dryrun())
1098 return 0;
1e5324e7 1099 td->o.pareto_h.u.f = val;
3cdb8cf3 1100 } else {
76527b19 1101 if (val < 0.00 || val >= 100.0) {
99c94a6b 1102 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
3cdb8cf3
JA
1103 return 1;
1104 }
55baca06
JA
1105 if (parse_dryrun())
1106 return 0;
f88cd222 1107 td->o.gauss_dev.u.f = val;
3cdb8cf3 1108 }
921c766f
JA
1109
1110 return 0;
1111}
1112
16e56d25
VF
1113static int str_steadystate_cb(void *data, const char *str)
1114{
94f218f6 1115 struct thread_data *td = cb_data_to_td(data);
16e56d25
VF
1116 double val;
1117 char *nr;
1118 char *pct;
1119 long long ll;
1120
2c5d94bc
VF
1121 if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1122 td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
16e56d25
VF
1123 /* should be impossible to get here */
1124 log_err("fio: unknown steady state criterion\n");
1125 return 1;
1126 }
1127
1128 nr = get_opt_postfix(str);
1129 if (!nr) {
1130 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1131 free(nr);
1132 return 1;
1133 }
1134
1135 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1136 pct = strstr(nr, "%");
1137 if (pct) {
1138 *pct = '\0';
1139 strip_blank_end(nr);
1140 if (!str_to_float(nr, &val, 0)) {
1141 log_err("fio: could not parse steadystate threshold percentage\n");
1142 free(nr);
1143 return 1;
1144 }
1145
1146 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1147 free(nr);
1148 if (parse_dryrun())
1149 return 0;
1150
c8caba48 1151 td->o.ss_state |= FIO_SS_PCT;
16e56d25 1152 td->o.ss_limit.u.f = val;
c8caba48 1153 } else if (td->o.ss_state & FIO_SS_IOPS) {
16e56d25
VF
1154 if (!str_to_float(nr, &val, 0)) {
1155 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1156 free(nr);
1157 return 1;
1158 }
1159
1160 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1161 free(nr);
1162 if (parse_dryrun())
1163 return 0;
1164
16e56d25 1165 td->o.ss_limit.u.f = val;
16e56d25
VF
1166 } else { /* bandwidth criterion */
1167 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1168 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1169 free(nr);
1170 return 1;
1171 }
1172
1173 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1174 free(nr);
1175 if (parse_dryrun())
1176 return 0;
1177
16e56d25 1178 td->o.ss_limit.u.f = (double) ll;
16e56d25
VF
1179 }
1180
2c5d94bc 1181 td->ss.state = td->o.ss_state;
16e56d25
VF
1182 return 0;
1183}
1184
8e827d35 1185/*
bcbfeefa 1186 * Return next name in the string. Files are separated with ':'. If the ':'
8e827d35
JA
1187 * is escaped with a '\', then that ':' is part of the filename and does not
1188 * indicate a new file.
1189 */
532eda7e 1190char *get_next_str(char **ptr)
8e827d35
JA
1191{
1192 char *str = *ptr;
1193 char *p, *start;
1194
1195 if (!str || !strlen(str))
1196 return NULL;
1197
1198 start = str;
1199 do {
1200 /*
1201 * No colon, we are done
1202 */
1203 p = strchr(str, ':');
1204 if (!p) {
1205 *ptr = NULL;
1206 break;
1207 }
1208
1209 /*
1210 * We got a colon, but it's the first character. Skip and
1211 * continue
1212 */
1213 if (p == start) {
1214 str = ++start;
1215 continue;
1216 }
1217
1218 if (*(p - 1) != '\\') {
1219 *p = '\0';
1220 *ptr = p + 1;
1221 break;
1222 }
1223
1224 memmove(p - 1, p, strlen(p) + 1);
1225 str = p;
1226 } while (1);
1227
1228 return start;
1229}
1230
bcbfeefa 1231
532eda7e 1232int get_max_str_idx(char *input)
bcbfeefa
CE
1233{
1234 unsigned int cur_idx;
1235 char *str, *p;
1236
1237 p = str = strdup(input);
1238 for (cur_idx = 0; ; cur_idx++)
532eda7e 1239 if (get_next_str(&str) == NULL)
bcbfeefa
CE
1240 break;
1241
1242 free(p);
1243 return cur_idx;
1244}
1245
1246/*
1247 * Returns the directory at the index, indexes > entires will be
1248 * assigned via modulo division of the index
1249 */
922a5be8
JA
1250int set_name_idx(char *target, size_t tlen, char *input, int index,
1251 bool unique_filename)
bcbfeefa
CE
1252{
1253 unsigned int cur_idx;
1254 int len;
1255 char *fname, *str, *p;
1256
1257 p = str = strdup(input);
1258
532eda7e 1259 index %= get_max_str_idx(input);
bcbfeefa 1260 for (cur_idx = 0; cur_idx <= index; cur_idx++)
532eda7e 1261 fname = get_next_str(&str);
bcbfeefa 1262
922a5be8 1263 if (client_sockaddr_str[0] && unique_filename) {
e13c3b50
JA
1264 len = snprintf(target, tlen, "%s/%s.", fname,
1265 client_sockaddr_str);
1266 } else
df18600f
SW
1267 len = snprintf(target, tlen, "%s%c", fname,
1268 FIO_OS_PATH_SEPARATOR);
72a703da 1269
e13c3b50 1270 target[tlen - 1] = '\0';
bcbfeefa
CE
1271 free(p);
1272
1273 return len;
1274}
1275
c70c7f58
AK
1276char* get_name_by_idx(char *input, int index)
1277{
1278 unsigned int cur_idx;
1279 char *fname, *str, *p;
1280
1281 p = str = strdup(input);
1282
532eda7e 1283 index %= get_max_str_idx(input);
c70c7f58 1284 for (cur_idx = 0; cur_idx <= index; cur_idx++)
532eda7e 1285 fname = get_next_str(&str);
c70c7f58
AK
1286
1287 fname = strdup(fname);
1288 free(p);
1289
1290 return fname;
1291}
1292
214e1eca
JA
1293static int str_filename_cb(void *data, const char *input)
1294{
a609f12a 1295 struct thread_data *td = cb_data_to_td(data);
214e1eca
JA
1296 char *fname, *str, *p;
1297
1298 p = str = strdup(input);
1299
1300 strip_blank_front(&str);
1301 strip_blank_end(str);
1302
79591fa9
TK
1303 /*
1304 * Ignore what we may already have from nrfiles option.
1305 */
214e1eca 1306 if (!td->files_index)
2dc1bbeb 1307 td->o.nr_files = 0;
214e1eca 1308
532eda7e 1309 while ((fname = get_next_str(&str)) != NULL) {
214e1eca
JA
1310 if (!strlen(fname))
1311 break;
5903e7b7 1312 add_file(td, fname, 0, 1);
214e1eca
JA
1313 }
1314
1315 free(p);
1316 return 0;
1317}
1318
bcbfeefa 1319static int str_directory_cb(void *data, const char fio_unused *unused)
214e1eca 1320{
a609f12a 1321 struct thread_data *td = cb_data_to_td(data);
214e1eca 1322 struct stat sb;
bcbfeefa
CE
1323 char *dirname, *str, *p;
1324 int ret = 0;
214e1eca 1325
f9633d72
JA
1326 if (parse_dryrun())
1327 return 0;
1328
bcbfeefa 1329 p = str = strdup(td->o.directory);
532eda7e 1330 while ((dirname = get_next_str(&str)) != NULL) {
bcbfeefa
CE
1331 if (lstat(dirname, &sb) < 0) {
1332 ret = errno;
921c766f 1333
bcbfeefa
CE
1334 log_err("fio: %s is not a directory\n", dirname);
1335 td_verror(td, ret, "lstat");
1336 goto out;
1337 }
1338 if (!S_ISDIR(sb.st_mode)) {
1339 log_err("fio: %s is not a directory\n", dirname);
1340 ret = 1;
1341 goto out;
1342 }
214e1eca
JA
1343 }
1344
bcbfeefa
CE
1345out:
1346 free(p);
1347 return ret;
214e1eca
JA
1348}
1349
1350static int str_opendir_cb(void *data, const char fio_unused *str)
1351{
a609f12a 1352 struct thread_data *td = cb_data_to_td(data);
214e1eca 1353
52c0cea3
JA
1354 if (parse_dryrun())
1355 return 0;
1356
214e1eca 1357 if (!td->files_index)
2dc1bbeb 1358 td->o.nr_files = 0;
214e1eca 1359
2dc1bbeb 1360 return add_dir_files(td, td->o.opendir);
214e1eca
JA
1361}
1362
ce35b1ec
JA
1363static int str_buffer_pattern_cb(void *data, const char *input)
1364{
a609f12a 1365 struct thread_data *td = cb_data_to_td(data);
ce35b1ec
JA
1366 int ret;
1367
61b9861d
RP
1368 /* FIXME: for now buffer pattern does not support formats */
1369 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
969b9fbb 1370 MAX_PATTERN_SIZE, NULL, NULL, NULL);
61b9861d
RP
1371 if (ret < 0)
1372 return 1;
ce35b1ec 1373
61b9861d
RP
1374 assert(ret != 0);
1375 td->o.buffer_pattern_bytes = ret;
c55fae03
JA
1376
1377 /*
1378 * If this job is doing any reading or has compression set,
1379 * ensure that we refill buffers for writes or we could be
1380 * invalidating the pattern through reads.
1381 */
1382 if (!td->o.compress_percentage && !td_read(td))
61b9861d 1383 td->o.refill_buffers = 0;
c55fae03
JA
1384 else
1385 td->o.refill_buffers = 1;
1386
61b9861d
RP
1387 td->o.scramble_buffers = 0;
1388 td->o.zero_buffers = 0;
efcd9dcc 1389
61b9861d 1390 return 0;
ce35b1ec
JA
1391}
1392
bedc9dc2
JA
1393static int str_buffer_compress_cb(void *data, unsigned long long *il)
1394{
a609f12a 1395 struct thread_data *td = cb_data_to_td(data);
bedc9dc2
JA
1396
1397 td->flags |= TD_F_COMPRESS;
1398 td->o.compress_percentage = *il;
1399 return 0;
1400}
1401
5c94b008
JA
1402static int str_dedupe_cb(void *data, unsigned long long *il)
1403{
a609f12a 1404 struct thread_data *td = cb_data_to_td(data);
5c94b008
JA
1405
1406 td->flags |= TD_F_COMPRESS;
1407 td->o.dedupe_percentage = *il;
1408 td->o.refill_buffers = 1;
1409 return 0;
1410}
1411
ce35b1ec
JA
1412static int str_verify_pattern_cb(void *data, const char *input)
1413{
a609f12a 1414 struct thread_data *td = cb_data_to_td(data);
ce35b1ec
JA
1415 int ret;
1416
59f94d26 1417 td->o.verify_fmt_sz = FIO_ARRAY_SIZE(td->o.verify_fmt);
61b9861d 1418 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
969b9fbb 1419 MAX_PATTERN_SIZE, fmt_desc,
4205998f 1420 td->o.verify_fmt, &td->o.verify_fmt_sz);
61b9861d
RP
1421 if (ret < 0)
1422 return 1;
efcd9dcc 1423
61b9861d
RP
1424 assert(ret != 0);
1425 td->o.verify_pattern_bytes = ret;
92bf48d5 1426 /*
b638d82f 1427 * VERIFY_* could already be set
92bf48d5 1428 */
61b9861d 1429 if (!fio_option_is_set(&td->o, verify))
92bf48d5 1430 td->o.verify = VERIFY_PATTERN;
efcd9dcc 1431
61b9861d 1432 return 0;
90059d65 1433}
214e1eca 1434
993bf48b
JA
1435static int str_gtod_reduce_cb(void *data, int *il)
1436{
a609f12a 1437 struct thread_data *td = cb_data_to_td(data);
993bf48b
JA
1438 int val = *il;
1439
56440e63
VF
1440 /*
1441 * Only modfiy options if gtod_reduce==1
1442 * Otherwise leave settings alone.
1443 */
1444 if (val) {
1445 td->o.disable_lat = 1;
1446 td->o.disable_clat = 1;
1447 td->o.disable_slat = 1;
1448 td->o.disable_bw = 1;
1449 td->o.clat_percentiles = 0;
1450 td->o.lat_percentiles = 0;
1451 td->o.slat_percentiles = 0;
8b6a404c 1452 td->ts_cache_mask = 63;
56440e63 1453 }
993bf48b
JA
1454
1455 return 0;
1456}
1457
89978a6b
BW
1458static int str_offset_cb(void *data, unsigned long long *__val)
1459{
1460 struct thread_data *td = cb_data_to_td(data);
1461 unsigned long long v = *__val;
1462
1463 if (parse_is_percent(v)) {
1464 td->o.start_offset = 0;
1465 td->o.start_offset_percent = -1ULL - v;
8f39afa7 1466 td->o.start_offset_nz = 0;
872e0415
JA
1467 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1468 td->o.start_offset_percent);
8f39afa7
AD
1469 } else if (parse_is_zone(v)) {
1470 td->o.start_offset = 0;
1471 td->o.start_offset_percent = 0;
1472 td->o.start_offset_nz = v - ZONE_BASE_VAL;
89978a6b
BW
1473 } else
1474 td->o.start_offset = v;
1475
1476 return 0;
1477}
1478
0b288ba1
VF
1479static int str_offset_increment_cb(void *data, unsigned long long *__val)
1480{
1481 struct thread_data *td = cb_data_to_td(data);
1482 unsigned long long v = *__val;
1483
1484 if (parse_is_percent(v)) {
1485 td->o.offset_increment = 0;
1486 td->o.offset_increment_percent = -1ULL - v;
8f39afa7 1487 td->o.offset_increment_nz = 0;
0b288ba1
VF
1488 dprint(FD_PARSE, "SET offset_increment_percent %d\n",
1489 td->o.offset_increment_percent);
8f39afa7
AD
1490 } else if (parse_is_zone(v)) {
1491 td->o.offset_increment = 0;
1492 td->o.offset_increment_percent = 0;
1493 td->o.offset_increment_nz = v - ZONE_BASE_VAL;
0b288ba1
VF
1494 } else
1495 td->o.offset_increment = v;
1496
1497 return 0;
1498}
1499
7bb59102
JA
1500static int str_size_cb(void *data, unsigned long long *__val)
1501{
a609f12a 1502 struct thread_data *td = cb_data_to_td(data);
7bb59102
JA
1503 unsigned long long v = *__val;
1504
1505 if (parse_is_percent(v)) {
1506 td->o.size = 0;
1507 td->o.size_percent = -1ULL - v;
24e4321c
TK
1508 dprint(FD_PARSE, "SET size_percent %d\n",
1509 td->o.size_percent);
8f39afa7
AD
1510 } else if (parse_is_zone(v)) {
1511 td->o.size = 0;
1512 td->o.size_percent = 0;
1513 td->o.size_nz = v - ZONE_BASE_VAL;
7bb59102
JA
1514 } else
1515 td->o.size = v;
1516
1517 return 0;
1518}
1519
8b38f401
AD
1520static int str_io_size_cb(void *data, unsigned long long *__val)
1521{
1522 struct thread_data *td = cb_data_to_td(data);
1523 unsigned long long v = *__val;
1524
f248a525 1525 if (parse_is_percent_uncapped(v)) {
8b38f401
AD
1526 td->o.io_size = 0;
1527 td->o.io_size_percent = -1ULL - v;
f248a525
AD
1528 if (td->o.io_size_percent > 100) {
1529 log_err("fio: io_size values greater than 100%% aren't supported\n");
1530 return 1;
1531 }
8b38f401
AD
1532 dprint(FD_PARSE, "SET io_size_percent %d\n",
1533 td->o.io_size_percent);
8f39afa7
AD
1534 } else if (parse_is_zone(v)) {
1535 td->o.io_size = 0;
1536 td->o.io_size_percent = 0;
1537 td->o.io_size_nz = v - ZONE_BASE_VAL;
8b38f401
AD
1538 } else
1539 td->o.io_size = v;
1540
1541 return 0;
1542}
1543
8f39afa7
AD
1544static int str_zoneskip_cb(void *data, unsigned long long *__val)
1545{
1546 struct thread_data *td = cb_data_to_td(data);
1547 unsigned long long v = *__val;
1548
1549 if (parse_is_zone(v)) {
1550 td->o.zone_skip = 0;
1551 td->o.zone_skip_nz = v - ZONE_BASE_VAL;
1552 } else
1553 td->o.zone_skip = v;
1554
1555 return 0;
1556}
1557
dded427c
OS
1558static int str_write_bw_log_cb(void *data, const char *str)
1559{
1560 struct thread_data *td = cb_data_to_td(data);
1561
1562 if (str)
1563 td->o.bw_log_file = strdup(str);
1564
1565 td->o.write_bw_log = 1;
1566 return 0;
1567}
1568
1569static int str_write_lat_log_cb(void *data, const char *str)
1570{
1571 struct thread_data *td = cb_data_to_td(data);
1572
1573 if (str)
1574 td->o.lat_log_file = strdup(str);
1575
1576 td->o.write_lat_log = 1;
1577 return 0;
1578}
1579
1580static int str_write_iops_log_cb(void *data, const char *str)
1581{
1582 struct thread_data *td = cb_data_to_td(data);
1583
1584 if (str)
1585 td->o.iops_log_file = strdup(str);
1586
1587 td->o.write_iops_log = 1;
1588 return 0;
1589}
1590
1591static int str_write_hist_log_cb(void *data, const char *str)
1592{
1593 struct thread_data *td = cb_data_to_td(data);
1594
1595 if (str)
1596 td->o.hist_log_file = strdup(str);
1597
1598 td->o.write_hist_log = 1;
1599 return 0;
1600}
1601
6730b40f
TK
1602/*
1603 * str is supposed to be a substring of the strdup'd original string,
1604 * and is valid only if it's a regular file path.
1605 * This function keeps the pointer to the path as needed later.
1606 *
1607 * "external:/path/to/so\0" <- original pointer updated with strdup'd
1608 * "external\0" <- above pointer after parsed, i.e. ->ioengine
1609 * "/path/to/so\0" <- str argument, i.e. ->ioengine_so_path
1610 */
1611static int str_ioengine_external_cb(void *data, const char *str)
1612{
1613 struct thread_data *td = cb_data_to_td(data);
1614 struct stat sb;
1615 char *p;
1616
1617 if (!str) {
1618 log_err("fio: null external ioengine path\n");
1619 return 1;
1620 }
1621
1622 p = (char *)str; /* str is mutable */
1623 strip_blank_front(&p);
1624 strip_blank_end(p);
1625
1626 if (stat(p, &sb) || !S_ISREG(sb.st_mode)) {
1627 log_err("fio: invalid external ioengine path \"%s\"\n", p);
1628 return 1;
1629 }
1630
1631 td->o.ioengine_so_path = p;
1632 return 0;
1633}
1634
9109883a 1635static int rw_verify(const struct fio_option *o, void *data)
896cac2a 1636{
a609f12a 1637 struct thread_data *td = cb_data_to_td(data);
896cac2a 1638
d81d0f99
VF
1639 if (read_only && (td_write(td) || td_trim(td))) {
1640 log_err("fio: job <%s> has write or trim bit set, but"
1641 " fio is in read-only mode\n", td->o.name);
896cac2a
JA
1642 return 1;
1643 }
1644
1645 return 0;
1646}
1647
9109883a 1648static int gtod_cpu_verify(const struct fio_option *o, void *data)
29d43ff9 1649{
276ca4f7 1650#ifndef FIO_HAVE_CPU_AFFINITY
a609f12a 1651 struct thread_data *td = cb_data_to_td(data);
29d43ff9 1652
29d43ff9
JA
1653 if (td->o.gtod_cpu) {
1654 log_err("fio: platform must support CPU affinity for"
1655 "gettimeofday() offloading\n");
1656 return 1;
1657 }
1658#endif
1659
1660 return 0;
1661}
1662
214e1eca
JA
1663/*
1664 * Map of job/command line options
1665 */
9af4a244 1666struct fio_option fio_options[FIO_MAX_OPTS] = {
214e1eca
JA
1667 {
1668 .name = "description",
e8b0e958 1669 .lname = "Description of job",
214e1eca 1670 .type = FIO_OPT_STR_STORE,
a609f12a 1671 .off1 = offsetof(struct thread_options, description),
214e1eca 1672 .help = "Text job description",
e8b0e958 1673 .category = FIO_OPT_C_GENERAL,
0626037e 1674 .group = FIO_OPT_G_DESC,
214e1eca
JA
1675 },
1676 {
1677 .name = "name",
e8b0e958 1678 .lname = "Job name",
214e1eca 1679 .type = FIO_OPT_STR_STORE,
a609f12a 1680 .off1 = offsetof(struct thread_options, name),
214e1eca 1681 .help = "Name of this job",
e8b0e958 1682 .category = FIO_OPT_C_GENERAL,
0626037e 1683 .group = FIO_OPT_G_DESC,
214e1eca 1684 },
9cc8cb91
AK
1685 {
1686 .name = "wait_for",
1687 .lname = "Waitee name",
1688 .type = FIO_OPT_STR_STORE,
a609f12a 1689 .off1 = offsetof(struct thread_options, wait_for),
9cc8cb91
AK
1690 .help = "Name of the job this one wants to wait for before starting",
1691 .category = FIO_OPT_C_GENERAL,
1692 .group = FIO_OPT_G_DESC,
1693 },
214e1eca
JA
1694 {
1695 .name = "filename",
e8b0e958 1696 .lname = "Filename(s)",
214e1eca 1697 .type = FIO_OPT_STR_STORE,
a609f12a 1698 .off1 = offsetof(struct thread_options, filename),
46576743 1699 .maxlen = PATH_MAX,
214e1eca 1700 .cb = str_filename_cb,
f0d524b0 1701 .prio = -1, /* must come after "directory" */
214e1eca 1702 .help = "File(s) to use for the workload",
e8b0e958 1703 .category = FIO_OPT_C_FILE,
0626037e 1704 .group = FIO_OPT_G_FILENAME,
214e1eca 1705 },
90fef2d1 1706 {
e8b0e958
JA
1707 .name = "directory",
1708 .lname = "Directory",
1709 .type = FIO_OPT_STR_STORE,
a609f12a 1710 .off1 = offsetof(struct thread_options, directory),
e8b0e958
JA
1711 .cb = str_directory_cb,
1712 .help = "Directory to store files in",
1713 .category = FIO_OPT_C_FILE,
0626037e 1714 .group = FIO_OPT_G_FILENAME,
90fef2d1 1715 },
de98bd30
JA
1716 {
1717 .name = "filename_format",
922a5be8 1718 .lname = "Filename Format",
de98bd30 1719 .type = FIO_OPT_STR_STORE,
a609f12a 1720 .off1 = offsetof(struct thread_options, filename_format),
de98bd30
JA
1721 .prio = -1, /* must come after "directory" */
1722 .help = "Override default $jobname.$jobnum.$filenum naming",
1723 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1724 .category = FIO_OPT_C_FILE,
1725 .group = FIO_OPT_G_FILENAME,
ad705bcb 1726 },
922a5be8
JA
1727 {
1728 .name = "unique_filename",
1729 .lname = "Unique Filename",
1730 .type = FIO_OPT_BOOL,
a609f12a 1731 .off1 = offsetof(struct thread_options, unique_filename),
922a5be8
JA
1732 .help = "For network clients, prefix file with source IP",
1733 .def = "1",
1734 .category = FIO_OPT_C_FILE,
1735 .group = FIO_OPT_G_FILENAME,
1736 },
29c1349f
JA
1737 {
1738 .name = "lockfile",
e8b0e958 1739 .lname = "Lockfile",
4d4e80f2 1740 .type = FIO_OPT_STR,
a609f12a 1741 .off1 = offsetof(struct thread_options, file_lock_mode),
29c1349f 1742 .help = "Lock file when doing IO to it",
bc6a0a5d 1743 .prio = 1,
29c1349f 1744 .parent = "filename",
d71c154c 1745 .hide = 0,
4d4e80f2 1746 .def = "none",
e8b0e958 1747 .category = FIO_OPT_C_FILE,
0626037e 1748 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1749 .posval = {
1750 { .ival = "none",
1751 .oval = FILE_LOCK_NONE,
1752 .help = "No file locking",
1753 },
1754 { .ival = "exclusive",
1755 .oval = FILE_LOCK_EXCLUSIVE,
1756 .help = "Exclusive file lock",
1757 },
1758 {
1759 .ival = "readwrite",
1760 .oval = FILE_LOCK_READWRITE,
1761 .help = "Read vs write lock",
1762 },
1763 },
29c1349f 1764 },
214e1eca
JA
1765 {
1766 .name = "opendir",
e8b0e958 1767 .lname = "Open directory",
214e1eca 1768 .type = FIO_OPT_STR_STORE,
a609f12a 1769 .off1 = offsetof(struct thread_options, opendir),
214e1eca
JA
1770 .cb = str_opendir_cb,
1771 .help = "Recursively add files from this directory and down",
e8b0e958 1772 .category = FIO_OPT_C_FILE,
0626037e 1773 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1774 },
1775 {
1776 .name = "rw",
e8b0e958 1777 .lname = "Read/write",
d3aad8f2 1778 .alias = "readwrite",
214e1eca 1779 .type = FIO_OPT_STR,
211097b2 1780 .cb = str_rw_cb,
a609f12a 1781 .off1 = offsetof(struct thread_options, td_ddir),
214e1eca
JA
1782 .help = "IO direction",
1783 .def = "read",
896cac2a 1784 .verify = rw_verify,
e8b0e958 1785 .category = FIO_OPT_C_IO,
0626037e 1786 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1787 .posval = {
1788 { .ival = "read",
1789 .oval = TD_DDIR_READ,
1790 .help = "Sequential read",
1791 },
1792 { .ival = "write",
1793 .oval = TD_DDIR_WRITE,
1794 .help = "Sequential write",
1795 },
6eaf09d6
SL
1796 { .ival = "trim",
1797 .oval = TD_DDIR_TRIM,
1798 .help = "Sequential trim",
1799 },
214e1eca
JA
1800 { .ival = "randread",
1801 .oval = TD_DDIR_RANDREAD,
1802 .help = "Random read",
1803 },
1804 { .ival = "randwrite",
1805 .oval = TD_DDIR_RANDWRITE,
1806 .help = "Random write",
1807 },
6eaf09d6
SL
1808 { .ival = "randtrim",
1809 .oval = TD_DDIR_RANDTRIM,
1810 .help = "Random trim",
1811 },
214e1eca
JA
1812 { .ival = "rw",
1813 .oval = TD_DDIR_RW,
1814 .help = "Sequential read and write mix",
1815 },
10b023db
JA
1816 { .ival = "readwrite",
1817 .oval = TD_DDIR_RW,
1818 .help = "Sequential read and write mix",
1819 },
214e1eca
JA
1820 { .ival = "randrw",
1821 .oval = TD_DDIR_RANDRW,
1822 .help = "Random read and write mix"
1823 },
82a90686
JA
1824 { .ival = "trimwrite",
1825 .oval = TD_DDIR_TRIMWRITE,
1826 .help = "Trim and write mix, trims preceding writes"
0e4dd95c 1827 },
214e1eca
JA
1828 },
1829 },
38dad62d
JA
1830 {
1831 .name = "rw_sequencer",
e8b0e958 1832 .lname = "RW Sequencer",
38dad62d 1833 .type = FIO_OPT_STR,
a609f12a 1834 .off1 = offsetof(struct thread_options, rw_seq),
38dad62d
JA
1835 .help = "IO offset generator modifier",
1836 .def = "sequential",
e8b0e958 1837 .category = FIO_OPT_C_IO,
0626037e 1838 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1839 .posval = {
1840 { .ival = "sequential",
1841 .oval = RW_SEQ_SEQ,
1842 .help = "Generate sequential offsets",
1843 },
1844 { .ival = "identical",
1845 .oval = RW_SEQ_IDENT,
1846 .help = "Generate identical offsets",
1847 },
1848 },
1849 },
1850
214e1eca
JA
1851 {
1852 .name = "ioengine",
e8b0e958 1853 .lname = "IO Engine",
214e1eca 1854 .type = FIO_OPT_STR_STORE,
a609f12a 1855 .off1 = offsetof(struct thread_options, ioengine),
214e1eca 1856 .help = "IO engine to use",
58483fa4 1857 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1858 .category = FIO_OPT_C_IO,
0626037e 1859 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1860 .posval = {
1861 { .ival = "sync",
1862 .help = "Use read/write",
1863 },
a31041ea 1864 { .ival = "psync",
1865 .help = "Use pread/pwrite",
1866 },
1d2af02a 1867 { .ival = "vsync",
03e20d68 1868 .help = "Use readv/writev",
1d2af02a 1869 },
07fc0acd
JA
1870#ifdef CONFIG_PWRITEV
1871 { .ival = "pvsync",
1872 .help = "Use preadv/pwritev",
1873 },
1874#endif
6562685f 1875#ifdef FIO_HAVE_PWRITEV2
2cafffbe
JA
1876 { .ival = "pvsync2",
1877 .help = "Use preadv2/pwritev2",
1878 },
1879#endif
67bf9823 1880#ifdef CONFIG_LIBAIO
214e1eca
JA
1881 { .ival = "libaio",
1882 .help = "Linux native asynchronous IO",
1883 },
1884#endif
bffad86f
JA
1885#ifdef ARCH_HAVE_IOURING
1886 { .ival = "io_uring",
1887 .help = "Fast Linux native aio",
52885fa2
JA
1888 },
1889#endif
67bf9823 1890#ifdef CONFIG_POSIXAIO
214e1eca
JA
1891 { .ival = "posixaio",
1892 .help = "POSIX asynchronous IO",
1893 },
417f0068 1894#endif
997843cb 1895#ifdef CONFIG_SOLARISAIO
417f0068
JA
1896 { .ival = "solarisaio",
1897 .help = "Solaris native asynchronous IO",
1898 },
214e1eca 1899#endif
4700b234 1900#ifdef CONFIG_WINDOWSAIO
03e20d68 1901 { .ival = "windowsaio",
3be80071 1902 .help = "Windows native asynchronous IO"
de890a1e 1903 },
fc5c0345
DG
1904#endif
1905#ifdef CONFIG_RBD
1906 { .ival = "rbd",
1907 .help = "Rados Block Device asynchronous IO"
1908 },
3be80071 1909#endif
214e1eca 1910 { .ival = "mmap",
03e20d68 1911 .help = "Memory mapped IO"
214e1eca 1912 },
67bf9823 1913#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1914 { .ival = "splice",
1915 .help = "splice/vmsplice based IO",
1916 },
9cce02e8
JA
1917 { .ival = "netsplice",
1918 .help = "splice/vmsplice to/from the network",
1919 },
214e1eca
JA
1920#endif
1921#ifdef FIO_HAVE_SGIO
1922 { .ival = "sg",
1923 .help = "SCSI generic v3 IO",
1924 },
1925#endif
1926 { .ival = "null",
1927 .help = "Testing engine (no data transfer)",
1928 },
1929 { .ival = "net",
1930 .help = "Network IO",
1931 },
214e1eca 1932 { .ival = "cpuio",
03e20d68 1933 .help = "CPU cycle burner engine",
214e1eca 1934 },
67bf9823 1935#ifdef CONFIG_RDMA
21b8aee8 1936 { .ival = "rdma",
1937 .help = "RDMA IO engine",
1938 },
8200b8c7 1939#endif
e4c4625f
JM
1940#ifdef CONFIG_LIBRPMA_APM
1941 { .ival = "librpma_apm",
1942 .help = "librpma IO engine in APM mode",
1943 },
1944#endif
1945#ifdef CONFIG_LIBRPMA_GPSPM
1946 { .ival = "librpma_gpspm",
1947 .help = "librpma IO engine in GPSPM mode",
1948 },
1949#endif
997843cb 1950#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1951 { .ival = "e4defrag",
1952 .help = "ext4 defrag engine",
1953 },
1954#endif
997843cb 1955#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1956 { .ival = "falloc",
1957 .help = "fallocate() file based engine",
1958 },
b8c82a46 1959#endif
a7c386f4 1960#ifdef CONFIG_GFAPI
1961 { .ival = "gfapi",
cc47f094 1962 .help = "Glusterfs libgfapi(sync) based engine"
1963 },
1964 { .ival = "gfapi_async",
1965 .help = "Glusterfs libgfapi(async) based engine"
a7c386f4 1966 },
1967#endif
1b10477b 1968#ifdef CONFIG_LIBHDFS
b74e419e 1969 { .ival = "libhdfs",
1b10477b
MM
1970 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1971 },
5c4ef02e
JA
1972#endif
1973#ifdef CONFIG_PMEMBLK
1974 { .ival = "pmemblk",
363a5f65 1975 .help = "PMDK libpmemblk based IO engine",
5c4ef02e
JA
1976 },
1977
104ee4de 1978#endif
a40e7a59
GB
1979#ifdef CONFIG_IME
1980 { .ival = "ime_psync",
1981 .help = "DDN's IME synchronous IO engine",
1982 },
1983 { .ival = "ime_psyncv",
1984 .help = "DDN's IME synchronous IO engine using iovecs",
1985 },
1986 { .ival = "ime_aio",
1987 .help = "DDN's IME asynchronous IO engine",
1988 },
1989#endif
104ee4de
DJ
1990#ifdef CONFIG_LINUX_DEVDAX
1991 { .ival = "dev-dax",
1992 .help = "DAX Device based IO engine",
1993 },
1b10477b 1994#endif
edc5fa12
JA
1995 {
1996 .ival = "filecreate",
1997 .help = "File creation engine",
1998 },
214e1eca
JA
1999 { .ival = "external",
2000 .help = "Load external engine (append name)",
6730b40f 2001 .cb = str_ioengine_external_cb,
214e1eca 2002 },
ae0db592
TI
2003#ifdef CONFIG_LIBPMEM
2004 { .ival = "libpmem",
363a5f65 2005 .help = "PMDK libpmem based IO engine",
ae0db592 2006 },
c2f6a13d
LMB
2007#endif
2008#ifdef CONFIG_HTTP
2009 { .ival = "http",
2010 .help = "HTTP (WebDAV/S3) IO engine",
2011 },
ae0db592 2012#endif
d643a1e2
RJ
2013 { .ival = "nbd",
2014 .help = "Network Block Device (NBD) IO engine"
2015 },
c363fdd7
JL
2016#ifdef CONFIG_DFS
2017 { .ival = "dfs",
2018 .help = "DAOS File System (dfs) IO engine",
2019 },
9326926b
TG
2020#endif
2021#ifdef CONFIG_NFS
2022 { .ival = "nfs",
2023 .help = "NFS IO engine",
2024 },
c363fdd7 2025#endif
214e1eca
JA
2026 },
2027 },
2028 {
2029 .name = "iodepth",
e8b0e958 2030 .lname = "IO Depth",
214e1eca 2031 .type = FIO_OPT_INT,
a609f12a 2032 .off1 = offsetof(struct thread_options, iodepth),
03e20d68 2033 .help = "Number of IO buffers to keep in flight",
757aff4f 2034 .minval = 1,
20eb06bd 2035 .interval = 1,
214e1eca 2036 .def = "1",
e8b0e958 2037 .category = FIO_OPT_C_IO,
0626037e 2038 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
2039 },
2040 {
2041 .name = "iodepth_batch",
e8b0e958 2042 .lname = "IO Depth batch",
4950421a 2043 .alias = "iodepth_batch_submit",
214e1eca 2044 .type = FIO_OPT_INT,
a609f12a 2045 .off1 = offsetof(struct thread_options, iodepth_batch),
d65db441 2046 .help = "Number of IO buffers to submit in one go",
afdf9352 2047 .parent = "iodepth",
d71c154c 2048 .hide = 1,
20eb06bd 2049 .interval = 1,
a2e6f8ac 2050 .def = "1",
e8b0e958 2051 .category = FIO_OPT_C_IO,
0626037e 2052 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
2053 },
2054 {
82407585
RP
2055 .name = "iodepth_batch_complete_min",
2056 .lname = "Min IO depth batch complete",
2057 .alias = "iodepth_batch_complete",
4950421a 2058 .type = FIO_OPT_INT,
a609f12a 2059 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
82407585 2060 .help = "Min number of IO buffers to retrieve in one go",
4950421a 2061 .parent = "iodepth",
d71c154c 2062 .hide = 1,
4950421a 2063 .minval = 0,
20eb06bd 2064 .interval = 1,
4950421a 2065 .def = "1",
e8b0e958 2066 .category = FIO_OPT_C_IO,
0626037e 2067 .group = FIO_OPT_G_IO_BASIC,
214e1eca 2068 },
82407585
RP
2069 {
2070 .name = "iodepth_batch_complete_max",
2071 .lname = "Max IO depth batch complete",
2072 .type = FIO_OPT_INT,
a609f12a 2073 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
82407585
RP
2074 .help = "Max number of IO buffers to retrieve in one go",
2075 .parent = "iodepth",
2076 .hide = 1,
2077 .minval = 0,
2078 .interval = 1,
2079 .category = FIO_OPT_C_IO,
2080 .group = FIO_OPT_G_IO_BASIC,
2081 },
214e1eca
JA
2082 {
2083 .name = "iodepth_low",
e8b0e958 2084 .lname = "IO Depth batch low",
214e1eca 2085 .type = FIO_OPT_INT,
a609f12a 2086 .off1 = offsetof(struct thread_options, iodepth_low),
214e1eca 2087 .help = "Low water mark for queuing depth",
afdf9352 2088 .parent = "iodepth",
d71c154c 2089 .hide = 1,
20eb06bd 2090 .interval = 1,
e8b0e958 2091 .category = FIO_OPT_C_IO,
0626037e 2092 .group = FIO_OPT_G_IO_BASIC,
214e1eca 2093 },
997b5680
SW
2094 {
2095 .name = "serialize_overlap",
2096 .lname = "Serialize overlap",
2097 .off1 = offsetof(struct thread_options, serialize_overlap),
2098 .type = FIO_OPT_BOOL,
2099 .help = "Wait for in-flight IOs that collide to complete",
2100 .parent = "iodepth",
2101 .def = "0",
2102 .category = FIO_OPT_C_IO,
2103 .group = FIO_OPT_G_IO_BASIC,
2104 },
a9da8ab2
JA
2105 {
2106 .name = "io_submit_mode",
2107 .lname = "IO submit mode",
2108 .type = FIO_OPT_STR,
a609f12a 2109 .off1 = offsetof(struct thread_options, io_submit_mode),
a9da8ab2
JA
2110 .help = "How IO submissions and completions are done",
2111 .def = "inline",
2112 .category = FIO_OPT_C_IO,
2113 .group = FIO_OPT_G_IO_BASIC,
2114 .posval = {
2115 { .ival = "inline",
2116 .oval = IO_MODE_INLINE,
2117 .help = "Submit and complete IO inline",
2118 },
2119 { .ival = "offload",
2120 .oval = IO_MODE_OFFLOAD,
2121 .help = "Offload submit and complete to threads",
2122 },
2123 },
2124 },
214e1eca
JA
2125 {
2126 .name = "size",
e8b0e958 2127 .lname = "Size",
8f39afa7 2128 .type = FIO_OPT_STR_VAL_ZONE,
7bb59102 2129 .cb = str_size_cb,
a609f12a 2130 .off1 = offsetof(struct thread_options, size),
214e1eca 2131 .help = "Total size of device or files",
e8b0e958
JA
2132 .category = FIO_OPT_C_IO,
2133 .group = FIO_OPT_G_INVALID,
214e1eca 2134 },
77731b29 2135 {
a4d3b4db
JA
2136 .name = "io_size",
2137 .alias = "io_limit",
2138 .lname = "IO Size",
8f39afa7 2139 .type = FIO_OPT_STR_VAL_ZONE,
8b38f401 2140 .cb = str_io_size_cb,
5be9bf09 2141 .off1 = offsetof(struct thread_options, io_size),
1684f7fd 2142 .help = "Total size of I/O to be performed",
77731b29
JA
2143 .category = FIO_OPT_C_IO,
2144 .group = FIO_OPT_G_INVALID,
2145 },
aa31f1f1
SL
2146 {
2147 .name = "fill_device",
e8b0e958 2148 .lname = "Fill device",
74586c1e 2149 .alias = "fill_fs",
aa31f1f1 2150 .type = FIO_OPT_BOOL,
a609f12a 2151 .off1 = offsetof(struct thread_options, fill_device),
aa31f1f1
SL
2152 .help = "Write until an ENOSPC error occurs",
2153 .def = "0",
e8b0e958
JA
2154 .category = FIO_OPT_C_FILE,
2155 .group = FIO_OPT_G_INVALID,
aa31f1f1 2156 },
214e1eca
JA
2157 {
2158 .name = "filesize",
e8b0e958 2159 .lname = "File size",
214e1eca 2160 .type = FIO_OPT_STR_VAL,
a609f12a
JA
2161 .off1 = offsetof(struct thread_options, file_size_low),
2162 .off2 = offsetof(struct thread_options, file_size_high),
c3edbdba 2163 .minval = 1,
214e1eca 2164 .help = "Size of individual files",
20eb06bd 2165 .interval = 1024 * 1024,
e8b0e958
JA
2166 .category = FIO_OPT_C_FILE,
2167 .group = FIO_OPT_G_INVALID,
214e1eca 2168 },
bedc9dc2
JA
2169 {
2170 .name = "file_append",
2171 .lname = "File append",
2172 .type = FIO_OPT_BOOL,
a609f12a 2173 .off1 = offsetof(struct thread_options, file_append),
bedc9dc2
JA
2174 .help = "IO will start at the end of the file(s)",
2175 .def = "0",
2176 .category = FIO_OPT_C_FILE,
2177 .group = FIO_OPT_G_INVALID,
2178 },
67a1000f
JA
2179 {
2180 .name = "offset",
e8b0e958 2181 .lname = "IO offset",
67a1000f 2182 .alias = "fileoffset",
8f39afa7 2183 .type = FIO_OPT_STR_VAL_ZONE,
89978a6b 2184 .cb = str_offset_cb,
a609f12a 2185 .off1 = offsetof(struct thread_options, start_offset),
67a1000f
JA
2186 .help = "Start IO from this offset",
2187 .def = "0",
e8b0e958
JA
2188 .category = FIO_OPT_C_IO,
2189 .group = FIO_OPT_G_INVALID,
67a1000f 2190 },
83c8b093
JF
2191 {
2192 .name = "offset_align",
2193 .lname = "IO offset alignment",
2194 .type = FIO_OPT_INT,
2195 .off1 = offsetof(struct thread_options, start_offset_align),
2196 .help = "Start IO from this offset alignment",
2197 .def = "0",
2198 .interval = 512,
2199 .category = FIO_OPT_C_IO,
2200 .group = FIO_OPT_G_INVALID,
2201 },
2d7cd868
JA
2202 {
2203 .name = "offset_increment",
e8b0e958 2204 .lname = "IO offset increment",
8f39afa7 2205 .type = FIO_OPT_STR_VAL_ZONE,
0b288ba1 2206 .cb = str_offset_increment_cb,
a609f12a 2207 .off1 = offsetof(struct thread_options, offset_increment),
2d7cd868
JA
2208 .help = "What is the increment from one offset to the next",
2209 .parent = "offset",
d71c154c 2210 .hide = 1,
2d7cd868 2211 .def = "0",
e8b0e958
JA
2212 .category = FIO_OPT_C_IO,
2213 .group = FIO_OPT_G_INVALID,
2d7cd868 2214 },
ddf24e42
JA
2215 {
2216 .name = "number_ios",
2217 .lname = "Number of IOs to perform",
2218 .type = FIO_OPT_STR_VAL,
a609f12a 2219 .off1 = offsetof(struct thread_options, number_ios),
be3fec7d 2220 .help = "Force job completion after this number of IOs",
ddf24e42
JA
2221 .def = "0",
2222 .category = FIO_OPT_C_IO,
2223 .group = FIO_OPT_G_INVALID,
2224 },
214e1eca
JA
2225 {
2226 .name = "bs",
e8b0e958 2227 .lname = "Block size",
d3aad8f2 2228 .alias = "blocksize",
5fff9543 2229 .type = FIO_OPT_ULL,
a609f12a
JA
2230 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
2231 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
2232 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
c3edbdba 2233 .minval = 1,
214e1eca 2234 .help = "Block size unit",
2b9136a3 2235 .def = "4096",
67a1000f 2236 .parent = "rw",
d71c154c 2237 .hide = 1,
20eb06bd 2238 .interval = 512,
e8b0e958
JA
2239 .category = FIO_OPT_C_IO,
2240 .group = FIO_OPT_G_INVALID,
214e1eca 2241 },
2b7a01d0
JA
2242 {
2243 .name = "ba",
e8b0e958 2244 .lname = "Block size align",
2b7a01d0 2245 .alias = "blockalign",
5fff9543 2246 .type = FIO_OPT_ULL,
a609f12a
JA
2247 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
2248 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
2249 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2b7a01d0
JA
2250 .minval = 1,
2251 .help = "IO block offset alignment",
2252 .parent = "rw",
d71c154c 2253 .hide = 1,
20eb06bd 2254 .interval = 512,
e8b0e958
JA
2255 .category = FIO_OPT_C_IO,
2256 .group = FIO_OPT_G_INVALID,
2b7a01d0 2257 },
214e1eca
JA
2258 {
2259 .name = "bsrange",
e8b0e958 2260 .lname = "Block size range",
d3aad8f2 2261 .alias = "blocksize_range",
214e1eca 2262 .type = FIO_OPT_RANGE,
a609f12a
JA
2263 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
2264 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
2265 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2266 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2267 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2268 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
c3edbdba 2269 .minval = 1,
214e1eca 2270 .help = "Set block size range (in more detail than bs)",
67a1000f 2271 .parent = "rw",
d71c154c 2272 .hide = 1,
20eb06bd 2273 .interval = 4096,
e8b0e958
JA
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_INVALID,
214e1eca 2276 },
564ca972
JA
2277 {
2278 .name = "bssplit",
e8b0e958 2279 .lname = "Block size split",
5fff9543 2280 .type = FIO_OPT_STR_ULL,
564ca972 2281 .cb = str_bssplit_cb,
a609f12a 2282 .off1 = offsetof(struct thread_options, bssplit),
564ca972
JA
2283 .help = "Set a specific mix of block sizes",
2284 .parent = "rw",
d71c154c 2285 .hide = 1,
e8b0e958
JA
2286 .category = FIO_OPT_C_IO,
2287 .group = FIO_OPT_G_INVALID,
564ca972 2288 },
214e1eca
JA
2289 {
2290 .name = "bs_unaligned",
e8b0e958 2291 .lname = "Block size unaligned",
d3aad8f2 2292 .alias = "blocksize_unaligned",
214e1eca 2293 .type = FIO_OPT_STR_SET,
a609f12a 2294 .off1 = offsetof(struct thread_options, bs_unaligned),
214e1eca 2295 .help = "Don't sector align IO buffer sizes",
67a1000f 2296 .parent = "rw",
d71c154c 2297 .hide = 1,
e8b0e958
JA
2298 .category = FIO_OPT_C_IO,
2299 .group = FIO_OPT_G_INVALID,
214e1eca 2300 },
6aca9b3d
JA
2301 {
2302 .name = "bs_is_seq_rand",
2303 .lname = "Block size division is seq/random (not read/write)",
2304 .type = FIO_OPT_BOOL,
a609f12a 2305 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
86d59660 2306 .help = "Consider any blocksize setting to be sequential,random",
6aca9b3d
JA
2307 .def = "0",
2308 .parent = "blocksize",
2309 .category = FIO_OPT_C_IO,
2310 .group = FIO_OPT_G_INVALID,
2311 },
214e1eca
JA
2312 {
2313 .name = "randrepeat",
e8b0e958 2314 .lname = "Random repeatable",
214e1eca 2315 .type = FIO_OPT_BOOL,
a609f12a 2316 .off1 = offsetof(struct thread_options, rand_repeatable),
214e1eca
JA
2317 .help = "Use repeatable random IO pattern",
2318 .def = "1",
67a1000f 2319 .parent = "rw",
d71c154c 2320 .hide = 1,
e8b0e958 2321 .category = FIO_OPT_C_IO,
3ceb458f 2322 .group = FIO_OPT_G_RANDOM,
214e1eca 2323 },
04778baf
JA
2324 {
2325 .name = "randseed",
2326 .lname = "The random generator seed",
363cffa7 2327 .type = FIO_OPT_STR_VAL,
a609f12a 2328 .off1 = offsetof(struct thread_options, rand_seed),
04778baf 2329 .help = "Set the random generator seed value",
40fe5e7b 2330 .def = "0x89",
04778baf
JA
2331 .parent = "rw",
2332 .category = FIO_OPT_C_IO,
2333 .group = FIO_OPT_G_RANDOM,
2334 },
214e1eca
JA
2335 {
2336 .name = "norandommap",
e8b0e958 2337 .lname = "No randommap",
214e1eca 2338 .type = FIO_OPT_STR_SET,
a609f12a 2339 .off1 = offsetof(struct thread_options, norandommap),
214e1eca 2340 .help = "Accept potential duplicate random blocks",
67a1000f 2341 .parent = "rw",
d71c154c 2342 .hide = 1,
b2452a43 2343 .hide_on_set = 1,
e8b0e958 2344 .category = FIO_OPT_C_IO,
3ceb458f 2345 .group = FIO_OPT_G_RANDOM,
214e1eca 2346 },
2b386d25
JA
2347 {
2348 .name = "softrandommap",
e8b0e958 2349 .lname = "Soft randommap",
2b386d25 2350 .type = FIO_OPT_BOOL,
a609f12a 2351 .off1 = offsetof(struct thread_options, softrandommap),
f66ab3c8 2352 .help = "Set norandommap if randommap allocation fails",
2b386d25 2353 .parent = "norandommap",
d71c154c 2354 .hide = 1,
2b386d25 2355 .def = "0",
e8b0e958 2356 .category = FIO_OPT_C_IO,
3ceb458f 2357 .group = FIO_OPT_G_RANDOM,
2b386d25 2358 },
8055e41d
JA
2359 {
2360 .name = "random_generator",
cce2fdfe 2361 .lname = "Random Generator",
8055e41d 2362 .type = FIO_OPT_STR,
a609f12a 2363 .off1 = offsetof(struct thread_options, random_generator),
8055e41d
JA
2364 .help = "Type of random number generator to use",
2365 .def = "tausworthe",
2366 .posval = {
2367 { .ival = "tausworthe",
2368 .oval = FIO_RAND_GEN_TAUSWORTHE,
2369 .help = "Strong Tausworthe generator",
2370 },
2371 { .ival = "lfsr",
2372 .oval = FIO_RAND_GEN_LFSR,
2373 .help = "Variable length LFSR",
2374 },
c3546b53
JA
2375 {
2376 .ival = "tausworthe64",
2377 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2378 .help = "64-bit Tausworthe variant",
2379 },
8055e41d 2380 },
48107598
JA
2381 .category = FIO_OPT_C_IO,
2382 .group = FIO_OPT_G_RANDOM,
8055e41d 2383 },
e25839d4
JA
2384 {
2385 .name = "random_distribution",
cce2fdfe 2386 .lname = "Random Distribution",
e25839d4 2387 .type = FIO_OPT_STR,
a609f12a 2388 .off1 = offsetof(struct thread_options, random_distribution),
e25839d4
JA
2389 .cb = str_random_distribution_cb,
2390 .help = "Random offset distribution generator",
2391 .def = "random",
2392 .posval = {
2393 { .ival = "random",
2394 .oval = FIO_RAND_DIST_RANDOM,
2395 .help = "Completely random",
2396 },
2397 { .ival = "zipf",
2398 .oval = FIO_RAND_DIST_ZIPF,
2399 .help = "Zipf distribution",
2400 },
925fee33
JA
2401 { .ival = "pareto",
2402 .oval = FIO_RAND_DIST_PARETO,
2403 .help = "Pareto distribution",
2404 },
56d9fa4b
JA
2405 { .ival = "normal",
2406 .oval = FIO_RAND_DIST_GAUSS,
ba2b3b07 2407 .help = "Normal (Gaussian) distribution",
56d9fa4b 2408 },
e0a04ac1
JA
2409 { .ival = "zoned",
2410 .oval = FIO_RAND_DIST_ZONED,
2411 .help = "Zoned random distribution",
2412 },
59466396
JA
2413 { .ival = "zoned_abs",
2414 .oval = FIO_RAND_DIST_ZONED_ABS,
2415 .help = "Zoned absolute random distribution",
2416 },
e25839d4 2417 },
48107598
JA
2418 .category = FIO_OPT_C_IO,
2419 .group = FIO_OPT_G_RANDOM,
e25839d4 2420 },
211c9b89
JA
2421 {
2422 .name = "percentage_random",
2423 .lname = "Percentage Random",
2424 .type = FIO_OPT_INT,
a609f12a
JA
2425 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2426 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2427 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
211c9b89
JA
2428 .maxval = 100,
2429 .help = "Percentage of seq/random mix that should be random",
d9472271 2430 .def = "100,100,100",
211c9b89
JA
2431 .interval = 5,
2432 .inverse = "percentage_sequential",
2433 .category = FIO_OPT_C_IO,
2434 .group = FIO_OPT_G_RANDOM,
2435 },
2436 {
2437 .name = "percentage_sequential",
2438 .lname = "Percentage Sequential",
d9472271 2439 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
2440 .category = FIO_OPT_C_IO,
2441 .group = FIO_OPT_G_RANDOM,
2442 },
56e2a5fc
CE
2443 {
2444 .name = "allrandrepeat",
cce2fdfe 2445 .lname = "All Random Repeat",
56e2a5fc 2446 .type = FIO_OPT_BOOL,
a609f12a 2447 .off1 = offsetof(struct thread_options, allrand_repeatable),
56e2a5fc
CE
2448 .help = "Use repeatable random numbers for everything",
2449 .def = "0",
a869d9c6
JA
2450 .category = FIO_OPT_C_IO,
2451 .group = FIO_OPT_G_RANDOM,
56e2a5fc 2452 },
214e1eca
JA
2453 {
2454 .name = "nrfiles",
e8b0e958 2455 .lname = "Number of files",
d7c8be03 2456 .alias = "nr_files",
214e1eca 2457 .type = FIO_OPT_INT,
a609f12a 2458 .off1 = offsetof(struct thread_options, nr_files),
214e1eca
JA
2459 .help = "Split job workload between this number of files",
2460 .def = "1",
20eb06bd 2461 .interval = 1,
e8b0e958
JA
2462 .category = FIO_OPT_C_FILE,
2463 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2464 },
2465 {
2466 .name = "openfiles",
e8b0e958 2467 .lname = "Number of open files",
214e1eca 2468 .type = FIO_OPT_INT,
a609f12a 2469 .off1 = offsetof(struct thread_options, open_files),
214e1eca 2470 .help = "Number of files to keep open at the same time",
e8b0e958
JA
2471 .category = FIO_OPT_C_FILE,
2472 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2473 },
2474 {
2475 .name = "file_service_type",
e8b0e958 2476 .lname = "File service type",
214e1eca
JA
2477 .type = FIO_OPT_STR,
2478 .cb = str_fst_cb,
a609f12a 2479 .off1 = offsetof(struct thread_options, file_service_type),
214e1eca
JA
2480 .help = "How to select which file to service next",
2481 .def = "roundrobin",
e8b0e958
JA
2482 .category = FIO_OPT_C_FILE,
2483 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2484 .posval = {
2485 { .ival = "random",
2486 .oval = FIO_FSERVICE_RANDOM,
8c07860d
JA
2487 .help = "Choose a file at random (uniform)",
2488 },
2489 { .ival = "zipf",
2490 .oval = FIO_FSERVICE_ZIPF,
2491 .help = "Zipf randomized",
2492 },
2493 { .ival = "pareto",
2494 .oval = FIO_FSERVICE_PARETO,
2495 .help = "Pareto randomized",
2496 },
dd3503d3
SW
2497 { .ival = "normal",
2498 .oval = FIO_FSERVICE_GAUSS,
2499 .help = "Normal (Gaussian) randomized",
2500 },
8c07860d
JA
2501 { .ival = "gauss",
2502 .oval = FIO_FSERVICE_GAUSS,
dd3503d3 2503 .help = "Alias for normal",
214e1eca
JA
2504 },
2505 { .ival = "roundrobin",
2506 .oval = FIO_FSERVICE_RR,
2507 .help = "Round robin select files",
2508 },
a086c257
JA
2509 { .ival = "sequential",
2510 .oval = FIO_FSERVICE_SEQ,
2511 .help = "Finish one file before moving to the next",
2512 },
214e1eca 2513 },
67a1000f 2514 .parent = "nrfiles",
d71c154c 2515 .hide = 1,
67a1000f 2516 },
7bc8c2cf
JA
2517 {
2518 .name = "fallocate",
e8b0e958 2519 .lname = "Fallocate",
a596f047 2520 .type = FIO_OPT_STR,
a609f12a 2521 .off1 = offsetof(struct thread_options, fallocate_mode),
a596f047 2522 .help = "Whether pre-allocation is performed when laying out files",
38ca5f03 2523#ifdef FIO_HAVE_DEFAULT_FALLOCATE
2c3e17be 2524 .def = "native",
38ca5f03
TV
2525#else
2526 .def = "none",
2527#endif
e8b0e958
JA
2528 .category = FIO_OPT_C_FILE,
2529 .group = FIO_OPT_G_INVALID,
a596f047
EG
2530 .posval = {
2531 { .ival = "none",
2532 .oval = FIO_FALLOCATE_NONE,
2533 .help = "Do not pre-allocate space",
2534 },
2c3e17be
SW
2535 { .ival = "native",
2536 .oval = FIO_FALLOCATE_NATIVE,
2537 .help = "Use native pre-allocation if possible",
2538 },
2539#ifdef CONFIG_POSIX_FALLOCATE
a596f047
EG
2540 { .ival = "posix",
2541 .oval = FIO_FALLOCATE_POSIX,
2542 .help = "Use posix_fallocate()",
2543 },
2c3e17be 2544#endif
97ac992c 2545#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
2546 { .ival = "keep",
2547 .oval = FIO_FALLOCATE_KEEP_SIZE,
2548 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2549 },
7bc8c2cf 2550#endif
38ca5f03
TV
2551 { .ival = "truncate",
2552 .oval = FIO_FALLOCATE_TRUNCATE,
2553 .help = "Truncate file to final size instead of allocating"
2554 },
a596f047
EG
2555 /* Compatibility with former boolean values */
2556 { .ival = "0",
2557 .oval = FIO_FALLOCATE_NONE,
2558 .help = "Alias for 'none'",
2559 },
2c3e17be 2560#ifdef CONFIG_POSIX_FALLOCATE
a596f047
EG
2561 { .ival = "1",
2562 .oval = FIO_FALLOCATE_POSIX,
2563 .help = "Alias for 'posix'",
2564 },
2c3e17be 2565#endif
a596f047
EG
2566 },
2567 },
67a1000f
JA
2568 {
2569 .name = "fadvise_hint",
e8b0e958 2570 .lname = "Fadvise hint",
ecb2083d 2571 .type = FIO_OPT_STR,
a609f12a 2572 .off1 = offsetof(struct thread_options, fadvise_hint),
ecb2083d
JA
2573 .posval = {
2574 { .ival = "0",
2575 .oval = F_ADV_NONE,
c712c97a 2576 .help = "Don't issue fadvise/madvise",
ecb2083d
JA
2577 },
2578 { .ival = "1",
2579 .oval = F_ADV_TYPE,
2580 .help = "Advise using fio IO pattern",
2581 },
2582 { .ival = "random",
2583 .oval = F_ADV_RANDOM,
2584 .help = "Advise using FADV_RANDOM",
2585 },
2586 { .ival = "sequential",
2587 .oval = F_ADV_SEQUENTIAL,
2588 .help = "Advise using FADV_SEQUENTIAL",
2589 },
2590 },
67a1000f
JA
2591 .help = "Use fadvise() to advise the kernel on IO pattern",
2592 .def = "1",
e8b0e958
JA
2593 .category = FIO_OPT_C_FILE,
2594 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2595 },
2596 {
2597 .name = "fsync",
e8b0e958 2598 .lname = "Fsync",
214e1eca 2599 .type = FIO_OPT_INT,
a609f12a 2600 .off1 = offsetof(struct thread_options, fsync_blocks),
214e1eca
JA
2601 .help = "Issue fsync for writes every given number of blocks",
2602 .def = "0",
20eb06bd 2603 .interval = 1,
e8b0e958
JA
2604 .category = FIO_OPT_C_FILE,
2605 .group = FIO_OPT_G_INVALID,
214e1eca 2606 },
5f9099ea
JA
2607 {
2608 .name = "fdatasync",
e8b0e958 2609 .lname = "Fdatasync",
5f9099ea 2610 .type = FIO_OPT_INT,
a609f12a 2611 .off1 = offsetof(struct thread_options, fdatasync_blocks),
5f9099ea
JA
2612 .help = "Issue fdatasync for writes every given number of blocks",
2613 .def = "0",
20eb06bd 2614 .interval = 1,
e8b0e958
JA
2615 .category = FIO_OPT_C_FILE,
2616 .group = FIO_OPT_G_INVALID,
5f9099ea 2617 },
1ef2b6be
JA
2618 {
2619 .name = "write_barrier",
e8b0e958 2620 .lname = "Write barrier",
1ef2b6be 2621 .type = FIO_OPT_INT,
a609f12a 2622 .off1 = offsetof(struct thread_options, barrier_blocks),
1ef2b6be
JA
2623 .help = "Make every Nth write a barrier write",
2624 .def = "0",
20eb06bd 2625 .interval = 1,
e8b0e958
JA
2626 .category = FIO_OPT_C_IO,
2627 .group = FIO_OPT_G_INVALID,
1ef2b6be 2628 },
67bf9823 2629#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2630 {
2631 .name = "sync_file_range",
e8b0e958 2632 .lname = "Sync file range",
44f29692
JA
2633 .posval = {
2634 { .ival = "wait_before",
2635 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2636 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2637 .orval = 1,
44f29692
JA
2638 },
2639 { .ival = "write",
2640 .oval = SYNC_FILE_RANGE_WRITE,
2641 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2642 .orval = 1,
44f29692
JA
2643 },
2644 {
2645 .ival = "wait_after",
2646 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2647 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2648 .orval = 1,
44f29692
JA
2649 },
2650 },
3843deb3 2651 .type = FIO_OPT_STR_MULTI,
44f29692 2652 .cb = str_sfr_cb,
a609f12a 2653 .off1 = offsetof(struct thread_options, sync_file_range),
44f29692 2654 .help = "Use sync_file_range()",
e8b0e958
JA
2655 .category = FIO_OPT_C_FILE,
2656 .group = FIO_OPT_G_INVALID,
44f29692 2657 },
a275c37a 2658#else
54d0a315 2659 {
a275c37a
JA
2660 .name = "sync_file_range",
2661 .lname = "Sync file range",
2662 .type = FIO_OPT_UNSUPPORTED,
2663 .help = "Your platform does not support sync_file_range",
2664 },
44f29692 2665#endif
214e1eca
JA
2666 {
2667 .name = "direct",
e8b0e958 2668 .lname = "Direct I/O",
214e1eca 2669 .type = FIO_OPT_BOOL,
a609f12a 2670 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2671 .help = "Use O_DIRECT IO (negates buffered)",
2672 .def = "0",
a01a1bc5 2673 .inverse = "buffered",
e8b0e958 2674 .category = FIO_OPT_C_IO,
3ceb458f 2675 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2676 },
d01612f3
CM
2677 {
2678 .name = "atomic",
2679 .lname = "Atomic I/O",
2680 .type = FIO_OPT_BOOL,
a609f12a 2681 .off1 = offsetof(struct thread_options, oatomic),
d01612f3
CM
2682 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2683 .def = "0",
2684 .category = FIO_OPT_C_IO,
2685 .group = FIO_OPT_G_IO_TYPE,
2686 },
214e1eca
JA
2687 {
2688 .name = "buffered",
e8b0e958 2689 .lname = "Buffered I/O",
214e1eca 2690 .type = FIO_OPT_BOOL,
a609f12a 2691 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2692 .neg = 1,
2693 .help = "Use buffered IO (negates direct)",
2694 .def = "1",
a01a1bc5 2695 .inverse = "direct",
e8b0e958 2696 .category = FIO_OPT_C_IO,
3ceb458f 2697 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2698 },
2699 {
2700 .name = "overwrite",
e8b0e958 2701 .lname = "Overwrite",
214e1eca 2702 .type = FIO_OPT_BOOL,
a609f12a 2703 .off1 = offsetof(struct thread_options, overwrite),
214e1eca
JA
2704 .help = "When writing, set whether to overwrite current data",
2705 .def = "0",
e8b0e958
JA
2706 .category = FIO_OPT_C_FILE,
2707 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2708 },
2709 {
2710 .name = "loops",
e8b0e958 2711 .lname = "Loops",
214e1eca 2712 .type = FIO_OPT_INT,
a609f12a 2713 .off1 = offsetof(struct thread_options, loops),
214e1eca
JA
2714 .help = "Number of times to run the job",
2715 .def = "1",
20eb06bd 2716 .interval = 1,
e8b0e958 2717 .category = FIO_OPT_C_GENERAL,
a1f6afec 2718 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2719 },
2720 {
2721 .name = "numjobs",
e8b0e958 2722 .lname = "Number of jobs",
214e1eca 2723 .type = FIO_OPT_INT,
a609f12a 2724 .off1 = offsetof(struct thread_options, numjobs),
214e1eca
JA
2725 .help = "Duplicate this job this many times",
2726 .def = "1",
20eb06bd 2727 .interval = 1,
e8b0e958 2728 .category = FIO_OPT_C_GENERAL,
a1f6afec 2729 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2730 },
2731 {
2732 .name = "startdelay",
e8b0e958 2733 .lname = "Start delay",
a5737c93 2734 .type = FIO_OPT_STR_VAL_TIME,
a609f12a
JA
2735 .off1 = offsetof(struct thread_options, start_delay),
2736 .off2 = offsetof(struct thread_options, start_delay_high),
214e1eca
JA
2737 .help = "Only start job when this period has passed",
2738 .def = "0",
0de5b26f 2739 .is_seconds = 1,
88038bc7 2740 .is_time = 1,
e8b0e958 2741 .category = FIO_OPT_C_GENERAL,
a1f6afec 2742 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2743 },
2744 {
2745 .name = "runtime",
e8b0e958 2746 .lname = "Runtime",
214e1eca
JA
2747 .alias = "timeout",
2748 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2749 .off1 = offsetof(struct thread_options, timeout),
214e1eca
JA
2750 .help = "Stop workload when this amount of time has passed",
2751 .def = "0",
0de5b26f 2752 .is_seconds = 1,
88038bc7 2753 .is_time = 1,
e8b0e958 2754 .category = FIO_OPT_C_GENERAL,
a1f6afec 2755 .group = FIO_OPT_G_RUNTIME,
214e1eca 2756 },
cf4464ca
JA
2757 {
2758 .name = "time_based",
e8b0e958 2759 .lname = "Time based",
cf4464ca 2760 .type = FIO_OPT_STR_SET,
a609f12a 2761 .off1 = offsetof(struct thread_options, time_based),
cf4464ca 2762 .help = "Keep running until runtime/timeout is met",
e8b0e958 2763 .category = FIO_OPT_C_GENERAL,
a1f6afec 2764 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2765 },
62167762
JC
2766 {
2767 .name = "verify_only",
2768 .lname = "Verify only",
2769 .type = FIO_OPT_STR_SET,
a609f12a 2770 .off1 = offsetof(struct thread_options, verify_only),
62167762
JC
2771 .help = "Verifies previously written data is still valid",
2772 .category = FIO_OPT_C_GENERAL,
2773 .group = FIO_OPT_G_RUNTIME,
2774 },
721938ae
JA
2775 {
2776 .name = "ramp_time",
e8b0e958 2777 .lname = "Ramp time",
721938ae 2778 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2779 .off1 = offsetof(struct thread_options, ramp_time),
721938ae 2780 .help = "Ramp up time before measuring performance",
0de5b26f 2781 .is_seconds = 1,
88038bc7 2782 .is_time = 1,
e8b0e958 2783 .category = FIO_OPT_C_GENERAL,
a1f6afec 2784 .group = FIO_OPT_G_RUNTIME,
721938ae 2785 },
c223da83
JA
2786 {
2787 .name = "clocksource",
e8b0e958 2788 .lname = "Clock source",
c223da83
JA
2789 .type = FIO_OPT_STR,
2790 .cb = fio_clock_source_cb,
a609f12a 2791 .off1 = offsetof(struct thread_options, clocksource),
c223da83 2792 .help = "What type of timing source to use",
e8b0e958 2793 .category = FIO_OPT_C_GENERAL,
10860056 2794 .group = FIO_OPT_G_CLOCK,
c223da83 2795 .posval = {
67bf9823 2796#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2797 { .ival = "gettimeofday",
2798 .oval = CS_GTOD,
2799 .help = "Use gettimeofday(2) for timing",
2800 },
67bf9823
JA
2801#endif
2802#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2803 { .ival = "clock_gettime",
2804 .oval = CS_CGETTIME,
2805 .help = "Use clock_gettime(2) for timing",
2806 },
67bf9823 2807#endif
c223da83
JA
2808#ifdef ARCH_HAVE_CPU_CLOCK
2809 { .ival = "cpu",
2810 .oval = CS_CPUCLOCK,
2811 .help = "Use CPU private clock",
2812 },
2813#endif
2814 },
2815 },
214e1eca
JA
2816 {
2817 .name = "mem",
d3aad8f2 2818 .alias = "iomem",
e8b0e958 2819 .lname = "I/O Memory",
214e1eca
JA
2820 .type = FIO_OPT_STR,
2821 .cb = str_mem_cb,
a609f12a 2822 .off1 = offsetof(struct thread_options, mem_type),
214e1eca
JA
2823 .help = "Backing type for IO buffers",
2824 .def = "malloc",
e8b0e958
JA
2825 .category = FIO_OPT_C_IO,
2826 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2827 .posval = {
2828 { .ival = "malloc",
2829 .oval = MEM_MALLOC,
2830 .help = "Use malloc(3) for IO buffers",
2831 },
c8931876 2832#ifndef CONFIG_NO_SHM
37c8cdfe
JA
2833 { .ival = "shm",
2834 .oval = MEM_SHM,
2835 .help = "Use shared memory segments for IO buffers",
2836 },
214e1eca
JA
2837#ifdef FIO_HAVE_HUGETLB
2838 { .ival = "shmhuge",
2839 .oval = MEM_SHMHUGE,
2840 .help = "Like shm, but use huge pages",
2841 },
c8931876 2842#endif
b370e46a 2843#endif
37c8cdfe
JA
2844 { .ival = "mmap",
2845 .oval = MEM_MMAP,
2846 .help = "Use mmap(2) (file or anon) for IO buffers",
2847 },
217b0f1d
LG
2848 { .ival = "mmapshared",
2849 .oval = MEM_MMAPSHARED,
2850 .help = "Like mmap, but use the shared flag",
2851 },
214e1eca
JA
2852#ifdef FIO_HAVE_HUGETLB
2853 { .ival = "mmaphuge",
2854 .oval = MEM_MMAPHUGE,
2855 .help = "Like mmap, but use huge pages",
2856 },
03553853
YR
2857#endif
2858#ifdef CONFIG_CUDA
2859 { .ival = "cudamalloc",
2860 .oval = MEM_CUDA_MALLOC,
2861 .help = "Allocate GPU device memory for GPUDirect RDMA",
2862 },
214e1eca
JA
2863#endif
2864 },
2865 },
d529ee19
JA
2866 {
2867 .name = "iomem_align",
2868 .alias = "mem_align",
e8b0e958 2869 .lname = "I/O memory alignment",
d529ee19 2870 .type = FIO_OPT_INT,
a609f12a 2871 .off1 = offsetof(struct thread_options, mem_align),
d529ee19
JA
2872 .minval = 0,
2873 .help = "IO memory buffer offset alignment",
2874 .def = "0",
2875 .parent = "iomem",
d71c154c 2876 .hide = 1,
e8b0e958
JA
2877 .category = FIO_OPT_C_IO,
2878 .group = FIO_OPT_G_INVALID,
d529ee19 2879 },
214e1eca
JA
2880 {
2881 .name = "verify",
e8b0e958 2882 .lname = "Verify",
214e1eca 2883 .type = FIO_OPT_STR,
a609f12a 2884 .off1 = offsetof(struct thread_options, verify),
214e1eca
JA
2885 .help = "Verify data written",
2886 .def = "0",
e8b0e958 2887 .category = FIO_OPT_C_IO,
3ceb458f 2888 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2889 .posval = {
2890 { .ival = "0",
2891 .oval = VERIFY_NONE,
2892 .help = "Don't do IO verification",
2893 },
fcca4b58
JA
2894 { .ival = "md5",
2895 .oval = VERIFY_MD5,
2896 .help = "Use md5 checksums for verification",
2897 },
d77a7af3
JA
2898 { .ival = "crc64",
2899 .oval = VERIFY_CRC64,
2900 .help = "Use crc64 checksums for verification",
2901 },
214e1eca
JA
2902 { .ival = "crc32",
2903 .oval = VERIFY_CRC32,
2904 .help = "Use crc32 checksums for verification",
2905 },
af497e6a 2906 { .ival = "crc32c-intel",
e3aaafc4
JA
2907 .oval = VERIFY_CRC32C,
2908 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2909 },
bac39e0e
JA
2910 { .ival = "crc32c",
2911 .oval = VERIFY_CRC32C,
e3aaafc4 2912 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2913 },
969f7ed3
JA
2914 { .ival = "crc16",
2915 .oval = VERIFY_CRC16,
2916 .help = "Use crc16 checksums for verification",
2917 },
1e154bdb
JA
2918 { .ival = "crc7",
2919 .oval = VERIFY_CRC7,
2920 .help = "Use crc7 checksums for verification",
2921 },
7c353ceb
JA
2922 { .ival = "sha1",
2923 .oval = VERIFY_SHA1,
2924 .help = "Use sha1 checksums for verification",
2925 },
cd14cc10
JA
2926 { .ival = "sha256",
2927 .oval = VERIFY_SHA256,
2928 .help = "Use sha256 checksums for verification",
2929 },
2930 { .ival = "sha512",
2931 .oval = VERIFY_SHA512,
2932 .help = "Use sha512 checksums for verification",
ae3a5acc
JA
2933 },
2934 { .ival = "sha3-224",
2935 .oval = VERIFY_SHA3_224,
2936 .help = "Use sha3-224 checksums for verification",
2937 },
2938 { .ival = "sha3-256",
2939 .oval = VERIFY_SHA3_256,
2940 .help = "Use sha3-256 checksums for verification",
2941 },
2942 { .ival = "sha3-384",
2943 .oval = VERIFY_SHA3_384,
2944 .help = "Use sha3-384 checksums for verification",
2945 },
2946 { .ival = "sha3-512",
2947 .oval = VERIFY_SHA3_512,
2948 .help = "Use sha3-512 checksums for verification",
cd14cc10 2949 },
844ea602
JA
2950 { .ival = "xxhash",
2951 .oval = VERIFY_XXHASH,
2952 .help = "Use xxhash checksums for verification",
2953 },
b638d82f
RP
2954 /* Meta information was included into verify_header,
2955 * 'meta' verification is implied by default. */
7437ee87 2956 { .ival = "meta",
b638d82f
RP
2957 .oval = VERIFY_HDR_ONLY,
2958 .help = "Use io information for verification. "
2959 "Now is implied by default, thus option is obsolete, "
2960 "don't use it",
7437ee87 2961 },
59245381
JA
2962 { .ival = "pattern",
2963 .oval = VERIFY_PATTERN_NO_HDR,
2964 .help = "Verify strict pattern",
2965 },
36690c9b
JA
2966 {
2967 .ival = "null",
2968 .oval = VERIFY_NULL,
2969 .help = "Pretend to verify",
2970 },
214e1eca
JA
2971 },
2972 },
005c565a
JA
2973 {
2974 .name = "do_verify",
e8b0e958 2975 .lname = "Perform verify step",
68e1f29a 2976 .type = FIO_OPT_BOOL,
a609f12a 2977 .off1 = offsetof(struct thread_options, do_verify),
005c565a
JA
2978 .help = "Run verification stage after write",
2979 .def = "1",
2980 .parent = "verify",
d71c154c 2981 .hide = 1,
e8b0e958
JA
2982 .category = FIO_OPT_C_IO,
2983 .group = FIO_OPT_G_VERIFY,
005c565a 2984 },
160b966d
JA
2985 {
2986 .name = "verifysort",
e8b0e958 2987 .lname = "Verify sort",
f31feaa2 2988 .type = FIO_OPT_SOFT_DEPRECATED,
e8b0e958
JA
2989 .category = FIO_OPT_C_IO,
2990 .group = FIO_OPT_G_VERIFY,
160b966d 2991 },
1ae83d45
JA
2992 {
2993 .name = "verifysort_nr",
cce2fdfe 2994 .lname = "Verify Sort Nr",
f31feaa2 2995 .type = FIO_OPT_SOFT_DEPRECATED,
836fcc0f
JA
2996 .category = FIO_OPT_C_IO,
2997 .group = FIO_OPT_G_VERIFY,
1ae83d45 2998 },
3f9f4e26 2999 {
a59e170d 3000 .name = "verify_interval",
e8b0e958 3001 .lname = "Verify interval",
e01b22b8 3002 .type = FIO_OPT_INT,
a609f12a 3003 .off1 = offsetof(struct thread_options, verify_interval),
819a9680 3004 .minval = 2 * sizeof(struct verify_header),
a59e170d 3005 .help = "Store verify buffer header every N bytes",
afdf9352 3006 .parent = "verify",
d71c154c 3007 .hide = 1,
20eb06bd 3008 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
3009 .category = FIO_OPT_C_IO,
3010 .group = FIO_OPT_G_VERIFY,
3f9f4e26 3011 },
546a9142 3012 {
a59e170d 3013 .name = "verify_offset",
e8b0e958 3014 .lname = "Verify offset",
e01b22b8 3015 .type = FIO_OPT_INT,
a59e170d 3016 .help = "Offset verify header location by N bytes",
a609f12a 3017 .off1 = offsetof(struct thread_options, verify_offset),
203160d5 3018 .minval = sizeof(struct verify_header),
afdf9352 3019 .parent = "verify",
d71c154c 3020 .hide = 1,
e8b0e958
JA
3021 .category = FIO_OPT_C_IO,
3022 .group = FIO_OPT_G_VERIFY,
546a9142 3023 },
e28218f3
SL
3024 {
3025 .name = "verify_pattern",
e8b0e958 3026 .lname = "Verify pattern",
0e92f873 3027 .type = FIO_OPT_STR,
e28218f3 3028 .cb = str_verify_pattern_cb,
a609f12a 3029 .off1 = offsetof(struct thread_options, verify_pattern),
e28218f3
SL
3030 .help = "Fill pattern for IO buffers",
3031 .parent = "verify",
d71c154c 3032 .hide = 1,
e8b0e958
JA
3033 .category = FIO_OPT_C_IO,
3034 .group = FIO_OPT_G_VERIFY,
e28218f3 3035 },
a12a3b4d
JA
3036 {
3037 .name = "verify_fatal",
e8b0e958 3038 .lname = "Verify fatal",
68e1f29a 3039 .type = FIO_OPT_BOOL,
a609f12a 3040 .off1 = offsetof(struct thread_options, verify_fatal),
a12a3b4d
JA
3041 .def = "0",
3042 .help = "Exit on a single verify failure, don't continue",
3043 .parent = "verify",
d71c154c 3044 .hide = 1,
e8b0e958
JA
3045 .category = FIO_OPT_C_IO,
3046 .group = FIO_OPT_G_VERIFY,
a12a3b4d 3047 },
b463e936
JA
3048 {
3049 .name = "verify_dump",
e8b0e958 3050 .lname = "Verify dump",
b463e936 3051 .type = FIO_OPT_BOOL,
a609f12a 3052 .off1 = offsetof(struct thread_options, verify_dump),
ef71e317 3053 .def = "0",
b463e936
JA
3054 .help = "Dump contents of good and bad blocks on failure",
3055 .parent = "verify",
d71c154c 3056 .hide = 1,
e8b0e958
JA
3057 .category = FIO_OPT_C_IO,
3058 .group = FIO_OPT_G_VERIFY,
b463e936 3059 },
e8462bd8
JA
3060 {
3061 .name = "verify_async",
e8b0e958 3062 .lname = "Verify asynchronously",
e8462bd8 3063 .type = FIO_OPT_INT,
a609f12a 3064 .off1 = offsetof(struct thread_options, verify_async),
e8462bd8
JA
3065 .def = "0",
3066 .help = "Number of async verifier threads to use",
3067 .parent = "verify",
d71c154c 3068 .hide = 1,
e8b0e958
JA
3069 .category = FIO_OPT_C_IO,
3070 .group = FIO_OPT_G_VERIFY,
e8462bd8 3071 },
9e144189
JA
3072 {
3073 .name = "verify_backlog",
e8b0e958 3074 .lname = "Verify backlog",
9e144189 3075 .type = FIO_OPT_STR_VAL,
a609f12a 3076 .off1 = offsetof(struct thread_options, verify_backlog),
9e144189
JA
3077 .help = "Verify after this number of blocks are written",
3078 .parent = "verify",
d71c154c 3079 .hide = 1,
e8b0e958
JA
3080 .category = FIO_OPT_C_IO,
3081 .group = FIO_OPT_G_VERIFY,
9e144189
JA
3082 },
3083 {
3084 .name = "verify_backlog_batch",
e8b0e958 3085 .lname = "Verify backlog batch",
9e144189 3086 .type = FIO_OPT_INT,
a609f12a 3087 .off1 = offsetof(struct thread_options, verify_batch),
9e144189 3088 .help = "Verify this number of IO blocks",
0d29de83 3089 .parent = "verify",
d71c154c 3090 .hide = 1,
e8b0e958
JA
3091 .category = FIO_OPT_C_IO,
3092 .group = FIO_OPT_G_VERIFY,
9e144189 3093 },
e8462bd8
JA
3094#ifdef FIO_HAVE_CPU_AFFINITY
3095 {
3096 .name = "verify_async_cpus",
e8b0e958 3097 .lname = "Async verify CPUs",
e8462bd8
JA
3098 .type = FIO_OPT_STR,
3099 .cb = str_verify_cpus_allowed_cb,
a609f12a 3100 .off1 = offsetof(struct thread_options, verify_cpumask),
e8462bd8
JA
3101 .help = "Set CPUs allowed for async verify threads",
3102 .parent = "verify_async",
d71c154c 3103 .hide = 1,
e8b0e958
JA
3104 .category = FIO_OPT_C_IO,
3105 .group = FIO_OPT_G_VERIFY,
e8462bd8 3106 },
a275c37a
JA
3107#else
3108 {
3109 .name = "verify_async_cpus",
3110 .lname = "Async verify CPUs",
3111 .type = FIO_OPT_UNSUPPORTED,
54d0a315 3112 .help = "Your platform does not support CPU affinities",
a275c37a 3113 },
0d29de83 3114#endif
51aa2da8
JA
3115 {
3116 .name = "experimental_verify",
cce2fdfe 3117 .lname = "Experimental Verify",
a609f12a 3118 .off1 = offsetof(struct thread_options, experimental_verify),
51aa2da8 3119 .type = FIO_OPT_BOOL,
b31eaac9 3120 .help = "Enable experimental verification",
ca09be4b
JA
3121 .parent = "verify",
3122 .category = FIO_OPT_C_IO,
3123 .group = FIO_OPT_G_VERIFY,
3124 },
3125 {
3126 .name = "verify_state_load",
3127 .lname = "Load verify state",
a609f12a 3128 .off1 = offsetof(struct thread_options, verify_state),
ca09be4b
JA
3129 .type = FIO_OPT_BOOL,
3130 .help = "Load verify termination state",
3131 .parent = "verify",
3132 .category = FIO_OPT_C_IO,
3133 .group = FIO_OPT_G_VERIFY,
3134 },
3135 {
3136 .name = "verify_state_save",
3137 .lname = "Save verify state",
a609f12a 3138 .off1 = offsetof(struct thread_options, verify_state_save),
ca09be4b
JA
3139 .type = FIO_OPT_BOOL,
3140 .def = "1",
3141 .help = "Save verify state on termination",
3142 .parent = "verify",
836fcc0f
JA
3143 .category = FIO_OPT_C_IO,
3144 .group = FIO_OPT_G_VERIFY,
51aa2da8 3145 },
0d29de83
JA
3146#ifdef FIO_HAVE_TRIM
3147 {
3148 .name = "trim_percentage",
e8b0e958 3149 .lname = "Trim percentage",
0d29de83 3150 .type = FIO_OPT_INT,
a609f12a 3151 .off1 = offsetof(struct thread_options, trim_percentage),
20eb06bd 3152 .minval = 0,
0d29de83 3153 .maxval = 100,
169c098d 3154 .help = "Number of verify blocks to trim (i.e., discard)",
0d29de83
JA
3155 .parent = "verify",
3156 .def = "0",
20eb06bd 3157 .interval = 1,
d71c154c 3158 .hide = 1,
e8b0e958
JA
3159 .category = FIO_OPT_C_IO,
3160 .group = FIO_OPT_G_TRIM,
0d29de83
JA
3161 },
3162 {
3163 .name = "trim_verify_zero",
e8b0e958 3164 .lname = "Verify trim zero",
20eb06bd 3165 .type = FIO_OPT_BOOL,
169c098d 3166 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
a609f12a 3167 .off1 = offsetof(struct thread_options, trim_zero),
0d29de83 3168 .parent = "trim_percentage",
d71c154c 3169 .hide = 1,
0d29de83 3170 .def = "1",
e8b0e958
JA
3171 .category = FIO_OPT_C_IO,
3172 .group = FIO_OPT_G_TRIM,
0d29de83
JA
3173 },
3174 {
3175 .name = "trim_backlog",
e8b0e958 3176 .lname = "Trim backlog",
0d29de83 3177 .type = FIO_OPT_STR_VAL,
a609f12a 3178 .off1 = offsetof(struct thread_options, trim_backlog),
0d29de83
JA
3179 .help = "Trim after this number of blocks are written",
3180 .parent = "trim_percentage",
d71c154c 3181 .hide = 1,
20eb06bd 3182 .interval = 1,
e8b0e958
JA
3183 .category = FIO_OPT_C_IO,
3184 .group = FIO_OPT_G_TRIM,
0d29de83
JA
3185 },
3186 {
3187 .name = "trim_backlog_batch",
e8b0e958 3188 .lname = "Trim backlog batch",
0d29de83 3189 .type = FIO_OPT_INT,
a609f12a 3190 .off1 = offsetof(struct thread_options, trim_batch),
0d29de83
JA
3191 .help = "Trim this number of IO blocks",
3192 .parent = "trim_percentage",
d71c154c 3193 .hide = 1,
20eb06bd 3194 .interval = 1,
e8b0e958
JA
3195 .category = FIO_OPT_C_IO,
3196 .group = FIO_OPT_G_TRIM,
0d29de83 3197 },
a275c37a
JA
3198#else
3199 {
3200 .name = "trim_percentage",
3201 .lname = "Trim percentage",
3202 .type = FIO_OPT_UNSUPPORTED,
3203 .help = "Fio does not support TRIM on your platform",
3204 },
3205 {
3206 .name = "trim_verify_zero",
3207 .lname = "Verify trim zero",
3208 .type = FIO_OPT_UNSUPPORTED,
3209 .help = "Fio does not support TRIM on your platform",
3210 },
3211 {
3212 .name = "trim_backlog",
3213 .lname = "Trim backlog",
3214 .type = FIO_OPT_UNSUPPORTED,
3215 .help = "Fio does not support TRIM on your platform",
3216 },
3217 {
3218 .name = "trim_backlog_batch",
3219 .lname = "Trim backlog batch",
3220 .type = FIO_OPT_UNSUPPORTED,
3221 .help = "Fio does not support TRIM on your platform",
3222 },
e8462bd8 3223#endif
214e1eca
JA
3224 {
3225 .name = "write_iolog",
e8b0e958 3226 .lname = "Write I/O log",
214e1eca 3227 .type = FIO_OPT_STR_STORE,
a609f12a 3228 .off1 = offsetof(struct thread_options, write_iolog_file),
214e1eca 3229 .help = "Store IO pattern to file",
e8b0e958
JA
3230 .category = FIO_OPT_C_IO,
3231 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
3232 },
3233 {
3234 .name = "read_iolog",
e8b0e958 3235 .lname = "Read I/O log",
214e1eca 3236 .type = FIO_OPT_STR_STORE,
a609f12a 3237 .off1 = offsetof(struct thread_options, read_iolog_file),
214e1eca 3238 .help = "Playback IO pattern from file",
e8b0e958
JA
3239 .category = FIO_OPT_C_IO,
3240 .group = FIO_OPT_G_IOLOG,
214e1eca 3241 },
98e7161c
AK
3242 {
3243 .name = "read_iolog_chunked",
3244 .lname = "Read I/O log in parts",
3245 .type = FIO_OPT_BOOL,
3246 .off1 = offsetof(struct thread_options, read_iolog_chunked),
3247 .def = "0",
3248 .parent = "read_iolog",
3249 .help = "Parse IO pattern in chunks",
3250 .category = FIO_OPT_C_IO,
3251 .group = FIO_OPT_G_IOLOG,
3252 },
64bbb865
DN
3253 {
3254 .name = "replay_no_stall",
e8b0e958 3255 .lname = "Don't stall on replay",
20eb06bd 3256 .type = FIO_OPT_BOOL,
a609f12a 3257 .off1 = offsetof(struct thread_options, no_stall),
64bbb865 3258 .def = "0",
87e7a972 3259 .parent = "read_iolog",
d71c154c 3260 .hide = 1,
64bbb865 3261 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
3262 .category = FIO_OPT_C_IO,
3263 .group = FIO_OPT_G_IOLOG,
64bbb865 3264 },
d1c46c04
DN
3265 {
3266 .name = "replay_redirect",
e8b0e958 3267 .lname = "Redirect device for replay",
d1c46c04 3268 .type = FIO_OPT_STR_STORE,
a609f12a 3269 .off1 = offsetof(struct thread_options, replay_redirect),
d1c46c04 3270 .parent = "read_iolog",
d71c154c 3271 .hide = 1,
d1c46c04 3272 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
3273 .category = FIO_OPT_C_IO,
3274 .group = FIO_OPT_G_IOLOG,
d1c46c04 3275 },
0c63576e
JA
3276 {
3277 .name = "replay_scale",
3278 .lname = "Replace offset scale factor",
3279 .type = FIO_OPT_INT,
a609f12a 3280 .off1 = offsetof(struct thread_options, replay_scale),
0c63576e
JA
3281 .parent = "read_iolog",
3282 .def = "1",
3283 .help = "Align offsets to this blocksize",
3284 .category = FIO_OPT_C_IO,
3285 .group = FIO_OPT_G_IOLOG,
3286 },
3287 {
3288 .name = "replay_align",
3289 .lname = "Replace alignment",
3290 .type = FIO_OPT_INT,
a609f12a 3291 .off1 = offsetof(struct thread_options, replay_align),
0c63576e
JA
3292 .parent = "read_iolog",
3293 .help = "Scale offset down by this factor",
3294 .category = FIO_OPT_C_IO,
3295 .group = FIO_OPT_G_IOLOG,
3296 .pow2 = 1,
3297 },
6dd7fa77
JA
3298 {
3299 .name = "replay_time_scale",
3300 .lname = "Replay Time Scale",
3301 .type = FIO_OPT_INT,
3302 .off1 = offsetof(struct thread_options, replay_time_scale),
3303 .def = "100",
3304 .minval = 1,
3305 .parent = "read_iolog",
3306 .hide = 1,
3307 .help = "Scale time for replay events",
3308 .category = FIO_OPT_C_IO,
3309 .group = FIO_OPT_G_IOLOG,
3310 },
d7235efb
JA
3311 {
3312 .name = "replay_skip",
3313 .lname = "Replay Skip",
3314 .type = FIO_OPT_STR,
3315 .cb = str_replay_skip_cb,
3316 .off1 = offsetof(struct thread_options, replay_skip),
3317 .parent = "read_iolog",
3318 .help = "Skip certain IO types (read,write,trim,flush)",
3319 .category = FIO_OPT_C_IO,
3320 .group = FIO_OPT_G_IOLOG,
3321 },
b9921d1a
DZ
3322 {
3323 .name = "merge_blktrace_file",
3324 .lname = "Merged blktrace output filename",
3325 .type = FIO_OPT_STR_STORE,
3326 .off1 = offsetof(struct thread_options, merge_blktrace_file),
3327 .help = "Merged blktrace output filename",
3328 .category = FIO_OPT_C_IO,
3329 .group = FIO_OPT_G_IOLOG,
3330 },
87a48ada
DZ
3331 {
3332 .name = "merge_blktrace_scalars",
3333 .lname = "Percentage to scale each trace",
3334 .type = FIO_OPT_FLOAT_LIST,
3335 .off1 = offsetof(struct thread_options, merge_blktrace_scalars),
3336 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3337 .help = "Percentage to scale each trace",
3338 .category = FIO_OPT_C_IO,
3339 .group = FIO_OPT_G_IOLOG,
3340 },
55bfd8c8
DZ
3341 {
3342 .name = "merge_blktrace_iters",
3343 .lname = "Number of iterations to run per trace",
3344 .type = FIO_OPT_FLOAT_LIST,
3345 .off1 = offsetof(struct thread_options, merge_blktrace_iters),
3346 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3347 .help = "Number of iterations to run per trace",
3348 .category = FIO_OPT_C_IO,
3349 .group = FIO_OPT_G_IOLOG,
3350 },
214e1eca
JA
3351 {
3352 .name = "exec_prerun",
e8b0e958 3353 .lname = "Pre-execute runnable",
214e1eca 3354 .type = FIO_OPT_STR_STORE,
a609f12a 3355 .off1 = offsetof(struct thread_options, exec_prerun),
214e1eca 3356 .help = "Execute this file prior to running job",
e8b0e958
JA
3357 .category = FIO_OPT_C_GENERAL,
3358 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3359 },
3360 {
3361 .name = "exec_postrun",
e8b0e958 3362 .lname = "Post-execute runnable",
214e1eca 3363 .type = FIO_OPT_STR_STORE,
a609f12a 3364 .off1 = offsetof(struct thread_options, exec_postrun),
214e1eca 3365 .help = "Execute this file after running job",
e8b0e958
JA
3366 .category = FIO_OPT_C_GENERAL,
3367 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3368 },
3369#ifdef FIO_HAVE_IOSCHED_SWITCH
3370 {
3371 .name = "ioscheduler",
e8b0e958 3372 .lname = "I/O scheduler",
214e1eca 3373 .type = FIO_OPT_STR_STORE,
a609f12a 3374 .off1 = offsetof(struct thread_options, ioscheduler),
214e1eca 3375 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
3376 .category = FIO_OPT_C_FILE,
3377 .group = FIO_OPT_G_INVALID,
214e1eca 3378 },
a275c37a
JA
3379#else
3380 {
3381 .name = "ioscheduler",
3382 .lname = "I/O scheduler",
3383 .type = FIO_OPT_UNSUPPORTED,
3384 .help = "Your platform does not support IO scheduler switching",
3385 },
214e1eca 3386#endif
7b865a2f
BVA
3387 {
3388 .name = "zonemode",
3389 .lname = "Zone mode",
3390 .help = "Mode for the zonesize, zonerange and zoneskip parameters",
3391 .type = FIO_OPT_STR,
3392 .off1 = offsetof(struct thread_options, zone_mode),
3393 .def = "none",
3394 .category = FIO_OPT_C_IO,
3395 .group = FIO_OPT_G_ZONE,
3396 .posval = {
3397 { .ival = "none",
3398 .oval = ZONE_MODE_NONE,
3399 .help = "no zoning",
3400 },
3401 { .ival = "strided",
3402 .oval = ZONE_MODE_STRIDED,
3403 .help = "strided mode - random I/O is restricted to a single zone",
3404 },
3405 { .ival = "zbd",
3406 .oval = ZONE_MODE_ZBD,
3407 .help = "zoned block device mode - random I/O selects one of multiple zones randomly",
3408 },
3409 },
3410 },
214e1eca
JA
3411 {
3412 .name = "zonesize",
e8b0e958 3413 .lname = "Zone size",
214e1eca 3414 .type = FIO_OPT_STR_VAL,
a609f12a 3415 .off1 = offsetof(struct thread_options, zone_size),
ed335855
SN
3416 .help = "Amount of data to read per zone",
3417 .def = "0",
20eb06bd 3418 .interval = 1024 * 1024,
e8b0e958
JA
3419 .category = FIO_OPT_C_IO,
3420 .group = FIO_OPT_G_ZONE,
ed335855 3421 },
b8dd9750
HH
3422 {
3423 .name = "zonecapacity",
3424 .lname = "Zone capacity",
3425 .type = FIO_OPT_STR_VAL,
3426 .off1 = offsetof(struct thread_options, zone_capacity),
3427 .help = "Capacity per zone",
3428 .def = "0",
3429 .interval = 1024 * 1024,
3430 .category = FIO_OPT_C_IO,
3431 .group = FIO_OPT_G_ZONE,
3432 },
ed335855
SN
3433 {
3434 .name = "zonerange",
e8b0e958 3435 .lname = "Zone range",
ed335855 3436 .type = FIO_OPT_STR_VAL,
a609f12a 3437 .off1 = offsetof(struct thread_options, zone_range),
214e1eca
JA
3438 .help = "Give size of an IO zone",
3439 .def = "0",
20eb06bd 3440 .interval = 1024 * 1024,
e8b0e958
JA
3441 .category = FIO_OPT_C_IO,
3442 .group = FIO_OPT_G_ZONE,
214e1eca
JA
3443 },
3444 {
3445 .name = "zoneskip",
e8b0e958 3446 .lname = "Zone skip",
8f39afa7
AD
3447 .type = FIO_OPT_STR_VAL_ZONE,
3448 .cb = str_zoneskip_cb,
a609f12a 3449 .off1 = offsetof(struct thread_options, zone_skip),
214e1eca
JA
3450 .help = "Space between IO zones",
3451 .def = "0",
e8b0e958
JA
3452 .category = FIO_OPT_C_IO,
3453 .group = FIO_OPT_G_ZONE,
214e1eca 3454 },
bfbdd35b
BVA
3455 {
3456 .name = "read_beyond_wp",
3457 .lname = "Allow reads beyond the zone write pointer",
3458 .type = FIO_OPT_BOOL,
3459 .off1 = offsetof(struct thread_options, read_beyond_wp),
3460 .help = "Allow reads beyond the zone write pointer",
3461 .def = "0",
3462 .category = FIO_OPT_C_IO,
3463 .group = FIO_OPT_G_INVALID,
3464 },
59b07544
BVA
3465 {
3466 .name = "max_open_zones",
219c662d 3467 .lname = "Per device/file maximum number of open zones",
59b07544
BVA
3468 .type = FIO_OPT_INT,
3469 .off1 = offsetof(struct thread_options, max_open_zones),
b7694961 3470 .maxval = ZBD_MAX_OPEN_ZONES,
219c662d
AD
3471 .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd",
3472 .def = "0",
3473 .category = FIO_OPT_C_IO,
3474 .group = FIO_OPT_G_INVALID,
3475 },
3476 {
3477 .name = "job_max_open_zones",
3478 .lname = "Job maximum number of open zones",
3479 .type = FIO_OPT_INT,
3480 .off1 = offsetof(struct thread_options, job_max_open_zones),
3481 .maxval = ZBD_MAX_OPEN_ZONES,
3482 .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd by one thread/process",
59b07544
BVA
3483 .def = "0",
3484 .category = FIO_OPT_C_IO,
3485 .group = FIO_OPT_G_INVALID,
3486 },
575686bb
NC
3487 {
3488 .name = "ignore_zone_limits",
3489 .lname = "Ignore zone resource limits",
3490 .type = FIO_OPT_BOOL,
3491 .off1 = offsetof(struct thread_options, ignore_zone_limits),
3492 .def = "0",
3493 .help = "Ignore the zone resource limits (max open/active zones) reported by the device",
3494 .category = FIO_OPT_C_IO,
3495 .group = FIO_OPT_G_INVALID,
3496 },
a7c2b6fc
BVA
3497 {
3498 .name = "zone_reset_threshold",
3499 .lname = "Zone reset threshold",
3500 .help = "Zoned block device reset threshold",
3501 .type = FIO_OPT_FLOAT_LIST,
3502 .maxlen = 1,
3503 .off1 = offsetof(struct thread_options, zrt),
3504 .minfp = 0,
3505 .maxfp = 1,
3506 .category = FIO_OPT_C_IO,
3507 .group = FIO_OPT_G_ZONE,
3508 },
3509 {
3510 .name = "zone_reset_frequency",
3511 .lname = "Zone reset frequency",
3512 .help = "Zoned block device zone reset frequency in HZ",
3513 .type = FIO_OPT_FLOAT_LIST,
3514 .maxlen = 1,
3515 .off1 = offsetof(struct thread_options, zrf),
3516 .minfp = 0,
3517 .maxfp = 1,
3518 .category = FIO_OPT_C_IO,
3519 .group = FIO_OPT_G_ZONE,
3520 },
214e1eca
JA
3521 {
3522 .name = "lockmem",
e8b0e958 3523 .lname = "Lock memory",
214e1eca 3524 .type = FIO_OPT_STR_VAL,
a609f12a 3525 .off1 = offsetof(struct thread_options, lockmem),
81c6b6cd 3526 .help = "Lock down this amount of memory (per worker)",
214e1eca 3527 .def = "0",
20eb06bd 3528 .interval = 1024 * 1024,
e8b0e958
JA
3529 .category = FIO_OPT_C_GENERAL,
3530 .group = FIO_OPT_G_INVALID,
214e1eca 3531 },
214e1eca
JA
3532 {
3533 .name = "rwmixread",
e8b0e958 3534 .lname = "Read/write mix read",
214e1eca 3535 .type = FIO_OPT_INT,
cb499fc4 3536 .cb = str_rwmix_read_cb,
a609f12a 3537 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
214e1eca
JA
3538 .maxval = 100,
3539 .help = "Percentage of mixed workload that is reads",
3540 .def = "50",
20eb06bd 3541 .interval = 5,
90265353 3542 .inverse = "rwmixwrite",
e8b0e958
JA
3543 .category = FIO_OPT_C_IO,
3544 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
3545 },
3546 {
3547 .name = "rwmixwrite",
e8b0e958 3548 .lname = "Read/write mix write",
214e1eca 3549 .type = FIO_OPT_INT,
cb499fc4 3550 .cb = str_rwmix_write_cb,
a609f12a 3551 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
214e1eca
JA
3552 .maxval = 100,
3553 .help = "Percentage of mixed workload that is writes",
3554 .def = "50",
20eb06bd 3555 .interval = 5,
90265353 3556 .inverse = "rwmixread",
e8b0e958
JA
3557 .category = FIO_OPT_C_IO,
3558 .group = FIO_OPT_G_RWMIX,
214e1eca 3559 },
afdf9352
JA
3560 {
3561 .name = "rwmixcycle",
e8b0e958 3562 .lname = "Read/write mix cycle",
15ca150e 3563 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
3564 .category = FIO_OPT_C_IO,
3565 .group = FIO_OPT_G_RWMIX,
afdf9352 3566 },
214e1eca
JA
3567 {
3568 .name = "nice",
e8b0e958 3569 .lname = "Nice",
214e1eca 3570 .type = FIO_OPT_INT,
a609f12a 3571 .off1 = offsetof(struct thread_options, nice),
214e1eca 3572 .help = "Set job CPU nice value",
11fd6aa8
RC
3573 .minval = -20,
3574 .maxval = 19,
214e1eca 3575 .def = "0",
20eb06bd 3576 .interval = 1,
e8b0e958 3577 .category = FIO_OPT_C_GENERAL,
10860056 3578 .group = FIO_OPT_G_CRED,
214e1eca
JA
3579 },
3580#ifdef FIO_HAVE_IOPRIO
3581 {
3582 .name = "prio",
e8b0e958 3583 .lname = "I/O nice priority",
214e1eca 3584 .type = FIO_OPT_INT,
a609f12a 3585 .off1 = offsetof(struct thread_options, ioprio),
214e1eca 3586 .help = "Set job IO priority value",
1767bd34
TK
3587 .minval = IOPRIO_MIN_PRIO,
3588 .maxval = IOPRIO_MAX_PRIO,
20eb06bd 3589 .interval = 1,
e8b0e958 3590 .category = FIO_OPT_C_GENERAL,
10860056 3591 .group = FIO_OPT_G_CRED,
214e1eca 3592 },
32ef447a
TK
3593#else
3594 {
3595 .name = "prio",
3596 .lname = "I/O nice priority",
3597 .type = FIO_OPT_UNSUPPORTED,
3598 .help = "Your platform does not support IO priorities",
3599 },
3600#endif
3601#ifdef FIO_HAVE_IOPRIO_CLASS
3602#ifndef FIO_HAVE_IOPRIO
3603#error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3604#endif
214e1eca
JA
3605 {
3606 .name = "prioclass",
e8b0e958 3607 .lname = "I/O nice priority class",
214e1eca 3608 .type = FIO_OPT_INT,
a609f12a 3609 .off1 = offsetof(struct thread_options, ioprio_class),
214e1eca 3610 .help = "Set job IO priority class",
1767bd34
TK
3611 .minval = IOPRIO_MIN_PRIO_CLASS,
3612 .maxval = IOPRIO_MAX_PRIO_CLASS,
20eb06bd 3613 .interval = 1,
e8b0e958 3614 .category = FIO_OPT_C_GENERAL,
10860056 3615 .group = FIO_OPT_G_CRED,
214e1eca 3616 },
a275c37a 3617#else
a275c37a
JA
3618 {
3619 .name = "prioclass",
3620 .lname = "I/O nice priority class",
3621 .type = FIO_OPT_UNSUPPORTED,
32ef447a 3622 .help = "Your platform does not support IO priority classes",
a275c37a 3623 },
214e1eca
JA
3624#endif
3625 {
3626 .name = "thinktime",
e8b0e958 3627 .lname = "Thinktime",
214e1eca 3628 .type = FIO_OPT_INT,
a609f12a 3629 .off1 = offsetof(struct thread_options, thinktime),
214e1eca
JA
3630 .help = "Idle time between IO buffers (usec)",
3631 .def = "0",
88038bc7 3632 .is_time = 1,
e8b0e958 3633 .category = FIO_OPT_C_IO,
3ceb458f 3634 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3635 },
3636 {
3637 .name = "thinktime_spin",
e8b0e958 3638 .lname = "Thinktime spin",
214e1eca 3639 .type = FIO_OPT_INT,
a609f12a 3640 .off1 = offsetof(struct thread_options, thinktime_spin),
214e1eca
JA
3641 .help = "Start think time by spinning this amount (usec)",
3642 .def = "0",
88038bc7 3643 .is_time = 1,
afdf9352 3644 .parent = "thinktime",
d71c154c 3645 .hide = 1,
e8b0e958 3646 .category = FIO_OPT_C_IO,
3ceb458f 3647 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3648 },
3649 {
3650 .name = "thinktime_blocks",
e8b0e958 3651 .lname = "Thinktime blocks",
214e1eca 3652 .type = FIO_OPT_INT,
a609f12a 3653 .off1 = offsetof(struct thread_options, thinktime_blocks),
214e1eca
JA
3654 .help = "IO buffer period between 'thinktime'",
3655 .def = "1",
afdf9352 3656 .parent = "thinktime",
d71c154c 3657 .hide = 1,
e8b0e958 3658 .category = FIO_OPT_C_IO,
3ceb458f 3659 .group = FIO_OPT_G_THINKTIME,
214e1eca 3660 },
33f42c20
HQ
3661 {
3662 .name = "thinktime_blocks_type",
3663 .lname = "Thinktime blocks type",
3664 .type = FIO_OPT_STR,
3665 .off1 = offsetof(struct thread_options, thinktime_blocks_type),
3666 .help = "How thinktime_blocks takes effect",
3667 .def = "complete",
3668 .category = FIO_OPT_C_IO,
3669 .group = FIO_OPT_G_THINKTIME,
3670 .posval = {
3671 { .ival = "complete",
3672 .oval = THINKTIME_BLOCKS_TYPE_COMPLETE,
3673 .help = "thinktime_blocks takes effect at the completion side",
3674 },
3675 {
3676 .ival = "issue",
3677 .oval = THINKTIME_BLOCKS_TYPE_ISSUE,
3678 .help = "thinktime_blocks takes effect at the issue side",
3679 },
3680 },
3681 .parent = "thinktime",
3682 },
f7942acd
SK
3683 {
3684 .name = "thinktime_iotime",
3685 .lname = "Thinktime interval",
3686 .type = FIO_OPT_INT,
3687 .off1 = offsetof(struct thread_options, thinktime_iotime),
3688 .help = "IO time interval between 'thinktime'",
3689 .def = "0",
3690 .parent = "thinktime",
3691 .hide = 1,
3692 .is_seconds = 1,
3693 .is_time = 1,
3694 .category = FIO_OPT_C_IO,
3695 .group = FIO_OPT_G_THINKTIME,
3696 },
214e1eca
JA
3697 {
3698 .name = "rate",
e8b0e958 3699 .lname = "I/O rate",
140a6888 3700 .type = FIO_OPT_ULL,
a609f12a
JA
3701 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3702 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3703 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
214e1eca 3704 .help = "Set bandwidth rate",
e8b0e958
JA
3705 .category = FIO_OPT_C_IO,
3706 .group = FIO_OPT_G_RATE,
214e1eca
JA
3707 },
3708 {
6d428bcd
JA
3709 .name = "rate_min",
3710 .alias = "ratemin",
e8b0e958 3711 .lname = "I/O min rate",
140a6888 3712 .type = FIO_OPT_ULL,
a609f12a
JA
3713 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3714 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3715 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
4e991c23 3716 .help = "Job must meet this rate or it will be shutdown",
afdf9352 3717 .parent = "rate",
d71c154c 3718 .hide = 1,
e8b0e958
JA
3719 .category = FIO_OPT_C_IO,
3720 .group = FIO_OPT_G_RATE,
4e991c23
JA
3721 },
3722 {
3723 .name = "rate_iops",
e8b0e958 3724 .lname = "I/O rate IOPS",
e01b22b8 3725 .type = FIO_OPT_INT,
a609f12a
JA
3726 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3727 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3728 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
4e991c23 3729 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 3730 .hide = 1,
e8b0e958
JA
3731 .category = FIO_OPT_C_IO,
3732 .group = FIO_OPT_G_RATE,
4e991c23
JA
3733 },
3734 {
3735 .name = "rate_iops_min",
e8b0e958 3736 .lname = "I/O min rate IOPS",
e01b22b8 3737 .type = FIO_OPT_INT,
a609f12a
JA
3738 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3739 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3740 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
03e20d68 3741 .help = "Job must meet this rate or it will be shut down",
afdf9352 3742 .parent = "rate_iops",
d71c154c 3743 .hide = 1,
e8b0e958
JA
3744 .category = FIO_OPT_C_IO,
3745 .group = FIO_OPT_G_RATE,
214e1eca 3746 },
ff6bb260 3747 {
6de65959
JA
3748 .name = "rate_process",
3749 .lname = "Rate Process",
3750 .type = FIO_OPT_STR,
a609f12a 3751 .off1 = offsetof(struct thread_options, rate_process),
6de65959
JA
3752 .help = "What process controls how rated IO is managed",
3753 .def = "linear",
ff6bb260
SL
3754 .category = FIO_OPT_C_IO,
3755 .group = FIO_OPT_G_RATE,
6de65959
JA
3756 .posval = {
3757 { .ival = "linear",
3758 .oval = RATE_PROCESS_LINEAR,
3759 .help = "Linear rate of IO",
3760 },
3761 {
3762 .ival = "poisson",
3763 .oval = RATE_PROCESS_POISSON,
3764 .help = "Rate follows Poisson process",
3765 },
3766 },
3767 .parent = "rate",
ff6bb260 3768 },
214e1eca 3769 {
6d428bcd
JA
3770 .name = "rate_cycle",
3771 .alias = "ratecycle",
e8b0e958 3772 .lname = "I/O rate cycle",
214e1eca 3773 .type = FIO_OPT_INT,
a609f12a 3774 .off1 = offsetof(struct thread_options, ratecycle),
214e1eca
JA
3775 .help = "Window average for rate limits (msec)",
3776 .def = "1000",
afdf9352 3777 .parent = "rate",
d71c154c 3778 .hide = 1,
e8b0e958
JA
3779 .category = FIO_OPT_C_IO,
3780 .group = FIO_OPT_G_RATE,
214e1eca 3781 },
1a9bf814
JA
3782 {
3783 .name = "rate_ignore_thinktime",
3784 .lname = "Rate ignore thinktime",
3785 .type = FIO_OPT_BOOL,
3786 .off1 = offsetof(struct thread_options, rate_ign_think),
3787 .help = "Rated IO ignores thinktime settings",
3788 .parent = "rate",
3789 .category = FIO_OPT_C_IO,
3790 .group = FIO_OPT_G_RATE,
3791 },
15501535
JA
3792 {
3793 .name = "max_latency",
dd97d866 3794 .lname = "Max Latency (usec)",
f7cf63bf
VR
3795 .type = FIO_OPT_ULL,
3796 .off1 = offsetof(struct thread_options, max_latency[DDIR_READ]),
3797 .off2 = offsetof(struct thread_options, max_latency[DDIR_WRITE]),
3798 .off3 = offsetof(struct thread_options, max_latency[DDIR_TRIM]),
15501535 3799 .help = "Maximum tolerated IO latency (usec)",
88038bc7 3800 .is_time = 1,
1e5324e7 3801 .category = FIO_OPT_C_IO,
3e260a46
JA
3802 .group = FIO_OPT_G_LATPROF,
3803 },
3804 {
3805 .name = "latency_target",
3806 .lname = "Latency Target (usec)",
3807 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3808 .off1 = offsetof(struct thread_options, latency_target),
3e260a46 3809 .help = "Ramp to max queue depth supporting this latency",
88038bc7 3810 .is_time = 1,
3e260a46
JA
3811 .category = FIO_OPT_C_IO,
3812 .group = FIO_OPT_G_LATPROF,
3813 },
3814 {
3815 .name = "latency_window",
3816 .lname = "Latency Window (usec)",
3817 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3818 .off1 = offsetof(struct thread_options, latency_window),
3e260a46 3819 .help = "Time to sustain latency_target",
88038bc7 3820 .is_time = 1,
3e260a46
JA
3821 .category = FIO_OPT_C_IO,
3822 .group = FIO_OPT_G_LATPROF,
3823 },
3824 {
3825 .name = "latency_percentile",
3826 .lname = "Latency Percentile",
3827 .type = FIO_OPT_FLOAT_LIST,
a609f12a 3828 .off1 = offsetof(struct thread_options, latency_percentile),
3e260a46
JA
3829 .help = "Percentile of IOs must be below latency_target",
3830 .def = "100",
3831 .maxlen = 1,
3832 .minfp = 0.0,
3833 .maxfp = 100.0,
3834 .category = FIO_OPT_C_IO,
3835 .group = FIO_OPT_G_LATPROF,
15501535 3836 },
e1bcd541
SL
3837 {
3838 .name = "latency_run",
3839 .lname = "Latency Run",
3840 .type = FIO_OPT_BOOL,
3841 .off1 = offsetof(struct thread_options, latency_run),
3842 .help = "Keep adjusting queue depth to match latency_target",
3843 .def = "0",
3844 .category = FIO_OPT_C_IO,
3845 .group = FIO_OPT_G_LATPROF,
3846 },
214e1eca
JA
3847 {
3848 .name = "invalidate",
e8b0e958 3849 .lname = "Cache invalidate",
214e1eca 3850 .type = FIO_OPT_BOOL,
a609f12a 3851 .off1 = offsetof(struct thread_options, invalidate_cache),
214e1eca
JA
3852 .help = "Invalidate buffer/page cache prior to running job",
3853 .def = "1",
e8b0e958 3854 .category = FIO_OPT_C_IO,
3ceb458f 3855 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
3856 },
3857 {
3858 .name = "sync",
e8b0e958 3859 .lname = "Synchronous I/O",
eb9f8d7f 3860 .type = FIO_OPT_STR,
a609f12a 3861 .off1 = offsetof(struct thread_options, sync_io),
eb9f8d7f
AF
3862 .help = "Use synchronous write IO",
3863 .def = "none",
d71c154c 3864 .hide = 1,
e8b0e958 3865 .category = FIO_OPT_C_IO,
3ceb458f 3866 .group = FIO_OPT_G_IO_TYPE,
eb9f8d7f
AF
3867 .posval = {
3868 { .ival = "none",
3869 .oval = 0,
3870 },
3871 { .ival = "0",
3872 .oval = 0,
3873 },
3874 { .ival = "sync",
3875 .oval = O_SYNC,
3876 },
3877 { .ival = "1",
3878 .oval = O_SYNC,
3879 },
3880#ifdef O_DSYNC
3881 { .ival = "dsync",
3882 .oval = O_DSYNC,
3883 },
3884#endif
3885 },
214e1eca 3886 },
ae8e559e
JA
3887#ifdef FIO_HAVE_WRITE_HINT
3888 {
3889 .name = "write_hint",
3890 .lname = "Write hint",
3891 .type = FIO_OPT_STR,
3892 .off1 = offsetof(struct thread_options, write_hint),
3893 .help = "Set expected write life time",
3894 .category = FIO_OPT_C_ENGINE,
3895 .group = FIO_OPT_G_INVALID,
3896 .posval = {
3897 { .ival = "none",
3898 .oval = RWH_WRITE_LIFE_NONE,
3899 },
3900 { .ival = "short",
3901 .oval = RWH_WRITE_LIFE_SHORT,
3902 },
3903 { .ival = "medium",
3904 .oval = RWH_WRITE_LIFE_MEDIUM,
3905 },
3906 { .ival = "long",
3907 .oval = RWH_WRITE_LIFE_LONG,
3908 },
3909 { .ival = "extreme",
3910 .oval = RWH_WRITE_LIFE_EXTREME,
3911 },
3912 },
3913 },
3914#endif
214e1eca
JA
3915 {
3916 .name = "create_serialize",
e8b0e958 3917 .lname = "Create serialize",
214e1eca 3918 .type = FIO_OPT_BOOL,
a609f12a 3919 .off1 = offsetof(struct thread_options, create_serialize),
c2b8035f 3920 .help = "Serialize creation of job files",
214e1eca 3921 .def = "1",
e8b0e958
JA
3922 .category = FIO_OPT_C_FILE,
3923 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3924 },
3925 {
3926 .name = "create_fsync",
e8b0e958 3927 .lname = "Create fsync",
214e1eca 3928 .type = FIO_OPT_BOOL,
a609f12a 3929 .off1 = offsetof(struct thread_options, create_fsync),
03e20d68 3930 .help = "fsync file after creation",
214e1eca 3931 .def = "1",
e8b0e958
JA
3932 .category = FIO_OPT_C_FILE,
3933 .group = FIO_OPT_G_INVALID,
214e1eca 3934 },
814452bd
JA
3935 {
3936 .name = "create_on_open",
e8b0e958 3937 .lname = "Create on open",
814452bd 3938 .type = FIO_OPT_BOOL,
a609f12a 3939 .off1 = offsetof(struct thread_options, create_on_open),
814452bd
JA
3940 .help = "Create files when they are opened for IO",
3941 .def = "0",
e8b0e958
JA
3942 .category = FIO_OPT_C_FILE,
3943 .group = FIO_OPT_G_INVALID,
814452bd 3944 },
25460cf6
JA
3945 {
3946 .name = "create_only",
cce2fdfe 3947 .lname = "Create Only",
25460cf6 3948 .type = FIO_OPT_BOOL,
a609f12a 3949 .off1 = offsetof(struct thread_options, create_only),
25460cf6 3950 .help = "Only perform file creation phase",
d17fda71 3951 .category = FIO_OPT_C_FILE,
25460cf6
JA
3952 .def = "0",
3953 },
2378826d
JA
3954 {
3955 .name = "allow_file_create",
e81ecca3 3956 .lname = "Allow file create",
2378826d 3957 .type = FIO_OPT_BOOL,
a609f12a 3958 .off1 = offsetof(struct thread_options, allow_create),
2378826d
JA
3959 .help = "Permit fio to create files, if they don't exist",
3960 .def = "1",
3961 .category = FIO_OPT_C_FILE,
3962 .group = FIO_OPT_G_FILENAME,
3963 },
e81ecca3
JA
3964 {
3965 .name = "allow_mounted_write",
3966 .lname = "Allow mounted write",
3967 .type = FIO_OPT_BOOL,
a609f12a 3968 .off1 = offsetof(struct thread_options, allow_mounted_write),
e81ecca3
JA
3969 .help = "Allow writes to a mounted partition",
3970 .def = "0",
3971 .category = FIO_OPT_C_FILE,
3972 .group = FIO_OPT_G_FILENAME,
3973 },
0b9d69ec 3974 {
afad68f7 3975 .name = "pre_read",
e8b0e958 3976 .lname = "Pre-read files",
afad68f7 3977 .type = FIO_OPT_BOOL,
a609f12a 3978 .off1 = offsetof(struct thread_options, pre_read),
03e20d68 3979 .help = "Pre-read files before starting official testing",
afad68f7 3980 .def = "0",
e8b0e958
JA
3981 .category = FIO_OPT_C_FILE,
3982 .group = FIO_OPT_G_INVALID,
afad68f7 3983 },
214e1eca
JA
3984#ifdef FIO_HAVE_CPU_AFFINITY
3985 {
3986 .name = "cpumask",
e8b0e958 3987 .lname = "CPU mask",
214e1eca
JA
3988 .type = FIO_OPT_INT,
3989 .cb = str_cpumask_cb,
a609f12a 3990 .off1 = offsetof(struct thread_options, cpumask),
214e1eca 3991 .help = "CPU affinity mask",
e8b0e958 3992 .category = FIO_OPT_C_GENERAL,
10860056 3993 .group = FIO_OPT_G_CRED,
214e1eca 3994 },
d2e268b0
JA
3995 {
3996 .name = "cpus_allowed",
e8b0e958 3997 .lname = "CPUs allowed",
d2e268b0
JA
3998 .type = FIO_OPT_STR,
3999 .cb = str_cpus_allowed_cb,
a609f12a 4000 .off1 = offsetof(struct thread_options, cpumask),
d2e268b0 4001 .help = "Set CPUs allowed",
e8b0e958 4002 .category = FIO_OPT_C_GENERAL,
10860056 4003 .group = FIO_OPT_G_CRED,
d2e268b0 4004 },
c2acfbac
JA
4005 {
4006 .name = "cpus_allowed_policy",
4007 .lname = "CPUs allowed distribution policy",
4008 .type = FIO_OPT_STR,
a609f12a 4009 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
c2acfbac
JA
4010 .help = "Distribution policy for cpus_allowed",
4011 .parent = "cpus_allowed",
4012 .prio = 1,
4013 .posval = {
4014 { .ival = "shared",
4015 .oval = FIO_CPUS_SHARED,
4016 .help = "Mask shared between threads",
4017 },
4018 { .ival = "split",
4019 .oval = FIO_CPUS_SPLIT,
4020 .help = "Mask split between threads",
4021 },
4022 },
4023 .category = FIO_OPT_C_GENERAL,
4024 .group = FIO_OPT_G_CRED,
4025 },
a275c37a
JA
4026#else
4027 {
4028 .name = "cpumask",
4029 .lname = "CPU mask",
4030 .type = FIO_OPT_UNSUPPORTED,
4031 .help = "Your platform does not support CPU affinities",
4032 },
4033 {
4034 .name = "cpus_allowed",
4035 .lname = "CPUs allowed",
4036 .type = FIO_OPT_UNSUPPORTED,
4037 .help = "Your platform does not support CPU affinities",
4038 },
4039 {
4040 .name = "cpus_allowed_policy",
4041 .lname = "CPUs allowed distribution policy",
4042 .type = FIO_OPT_UNSUPPORTED,
4043 .help = "Your platform does not support CPU affinities",
4044 },
d0b937ed 4045#endif
67bf9823 4046#ifdef CONFIG_LIBNUMA
d0b937ed
YR
4047 {
4048 .name = "numa_cpu_nodes",
cce2fdfe 4049 .lname = "NUMA CPU Nodes",
d0b937ed
YR
4050 .type = FIO_OPT_STR,
4051 .cb = str_numa_cpunodes_cb,
a609f12a 4052 .off1 = offsetof(struct thread_options, numa_cpunodes),
d0b937ed 4053 .help = "NUMA CPU nodes bind",
6be54b2d
JA
4054 .category = FIO_OPT_C_GENERAL,
4055 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
4056 },
4057 {
4058 .name = "numa_mem_policy",
cce2fdfe 4059 .lname = "NUMA Memory Policy",
d0b937ed
YR
4060 .type = FIO_OPT_STR,
4061 .cb = str_numa_mpol_cb,
a609f12a 4062 .off1 = offsetof(struct thread_options, numa_memnodes),
d0b937ed 4063 .help = "NUMA memory policy setup",
6be54b2d
JA
4064 .category = FIO_OPT_C_GENERAL,
4065 .group = FIO_OPT_G_INVALID,
d0b937ed 4066 },
a275c37a
JA
4067#else
4068 {
4069 .name = "numa_cpu_nodes",
4070 .lname = "NUMA CPU Nodes",
4071 .type = FIO_OPT_UNSUPPORTED,
4072 .help = "Build fio with libnuma-dev(el) to enable this option",
4073 },
4074 {
4075 .name = "numa_mem_policy",
4076 .lname = "NUMA Memory Policy",
4077 .type = FIO_OPT_UNSUPPORTED,
4078 .help = "Build fio with libnuma-dev(el) to enable this option",
4079 },
03553853
YR
4080#endif
4081#ifdef CONFIG_CUDA
4082 {
4083 .name = "gpu_dev_id",
4084 .lname = "GPU device ID",
4085 .type = FIO_OPT_INT,
4086 .off1 = offsetof(struct thread_options, gpu_dev_id),
4087 .help = "Set GPU device ID for GPUDirect RDMA",
4088 .def = "0",
4089 .category = FIO_OPT_C_GENERAL,
4090 .group = FIO_OPT_G_INVALID,
4091 },
214e1eca
JA
4092#endif
4093 {
4094 .name = "end_fsync",
e8b0e958 4095 .lname = "End fsync",
214e1eca 4096 .type = FIO_OPT_BOOL,
a609f12a 4097 .off1 = offsetof(struct thread_options, end_fsync),
214e1eca
JA
4098 .help = "Include fsync at the end of job",
4099 .def = "0",
e8b0e958
JA
4100 .category = FIO_OPT_C_FILE,
4101 .group = FIO_OPT_G_INVALID,
214e1eca
JA
4102 },
4103 {
4104 .name = "fsync_on_close",
e8b0e958 4105 .lname = "Fsync on close",
214e1eca 4106 .type = FIO_OPT_BOOL,
a609f12a 4107 .off1 = offsetof(struct thread_options, fsync_on_close),
214e1eca
JA
4108 .help = "fsync files on close",
4109 .def = "0",
e8b0e958
JA
4110 .category = FIO_OPT_C_FILE,
4111 .group = FIO_OPT_G_INVALID,
214e1eca
JA
4112 },
4113 {
4114 .name = "unlink",
e8b0e958 4115 .lname = "Unlink file",
214e1eca 4116 .type = FIO_OPT_BOOL,
a609f12a 4117 .off1 = offsetof(struct thread_options, unlink),
214e1eca
JA
4118 .help = "Unlink created files after job has completed",
4119 .def = "0",
e8b0e958
JA
4120 .category = FIO_OPT_C_FILE,
4121 .group = FIO_OPT_G_INVALID,
214e1eca 4122 },
39c1c323 4123 {
4124 .name = "unlink_each_loop",
4125 .lname = "Unlink file after each loop of a job",
4126 .type = FIO_OPT_BOOL,
a609f12a 4127 .off1 = offsetof(struct thread_options, unlink_each_loop),
39c1c323 4128 .help = "Unlink created files after each loop in a job has completed",
4129 .def = "0",
4130 .category = FIO_OPT_C_FILE,
4131 .group = FIO_OPT_G_INVALID,
4132 },
214e1eca
JA
4133 {
4134 .name = "exitall",
e8b0e958 4135 .lname = "Exit-all on terminate",
214e1eca
JA
4136 .type = FIO_OPT_STR_SET,
4137 .cb = str_exitall_cb,
4138 .help = "Terminate all jobs when one exits",
e8b0e958 4139 .category = FIO_OPT_C_GENERAL,
a1f6afec 4140 .group = FIO_OPT_G_PROCESS,
214e1eca 4141 },
64402a8a
HW
4142 {
4143 .name = "exit_what",
4144 .lname = "What jobs to quit on terminate",
4145 .type = FIO_OPT_STR,
4146 .off1 = offsetof(struct thread_options, exit_what),
4147 .help = "Fine-grained control for exitall",
4148 .def = "group",
4149 .category = FIO_OPT_C_GENERAL,
4150 .group = FIO_OPT_G_PROCESS,
4151 .posval = {
4152 { .ival = "group",
4153 .oval = TERMINATE_GROUP,
4154 .help = "exit_all=1 default behaviour",
4155 },
4156 { .ival = "stonewall",
4157 .oval = TERMINATE_STONEWALL,
4158 .help = "quit all currently running jobs; continue with next stonewall",
4159 },
4160 { .ival = "all",
4161 .oval = TERMINATE_ALL,
4162 .help = "Quit everything",
4163 },
4164 },
4165 },
f9cafb12
JA
4166 {
4167 .name = "exitall_on_error",
4168 .lname = "Exit-all on terminate in error",
78abcf9b 4169 .type = FIO_OPT_STR_SET,
a609f12a 4170 .off1 = offsetof(struct thread_options, exitall_error),
f9cafb12
JA
4171 .help = "Terminate all jobs when one exits in error",
4172 .category = FIO_OPT_C_GENERAL,
4173 .group = FIO_OPT_G_PROCESS,
4174 },
214e1eca
JA
4175 {
4176 .name = "stonewall",
e8b0e958 4177 .lname = "Wait for previous",
d392365e 4178 .alias = "wait_for_previous",
214e1eca 4179 .type = FIO_OPT_STR_SET,
a609f12a 4180 .off1 = offsetof(struct thread_options, stonewall),
214e1eca 4181 .help = "Insert a hard barrier between this job and previous",
e8b0e958 4182 .category = FIO_OPT_C_GENERAL,
a1f6afec 4183 .group = FIO_OPT_G_PROCESS,
214e1eca 4184 },
b3d62a75
JA
4185 {
4186 .name = "new_group",
e8b0e958 4187 .lname = "New group",
b3d62a75 4188 .type = FIO_OPT_STR_SET,
a609f12a 4189 .off1 = offsetof(struct thread_options, new_group),
b3d62a75 4190 .help = "Mark the start of a new group (for reporting)",
e8b0e958 4191 .category = FIO_OPT_C_GENERAL,
a1f6afec 4192 .group = FIO_OPT_G_PROCESS,
b3d62a75 4193 },
214e1eca
JA
4194 {
4195 .name = "thread",
e8b0e958 4196 .lname = "Thread",
214e1eca 4197 .type = FIO_OPT_STR_SET,
a609f12a 4198 .off1 = offsetof(struct thread_options, use_thread),
20eb06bd 4199 .help = "Use threads instead of processes",
c8931876
JA
4200#ifdef CONFIG_NO_SHM
4201 .def = "1",
4202 .no_warn_def = 1,
4203#endif
e8b0e958 4204 .category = FIO_OPT_C_GENERAL,
a1f6afec 4205 .group = FIO_OPT_G_PROCESS,
214e1eca 4206 },
3a5db920
JA
4207 {
4208 .name = "per_job_logs",
cce2fdfe 4209 .lname = "Per Job Logs",
3a5db920 4210 .type = FIO_OPT_BOOL,
a609f12a 4211 .off1 = offsetof(struct thread_options, per_job_logs),
3a5db920
JA
4212 .help = "Include job number in generated log files or not",
4213 .def = "1",
4214 .category = FIO_OPT_C_LOG,
4215 .group = FIO_OPT_G_INVALID,
4216 },
214e1eca
JA
4217 {
4218 .name = "write_bw_log",
e8b0e958 4219 .lname = "Write bandwidth log",
dded427c 4220 .type = FIO_OPT_STR,
a609f12a 4221 .off1 = offsetof(struct thread_options, bw_log_file),
dded427c 4222 .cb = str_write_bw_log_cb,
214e1eca 4223 .help = "Write log of bandwidth during run",
e8b0e958
JA
4224 .category = FIO_OPT_C_LOG,
4225 .group = FIO_OPT_G_INVALID,
214e1eca
JA
4226 },
4227 {
4228 .name = "write_lat_log",
e8b0e958 4229 .lname = "Write latency log",
dded427c 4230 .type = FIO_OPT_STR,
a609f12a 4231 .off1 = offsetof(struct thread_options, lat_log_file),
dded427c 4232 .cb = str_write_lat_log_cb,
214e1eca 4233 .help = "Write log of latency during run",
e8b0e958
JA
4234 .category = FIO_OPT_C_LOG,
4235 .group = FIO_OPT_G_INVALID,
214e1eca 4236 },
c8eeb9df
JA
4237 {
4238 .name = "write_iops_log",
e8b0e958 4239 .lname = "Write IOPS log",
dded427c 4240 .type = FIO_OPT_STR,
a609f12a 4241 .off1 = offsetof(struct thread_options, iops_log_file),
dded427c 4242 .cb = str_write_iops_log_cb,
c8eeb9df 4243 .help = "Write log of IOPS during run",
e8b0e958
JA
4244 .category = FIO_OPT_C_LOG,
4245 .group = FIO_OPT_G_INVALID,
c8eeb9df 4246 },
b8bc8cba
JA
4247 {
4248 .name = "log_avg_msec",
e8b0e958 4249 .lname = "Log averaging (msec)",
b8bc8cba 4250 .type = FIO_OPT_INT,
a609f12a 4251 .off1 = offsetof(struct thread_options, log_avg_msec),
b8bc8cba
JA
4252 .help = "Average bw/iops/lat logs over this period of time",
4253 .def = "0",
e8b0e958 4254 .category = FIO_OPT_C_LOG,
1e613c9c
KC
4255 .group = FIO_OPT_G_INVALID,
4256 },
4257 {
4258 .name = "log_hist_msec",
4259 .lname = "Log histograms (msec)",
4260 .type = FIO_OPT_INT,
a609f12a 4261 .off1 = offsetof(struct thread_options, log_hist_msec),
1e613c9c
KC
4262 .help = "Dump completion latency histograms at frequency of this time value",
4263 .def = "0",
4264 .category = FIO_OPT_C_LOG,
4265 .group = FIO_OPT_G_INVALID,
4266 },
4267 {
4268 .name = "log_hist_coarseness",
4269 .lname = "Histogram logs coarseness",
4270 .type = FIO_OPT_INT,
a609f12a 4271 .off1 = offsetof(struct thread_options, log_hist_coarseness),
1e613c9c
KC
4272 .help = "Integer in range [0,6]. Higher coarseness outputs"
4273 " fewer histogram bins per sample. The number of bins for"
4274 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
4275 .def = "0",
4276 .category = FIO_OPT_C_LOG,
4277 .group = FIO_OPT_G_INVALID,
4278 },
4279 {
4280 .name = "write_hist_log",
4281 .lname = "Write latency histogram logs",
dded427c 4282 .type = FIO_OPT_STR,
a609f12a 4283 .off1 = offsetof(struct thread_options, hist_log_file),
dded427c 4284 .cb = str_write_hist_log_cb,
1e613c9c
KC
4285 .help = "Write log of latency histograms during run",
4286 .category = FIO_OPT_C_LOG,
e8b0e958 4287 .group = FIO_OPT_G_INVALID,
b8bc8cba 4288 },
e6989e10
JA
4289 {
4290 .name = "log_max_value",
4291 .lname = "Log maximum instead of average",
4292 .type = FIO_OPT_BOOL,
a609f12a 4293 .off1 = offsetof(struct thread_options, log_max),
e6989e10
JA
4294 .help = "Log max sample in a window instead of average",
4295 .def = "0",
4296 .category = FIO_OPT_C_LOG,
4297 .group = FIO_OPT_G_INVALID,
4298 },
ae588852
JA
4299 {
4300 .name = "log_offset",
4301 .lname = "Log offset of IO",
4302 .type = FIO_OPT_BOOL,
a609f12a 4303 .off1 = offsetof(struct thread_options, log_offset),
ae588852
JA
4304 .help = "Include offset of IO for each log entry",
4305 .def = "0",
4306 .category = FIO_OPT_C_LOG,
4307 .group = FIO_OPT_G_INVALID,
4308 },
03ec570f
DLM
4309 {
4310 .name = "log_prio",
4311 .lname = "Log priority of IO",
4312 .type = FIO_OPT_BOOL,
4313 .off1 = offsetof(struct thread_options, log_prio),
4314 .help = "Include priority value of IO for each log entry",
4315 .def = "0",
4316 .category = FIO_OPT_C_LOG,
4317 .group = FIO_OPT_G_INVALID,
4318 },
aee2ab67
JA
4319#ifdef CONFIG_ZLIB
4320 {
4321 .name = "log_compression",
4322 .lname = "Log compression",
4323 .type = FIO_OPT_INT,
a609f12a 4324 .off1 = offsetof(struct thread_options, log_gz),
aee2ab67 4325 .help = "Log in compressed chunks of this size",
9919b27b 4326 .minval = 1024ULL,
aee2ab67
JA
4327 .maxval = 512 * 1024 * 1024ULL,
4328 .category = FIO_OPT_C_LOG,
4329 .group = FIO_OPT_G_INVALID,
4330 },
c08f9fe2
JA
4331#ifdef FIO_HAVE_CPU_AFFINITY
4332 {
4333 .name = "log_compression_cpus",
4334 .lname = "Log Compression CPUs",
4335 .type = FIO_OPT_STR,
4336 .cb = str_log_cpus_allowed_cb,
a609f12a 4337 .off1 = offsetof(struct thread_options, log_gz_cpumask),
c08f9fe2
JA
4338 .parent = "log_compression",
4339 .help = "Limit log compression to these CPUs",
4340 .category = FIO_OPT_C_LOG,
4341 .group = FIO_OPT_G_INVALID,
4342 },
a275c37a
JA
4343#else
4344 {
4345 .name = "log_compression_cpus",
4346 .lname = "Log Compression CPUs",
4347 .type = FIO_OPT_UNSUPPORTED,
4348 .help = "Your platform does not support CPU affinities",
4349 },
c08f9fe2 4350#endif
b26317c9
JA
4351 {
4352 .name = "log_store_compressed",
4353 .lname = "Log store compressed",
4354 .type = FIO_OPT_BOOL,
a609f12a 4355 .off1 = offsetof(struct thread_options, log_gz_store),
b26317c9
JA
4356 .help = "Store logs in a compressed format",
4357 .category = FIO_OPT_C_LOG,
4358 .group = FIO_OPT_G_INVALID,
4359 },
a275c37a
JA
4360#else
4361 {
4362 .name = "log_compression",
4363 .lname = "Log compression",
4364 .type = FIO_OPT_UNSUPPORTED,
4365 .help = "Install libz-dev(el) to get compression support",
4366 },
4367 {
4368 .name = "log_store_compressed",
4369 .lname = "Log store compressed",
4370 .type = FIO_OPT_UNSUPPORTED,
4371 .help = "Install libz-dev(el) to get compression support",
4372 },
aee2ab67 4373#endif
3aea75b1
KC
4374 {
4375 .name = "log_unix_epoch",
4376 .lname = "Log epoch unix",
4377 .type = FIO_OPT_BOOL,
4378 .off1 = offsetof(struct thread_options, log_unix_epoch),
4379 .help = "Use Unix time in log files",
4380 .category = FIO_OPT_C_LOG,
4381 .group = FIO_OPT_G_INVALID,
4382 },
66347cfa
DE
4383 {
4384 .name = "block_error_percentiles",
4385 .lname = "Block error percentiles",
4386 .type = FIO_OPT_BOOL,
a609f12a 4387 .off1 = offsetof(struct thread_options, block_error_hist),
66347cfa
DE
4388 .help = "Record trim block errors and make a histogram",
4389 .def = "0",
4390 .category = FIO_OPT_C_LOG,
4391 .group = FIO_OPT_G_INVALID,
4392 },
c504ee55
JA
4393 {
4394 .name = "bwavgtime",
4395 .lname = "Bandwidth average time",
4396 .type = FIO_OPT_INT,
a609f12a 4397 .off1 = offsetof(struct thread_options, bw_avg_time),
c504ee55
JA
4398 .help = "Time window over which to calculate bandwidth"
4399 " (msec)",
4400 .def = "500",
4401 .parent = "write_bw_log",
4402 .hide = 1,
4403 .interval = 100,
4404 .category = FIO_OPT_C_LOG,
4405 .group = FIO_OPT_G_INVALID,
4406 },
4407 {
4408 .name = "iopsavgtime",
4409 .lname = "IOPS average time",
4410 .type = FIO_OPT_INT,
a609f12a 4411 .off1 = offsetof(struct thread_options, iops_avg_time),
c504ee55
JA
4412 .help = "Time window over which to calculate IOPS (msec)",
4413 .def = "500",
4414 .parent = "write_iops_log",
4415 .hide = 1,
4416 .interval = 100,
4417 .category = FIO_OPT_C_LOG,
4418 .group = FIO_OPT_G_INVALID,
4419 },
214e1eca
JA
4420 {
4421 .name = "group_reporting",
e8b0e958 4422 .lname = "Group reporting",
d2507043 4423 .type = FIO_OPT_STR_SET,
a609f12a 4424 .off1 = offsetof(struct thread_options, group_reporting),
214e1eca 4425 .help = "Do reporting on a per-group basis",
10860056 4426 .category = FIO_OPT_C_STAT,
e8b0e958 4427 .group = FIO_OPT_G_INVALID,
214e1eca 4428 },
8243be59
JA
4429 {
4430 .name = "stats",
4431 .lname = "Stats",
4432 .type = FIO_OPT_BOOL,
4433 .off1 = offsetof(struct thread_options, stats),
4434 .help = "Enable collection of stats",
4435 .def = "1",
4436 .category = FIO_OPT_C_STAT,
4437 .group = FIO_OPT_G_INVALID,
4438 },
e9459e5a
JA
4439 {
4440 .name = "zero_buffers",
e8b0e958 4441 .lname = "Zero I/O buffers",
e9459e5a 4442 .type = FIO_OPT_STR_SET,
a609f12a 4443 .off1 = offsetof(struct thread_options, zero_buffers),
e9459e5a 4444 .help = "Init IO buffers to all zeroes",
e8b0e958 4445 .category = FIO_OPT_C_IO,
3ceb458f 4446 .group = FIO_OPT_G_IO_BUF,
e9459e5a 4447 },
5973cafb
JA
4448 {
4449 .name = "refill_buffers",
e8b0e958 4450 .lname = "Refill I/O buffers",
5973cafb 4451 .type = FIO_OPT_STR_SET,
a609f12a 4452 .off1 = offsetof(struct thread_options, refill_buffers),
5973cafb 4453 .help = "Refill IO buffers on every IO submit",
e8b0e958 4454 .category = FIO_OPT_C_IO,
3ceb458f 4455 .group = FIO_OPT_G_IO_BUF,
5973cafb 4456 },
fd68418e
JA
4457 {
4458 .name = "scramble_buffers",
e8b0e958 4459 .lname = "Scramble I/O buffers",
fd68418e 4460 .type = FIO_OPT_BOOL,
a609f12a 4461 .off1 = offsetof(struct thread_options, scramble_buffers),
fd68418e
JA
4462 .help = "Slightly scramble buffers on every IO submit",
4463 .def = "1",
e8b0e958 4464 .category = FIO_OPT_C_IO,
3ceb458f 4465 .group = FIO_OPT_G_IO_BUF,
fd68418e 4466 },
ce35b1ec
JA
4467 {
4468 .name = "buffer_pattern",
4469 .lname = "Buffer pattern",
4470 .type = FIO_OPT_STR,
4471 .cb = str_buffer_pattern_cb,
a609f12a 4472 .off1 = offsetof(struct thread_options, buffer_pattern),
ce35b1ec
JA
4473 .help = "Fill pattern for IO buffers",
4474 .category = FIO_OPT_C_IO,
4475 .group = FIO_OPT_G_IO_BUF,
4476 },
9c42684e
JA
4477 {
4478 .name = "buffer_compress_percentage",
e8b0e958 4479 .lname = "Buffer compression percentage",
9c42684e 4480 .type = FIO_OPT_INT,
bedc9dc2 4481 .cb = str_buffer_compress_cb,
a609f12a 4482 .off1 = offsetof(struct thread_options, compress_percentage),
9c42684e 4483 .maxval = 100,
e7f5de90 4484 .minval = 0,
9c42684e 4485 .help = "How compressible the buffer is (approximately)",
20eb06bd 4486 .interval = 5,
e8b0e958 4487 .category = FIO_OPT_C_IO,
3ceb458f 4488 .group = FIO_OPT_G_IO_BUF,
9c42684e 4489 },
f97a43a1
JA
4490 {
4491 .name = "buffer_compress_chunk",
e8b0e958 4492 .lname = "Buffer compression chunk size",
f97a43a1 4493 .type = FIO_OPT_INT,
a609f12a 4494 .off1 = offsetof(struct thread_options, compress_chunk),
207b18e4 4495 .parent = "buffer_compress_percentage",
d71c154c 4496 .hide = 1,
f97a43a1 4497 .help = "Size of compressible region in buffer",
1de80624 4498 .def = "512",
20eb06bd 4499 .interval = 256,
e8b0e958 4500 .category = FIO_OPT_C_IO,
3ceb458f 4501 .group = FIO_OPT_G_IO_BUF,
f97a43a1 4502 },
5c94b008
JA
4503 {
4504 .name = "dedupe_percentage",
4505 .lname = "Dedupe percentage",
4506 .type = FIO_OPT_INT,
4507 .cb = str_dedupe_cb,
a609f12a 4508 .off1 = offsetof(struct thread_options, dedupe_percentage),
5c94b008
JA
4509 .maxval = 100,
4510 .minval = 0,
4511 .help = "Percentage of buffers that are dedupable",
4512 .interval = 1,
4513 .category = FIO_OPT_C_IO,
4514 .group = FIO_OPT_G_IO_BUF,
4515 },
0d71aa98
BD
4516 {
4517 .name = "dedupe_mode",
4518 .lname = "Dedupe mode",
4519 .help = "Mode for the deduplication buffer generation",
4520 .type = FIO_OPT_STR,
4521 .off1 = offsetof(struct thread_options, dedupe_mode),
4522 .parent = "dedupe_percentage",
4523 .def = "repeat",
4524 .category = FIO_OPT_C_IO,
4525 .group = FIO_OPT_G_IO_BUF,
4526 .posval = {
4527 { .ival = "repeat",
4528 .oval = DEDUPE_MODE_REPEAT,
4529 .help = "repeat previous page",
4530 },
4531 { .ival = "working_set",
4532 .oval = DEDUPE_MODE_WORKING_SET,
4533 .help = "choose a page randomly from limited working set defined in dedupe_working_set_percentage",
4534 },
4535 },
4536 },
4537 {
4538 .name = "dedupe_working_set_percentage",
4539 .lname = "Dedupe working set percentage",
4540 .help = "Dedupe working set size in percentages from file or device size used to generate dedupe patterns from",
4541 .type = FIO_OPT_INT,
4542 .off1 = offsetof(struct thread_options, dedupe_working_set_percentage),
4543 .parent = "dedupe_percentage",
4544 .def = "5",
4545 .maxval = 100,
4546 .minval = 0,
4547 .category = FIO_OPT_C_IO,
4548 .group = FIO_OPT_G_IO_BUF,
4549 },
83349190
YH
4550 {
4551 .name = "clat_percentiles",
e8b0e958 4552 .lname = "Completion latency percentiles",
83349190 4553 .type = FIO_OPT_BOOL,
a609f12a 4554 .off1 = offsetof(struct thread_options, clat_percentiles),
83349190 4555 .help = "Enable the reporting of completion latency percentiles",
467b35ed 4556 .def = "1",
b599759b
JA
4557 .category = FIO_OPT_C_STAT,
4558 .group = FIO_OPT_G_INVALID,
4559 },
4560 {
4561 .name = "lat_percentiles",
4562 .lname = "IO latency percentiles",
4563 .type = FIO_OPT_BOOL,
4564 .off1 = offsetof(struct thread_options, lat_percentiles),
4565 .help = "Enable the reporting of IO latency percentiles",
4566 .def = "0",
56440e63
VF
4567 .category = FIO_OPT_C_STAT,
4568 .group = FIO_OPT_G_INVALID,
4569 },
4570 {
4571 .name = "slat_percentiles",
4572 .lname = "Submission latency percentiles",
4573 .type = FIO_OPT_BOOL,
4574 .off1 = offsetof(struct thread_options, slat_percentiles),
4575 .help = "Enable the reporting of submission latency percentiles",
4576 .def = "0",
e8b0e958
JA
4577 .category = FIO_OPT_C_STAT,
4578 .group = FIO_OPT_G_INVALID,
83349190
YH
4579 },
4580 {
4581 .name = "percentile_list",
66347cfa 4582 .lname = "Percentile list",
83349190 4583 .type = FIO_OPT_FLOAT_LIST,
a609f12a
JA
4584 .off1 = offsetof(struct thread_options, percentile_list),
4585 .off2 = offsetof(struct thread_options, percentile_precision),
66347cfa
DE
4586 .help = "Specify a custom list of percentiles to report for "
4587 "completion latency and block errors",
fd112d34 4588 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
4589 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4590 .minfp = 0.0,
4591 .maxfp = 100.0,
e8b0e958
JA
4592 .category = FIO_OPT_C_STAT,
4593 .group = FIO_OPT_G_INVALID,
e883cb35
JF
4594 },
4595 {
4596 .name = "significant_figures",
4597 .lname = "Significant figures",
4598 .type = FIO_OPT_INT,
4599 .off1 = offsetof(struct thread_options, sig_figs),
4600 .maxval = 10,
4601 .minval = 1,
4602 .help = "Significant figures for output-format set to normal",
4603 .def = "4",
4604 .interval = 1,
4605 .category = FIO_OPT_C_STAT,
4606 .group = FIO_OPT_G_INVALID,
83349190
YH
4607 },
4608
0a839f30
JA
4609#ifdef FIO_HAVE_DISK_UTIL
4610 {
4611 .name = "disk_util",
e8b0e958 4612 .lname = "Disk utilization",
0a839f30 4613 .type = FIO_OPT_BOOL,
a609f12a 4614 .off1 = offsetof(struct thread_options, do_disk_util),
f66ab3c8 4615 .help = "Log disk utilization statistics",
0a839f30 4616 .def = "1",
e8b0e958
JA
4617 .category = FIO_OPT_C_STAT,
4618 .group = FIO_OPT_G_INVALID,
0a839f30 4619 },
a275c37a
JA
4620#else
4621 {
4622 .name = "disk_util",
4623 .lname = "Disk utilization",
4624 .type = FIO_OPT_UNSUPPORTED,
4625 .help = "Your platform does not support disk utilization",
4626 },
0a839f30 4627#endif
993bf48b
JA
4628 {
4629 .name = "gtod_reduce",
e8b0e958 4630 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
4631 .type = FIO_OPT_BOOL,
4632 .help = "Greatly reduce number of gettimeofday() calls",
4633 .cb = str_gtod_reduce_cb,
4634 .def = "0",
a4ed77fe 4635 .hide_on_set = 1,
e8b0e958
JA
4636 .category = FIO_OPT_C_STAT,
4637 .group = FIO_OPT_G_INVALID,
993bf48b 4638 },
02af0988
JA
4639 {
4640 .name = "disable_lat",
e8b0e958 4641 .lname = "Disable all latency stats",
02af0988 4642 .type = FIO_OPT_BOOL,
a609f12a 4643 .off1 = offsetof(struct thread_options, disable_lat),
02af0988
JA
4644 .help = "Disable latency numbers",
4645 .parent = "gtod_reduce",
d71c154c 4646 .hide = 1,
02af0988 4647 .def = "0",
e8b0e958
JA
4648 .category = FIO_OPT_C_STAT,
4649 .group = FIO_OPT_G_INVALID,
02af0988 4650 },
9520ebb9
JA
4651 {
4652 .name = "disable_clat",
e8b0e958 4653 .lname = "Disable completion latency stats",
9520ebb9 4654 .type = FIO_OPT_BOOL,
a609f12a 4655 .off1 = offsetof(struct thread_options, disable_clat),
9520ebb9 4656 .help = "Disable completion latency numbers",
993bf48b 4657 .parent = "gtod_reduce",
d71c154c 4658 .hide = 1,
9520ebb9 4659 .def = "0",
e8b0e958
JA
4660 .category = FIO_OPT_C_STAT,
4661 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
4662 },
4663 {
4664 .name = "disable_slat",
e8b0e958 4665 .lname = "Disable submission latency stats",
9520ebb9 4666 .type = FIO_OPT_BOOL,
a609f12a 4667 .off1 = offsetof(struct thread_options, disable_slat),
03e20d68 4668 .help = "Disable submission latency numbers",
993bf48b 4669 .parent = "gtod_reduce",
d71c154c 4670 .hide = 1,
9520ebb9 4671 .def = "0",
e8b0e958
JA
4672 .category = FIO_OPT_C_STAT,
4673 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
4674 },
4675 {
4676 .name = "disable_bw_measurement",
afd2ceff 4677 .alias = "disable_bw",
e8b0e958 4678 .lname = "Disable bandwidth stats",
9520ebb9 4679 .type = FIO_OPT_BOOL,
a609f12a 4680 .off1 = offsetof(struct thread_options, disable_bw),
9520ebb9 4681 .help = "Disable bandwidth logging",
993bf48b 4682 .parent = "gtod_reduce",
d71c154c 4683 .hide = 1,
9520ebb9 4684 .def = "0",
e8b0e958
JA
4685 .category = FIO_OPT_C_STAT,
4686 .group = FIO_OPT_G_INVALID,
9520ebb9 4687 },
be4ecfdf
JA
4688 {
4689 .name = "gtod_cpu",
e8b0e958 4690 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf 4691 .type = FIO_OPT_INT,
a609f12a 4692 .off1 = offsetof(struct thread_options, gtod_cpu),
03e20d68 4693 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 4694 .verify = gtod_cpu_verify,
e8b0e958 4695 .category = FIO_OPT_C_GENERAL,
10860056 4696 .group = FIO_OPT_G_CLOCK,
be4ecfdf 4697 },
771e58be
JA
4698 {
4699 .name = "unified_rw_reporting",
cce2fdfe 4700 .lname = "Unified RW Reporting",
5cb8a8cd 4701 .type = FIO_OPT_STR,
a609f12a 4702 .off1 = offsetof(struct thread_options, unified_rw_rep),
771e58be 4703 .help = "Unify reporting across data direction",
5cb8a8cd 4704 .def = "none",
90b7a96d
JA
4705 .category = FIO_OPT_C_GENERAL,
4706 .group = FIO_OPT_G_INVALID,
5cb8a8cd
BP
4707 .posval = {
4708 { .ival = "none",
4709 .oval = UNIFIED_SPLIT,
4710 .help = "Normal statistics reporting",
4711 },
4712 { .ival = "mixed",
4713 .oval = UNIFIED_MIXED,
4714 .help = "Statistics are summed per data direction and reported together",
4715 },
4716 { .ival = "both",
4717 .oval = UNIFIED_BOTH,
4718 .help = "Statistics are reported normally, followed by the mixed statistics"
4719 },
4720 /* Compatibility with former boolean values */
4721 { .ival = "0",
4722 .oval = UNIFIED_SPLIT,
4723 .help = "Alias for 'none'",
4724 },
4725 { .ival = "1",
4726 .oval = UNIFIED_MIXED,
4727 .help = "Alias for 'mixed'",
4728 },
4729 { .ival = "2",
4730 .oval = UNIFIED_BOTH,
4731 .help = "Alias for 'both'",
4732 },
4733 },
771e58be 4734 },
f2bba182
RR
4735 {
4736 .name = "continue_on_error",
e8b0e958 4737 .lname = "Continue on error",
06842027 4738 .type = FIO_OPT_STR,
a609f12a 4739 .off1 = offsetof(struct thread_options, continue_on_error),
03e20d68 4740 .help = "Continue on non-fatal errors during IO",
06842027 4741 .def = "none",
e8b0e958 4742 .category = FIO_OPT_C_GENERAL,
bc3f552f 4743 .group = FIO_OPT_G_ERR,
06842027
SL
4744 .posval = {
4745 { .ival = "none",
4746 .oval = ERROR_TYPE_NONE,
4747 .help = "Exit when an error is encountered",
4748 },
4749 { .ival = "read",
4750 .oval = ERROR_TYPE_READ,
4751 .help = "Continue on read errors only",
4752 },
4753 { .ival = "write",
4754 .oval = ERROR_TYPE_WRITE,
4755 .help = "Continue on write errors only",
4756 },
4757 { .ival = "io",
4758 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4759 .help = "Continue on any IO errors",
4760 },
4761 { .ival = "verify",
4762 .oval = ERROR_TYPE_VERIFY,
4763 .help = "Continue on verify errors only",
4764 },
4765 { .ival = "all",
4766 .oval = ERROR_TYPE_ANY,
4767 .help = "Continue on all io and verify errors",
4768 },
4769 { .ival = "0",
4770 .oval = ERROR_TYPE_NONE,
4771 .help = "Alias for 'none'",
4772 },
4773 { .ival = "1",
4774 .oval = ERROR_TYPE_ANY,
4775 .help = "Alias for 'all'",
4776 },
4777 },
f2bba182 4778 },
8b28bd41
DM
4779 {
4780 .name = "ignore_error",
cce2fdfe 4781 .lname = "Ignore Error",
8b28bd41
DM
4782 .type = FIO_OPT_STR,
4783 .cb = str_ignore_error_cb,
a609f12a 4784 .off1 = offsetof(struct thread_options, ignore_error_nr),
8b28bd41
DM
4785 .help = "Set a specific list of errors to ignore",
4786 .parent = "rw",
a94eb99a 4787 .category = FIO_OPT_C_GENERAL,
bc3f552f 4788 .group = FIO_OPT_G_ERR,
8b28bd41
DM
4789 },
4790 {
4791 .name = "error_dump",
cce2fdfe 4792 .lname = "Error Dump",
8b28bd41 4793 .type = FIO_OPT_BOOL,
a609f12a 4794 .off1 = offsetof(struct thread_options, error_dump),
8b28bd41
DM
4795 .def = "0",
4796 .help = "Dump info on each error",
a94eb99a 4797 .category = FIO_OPT_C_GENERAL,
bc3f552f 4798 .group = FIO_OPT_G_ERR,
8b28bd41 4799 },
9ac8a797
JA
4800 {
4801 .name = "profile",
e8b0e958 4802 .lname = "Profile",
79d16311 4803 .type = FIO_OPT_STR_STORE,
a609f12a 4804 .off1 = offsetof(struct thread_options, profile),
9ac8a797 4805 .help = "Select a specific builtin performance test",
13fca827 4806 .category = FIO_OPT_C_PROFILE,
e8b0e958 4807 .group = FIO_OPT_G_INVALID,
9ac8a797 4808 },
a696fa2a
JA
4809 {
4810 .name = "cgroup",
e8b0e958 4811 .lname = "Cgroup",
a696fa2a 4812 .type = FIO_OPT_STR_STORE,
a609f12a 4813 .off1 = offsetof(struct thread_options, cgroup),
a696fa2a 4814 .help = "Add job to cgroup of this name",
e8b0e958 4815 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
4816 .group = FIO_OPT_G_CGROUP,
4817 },
4818 {
4819 .name = "cgroup_nodelete",
4820 .lname = "Cgroup no-delete",
4821 .type = FIO_OPT_BOOL,
a609f12a 4822 .off1 = offsetof(struct thread_options, cgroup_nodelete),
a1f6afec
JA
4823 .help = "Do not delete cgroups after job completion",
4824 .def = "0",
4825 .parent = "cgroup",
4826 .category = FIO_OPT_C_GENERAL,
4827 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
4828 },
4829 {
4830 .name = "cgroup_weight",
e8b0e958 4831 .lname = "Cgroup weight",
a696fa2a 4832 .type = FIO_OPT_INT,
a609f12a 4833 .off1 = offsetof(struct thread_options, cgroup_weight),
a696fa2a
JA
4834 .help = "Use given weight for cgroup",
4835 .minval = 100,
4836 .maxval = 1000,
a1f6afec 4837 .parent = "cgroup",
e8b0e958 4838 .category = FIO_OPT_C_GENERAL,
a1f6afec 4839 .group = FIO_OPT_G_CGROUP,
7de87099 4840 },
e0b0d892
JA
4841 {
4842 .name = "uid",
e8b0e958 4843 .lname = "User ID",
e0b0d892 4844 .type = FIO_OPT_INT,
a609f12a 4845 .off1 = offsetof(struct thread_options, uid),
e0b0d892 4846 .help = "Run job with this user ID",
e8b0e958 4847 .category = FIO_OPT_C_GENERAL,
10860056 4848 .group = FIO_OPT_G_CRED,
e0b0d892
JA
4849 },
4850 {
4851 .name = "gid",
e8b0e958 4852 .lname = "Group ID",
e0b0d892 4853 .type = FIO_OPT_INT,
a609f12a 4854 .off1 = offsetof(struct thread_options, gid),
e0b0d892 4855 .help = "Run job with this group ID",
e8b0e958 4856 .category = FIO_OPT_C_GENERAL,
10860056 4857 .group = FIO_OPT_G_CRED,
e0b0d892 4858 },
a1f6afec
JA
4859 {
4860 .name = "kb_base",
4861 .lname = "KB Base",
41dd12d6 4862 .type = FIO_OPT_STR,
a609f12a 4863 .off1 = offsetof(struct thread_options, kb_base),
a1f6afec
JA
4864 .prio = 1,
4865 .def = "1024",
ba9c7219
JA
4866 .posval = {
4867 { .ival = "1024",
4868 .oval = 1024,
d694a6a7 4869 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
ba9c7219
JA
4870 },
4871 { .ival = "1000",
4872 .oval = 1000,
d694a6a7 4873 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
ba9c7219
JA
4874 },
4875 },
d694a6a7 4876 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
a1f6afec
JA
4877 .category = FIO_OPT_C_GENERAL,
4878 .group = FIO_OPT_G_INVALID,
4879 },
cf3a0518
JA
4880 {
4881 .name = "unit_base",
d694a6a7 4882 .lname = "Unit for quantities of data (Bits or Bytes)",
92a1a1d7 4883 .type = FIO_OPT_STR,
a609f12a 4884 .off1 = offsetof(struct thread_options, unit_base),
cf3a0518 4885 .prio = 1,
71a08258
JA
4886 .posval = {
4887 { .ival = "0",
41a87019 4888 .oval = N2S_NONE,
71a08258
JA
4889 .help = "Auto-detect",
4890 },
4891 { .ival = "8",
41a87019 4892 .oval = N2S_BYTEPERSEC,
71a08258
JA
4893 .help = "Normal (byte based)",
4894 },
4895 { .ival = "1",
41a87019 4896 .oval = N2S_BITPERSEC,
71a08258
JA
4897 .help = "Bit based",
4898 },
4899 },
cf3a0518
JA
4900 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4901 .category = FIO_OPT_C_GENERAL,
4902 .group = FIO_OPT_G_INVALID,
4903 },
3ceb458f
JA
4904 {
4905 .name = "hugepage-size",
4906 .lname = "Hugepage size",
4907 .type = FIO_OPT_INT,
a609f12a 4908 .off1 = offsetof(struct thread_options, hugepage_size),
3ceb458f
JA
4909 .help = "When using hugepages, specify size of each page",
4910 .def = __fio_stringify(FIO_HUGE_PAGE),
4911 .interval = 1024 * 1024,
4912 .category = FIO_OPT_C_GENERAL,
4913 .group = FIO_OPT_G_INVALID,
4914 },
9e684a49
DE
4915 {
4916 .name = "flow_id",
e8b0e958 4917 .lname = "I/O flow ID",
9e684a49 4918 .type = FIO_OPT_INT,
a609f12a 4919 .off1 = offsetof(struct thread_options, flow_id),
9e684a49
DE
4920 .help = "The flow index ID to use",
4921 .def = "0",
e8b0e958
JA
4922 .category = FIO_OPT_C_IO,
4923 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4924 },
4925 {
4926 .name = "flow",
e8b0e958 4927 .lname = "I/O flow weight",
20c7a244 4928 .type = FIO_OPT_INT,
a609f12a 4929 .off1 = offsetof(struct thread_options, flow),
9e684a49
DE
4930 .help = "Weight for flow control of this job",
4931 .parent = "flow_id",
d71c154c 4932 .hide = 1,
9e684a49 4933 .def = "0",
d4e74fda 4934 .maxval = FLOW_MAX_WEIGHT,
e8b0e958
JA
4935 .category = FIO_OPT_C_IO,
4936 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4937 },
4938 {
4939 .name = "flow_watermark",
e8b0e958 4940 .lname = "I/O flow watermark",
d4e74fda 4941 .type = FIO_OPT_SOFT_DEPRECATED,
e8b0e958
JA
4942 .category = FIO_OPT_C_IO,
4943 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4944 },
4945 {
4946 .name = "flow_sleep",
e8b0e958 4947 .lname = "I/O flow sleep",
9e684a49 4948 .type = FIO_OPT_INT,
a609f12a 4949 .off1 = offsetof(struct thread_options, flow_sleep),
9e684a49
DE
4950 .help = "How many microseconds to sleep after being held"
4951 " back by the flow control mechanism",
4952 .parent = "flow_id",
d71c154c 4953 .hide = 1,
9e684a49 4954 .def = "0",
e8b0e958
JA
4955 .category = FIO_OPT_C_IO,
4956 .group = FIO_OPT_G_IO_FLOW,
9e684a49 4957 },
16e56d25
VF
4958 {
4959 .name = "steadystate",
4960 .lname = "Steady state threshold",
4961 .alias = "ss",
4962 .type = FIO_OPT_STR,
2c5d94bc 4963 .off1 = offsetof(struct thread_options, ss_state),
16e56d25
VF
4964 .cb = str_steadystate_cb,
4965 .help = "Define the criterion and limit to judge when a job has reached steady state",
4966 .def = "iops_slope:0.01%",
4967 .posval = {
4968 { .ival = "iops",
f0c50c66 4969 .oval = FIO_SS_IOPS,
16e56d25
VF
4970 .help = "maximum mean deviation of IOPS measurements",
4971 },
4972 { .ival = "iops_slope",
f0c50c66 4973 .oval = FIO_SS_IOPS_SLOPE,
16e56d25
VF
4974 .help = "slope calculated from IOPS measurements",
4975 },
4976 { .ival = "bw",
f0c50c66 4977 .oval = FIO_SS_BW,
16e56d25
VF
4978 .help = "maximum mean deviation of bandwidth measurements",
4979 },
4980 {
4981 .ival = "bw_slope",
f0c50c66 4982 .oval = FIO_SS_BW_SLOPE,
16e56d25
VF
4983 .help = "slope calculated from bandwidth measurements",
4984 },
4985 },
4986 .category = FIO_OPT_C_GENERAL,
4987 .group = FIO_OPT_G_RUNTIME,
4988 },
4989 {
4990 .name = "steadystate_duration",
4991 .lname = "Steady state duration",
4992 .alias = "ss_dur",
915ca980 4993 .parent = "steadystate",
16e56d25
VF
4994 .type = FIO_OPT_STR_VAL_TIME,
4995 .off1 = offsetof(struct thread_options, ss_dur),
4996 .help = "Stop workload upon attaining steady state for specified duration",
4997 .def = "0",
4998 .is_seconds = 1,
4999 .is_time = 1,
5000 .category = FIO_OPT_C_GENERAL,
5001 .group = FIO_OPT_G_RUNTIME,
5002 },
5003 {
5004 .name = "steadystate_ramp_time",
5005 .lname = "Steady state ramp time",
5006 .alias = "ss_ramp",
915ca980 5007 .parent = "steadystate",
16e56d25
VF
5008 .type = FIO_OPT_STR_VAL_TIME,
5009 .off1 = offsetof(struct thread_options, ss_ramp_time),
5010 .help = "Delay before initiation of data collection for steady state job termination testing",
5011 .def = "0",
5012 .is_seconds = 1,
5013 .is_time = 1,
5014 .category = FIO_OPT_C_GENERAL,
5015 .group = FIO_OPT_G_RUNTIME,
5016 },
214e1eca
JA
5017 {
5018 .name = NULL,
5019 },
5020};
5021
17af15d4 5022static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 5023 const char *name, int val)
9f81736c 5024{
17af15d4 5025 lopt->name = (char *) name;
de890a1e 5026 lopt->val = val;
9f81736c 5027 if (o->type == FIO_OPT_STR_SET)
ff52be3d 5028 lopt->has_arg = optional_argument;
9f81736c
JA
5029 else
5030 lopt->has_arg = required_argument;
5031}
5032
de890a1e
SL
5033static void options_to_lopts(struct fio_option *opts,
5034 struct option *long_options,
5035 int i, int option_type)
214e1eca 5036{
de890a1e 5037 struct fio_option *o = &opts[0];
214e1eca 5038 while (o->name) {
de890a1e 5039 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
5040 if (o->alias) {
5041 i++;
de890a1e 5042 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 5043 }
214e1eca
JA
5044
5045 i++;
5046 o++;
5047 assert(i < FIO_NR_OPTIONS);
5048 }
5049}
5050
de890a1e
SL
5051void fio_options_set_ioengine_opts(struct option *long_options,
5052 struct thread_data *td)
5053{
5054 unsigned int i;
5055
5056 i = 0;
5057 while (long_options[i].name) {
5058 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
5059 memset(&long_options[i], 0, sizeof(*long_options));
5060 break;
5061 }
5062 i++;
5063 }
5064
5065 /*
5066 * Just clear out the prior ioengine options.
5067 */
5068 if (!td || !td->eo)
5069 return;
5070
5071 options_to_lopts(td->io_ops->options, long_options, i,
5072 FIO_GETOPT_IOENGINE);
5073}
5074
5075void fio_options_dup_and_init(struct option *long_options)
5076{
5077 unsigned int i;
5078
9af4a244 5079 options_init(fio_options);
de890a1e
SL
5080
5081 i = 0;
5082 while (long_options[i].name)
5083 i++;
5084
9af4a244 5085 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
5086}
5087
74929ac2
JA
5088struct fio_keyword {
5089 const char *word;
5090 const char *desc;
5091 char *replace;
5092};
5093
5094static struct fio_keyword fio_keywords[] = {
5095 {
5096 .word = "$pagesize",
5097 .desc = "Page size in the system",
5098 },
5099 {
5100 .word = "$mb_memory",
5101 .desc = "Megabytes of memory online",
5102 },
5103 {
5104 .word = "$ncpus",
5105 .desc = "Number of CPUs online in the system",
5106 },
5107 {
5108 .word = NULL,
5109 },
5110};
5111
af1dc266
JA
5112void fio_keywords_exit(void)
5113{
5114 struct fio_keyword *kw;
5115
5116 kw = &fio_keywords[0];
5117 while (kw->word) {
5118 free(kw->replace);
5119 kw->replace = NULL;
5120 kw++;
5121 }
5122}
5123
74929ac2
JA
5124void fio_keywords_init(void)
5125{
3b2e1464 5126 unsigned long long mb_memory;
74929ac2
JA
5127 char buf[128];
5128 long l;
5129
a4cfc477 5130 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
5131 fio_keywords[0].replace = strdup(buf);
5132
8eb016d3 5133 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 5134 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
5135 fio_keywords[1].replace = strdup(buf);
5136
c00a2289 5137 l = cpus_online();
74929ac2
JA
5138 sprintf(buf, "%lu", l);
5139 fio_keywords[2].replace = strdup(buf);
5140}
5141
892a6ffc
JA
5142#define BC_APP "bc"
5143
5144static char *bc_calc(char *str)
5145{
d0c814ec 5146 char buf[128], *tmp;
892a6ffc
JA
5147 FILE *f;
5148 int ret;
5149
5150 /*
5151 * No math, just return string
5152 */
d0c814ec
SL
5153 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
5154 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
5155 return str;
5156
5157 /*
5158 * Split option from value, we only need to calculate the value
5159 */
5160 tmp = strchr(str, '=');
5161 if (!tmp)
5162 return str;
5163
5164 tmp++;
892a6ffc 5165
d0c814ec
SL
5166 /*
5167 * Prevent buffer overflows; such a case isn't reasonable anyway
5168 */
5169 if (strlen(str) >= 128 || strlen(tmp) > 100)
5170 return str;
892a6ffc
JA
5171
5172 sprintf(buf, "which %s > /dev/null", BC_APP);
5173 if (system(buf)) {
5174 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
5175 return NULL;
5176 }
5177
d0c814ec 5178 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 5179 f = popen(buf, "r");
3c3ed070 5180 if (!f)
892a6ffc 5181 return NULL;
892a6ffc 5182
d0c814ec 5183 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
1d824f37
JA
5184 if (ret <= 0) {
5185 pclose(f);
892a6ffc 5186 return NULL;
1d824f37 5187 }
892a6ffc 5188
892a6ffc 5189 pclose(f);
d0c814ec
SL
5190 buf[(tmp - str) + ret - 1] = '\0';
5191 memcpy(buf, str, tmp - str);
892a6ffc 5192 free(str);
d0c814ec
SL
5193 return strdup(buf);
5194}
5195
5196/*
5197 * Return a copy of the input string with substrings of the form ${VARNAME}
5198 * substituted with the value of the environment variable VARNAME. The
5199 * substitution always occurs, even if VARNAME is empty or the corresponding
5200 * environment variable undefined.
5201 */
b4f5e72f 5202char *fio_option_dup_subs(const char *opt)
d0c814ec
SL
5203{
5204 char out[OPT_LEN_MAX+1];
5205 char in[OPT_LEN_MAX+1];
5206 char *outptr = out;
5207 char *inptr = in;
5208 char *ch1, *ch2, *env;
5209 ssize_t nchr = OPT_LEN_MAX;
5210 size_t envlen;
5211
5212 if (strlen(opt) + 1 > OPT_LEN_MAX) {
5213 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
5214 return NULL;
5215 }
5216
36833fb0 5217 snprintf(in, sizeof(in), "%s", opt);
d0c814ec
SL
5218
5219 while (*inptr && nchr > 0) {
5220 if (inptr[0] == '$' && inptr[1] == '{') {
5221 ch2 = strchr(inptr, '}');
5222 if (ch2 && inptr+1 < ch2) {
5223 ch1 = inptr+2;
5224 inptr = ch2+1;
5225 *ch2 = '\0';
5226
5227 env = getenv(ch1);
5228 if (env) {
5229 envlen = strlen(env);
5230 if (envlen <= nchr) {
5231 memcpy(outptr, env, envlen);
5232 outptr += envlen;
5233 nchr -= envlen;
5234 }
5235 }
5236
5237 continue;
5238 }
5239 }
5240
5241 *outptr++ = *inptr++;
5242 --nchr;
5243 }
5244
5245 *outptr = '\0';
5246 return strdup(out);
892a6ffc
JA
5247}
5248
74929ac2
JA
5249/*
5250 * Look for reserved variable names and replace them with real values
5251 */
5252static char *fio_keyword_replace(char *opt)
5253{
5254 char *s;
5255 int i;
d0c814ec 5256 int docalc = 0;
74929ac2
JA
5257
5258 for (i = 0; fio_keywords[i].word != NULL; i++) {
5259 struct fio_keyword *kw = &fio_keywords[i];
5260
5261 while ((s = strstr(opt, kw->word)) != NULL) {
33153428 5262 char *new = calloc(strlen(opt) + 1, 1);
74929ac2
JA
5263 char *o_org = opt;
5264 int olen = s - opt;
5265 int len;
5266
5267 /*
5268 * Copy part of the string before the keyword and
5269 * sprintf() the replacement after it.
5270 */
5271 memcpy(new, opt, olen);
5272 len = sprintf(new + olen, "%s", kw->replace);
5273
5274 /*
5275 * If there's more in the original string, copy that
5276 * in too
5277 */
85b9ee7e 5278 opt += olen + strlen(kw->word);
33153428 5279 /* keeps final zero thanks to calloc */
74929ac2 5280 if (strlen(opt))
85b9ee7e 5281 memcpy(new + olen + len, opt, strlen(opt));
74929ac2
JA
5282
5283 /*
5284 * replace opt and free the old opt
5285 */
5286 opt = new;
d0c814ec 5287 free(o_org);
7a958bd5 5288
d0c814ec 5289 docalc = 1;
74929ac2
JA
5290 }
5291 }
5292
d0c814ec
SL
5293 /*
5294 * Check for potential math and invoke bc, if possible
5295 */
5296 if (docalc)
5297 opt = bc_calc(opt);
5298
7a958bd5 5299 return opt;
74929ac2
JA
5300}
5301
d0c814ec
SL
5302static char **dup_and_sub_options(char **opts, int num_opts)
5303{
5304 int i;
5305 char **opts_copy = malloc(num_opts * sizeof(*opts));
5306 for (i = 0; i < num_opts; i++) {
b4f5e72f 5307 opts_copy[i] = fio_option_dup_subs(opts[i]);
d0c814ec
SL
5308 if (!opts_copy[i])
5309 continue;
5310 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
5311 }
5312 return opts_copy;
5313}
5314
e15b023b 5315static void show_closest_option(const char *opt)
a2d027b9
JA
5316{
5317 int best_option, best_distance;
5318 int i, distance;
e15b023b
JA
5319 char *name;
5320
5321 if (!strlen(opt))
5322 return;
5323
5324 name = strdup(opt);
5325 i = 0;
5326 while (name[i] != '\0' && name[i] != '=')
5327 i++;
5328 name[i] = '\0';
a2d027b9
JA
5329
5330 best_option = -1;
5331 best_distance = INT_MAX;
5332 i = 0;
5333 while (fio_options[i].name) {
5334 distance = string_distance(name, fio_options[i].name);
5335 if (distance < best_distance) {
5336 best_distance = distance;
5337 best_option = i;
5338 }
5339 i++;
5340 }
5341
75e6bcba
JA
5342 if (best_option != -1 && string_distance_ok(name, best_distance) &&
5343 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
a2d027b9 5344 log_err("Did you mean %s?\n", fio_options[best_option].name);
e15b023b
JA
5345
5346 free(name);
a2d027b9
JA
5347}
5348
c2292325 5349int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 5350{
de890a1e 5351 int i, ret, unknown;
d0c814ec 5352 char **opts_copy;
3b8b7135 5353
9af4a244 5354 sort_options(opts, fio_options, num_opts);
d0c814ec 5355 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 5356
de890a1e 5357 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
9109883a 5358 const struct fio_option *o;
9af4a244 5359 int newret = parse_option(opts_copy[i], opts[i], fio_options,
a609f12a 5360 &o, &td->o, &td->opt_list);
d0c814ec 5361
a8523a6a
JA
5362 if (!newret && o)
5363 fio_option_mark_set(&td->o, o);
5364
de890a1e
SL
5365 if (opts_copy[i]) {
5366 if (newret && !o) {
5367 unknown++;
5368 continue;
5369 }
d0c814ec 5370 free(opts_copy[i]);
de890a1e
SL
5371 opts_copy[i] = NULL;
5372 }
5373
5374 ret |= newret;
5375 }
5376
5377 if (unknown) {
5378 ret |= ioengine_load(td);
5379 if (td->eo) {
5380 sort_options(opts_copy, td->io_ops->options, num_opts);
5381 opts = opts_copy;
5382 }
5383 for (i = 0; i < num_opts; i++) {
9109883a 5384 const struct fio_option *o = NULL;
de890a1e 5385 int newret = 1;
a2d027b9 5386
de890a1e
SL
5387 if (!opts_copy[i])
5388 continue;
5389
5390 if (td->eo)
5391 newret = parse_option(opts_copy[i], opts[i],
5392 td->io_ops->options, &o,
66e19a38 5393 td->eo, &td->opt_list);
de890a1e
SL
5394
5395 ret |= newret;
a2d027b9 5396 if (!o) {
de890a1e 5397 log_err("Bad option <%s>\n", opts[i]);
a2d027b9
JA
5398 show_closest_option(opts[i]);
5399 }
de890a1e
SL
5400 free(opts_copy[i]);
5401 opts_copy[i] = NULL;
5402 }
74929ac2 5403 }
3b8b7135 5404
d0c814ec 5405 free(opts_copy);
3b8b7135 5406 return ret;
214e1eca
JA
5407}
5408
5409int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
5410{
a8523a6a
JA
5411 int ret;
5412
a609f12a 5413 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
a8523a6a 5414 if (!ret) {
9109883a 5415 const struct fio_option *o;
a8523a6a 5416
9109883a 5417 o = find_option_c(fio_options, opt);
a8523a6a
JA
5418 if (o)
5419 fio_option_mark_set(&td->o, o);
5420 }
5421
5422 return ret;
214e1eca
JA
5423}
5424
de890a1e
SL
5425int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
5426 char *val)
5427{
d8b4f395
JA
5428 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
5429 &td->opt_list);
de890a1e
SL
5430}
5431
214e1eca
JA
5432void fio_fill_default_options(struct thread_data *td)
5433{
cb1402d6 5434 td->o.magic = OPT_MAGIC;
a609f12a 5435 fill_default_options(&td->o, fio_options);
214e1eca
JA
5436}
5437
5438int fio_show_option_help(const char *opt)
5439{
9af4a244 5440 return show_cmd_help(fio_options, opt);
214e1eca 5441}
d23bb327 5442
de890a1e
SL
5443/*
5444 * dupe FIO_OPT_STR_STORE options
5445 */
5446void fio_options_mem_dupe(struct thread_data *td)
5447{
53b5693d 5448 options_mem_dupe(fio_options, &td->o);
1647f592
JA
5449
5450 if (td->eo && td->io_ops) {
de890a1e 5451 void *oldeo = td->eo;
1647f592 5452
de890a1e
SL
5453 td->eo = malloc(td->io_ops->option_struct_size);
5454 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
53b5693d 5455 options_mem_dupe(td->io_ops->options, td->eo);
de890a1e
SL
5456 }
5457}
5458
d6978a32
JA
5459unsigned int fio_get_kb_base(void *data)
5460{
a609f12a
JA
5461 struct thread_data *td = cb_data_to_td(data);
5462 struct thread_options *o = &td->o;
d6978a32
JA
5463 unsigned int kb_base = 0;
5464
cb1402d6
JA
5465 /*
5466 * This is a hack... For private options, *data is not holding
5467 * a pointer to the thread_options, but to private data. This means
5468 * we can't safely dereference it, but magic is first so mem wise
5469 * it is valid. But this also means that if the job first sets
5470 * kb_base and expects that to be honored by private options,
5471 * it will be disappointed. We will return the global default
5472 * for this.
5473 */
5474 if (o && o->magic == OPT_MAGIC)
83ea422a 5475 kb_base = o->kb_base;
d6978a32
JA
5476 if (!kb_base)
5477 kb_base = 1024;
5478
5479 return kb_base;
5480}
9f988e2e 5481
9109883a 5482int add_option(const struct fio_option *o)
9f988e2e 5483{
07b3232d
JA
5484 struct fio_option *__o;
5485 int opt_index = 0;
5486
9af4a244 5487 __o = fio_options;
07b3232d
JA
5488 while (__o->name) {
5489 opt_index++;
5490 __o++;
5491 }
5492
7b504edd
JA
5493 if (opt_index + 1 == FIO_MAX_OPTS) {
5494 log_err("fio: FIO_MAX_OPTS is too small\n");
5495 return 1;
5496 }
5497
9af4a244 5498 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 5499 fio_options[opt_index + 1].name = NULL;
07b3232d 5500 return 0;
9f988e2e 5501}
e2de69da 5502
07b3232d 5503void invalidate_profile_options(const char *prof_name)
e2de69da 5504{
07b3232d 5505 struct fio_option *o;
e2de69da 5506
9af4a244 5507 o = fio_options;
07b3232d
JA
5508 while (o->name) {
5509 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
5510 o->type = FIO_OPT_INVALID;
5511 o->prof_name = NULL;
5512 }
5513 o++;
e2de69da
JA
5514 }
5515}
f5b6bb85
JA
5516
5517void add_opt_posval(const char *optname, const char *ival, const char *help)
5518{
5519 struct fio_option *o;
5520 unsigned int i;
5521
9af4a244 5522 o = find_option(fio_options, optname);
f5b6bb85
JA
5523 if (!o)
5524 return;
5525
5526 for (i = 0; i < PARSE_MAX_VP; i++) {
5527 if (o->posval[i].ival)
5528 continue;
5529
5530 o->posval[i].ival = ival;
5531 o->posval[i].help = help;
5532 break;
5533 }
5534}
5535
5536void del_opt_posval(const char *optname, const char *ival)
5537{
5538 struct fio_option *o;
5539 unsigned int i;
5540
9af4a244 5541 o = find_option(fio_options, optname);
f5b6bb85
JA
5542 if (!o)
5543 return;
5544
5545 for (i = 0; i < PARSE_MAX_VP; i++) {
5546 if (!o->posval[i].ival)
5547 continue;
5548 if (strcmp(o->posval[i].ival, ival))
5549 continue;
5550
5551 o->posval[i].ival = NULL;
5552 o->posval[i].help = NULL;
5553 }
5554}
7e356b2d
JA
5555
5556void fio_options_free(struct thread_data *td)
5557{
ca6336a8 5558 options_free(fio_options, &td->o);
de890a1e
SL
5559 if (td->eo && td->io_ops && td->io_ops->options) {
5560 options_free(td->io_ops->options, td->eo);
5561 free(td->eo);
5562 td->eo = NULL;
5563 }
7e356b2d 5564}
c504ee55 5565
8009f543
NC
5566void fio_dump_options_free(struct thread_data *td)
5567{
5568 while (!flist_empty(&td->opt_list)) {
5569 struct print_option *p;
5570
5571 p = flist_first_entry(&td->opt_list, struct print_option, list);
5572 flist_del_init(&p->list);
5573 free(p->name);
5574 free(p->value);
5575 free(p);
5576 }
5577}
5578
c504ee55
JA
5579struct fio_option *fio_option_find(const char *name)
5580{
5581 return find_option(fio_options, name);
5582}
5583
517c9c72 5584static struct fio_option *find_next_opt(struct fio_option *from,
f0e7f45a 5585 unsigned int off1)
a8523a6a 5586{
f0e7f45a 5587 struct fio_option *opt;
a8523a6a 5588
f0e7f45a
JA
5589 if (!from)
5590 from = &fio_options[0];
5591 else
5592 from++;
5593
5594 opt = NULL;
5595 do {
5596 if (off1 == from->off1) {
5597 opt = from;
a8523a6a
JA
5598 break;
5599 }
f0e7f45a
JA
5600 from++;
5601 } while (from->name);
a8523a6a 5602
f0e7f45a
JA
5603 return opt;
5604}
5605
5606static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5607{
5608 unsigned int opt_off, index, offset;
a8523a6a
JA
5609
5610 opt_off = opt - &fio_options[0];
5611 index = opt_off / (8 * sizeof(uint64_t));
5612 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 5613 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
a8523a6a
JA
5614}
5615
72f39748 5616bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
f0e7f45a
JA
5617{
5618 struct fio_option *opt, *next;
5619
5620 next = NULL;
517c9c72 5621 while ((opt = find_next_opt(next, off1)) != NULL) {
f0e7f45a 5622 if (opt_is_set(o, opt))
72f39748 5623 return true;
f0e7f45a
JA
5624
5625 next = opt;
5626 }
5627
72f39748 5628 return false;
f0e7f45a
JA
5629}
5630
9109883a 5631void fio_option_mark_set(struct thread_options *o, const struct fio_option *opt)
a8523a6a
JA
5632{
5633 unsigned int opt_off, index, offset;
5634
5635 opt_off = opt - &fio_options[0];
5636 index = opt_off / (8 * sizeof(uint64_t));
5637 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 5638 o->set_options[index] |= (uint64_t)1 << offset;
a8523a6a 5639}