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