Cleanup IO buffer memory allocation
[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>
6#include <getopt.h>
7#include <assert.h>
921c766f 8#include <libgen.h>
5921e80c
JA
9#include <fcntl.h>
10#include <sys/types.h>
11#include <sys/stat.h>
214e1eca
JA
12
13#include "fio.h"
4f5af7b2 14#include "verify.h"
214e1eca 15#include "parse.h"
eef32359 16#include "lib/fls.h"
214e1eca 17
2dc1bbeb 18#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
214e1eca
JA
19
20/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
564ca972
JA
36static int bs_cmp(const void *p1, const void *p2)
37{
38 const struct bssplit *bsp1 = p1;
39 const struct bssplit *bsp2 = p2;
40
41 return bsp1->perc < bsp2->perc;
42}
43
720e84ad 44static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
564ca972 45{
720e84ad 46 struct bssplit *bssplit;
564ca972
JA
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
49 long long val;
720e84ad 50 char *fname;
564ca972 51
720e84ad
JA
52 td->o.bssplit_nr[ddir] = 4;
53 bssplit = malloc(4 * sizeof(struct bssplit));
564ca972
JA
54
55 i = 0;
56 max_bs = 0;
57 min_bs = -1;
58 while ((fname = strsep(&str, ":")) != NULL) {
59 char *perc_str;
60
61 if (!strlen(fname))
62 break;
63
64 /*
65 * grow struct buffer, if needed
66 */
720e84ad
JA
67 if (i == td->o.bssplit_nr[ddir]) {
68 td->o.bssplit_nr[ddir] <<= 1;
69 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
5ec10eaa 70 * sizeof(struct bssplit));
564ca972
JA
71 }
72
73 perc_str = strstr(fname, "/");
74 if (perc_str) {
75 *perc_str = '\0';
76 perc_str++;
77 perc = atoi(perc_str);
78 if (perc > 100)
79 perc = 100;
80 else if (!perc)
81 perc = -1;
82 } else
83 perc = -1;
84
85 if (str_to_decimal(fname, &val, 1)) {
86 log_err("fio: bssplit conversion failed\n");
87 free(td->o.bssplit);
88 return 1;
89 }
90
91 if (val > max_bs)
92 max_bs = val;
93 if (val < min_bs)
94 min_bs = val;
95
720e84ad
JA
96 bssplit[i].bs = val;
97 bssplit[i].perc = perc;
564ca972
JA
98 i++;
99 }
100
720e84ad 101 td->o.bssplit_nr[ddir] = i;
564ca972
JA
102
103 /*
104 * Now check if the percentages add up, and how much is missing
105 */
106 perc = perc_missing = 0;
720e84ad
JA
107 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108 struct bssplit *bsp = &bssplit[i];
564ca972
JA
109
110 if (bsp->perc == (unsigned char) -1)
111 perc_missing++;
112 else
113 perc += bsp->perc;
114 }
115
116 if (perc > 100) {
117 log_err("fio: bssplit percentages add to more than 100%%\n");
720e84ad 118 free(bssplit);
564ca972
JA
119 return 1;
120 }
121 /*
122 * If values didn't have a percentage set, divide the remains between
123 * them.
124 */
125 if (perc_missing) {
720e84ad
JA
126 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127 struct bssplit *bsp = &bssplit[i];
564ca972
JA
128
129 if (bsp->perc == (unsigned char) -1)
130 bsp->perc = (100 - perc) / perc_missing;
131 }
132 }
133
720e84ad
JA
134 td->o.min_bs[ddir] = min_bs;
135 td->o.max_bs[ddir] = max_bs;
564ca972
JA
136
137 /*
138 * now sort based on percentages, for ease of lookup
139 */
720e84ad
JA
140 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141 td->o.bssplit[ddir] = bssplit;
142 return 0;
143
144}
145
146static int str_bssplit_cb(void *data, const char *input)
147{
148 struct thread_data *td = data;
149 char *str, *p, *odir;
150 int ret = 0;
151
152 p = str = strdup(input);
153
154 strip_blank_front(&str);
155 strip_blank_end(str);
156
157 odir = strchr(str, ',');
158 if (odir) {
159 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
160 if (!ret) {
161 *odir = '\0';
162 ret = bssplit_ddir(td, DDIR_READ, str);
163 }
164 } else {
165 char *op;
166
167 op = strdup(str);
168
169 ret = bssplit_ddir(td, DDIR_READ, str);
170 if (!ret)
171 ret = bssplit_ddir(td, DDIR_WRITE, op);
172
173 free(op);
174 }
564ca972
JA
175
176 free(p);
720e84ad 177 return ret;
564ca972
JA
178}
179
211097b2
JA
180static int str_rw_cb(void *data, const char *str)
181{
182 struct thread_data *td = data;
183 char *nr = get_opt_postfix(str);
184
fafdba3c 185 td->o.ddir_nr = 1;
182ec6ee 186 if (nr) {
211097b2 187 td->o.ddir_nr = atoi(nr);
182ec6ee
JA
188 free(nr);
189 }
211097b2 190
211097b2
JA
191 return 0;
192}
193
214e1eca
JA
194static int str_mem_cb(void *data, const char *mem)
195{
196 struct thread_data *td = data;
197
2dc1bbeb 198 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
214e1eca 199 td->mmapfile = get_opt_postfix(mem);
2dc1bbeb 200 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
214e1eca
JA
201 log_err("fio: mmaphuge:/path/to/file\n");
202 return 1;
203 }
204 }
205
206 return 0;
207}
208
209static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
210{
211 mlock_size = *val;
212 return 0;
213}
214
cb499fc4
JA
215static int str_rwmix_read_cb(void *data, unsigned int *val)
216{
217 struct thread_data *td = data;
218
219 td->o.rwmix[DDIR_READ] = *val;
220 td->o.rwmix[DDIR_WRITE] = 100 - *val;
221 return 0;
222}
223
224static int str_rwmix_write_cb(void *data, unsigned int *val)
225{
226 struct thread_data *td = data;
227
228 td->o.rwmix[DDIR_WRITE] = *val;
229 td->o.rwmix[DDIR_READ] = 100 - *val;
230 return 0;
231}
232
214e1eca
JA
233#ifdef FIO_HAVE_IOPRIO
234static int str_prioclass_cb(void *data, unsigned int *val)
235{
236 struct thread_data *td = data;
6cefbe33
JA
237 unsigned short mask;
238
239 /*
240 * mask off old class bits, str_prio_cb() may have set a default class
241 */
242 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
243 td->ioprio &= mask;
214e1eca
JA
244
245 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
ac684785 246 td->ioprio_set = 1;
214e1eca
JA
247 return 0;
248}
249
250static int str_prio_cb(void *data, unsigned int *val)
251{
252 struct thread_data *td = data;
253
254 td->ioprio |= *val;
6cefbe33
JA
255
256 /*
257 * If no class is set, assume BE
258 */
259 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
261
ac684785 262 td->ioprio_set = 1;
214e1eca
JA
263 return 0;
264}
265#endif
266
267static int str_exitall_cb(void)
268{
269 exitall_on_terminate = 1;
270 return 0;
271}
272
214e1eca 273#ifdef FIO_HAVE_CPU_AFFINITY
d2e268b0
JA
274static int str_cpumask_cb(void *data, unsigned int *val)
275{
276 struct thread_data *td = data;
214e1eca 277 unsigned int i;
b03daafb 278 long max_cpu;
d2ce18b5
JA
279 int ret;
280
281 ret = fio_cpuset_init(&td->o.cpumask);
282 if (ret < 0) {
283 log_err("fio: cpuset_init failed\n");
284 td_verror(td, ret, "fio_cpuset_init");
285 return 1;
286 }
214e1eca 287
b03daafb 288 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
214e1eca 289
62a7273d
JA
290 for (i = 0; i < sizeof(int) * 8; i++) {
291 if ((1 << i) & *val) {
b03daafb
JA
292 if (i > max_cpu) {
293 log_err("fio: CPU %d too large (max=%ld)\n", i,
294 max_cpu);
295 return 1;
296 }
62a7273d 297 dprint(FD_PARSE, "set cpu allowed %d\n", i);
6d459ee7 298 fio_cpu_set(&td->o.cpumask, i);
62a7273d
JA
299 }
300 }
d2e268b0
JA
301
302 td->o.cpumask_set = 1;
303 return 0;
214e1eca
JA
304}
305
d2e268b0 306static int str_cpus_allowed_cb(void *data, const char *input)
214e1eca
JA
307{
308 struct thread_data *td = data;
d2e268b0 309 char *cpu, *str, *p;
b03daafb 310 long max_cpu;
19608d6c 311 int ret = 0;
d2e268b0 312
d2ce18b5
JA
313 ret = fio_cpuset_init(&td->o.cpumask);
314 if (ret < 0) {
315 log_err("fio: cpuset_init failed\n");
316 td_verror(td, ret, "fio_cpuset_init");
317 return 1;
318 }
d2e268b0
JA
319
320 p = str = strdup(input);
214e1eca 321
d2e268b0
JA
322 strip_blank_front(&str);
323 strip_blank_end(str);
324
b03daafb
JA
325 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
326
d2e268b0 327 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
328 char *str2, *cpu2;
329 int icpu, icpu2;
330
d2e268b0
JA
331 if (!strlen(cpu))
332 break;
62a7273d
JA
333
334 str2 = cpu;
335 icpu2 = -1;
336 while ((cpu2 = strsep(&str2, "-")) != NULL) {
337 if (!strlen(cpu2))
338 break;
339
340 icpu2 = atoi(cpu2);
341 }
342
343 icpu = atoi(cpu);
344 if (icpu2 == -1)
345 icpu2 = icpu;
346 while (icpu <= icpu2) {
6d459ee7 347 if (icpu >= FIO_MAX_CPUS) {
19608d6c 348 log_err("fio: your OS only supports up to"
6d459ee7 349 " %d CPUs\n", (int) FIO_MAX_CPUS);
19608d6c
JA
350 ret = 1;
351 break;
352 }
b03daafb
JA
353 if (icpu > max_cpu) {
354 log_err("fio: CPU %d too large (max=%ld)\n",
355 icpu, max_cpu);
356 ret = 1;
357 break;
358 }
359
62a7273d 360 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
6d459ee7 361 fio_cpu_set(&td->o.cpumask, icpu);
62a7273d
JA
362 icpu++;
363 }
19608d6c
JA
364 if (ret)
365 break;
d2e268b0
JA
366 }
367
368 free(p);
19608d6c
JA
369 if (!ret)
370 td->o.cpumask_set = 1;
371 return ret;
214e1eca 372}
d2e268b0 373#endif
214e1eca
JA
374
375static int str_fst_cb(void *data, const char *str)
376{
377 struct thread_data *td = data;
378 char *nr = get_opt_postfix(str);
379
380 td->file_service_nr = 1;
182ec6ee 381 if (nr) {
214e1eca 382 td->file_service_nr = atoi(nr);
182ec6ee
JA
383 free(nr);
384 }
214e1eca
JA
385
386 return 0;
387}
388
921c766f
JA
389static int check_dir(struct thread_data *td, char *fname)
390{
391 char file[PATH_MAX], *dir;
bc838919 392 int elen = 0;
921c766f 393
bc838919
JA
394 if (td->o.directory) {
395 strcpy(file, td->o.directory);
fcef0b35 396 strcat(file, "/");
bc838919
JA
397 elen = strlen(file);
398 }
399
fcef0b35 400 sprintf(file + elen, "%s", fname);
921c766f
JA
401 dir = dirname(file);
402
fcef0b35
JA
403#if 0
404 {
405 struct stat sb;
406 /*
407 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
408 * yet, so we can't do this check right here...
409 */
921c766f
JA
410 if (lstat(dir, &sb) < 0) {
411 int ret = errno;
412
413 log_err("fio: %s is not a directory\n", dir);
414 td_verror(td, ret, "lstat");
415 return 1;
416 }
417
418 if (!S_ISDIR(sb.st_mode)) {
419 log_err("fio: %s is not a directory\n", dir);
420 return 1;
421 }
fcef0b35
JA
422 }
423#endif
921c766f
JA
424
425 return 0;
426}
427
214e1eca
JA
428static int str_filename_cb(void *data, const char *input)
429{
430 struct thread_data *td = data;
431 char *fname, *str, *p;
432
433 p = str = strdup(input);
434
435 strip_blank_front(&str);
436 strip_blank_end(str);
437
438 if (!td->files_index)
2dc1bbeb 439 td->o.nr_files = 0;
214e1eca
JA
440
441 while ((fname = strsep(&str, ":")) != NULL) {
442 if (!strlen(fname))
443 break;
921c766f
JA
444 if (check_dir(td, fname)) {
445 free(p);
446 return 1;
447 }
214e1eca 448 add_file(td, fname);
2dc1bbeb 449 td->o.nr_files++;
214e1eca
JA
450 }
451
452 free(p);
453 return 0;
454}
455
456static int str_directory_cb(void *data, const char fio_unused *str)
457{
458 struct thread_data *td = data;
459 struct stat sb;
460
2dc1bbeb 461 if (lstat(td->o.directory, &sb) < 0) {
921c766f
JA
462 int ret = errno;
463
2dc1bbeb 464 log_err("fio: %s is not a directory\n", td->o.directory);
921c766f 465 td_verror(td, ret, "lstat");
214e1eca
JA
466 return 1;
467 }
468 if (!S_ISDIR(sb.st_mode)) {
2dc1bbeb 469 log_err("fio: %s is not a directory\n", td->o.directory);
214e1eca
JA
470 return 1;
471 }
472
473 return 0;
474}
475
476static int str_opendir_cb(void *data, const char fio_unused *str)
477{
478 struct thread_data *td = data;
479
480 if (!td->files_index)
2dc1bbeb 481 td->o.nr_files = 0;
214e1eca 482
2dc1bbeb 483 return add_dir_files(td, td->o.opendir);
214e1eca
JA
484}
485
a59e170d 486static int str_verify_offset_cb(void *data, unsigned int *off)
546a9142
SL
487{
488 struct thread_data *td = data;
a59e170d 489
546a9142 490 if (*off && *off < sizeof(struct verify_header)) {
a59e170d 491 log_err("fio: verify_offset too small\n");
546a9142
SL
492 return 1;
493 }
a59e170d
JA
494
495 td->o.verify_offset = *off;
546a9142
SL
496 return 0;
497}
498
e28218f3 499static int str_verify_pattern_cb(void *data, unsigned int *off)
90059d65
JA
500{
501 struct thread_data *td = data;
e28218f3 502 unsigned int msb;
90059d65 503
3c48c2c1 504 msb = __fls(*off);
90059d65
JA
505 if (msb <= 8)
506 td->o.verify_pattern_bytes = 1;
507 else if (msb <= 16)
508 td->o.verify_pattern_bytes = 2;
509 else if (msb <= 24)
510 td->o.verify_pattern_bytes = 3;
511 else
512 td->o.verify_pattern_bytes = 4;
513
e28218f3 514 td->o.verify_pattern = *off;
90059d65
JA
515 return 0;
516}
214e1eca 517
4d4e80f2
JA
518static int str_lockfile_cb(void *data, const char *str)
519{
520 struct thread_data *td = data;
521 char *nr = get_opt_postfix(str);
522
523 td->o.lockfile_batch = 1;
182ec6ee 524 if (nr) {
4d4e80f2 525 td->o.lockfile_batch = atoi(nr);
182ec6ee
JA
526 free(nr);
527 }
4d4e80f2
JA
528
529 return 0;
530}
531
e3cedca7
JA
532static int str_write_bw_log_cb(void *data, const char *str)
533{
534 struct thread_data *td = data;
535
536 if (str)
537 td->o.bw_log_file = strdup(str);
538
539 td->o.write_bw_log = 1;
540 return 0;
541}
542
543static int str_write_lat_log_cb(void *data, const char *str)
544{
545 struct thread_data *td = data;
546
547 if (str)
548 td->o.lat_log_file = strdup(str);
549
550 td->o.write_lat_log = 1;
551 return 0;
552}
553
993bf48b
JA
554static int str_gtod_reduce_cb(void *data, int *il)
555{
556 struct thread_data *td = data;
557 int val = *il;
558
559 td->o.disable_clat = !!val;
560 td->o.disable_slat = !!val;
561 td->o.disable_bw = !!val;
562 if (val)
563 td->tv_cache_mask = 63;
564
565 return 0;
566}
567
be4ecfdf
JA
568static int str_gtod_cpu_cb(void *data, int *il)
569{
570 struct thread_data *td = data;
571 int val = *il;
572
573 td->o.gtod_cpu = val;
574 td->o.gtod_offload = 1;
575 return 0;
576}
577
214e1eca
JA
578#define __stringify_1(x) #x
579#define __stringify(x) __stringify_1(x)
580
581/*
582 * Map of job/command line options
583 */
584static struct fio_option options[] = {
585 {
586 .name = "description",
587 .type = FIO_OPT_STR_STORE,
588 .off1 = td_var_offset(description),
589 .help = "Text job description",
590 },
591 {
592 .name = "name",
593 .type = FIO_OPT_STR_STORE,
594 .off1 = td_var_offset(name),
595 .help = "Name of this job",
596 },
597 {
598 .name = "directory",
599 .type = FIO_OPT_STR_STORE,
600 .off1 = td_var_offset(directory),
601 .cb = str_directory_cb,
602 .help = "Directory to store files in",
603 },
604 {
605 .name = "filename",
606 .type = FIO_OPT_STR_STORE,
607 .off1 = td_var_offset(filename),
608 .cb = str_filename_cb,
f0d524b0 609 .prio = -1, /* must come after "directory" */
214e1eca
JA
610 .help = "File(s) to use for the workload",
611 },
29c1349f
JA
612 {
613 .name = "lockfile",
4d4e80f2
JA
614 .type = FIO_OPT_STR,
615 .cb = str_lockfile_cb,
616 .off1 = td_var_offset(file_lock_mode),
29c1349f
JA
617 .help = "Lock file when doing IO to it",
618 .parent = "filename",
4d4e80f2
JA
619 .def = "none",
620 .posval = {
621 { .ival = "none",
622 .oval = FILE_LOCK_NONE,
623 .help = "No file locking",
624 },
625 { .ival = "exclusive",
626 .oval = FILE_LOCK_EXCLUSIVE,
627 .help = "Exclusive file lock",
628 },
629 {
630 .ival = "readwrite",
631 .oval = FILE_LOCK_READWRITE,
632 .help = "Read vs write lock",
633 },
634 },
29c1349f 635 },
214e1eca
JA
636 {
637 .name = "opendir",
638 .type = FIO_OPT_STR_STORE,
639 .off1 = td_var_offset(opendir),
640 .cb = str_opendir_cb,
641 .help = "Recursively add files from this directory and down",
642 },
643 {
644 .name = "rw",
d3aad8f2 645 .alias = "readwrite",
214e1eca 646 .type = FIO_OPT_STR,
211097b2 647 .cb = str_rw_cb,
214e1eca
JA
648 .off1 = td_var_offset(td_ddir),
649 .help = "IO direction",
650 .def = "read",
651 .posval = {
652 { .ival = "read",
653 .oval = TD_DDIR_READ,
654 .help = "Sequential read",
655 },
656 { .ival = "write",
657 .oval = TD_DDIR_WRITE,
658 .help = "Sequential write",
659 },
660 { .ival = "randread",
661 .oval = TD_DDIR_RANDREAD,
662 .help = "Random read",
663 },
664 { .ival = "randwrite",
665 .oval = TD_DDIR_RANDWRITE,
666 .help = "Random write",
667 },
668 { .ival = "rw",
669 .oval = TD_DDIR_RW,
670 .help = "Sequential read and write mix",
671 },
672 { .ival = "randrw",
673 .oval = TD_DDIR_RANDRW,
674 .help = "Random read and write mix"
675 },
676 },
677 },
678 {
679 .name = "ioengine",
680 .type = FIO_OPT_STR_STORE,
681 .off1 = td_var_offset(ioengine),
682 .help = "IO engine to use",
683 .def = "sync",
684 .posval = {
685 { .ival = "sync",
686 .help = "Use read/write",
687 },
a31041ea 688 { .ival = "psync",
689 .help = "Use pread/pwrite",
690 },
1d2af02a
JA
691 { .ival = "vsync",
692 .help = "Use readv/writev",
693 },
214e1eca
JA
694#ifdef FIO_HAVE_LIBAIO
695 { .ival = "libaio",
696 .help = "Linux native asynchronous IO",
697 },
698#endif
699#ifdef FIO_HAVE_POSIXAIO
700 { .ival = "posixaio",
701 .help = "POSIX asynchronous IO",
702 },
417f0068
JA
703#endif
704#ifdef FIO_HAVE_SOLARISAIO
705 { .ival = "solarisaio",
706 .help = "Solaris native asynchronous IO",
707 },
214e1eca
JA
708#endif
709 { .ival = "mmap",
710 .help = "Memory mapped IO",
711 },
712#ifdef FIO_HAVE_SPLICE
713 { .ival = "splice",
714 .help = "splice/vmsplice based IO",
715 },
9cce02e8
JA
716 { .ival = "netsplice",
717 .help = "splice/vmsplice to/from the network",
718 },
214e1eca
JA
719#endif
720#ifdef FIO_HAVE_SGIO
721 { .ival = "sg",
722 .help = "SCSI generic v3 IO",
723 },
724#endif
725 { .ival = "null",
726 .help = "Testing engine (no data transfer)",
727 },
728 { .ival = "net",
729 .help = "Network IO",
730 },
731#ifdef FIO_HAVE_SYSLET
732 { .ival = "syslet-rw",
733 .help = "syslet enabled async pread/pwrite IO",
734 },
735#endif
736 { .ival = "cpuio",
737 .help = "CPU cycler burner engine",
738 },
b8c82a46
JA
739#ifdef FIO_HAVE_GUASI
740 { .ival = "guasi",
741 .help = "GUASI IO engine",
742 },
743#endif
214e1eca
JA
744 { .ival = "external",
745 .help = "Load external engine (append name)",
746 },
747 },
748 },
749 {
750 .name = "iodepth",
751 .type = FIO_OPT_INT,
752 .off1 = td_var_offset(iodepth),
753 .help = "Amount of IO buffers to keep in flight",
757aff4f 754 .minval = 1,
214e1eca
JA
755 .def = "1",
756 },
757 {
758 .name = "iodepth_batch",
4950421a 759 .alias = "iodepth_batch_submit",
214e1eca
JA
760 .type = FIO_OPT_INT,
761 .off1 = td_var_offset(iodepth_batch),
d65db441 762 .help = "Number of IO buffers to submit in one go",
afdf9352 763 .parent = "iodepth",
a2e6f8ac
JA
764 .minval = 1,
765 .def = "1",
4950421a
JA
766 },
767 {
768 .name = "iodepth_batch_complete",
769 .type = FIO_OPT_INT,
770 .off1 = td_var_offset(iodepth_batch_complete),
d65db441 771 .help = "Number of IO buffers to retrieve in one go",
4950421a
JA
772 .parent = "iodepth",
773 .minval = 0,
774 .def = "1",
214e1eca
JA
775 },
776 {
777 .name = "iodepth_low",
778 .type = FIO_OPT_INT,
779 .off1 = td_var_offset(iodepth_low),
780 .help = "Low water mark for queuing depth",
afdf9352 781 .parent = "iodepth",
214e1eca
JA
782 },
783 {
784 .name = "size",
785 .type = FIO_OPT_STR_VAL,
2dc1bbeb 786 .off1 = td_var_offset(size),
c3edbdba 787 .minval = 1,
214e1eca
JA
788 .help = "Total size of device or files",
789 },
aa31f1f1
SL
790 {
791 .name = "fill_device",
792 .type = FIO_OPT_BOOL,
793 .off1 = td_var_offset(fill_device),
794 .help = "Write until an ENOSPC error occurs",
795 .def = "0",
796 },
214e1eca
JA
797 {
798 .name = "filesize",
799 .type = FIO_OPT_STR_VAL,
800 .off1 = td_var_offset(file_size_low),
801 .off2 = td_var_offset(file_size_high),
c3edbdba 802 .minval = 1,
214e1eca
JA
803 .help = "Size of individual files",
804 },
67a1000f
JA
805 {
806 .name = "offset",
807 .alias = "fileoffset",
808 .type = FIO_OPT_STR_VAL,
809 .off1 = td_var_offset(start_offset),
810 .help = "Start IO from this offset",
811 .def = "0",
812 },
214e1eca
JA
813 {
814 .name = "bs",
d3aad8f2 815 .alias = "blocksize",
e01b22b8 816 .type = FIO_OPT_INT,
214e1eca
JA
817 .off1 = td_var_offset(bs[DDIR_READ]),
818 .off2 = td_var_offset(bs[DDIR_WRITE]),
c3edbdba 819 .minval = 1,
214e1eca
JA
820 .help = "Block size unit",
821 .def = "4k",
67a1000f 822 .parent = "rw",
214e1eca 823 },
2b7a01d0
JA
824 {
825 .name = "ba",
826 .alias = "blockalign",
e01b22b8 827 .type = FIO_OPT_INT,
2b7a01d0
JA
828 .off1 = td_var_offset(ba[DDIR_READ]),
829 .off2 = td_var_offset(ba[DDIR_WRITE]),
830 .minval = 1,
831 .help = "IO block offset alignment",
832 .parent = "rw",
833 },
214e1eca
JA
834 {
835 .name = "bsrange",
d3aad8f2 836 .alias = "blocksize_range",
214e1eca
JA
837 .type = FIO_OPT_RANGE,
838 .off1 = td_var_offset(min_bs[DDIR_READ]),
839 .off2 = td_var_offset(max_bs[DDIR_READ]),
840 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
841 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
c3edbdba 842 .minval = 1,
214e1eca 843 .help = "Set block size range (in more detail than bs)",
67a1000f 844 .parent = "rw",
214e1eca 845 },
564ca972
JA
846 {
847 .name = "bssplit",
848 .type = FIO_OPT_STR,
849 .cb = str_bssplit_cb,
850 .help = "Set a specific mix of block sizes",
851 .parent = "rw",
852 },
214e1eca
JA
853 {
854 .name = "bs_unaligned",
d3aad8f2 855 .alias = "blocksize_unaligned",
214e1eca
JA
856 .type = FIO_OPT_STR_SET,
857 .off1 = td_var_offset(bs_unaligned),
858 .help = "Don't sector align IO buffer sizes",
67a1000f 859 .parent = "rw",
214e1eca
JA
860 },
861 {
862 .name = "randrepeat",
863 .type = FIO_OPT_BOOL,
864 .off1 = td_var_offset(rand_repeatable),
865 .help = "Use repeatable random IO pattern",
866 .def = "1",
67a1000f 867 .parent = "rw",
214e1eca
JA
868 },
869 {
870 .name = "norandommap",
871 .type = FIO_OPT_STR_SET,
872 .off1 = td_var_offset(norandommap),
873 .help = "Accept potential duplicate random blocks",
67a1000f 874 .parent = "rw",
214e1eca 875 },
2b386d25
JA
876 {
877 .name = "softrandommap",
878 .type = FIO_OPT_BOOL,
879 .off1 = td_var_offset(softrandommap),
f66ab3c8 880 .help = "Set norandommap if randommap allocation fails",
2b386d25
JA
881 .parent = "norandommap",
882 .def = "0",
883 },
214e1eca
JA
884 {
885 .name = "nrfiles",
886 .type = FIO_OPT_INT,
887 .off1 = td_var_offset(nr_files),
888 .help = "Split job workload between this number of files",
889 .def = "1",
890 },
891 {
892 .name = "openfiles",
893 .type = FIO_OPT_INT,
894 .off1 = td_var_offset(open_files),
895 .help = "Number of files to keep open at the same time",
896 },
897 {
898 .name = "file_service_type",
899 .type = FIO_OPT_STR,
900 .cb = str_fst_cb,
901 .off1 = td_var_offset(file_service_type),
902 .help = "How to select which file to service next",
903 .def = "roundrobin",
904 .posval = {
905 { .ival = "random",
906 .oval = FIO_FSERVICE_RANDOM,
907 .help = "Choose a file at random",
908 },
909 { .ival = "roundrobin",
910 .oval = FIO_FSERVICE_RR,
911 .help = "Round robin select files",
912 },
a086c257
JA
913 { .ival = "sequential",
914 .oval = FIO_FSERVICE_SEQ,
915 .help = "Finish one file before moving to the next",
916 },
214e1eca 917 },
67a1000f
JA
918 .parent = "nrfiles",
919 },
920 {
921 .name = "fadvise_hint",
922 .type = FIO_OPT_BOOL,
923 .off1 = td_var_offset(fadvise_hint),
924 .help = "Use fadvise() to advise the kernel on IO pattern",
925 .def = "1",
214e1eca
JA
926 },
927 {
928 .name = "fsync",
929 .type = FIO_OPT_INT,
930 .off1 = td_var_offset(fsync_blocks),
931 .help = "Issue fsync for writes every given number of blocks",
932 .def = "0",
933 },
5f9099ea
JA
934 {
935 .name = "fdatasync",
936 .type = FIO_OPT_INT,
937 .off1 = td_var_offset(fdatasync_blocks),
938 .help = "Issue fdatasync for writes every given number of blocks",
939 .def = "0",
940 },
214e1eca
JA
941 {
942 .name = "direct",
943 .type = FIO_OPT_BOOL,
944 .off1 = td_var_offset(odirect),
945 .help = "Use O_DIRECT IO (negates buffered)",
946 .def = "0",
947 },
948 {
949 .name = "buffered",
950 .type = FIO_OPT_BOOL,
951 .off1 = td_var_offset(odirect),
952 .neg = 1,
953 .help = "Use buffered IO (negates direct)",
954 .def = "1",
955 },
956 {
957 .name = "overwrite",
958 .type = FIO_OPT_BOOL,
959 .off1 = td_var_offset(overwrite),
960 .help = "When writing, set whether to overwrite current data",
961 .def = "0",
962 },
963 {
964 .name = "loops",
965 .type = FIO_OPT_INT,
966 .off1 = td_var_offset(loops),
967 .help = "Number of times to run the job",
968 .def = "1",
969 },
970 {
971 .name = "numjobs",
972 .type = FIO_OPT_INT,
973 .off1 = td_var_offset(numjobs),
974 .help = "Duplicate this job this many times",
975 .def = "1",
976 },
977 {
978 .name = "startdelay",
979 .type = FIO_OPT_INT,
980 .off1 = td_var_offset(start_delay),
981 .help = "Only start job when this period has passed",
982 .def = "0",
983 },
984 {
985 .name = "runtime",
986 .alias = "timeout",
987 .type = FIO_OPT_STR_VAL_TIME,
988 .off1 = td_var_offset(timeout),
989 .help = "Stop workload when this amount of time has passed",
990 .def = "0",
991 },
cf4464ca
JA
992 {
993 .name = "time_based",
994 .type = FIO_OPT_STR_SET,
995 .off1 = td_var_offset(time_based),
996 .help = "Keep running until runtime/timeout is met",
997 },
721938ae
JA
998 {
999 .name = "ramp_time",
1000 .type = FIO_OPT_STR_VAL_TIME,
1001 .off1 = td_var_offset(ramp_time),
1002 .help = "Ramp up time before measuring performance",
1003 },
214e1eca
JA
1004 {
1005 .name = "mem",
d3aad8f2 1006 .alias = "iomem",
214e1eca
JA
1007 .type = FIO_OPT_STR,
1008 .cb = str_mem_cb,
1009 .off1 = td_var_offset(mem_type),
1010 .help = "Backing type for IO buffers",
1011 .def = "malloc",
1012 .posval = {
1013 { .ival = "malloc",
1014 .oval = MEM_MALLOC,
1015 .help = "Use malloc(3) for IO buffers",
1016 },
37c8cdfe
JA
1017 { .ival = "shm",
1018 .oval = MEM_SHM,
1019 .help = "Use shared memory segments for IO buffers",
1020 },
214e1eca
JA
1021#ifdef FIO_HAVE_HUGETLB
1022 { .ival = "shmhuge",
1023 .oval = MEM_SHMHUGE,
1024 .help = "Like shm, but use huge pages",
1025 },
b370e46a 1026#endif
37c8cdfe
JA
1027 { .ival = "mmap",
1028 .oval = MEM_MMAP,
1029 .help = "Use mmap(2) (file or anon) for IO buffers",
1030 },
214e1eca
JA
1031#ifdef FIO_HAVE_HUGETLB
1032 { .ival = "mmaphuge",
1033 .oval = MEM_MMAPHUGE,
1034 .help = "Like mmap, but use huge pages",
1035 },
1036#endif
1037 },
1038 },
1039 {
1040 .name = "verify",
1041 .type = FIO_OPT_STR,
1042 .off1 = td_var_offset(verify),
1043 .help = "Verify data written",
1044 .def = "0",
1045 .posval = {
1046 { .ival = "0",
1047 .oval = VERIFY_NONE,
1048 .help = "Don't do IO verification",
1049 },
fcca4b58
JA
1050 { .ival = "md5",
1051 .oval = VERIFY_MD5,
1052 .help = "Use md5 checksums for verification",
1053 },
d77a7af3
JA
1054 { .ival = "crc64",
1055 .oval = VERIFY_CRC64,
1056 .help = "Use crc64 checksums for verification",
1057 },
214e1eca
JA
1058 { .ival = "crc32",
1059 .oval = VERIFY_CRC32,
1060 .help = "Use crc32 checksums for verification",
1061 },
af497e6a
JA
1062 { .ival = "crc32c-intel",
1063 .oval = VERIFY_CRC32C_INTEL,
1064 .help = "Use hw crc32c checksums for verification",
1065 },
bac39e0e
JA
1066 { .ival = "crc32c",
1067 .oval = VERIFY_CRC32C,
1068 .help = "Use crc32c checksums for verification",
1069 },
969f7ed3
JA
1070 { .ival = "crc16",
1071 .oval = VERIFY_CRC16,
1072 .help = "Use crc16 checksums for verification",
1073 },
1e154bdb
JA
1074 { .ival = "crc7",
1075 .oval = VERIFY_CRC7,
1076 .help = "Use crc7 checksums for verification",
1077 },
cd14cc10
JA
1078 { .ival = "sha256",
1079 .oval = VERIFY_SHA256,
1080 .help = "Use sha256 checksums for verification",
1081 },
1082 { .ival = "sha512",
1083 .oval = VERIFY_SHA512,
1084 .help = "Use sha512 checksums for verification",
1085 },
7437ee87
SL
1086 { .ival = "meta",
1087 .oval = VERIFY_META,
1088 .help = "Use io information",
1089 },
36690c9b
JA
1090 {
1091 .ival = "null",
1092 .oval = VERIFY_NULL,
1093 .help = "Pretend to verify",
1094 },
214e1eca
JA
1095 },
1096 },
005c565a
JA
1097 {
1098 .name = "do_verify",
68e1f29a 1099 .type = FIO_OPT_BOOL,
005c565a
JA
1100 .off1 = td_var_offset(do_verify),
1101 .help = "Run verification stage after write",
1102 .def = "1",
1103 .parent = "verify",
1104 },
160b966d
JA
1105 {
1106 .name = "verifysort",
1107 .type = FIO_OPT_BOOL,
1108 .off1 = td_var_offset(verifysort),
1109 .help = "Sort written verify blocks for read back",
1110 .def = "1",
c83f2df1 1111 .parent = "verify",
160b966d 1112 },
3f9f4e26 1113 {
a59e170d 1114 .name = "verify_interval",
e01b22b8 1115 .type = FIO_OPT_INT,
a59e170d 1116 .off1 = td_var_offset(verify_interval),
819a9680 1117 .minval = 2 * sizeof(struct verify_header),
a59e170d 1118 .help = "Store verify buffer header every N bytes",
afdf9352 1119 .parent = "verify",
3f9f4e26 1120 },
546a9142 1121 {
a59e170d 1122 .name = "verify_offset",
e01b22b8 1123 .type = FIO_OPT_INT,
a59e170d 1124 .help = "Offset verify header location by N bytes",
546a9142 1125 .def = "0",
5ec10eaa 1126 .cb = str_verify_offset_cb,
afdf9352 1127 .parent = "verify",
546a9142 1128 },
e28218f3
SL
1129 {
1130 .name = "verify_pattern",
1131 .type = FIO_OPT_INT,
1132 .cb = str_verify_pattern_cb,
1133 .help = "Fill pattern for IO buffers",
1134 .parent = "verify",
1135 },
a12a3b4d
JA
1136 {
1137 .name = "verify_fatal",
68e1f29a 1138 .type = FIO_OPT_BOOL,
a12a3b4d
JA
1139 .off1 = td_var_offset(verify_fatal),
1140 .def = "0",
1141 .help = "Exit on a single verify failure, don't continue",
1142 .parent = "verify",
1143 },
214e1eca
JA
1144 {
1145 .name = "write_iolog",
1146 .type = FIO_OPT_STR_STORE,
1147 .off1 = td_var_offset(write_iolog_file),
1148 .help = "Store IO pattern to file",
1149 },
1150 {
1151 .name = "read_iolog",
1152 .type = FIO_OPT_STR_STORE,
1153 .off1 = td_var_offset(read_iolog_file),
1154 .help = "Playback IO pattern from file",
1155 },
1156 {
1157 .name = "exec_prerun",
1158 .type = FIO_OPT_STR_STORE,
1159 .off1 = td_var_offset(exec_prerun),
1160 .help = "Execute this file prior to running job",
1161 },
1162 {
1163 .name = "exec_postrun",
1164 .type = FIO_OPT_STR_STORE,
1165 .off1 = td_var_offset(exec_postrun),
1166 .help = "Execute this file after running job",
1167 },
1168#ifdef FIO_HAVE_IOSCHED_SWITCH
1169 {
1170 .name = "ioscheduler",
1171 .type = FIO_OPT_STR_STORE,
1172 .off1 = td_var_offset(ioscheduler),
1173 .help = "Use this IO scheduler on the backing device",
1174 },
1175#endif
1176 {
1177 .name = "zonesize",
1178 .type = FIO_OPT_STR_VAL,
1179 .off1 = td_var_offset(zone_size),
1180 .help = "Give size of an IO zone",
1181 .def = "0",
1182 },
1183 {
1184 .name = "zoneskip",
1185 .type = FIO_OPT_STR_VAL,
1186 .off1 = td_var_offset(zone_skip),
1187 .help = "Space between IO zones",
1188 .def = "0",
1189 },
1190 {
1191 .name = "lockmem",
1192 .type = FIO_OPT_STR_VAL,
1193 .cb = str_lockmem_cb,
1194 .help = "Lock down this amount of memory",
1195 .def = "0",
1196 },
214e1eca
JA
1197 {
1198 .name = "rwmixread",
1199 .type = FIO_OPT_INT,
cb499fc4 1200 .cb = str_rwmix_read_cb,
214e1eca
JA
1201 .maxval = 100,
1202 .help = "Percentage of mixed workload that is reads",
1203 .def = "50",
1204 },
1205 {
1206 .name = "rwmixwrite",
1207 .type = FIO_OPT_INT,
cb499fc4 1208 .cb = str_rwmix_write_cb,
214e1eca
JA
1209 .maxval = 100,
1210 .help = "Percentage of mixed workload that is writes",
1211 .def = "50",
1212 },
afdf9352
JA
1213 {
1214 .name = "rwmixcycle",
15ca150e 1215 .type = FIO_OPT_DEPRECATED,
afdf9352 1216 },
214e1eca
JA
1217 {
1218 .name = "nice",
1219 .type = FIO_OPT_INT,
1220 .off1 = td_var_offset(nice),
1221 .help = "Set job CPU nice value",
1222 .minval = -19,
1223 .maxval = 20,
1224 .def = "0",
1225 },
1226#ifdef FIO_HAVE_IOPRIO
1227 {
1228 .name = "prio",
1229 .type = FIO_OPT_INT,
1230 .cb = str_prio_cb,
1231 .help = "Set job IO priority value",
1232 .minval = 0,
1233 .maxval = 7,
1234 },
1235 {
1236 .name = "prioclass",
1237 .type = FIO_OPT_INT,
1238 .cb = str_prioclass_cb,
1239 .help = "Set job IO priority class",
1240 .minval = 0,
1241 .maxval = 3,
1242 },
1243#endif
1244 {
1245 .name = "thinktime",
1246 .type = FIO_OPT_INT,
1247 .off1 = td_var_offset(thinktime),
1248 .help = "Idle time between IO buffers (usec)",
1249 .def = "0",
1250 },
1251 {
1252 .name = "thinktime_spin",
1253 .type = FIO_OPT_INT,
1254 .off1 = td_var_offset(thinktime_spin),
1255 .help = "Start think time by spinning this amount (usec)",
1256 .def = "0",
afdf9352 1257 .parent = "thinktime",
214e1eca
JA
1258 },
1259 {
1260 .name = "thinktime_blocks",
1261 .type = FIO_OPT_INT,
1262 .off1 = td_var_offset(thinktime_blocks),
1263 .help = "IO buffer period between 'thinktime'",
1264 .def = "1",
afdf9352 1265 .parent = "thinktime",
214e1eca
JA
1266 },
1267 {
1268 .name = "rate",
e01b22b8 1269 .type = FIO_OPT_INT,
581e7141
JA
1270 .off1 = td_var_offset(rate[0]),
1271 .off2 = td_var_offset(rate[1]),
214e1eca
JA
1272 .help = "Set bandwidth rate",
1273 },
1274 {
1275 .name = "ratemin",
e01b22b8 1276 .type = FIO_OPT_INT,
581e7141
JA
1277 .off1 = td_var_offset(ratemin[0]),
1278 .off2 = td_var_offset(ratemin[1]),
4e991c23 1279 .help = "Job must meet this rate or it will be shutdown",
afdf9352 1280 .parent = "rate",
4e991c23
JA
1281 },
1282 {
1283 .name = "rate_iops",
e01b22b8 1284 .type = FIO_OPT_INT,
581e7141
JA
1285 .off1 = td_var_offset(rate_iops[0]),
1286 .off2 = td_var_offset(rate_iops[1]),
4e991c23
JA
1287 .help = "Limit IO used to this number of IO operations/sec",
1288 },
1289 {
1290 .name = "rate_iops_min",
e01b22b8 1291 .type = FIO_OPT_INT,
581e7141
JA
1292 .off1 = td_var_offset(rate_iops_min[0]),
1293 .off2 = td_var_offset(rate_iops_min[1]),
4e991c23 1294 .help = "Job must meet this rate or it will be shutdown",
afdf9352 1295 .parent = "rate_iops",
214e1eca
JA
1296 },
1297 {
1298 .name = "ratecycle",
1299 .type = FIO_OPT_INT,
1300 .off1 = td_var_offset(ratecycle),
1301 .help = "Window average for rate limits (msec)",
1302 .def = "1000",
afdf9352 1303 .parent = "rate",
214e1eca
JA
1304 },
1305 {
1306 .name = "invalidate",
1307 .type = FIO_OPT_BOOL,
1308 .off1 = td_var_offset(invalidate_cache),
1309 .help = "Invalidate buffer/page cache prior to running job",
1310 .def = "1",
1311 },
1312 {
1313 .name = "sync",
1314 .type = FIO_OPT_BOOL,
1315 .off1 = td_var_offset(sync_io),
1316 .help = "Use O_SYNC for buffered writes",
1317 .def = "0",
67a1000f 1318 .parent = "buffered",
214e1eca
JA
1319 },
1320 {
1321 .name = "bwavgtime",
1322 .type = FIO_OPT_INT,
1323 .off1 = td_var_offset(bw_avg_time),
5ec10eaa
JA
1324 .help = "Time window over which to calculate bandwidth"
1325 " (msec)",
214e1eca
JA
1326 .def = "500",
1327 },
1328 {
1329 .name = "create_serialize",
1330 .type = FIO_OPT_BOOL,
1331 .off1 = td_var_offset(create_serialize),
1332 .help = "Serialize creating of job files",
1333 .def = "1",
1334 },
1335 {
1336 .name = "create_fsync",
1337 .type = FIO_OPT_BOOL,
1338 .off1 = td_var_offset(create_fsync),
1339 .help = "Fsync file after creation",
1340 .def = "1",
1341 },
814452bd
JA
1342 {
1343 .name = "create_on_open",
1344 .type = FIO_OPT_BOOL,
1345 .off1 = td_var_offset(create_on_open),
1346 .help = "Create files when they are opened for IO",
1347 .def = "0",
1348 },
afad68f7
ZY
1349 {
1350 .name = "pre_read",
1351 .type = FIO_OPT_BOOL,
1352 .off1 = td_var_offset(pre_read),
1353 .help = "Preread files before starting official testing",
1354 .def = "0",
1355 },
214e1eca
JA
1356 {
1357 .name = "cpuload",
1358 .type = FIO_OPT_INT,
1359 .off1 = td_var_offset(cpuload),
1360 .help = "Use this percentage of CPU",
1361 },
1362 {
1363 .name = "cpuchunks",
1364 .type = FIO_OPT_INT,
1365 .off1 = td_var_offset(cpucycle),
1366 .help = "Length of the CPU burn cycles (usecs)",
1367 .def = "50000",
67a1000f 1368 .parent = "cpuload",
214e1eca
JA
1369 },
1370#ifdef FIO_HAVE_CPU_AFFINITY
1371 {
1372 .name = "cpumask",
1373 .type = FIO_OPT_INT,
1374 .cb = str_cpumask_cb,
1375 .help = "CPU affinity mask",
1376 },
d2e268b0
JA
1377 {
1378 .name = "cpus_allowed",
1379 .type = FIO_OPT_STR,
1380 .cb = str_cpus_allowed_cb,
1381 .help = "Set CPUs allowed",
1382 },
214e1eca
JA
1383#endif
1384 {
1385 .name = "end_fsync",
1386 .type = FIO_OPT_BOOL,
1387 .off1 = td_var_offset(end_fsync),
1388 .help = "Include fsync at the end of job",
1389 .def = "0",
1390 },
1391 {
1392 .name = "fsync_on_close",
1393 .type = FIO_OPT_BOOL,
1394 .off1 = td_var_offset(fsync_on_close),
1395 .help = "fsync files on close",
1396 .def = "0",
1397 },
1398 {
1399 .name = "unlink",
1400 .type = FIO_OPT_BOOL,
1401 .off1 = td_var_offset(unlink),
1402 .help = "Unlink created files after job has completed",
1403 .def = "0",
1404 },
1405 {
1406 .name = "exitall",
1407 .type = FIO_OPT_STR_SET,
1408 .cb = str_exitall_cb,
1409 .help = "Terminate all jobs when one exits",
1410 },
1411 {
1412 .name = "stonewall",
1413 .type = FIO_OPT_STR_SET,
1414 .off1 = td_var_offset(stonewall),
1415 .help = "Insert a hard barrier between this job and previous",
1416 },
b3d62a75
JA
1417 {
1418 .name = "new_group",
1419 .type = FIO_OPT_STR_SET,
1420 .off1 = td_var_offset(new_group),
1421 .help = "Mark the start of a new group (for reporting)",
1422 },
214e1eca
JA
1423 {
1424 .name = "thread",
1425 .type = FIO_OPT_STR_SET,
1426 .off1 = td_var_offset(use_thread),
1427 .help = "Use threads instead of forks",
1428 },
1429 {
1430 .name = "write_bw_log",
e3cedca7 1431 .type = FIO_OPT_STR,
214e1eca 1432 .off1 = td_var_offset(write_bw_log),
e3cedca7 1433 .cb = str_write_bw_log_cb,
214e1eca
JA
1434 .help = "Write log of bandwidth during run",
1435 },
1436 {
1437 .name = "write_lat_log",
e3cedca7 1438 .type = FIO_OPT_STR,
214e1eca 1439 .off1 = td_var_offset(write_lat_log),
e3cedca7 1440 .cb = str_write_lat_log_cb,
214e1eca
JA
1441 .help = "Write log of latency during run",
1442 },
1443 {
1444 .name = "hugepage-size",
e01b22b8 1445 .type = FIO_OPT_INT,
214e1eca
JA
1446 .off1 = td_var_offset(hugepage_size),
1447 .help = "When using hugepages, specify size of each page",
1448 .def = __stringify(FIO_HUGE_PAGE),
1449 },
1450 {
1451 .name = "group_reporting",
1452 .type = FIO_OPT_STR_SET,
1453 .off1 = td_var_offset(group_reporting),
1454 .help = "Do reporting on a per-group basis",
1455 },
e9459e5a
JA
1456 {
1457 .name = "zero_buffers",
1458 .type = FIO_OPT_STR_SET,
1459 .off1 = td_var_offset(zero_buffers),
1460 .help = "Init IO buffers to all zeroes",
1461 },
5973cafb
JA
1462 {
1463 .name = "refill_buffers",
1464 .type = FIO_OPT_STR_SET,
1465 .off1 = td_var_offset(refill_buffers),
1466 .help = "Refill IO buffers on every IO submit",
1467 },
0a839f30
JA
1468#ifdef FIO_HAVE_DISK_UTIL
1469 {
1470 .name = "disk_util",
1471 .type = FIO_OPT_BOOL,
1472 .off1 = td_var_offset(do_disk_util),
f66ab3c8 1473 .help = "Log disk utilization statistics",
0a839f30
JA
1474 .def = "1",
1475 },
1476#endif
993bf48b
JA
1477 {
1478 .name = "gtod_reduce",
1479 .type = FIO_OPT_BOOL,
1480 .help = "Greatly reduce number of gettimeofday() calls",
1481 .cb = str_gtod_reduce_cb,
1482 .def = "0",
1483 },
9520ebb9
JA
1484 {
1485 .name = "disable_clat",
1486 .type = FIO_OPT_BOOL,
1487 .off1 = td_var_offset(disable_clat),
1488 .help = "Disable completion latency numbers",
993bf48b 1489 .parent = "gtod_reduce",
9520ebb9
JA
1490 .def = "0",
1491 },
1492 {
1493 .name = "disable_slat",
1494 .type = FIO_OPT_BOOL,
1495 .off1 = td_var_offset(disable_slat),
1496 .help = "Disable submissionn latency numbers",
993bf48b 1497 .parent = "gtod_reduce",
9520ebb9
JA
1498 .def = "0",
1499 },
1500 {
1501 .name = "disable_bw_measurement",
1502 .type = FIO_OPT_BOOL,
1503 .off1 = td_var_offset(disable_bw),
1504 .help = "Disable bandwidth logging",
993bf48b 1505 .parent = "gtod_reduce",
9520ebb9
JA
1506 .def = "0",
1507 },
be4ecfdf
JA
1508 {
1509 .name = "gtod_cpu",
1510 .type = FIO_OPT_INT,
1511 .cb = str_gtod_cpu_cb,
1512 .help = "Setup dedicated gettimeofday() thread on this CPU",
1513 },
f2bba182
RR
1514 {
1515 .name = "continue_on_error",
1516 .type = FIO_OPT_BOOL,
1517 .off1 = td_var_offset(continue_on_error),
1518 .help = "Continue on non-fatal errors during I/O",
1519 .def = "0",
1520 },
214e1eca
JA
1521 {
1522 .name = NULL,
1523 },
1524};
1525
1526void fio_options_dup_and_init(struct option *long_options)
1527{
1528 struct fio_option *o;
1529 unsigned int i;
1530
1531 options_init(options);
1532
1533 i = 0;
1534 while (long_options[i].name)
1535 i++;
1536
1537 o = &options[0];
1538 while (o->name) {
5921e80c 1539 long_options[i].name = (char *) o->name;
214e1eca
JA
1540 long_options[i].val = FIO_GETOPT_JOB;
1541 if (o->type == FIO_OPT_STR_SET)
1542 long_options[i].has_arg = no_argument;
1543 else
1544 long_options[i].has_arg = required_argument;
1545
1546 i++;
1547 o++;
1548 assert(i < FIO_NR_OPTIONS);
1549 }
1550}
1551
3b8b7135 1552int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 1553{
3b8b7135
JA
1554 int i, ret;
1555
1556 sort_options(opts, options, num_opts);
1557
1558 for (ret = 0, i = 0; i < num_opts; i++)
1559 ret |= parse_option(opts[i], options, td);
1560
1561 return ret;
214e1eca
JA
1562}
1563
1564int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1565{
1566 return parse_cmd_option(opt, val, options, td);
1567}
1568
1569void fio_fill_default_options(struct thread_data *td)
1570{
1571 fill_default_options(td, options);
1572}
1573
1574int fio_show_option_help(const char *opt)
1575{
1576 return show_cmd_help(options, opt);
1577}
d23bb327
JA
1578
1579static void __options_mem(struct thread_data *td, int alloc)
1580{
1581 struct thread_options *o = &td->o;
1582 struct fio_option *opt;
1583 char **ptr;
1584 int i;
1585
1586 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1587 if (opt->type != FIO_OPT_STR_STORE)
1588 continue;
1589
1590 ptr = (void *) o + opt->off1;
1591 if (*ptr) {
1592 if (alloc)
1593 *ptr = strdup(*ptr);
1594 else {
1595 free(*ptr);
1596 *ptr = NULL;
1597 }
1598 }
1599 }
1600}
1601
1602/*
1603 * dupe FIO_OPT_STR_STORE options
1604 */
1605void options_mem_dupe(struct thread_data *td)
1606{
1607 __options_mem(td, 1);
1608}
1609
22d66213 1610void options_mem_free(struct thread_data fio_unused *td)
d23bb327 1611{
22d66213 1612#if 0
d23bb327 1613 __options_mem(td, 0);
22d66213 1614#endif
d23bb327 1615}