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