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