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