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