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