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