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