Define pointer alignment macro in fio.h
[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),
1684f7fd 1886 .help = "Total size of I/O to be performed",
77731b29
JA
1887 .interval = 1024 * 1024,
1888 .category = FIO_OPT_C_IO,
1889 .group = FIO_OPT_G_INVALID,
1890 },
aa31f1f1
SL
1891 {
1892 .name = "fill_device",
e8b0e958 1893 .lname = "Fill device",
74586c1e 1894 .alias = "fill_fs",
aa31f1f1 1895 .type = FIO_OPT_BOOL,
a609f12a 1896 .off1 = offsetof(struct thread_options, fill_device),
aa31f1f1
SL
1897 .help = "Write until an ENOSPC error occurs",
1898 .def = "0",
e8b0e958
JA
1899 .category = FIO_OPT_C_FILE,
1900 .group = FIO_OPT_G_INVALID,
aa31f1f1 1901 },
214e1eca
JA
1902 {
1903 .name = "filesize",
e8b0e958 1904 .lname = "File size",
214e1eca 1905 .type = FIO_OPT_STR_VAL,
a609f12a
JA
1906 .off1 = offsetof(struct thread_options, file_size_low),
1907 .off2 = offsetof(struct thread_options, file_size_high),
c3edbdba 1908 .minval = 1,
214e1eca 1909 .help = "Size of individual files",
20eb06bd 1910 .interval = 1024 * 1024,
e8b0e958
JA
1911 .category = FIO_OPT_C_FILE,
1912 .group = FIO_OPT_G_INVALID,
214e1eca 1913 },
bedc9dc2
JA
1914 {
1915 .name = "file_append",
1916 .lname = "File append",
1917 .type = FIO_OPT_BOOL,
a609f12a 1918 .off1 = offsetof(struct thread_options, file_append),
bedc9dc2
JA
1919 .help = "IO will start at the end of the file(s)",
1920 .def = "0",
1921 .category = FIO_OPT_C_FILE,
1922 .group = FIO_OPT_G_INVALID,
1923 },
67a1000f
JA
1924 {
1925 .name = "offset",
e8b0e958 1926 .lname = "IO offset",
67a1000f
JA
1927 .alias = "fileoffset",
1928 .type = FIO_OPT_STR_VAL,
a609f12a 1929 .off1 = offsetof(struct thread_options, start_offset),
67a1000f
JA
1930 .help = "Start IO from this offset",
1931 .def = "0",
20eb06bd 1932 .interval = 1024 * 1024,
e8b0e958
JA
1933 .category = FIO_OPT_C_IO,
1934 .group = FIO_OPT_G_INVALID,
67a1000f 1935 },
2d7cd868
JA
1936 {
1937 .name = "offset_increment",
e8b0e958 1938 .lname = "IO offset increment",
2d7cd868 1939 .type = FIO_OPT_STR_VAL,
a609f12a 1940 .off1 = offsetof(struct thread_options, offset_increment),
2d7cd868
JA
1941 .help = "What is the increment from one offset to the next",
1942 .parent = "offset",
d71c154c 1943 .hide = 1,
2d7cd868 1944 .def = "0",
20eb06bd 1945 .interval = 1024 * 1024,
e8b0e958
JA
1946 .category = FIO_OPT_C_IO,
1947 .group = FIO_OPT_G_INVALID,
2d7cd868 1948 },
ddf24e42
JA
1949 {
1950 .name = "number_ios",
1951 .lname = "Number of IOs to perform",
1952 .type = FIO_OPT_STR_VAL,
a609f12a 1953 .off1 = offsetof(struct thread_options, number_ios),
be3fec7d 1954 .help = "Force job completion after this number of IOs",
ddf24e42
JA
1955 .def = "0",
1956 .category = FIO_OPT_C_IO,
1957 .group = FIO_OPT_G_INVALID,
1958 },
214e1eca
JA
1959 {
1960 .name = "bs",
e8b0e958 1961 .lname = "Block size",
d3aad8f2 1962 .alias = "blocksize",
e01b22b8 1963 .type = FIO_OPT_INT,
a609f12a
JA
1964 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1965 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1966 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
c3edbdba 1967 .minval = 1,
214e1eca 1968 .help = "Block size unit",
2b9136a3 1969 .def = "4096",
67a1000f 1970 .parent = "rw",
d71c154c 1971 .hide = 1,
20eb06bd 1972 .interval = 512,
e8b0e958
JA
1973 .category = FIO_OPT_C_IO,
1974 .group = FIO_OPT_G_INVALID,
214e1eca 1975 },
2b7a01d0
JA
1976 {
1977 .name = "ba",
e8b0e958 1978 .lname = "Block size align",
2b7a01d0 1979 .alias = "blockalign",
e01b22b8 1980 .type = FIO_OPT_INT,
a609f12a
JA
1981 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
1982 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
1983 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2b7a01d0
JA
1984 .minval = 1,
1985 .help = "IO block offset alignment",
1986 .parent = "rw",
d71c154c 1987 .hide = 1,
20eb06bd 1988 .interval = 512,
e8b0e958
JA
1989 .category = FIO_OPT_C_IO,
1990 .group = FIO_OPT_G_INVALID,
2b7a01d0 1991 },
214e1eca
JA
1992 {
1993 .name = "bsrange",
e8b0e958 1994 .lname = "Block size range",
d3aad8f2 1995 .alias = "blocksize_range",
214e1eca 1996 .type = FIO_OPT_RANGE,
a609f12a
JA
1997 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
1998 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
1999 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2000 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2001 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2002 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
c3edbdba 2003 .minval = 1,
214e1eca 2004 .help = "Set block size range (in more detail than bs)",
67a1000f 2005 .parent = "rw",
d71c154c 2006 .hide = 1,
20eb06bd 2007 .interval = 4096,
e8b0e958
JA
2008 .category = FIO_OPT_C_IO,
2009 .group = FIO_OPT_G_INVALID,
214e1eca 2010 },
564ca972
JA
2011 {
2012 .name = "bssplit",
e8b0e958 2013 .lname = "Block size split",
564ca972
JA
2014 .type = FIO_OPT_STR,
2015 .cb = str_bssplit_cb,
a609f12a 2016 .off1 = offsetof(struct thread_options, bssplit),
564ca972
JA
2017 .help = "Set a specific mix of block sizes",
2018 .parent = "rw",
d71c154c 2019 .hide = 1,
e8b0e958
JA
2020 .category = FIO_OPT_C_IO,
2021 .group = FIO_OPT_G_INVALID,
564ca972 2022 },
214e1eca
JA
2023 {
2024 .name = "bs_unaligned",
e8b0e958 2025 .lname = "Block size unaligned",
d3aad8f2 2026 .alias = "blocksize_unaligned",
214e1eca 2027 .type = FIO_OPT_STR_SET,
a609f12a 2028 .off1 = offsetof(struct thread_options, bs_unaligned),
214e1eca 2029 .help = "Don't sector align IO buffer sizes",
67a1000f 2030 .parent = "rw",
d71c154c 2031 .hide = 1,
e8b0e958
JA
2032 .category = FIO_OPT_C_IO,
2033 .group = FIO_OPT_G_INVALID,
214e1eca 2034 },
6aca9b3d
JA
2035 {
2036 .name = "bs_is_seq_rand",
2037 .lname = "Block size division is seq/random (not read/write)",
2038 .type = FIO_OPT_BOOL,
a609f12a 2039 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
86d59660 2040 .help = "Consider any blocksize setting to be sequential,random",
6aca9b3d
JA
2041 .def = "0",
2042 .parent = "blocksize",
2043 .category = FIO_OPT_C_IO,
2044 .group = FIO_OPT_G_INVALID,
2045 },
214e1eca
JA
2046 {
2047 .name = "randrepeat",
e8b0e958 2048 .lname = "Random repeatable",
214e1eca 2049 .type = FIO_OPT_BOOL,
a609f12a 2050 .off1 = offsetof(struct thread_options, rand_repeatable),
214e1eca
JA
2051 .help = "Use repeatable random IO pattern",
2052 .def = "1",
67a1000f 2053 .parent = "rw",
d71c154c 2054 .hide = 1,
e8b0e958 2055 .category = FIO_OPT_C_IO,
3ceb458f 2056 .group = FIO_OPT_G_RANDOM,
214e1eca 2057 },
04778baf
JA
2058 {
2059 .name = "randseed",
2060 .lname = "The random generator seed",
363cffa7 2061 .type = FIO_OPT_STR_VAL,
a609f12a 2062 .off1 = offsetof(struct thread_options, rand_seed),
04778baf 2063 .help = "Set the random generator seed value",
40fe5e7b 2064 .def = "0x89",
04778baf
JA
2065 .parent = "rw",
2066 .category = FIO_OPT_C_IO,
2067 .group = FIO_OPT_G_RANDOM,
2068 },
2615cc4b
JA
2069 {
2070 .name = "use_os_rand",
e8b0e958 2071 .lname = "Use OS random",
54a21917 2072 .type = FIO_OPT_DEPRECATED,
a609f12a 2073 .off1 = offsetof(struct thread_options, dep_use_os_rand),
e8b0e958 2074 .category = FIO_OPT_C_IO,
3ceb458f 2075 .group = FIO_OPT_G_RANDOM,
2615cc4b 2076 },
214e1eca
JA
2077 {
2078 .name = "norandommap",
e8b0e958 2079 .lname = "No randommap",
214e1eca 2080 .type = FIO_OPT_STR_SET,
a609f12a 2081 .off1 = offsetof(struct thread_options, norandommap),
214e1eca 2082 .help = "Accept potential duplicate random blocks",
67a1000f 2083 .parent = "rw",
d71c154c 2084 .hide = 1,
b2452a43 2085 .hide_on_set = 1,
e8b0e958 2086 .category = FIO_OPT_C_IO,
3ceb458f 2087 .group = FIO_OPT_G_RANDOM,
214e1eca 2088 },
2b386d25
JA
2089 {
2090 .name = "softrandommap",
e8b0e958 2091 .lname = "Soft randommap",
2b386d25 2092 .type = FIO_OPT_BOOL,
a609f12a 2093 .off1 = offsetof(struct thread_options, softrandommap),
f66ab3c8 2094 .help = "Set norandommap if randommap allocation fails",
2b386d25 2095 .parent = "norandommap",
d71c154c 2096 .hide = 1,
2b386d25 2097 .def = "0",
e8b0e958 2098 .category = FIO_OPT_C_IO,
3ceb458f 2099 .group = FIO_OPT_G_RANDOM,
2b386d25 2100 },
8055e41d
JA
2101 {
2102 .name = "random_generator",
cce2fdfe 2103 .lname = "Random Generator",
8055e41d 2104 .type = FIO_OPT_STR,
a609f12a 2105 .off1 = offsetof(struct thread_options, random_generator),
8055e41d
JA
2106 .help = "Type of random number generator to use",
2107 .def = "tausworthe",
2108 .posval = {
2109 { .ival = "tausworthe",
2110 .oval = FIO_RAND_GEN_TAUSWORTHE,
2111 .help = "Strong Tausworthe generator",
2112 },
2113 { .ival = "lfsr",
2114 .oval = FIO_RAND_GEN_LFSR,
2115 .help = "Variable length LFSR",
2116 },
c3546b53
JA
2117 {
2118 .ival = "tausworthe64",
2119 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2120 .help = "64-bit Tausworthe variant",
2121 },
8055e41d 2122 },
48107598
JA
2123 .category = FIO_OPT_C_IO,
2124 .group = FIO_OPT_G_RANDOM,
8055e41d 2125 },
e25839d4
JA
2126 {
2127 .name = "random_distribution",
cce2fdfe 2128 .lname = "Random Distribution",
e25839d4 2129 .type = FIO_OPT_STR,
a609f12a 2130 .off1 = offsetof(struct thread_options, random_distribution),
e25839d4
JA
2131 .cb = str_random_distribution_cb,
2132 .help = "Random offset distribution generator",
2133 .def = "random",
2134 .posval = {
2135 { .ival = "random",
2136 .oval = FIO_RAND_DIST_RANDOM,
2137 .help = "Completely random",
2138 },
2139 { .ival = "zipf",
2140 .oval = FIO_RAND_DIST_ZIPF,
2141 .help = "Zipf distribution",
2142 },
925fee33
JA
2143 { .ival = "pareto",
2144 .oval = FIO_RAND_DIST_PARETO,
2145 .help = "Pareto distribution",
2146 },
56d9fa4b
JA
2147 { .ival = "normal",
2148 .oval = FIO_RAND_DIST_GAUSS,
ba2b3b07 2149 .help = "Normal (Gaussian) distribution",
56d9fa4b 2150 },
e0a04ac1
JA
2151 { .ival = "zoned",
2152 .oval = FIO_RAND_DIST_ZONED,
2153 .help = "Zoned random distribution",
2154 },
2155
e25839d4 2156 },
48107598
JA
2157 .category = FIO_OPT_C_IO,
2158 .group = FIO_OPT_G_RANDOM,
e25839d4 2159 },
211c9b89
JA
2160 {
2161 .name = "percentage_random",
2162 .lname = "Percentage Random",
2163 .type = FIO_OPT_INT,
a609f12a
JA
2164 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2165 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2166 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
211c9b89
JA
2167 .maxval = 100,
2168 .help = "Percentage of seq/random mix that should be random",
d9472271 2169 .def = "100,100,100",
211c9b89
JA
2170 .interval = 5,
2171 .inverse = "percentage_sequential",
2172 .category = FIO_OPT_C_IO,
2173 .group = FIO_OPT_G_RANDOM,
2174 },
2175 {
2176 .name = "percentage_sequential",
2177 .lname = "Percentage Sequential",
d9472271 2178 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
2179 .category = FIO_OPT_C_IO,
2180 .group = FIO_OPT_G_RANDOM,
2181 },
56e2a5fc
CE
2182 {
2183 .name = "allrandrepeat",
cce2fdfe 2184 .lname = "All Random Repeat",
56e2a5fc 2185 .type = FIO_OPT_BOOL,
a609f12a 2186 .off1 = offsetof(struct thread_options, allrand_repeatable),
56e2a5fc
CE
2187 .help = "Use repeatable random numbers for everything",
2188 .def = "0",
a869d9c6
JA
2189 .category = FIO_OPT_C_IO,
2190 .group = FIO_OPT_G_RANDOM,
56e2a5fc 2191 },
214e1eca
JA
2192 {
2193 .name = "nrfiles",
e8b0e958 2194 .lname = "Number of files",
d7c8be03 2195 .alias = "nr_files",
214e1eca 2196 .type = FIO_OPT_INT,
a609f12a 2197 .off1 = offsetof(struct thread_options, nr_files),
214e1eca
JA
2198 .help = "Split job workload between this number of files",
2199 .def = "1",
20eb06bd 2200 .interval = 1,
e8b0e958
JA
2201 .category = FIO_OPT_C_FILE,
2202 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2203 },
2204 {
2205 .name = "openfiles",
e8b0e958 2206 .lname = "Number of open files",
214e1eca 2207 .type = FIO_OPT_INT,
a609f12a 2208 .off1 = offsetof(struct thread_options, open_files),
214e1eca 2209 .help = "Number of files to keep open at the same time",
e8b0e958
JA
2210 .category = FIO_OPT_C_FILE,
2211 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2212 },
2213 {
2214 .name = "file_service_type",
e8b0e958 2215 .lname = "File service type",
214e1eca
JA
2216 .type = FIO_OPT_STR,
2217 .cb = str_fst_cb,
a609f12a 2218 .off1 = offsetof(struct thread_options, file_service_type),
214e1eca
JA
2219 .help = "How to select which file to service next",
2220 .def = "roundrobin",
e8b0e958
JA
2221 .category = FIO_OPT_C_FILE,
2222 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2223 .posval = {
2224 { .ival = "random",
2225 .oval = FIO_FSERVICE_RANDOM,
8c07860d
JA
2226 .help = "Choose a file at random (uniform)",
2227 },
2228 { .ival = "zipf",
2229 .oval = FIO_FSERVICE_ZIPF,
2230 .help = "Zipf randomized",
2231 },
2232 { .ival = "pareto",
2233 .oval = FIO_FSERVICE_PARETO,
2234 .help = "Pareto randomized",
2235 },
2236 { .ival = "gauss",
2237 .oval = FIO_FSERVICE_GAUSS,
4e7a8814 2238 .help = "Normal (gaussian) distribution",
214e1eca
JA
2239 },
2240 { .ival = "roundrobin",
2241 .oval = FIO_FSERVICE_RR,
2242 .help = "Round robin select files",
2243 },
a086c257
JA
2244 { .ival = "sequential",
2245 .oval = FIO_FSERVICE_SEQ,
2246 .help = "Finish one file before moving to the next",
2247 },
214e1eca 2248 },
67a1000f 2249 .parent = "nrfiles",
d71c154c 2250 .hide = 1,
67a1000f 2251 },
97ac992c 2252#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
2253 {
2254 .name = "fallocate",
e8b0e958 2255 .lname = "Fallocate",
a596f047 2256 .type = FIO_OPT_STR,
a609f12a 2257 .off1 = offsetof(struct thread_options, fallocate_mode),
a596f047
EG
2258 .help = "Whether pre-allocation is performed when laying out files",
2259 .def = "posix",
e8b0e958
JA
2260 .category = FIO_OPT_C_FILE,
2261 .group = FIO_OPT_G_INVALID,
a596f047
EG
2262 .posval = {
2263 { .ival = "none",
2264 .oval = FIO_FALLOCATE_NONE,
2265 .help = "Do not pre-allocate space",
2266 },
2267 { .ival = "posix",
2268 .oval = FIO_FALLOCATE_POSIX,
2269 .help = "Use posix_fallocate()",
2270 },
97ac992c 2271#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
2272 { .ival = "keep",
2273 .oval = FIO_FALLOCATE_KEEP_SIZE,
2274 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2275 },
7bc8c2cf 2276#endif
a596f047
EG
2277 /* Compatibility with former boolean values */
2278 { .ival = "0",
2279 .oval = FIO_FALLOCATE_NONE,
2280 .help = "Alias for 'none'",
2281 },
2282 { .ival = "1",
2283 .oval = FIO_FALLOCATE_POSIX,
2284 .help = "Alias for 'posix'",
2285 },
2286 },
2287 },
a275c37a
JA
2288#else /* CONFIG_POSIX_FALLOCATE */
2289 {
2290 .name = "fallocate",
2291 .lname = "Fallocate",
2292 .type = FIO_OPT_UNSUPPORTED,
2293 .help = "Your platform does not support fallocate",
2294 },
2295#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
2296 {
2297 .name = "fadvise_hint",
e8b0e958 2298 .lname = "Fadvise hint",
ecb2083d 2299 .type = FIO_OPT_STR,
a609f12a 2300 .off1 = offsetof(struct thread_options, fadvise_hint),
ecb2083d
JA
2301 .posval = {
2302 { .ival = "0",
2303 .oval = F_ADV_NONE,
2304 .help = "Don't issue fadvise",
2305 },
2306 { .ival = "1",
2307 .oval = F_ADV_TYPE,
2308 .help = "Advise using fio IO pattern",
2309 },
2310 { .ival = "random",
2311 .oval = F_ADV_RANDOM,
2312 .help = "Advise using FADV_RANDOM",
2313 },
2314 { .ival = "sequential",
2315 .oval = F_ADV_SEQUENTIAL,
2316 .help = "Advise using FADV_SEQUENTIAL",
2317 },
2318 },
67a1000f
JA
2319 .help = "Use fadvise() to advise the kernel on IO pattern",
2320 .def = "1",
e8b0e958
JA
2321 .category = FIO_OPT_C_FILE,
2322 .group = FIO_OPT_G_INVALID,
214e1eca 2323 },
37659335
JA
2324#ifdef FIO_HAVE_STREAMID
2325 {
2326 .name = "fadvise_stream",
2327 .lname = "Fadvise stream",
2328 .type = FIO_OPT_INT,
a609f12a 2329 .off1 = offsetof(struct thread_options, fadvise_stream),
37659335
JA
2330 .help = "Use fadvise() to set stream ID",
2331 .category = FIO_OPT_C_FILE,
2332 .group = FIO_OPT_G_INVALID,
2333 },
a275c37a 2334#else
54d0a315 2335 {
a275c37a
JA
2336 .name = "fadvise_stream",
2337 .lname = "Fadvise stream",
2338 .type = FIO_OPT_UNSUPPORTED,
2339 .help = "Your platform does not support fadvise stream ID",
2340 },
37659335 2341#endif
214e1eca
JA
2342 {
2343 .name = "fsync",
e8b0e958 2344 .lname = "Fsync",
214e1eca 2345 .type = FIO_OPT_INT,
a609f12a 2346 .off1 = offsetof(struct thread_options, fsync_blocks),
214e1eca
JA
2347 .help = "Issue fsync for writes every given number of blocks",
2348 .def = "0",
20eb06bd 2349 .interval = 1,
e8b0e958
JA
2350 .category = FIO_OPT_C_FILE,
2351 .group = FIO_OPT_G_INVALID,
214e1eca 2352 },
5f9099ea
JA
2353 {
2354 .name = "fdatasync",
e8b0e958 2355 .lname = "Fdatasync",
5f9099ea 2356 .type = FIO_OPT_INT,
a609f12a 2357 .off1 = offsetof(struct thread_options, fdatasync_blocks),
5f9099ea
JA
2358 .help = "Issue fdatasync for writes every given number of blocks",
2359 .def = "0",
20eb06bd 2360 .interval = 1,
e8b0e958
JA
2361 .category = FIO_OPT_C_FILE,
2362 .group = FIO_OPT_G_INVALID,
5f9099ea 2363 },
1ef2b6be
JA
2364 {
2365 .name = "write_barrier",
e8b0e958 2366 .lname = "Write barrier",
1ef2b6be 2367 .type = FIO_OPT_INT,
a609f12a 2368 .off1 = offsetof(struct thread_options, barrier_blocks),
1ef2b6be
JA
2369 .help = "Make every Nth write a barrier write",
2370 .def = "0",
20eb06bd 2371 .interval = 1,
e8b0e958
JA
2372 .category = FIO_OPT_C_IO,
2373 .group = FIO_OPT_G_INVALID,
1ef2b6be 2374 },
67bf9823 2375#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2376 {
2377 .name = "sync_file_range",
e8b0e958 2378 .lname = "Sync file range",
44f29692
JA
2379 .posval = {
2380 { .ival = "wait_before",
2381 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2382 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2383 .orval = 1,
44f29692
JA
2384 },
2385 { .ival = "write",
2386 .oval = SYNC_FILE_RANGE_WRITE,
2387 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2388 .orval = 1,
44f29692
JA
2389 },
2390 {
2391 .ival = "wait_after",
2392 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2393 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2394 .orval = 1,
44f29692
JA
2395 },
2396 },
3843deb3 2397 .type = FIO_OPT_STR_MULTI,
44f29692 2398 .cb = str_sfr_cb,
a609f12a 2399 .off1 = offsetof(struct thread_options, sync_file_range),
44f29692 2400 .help = "Use sync_file_range()",
e8b0e958
JA
2401 .category = FIO_OPT_C_FILE,
2402 .group = FIO_OPT_G_INVALID,
44f29692 2403 },
a275c37a 2404#else
54d0a315 2405 {
a275c37a
JA
2406 .name = "sync_file_range",
2407 .lname = "Sync file range",
2408 .type = FIO_OPT_UNSUPPORTED,
2409 .help = "Your platform does not support sync_file_range",
2410 },
44f29692 2411#endif
214e1eca
JA
2412 {
2413 .name = "direct",
e8b0e958 2414 .lname = "Direct I/O",
214e1eca 2415 .type = FIO_OPT_BOOL,
a609f12a 2416 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2417 .help = "Use O_DIRECT IO (negates buffered)",
2418 .def = "0",
a01a1bc5 2419 .inverse = "buffered",
e8b0e958 2420 .category = FIO_OPT_C_IO,
3ceb458f 2421 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2422 },
d01612f3
CM
2423 {
2424 .name = "atomic",
2425 .lname = "Atomic I/O",
2426 .type = FIO_OPT_BOOL,
a609f12a 2427 .off1 = offsetof(struct thread_options, oatomic),
d01612f3
CM
2428 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2429 .def = "0",
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_IO_TYPE,
2432 },
214e1eca
JA
2433 {
2434 .name = "buffered",
e8b0e958 2435 .lname = "Buffered I/O",
214e1eca 2436 .type = FIO_OPT_BOOL,
a609f12a 2437 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2438 .neg = 1,
2439 .help = "Use buffered IO (negates direct)",
2440 .def = "1",
a01a1bc5 2441 .inverse = "direct",
e8b0e958 2442 .category = FIO_OPT_C_IO,
3ceb458f 2443 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2444 },
2445 {
2446 .name = "overwrite",
e8b0e958 2447 .lname = "Overwrite",
214e1eca 2448 .type = FIO_OPT_BOOL,
a609f12a 2449 .off1 = offsetof(struct thread_options, overwrite),
214e1eca
JA
2450 .help = "When writing, set whether to overwrite current data",
2451 .def = "0",
e8b0e958
JA
2452 .category = FIO_OPT_C_FILE,
2453 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2454 },
2455 {
2456 .name = "loops",
e8b0e958 2457 .lname = "Loops",
214e1eca 2458 .type = FIO_OPT_INT,
a609f12a 2459 .off1 = offsetof(struct thread_options, loops),
214e1eca
JA
2460 .help = "Number of times to run the job",
2461 .def = "1",
20eb06bd 2462 .interval = 1,
e8b0e958 2463 .category = FIO_OPT_C_GENERAL,
a1f6afec 2464 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2465 },
2466 {
2467 .name = "numjobs",
e8b0e958 2468 .lname = "Number of jobs",
214e1eca 2469 .type = FIO_OPT_INT,
a609f12a 2470 .off1 = offsetof(struct thread_options, numjobs),
214e1eca
JA
2471 .help = "Duplicate this job this many times",
2472 .def = "1",
20eb06bd 2473 .interval = 1,
e8b0e958 2474 .category = FIO_OPT_C_GENERAL,
a1f6afec 2475 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2476 },
2477 {
2478 .name = "startdelay",
e8b0e958 2479 .lname = "Start delay",
a5737c93 2480 .type = FIO_OPT_STR_VAL_TIME,
a609f12a
JA
2481 .off1 = offsetof(struct thread_options, start_delay),
2482 .off2 = offsetof(struct thread_options, start_delay_high),
214e1eca
JA
2483 .help = "Only start job when this period has passed",
2484 .def = "0",
0de5b26f 2485 .is_seconds = 1,
88038bc7 2486 .is_time = 1,
e8b0e958 2487 .category = FIO_OPT_C_GENERAL,
a1f6afec 2488 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2489 },
2490 {
2491 .name = "runtime",
e8b0e958 2492 .lname = "Runtime",
214e1eca
JA
2493 .alias = "timeout",
2494 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2495 .off1 = offsetof(struct thread_options, timeout),
214e1eca
JA
2496 .help = "Stop workload when this amount of time has passed",
2497 .def = "0",
0de5b26f 2498 .is_seconds = 1,
88038bc7 2499 .is_time = 1,
e8b0e958 2500 .category = FIO_OPT_C_GENERAL,
a1f6afec 2501 .group = FIO_OPT_G_RUNTIME,
214e1eca 2502 },
cf4464ca
JA
2503 {
2504 .name = "time_based",
e8b0e958 2505 .lname = "Time based",
cf4464ca 2506 .type = FIO_OPT_STR_SET,
a609f12a 2507 .off1 = offsetof(struct thread_options, time_based),
cf4464ca 2508 .help = "Keep running until runtime/timeout is met",
e8b0e958 2509 .category = FIO_OPT_C_GENERAL,
a1f6afec 2510 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2511 },
62167762
JC
2512 {
2513 .name = "verify_only",
2514 .lname = "Verify only",
2515 .type = FIO_OPT_STR_SET,
a609f12a 2516 .off1 = offsetof(struct thread_options, verify_only),
62167762
JC
2517 .help = "Verifies previously written data is still valid",
2518 .category = FIO_OPT_C_GENERAL,
2519 .group = FIO_OPT_G_RUNTIME,
2520 },
721938ae
JA
2521 {
2522 .name = "ramp_time",
e8b0e958 2523 .lname = "Ramp time",
721938ae 2524 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2525 .off1 = offsetof(struct thread_options, ramp_time),
721938ae 2526 .help = "Ramp up time before measuring performance",
0de5b26f 2527 .is_seconds = 1,
88038bc7 2528 .is_time = 1,
e8b0e958 2529 .category = FIO_OPT_C_GENERAL,
a1f6afec 2530 .group = FIO_OPT_G_RUNTIME,
721938ae 2531 },
c223da83
JA
2532 {
2533 .name = "clocksource",
e8b0e958 2534 .lname = "Clock source",
c223da83
JA
2535 .type = FIO_OPT_STR,
2536 .cb = fio_clock_source_cb,
a609f12a 2537 .off1 = offsetof(struct thread_options, clocksource),
c223da83 2538 .help = "What type of timing source to use",
e8b0e958 2539 .category = FIO_OPT_C_GENERAL,
10860056 2540 .group = FIO_OPT_G_CLOCK,
c223da83 2541 .posval = {
67bf9823 2542#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2543 { .ival = "gettimeofday",
2544 .oval = CS_GTOD,
2545 .help = "Use gettimeofday(2) for timing",
2546 },
67bf9823
JA
2547#endif
2548#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2549 { .ival = "clock_gettime",
2550 .oval = CS_CGETTIME,
2551 .help = "Use clock_gettime(2) for timing",
2552 },
67bf9823 2553#endif
c223da83
JA
2554#ifdef ARCH_HAVE_CPU_CLOCK
2555 { .ival = "cpu",
2556 .oval = CS_CPUCLOCK,
2557 .help = "Use CPU private clock",
2558 },
2559#endif
2560 },
2561 },
214e1eca
JA
2562 {
2563 .name = "mem",
d3aad8f2 2564 .alias = "iomem",
e8b0e958 2565 .lname = "I/O Memory",
214e1eca
JA
2566 .type = FIO_OPT_STR,
2567 .cb = str_mem_cb,
a609f12a 2568 .off1 = offsetof(struct thread_options, mem_type),
214e1eca
JA
2569 .help = "Backing type for IO buffers",
2570 .def = "malloc",
e8b0e958
JA
2571 .category = FIO_OPT_C_IO,
2572 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2573 .posval = {
2574 { .ival = "malloc",
2575 .oval = MEM_MALLOC,
2576 .help = "Use malloc(3) for IO buffers",
2577 },
c8931876 2578#ifndef CONFIG_NO_SHM
37c8cdfe
JA
2579 { .ival = "shm",
2580 .oval = MEM_SHM,
2581 .help = "Use shared memory segments for IO buffers",
2582 },
214e1eca
JA
2583#ifdef FIO_HAVE_HUGETLB
2584 { .ival = "shmhuge",
2585 .oval = MEM_SHMHUGE,
2586 .help = "Like shm, but use huge pages",
2587 },
c8931876 2588#endif
b370e46a 2589#endif
37c8cdfe
JA
2590 { .ival = "mmap",
2591 .oval = MEM_MMAP,
2592 .help = "Use mmap(2) (file or anon) for IO buffers",
2593 },
217b0f1d
LG
2594 { .ival = "mmapshared",
2595 .oval = MEM_MMAPSHARED,
2596 .help = "Like mmap, but use the shared flag",
2597 },
214e1eca
JA
2598#ifdef FIO_HAVE_HUGETLB
2599 { .ival = "mmaphuge",
2600 .oval = MEM_MMAPHUGE,
2601 .help = "Like mmap, but use huge pages",
2602 },
2603#endif
2604 },
2605 },
d529ee19
JA
2606 {
2607 .name = "iomem_align",
2608 .alias = "mem_align",
e8b0e958 2609 .lname = "I/O memory alignment",
d529ee19 2610 .type = FIO_OPT_INT,
a609f12a 2611 .off1 = offsetof(struct thread_options, mem_align),
d529ee19
JA
2612 .minval = 0,
2613 .help = "IO memory buffer offset alignment",
2614 .def = "0",
2615 .parent = "iomem",
d71c154c 2616 .hide = 1,
e8b0e958
JA
2617 .category = FIO_OPT_C_IO,
2618 .group = FIO_OPT_G_INVALID,
d529ee19 2619 },
214e1eca
JA
2620 {
2621 .name = "verify",
e8b0e958 2622 .lname = "Verify",
214e1eca 2623 .type = FIO_OPT_STR,
a609f12a 2624 .off1 = offsetof(struct thread_options, verify),
214e1eca
JA
2625 .help = "Verify data written",
2626 .def = "0",
e8b0e958 2627 .category = FIO_OPT_C_IO,
3ceb458f 2628 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2629 .posval = {
2630 { .ival = "0",
2631 .oval = VERIFY_NONE,
2632 .help = "Don't do IO verification",
2633 },
fcca4b58
JA
2634 { .ival = "md5",
2635 .oval = VERIFY_MD5,
2636 .help = "Use md5 checksums for verification",
2637 },
d77a7af3
JA
2638 { .ival = "crc64",
2639 .oval = VERIFY_CRC64,
2640 .help = "Use crc64 checksums for verification",
2641 },
214e1eca
JA
2642 { .ival = "crc32",
2643 .oval = VERIFY_CRC32,
2644 .help = "Use crc32 checksums for verification",
2645 },
af497e6a 2646 { .ival = "crc32c-intel",
e3aaafc4
JA
2647 .oval = VERIFY_CRC32C,
2648 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2649 },
bac39e0e
JA
2650 { .ival = "crc32c",
2651 .oval = VERIFY_CRC32C,
e3aaafc4 2652 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2653 },
969f7ed3
JA
2654 { .ival = "crc16",
2655 .oval = VERIFY_CRC16,
2656 .help = "Use crc16 checksums for verification",
2657 },
1e154bdb
JA
2658 { .ival = "crc7",
2659 .oval = VERIFY_CRC7,
2660 .help = "Use crc7 checksums for verification",
2661 },
7c353ceb
JA
2662 { .ival = "sha1",
2663 .oval = VERIFY_SHA1,
2664 .help = "Use sha1 checksums for verification",
2665 },
cd14cc10
JA
2666 { .ival = "sha256",
2667 .oval = VERIFY_SHA256,
2668 .help = "Use sha256 checksums for verification",
2669 },
2670 { .ival = "sha512",
2671 .oval = VERIFY_SHA512,
2672 .help = "Use sha512 checksums for verification",
2673 },
844ea602
JA
2674 { .ival = "xxhash",
2675 .oval = VERIFY_XXHASH,
2676 .help = "Use xxhash checksums for verification",
2677 },
b638d82f
RP
2678 /* Meta information was included into verify_header,
2679 * 'meta' verification is implied by default. */
7437ee87 2680 { .ival = "meta",
b638d82f
RP
2681 .oval = VERIFY_HDR_ONLY,
2682 .help = "Use io information for verification. "
2683 "Now is implied by default, thus option is obsolete, "
2684 "don't use it",
7437ee87 2685 },
59245381
JA
2686 { .ival = "pattern",
2687 .oval = VERIFY_PATTERN_NO_HDR,
2688 .help = "Verify strict pattern",
2689 },
36690c9b
JA
2690 {
2691 .ival = "null",
2692 .oval = VERIFY_NULL,
2693 .help = "Pretend to verify",
2694 },
214e1eca
JA
2695 },
2696 },
005c565a
JA
2697 {
2698 .name = "do_verify",
e8b0e958 2699 .lname = "Perform verify step",
68e1f29a 2700 .type = FIO_OPT_BOOL,
a609f12a 2701 .off1 = offsetof(struct thread_options, do_verify),
005c565a
JA
2702 .help = "Run verification stage after write",
2703 .def = "1",
2704 .parent = "verify",
d71c154c 2705 .hide = 1,
e8b0e958
JA
2706 .category = FIO_OPT_C_IO,
2707 .group = FIO_OPT_G_VERIFY,
005c565a 2708 },
160b966d
JA
2709 {
2710 .name = "verifysort",
e8b0e958 2711 .lname = "Verify sort",
160b966d 2712 .type = FIO_OPT_BOOL,
a609f12a 2713 .off1 = offsetof(struct thread_options, verifysort),
160b966d
JA
2714 .help = "Sort written verify blocks for read back",
2715 .def = "1",
c83f2df1 2716 .parent = "verify",
d71c154c 2717 .hide = 1,
e8b0e958
JA
2718 .category = FIO_OPT_C_IO,
2719 .group = FIO_OPT_G_VERIFY,
160b966d 2720 },
1ae83d45
JA
2721 {
2722 .name = "verifysort_nr",
cce2fdfe 2723 .lname = "Verify Sort Nr",
1ae83d45 2724 .type = FIO_OPT_INT,
a609f12a 2725 .off1 = offsetof(struct thread_options, verifysort_nr),
1ae83d45
JA
2726 .help = "Pre-load and sort verify blocks for a read workload",
2727 .minval = 0,
2728 .maxval = 131072,
2729 .def = "1024",
2730 .parent = "verify",
836fcc0f
JA
2731 .category = FIO_OPT_C_IO,
2732 .group = FIO_OPT_G_VERIFY,
1ae83d45 2733 },
3f9f4e26 2734 {
a59e170d 2735 .name = "verify_interval",
e8b0e958 2736 .lname = "Verify interval",
e01b22b8 2737 .type = FIO_OPT_INT,
a609f12a 2738 .off1 = offsetof(struct thread_options, verify_interval),
819a9680 2739 .minval = 2 * sizeof(struct verify_header),
a59e170d 2740 .help = "Store verify buffer header every N bytes",
afdf9352 2741 .parent = "verify",
d71c154c 2742 .hide = 1,
20eb06bd 2743 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2744 .category = FIO_OPT_C_IO,
2745 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2746 },
546a9142 2747 {
a59e170d 2748 .name = "verify_offset",
e8b0e958 2749 .lname = "Verify offset",
e01b22b8 2750 .type = FIO_OPT_INT,
a59e170d 2751 .help = "Offset verify header location by N bytes",
a609f12a 2752 .off1 = offsetof(struct thread_options, verify_offset),
203160d5 2753 .minval = sizeof(struct verify_header),
afdf9352 2754 .parent = "verify",
d71c154c 2755 .hide = 1,
e8b0e958
JA
2756 .category = FIO_OPT_C_IO,
2757 .group = FIO_OPT_G_VERIFY,
546a9142 2758 },
e28218f3
SL
2759 {
2760 .name = "verify_pattern",
e8b0e958 2761 .lname = "Verify pattern",
0e92f873 2762 .type = FIO_OPT_STR,
e28218f3 2763 .cb = str_verify_pattern_cb,
a609f12a 2764 .off1 = offsetof(struct thread_options, verify_pattern),
e28218f3
SL
2765 .help = "Fill pattern for IO buffers",
2766 .parent = "verify",
d71c154c 2767 .hide = 1,
e8b0e958
JA
2768 .category = FIO_OPT_C_IO,
2769 .group = FIO_OPT_G_VERIFY,
e28218f3 2770 },
a12a3b4d
JA
2771 {
2772 .name = "verify_fatal",
e8b0e958 2773 .lname = "Verify fatal",
68e1f29a 2774 .type = FIO_OPT_BOOL,
a609f12a 2775 .off1 = offsetof(struct thread_options, verify_fatal),
a12a3b4d
JA
2776 .def = "0",
2777 .help = "Exit on a single verify failure, don't continue",
2778 .parent = "verify",
d71c154c 2779 .hide = 1,
e8b0e958
JA
2780 .category = FIO_OPT_C_IO,
2781 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2782 },
b463e936
JA
2783 {
2784 .name = "verify_dump",
e8b0e958 2785 .lname = "Verify dump",
b463e936 2786 .type = FIO_OPT_BOOL,
a609f12a 2787 .off1 = offsetof(struct thread_options, verify_dump),
ef71e317 2788 .def = "0",
b463e936
JA
2789 .help = "Dump contents of good and bad blocks on failure",
2790 .parent = "verify",
d71c154c 2791 .hide = 1,
e8b0e958
JA
2792 .category = FIO_OPT_C_IO,
2793 .group = FIO_OPT_G_VERIFY,
b463e936 2794 },
e8462bd8
JA
2795 {
2796 .name = "verify_async",
e8b0e958 2797 .lname = "Verify asynchronously",
e8462bd8 2798 .type = FIO_OPT_INT,
a609f12a 2799 .off1 = offsetof(struct thread_options, verify_async),
e8462bd8
JA
2800 .def = "0",
2801 .help = "Number of async verifier threads to use",
2802 .parent = "verify",
d71c154c 2803 .hide = 1,
e8b0e958
JA
2804 .category = FIO_OPT_C_IO,
2805 .group = FIO_OPT_G_VERIFY,
e8462bd8 2806 },
9e144189
JA
2807 {
2808 .name = "verify_backlog",
e8b0e958 2809 .lname = "Verify backlog",
9e144189 2810 .type = FIO_OPT_STR_VAL,
a609f12a 2811 .off1 = offsetof(struct thread_options, verify_backlog),
9e144189
JA
2812 .help = "Verify after this number of blocks are written",
2813 .parent = "verify",
d71c154c 2814 .hide = 1,
e8b0e958
JA
2815 .category = FIO_OPT_C_IO,
2816 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2817 },
2818 {
2819 .name = "verify_backlog_batch",
e8b0e958 2820 .lname = "Verify backlog batch",
9e144189 2821 .type = FIO_OPT_INT,
a609f12a 2822 .off1 = offsetof(struct thread_options, verify_batch),
9e144189 2823 .help = "Verify this number of IO blocks",
0d29de83 2824 .parent = "verify",
d71c154c 2825 .hide = 1,
e8b0e958
JA
2826 .category = FIO_OPT_C_IO,
2827 .group = FIO_OPT_G_VERIFY,
9e144189 2828 },
e8462bd8
JA
2829#ifdef FIO_HAVE_CPU_AFFINITY
2830 {
2831 .name = "verify_async_cpus",
e8b0e958 2832 .lname = "Async verify CPUs",
e8462bd8
JA
2833 .type = FIO_OPT_STR,
2834 .cb = str_verify_cpus_allowed_cb,
a609f12a 2835 .off1 = offsetof(struct thread_options, verify_cpumask),
e8462bd8
JA
2836 .help = "Set CPUs allowed for async verify threads",
2837 .parent = "verify_async",
d71c154c 2838 .hide = 1,
e8b0e958
JA
2839 .category = FIO_OPT_C_IO,
2840 .group = FIO_OPT_G_VERIFY,
e8462bd8 2841 },
a275c37a
JA
2842#else
2843 {
2844 .name = "verify_async_cpus",
2845 .lname = "Async verify CPUs",
2846 .type = FIO_OPT_UNSUPPORTED,
54d0a315 2847 .help = "Your platform does not support CPU affinities",
a275c37a 2848 },
0d29de83 2849#endif
51aa2da8
JA
2850 {
2851 .name = "experimental_verify",
cce2fdfe 2852 .lname = "Experimental Verify",
a609f12a 2853 .off1 = offsetof(struct thread_options, experimental_verify),
51aa2da8 2854 .type = FIO_OPT_BOOL,
b31eaac9 2855 .help = "Enable experimental verification",
ca09be4b
JA
2856 .parent = "verify",
2857 .category = FIO_OPT_C_IO,
2858 .group = FIO_OPT_G_VERIFY,
2859 },
2860 {
2861 .name = "verify_state_load",
2862 .lname = "Load verify state",
a609f12a 2863 .off1 = offsetof(struct thread_options, verify_state),
ca09be4b
JA
2864 .type = FIO_OPT_BOOL,
2865 .help = "Load verify termination state",
2866 .parent = "verify",
2867 .category = FIO_OPT_C_IO,
2868 .group = FIO_OPT_G_VERIFY,
2869 },
2870 {
2871 .name = "verify_state_save",
2872 .lname = "Save verify state",
a609f12a 2873 .off1 = offsetof(struct thread_options, verify_state_save),
ca09be4b
JA
2874 .type = FIO_OPT_BOOL,
2875 .def = "1",
2876 .help = "Save verify state on termination",
2877 .parent = "verify",
836fcc0f
JA
2878 .category = FIO_OPT_C_IO,
2879 .group = FIO_OPT_G_VERIFY,
51aa2da8 2880 },
0d29de83
JA
2881#ifdef FIO_HAVE_TRIM
2882 {
2883 .name = "trim_percentage",
e8b0e958 2884 .lname = "Trim percentage",
0d29de83 2885 .type = FIO_OPT_INT,
a609f12a 2886 .off1 = offsetof(struct thread_options, trim_percentage),
20eb06bd 2887 .minval = 0,
0d29de83 2888 .maxval = 100,
169c098d 2889 .help = "Number of verify blocks to trim (i.e., discard)",
0d29de83
JA
2890 .parent = "verify",
2891 .def = "0",
20eb06bd 2892 .interval = 1,
d71c154c 2893 .hide = 1,
e8b0e958
JA
2894 .category = FIO_OPT_C_IO,
2895 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2896 },
2897 {
2898 .name = "trim_verify_zero",
e8b0e958 2899 .lname = "Verify trim zero",
20eb06bd 2900 .type = FIO_OPT_BOOL,
169c098d 2901 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
a609f12a 2902 .off1 = offsetof(struct thread_options, trim_zero),
0d29de83 2903 .parent = "trim_percentage",
d71c154c 2904 .hide = 1,
0d29de83 2905 .def = "1",
e8b0e958
JA
2906 .category = FIO_OPT_C_IO,
2907 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2908 },
2909 {
2910 .name = "trim_backlog",
e8b0e958 2911 .lname = "Trim backlog",
0d29de83 2912 .type = FIO_OPT_STR_VAL,
a609f12a 2913 .off1 = offsetof(struct thread_options, trim_backlog),
0d29de83
JA
2914 .help = "Trim after this number of blocks are written",
2915 .parent = "trim_percentage",
d71c154c 2916 .hide = 1,
20eb06bd 2917 .interval = 1,
e8b0e958
JA
2918 .category = FIO_OPT_C_IO,
2919 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2920 },
2921 {
2922 .name = "trim_backlog_batch",
e8b0e958 2923 .lname = "Trim backlog batch",
0d29de83 2924 .type = FIO_OPT_INT,
a609f12a 2925 .off1 = offsetof(struct thread_options, trim_batch),
0d29de83
JA
2926 .help = "Trim this number of IO blocks",
2927 .parent = "trim_percentage",
d71c154c 2928 .hide = 1,
20eb06bd 2929 .interval = 1,
e8b0e958
JA
2930 .category = FIO_OPT_C_IO,
2931 .group = FIO_OPT_G_TRIM,
0d29de83 2932 },
a275c37a
JA
2933#else
2934 {
2935 .name = "trim_percentage",
2936 .lname = "Trim percentage",
2937 .type = FIO_OPT_UNSUPPORTED,
2938 .help = "Fio does not support TRIM on your platform",
2939 },
2940 {
2941 .name = "trim_verify_zero",
2942 .lname = "Verify trim zero",
2943 .type = FIO_OPT_UNSUPPORTED,
2944 .help = "Fio does not support TRIM on your platform",
2945 },
2946 {
2947 .name = "trim_backlog",
2948 .lname = "Trim backlog",
2949 .type = FIO_OPT_UNSUPPORTED,
2950 .help = "Fio does not support TRIM on your platform",
2951 },
2952 {
2953 .name = "trim_backlog_batch",
2954 .lname = "Trim backlog batch",
2955 .type = FIO_OPT_UNSUPPORTED,
2956 .help = "Fio does not support TRIM on your platform",
2957 },
e8462bd8 2958#endif
214e1eca
JA
2959 {
2960 .name = "write_iolog",
e8b0e958 2961 .lname = "Write I/O log",
214e1eca 2962 .type = FIO_OPT_STR_STORE,
a609f12a 2963 .off1 = offsetof(struct thread_options, write_iolog_file),
214e1eca 2964 .help = "Store IO pattern to file",
e8b0e958
JA
2965 .category = FIO_OPT_C_IO,
2966 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2967 },
2968 {
2969 .name = "read_iolog",
e8b0e958 2970 .lname = "Read I/O log",
214e1eca 2971 .type = FIO_OPT_STR_STORE,
a609f12a 2972 .off1 = offsetof(struct thread_options, read_iolog_file),
214e1eca 2973 .help = "Playback IO pattern from file",
e8b0e958
JA
2974 .category = FIO_OPT_C_IO,
2975 .group = FIO_OPT_G_IOLOG,
214e1eca 2976 },
64bbb865
DN
2977 {
2978 .name = "replay_no_stall",
e8b0e958 2979 .lname = "Don't stall on replay",
20eb06bd 2980 .type = FIO_OPT_BOOL,
a609f12a 2981 .off1 = offsetof(struct thread_options, no_stall),
64bbb865 2982 .def = "0",
87e7a972 2983 .parent = "read_iolog",
d71c154c 2984 .hide = 1,
64bbb865 2985 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2986 .category = FIO_OPT_C_IO,
2987 .group = FIO_OPT_G_IOLOG,
64bbb865 2988 },
d1c46c04
DN
2989 {
2990 .name = "replay_redirect",
e8b0e958 2991 .lname = "Redirect device for replay",
d1c46c04 2992 .type = FIO_OPT_STR_STORE,
a609f12a 2993 .off1 = offsetof(struct thread_options, replay_redirect),
d1c46c04 2994 .parent = "read_iolog",
d71c154c 2995 .hide = 1,
d1c46c04 2996 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2997 .category = FIO_OPT_C_IO,
2998 .group = FIO_OPT_G_IOLOG,
d1c46c04 2999 },
0c63576e
JA
3000 {
3001 .name = "replay_scale",
3002 .lname = "Replace offset scale factor",
3003 .type = FIO_OPT_INT,
a609f12a 3004 .off1 = offsetof(struct thread_options, replay_scale),
0c63576e
JA
3005 .parent = "read_iolog",
3006 .def = "1",
3007 .help = "Align offsets to this blocksize",
3008 .category = FIO_OPT_C_IO,
3009 .group = FIO_OPT_G_IOLOG,
3010 },
3011 {
3012 .name = "replay_align",
3013 .lname = "Replace alignment",
3014 .type = FIO_OPT_INT,
a609f12a 3015 .off1 = offsetof(struct thread_options, replay_align),
0c63576e
JA
3016 .parent = "read_iolog",
3017 .help = "Scale offset down by this factor",
3018 .category = FIO_OPT_C_IO,
3019 .group = FIO_OPT_G_IOLOG,
3020 .pow2 = 1,
3021 },
214e1eca
JA
3022 {
3023 .name = "exec_prerun",
e8b0e958 3024 .lname = "Pre-execute runnable",
214e1eca 3025 .type = FIO_OPT_STR_STORE,
a609f12a 3026 .off1 = offsetof(struct thread_options, exec_prerun),
214e1eca 3027 .help = "Execute this file prior to running job",
e8b0e958
JA
3028 .category = FIO_OPT_C_GENERAL,
3029 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3030 },
3031 {
3032 .name = "exec_postrun",
e8b0e958 3033 .lname = "Post-execute runnable",
214e1eca 3034 .type = FIO_OPT_STR_STORE,
a609f12a 3035 .off1 = offsetof(struct thread_options, exec_postrun),
214e1eca 3036 .help = "Execute this file after running job",
e8b0e958
JA
3037 .category = FIO_OPT_C_GENERAL,
3038 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3039 },
3040#ifdef FIO_HAVE_IOSCHED_SWITCH
3041 {
3042 .name = "ioscheduler",
e8b0e958 3043 .lname = "I/O scheduler",
214e1eca 3044 .type = FIO_OPT_STR_STORE,
a609f12a 3045 .off1 = offsetof(struct thread_options, ioscheduler),
214e1eca 3046 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
3047 .category = FIO_OPT_C_FILE,
3048 .group = FIO_OPT_G_INVALID,
214e1eca 3049 },
a275c37a
JA
3050#else
3051 {
3052 .name = "ioscheduler",
3053 .lname = "I/O scheduler",
3054 .type = FIO_OPT_UNSUPPORTED,
3055 .help = "Your platform does not support IO scheduler switching",
3056 },
214e1eca
JA
3057#endif
3058 {
3059 .name = "zonesize",
e8b0e958 3060 .lname = "Zone size",
214e1eca 3061 .type = FIO_OPT_STR_VAL,
a609f12a 3062 .off1 = offsetof(struct thread_options, zone_size),
ed335855
SN
3063 .help = "Amount of data to read per zone",
3064 .def = "0",
20eb06bd 3065 .interval = 1024 * 1024,
e8b0e958
JA
3066 .category = FIO_OPT_C_IO,
3067 .group = FIO_OPT_G_ZONE,
ed335855
SN
3068 },
3069 {
3070 .name = "zonerange",
e8b0e958 3071 .lname = "Zone range",
ed335855 3072 .type = FIO_OPT_STR_VAL,
a609f12a 3073 .off1 = offsetof(struct thread_options, zone_range),
214e1eca
JA
3074 .help = "Give size of an IO zone",
3075 .def = "0",
20eb06bd 3076 .interval = 1024 * 1024,
e8b0e958
JA
3077 .category = FIO_OPT_C_IO,
3078 .group = FIO_OPT_G_ZONE,
214e1eca
JA
3079 },
3080 {
3081 .name = "zoneskip",
e8b0e958 3082 .lname = "Zone skip",
214e1eca 3083 .type = FIO_OPT_STR_VAL,
a609f12a 3084 .off1 = offsetof(struct thread_options, zone_skip),
214e1eca
JA
3085 .help = "Space between IO zones",
3086 .def = "0",
20eb06bd 3087 .interval = 1024 * 1024,
e8b0e958
JA
3088 .category = FIO_OPT_C_IO,
3089 .group = FIO_OPT_G_ZONE,
214e1eca
JA
3090 },
3091 {
3092 .name = "lockmem",
e8b0e958 3093 .lname = "Lock memory",
214e1eca 3094 .type = FIO_OPT_STR_VAL,
a609f12a 3095 .off1 = offsetof(struct thread_options, lockmem),
81c6b6cd 3096 .help = "Lock down this amount of memory (per worker)",
214e1eca 3097 .def = "0",
20eb06bd 3098 .interval = 1024 * 1024,
e8b0e958
JA
3099 .category = FIO_OPT_C_GENERAL,
3100 .group = FIO_OPT_G_INVALID,
214e1eca 3101 },
214e1eca
JA
3102 {
3103 .name = "rwmixread",
e8b0e958 3104 .lname = "Read/write mix read",
214e1eca 3105 .type = FIO_OPT_INT,
cb499fc4 3106 .cb = str_rwmix_read_cb,
a609f12a 3107 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
214e1eca
JA
3108 .maxval = 100,
3109 .help = "Percentage of mixed workload that is reads",
3110 .def = "50",
20eb06bd 3111 .interval = 5,
90265353 3112 .inverse = "rwmixwrite",
e8b0e958
JA
3113 .category = FIO_OPT_C_IO,
3114 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
3115 },
3116 {
3117 .name = "rwmixwrite",
e8b0e958 3118 .lname = "Read/write mix write",
214e1eca 3119 .type = FIO_OPT_INT,
cb499fc4 3120 .cb = str_rwmix_write_cb,
a609f12a 3121 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
214e1eca
JA
3122 .maxval = 100,
3123 .help = "Percentage of mixed workload that is writes",
3124 .def = "50",
20eb06bd 3125 .interval = 5,
90265353 3126 .inverse = "rwmixread",
e8b0e958
JA
3127 .category = FIO_OPT_C_IO,
3128 .group = FIO_OPT_G_RWMIX,
214e1eca 3129 },
afdf9352
JA
3130 {
3131 .name = "rwmixcycle",
e8b0e958 3132 .lname = "Read/write mix cycle",
15ca150e 3133 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
3134 .category = FIO_OPT_C_IO,
3135 .group = FIO_OPT_G_RWMIX,
afdf9352 3136 },
214e1eca
JA
3137 {
3138 .name = "nice",
e8b0e958 3139 .lname = "Nice",
214e1eca 3140 .type = FIO_OPT_INT,
a609f12a 3141 .off1 = offsetof(struct thread_options, nice),
214e1eca
JA
3142 .help = "Set job CPU nice value",
3143 .minval = -19,
3144 .maxval = 20,
3145 .def = "0",
20eb06bd 3146 .interval = 1,
e8b0e958 3147 .category = FIO_OPT_C_GENERAL,
10860056 3148 .group = FIO_OPT_G_CRED,
214e1eca
JA
3149 },
3150#ifdef FIO_HAVE_IOPRIO
3151 {
3152 .name = "prio",
e8b0e958 3153 .lname = "I/O nice priority",
214e1eca 3154 .type = FIO_OPT_INT,
a609f12a 3155 .off1 = offsetof(struct thread_options, ioprio),
214e1eca 3156 .help = "Set job IO priority value",
1767bd34
TK
3157 .minval = IOPRIO_MIN_PRIO,
3158 .maxval = IOPRIO_MAX_PRIO,
20eb06bd 3159 .interval = 1,
e8b0e958 3160 .category = FIO_OPT_C_GENERAL,
10860056 3161 .group = FIO_OPT_G_CRED,
214e1eca 3162 },
32ef447a
TK
3163#else
3164 {
3165 .name = "prio",
3166 .lname = "I/O nice priority",
3167 .type = FIO_OPT_UNSUPPORTED,
3168 .help = "Your platform does not support IO priorities",
3169 },
3170#endif
3171#ifdef FIO_HAVE_IOPRIO_CLASS
3172#ifndef FIO_HAVE_IOPRIO
3173#error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3174#endif
214e1eca
JA
3175 {
3176 .name = "prioclass",
e8b0e958 3177 .lname = "I/O nice priority class",
214e1eca 3178 .type = FIO_OPT_INT,
a609f12a 3179 .off1 = offsetof(struct thread_options, ioprio_class),
214e1eca 3180 .help = "Set job IO priority class",
1767bd34
TK
3181 .minval = IOPRIO_MIN_PRIO_CLASS,
3182 .maxval = IOPRIO_MAX_PRIO_CLASS,
20eb06bd 3183 .interval = 1,
e8b0e958 3184 .category = FIO_OPT_C_GENERAL,
10860056 3185 .group = FIO_OPT_G_CRED,
214e1eca 3186 },
a275c37a 3187#else
a275c37a
JA
3188 {
3189 .name = "prioclass",
3190 .lname = "I/O nice priority class",
3191 .type = FIO_OPT_UNSUPPORTED,
32ef447a 3192 .help = "Your platform does not support IO priority classes",
a275c37a 3193 },
214e1eca
JA
3194#endif
3195 {
3196 .name = "thinktime",
e8b0e958 3197 .lname = "Thinktime",
214e1eca 3198 .type = FIO_OPT_INT,
a609f12a 3199 .off1 = offsetof(struct thread_options, thinktime),
214e1eca
JA
3200 .help = "Idle time between IO buffers (usec)",
3201 .def = "0",
88038bc7 3202 .is_time = 1,
e8b0e958 3203 .category = FIO_OPT_C_IO,
3ceb458f 3204 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3205 },
3206 {
3207 .name = "thinktime_spin",
e8b0e958 3208 .lname = "Thinktime spin",
214e1eca 3209 .type = FIO_OPT_INT,
a609f12a 3210 .off1 = offsetof(struct thread_options, thinktime_spin),
214e1eca
JA
3211 .help = "Start think time by spinning this amount (usec)",
3212 .def = "0",
88038bc7 3213 .is_time = 1,
afdf9352 3214 .parent = "thinktime",
d71c154c 3215 .hide = 1,
e8b0e958 3216 .category = FIO_OPT_C_IO,
3ceb458f 3217 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3218 },
3219 {
3220 .name = "thinktime_blocks",
e8b0e958 3221 .lname = "Thinktime blocks",
214e1eca 3222 .type = FIO_OPT_INT,
a609f12a 3223 .off1 = offsetof(struct thread_options, thinktime_blocks),
214e1eca
JA
3224 .help = "IO buffer period between 'thinktime'",
3225 .def = "1",
afdf9352 3226 .parent = "thinktime",
d71c154c 3227 .hide = 1,
e8b0e958 3228 .category = FIO_OPT_C_IO,
3ceb458f 3229 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3230 },
3231 {
3232 .name = "rate",
e8b0e958 3233 .lname = "I/O rate",
e01b22b8 3234 .type = FIO_OPT_INT,
a609f12a
JA
3235 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3236 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3237 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
214e1eca 3238 .help = "Set bandwidth rate",
e8b0e958
JA
3239 .category = FIO_OPT_C_IO,
3240 .group = FIO_OPT_G_RATE,
214e1eca
JA
3241 },
3242 {
6d428bcd
JA
3243 .name = "rate_min",
3244 .alias = "ratemin",
e8b0e958 3245 .lname = "I/O min rate",
e01b22b8 3246 .type = FIO_OPT_INT,
a609f12a
JA
3247 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3248 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3249 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
4e991c23 3250 .help = "Job must meet this rate or it will be shutdown",
afdf9352 3251 .parent = "rate",
d71c154c 3252 .hide = 1,
e8b0e958
JA
3253 .category = FIO_OPT_C_IO,
3254 .group = FIO_OPT_G_RATE,
4e991c23
JA
3255 },
3256 {
3257 .name = "rate_iops",
e8b0e958 3258 .lname = "I/O rate IOPS",
e01b22b8 3259 .type = FIO_OPT_INT,
a609f12a
JA
3260 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3261 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3262 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
4e991c23 3263 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 3264 .hide = 1,
e8b0e958
JA
3265 .category = FIO_OPT_C_IO,
3266 .group = FIO_OPT_G_RATE,
4e991c23
JA
3267 },
3268 {
3269 .name = "rate_iops_min",
e8b0e958 3270 .lname = "I/O min rate IOPS",
e01b22b8 3271 .type = FIO_OPT_INT,
a609f12a
JA
3272 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3273 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3274 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
03e20d68 3275 .help = "Job must meet this rate or it will be shut down",
afdf9352 3276 .parent = "rate_iops",
d71c154c 3277 .hide = 1,
e8b0e958
JA
3278 .category = FIO_OPT_C_IO,
3279 .group = FIO_OPT_G_RATE,
214e1eca 3280 },
ff6bb260 3281 {
6de65959
JA
3282 .name = "rate_process",
3283 .lname = "Rate Process",
3284 .type = FIO_OPT_STR,
a609f12a 3285 .off1 = offsetof(struct thread_options, rate_process),
6de65959
JA
3286 .help = "What process controls how rated IO is managed",
3287 .def = "linear",
ff6bb260
SL
3288 .category = FIO_OPT_C_IO,
3289 .group = FIO_OPT_G_RATE,
6de65959
JA
3290 .posval = {
3291 { .ival = "linear",
3292 .oval = RATE_PROCESS_LINEAR,
3293 .help = "Linear rate of IO",
3294 },
3295 {
3296 .ival = "poisson",
3297 .oval = RATE_PROCESS_POISSON,
3298 .help = "Rate follows Poisson process",
3299 },
3300 },
3301 .parent = "rate",
ff6bb260 3302 },
214e1eca 3303 {
6d428bcd
JA
3304 .name = "rate_cycle",
3305 .alias = "ratecycle",
e8b0e958 3306 .lname = "I/O rate cycle",
214e1eca 3307 .type = FIO_OPT_INT,
a609f12a 3308 .off1 = offsetof(struct thread_options, ratecycle),
214e1eca
JA
3309 .help = "Window average for rate limits (msec)",
3310 .def = "1000",
afdf9352 3311 .parent = "rate",
d71c154c 3312 .hide = 1,
e8b0e958
JA
3313 .category = FIO_OPT_C_IO,
3314 .group = FIO_OPT_G_RATE,
214e1eca 3315 },
15501535
JA
3316 {
3317 .name = "max_latency",
cce2fdfe 3318 .lname = "Max Latency",
15501535 3319 .type = FIO_OPT_INT,
a609f12a 3320 .off1 = offsetof(struct thread_options, max_latency),
15501535 3321 .help = "Maximum tolerated IO latency (usec)",
88038bc7 3322 .is_time = 1,
1e5324e7 3323 .category = FIO_OPT_C_IO,
3e260a46
JA
3324 .group = FIO_OPT_G_LATPROF,
3325 },
3326 {
3327 .name = "latency_target",
3328 .lname = "Latency Target (usec)",
3329 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3330 .off1 = offsetof(struct thread_options, latency_target),
3e260a46 3331 .help = "Ramp to max queue depth supporting this latency",
88038bc7 3332 .is_time = 1,
3e260a46
JA
3333 .category = FIO_OPT_C_IO,
3334 .group = FIO_OPT_G_LATPROF,
3335 },
3336 {
3337 .name = "latency_window",
3338 .lname = "Latency Window (usec)",
3339 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3340 .off1 = offsetof(struct thread_options, latency_window),
3e260a46 3341 .help = "Time to sustain latency_target",
88038bc7 3342 .is_time = 1,
3e260a46
JA
3343 .category = FIO_OPT_C_IO,
3344 .group = FIO_OPT_G_LATPROF,
3345 },
3346 {
3347 .name = "latency_percentile",
3348 .lname = "Latency Percentile",
3349 .type = FIO_OPT_FLOAT_LIST,
a609f12a 3350 .off1 = offsetof(struct thread_options, latency_percentile),
3e260a46
JA
3351 .help = "Percentile of IOs must be below latency_target",
3352 .def = "100",
3353 .maxlen = 1,
3354 .minfp = 0.0,
3355 .maxfp = 100.0,
3356 .category = FIO_OPT_C_IO,
3357 .group = FIO_OPT_G_LATPROF,
15501535 3358 },
214e1eca
JA
3359 {
3360 .name = "invalidate",
e8b0e958 3361 .lname = "Cache invalidate",
214e1eca 3362 .type = FIO_OPT_BOOL,
a609f12a 3363 .off1 = offsetof(struct thread_options, invalidate_cache),
214e1eca
JA
3364 .help = "Invalidate buffer/page cache prior to running job",
3365 .def = "1",
e8b0e958 3366 .category = FIO_OPT_C_IO,
3ceb458f 3367 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
3368 },
3369 {
3370 .name = "sync",
e8b0e958 3371 .lname = "Synchronous I/O",
214e1eca 3372 .type = FIO_OPT_BOOL,
a609f12a 3373 .off1 = offsetof(struct thread_options, sync_io),
214e1eca
JA
3374 .help = "Use O_SYNC for buffered writes",
3375 .def = "0",
67a1000f 3376 .parent = "buffered",
d71c154c 3377 .hide = 1,
e8b0e958 3378 .category = FIO_OPT_C_IO,
3ceb458f 3379 .group = FIO_OPT_G_IO_TYPE,
214e1eca 3380 },
214e1eca
JA
3381 {
3382 .name = "create_serialize",
e8b0e958 3383 .lname = "Create serialize",
214e1eca 3384 .type = FIO_OPT_BOOL,
a609f12a 3385 .off1 = offsetof(struct thread_options, create_serialize),
c2b8035f 3386 .help = "Serialize creation of job files",
214e1eca 3387 .def = "1",
e8b0e958
JA
3388 .category = FIO_OPT_C_FILE,
3389 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3390 },
3391 {
3392 .name = "create_fsync",
e8b0e958 3393 .lname = "Create fsync",
214e1eca 3394 .type = FIO_OPT_BOOL,
a609f12a 3395 .off1 = offsetof(struct thread_options, create_fsync),
03e20d68 3396 .help = "fsync file after creation",
214e1eca 3397 .def = "1",
e8b0e958
JA
3398 .category = FIO_OPT_C_FILE,
3399 .group = FIO_OPT_G_INVALID,
214e1eca 3400 },
814452bd
JA
3401 {
3402 .name = "create_on_open",
e8b0e958 3403 .lname = "Create on open",
814452bd 3404 .type = FIO_OPT_BOOL,
a609f12a 3405 .off1 = offsetof(struct thread_options, create_on_open),
814452bd
JA
3406 .help = "Create files when they are opened for IO",
3407 .def = "0",
e8b0e958
JA
3408 .category = FIO_OPT_C_FILE,
3409 .group = FIO_OPT_G_INVALID,
814452bd 3410 },
25460cf6
JA
3411 {
3412 .name = "create_only",
cce2fdfe 3413 .lname = "Create Only",
25460cf6 3414 .type = FIO_OPT_BOOL,
a609f12a 3415 .off1 = offsetof(struct thread_options, create_only),
25460cf6 3416 .help = "Only perform file creation phase",
d17fda71 3417 .category = FIO_OPT_C_FILE,
25460cf6
JA
3418 .def = "0",
3419 },
2378826d
JA
3420 {
3421 .name = "allow_file_create",
e81ecca3 3422 .lname = "Allow file create",
2378826d 3423 .type = FIO_OPT_BOOL,
a609f12a 3424 .off1 = offsetof(struct thread_options, allow_create),
2378826d
JA
3425 .help = "Permit fio to create files, if they don't exist",
3426 .def = "1",
3427 .category = FIO_OPT_C_FILE,
3428 .group = FIO_OPT_G_FILENAME,
3429 },
e81ecca3
JA
3430 {
3431 .name = "allow_mounted_write",
3432 .lname = "Allow mounted write",
3433 .type = FIO_OPT_BOOL,
a609f12a 3434 .off1 = offsetof(struct thread_options, allow_mounted_write),
e81ecca3
JA
3435 .help = "Allow writes to a mounted partition",
3436 .def = "0",
3437 .category = FIO_OPT_C_FILE,
3438 .group = FIO_OPT_G_FILENAME,
3439 },
0b9d69ec 3440 {
afad68f7 3441 .name = "pre_read",
e8b0e958 3442 .lname = "Pre-read files",
afad68f7 3443 .type = FIO_OPT_BOOL,
a609f12a 3444 .off1 = offsetof(struct thread_options, pre_read),
03e20d68 3445 .help = "Pre-read files before starting official testing",
afad68f7 3446 .def = "0",
e8b0e958
JA
3447 .category = FIO_OPT_C_FILE,
3448 .group = FIO_OPT_G_INVALID,
afad68f7 3449 },
214e1eca
JA
3450#ifdef FIO_HAVE_CPU_AFFINITY
3451 {
3452 .name = "cpumask",
e8b0e958 3453 .lname = "CPU mask",
214e1eca
JA
3454 .type = FIO_OPT_INT,
3455 .cb = str_cpumask_cb,
a609f12a 3456 .off1 = offsetof(struct thread_options, cpumask),
214e1eca 3457 .help = "CPU affinity mask",
e8b0e958 3458 .category = FIO_OPT_C_GENERAL,
10860056 3459 .group = FIO_OPT_G_CRED,
214e1eca 3460 },
d2e268b0
JA
3461 {
3462 .name = "cpus_allowed",
e8b0e958 3463 .lname = "CPUs allowed",
d2e268b0
JA
3464 .type = FIO_OPT_STR,
3465 .cb = str_cpus_allowed_cb,
a609f12a 3466 .off1 = offsetof(struct thread_options, cpumask),
d2e268b0 3467 .help = "Set CPUs allowed",
e8b0e958 3468 .category = FIO_OPT_C_GENERAL,
10860056 3469 .group = FIO_OPT_G_CRED,
d2e268b0 3470 },
c2acfbac
JA
3471 {
3472 .name = "cpus_allowed_policy",
3473 .lname = "CPUs allowed distribution policy",
3474 .type = FIO_OPT_STR,
a609f12a 3475 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
c2acfbac
JA
3476 .help = "Distribution policy for cpus_allowed",
3477 .parent = "cpus_allowed",
3478 .prio = 1,
3479 .posval = {
3480 { .ival = "shared",
3481 .oval = FIO_CPUS_SHARED,
3482 .help = "Mask shared between threads",
3483 },
3484 { .ival = "split",
3485 .oval = FIO_CPUS_SPLIT,
3486 .help = "Mask split between threads",
3487 },
3488 },
3489 .category = FIO_OPT_C_GENERAL,
3490 .group = FIO_OPT_G_CRED,
3491 },
a275c37a
JA
3492#else
3493 {
3494 .name = "cpumask",
3495 .lname = "CPU mask",
3496 .type = FIO_OPT_UNSUPPORTED,
3497 .help = "Your platform does not support CPU affinities",
3498 },
3499 {
3500 .name = "cpus_allowed",
3501 .lname = "CPUs allowed",
3502 .type = FIO_OPT_UNSUPPORTED,
3503 .help = "Your platform does not support CPU affinities",
3504 },
3505 {
3506 .name = "cpus_allowed_policy",
3507 .lname = "CPUs allowed distribution policy",
3508 .type = FIO_OPT_UNSUPPORTED,
3509 .help = "Your platform does not support CPU affinities",
3510 },
d0b937ed 3511#endif
67bf9823 3512#ifdef CONFIG_LIBNUMA
d0b937ed
YR
3513 {
3514 .name = "numa_cpu_nodes",
cce2fdfe 3515 .lname = "NUMA CPU Nodes",
d0b937ed
YR
3516 .type = FIO_OPT_STR,
3517 .cb = str_numa_cpunodes_cb,
a609f12a 3518 .off1 = offsetof(struct thread_options, numa_cpunodes),
d0b937ed 3519 .help = "NUMA CPU nodes bind",
6be54b2d
JA
3520 .category = FIO_OPT_C_GENERAL,
3521 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
3522 },
3523 {
3524 .name = "numa_mem_policy",
cce2fdfe 3525 .lname = "NUMA Memory Policy",
d0b937ed
YR
3526 .type = FIO_OPT_STR,
3527 .cb = str_numa_mpol_cb,
a609f12a 3528 .off1 = offsetof(struct thread_options, numa_memnodes),
d0b937ed 3529 .help = "NUMA memory policy setup",
6be54b2d
JA
3530 .category = FIO_OPT_C_GENERAL,
3531 .group = FIO_OPT_G_INVALID,
d0b937ed 3532 },
a275c37a
JA
3533#else
3534 {
3535 .name = "numa_cpu_nodes",
3536 .lname = "NUMA CPU Nodes",
3537 .type = FIO_OPT_UNSUPPORTED,
3538 .help = "Build fio with libnuma-dev(el) to enable this option",
3539 },
3540 {
3541 .name = "numa_mem_policy",
3542 .lname = "NUMA Memory Policy",
3543 .type = FIO_OPT_UNSUPPORTED,
3544 .help = "Build fio with libnuma-dev(el) to enable this option",
3545 },
214e1eca
JA
3546#endif
3547 {
3548 .name = "end_fsync",
e8b0e958 3549 .lname = "End fsync",
214e1eca 3550 .type = FIO_OPT_BOOL,
a609f12a 3551 .off1 = offsetof(struct thread_options, end_fsync),
214e1eca
JA
3552 .help = "Include fsync at the end of job",
3553 .def = "0",
e8b0e958
JA
3554 .category = FIO_OPT_C_FILE,
3555 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3556 },
3557 {
3558 .name = "fsync_on_close",
e8b0e958 3559 .lname = "Fsync on close",
214e1eca 3560 .type = FIO_OPT_BOOL,
a609f12a 3561 .off1 = offsetof(struct thread_options, fsync_on_close),
214e1eca
JA
3562 .help = "fsync files on close",
3563 .def = "0",
e8b0e958
JA
3564 .category = FIO_OPT_C_FILE,
3565 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3566 },
3567 {
3568 .name = "unlink",
e8b0e958 3569 .lname = "Unlink file",
214e1eca 3570 .type = FIO_OPT_BOOL,
a609f12a 3571 .off1 = offsetof(struct thread_options, unlink),
214e1eca
JA
3572 .help = "Unlink created files after job has completed",
3573 .def = "0",
e8b0e958
JA
3574 .category = FIO_OPT_C_FILE,
3575 .group = FIO_OPT_G_INVALID,
214e1eca 3576 },
39c1c323 3577 {
3578 .name = "unlink_each_loop",
3579 .lname = "Unlink file after each loop of a job",
3580 .type = FIO_OPT_BOOL,
a609f12a 3581 .off1 = offsetof(struct thread_options, unlink_each_loop),
39c1c323 3582 .help = "Unlink created files after each loop in a job has completed",
3583 .def = "0",
3584 .category = FIO_OPT_C_FILE,
3585 .group = FIO_OPT_G_INVALID,
3586 },
214e1eca
JA
3587 {
3588 .name = "exitall",
e8b0e958 3589 .lname = "Exit-all on terminate",
214e1eca
JA
3590 .type = FIO_OPT_STR_SET,
3591 .cb = str_exitall_cb,
3592 .help = "Terminate all jobs when one exits",
e8b0e958 3593 .category = FIO_OPT_C_GENERAL,
a1f6afec 3594 .group = FIO_OPT_G_PROCESS,
214e1eca 3595 },
f9cafb12
JA
3596 {
3597 .name = "exitall_on_error",
3598 .lname = "Exit-all on terminate in error",
78abcf9b 3599 .type = FIO_OPT_STR_SET,
a609f12a 3600 .off1 = offsetof(struct thread_options, exitall_error),
f9cafb12
JA
3601 .help = "Terminate all jobs when one exits in error",
3602 .category = FIO_OPT_C_GENERAL,
3603 .group = FIO_OPT_G_PROCESS,
3604 },
214e1eca
JA
3605 {
3606 .name = "stonewall",
e8b0e958 3607 .lname = "Wait for previous",
d392365e 3608 .alias = "wait_for_previous",
214e1eca 3609 .type = FIO_OPT_STR_SET,
a609f12a 3610 .off1 = offsetof(struct thread_options, stonewall),
214e1eca 3611 .help = "Insert a hard barrier between this job and previous",
e8b0e958 3612 .category = FIO_OPT_C_GENERAL,
a1f6afec 3613 .group = FIO_OPT_G_PROCESS,
214e1eca 3614 },
b3d62a75
JA
3615 {
3616 .name = "new_group",
e8b0e958 3617 .lname = "New group",
b3d62a75 3618 .type = FIO_OPT_STR_SET,
a609f12a 3619 .off1 = offsetof(struct thread_options, new_group),
b3d62a75 3620 .help = "Mark the start of a new group (for reporting)",
e8b0e958 3621 .category = FIO_OPT_C_GENERAL,
a1f6afec 3622 .group = FIO_OPT_G_PROCESS,
b3d62a75 3623 },
214e1eca
JA
3624 {
3625 .name = "thread",
e8b0e958 3626 .lname = "Thread",
214e1eca 3627 .type = FIO_OPT_STR_SET,
a609f12a 3628 .off1 = offsetof(struct thread_options, use_thread),
20eb06bd 3629 .help = "Use threads instead of processes",
c8931876
JA
3630#ifdef CONFIG_NO_SHM
3631 .def = "1",
3632 .no_warn_def = 1,
3633#endif
e8b0e958 3634 .category = FIO_OPT_C_GENERAL,
a1f6afec 3635 .group = FIO_OPT_G_PROCESS,
214e1eca 3636 },
3a5db920
JA
3637 {
3638 .name = "per_job_logs",
cce2fdfe 3639 .lname = "Per Job Logs",
3a5db920 3640 .type = FIO_OPT_BOOL,
a609f12a 3641 .off1 = offsetof(struct thread_options, per_job_logs),
3a5db920
JA
3642 .help = "Include job number in generated log files or not",
3643 .def = "1",
3644 .category = FIO_OPT_C_LOG,
3645 .group = FIO_OPT_G_INVALID,
3646 },
214e1eca
JA
3647 {
3648 .name = "write_bw_log",
e8b0e958 3649 .lname = "Write bandwidth log",
dded427c 3650 .type = FIO_OPT_STR,
a609f12a 3651 .off1 = offsetof(struct thread_options, bw_log_file),
dded427c 3652 .cb = str_write_bw_log_cb,
214e1eca 3653 .help = "Write log of bandwidth during run",
e8b0e958
JA
3654 .category = FIO_OPT_C_LOG,
3655 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3656 },
3657 {
3658 .name = "write_lat_log",
e8b0e958 3659 .lname = "Write latency log",
dded427c 3660 .type = FIO_OPT_STR,
a609f12a 3661 .off1 = offsetof(struct thread_options, lat_log_file),
dded427c 3662 .cb = str_write_lat_log_cb,
214e1eca 3663 .help = "Write log of latency during run",
e8b0e958
JA
3664 .category = FIO_OPT_C_LOG,
3665 .group = FIO_OPT_G_INVALID,
214e1eca 3666 },
c8eeb9df
JA
3667 {
3668 .name = "write_iops_log",
e8b0e958 3669 .lname = "Write IOPS log",
dded427c 3670 .type = FIO_OPT_STR,
a609f12a 3671 .off1 = offsetof(struct thread_options, iops_log_file),
dded427c 3672 .cb = str_write_iops_log_cb,
c8eeb9df 3673 .help = "Write log of IOPS during run",
e8b0e958
JA
3674 .category = FIO_OPT_C_LOG,
3675 .group = FIO_OPT_G_INVALID,
c8eeb9df 3676 },
b8bc8cba
JA
3677 {
3678 .name = "log_avg_msec",
e8b0e958 3679 .lname = "Log averaging (msec)",
b8bc8cba 3680 .type = FIO_OPT_INT,
a609f12a 3681 .off1 = offsetof(struct thread_options, log_avg_msec),
b8bc8cba
JA
3682 .help = "Average bw/iops/lat logs over this period of time",
3683 .def = "0",
e8b0e958 3684 .category = FIO_OPT_C_LOG,
1e613c9c
KC
3685 .group = FIO_OPT_G_INVALID,
3686 },
3687 {
3688 .name = "log_hist_msec",
3689 .lname = "Log histograms (msec)",
3690 .type = FIO_OPT_INT,
a609f12a 3691 .off1 = offsetof(struct thread_options, log_hist_msec),
1e613c9c
KC
3692 .help = "Dump completion latency histograms at frequency of this time value",
3693 .def = "0",
3694 .category = FIO_OPT_C_LOG,
3695 .group = FIO_OPT_G_INVALID,
3696 },
3697 {
3698 .name = "log_hist_coarseness",
3699 .lname = "Histogram logs coarseness",
3700 .type = FIO_OPT_INT,
a609f12a 3701 .off1 = offsetof(struct thread_options, log_hist_coarseness),
1e613c9c
KC
3702 .help = "Integer in range [0,6]. Higher coarseness outputs"
3703 " fewer histogram bins per sample. The number of bins for"
3704 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3705 .def = "0",
3706 .category = FIO_OPT_C_LOG,
3707 .group = FIO_OPT_G_INVALID,
3708 },
3709 {
3710 .name = "write_hist_log",
3711 .lname = "Write latency histogram logs",
dded427c 3712 .type = FIO_OPT_STR,
a609f12a 3713 .off1 = offsetof(struct thread_options, hist_log_file),
dded427c 3714 .cb = str_write_hist_log_cb,
1e613c9c
KC
3715 .help = "Write log of latency histograms during run",
3716 .category = FIO_OPT_C_LOG,
e8b0e958 3717 .group = FIO_OPT_G_INVALID,
b8bc8cba 3718 },
e6989e10
JA
3719 {
3720 .name = "log_max_value",
3721 .lname = "Log maximum instead of average",
3722 .type = FIO_OPT_BOOL,
a609f12a 3723 .off1 = offsetof(struct thread_options, log_max),
e6989e10
JA
3724 .help = "Log max sample in a window instead of average",
3725 .def = "0",
3726 .category = FIO_OPT_C_LOG,
3727 .group = FIO_OPT_G_INVALID,
3728 },
ae588852
JA
3729 {
3730 .name = "log_offset",
3731 .lname = "Log offset of IO",
3732 .type = FIO_OPT_BOOL,
a609f12a 3733 .off1 = offsetof(struct thread_options, log_offset),
ae588852
JA
3734 .help = "Include offset of IO for each log entry",
3735 .def = "0",
3736 .category = FIO_OPT_C_LOG,
3737 .group = FIO_OPT_G_INVALID,
3738 },
aee2ab67
JA
3739#ifdef CONFIG_ZLIB
3740 {
3741 .name = "log_compression",
3742 .lname = "Log compression",
3743 .type = FIO_OPT_INT,
a609f12a 3744 .off1 = offsetof(struct thread_options, log_gz),
aee2ab67 3745 .help = "Log in compressed chunks of this size",
9919b27b 3746 .minval = 1024ULL,
aee2ab67
JA
3747 .maxval = 512 * 1024 * 1024ULL,
3748 .category = FIO_OPT_C_LOG,
3749 .group = FIO_OPT_G_INVALID,
3750 },
c08f9fe2
JA
3751#ifdef FIO_HAVE_CPU_AFFINITY
3752 {
3753 .name = "log_compression_cpus",
3754 .lname = "Log Compression CPUs",
3755 .type = FIO_OPT_STR,
3756 .cb = str_log_cpus_allowed_cb,
a609f12a 3757 .off1 = offsetof(struct thread_options, log_gz_cpumask),
c08f9fe2
JA
3758 .parent = "log_compression",
3759 .help = "Limit log compression to these CPUs",
3760 .category = FIO_OPT_C_LOG,
3761 .group = FIO_OPT_G_INVALID,
3762 },
a275c37a
JA
3763#else
3764 {
3765 .name = "log_compression_cpus",
3766 .lname = "Log Compression CPUs",
3767 .type = FIO_OPT_UNSUPPORTED,
3768 .help = "Your platform does not support CPU affinities",
3769 },
c08f9fe2 3770#endif
b26317c9
JA
3771 {
3772 .name = "log_store_compressed",
3773 .lname = "Log store compressed",
3774 .type = FIO_OPT_BOOL,
a609f12a 3775 .off1 = offsetof(struct thread_options, log_gz_store),
b26317c9
JA
3776 .help = "Store logs in a compressed format",
3777 .category = FIO_OPT_C_LOG,
3778 .group = FIO_OPT_G_INVALID,
3779 },
a275c37a
JA
3780#else
3781 {
3782 .name = "log_compression",
3783 .lname = "Log compression",
3784 .type = FIO_OPT_UNSUPPORTED,
3785 .help = "Install libz-dev(el) to get compression support",
3786 },
3787 {
3788 .name = "log_store_compressed",
3789 .lname = "Log store compressed",
3790 .type = FIO_OPT_UNSUPPORTED,
3791 .help = "Install libz-dev(el) to get compression support",
3792 },
aee2ab67 3793#endif
3aea75b1
KC
3794 {
3795 .name = "log_unix_epoch",
3796 .lname = "Log epoch unix",
3797 .type = FIO_OPT_BOOL,
3798 .off1 = offsetof(struct thread_options, log_unix_epoch),
3799 .help = "Use Unix time in log files",
3800 .category = FIO_OPT_C_LOG,
3801 .group = FIO_OPT_G_INVALID,
3802 },
66347cfa
DE
3803 {
3804 .name = "block_error_percentiles",
3805 .lname = "Block error percentiles",
3806 .type = FIO_OPT_BOOL,
a609f12a 3807 .off1 = offsetof(struct thread_options, block_error_hist),
66347cfa
DE
3808 .help = "Record trim block errors and make a histogram",
3809 .def = "0",
3810 .category = FIO_OPT_C_LOG,
3811 .group = FIO_OPT_G_INVALID,
3812 },
c504ee55
JA
3813 {
3814 .name = "bwavgtime",
3815 .lname = "Bandwidth average time",
3816 .type = FIO_OPT_INT,
a609f12a 3817 .off1 = offsetof(struct thread_options, bw_avg_time),
c504ee55
JA
3818 .help = "Time window over which to calculate bandwidth"
3819 " (msec)",
3820 .def = "500",
3821 .parent = "write_bw_log",
3822 .hide = 1,
3823 .interval = 100,
3824 .category = FIO_OPT_C_LOG,
3825 .group = FIO_OPT_G_INVALID,
3826 },
3827 {
3828 .name = "iopsavgtime",
3829 .lname = "IOPS average time",
3830 .type = FIO_OPT_INT,
a609f12a 3831 .off1 = offsetof(struct thread_options, iops_avg_time),
c504ee55
JA
3832 .help = "Time window over which to calculate IOPS (msec)",
3833 .def = "500",
3834 .parent = "write_iops_log",
3835 .hide = 1,
3836 .interval = 100,
3837 .category = FIO_OPT_C_LOG,
3838 .group = FIO_OPT_G_INVALID,
3839 },
214e1eca
JA
3840 {
3841 .name = "group_reporting",
e8b0e958 3842 .lname = "Group reporting",
d2507043 3843 .type = FIO_OPT_STR_SET,
a609f12a 3844 .off1 = offsetof(struct thread_options, group_reporting),
214e1eca 3845 .help = "Do reporting on a per-group basis",
10860056 3846 .category = FIO_OPT_C_STAT,
e8b0e958 3847 .group = FIO_OPT_G_INVALID,
214e1eca 3848 },
e9459e5a
JA
3849 {
3850 .name = "zero_buffers",
e8b0e958 3851 .lname = "Zero I/O buffers",
e9459e5a 3852 .type = FIO_OPT_STR_SET,
a609f12a 3853 .off1 = offsetof(struct thread_options, zero_buffers),
e9459e5a 3854 .help = "Init IO buffers to all zeroes",
e8b0e958 3855 .category = FIO_OPT_C_IO,
3ceb458f 3856 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3857 },
5973cafb
JA
3858 {
3859 .name = "refill_buffers",
e8b0e958 3860 .lname = "Refill I/O buffers",
5973cafb 3861 .type = FIO_OPT_STR_SET,
a609f12a 3862 .off1 = offsetof(struct thread_options, refill_buffers),
5973cafb 3863 .help = "Refill IO buffers on every IO submit",
e8b0e958 3864 .category = FIO_OPT_C_IO,
3ceb458f 3865 .group = FIO_OPT_G_IO_BUF,
5973cafb 3866 },
fd68418e
JA
3867 {
3868 .name = "scramble_buffers",
e8b0e958 3869 .lname = "Scramble I/O buffers",
fd68418e 3870 .type = FIO_OPT_BOOL,
a609f12a 3871 .off1 = offsetof(struct thread_options, scramble_buffers),
fd68418e
JA
3872 .help = "Slightly scramble buffers on every IO submit",
3873 .def = "1",
e8b0e958 3874 .category = FIO_OPT_C_IO,
3ceb458f 3875 .group = FIO_OPT_G_IO_BUF,
fd68418e 3876 },
ce35b1ec
JA
3877 {
3878 .name = "buffer_pattern",
3879 .lname = "Buffer pattern",
3880 .type = FIO_OPT_STR,
3881 .cb = str_buffer_pattern_cb,
a609f12a 3882 .off1 = offsetof(struct thread_options, buffer_pattern),
ce35b1ec
JA
3883 .help = "Fill pattern for IO buffers",
3884 .category = FIO_OPT_C_IO,
3885 .group = FIO_OPT_G_IO_BUF,
3886 },
9c42684e
JA
3887 {
3888 .name = "buffer_compress_percentage",
e8b0e958 3889 .lname = "Buffer compression percentage",
9c42684e 3890 .type = FIO_OPT_INT,
bedc9dc2 3891 .cb = str_buffer_compress_cb,
a609f12a 3892 .off1 = offsetof(struct thread_options, compress_percentage),
9c42684e 3893 .maxval = 100,
e7f5de90 3894 .minval = 0,
9c42684e 3895 .help = "How compressible the buffer is (approximately)",
20eb06bd 3896 .interval = 5,
e8b0e958 3897 .category = FIO_OPT_C_IO,
3ceb458f 3898 .group = FIO_OPT_G_IO_BUF,
9c42684e 3899 },
f97a43a1
JA
3900 {
3901 .name = "buffer_compress_chunk",
e8b0e958 3902 .lname = "Buffer compression chunk size",
f97a43a1 3903 .type = FIO_OPT_INT,
a609f12a 3904 .off1 = offsetof(struct thread_options, compress_chunk),
207b18e4 3905 .parent = "buffer_compress_percentage",
d71c154c 3906 .hide = 1,
f97a43a1 3907 .help = "Size of compressible region in buffer",
20eb06bd 3908 .interval = 256,
e8b0e958 3909 .category = FIO_OPT_C_IO,
3ceb458f 3910 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3911 },
5c94b008
JA
3912 {
3913 .name = "dedupe_percentage",
3914 .lname = "Dedupe percentage",
3915 .type = FIO_OPT_INT,
3916 .cb = str_dedupe_cb,
a609f12a 3917 .off1 = offsetof(struct thread_options, dedupe_percentage),
5c94b008
JA
3918 .maxval = 100,
3919 .minval = 0,
3920 .help = "Percentage of buffers that are dedupable",
3921 .interval = 1,
3922 .category = FIO_OPT_C_IO,
3923 .group = FIO_OPT_G_IO_BUF,
3924 },
83349190
YH
3925 {
3926 .name = "clat_percentiles",
e8b0e958 3927 .lname = "Completion latency percentiles",
83349190 3928 .type = FIO_OPT_BOOL,
a609f12a 3929 .off1 = offsetof(struct thread_options, clat_percentiles),
83349190 3930 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3931 .def = "1",
e8b0e958
JA
3932 .category = FIO_OPT_C_STAT,
3933 .group = FIO_OPT_G_INVALID,
83349190
YH
3934 },
3935 {
3936 .name = "percentile_list",
66347cfa 3937 .lname = "Percentile list",
83349190 3938 .type = FIO_OPT_FLOAT_LIST,
a609f12a
JA
3939 .off1 = offsetof(struct thread_options, percentile_list),
3940 .off2 = offsetof(struct thread_options, percentile_precision),
66347cfa
DE
3941 .help = "Specify a custom list of percentiles to report for "
3942 "completion latency and block errors",
fd112d34 3943 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3944 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3945 .minfp = 0.0,
3946 .maxfp = 100.0,
e8b0e958
JA
3947 .category = FIO_OPT_C_STAT,
3948 .group = FIO_OPT_G_INVALID,
83349190
YH
3949 },
3950
0a839f30
JA
3951#ifdef FIO_HAVE_DISK_UTIL
3952 {
3953 .name = "disk_util",
e8b0e958 3954 .lname = "Disk utilization",
0a839f30 3955 .type = FIO_OPT_BOOL,
a609f12a 3956 .off1 = offsetof(struct thread_options, do_disk_util),
f66ab3c8 3957 .help = "Log disk utilization statistics",
0a839f30 3958 .def = "1",
e8b0e958
JA
3959 .category = FIO_OPT_C_STAT,
3960 .group = FIO_OPT_G_INVALID,
0a839f30 3961 },
a275c37a
JA
3962#else
3963 {
3964 .name = "disk_util",
3965 .lname = "Disk utilization",
3966 .type = FIO_OPT_UNSUPPORTED,
3967 .help = "Your platform does not support disk utilization",
3968 },
0a839f30 3969#endif
993bf48b
JA
3970 {
3971 .name = "gtod_reduce",
e8b0e958 3972 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3973 .type = FIO_OPT_BOOL,
3974 .help = "Greatly reduce number of gettimeofday() calls",
3975 .cb = str_gtod_reduce_cb,
3976 .def = "0",
a4ed77fe 3977 .hide_on_set = 1,
e8b0e958
JA
3978 .category = FIO_OPT_C_STAT,
3979 .group = FIO_OPT_G_INVALID,
993bf48b 3980 },
02af0988
JA
3981 {
3982 .name = "disable_lat",
e8b0e958 3983 .lname = "Disable all latency stats",
02af0988 3984 .type = FIO_OPT_BOOL,
a609f12a 3985 .off1 = offsetof(struct thread_options, disable_lat),
02af0988
JA
3986 .help = "Disable latency numbers",
3987 .parent = "gtod_reduce",
d71c154c 3988 .hide = 1,
02af0988 3989 .def = "0",
e8b0e958
JA
3990 .category = FIO_OPT_C_STAT,
3991 .group = FIO_OPT_G_INVALID,
02af0988 3992 },
9520ebb9
JA
3993 {
3994 .name = "disable_clat",
e8b0e958 3995 .lname = "Disable completion latency stats",
9520ebb9 3996 .type = FIO_OPT_BOOL,
a609f12a 3997 .off1 = offsetof(struct thread_options, disable_clat),
9520ebb9 3998 .help = "Disable completion latency numbers",
993bf48b 3999 .parent = "gtod_reduce",
d71c154c 4000 .hide = 1,
9520ebb9 4001 .def = "0",
e8b0e958
JA
4002 .category = FIO_OPT_C_STAT,
4003 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
4004 },
4005 {
4006 .name = "disable_slat",
e8b0e958 4007 .lname = "Disable submission latency stats",
9520ebb9 4008 .type = FIO_OPT_BOOL,
a609f12a 4009 .off1 = offsetof(struct thread_options, disable_slat),
03e20d68 4010 .help = "Disable submission latency numbers",
993bf48b 4011 .parent = "gtod_reduce",
d71c154c 4012 .hide = 1,
9520ebb9 4013 .def = "0",
e8b0e958
JA
4014 .category = FIO_OPT_C_STAT,
4015 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
4016 },
4017 {
4018 .name = "disable_bw_measurement",
afd2ceff 4019 .alias = "disable_bw",
e8b0e958 4020 .lname = "Disable bandwidth stats",
9520ebb9 4021 .type = FIO_OPT_BOOL,
a609f12a 4022 .off1 = offsetof(struct thread_options, disable_bw),
9520ebb9 4023 .help = "Disable bandwidth logging",
993bf48b 4024 .parent = "gtod_reduce",
d71c154c 4025 .hide = 1,
9520ebb9 4026 .def = "0",
e8b0e958
JA
4027 .category = FIO_OPT_C_STAT,
4028 .group = FIO_OPT_G_INVALID,
9520ebb9 4029 },
be4ecfdf
JA
4030 {
4031 .name = "gtod_cpu",
e8b0e958 4032 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf 4033 .type = FIO_OPT_INT,
a609f12a 4034 .off1 = offsetof(struct thread_options, gtod_cpu),
03e20d68 4035 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 4036 .verify = gtod_cpu_verify,
e8b0e958 4037 .category = FIO_OPT_C_GENERAL,
10860056 4038 .group = FIO_OPT_G_CLOCK,
be4ecfdf 4039 },
771e58be
JA
4040 {
4041 .name = "unified_rw_reporting",
cce2fdfe 4042 .lname = "Unified RW Reporting",
771e58be 4043 .type = FIO_OPT_BOOL,
a609f12a 4044 .off1 = offsetof(struct thread_options, unified_rw_rep),
771e58be
JA
4045 .help = "Unify reporting across data direction",
4046 .def = "0",
90b7a96d
JA
4047 .category = FIO_OPT_C_GENERAL,
4048 .group = FIO_OPT_G_INVALID,
771e58be 4049 },
f2bba182
RR
4050 {
4051 .name = "continue_on_error",
e8b0e958 4052 .lname = "Continue on error",
06842027 4053 .type = FIO_OPT_STR,
a609f12a 4054 .off1 = offsetof(struct thread_options, continue_on_error),
03e20d68 4055 .help = "Continue on non-fatal errors during IO",
06842027 4056 .def = "none",
e8b0e958 4057 .category = FIO_OPT_C_GENERAL,
bc3f552f 4058 .group = FIO_OPT_G_ERR,
06842027
SL
4059 .posval = {
4060 { .ival = "none",
4061 .oval = ERROR_TYPE_NONE,
4062 .help = "Exit when an error is encountered",
4063 },
4064 { .ival = "read",
4065 .oval = ERROR_TYPE_READ,
4066 .help = "Continue on read errors only",
4067 },
4068 { .ival = "write",
4069 .oval = ERROR_TYPE_WRITE,
4070 .help = "Continue on write errors only",
4071 },
4072 { .ival = "io",
4073 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4074 .help = "Continue on any IO errors",
4075 },
4076 { .ival = "verify",
4077 .oval = ERROR_TYPE_VERIFY,
4078 .help = "Continue on verify errors only",
4079 },
4080 { .ival = "all",
4081 .oval = ERROR_TYPE_ANY,
4082 .help = "Continue on all io and verify errors",
4083 },
4084 { .ival = "0",
4085 .oval = ERROR_TYPE_NONE,
4086 .help = "Alias for 'none'",
4087 },
4088 { .ival = "1",
4089 .oval = ERROR_TYPE_ANY,
4090 .help = "Alias for 'all'",
4091 },
4092 },
f2bba182 4093 },
8b28bd41
DM
4094 {
4095 .name = "ignore_error",
cce2fdfe 4096 .lname = "Ignore Error",
8b28bd41
DM
4097 .type = FIO_OPT_STR,
4098 .cb = str_ignore_error_cb,
a609f12a 4099 .off1 = offsetof(struct thread_options, ignore_error_nr),
8b28bd41
DM
4100 .help = "Set a specific list of errors to ignore",
4101 .parent = "rw",
a94eb99a 4102 .category = FIO_OPT_C_GENERAL,
bc3f552f 4103 .group = FIO_OPT_G_ERR,
8b28bd41
DM
4104 },
4105 {
4106 .name = "error_dump",
cce2fdfe 4107 .lname = "Error Dump",
8b28bd41 4108 .type = FIO_OPT_BOOL,
a609f12a 4109 .off1 = offsetof(struct thread_options, error_dump),
8b28bd41
DM
4110 .def = "0",
4111 .help = "Dump info on each error",
a94eb99a 4112 .category = FIO_OPT_C_GENERAL,
bc3f552f 4113 .group = FIO_OPT_G_ERR,
8b28bd41 4114 },
9ac8a797
JA
4115 {
4116 .name = "profile",
e8b0e958 4117 .lname = "Profile",
79d16311 4118 .type = FIO_OPT_STR_STORE,
a609f12a 4119 .off1 = offsetof(struct thread_options, profile),
9ac8a797 4120 .help = "Select a specific builtin performance test",
13fca827 4121 .category = FIO_OPT_C_PROFILE,
e8b0e958 4122 .group = FIO_OPT_G_INVALID,
9ac8a797 4123 },
a696fa2a
JA
4124 {
4125 .name = "cgroup",
e8b0e958 4126 .lname = "Cgroup",
a696fa2a 4127 .type = FIO_OPT_STR_STORE,
a609f12a 4128 .off1 = offsetof(struct thread_options, cgroup),
a696fa2a 4129 .help = "Add job to cgroup of this name",
e8b0e958 4130 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
4131 .group = FIO_OPT_G_CGROUP,
4132 },
4133 {
4134 .name = "cgroup_nodelete",
4135 .lname = "Cgroup no-delete",
4136 .type = FIO_OPT_BOOL,
a609f12a 4137 .off1 = offsetof(struct thread_options, cgroup_nodelete),
a1f6afec
JA
4138 .help = "Do not delete cgroups after job completion",
4139 .def = "0",
4140 .parent = "cgroup",
4141 .category = FIO_OPT_C_GENERAL,
4142 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
4143 },
4144 {
4145 .name = "cgroup_weight",
e8b0e958 4146 .lname = "Cgroup weight",
a696fa2a 4147 .type = FIO_OPT_INT,
a609f12a 4148 .off1 = offsetof(struct thread_options, cgroup_weight),
a696fa2a
JA
4149 .help = "Use given weight for cgroup",
4150 .minval = 100,
4151 .maxval = 1000,
a1f6afec 4152 .parent = "cgroup",
e8b0e958 4153 .category = FIO_OPT_C_GENERAL,
a1f6afec 4154 .group = FIO_OPT_G_CGROUP,
7de87099 4155 },
e0b0d892
JA
4156 {
4157 .name = "uid",
e8b0e958 4158 .lname = "User ID",
e0b0d892 4159 .type = FIO_OPT_INT,
a609f12a 4160 .off1 = offsetof(struct thread_options, uid),
e0b0d892 4161 .help = "Run job with this user ID",
e8b0e958 4162 .category = FIO_OPT_C_GENERAL,
10860056 4163 .group = FIO_OPT_G_CRED,
e0b0d892
JA
4164 },
4165 {
4166 .name = "gid",
e8b0e958 4167 .lname = "Group ID",
e0b0d892 4168 .type = FIO_OPT_INT,
a609f12a 4169 .off1 = offsetof(struct thread_options, gid),
e0b0d892 4170 .help = "Run job with this group ID",
e8b0e958 4171 .category = FIO_OPT_C_GENERAL,
10860056 4172 .group = FIO_OPT_G_CRED,
e0b0d892 4173 },
a1f6afec
JA
4174 {
4175 .name = "kb_base",
4176 .lname = "KB Base",
4177 .type = FIO_OPT_INT,
a609f12a 4178 .off1 = offsetof(struct thread_options, kb_base),
a1f6afec
JA
4179 .prio = 1,
4180 .def = "1024",
ba9c7219
JA
4181 .posval = {
4182 { .ival = "1024",
4183 .oval = 1024,
d694a6a7 4184 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
ba9c7219
JA
4185 },
4186 { .ival = "1000",
4187 .oval = 1000,
d694a6a7 4188 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
ba9c7219
JA
4189 },
4190 },
d694a6a7 4191 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
a1f6afec
JA
4192 .category = FIO_OPT_C_GENERAL,
4193 .group = FIO_OPT_G_INVALID,
4194 },
cf3a0518
JA
4195 {
4196 .name = "unit_base",
d694a6a7 4197 .lname = "Unit for quantities of data (Bits or Bytes)",
cf3a0518 4198 .type = FIO_OPT_INT,
a609f12a 4199 .off1 = offsetof(struct thread_options, unit_base),
cf3a0518 4200 .prio = 1,
71a08258
JA
4201 .posval = {
4202 { .ival = "0",
4203 .oval = 0,
4204 .help = "Auto-detect",
4205 },
4206 { .ival = "8",
4207 .oval = 8,
4208 .help = "Normal (byte based)",
4209 },
4210 { .ival = "1",
4211 .oval = 1,
4212 .help = "Bit based",
4213 },
4214 },
cf3a0518
JA
4215 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4216 .category = FIO_OPT_C_GENERAL,
4217 .group = FIO_OPT_G_INVALID,
4218 },
3ceb458f
JA
4219 {
4220 .name = "hugepage-size",
4221 .lname = "Hugepage size",
4222 .type = FIO_OPT_INT,
a609f12a 4223 .off1 = offsetof(struct thread_options, hugepage_size),
3ceb458f
JA
4224 .help = "When using hugepages, specify size of each page",
4225 .def = __fio_stringify(FIO_HUGE_PAGE),
4226 .interval = 1024 * 1024,
4227 .category = FIO_OPT_C_GENERAL,
4228 .group = FIO_OPT_G_INVALID,
4229 },
9e684a49
DE
4230 {
4231 .name = "flow_id",
e8b0e958 4232 .lname = "I/O flow ID",
9e684a49 4233 .type = FIO_OPT_INT,
a609f12a 4234 .off1 = offsetof(struct thread_options, flow_id),
9e684a49
DE
4235 .help = "The flow index ID to use",
4236 .def = "0",
e8b0e958
JA
4237 .category = FIO_OPT_C_IO,
4238 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4239 },
4240 {
4241 .name = "flow",
e8b0e958 4242 .lname = "I/O flow weight",
9e684a49 4243 .type = FIO_OPT_INT,
a609f12a 4244 .off1 = offsetof(struct thread_options, flow),
9e684a49
DE
4245 .help = "Weight for flow control of this job",
4246 .parent = "flow_id",
d71c154c 4247 .hide = 1,
9e684a49 4248 .def = "0",
e8b0e958
JA
4249 .category = FIO_OPT_C_IO,
4250 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4251 },
4252 {
4253 .name = "flow_watermark",
e8b0e958 4254 .lname = "I/O flow watermark",
9e684a49 4255 .type = FIO_OPT_INT,
a609f12a 4256 .off1 = offsetof(struct thread_options, flow_watermark),
9e684a49
DE
4257 .help = "High watermark for flow control. This option"
4258 " should be set to the same value for all threads"
4259 " with non-zero flow.",
4260 .parent = "flow_id",
d71c154c 4261 .hide = 1,
9e684a49 4262 .def = "1024",
e8b0e958
JA
4263 .category = FIO_OPT_C_IO,
4264 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
4265 },
4266 {
4267 .name = "flow_sleep",
e8b0e958 4268 .lname = "I/O flow sleep",
9e684a49 4269 .type = FIO_OPT_INT,
a609f12a 4270 .off1 = offsetof(struct thread_options, flow_sleep),
9e684a49
DE
4271 .help = "How many microseconds to sleep after being held"
4272 " back by the flow control mechanism",
4273 .parent = "flow_id",
d71c154c 4274 .hide = 1,
9e684a49 4275 .def = "0",
e8b0e958
JA
4276 .category = FIO_OPT_C_IO,
4277 .group = FIO_OPT_G_IO_FLOW,
9e684a49 4278 },
65fa28ca
DE
4279 {
4280 .name = "skip_bad",
4281 .lname = "Skip operations against bad blocks",
4282 .type = FIO_OPT_BOOL,
a609f12a 4283 .off1 = offsetof(struct thread_options, skip_bad),
65fa28ca
DE
4284 .help = "Skip operations against known bad blocks.",
4285 .hide = 1,
4286 .def = "0",
4287 .category = FIO_OPT_C_IO,
4288 .group = FIO_OPT_G_MTD,
4289 },
16e56d25
VF
4290 {
4291 .name = "steadystate",
4292 .lname = "Steady state threshold",
4293 .alias = "ss",
4294 .type = FIO_OPT_STR,
2c5d94bc 4295 .off1 = offsetof(struct thread_options, ss_state),
16e56d25
VF
4296 .cb = str_steadystate_cb,
4297 .help = "Define the criterion and limit to judge when a job has reached steady state",
4298 .def = "iops_slope:0.01%",
4299 .posval = {
4300 { .ival = "iops",
f0c50c66 4301 .oval = FIO_SS_IOPS,
16e56d25
VF
4302 .help = "maximum mean deviation of IOPS measurements",
4303 },
4304 { .ival = "iops_slope",
f0c50c66 4305 .oval = FIO_SS_IOPS_SLOPE,
16e56d25
VF
4306 .help = "slope calculated from IOPS measurements",
4307 },
4308 { .ival = "bw",
f0c50c66 4309 .oval = FIO_SS_BW,
16e56d25
VF
4310 .help = "maximum mean deviation of bandwidth measurements",
4311 },
4312 {
4313 .ival = "bw_slope",
f0c50c66 4314 .oval = FIO_SS_BW_SLOPE,
16e56d25
VF
4315 .help = "slope calculated from bandwidth measurements",
4316 },
4317 },
4318 .category = FIO_OPT_C_GENERAL,
4319 .group = FIO_OPT_G_RUNTIME,
4320 },
4321 {
4322 .name = "steadystate_duration",
4323 .lname = "Steady state duration",
4324 .alias = "ss_dur",
915ca980 4325 .parent = "steadystate",
16e56d25
VF
4326 .type = FIO_OPT_STR_VAL_TIME,
4327 .off1 = offsetof(struct thread_options, ss_dur),
4328 .help = "Stop workload upon attaining steady state for specified duration",
4329 .def = "0",
4330 .is_seconds = 1,
4331 .is_time = 1,
4332 .category = FIO_OPT_C_GENERAL,
4333 .group = FIO_OPT_G_RUNTIME,
4334 },
4335 {
4336 .name = "steadystate_ramp_time",
4337 .lname = "Steady state ramp time",
4338 .alias = "ss_ramp",
915ca980 4339 .parent = "steadystate",
16e56d25
VF
4340 .type = FIO_OPT_STR_VAL_TIME,
4341 .off1 = offsetof(struct thread_options, ss_ramp_time),
4342 .help = "Delay before initiation of data collection for steady state job termination testing",
4343 .def = "0",
4344 .is_seconds = 1,
4345 .is_time = 1,
4346 .category = FIO_OPT_C_GENERAL,
4347 .group = FIO_OPT_G_RUNTIME,
4348 },
214e1eca
JA
4349 {
4350 .name = NULL,
4351 },
4352};
4353
17af15d4 4354static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 4355 const char *name, int val)
9f81736c 4356{
17af15d4 4357 lopt->name = (char *) name;
de890a1e 4358 lopt->val = val;
9f81736c 4359 if (o->type == FIO_OPT_STR_SET)
ff52be3d 4360 lopt->has_arg = optional_argument;
9f81736c
JA
4361 else
4362 lopt->has_arg = required_argument;
4363}
4364
de890a1e
SL
4365static void options_to_lopts(struct fio_option *opts,
4366 struct option *long_options,
4367 int i, int option_type)
214e1eca 4368{
de890a1e 4369 struct fio_option *o = &opts[0];
214e1eca 4370 while (o->name) {
de890a1e 4371 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
4372 if (o->alias) {
4373 i++;
de890a1e 4374 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 4375 }
214e1eca
JA
4376
4377 i++;
4378 o++;
4379 assert(i < FIO_NR_OPTIONS);
4380 }
4381}
4382
de890a1e
SL
4383void fio_options_set_ioengine_opts(struct option *long_options,
4384 struct thread_data *td)
4385{
4386 unsigned int i;
4387
4388 i = 0;
4389 while (long_options[i].name) {
4390 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4391 memset(&long_options[i], 0, sizeof(*long_options));
4392 break;
4393 }
4394 i++;
4395 }
4396
4397 /*
4398 * Just clear out the prior ioengine options.
4399 */
4400 if (!td || !td->eo)
4401 return;
4402
4403 options_to_lopts(td->io_ops->options, long_options, i,
4404 FIO_GETOPT_IOENGINE);
4405}
4406
4407void fio_options_dup_and_init(struct option *long_options)
4408{
4409 unsigned int i;
4410
9af4a244 4411 options_init(fio_options);
de890a1e
SL
4412
4413 i = 0;
4414 while (long_options[i].name)
4415 i++;
4416
9af4a244 4417 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
4418}
4419
74929ac2
JA
4420struct fio_keyword {
4421 const char *word;
4422 const char *desc;
4423 char *replace;
4424};
4425
4426static struct fio_keyword fio_keywords[] = {
4427 {
4428 .word = "$pagesize",
4429 .desc = "Page size in the system",
4430 },
4431 {
4432 .word = "$mb_memory",
4433 .desc = "Megabytes of memory online",
4434 },
4435 {
4436 .word = "$ncpus",
4437 .desc = "Number of CPUs online in the system",
4438 },
4439 {
4440 .word = NULL,
4441 },
4442};
4443
af1dc266
JA
4444void fio_keywords_exit(void)
4445{
4446 struct fio_keyword *kw;
4447
4448 kw = &fio_keywords[0];
4449 while (kw->word) {
4450 free(kw->replace);
4451 kw->replace = NULL;
4452 kw++;
4453 }
4454}
4455
74929ac2
JA
4456void fio_keywords_init(void)
4457{
3b2e1464 4458 unsigned long long mb_memory;
74929ac2
JA
4459 char buf[128];
4460 long l;
4461
a4cfc477 4462 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
4463 fio_keywords[0].replace = strdup(buf);
4464
8eb016d3 4465 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 4466 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
4467 fio_keywords[1].replace = strdup(buf);
4468
c00a2289 4469 l = cpus_online();
74929ac2
JA
4470 sprintf(buf, "%lu", l);
4471 fio_keywords[2].replace = strdup(buf);
4472}
4473
892a6ffc
JA
4474#define BC_APP "bc"
4475
4476static char *bc_calc(char *str)
4477{
d0c814ec 4478 char buf[128], *tmp;
892a6ffc
JA
4479 FILE *f;
4480 int ret;
4481
4482 /*
4483 * No math, just return string
4484 */
d0c814ec
SL
4485 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4486 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
4487 return str;
4488
4489 /*
4490 * Split option from value, we only need to calculate the value
4491 */
4492 tmp = strchr(str, '=');
4493 if (!tmp)
4494 return str;
4495
4496 tmp++;
892a6ffc 4497
d0c814ec
SL
4498 /*
4499 * Prevent buffer overflows; such a case isn't reasonable anyway
4500 */
4501 if (strlen(str) >= 128 || strlen(tmp) > 100)
4502 return str;
892a6ffc
JA
4503
4504 sprintf(buf, "which %s > /dev/null", BC_APP);
4505 if (system(buf)) {
4506 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
4507 return NULL;
4508 }
4509
d0c814ec 4510 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 4511 f = popen(buf, "r");
3c3ed070 4512 if (!f)
892a6ffc 4513 return NULL;
892a6ffc 4514
d0c814ec 4515 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
1d824f37
JA
4516 if (ret <= 0) {
4517 pclose(f);
892a6ffc 4518 return NULL;
1d824f37 4519 }
892a6ffc 4520
892a6ffc 4521 pclose(f);
d0c814ec
SL
4522 buf[(tmp - str) + ret - 1] = '\0';
4523 memcpy(buf, str, tmp - str);
892a6ffc 4524 free(str);
d0c814ec
SL
4525 return strdup(buf);
4526}
4527
4528/*
4529 * Return a copy of the input string with substrings of the form ${VARNAME}
4530 * substituted with the value of the environment variable VARNAME. The
4531 * substitution always occurs, even if VARNAME is empty or the corresponding
4532 * environment variable undefined.
4533 */
4534static char *option_dup_subs(const char *opt)
4535{
4536 char out[OPT_LEN_MAX+1];
4537 char in[OPT_LEN_MAX+1];
4538 char *outptr = out;
4539 char *inptr = in;
4540 char *ch1, *ch2, *env;
4541 ssize_t nchr = OPT_LEN_MAX;
4542 size_t envlen;
4543
4544 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4545 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4546 return NULL;
4547 }
4548
4549 in[OPT_LEN_MAX] = '\0';
4550 strncpy(in, opt, OPT_LEN_MAX);
4551
4552 while (*inptr && nchr > 0) {
4553 if (inptr[0] == '$' && inptr[1] == '{') {
4554 ch2 = strchr(inptr, '}');
4555 if (ch2 && inptr+1 < ch2) {
4556 ch1 = inptr+2;
4557 inptr = ch2+1;
4558 *ch2 = '\0';
4559
4560 env = getenv(ch1);
4561 if (env) {
4562 envlen = strlen(env);
4563 if (envlen <= nchr) {
4564 memcpy(outptr, env, envlen);
4565 outptr += envlen;
4566 nchr -= envlen;
4567 }
4568 }
4569
4570 continue;
4571 }
4572 }
4573
4574 *outptr++ = *inptr++;
4575 --nchr;
4576 }
4577
4578 *outptr = '\0';
4579 return strdup(out);
892a6ffc
JA
4580}
4581
74929ac2
JA
4582/*
4583 * Look for reserved variable names and replace them with real values
4584 */
4585static char *fio_keyword_replace(char *opt)
4586{
4587 char *s;
4588 int i;
d0c814ec 4589 int docalc = 0;
74929ac2
JA
4590
4591 for (i = 0; fio_keywords[i].word != NULL; i++) {
4592 struct fio_keyword *kw = &fio_keywords[i];
4593
4594 while ((s = strstr(opt, kw->word)) != NULL) {
4595 char *new = malloc(strlen(opt) + 1);
4596 char *o_org = opt;
4597 int olen = s - opt;
4598 int len;
4599
4600 /*
4601 * Copy part of the string before the keyword and
4602 * sprintf() the replacement after it.
4603 */
4604 memcpy(new, opt, olen);
4605 len = sprintf(new + olen, "%s", kw->replace);
4606
4607 /*
4608 * If there's more in the original string, copy that
4609 * in too
4610 */
4611 opt += strlen(kw->word) + olen;
4612 if (strlen(opt))
4613 memcpy(new + olen + len, opt, opt - o_org - 1);
4614
4615 /*
4616 * replace opt and free the old opt
4617 */
4618 opt = new;
d0c814ec 4619 free(o_org);
7a958bd5 4620
d0c814ec 4621 docalc = 1;
74929ac2
JA
4622 }
4623 }
4624
d0c814ec
SL
4625 /*
4626 * Check for potential math and invoke bc, if possible
4627 */
4628 if (docalc)
4629 opt = bc_calc(opt);
4630
7a958bd5 4631 return opt;
74929ac2
JA
4632}
4633
d0c814ec
SL
4634static char **dup_and_sub_options(char **opts, int num_opts)
4635{
4636 int i;
4637 char **opts_copy = malloc(num_opts * sizeof(*opts));
4638 for (i = 0; i < num_opts; i++) {
4639 opts_copy[i] = option_dup_subs(opts[i]);
4640 if (!opts_copy[i])
4641 continue;
4642 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4643 }
4644 return opts_copy;
4645}
4646
e15b023b 4647static void show_closest_option(const char *opt)
a2d027b9
JA
4648{
4649 int best_option, best_distance;
4650 int i, distance;
e15b023b
JA
4651 char *name;
4652
4653 if (!strlen(opt))
4654 return;
4655
4656 name = strdup(opt);
4657 i = 0;
4658 while (name[i] != '\0' && name[i] != '=')
4659 i++;
4660 name[i] = '\0';
a2d027b9
JA
4661
4662 best_option = -1;
4663 best_distance = INT_MAX;
4664 i = 0;
4665 while (fio_options[i].name) {
4666 distance = string_distance(name, fio_options[i].name);
4667 if (distance < best_distance) {
4668 best_distance = distance;
4669 best_option = i;
4670 }
4671 i++;
4672 }
4673
75e6bcba
JA
4674 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4675 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
a2d027b9 4676 log_err("Did you mean %s?\n", fio_options[best_option].name);
e15b023b
JA
4677
4678 free(name);
a2d027b9
JA
4679}
4680
c2292325 4681int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 4682{
de890a1e 4683 int i, ret, unknown;
d0c814ec 4684 char **opts_copy;
3b8b7135 4685
9af4a244 4686 sort_options(opts, fio_options, num_opts);
d0c814ec 4687 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 4688
de890a1e
SL
4689 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4690 struct fio_option *o;
9af4a244 4691 int newret = parse_option(opts_copy[i], opts[i], fio_options,
a609f12a 4692 &o, &td->o, &td->opt_list);
d0c814ec 4693
a8523a6a
JA
4694 if (!newret && o)
4695 fio_option_mark_set(&td->o, o);
4696
de890a1e
SL
4697 if (opts_copy[i]) {
4698 if (newret && !o) {
4699 unknown++;
4700 continue;
4701 }
d0c814ec 4702 free(opts_copy[i]);
de890a1e
SL
4703 opts_copy[i] = NULL;
4704 }
4705
4706 ret |= newret;
4707 }
4708
4709 if (unknown) {
4710 ret |= ioengine_load(td);
4711 if (td->eo) {
4712 sort_options(opts_copy, td->io_ops->options, num_opts);
4713 opts = opts_copy;
4714 }
4715 for (i = 0; i < num_opts; i++) {
4716 struct fio_option *o = NULL;
4717 int newret = 1;
a2d027b9 4718
de890a1e
SL
4719 if (!opts_copy[i])
4720 continue;
4721
4722 if (td->eo)
4723 newret = parse_option(opts_copy[i], opts[i],
4724 td->io_ops->options, &o,
66e19a38 4725 td->eo, &td->opt_list);
de890a1e
SL
4726
4727 ret |= newret;
a2d027b9 4728 if (!o) {
de890a1e 4729 log_err("Bad option <%s>\n", opts[i]);
a2d027b9
JA
4730 show_closest_option(opts[i]);
4731 }
de890a1e
SL
4732 free(opts_copy[i]);
4733 opts_copy[i] = NULL;
4734 }
74929ac2 4735 }
3b8b7135 4736
d0c814ec 4737 free(opts_copy);
3b8b7135 4738 return ret;
214e1eca
JA
4739}
4740
4741int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4742{
a8523a6a
JA
4743 int ret;
4744
a609f12a 4745 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
a8523a6a
JA
4746 if (!ret) {
4747 struct fio_option *o;
4748
4749 o = find_option(fio_options, opt);
4750 if (o)
4751 fio_option_mark_set(&td->o, o);
4752 }
4753
4754 return ret;
214e1eca
JA
4755}
4756
de890a1e
SL
4757int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4758 char *val)
4759{
d8b4f395
JA
4760 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4761 &td->opt_list);
de890a1e
SL
4762}
4763
214e1eca
JA
4764void fio_fill_default_options(struct thread_data *td)
4765{
cb1402d6 4766 td->o.magic = OPT_MAGIC;
a609f12a 4767 fill_default_options(&td->o, fio_options);
214e1eca
JA
4768}
4769
4770int fio_show_option_help(const char *opt)
4771{
9af4a244 4772 return show_cmd_help(fio_options, opt);
214e1eca 4773}
d23bb327 4774
de890a1e
SL
4775/*
4776 * dupe FIO_OPT_STR_STORE options
4777 */
4778void fio_options_mem_dupe(struct thread_data *td)
4779{
53b5693d 4780 options_mem_dupe(fio_options, &td->o);
1647f592
JA
4781
4782 if (td->eo && td->io_ops) {
de890a1e 4783 void *oldeo = td->eo;
1647f592 4784
de890a1e
SL
4785 td->eo = malloc(td->io_ops->option_struct_size);
4786 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
53b5693d 4787 options_mem_dupe(td->io_ops->options, td->eo);
de890a1e
SL
4788 }
4789}
4790
d6978a32
JA
4791unsigned int fio_get_kb_base(void *data)
4792{
a609f12a
JA
4793 struct thread_data *td = cb_data_to_td(data);
4794 struct thread_options *o = &td->o;
d6978a32
JA
4795 unsigned int kb_base = 0;
4796
cb1402d6
JA
4797 /*
4798 * This is a hack... For private options, *data is not holding
4799 * a pointer to the thread_options, but to private data. This means
4800 * we can't safely dereference it, but magic is first so mem wise
4801 * it is valid. But this also means that if the job first sets
4802 * kb_base and expects that to be honored by private options,
4803 * it will be disappointed. We will return the global default
4804 * for this.
4805 */
4806 if (o && o->magic == OPT_MAGIC)
83ea422a 4807 kb_base = o->kb_base;
d6978a32
JA
4808 if (!kb_base)
4809 kb_base = 1024;
4810
4811 return kb_base;
4812}
9f988e2e 4813
07b3232d 4814int add_option(struct fio_option *o)
9f988e2e 4815{
07b3232d
JA
4816 struct fio_option *__o;
4817 int opt_index = 0;
4818
9af4a244 4819 __o = fio_options;
07b3232d
JA
4820 while (__o->name) {
4821 opt_index++;
4822 __o++;
4823 }
4824
7b504edd
JA
4825 if (opt_index + 1 == FIO_MAX_OPTS) {
4826 log_err("fio: FIO_MAX_OPTS is too small\n");
4827 return 1;
4828 }
4829
9af4a244 4830 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 4831 fio_options[opt_index + 1].name = NULL;
07b3232d 4832 return 0;
9f988e2e 4833}
e2de69da 4834
07b3232d 4835void invalidate_profile_options(const char *prof_name)
e2de69da 4836{
07b3232d 4837 struct fio_option *o;
e2de69da 4838
9af4a244 4839 o = fio_options;
07b3232d
JA
4840 while (o->name) {
4841 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4842 o->type = FIO_OPT_INVALID;
4843 o->prof_name = NULL;
4844 }
4845 o++;
e2de69da
JA
4846 }
4847}
f5b6bb85
JA
4848
4849void add_opt_posval(const char *optname, const char *ival, const char *help)
4850{
4851 struct fio_option *o;
4852 unsigned int i;
4853
9af4a244 4854 o = find_option(fio_options, optname);
f5b6bb85
JA
4855 if (!o)
4856 return;
4857
4858 for (i = 0; i < PARSE_MAX_VP; i++) {
4859 if (o->posval[i].ival)
4860 continue;
4861
4862 o->posval[i].ival = ival;
4863 o->posval[i].help = help;
4864 break;
4865 }
4866}
4867
4868void del_opt_posval(const char *optname, const char *ival)
4869{
4870 struct fio_option *o;
4871 unsigned int i;
4872
9af4a244 4873 o = find_option(fio_options, optname);
f5b6bb85
JA
4874 if (!o)
4875 return;
4876
4877 for (i = 0; i < PARSE_MAX_VP; i++) {
4878 if (!o->posval[i].ival)
4879 continue;
4880 if (strcmp(o->posval[i].ival, ival))
4881 continue;
4882
4883 o->posval[i].ival = NULL;
4884 o->posval[i].help = NULL;
4885 }
4886}
7e356b2d
JA
4887
4888void fio_options_free(struct thread_data *td)
4889{
ca6336a8 4890 options_free(fio_options, &td->o);
de890a1e
SL
4891 if (td->eo && td->io_ops && td->io_ops->options) {
4892 options_free(td->io_ops->options, td->eo);
4893 free(td->eo);
4894 td->eo = NULL;
4895 }
7e356b2d 4896}
c504ee55
JA
4897
4898struct fio_option *fio_option_find(const char *name)
4899{
4900 return find_option(fio_options, name);
4901}
4902
f0e7f45a
JA
4903static struct fio_option *find_next_opt(struct thread_options *o,
4904 struct fio_option *from,
4905 unsigned int off1)
a8523a6a 4906{
f0e7f45a 4907 struct fio_option *opt;
a8523a6a 4908
f0e7f45a
JA
4909 if (!from)
4910 from = &fio_options[0];
4911 else
4912 from++;
4913
4914 opt = NULL;
4915 do {
4916 if (off1 == from->off1) {
4917 opt = from;
a8523a6a
JA
4918 break;
4919 }
f0e7f45a
JA
4920 from++;
4921 } while (from->name);
a8523a6a 4922
f0e7f45a
JA
4923 return opt;
4924}
4925
4926static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4927{
4928 unsigned int opt_off, index, offset;
a8523a6a
JA
4929
4930 opt_off = opt - &fio_options[0];
4931 index = opt_off / (8 * sizeof(uint64_t));
4932 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4933 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
a8523a6a
JA
4934}
4935
72f39748 4936bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
f0e7f45a
JA
4937{
4938 struct fio_option *opt, *next;
4939
4940 next = NULL;
4941 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4942 if (opt_is_set(o, opt))
72f39748 4943 return true;
f0e7f45a
JA
4944
4945 next = opt;
4946 }
4947
72f39748 4948 return false;
f0e7f45a
JA
4949}
4950
a8523a6a
JA
4951void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4952{
4953 unsigned int opt_off, index, offset;
4954
4955 opt_off = opt - &fio_options[0];
4956 index = opt_off / (8 * sizeof(uint64_t));
4957 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4958 o->set_options[index] |= (uint64_t)1 << offset;
a8523a6a 4959}