blob: ead31ace29c00fb88247ea82ec76502edafb582a [file] [log] [blame]
Jens Axboe214e1ec2007-03-15 10:48:13 +01001#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>
Jens Axboe921c7662008-03-26 09:17:55 +01008#include <libgen.h>
Jens Axboe214e1ec2007-03-15 10:48:13 +01009
10#include "fio.h"
11#include "parse.h"
Jens Axboe90059d62007-07-30 09:33:12 +020012#include "fls.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010013
Jens Axboe2dc1bbe2007-03-15 15:01:33 +010014#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010015
16/*
17 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
18 */
19static char *get_opt_postfix(const char *str)
20{
21 char *p = strstr(str, ":");
22
23 if (!p)
24 return NULL;
25
26 p++;
27 strip_blank_front(&p);
28 strip_blank_end(p);
29 return strdup(p);
30}
31
Jens Axboe564ca972007-12-14 12:21:19 +010032static int bs_cmp(const void *p1, const void *p2)
33{
34 const struct bssplit *bsp1 = p1;
35 const struct bssplit *bsp2 = p2;
36
37 return bsp1->perc < bsp2->perc;
38}
39
40static int str_bssplit_cb(void *data, const char *input)
41{
42 struct thread_data *td = data;
43 char *fname, *str, *p;
44 unsigned int i, perc, perc_missing;
45 unsigned int max_bs, min_bs;
46 long long val;
47
48 p = str = strdup(input);
49
50 strip_blank_front(&str);
51 strip_blank_end(str);
52
53 td->o.bssplit_nr = 4;
54 td->o.bssplit = malloc(4 * sizeof(struct bssplit));
55
56 i = 0;
57 max_bs = 0;
58 min_bs = -1;
59 while ((fname = strsep(&str, ":")) != NULL) {
60 char *perc_str;
61
62 if (!strlen(fname))
63 break;
64
65 /*
66 * grow struct buffer, if needed
67 */
68 if (i == td->o.bssplit_nr) {
69 td->o.bssplit_nr <<= 1;
Jens Axboe5ec10ea2008-03-06 15:42:00 +010070 td->o.bssplit = realloc(td->o.bssplit,
71 td->o.bssplit_nr
72 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010073 }
74
75 perc_str = strstr(fname, "/");
76 if (perc_str) {
77 *perc_str = '\0';
78 perc_str++;
79 perc = atoi(perc_str);
80 if (perc > 100)
81 perc = 100;
82 else if (!perc)
83 perc = -1;
84 } else
85 perc = -1;
86
87 if (str_to_decimal(fname, &val, 1)) {
88 log_err("fio: bssplit conversion failed\n");
89 free(td->o.bssplit);
90 return 1;
91 }
92
93 if (val > max_bs)
94 max_bs = val;
95 if (val < min_bs)
96 min_bs = val;
97
98 td->o.bssplit[i].bs = val;
99 td->o.bssplit[i].perc = perc;
100 i++;
101 }
102
103 td->o.bssplit_nr = i;
104
105 /*
106 * Now check if the percentages add up, and how much is missing
107 */
108 perc = perc_missing = 0;
109 for (i = 0; i < td->o.bssplit_nr; i++) {
110 struct bssplit *bsp = &td->o.bssplit[i];
111
112 if (bsp->perc == (unsigned char) -1)
113 perc_missing++;
114 else
115 perc += bsp->perc;
116 }
117
118 if (perc > 100) {
119 log_err("fio: bssplit percentages add to more than 100%%\n");
120 free(td->o.bssplit);
121 return 1;
122 }
123 /*
124 * If values didn't have a percentage set, divide the remains between
125 * them.
126 */
127 if (perc_missing) {
128 for (i = 0; i < td->o.bssplit_nr; i++) {
129 struct bssplit *bsp = &td->o.bssplit[i];
130
131 if (bsp->perc == (unsigned char) -1)
132 bsp->perc = (100 - perc) / perc_missing;
133 }
134 }
135
136 td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
137 td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
138
139 /*
140 * now sort based on percentages, for ease of lookup
141 */
142 qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
143
144 free(p);
145 return 0;
146}
147
Jens Axboe211097b2007-03-22 18:56:45 +0100148static int str_rw_cb(void *data, const char *str)
149{
150 struct thread_data *td = data;
151 char *nr = get_opt_postfix(str);
152
Jens Axboefafdba32007-03-26 10:09:12 +0200153 td->o.ddir_nr = 1;
Jens Axboe211097b2007-03-22 18:56:45 +0100154 if (nr)
155 td->o.ddir_nr = atoi(nr);
156
Jens Axboe211097b2007-03-22 18:56:45 +0100157 return 0;
158}
159
Jens Axboe214e1ec2007-03-15 10:48:13 +0100160static int str_mem_cb(void *data, const char *mem)
161{
162 struct thread_data *td = data;
163
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100164 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100165 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100166 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100167 log_err("fio: mmaphuge:/path/to/file\n");
168 return 1;
169 }
170 }
171
172 return 0;
173}
174
175static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
176{
177 mlock_size = *val;
178 return 0;
179}
180
181#ifdef FIO_HAVE_IOPRIO
182static int str_prioclass_cb(void *data, unsigned int *val)
183{
184 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200185 unsigned short mask;
186
187 /*
188 * mask off old class bits, str_prio_cb() may have set a default class
189 */
190 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
191 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100192
193 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100194 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100195 return 0;
196}
197
198static int str_prio_cb(void *data, unsigned int *val)
199{
200 struct thread_data *td = data;
201
202 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200203
204 /*
205 * If no class is set, assume BE
206 */
207 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
208 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
209
Jens Axboeac684782007-11-08 08:29:07 +0100210 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100211 return 0;
212}
213#endif
214
215static int str_exitall_cb(void)
216{
217 exitall_on_terminate = 1;
218 return 0;
219}
220
Jens Axboe214e1ec2007-03-15 10:48:13 +0100221#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100222static int str_cpumask_cb(void *data, unsigned int *val)
223{
224 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200225 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100226
Jens Axboed2e268b2007-06-15 10:33:49 +0200227 CPU_ZERO(&td->o.cpumask);
228
229 for (i = 0; i < sizeof(int) * 8; i++)
230 if ((1 << i) & *val)
231 CPU_SET(*val, &td->o.cpumask);
232
Jens Axboe375b2692007-05-22 09:13:02 +0200233 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100234 return 0;
235}
236
Jens Axboed2e268b2007-06-15 10:33:49 +0200237static int str_cpus_allowed_cb(void *data, const char *input)
238{
239 struct thread_data *td = data;
240 char *cpu, *str, *p;
241
242 CPU_ZERO(&td->o.cpumask);
243
244 p = str = strdup(input);
245
246 strip_blank_front(&str);
247 strip_blank_end(str);
248
249 while ((cpu = strsep(&str, ",")) != NULL) {
250 if (!strlen(cpu))
251 break;
252 CPU_SET(atoi(cpu), &td->o.cpumask);
253 }
254
255 free(p);
256 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200257 return 0;
258}
259#endif
260
Jens Axboe214e1ec2007-03-15 10:48:13 +0100261static int str_fst_cb(void *data, const char *str)
262{
263 struct thread_data *td = data;
264 char *nr = get_opt_postfix(str);
265
266 td->file_service_nr = 1;
267 if (nr)
268 td->file_service_nr = atoi(nr);
269
270 return 0;
271}
272
Jens Axboe921c7662008-03-26 09:17:55 +0100273static int check_dir(struct thread_data *td, char *fname)
274{
275 char file[PATH_MAX], *dir;
276 struct stat sb;
277
278 strcpy(file, fname);
279 dir = dirname(file);
280
281 if (lstat(dir, &sb) < 0) {
282 int ret = errno;
283
284 log_err("fio: %s is not a directory\n", dir);
285 td_verror(td, ret, "lstat");
286 return 1;
287 }
288
289 if (!S_ISDIR(sb.st_mode)) {
290 log_err("fio: %s is not a directory\n", dir);
291 return 1;
292 }
293
294 return 0;
295}
296
Jens Axboe214e1ec2007-03-15 10:48:13 +0100297static int str_filename_cb(void *data, const char *input)
298{
299 struct thread_data *td = data;
300 char *fname, *str, *p;
301
302 p = str = strdup(input);
303
304 strip_blank_front(&str);
305 strip_blank_end(str);
306
307 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100308 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100309
310 while ((fname = strsep(&str, ":")) != NULL) {
311 if (!strlen(fname))
312 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100313 if (check_dir(td, fname)) {
314 free(p);
315 return 1;
316 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100317 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100318 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100319 }
320
321 free(p);
322 return 0;
323}
324
325static int str_directory_cb(void *data, const char fio_unused *str)
326{
327 struct thread_data *td = data;
328 struct stat sb;
329
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100330 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100331 int ret = errno;
332
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100333 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100334 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100335 return 1;
336 }
337 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100338 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100339 return 1;
340 }
341
342 return 0;
343}
344
345static int str_opendir_cb(void *data, const char fio_unused *str)
346{
347 struct thread_data *td = data;
348
349 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100350 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100351
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100352 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353}
354
Jens Axboea59e1702007-07-30 08:53:27 +0200355static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200356{
357 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200358
Shawn Lewis546a9142007-07-28 21:11:37 +0200359 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200360 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200361 return 1;
362 }
Jens Axboea59e1702007-07-30 08:53:27 +0200363
364 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200365 return 0;
366}
367
Shawn Lewise28218f2008-01-16 11:01:33 +0100368static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200369{
370 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100371 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200372
Shawn Lewise28218f2008-01-16 11:01:33 +0100373 msb = fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200374 if (msb <= 8)
375 td->o.verify_pattern_bytes = 1;
376 else if (msb <= 16)
377 td->o.verify_pattern_bytes = 2;
378 else if (msb <= 24)
379 td->o.verify_pattern_bytes = 3;
380 else
381 td->o.verify_pattern_bytes = 4;
382
Shawn Lewise28218f2008-01-16 11:01:33 +0100383 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200384 return 0;
385}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100386
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100387static int str_lockfile_cb(void *data, const char *str)
388{
389 struct thread_data *td = data;
390 char *nr = get_opt_postfix(str);
391
392 td->o.lockfile_batch = 1;
393 if (nr)
394 td->o.lockfile_batch = atoi(nr);
395
396 return 0;
397}
398
Jens Axboe214e1ec2007-03-15 10:48:13 +0100399#define __stringify_1(x) #x
400#define __stringify(x) __stringify_1(x)
401
402/*
403 * Map of job/command line options
404 */
405static struct fio_option options[] = {
406 {
407 .name = "description",
408 .type = FIO_OPT_STR_STORE,
409 .off1 = td_var_offset(description),
410 .help = "Text job description",
411 },
412 {
413 .name = "name",
414 .type = FIO_OPT_STR_STORE,
415 .off1 = td_var_offset(name),
416 .help = "Name of this job",
417 },
418 {
419 .name = "directory",
420 .type = FIO_OPT_STR_STORE,
421 .off1 = td_var_offset(directory),
422 .cb = str_directory_cb,
423 .help = "Directory to store files in",
424 },
425 {
426 .name = "filename",
427 .type = FIO_OPT_STR_STORE,
428 .off1 = td_var_offset(filename),
429 .cb = str_filename_cb,
430 .help = "File(s) to use for the workload",
431 },
432 {
Jens Axboe29c13492008-03-01 19:25:20 +0100433 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100434 .type = FIO_OPT_STR,
435 .cb = str_lockfile_cb,
436 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100437 .help = "Lock file when doing IO to it",
438 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100439 .def = "none",
440 .posval = {
441 { .ival = "none",
442 .oval = FILE_LOCK_NONE,
443 .help = "No file locking",
444 },
445 { .ival = "exclusive",
446 .oval = FILE_LOCK_EXCLUSIVE,
447 .help = "Exclusive file lock",
448 },
449 {
450 .ival = "readwrite",
451 .oval = FILE_LOCK_READWRITE,
452 .help = "Read vs write lock",
453 },
454 },
Jens Axboe29c13492008-03-01 19:25:20 +0100455 },
456 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100457 .name = "opendir",
458 .type = FIO_OPT_STR_STORE,
459 .off1 = td_var_offset(opendir),
460 .cb = str_opendir_cb,
461 .help = "Recursively add files from this directory and down",
462 },
463 {
464 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100465 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100466 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100467 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100468 .off1 = td_var_offset(td_ddir),
469 .help = "IO direction",
470 .def = "read",
471 .posval = {
472 { .ival = "read",
473 .oval = TD_DDIR_READ,
474 .help = "Sequential read",
475 },
476 { .ival = "write",
477 .oval = TD_DDIR_WRITE,
478 .help = "Sequential write",
479 },
480 { .ival = "randread",
481 .oval = TD_DDIR_RANDREAD,
482 .help = "Random read",
483 },
484 { .ival = "randwrite",
485 .oval = TD_DDIR_RANDWRITE,
486 .help = "Random write",
487 },
488 { .ival = "rw",
489 .oval = TD_DDIR_RW,
490 .help = "Sequential read and write mix",
491 },
492 { .ival = "randrw",
493 .oval = TD_DDIR_RANDRW,
494 .help = "Random read and write mix"
495 },
496 },
497 },
498 {
499 .name = "ioengine",
500 .type = FIO_OPT_STR_STORE,
501 .off1 = td_var_offset(ioengine),
502 .help = "IO engine to use",
503 .def = "sync",
504 .posval = {
505 { .ival = "sync",
506 .help = "Use read/write",
507 },
gurudas paia31041e2007-10-23 15:12:30 +0200508 { .ival = "psync",
509 .help = "Use pread/pwrite",
510 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100511 { .ival = "vsync",
512 .help = "Use readv/writev",
513 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100514#ifdef FIO_HAVE_LIBAIO
515 { .ival = "libaio",
516 .help = "Linux native asynchronous IO",
517 },
518#endif
519#ifdef FIO_HAVE_POSIXAIO
520 { .ival = "posixaio",
521 .help = "POSIX asynchronous IO",
522 },
523#endif
524 { .ival = "mmap",
525 .help = "Memory mapped IO",
526 },
527#ifdef FIO_HAVE_SPLICE
528 { .ival = "splice",
529 .help = "splice/vmsplice based IO",
530 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200531 { .ival = "netsplice",
532 .help = "splice/vmsplice to/from the network",
533 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100534#endif
535#ifdef FIO_HAVE_SGIO
536 { .ival = "sg",
537 .help = "SCSI generic v3 IO",
538 },
539#endif
540 { .ival = "null",
541 .help = "Testing engine (no data transfer)",
542 },
543 { .ival = "net",
544 .help = "Network IO",
545 },
546#ifdef FIO_HAVE_SYSLET
547 { .ival = "syslet-rw",
548 .help = "syslet enabled async pread/pwrite IO",
549 },
550#endif
551 { .ival = "cpuio",
552 .help = "CPU cycler burner engine",
553 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100554#ifdef FIO_HAVE_GUASI
555 { .ival = "guasi",
556 .help = "GUASI IO engine",
557 },
558#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100559 { .ival = "external",
560 .help = "Load external engine (append name)",
561 },
562 },
563 },
564 {
565 .name = "iodepth",
566 .type = FIO_OPT_INT,
567 .off1 = td_var_offset(iodepth),
568 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100569 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100570 .def = "1",
571 },
572 {
573 .name = "iodepth_batch",
574 .type = FIO_OPT_INT,
575 .off1 = td_var_offset(iodepth_batch),
576 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200577 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100578 .minval = 1,
579 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100580 },
581 {
582 .name = "iodepth_low",
583 .type = FIO_OPT_INT,
584 .off1 = td_var_offset(iodepth_low),
585 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200586 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100587 },
588 {
589 .name = "size",
590 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100591 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200592 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100593 .help = "Total size of device or files",
594 },
595 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100596 .name = "fill_device",
597 .type = FIO_OPT_BOOL,
598 .off1 = td_var_offset(fill_device),
599 .help = "Write until an ENOSPC error occurs",
600 .def = "0",
601 },
602 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100603 .name = "filesize",
604 .type = FIO_OPT_STR_VAL,
605 .off1 = td_var_offset(file_size_low),
606 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200607 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100608 .help = "Size of individual files",
609 },
610 {
Jens Axboe67a10002007-07-31 23:12:16 +0200611 .name = "offset",
612 .alias = "fileoffset",
613 .type = FIO_OPT_STR_VAL,
614 .off1 = td_var_offset(start_offset),
615 .help = "Start IO from this offset",
616 .def = "0",
617 },
618 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100619 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100620 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100621 .type = FIO_OPT_STR_VAL_INT,
622 .off1 = td_var_offset(bs[DDIR_READ]),
623 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200624 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100625 .help = "Block size unit",
626 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200627 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100628 },
629 {
630 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100631 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100632 .type = FIO_OPT_RANGE,
633 .off1 = td_var_offset(min_bs[DDIR_READ]),
634 .off2 = td_var_offset(max_bs[DDIR_READ]),
635 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
636 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200637 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100638 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200639 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100640 },
641 {
Jens Axboe564ca972007-12-14 12:21:19 +0100642 .name = "bssplit",
643 .type = FIO_OPT_STR,
644 .cb = str_bssplit_cb,
645 .help = "Set a specific mix of block sizes",
646 .parent = "rw",
647 },
648 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100649 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100650 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100651 .type = FIO_OPT_STR_SET,
652 .off1 = td_var_offset(bs_unaligned),
653 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200654 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100655 },
656 {
657 .name = "randrepeat",
658 .type = FIO_OPT_BOOL,
659 .off1 = td_var_offset(rand_repeatable),
660 .help = "Use repeatable random IO pattern",
661 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200662 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100663 },
664 {
665 .name = "norandommap",
666 .type = FIO_OPT_STR_SET,
667 .off1 = td_var_offset(norandommap),
668 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200669 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100670 },
671 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100672 .name = "softrandommap",
673 .type = FIO_OPT_BOOL,
674 .off1 = td_var_offset(softrandommap),
675 .help = "Allow randommap to fail and continue witout",
676 .parent = "norandommap",
677 .def = "0",
678 },
679 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100680 .name = "nrfiles",
681 .type = FIO_OPT_INT,
682 .off1 = td_var_offset(nr_files),
683 .help = "Split job workload between this number of files",
684 .def = "1",
685 },
686 {
687 .name = "openfiles",
688 .type = FIO_OPT_INT,
689 .off1 = td_var_offset(open_files),
690 .help = "Number of files to keep open at the same time",
691 },
692 {
693 .name = "file_service_type",
694 .type = FIO_OPT_STR,
695 .cb = str_fst_cb,
696 .off1 = td_var_offset(file_service_type),
697 .help = "How to select which file to service next",
698 .def = "roundrobin",
699 .posval = {
700 { .ival = "random",
701 .oval = FIO_FSERVICE_RANDOM,
702 .help = "Choose a file at random",
703 },
704 { .ival = "roundrobin",
705 .oval = FIO_FSERVICE_RR,
706 .help = "Round robin select files",
707 },
708 },
Jens Axboe67a10002007-07-31 23:12:16 +0200709 .parent = "nrfiles",
710 },
711 {
712 .name = "fadvise_hint",
713 .type = FIO_OPT_BOOL,
714 .off1 = td_var_offset(fadvise_hint),
715 .help = "Use fadvise() to advise the kernel on IO pattern",
716 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100717 },
718 {
719 .name = "fsync",
720 .type = FIO_OPT_INT,
721 .off1 = td_var_offset(fsync_blocks),
722 .help = "Issue fsync for writes every given number of blocks",
723 .def = "0",
724 },
725 {
726 .name = "direct",
727 .type = FIO_OPT_BOOL,
728 .off1 = td_var_offset(odirect),
729 .help = "Use O_DIRECT IO (negates buffered)",
730 .def = "0",
731 },
732 {
733 .name = "buffered",
734 .type = FIO_OPT_BOOL,
735 .off1 = td_var_offset(odirect),
736 .neg = 1,
737 .help = "Use buffered IO (negates direct)",
738 .def = "1",
739 },
740 {
741 .name = "overwrite",
742 .type = FIO_OPT_BOOL,
743 .off1 = td_var_offset(overwrite),
744 .help = "When writing, set whether to overwrite current data",
745 .def = "0",
746 },
747 {
748 .name = "loops",
749 .type = FIO_OPT_INT,
750 .off1 = td_var_offset(loops),
751 .help = "Number of times to run the job",
752 .def = "1",
753 },
754 {
755 .name = "numjobs",
756 .type = FIO_OPT_INT,
757 .off1 = td_var_offset(numjobs),
758 .help = "Duplicate this job this many times",
759 .def = "1",
760 },
761 {
762 .name = "startdelay",
763 .type = FIO_OPT_INT,
764 .off1 = td_var_offset(start_delay),
765 .help = "Only start job when this period has passed",
766 .def = "0",
767 },
768 {
769 .name = "runtime",
770 .alias = "timeout",
771 .type = FIO_OPT_STR_VAL_TIME,
772 .off1 = td_var_offset(timeout),
773 .help = "Stop workload when this amount of time has passed",
774 .def = "0",
775 },
776 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200777 .name = "time_based",
778 .type = FIO_OPT_STR_SET,
779 .off1 = td_var_offset(time_based),
780 .help = "Keep running until runtime/timeout is met",
781 },
782 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100783 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100784 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100785 .type = FIO_OPT_STR,
786 .cb = str_mem_cb,
787 .off1 = td_var_offset(mem_type),
788 .help = "Backing type for IO buffers",
789 .def = "malloc",
790 .posval = {
791 { .ival = "malloc",
792 .oval = MEM_MALLOC,
793 .help = "Use malloc(3) for IO buffers",
794 },
Jens Axboeb370e462007-03-19 10:51:49 +0100795 { .ival = "shm",
796 .oval = MEM_SHM,
797 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100798 },
799#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100800 { .ival = "shmhuge",
801 .oval = MEM_SHMHUGE,
802 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100803 },
804#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100805 { .ival = "mmap",
806 .oval = MEM_MMAP,
807 .help = "Use mmap(2) (file or anon) for IO buffers",
808 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100809#ifdef FIO_HAVE_HUGETLB
810 { .ival = "mmaphuge",
811 .oval = MEM_MMAPHUGE,
812 .help = "Like mmap, but use huge pages",
813 },
814#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100815 },
816 },
817 {
818 .name = "verify",
819 .type = FIO_OPT_STR,
820 .off1 = td_var_offset(verify),
821 .help = "Verify data written",
822 .def = "0",
823 .posval = {
824 { .ival = "0",
825 .oval = VERIFY_NONE,
826 .help = "Don't do IO verification",
827 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200828 { .ival = "md5",
829 .oval = VERIFY_MD5,
830 .help = "Use md5 checksums for verification",
831 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200832 { .ival = "crc64",
833 .oval = VERIFY_CRC64,
834 .help = "Use crc64 checksums for verification",
835 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100836 { .ival = "crc32",
837 .oval = VERIFY_CRC32,
838 .help = "Use crc32 checksums for verification",
839 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200840 { .ival = "crc16",
841 .oval = VERIFY_CRC16,
842 .help = "Use crc16 checksums for verification",
843 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200844 { .ival = "crc7",
845 .oval = VERIFY_CRC7,
846 .help = "Use crc7 checksums for verification",
847 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200848 { .ival = "sha256",
849 .oval = VERIFY_SHA256,
850 .help = "Use sha256 checksums for verification",
851 },
852 { .ival = "sha512",
853 .oval = VERIFY_SHA512,
854 .help = "Use sha512 checksums for verification",
855 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200856 { .ival = "meta",
857 .oval = VERIFY_META,
858 .help = "Use io information",
859 },
Jens Axboe36690c92007-03-26 10:23:34 +0200860 {
861 .ival = "null",
862 .oval = VERIFY_NULL,
863 .help = "Pretend to verify",
864 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100865 },
866 },
867 {
Jens Axboe005c5652007-08-02 22:21:36 +0200868 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200869 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200870 .off1 = td_var_offset(do_verify),
871 .help = "Run verification stage after write",
872 .def = "1",
873 .parent = "verify",
874 },
875 {
Jens Axboe160b9662007-03-27 10:59:49 +0200876 .name = "verifysort",
877 .type = FIO_OPT_BOOL,
878 .off1 = td_var_offset(verifysort),
879 .help = "Sort written verify blocks for read back",
880 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200881 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200882 },
883 {
Jens Axboea59e1702007-07-30 08:53:27 +0200884 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200885 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200886 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200887 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200888 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200889 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200890 },
891 {
Jens Axboea59e1702007-07-30 08:53:27 +0200892 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +0200893 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200894 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +0200895 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100896 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +0200897 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +0200898 },
899 {
Shawn Lewise28218f2008-01-16 11:01:33 +0100900 .name = "verify_pattern",
901 .type = FIO_OPT_INT,
902 .cb = str_verify_pattern_cb,
903 .help = "Fill pattern for IO buffers",
904 .parent = "verify",
905 },
906 {
Jens Axboea12a3b42007-08-09 10:20:54 +0200907 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +0200908 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +0200909 .off1 = td_var_offset(verify_fatal),
910 .def = "0",
911 .help = "Exit on a single verify failure, don't continue",
912 .parent = "verify",
913 },
914 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100915 .name = "write_iolog",
916 .type = FIO_OPT_STR_STORE,
917 .off1 = td_var_offset(write_iolog_file),
918 .help = "Store IO pattern to file",
919 },
920 {
921 .name = "read_iolog",
922 .type = FIO_OPT_STR_STORE,
923 .off1 = td_var_offset(read_iolog_file),
924 .help = "Playback IO pattern from file",
925 },
926 {
927 .name = "exec_prerun",
928 .type = FIO_OPT_STR_STORE,
929 .off1 = td_var_offset(exec_prerun),
930 .help = "Execute this file prior to running job",
931 },
932 {
933 .name = "exec_postrun",
934 .type = FIO_OPT_STR_STORE,
935 .off1 = td_var_offset(exec_postrun),
936 .help = "Execute this file after running job",
937 },
938#ifdef FIO_HAVE_IOSCHED_SWITCH
939 {
940 .name = "ioscheduler",
941 .type = FIO_OPT_STR_STORE,
942 .off1 = td_var_offset(ioscheduler),
943 .help = "Use this IO scheduler on the backing device",
944 },
945#endif
946 {
947 .name = "zonesize",
948 .type = FIO_OPT_STR_VAL,
949 .off1 = td_var_offset(zone_size),
950 .help = "Give size of an IO zone",
951 .def = "0",
952 },
953 {
954 .name = "zoneskip",
955 .type = FIO_OPT_STR_VAL,
956 .off1 = td_var_offset(zone_skip),
957 .help = "Space between IO zones",
958 .def = "0",
959 },
960 {
961 .name = "lockmem",
962 .type = FIO_OPT_STR_VAL,
963 .cb = str_lockmem_cb,
964 .help = "Lock down this amount of memory",
965 .def = "0",
966 },
967 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100968 .name = "rwmixread",
969 .type = FIO_OPT_INT,
Jens Axboee47f7992007-03-21 14:05:39 +0100970 .off1 = td_var_offset(rwmix[DDIR_READ]),
Jens Axboe214e1ec2007-03-15 10:48:13 +0100971 .maxval = 100,
972 .help = "Percentage of mixed workload that is reads",
973 .def = "50",
974 },
975 {
976 .name = "rwmixwrite",
977 .type = FIO_OPT_INT,
Jens Axboee47f7992007-03-21 14:05:39 +0100978 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
Jens Axboe214e1ec2007-03-15 10:48:13 +0100979 .maxval = 100,
980 .help = "Percentage of mixed workload that is writes",
981 .def = "50",
982 },
983 {
Jens Axboeafdf9352007-07-31 16:14:34 +0200984 .name = "rwmixcycle",
985 .type = FIO_OPT_INT,
986 .off1 = td_var_offset(rwmixcycle),
987 .help = "Cycle period for mixed read/write workloads (msec)",
988 .def = "500",
989 .parent = "rwmixread",
990 },
991 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100992 .name = "nice",
993 .type = FIO_OPT_INT,
994 .off1 = td_var_offset(nice),
995 .help = "Set job CPU nice value",
996 .minval = -19,
997 .maxval = 20,
998 .def = "0",
999 },
1000#ifdef FIO_HAVE_IOPRIO
1001 {
1002 .name = "prio",
1003 .type = FIO_OPT_INT,
1004 .cb = str_prio_cb,
1005 .help = "Set job IO priority value",
1006 .minval = 0,
1007 .maxval = 7,
1008 },
1009 {
1010 .name = "prioclass",
1011 .type = FIO_OPT_INT,
1012 .cb = str_prioclass_cb,
1013 .help = "Set job IO priority class",
1014 .minval = 0,
1015 .maxval = 3,
1016 },
1017#endif
1018 {
1019 .name = "thinktime",
1020 .type = FIO_OPT_INT,
1021 .off1 = td_var_offset(thinktime),
1022 .help = "Idle time between IO buffers (usec)",
1023 .def = "0",
1024 },
1025 {
1026 .name = "thinktime_spin",
1027 .type = FIO_OPT_INT,
1028 .off1 = td_var_offset(thinktime_spin),
1029 .help = "Start think time by spinning this amount (usec)",
1030 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001031 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001032 },
1033 {
1034 .name = "thinktime_blocks",
1035 .type = FIO_OPT_INT,
1036 .off1 = td_var_offset(thinktime_blocks),
1037 .help = "IO buffer period between 'thinktime'",
1038 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001039 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001040 },
1041 {
1042 .name = "rate",
1043 .type = FIO_OPT_INT,
1044 .off1 = td_var_offset(rate),
1045 .help = "Set bandwidth rate",
1046 },
1047 {
1048 .name = "ratemin",
1049 .type = FIO_OPT_INT,
1050 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001051 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001052 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001053 },
1054 {
1055 .name = "rate_iops",
1056 .type = FIO_OPT_INT,
1057 .off1 = td_var_offset(rate_iops),
1058 .help = "Limit IO used to this number of IO operations/sec",
1059 },
1060 {
1061 .name = "rate_iops_min",
1062 .type = FIO_OPT_INT,
1063 .off1 = td_var_offset(rate_iops_min),
1064 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001065 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001066 },
1067 {
1068 .name = "ratecycle",
1069 .type = FIO_OPT_INT,
1070 .off1 = td_var_offset(ratecycle),
1071 .help = "Window average for rate limits (msec)",
1072 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001073 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001074 },
1075 {
1076 .name = "invalidate",
1077 .type = FIO_OPT_BOOL,
1078 .off1 = td_var_offset(invalidate_cache),
1079 .help = "Invalidate buffer/page cache prior to running job",
1080 .def = "1",
1081 },
1082 {
1083 .name = "sync",
1084 .type = FIO_OPT_BOOL,
1085 .off1 = td_var_offset(sync_io),
1086 .help = "Use O_SYNC for buffered writes",
1087 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001088 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001089 },
1090 {
1091 .name = "bwavgtime",
1092 .type = FIO_OPT_INT,
1093 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001094 .help = "Time window over which to calculate bandwidth"
1095 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001096 .def = "500",
1097 },
1098 {
1099 .name = "create_serialize",
1100 .type = FIO_OPT_BOOL,
1101 .off1 = td_var_offset(create_serialize),
1102 .help = "Serialize creating of job files",
1103 .def = "1",
1104 },
1105 {
1106 .name = "create_fsync",
1107 .type = FIO_OPT_BOOL,
1108 .off1 = td_var_offset(create_fsync),
1109 .help = "Fsync file after creation",
1110 .def = "1",
1111 },
1112 {
1113 .name = "cpuload",
1114 .type = FIO_OPT_INT,
1115 .off1 = td_var_offset(cpuload),
1116 .help = "Use this percentage of CPU",
1117 },
1118 {
1119 .name = "cpuchunks",
1120 .type = FIO_OPT_INT,
1121 .off1 = td_var_offset(cpucycle),
1122 .help = "Length of the CPU burn cycles (usecs)",
1123 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001124 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001125 },
1126#ifdef FIO_HAVE_CPU_AFFINITY
1127 {
1128 .name = "cpumask",
1129 .type = FIO_OPT_INT,
1130 .cb = str_cpumask_cb,
1131 .help = "CPU affinity mask",
1132 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001133 {
1134 .name = "cpus_allowed",
1135 .type = FIO_OPT_STR,
1136 .cb = str_cpus_allowed_cb,
1137 .help = "Set CPUs allowed",
1138 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001139#endif
1140 {
1141 .name = "end_fsync",
1142 .type = FIO_OPT_BOOL,
1143 .off1 = td_var_offset(end_fsync),
1144 .help = "Include fsync at the end of job",
1145 .def = "0",
1146 },
1147 {
1148 .name = "fsync_on_close",
1149 .type = FIO_OPT_BOOL,
1150 .off1 = td_var_offset(fsync_on_close),
1151 .help = "fsync files on close",
1152 .def = "0",
1153 },
1154 {
1155 .name = "unlink",
1156 .type = FIO_OPT_BOOL,
1157 .off1 = td_var_offset(unlink),
1158 .help = "Unlink created files after job has completed",
1159 .def = "0",
1160 },
1161 {
1162 .name = "exitall",
1163 .type = FIO_OPT_STR_SET,
1164 .cb = str_exitall_cb,
1165 .help = "Terminate all jobs when one exits",
1166 },
1167 {
1168 .name = "stonewall",
1169 .type = FIO_OPT_STR_SET,
1170 .off1 = td_var_offset(stonewall),
1171 .help = "Insert a hard barrier between this job and previous",
1172 },
1173 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001174 .name = "new_group",
1175 .type = FIO_OPT_STR_SET,
1176 .off1 = td_var_offset(new_group),
1177 .help = "Mark the start of a new group (for reporting)",
1178 },
1179 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001180 .name = "thread",
1181 .type = FIO_OPT_STR_SET,
1182 .off1 = td_var_offset(use_thread),
1183 .help = "Use threads instead of forks",
1184 },
1185 {
1186 .name = "write_bw_log",
1187 .type = FIO_OPT_STR_SET,
1188 .off1 = td_var_offset(write_bw_log),
1189 .help = "Write log of bandwidth during run",
1190 },
1191 {
1192 .name = "write_lat_log",
1193 .type = FIO_OPT_STR_SET,
1194 .off1 = td_var_offset(write_lat_log),
1195 .help = "Write log of latency during run",
1196 },
1197 {
1198 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001199 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001200 .off1 = td_var_offset(hugepage_size),
1201 .help = "When using hugepages, specify size of each page",
1202 .def = __stringify(FIO_HUGE_PAGE),
1203 },
1204 {
1205 .name = "group_reporting",
1206 .type = FIO_OPT_STR_SET,
1207 .off1 = td_var_offset(group_reporting),
1208 .help = "Do reporting on a per-group basis",
1209 },
1210 {
Jens Axboee9459e52007-04-17 15:46:32 +02001211 .name = "zero_buffers",
1212 .type = FIO_OPT_STR_SET,
1213 .off1 = td_var_offset(zero_buffers),
1214 .help = "Init IO buffers to all zeroes",
1215 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001216#ifdef FIO_HAVE_DISK_UTIL
1217 {
1218 .name = "disk_util",
1219 .type = FIO_OPT_BOOL,
1220 .off1 = td_var_offset(do_disk_util),
1221 .help = "Log disk utilization stats",
1222 .def = "1",
1223 },
1224#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001225 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001226 .name = NULL,
1227 },
1228};
1229
1230void fio_options_dup_and_init(struct option *long_options)
1231{
1232 struct fio_option *o;
1233 unsigned int i;
1234
1235 options_init(options);
1236
1237 i = 0;
1238 while (long_options[i].name)
1239 i++;
1240
1241 o = &options[0];
1242 while (o->name) {
1243 long_options[i].name = o->name;
1244 long_options[i].val = FIO_GETOPT_JOB;
1245 if (o->type == FIO_OPT_STR_SET)
1246 long_options[i].has_arg = no_argument;
1247 else
1248 long_options[i].has_arg = required_argument;
1249
1250 i++;
1251 o++;
1252 assert(i < FIO_NR_OPTIONS);
1253 }
1254}
1255
1256int fio_option_parse(struct thread_data *td, const char *opt)
1257{
1258 return parse_option(opt, options, td);
1259}
1260
1261int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1262{
1263 return parse_cmd_option(opt, val, options, td);
1264}
1265
1266void fio_fill_default_options(struct thread_data *td)
1267{
1268 fill_default_options(td, options);
1269}
1270
1271int fio_show_option_help(const char *opt)
1272{
1273 return show_cmd_help(options, opt);
1274}
Jens Axboed23bb322007-03-23 15:57:56 +01001275
1276static void __options_mem(struct thread_data *td, int alloc)
1277{
1278 struct thread_options *o = &td->o;
1279 struct fio_option *opt;
1280 char **ptr;
1281 int i;
1282
1283 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1284 if (opt->type != FIO_OPT_STR_STORE)
1285 continue;
1286
1287 ptr = (void *) o + opt->off1;
1288 if (*ptr) {
1289 if (alloc)
1290 *ptr = strdup(*ptr);
1291 else {
1292 free(*ptr);
1293 *ptr = NULL;
1294 }
1295 }
1296 }
1297}
1298
1299/*
1300 * dupe FIO_OPT_STR_STORE options
1301 */
1302void options_mem_dupe(struct thread_data *td)
1303{
1304 __options_mem(td, 1);
1305}
1306
Jens Axboe22d66212007-03-27 20:06:25 +02001307void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001308{
Jens Axboe22d66212007-03-27 20:06:25 +02001309#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001310 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001311#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001312}