blob: 5aad00501c42b124cf9a7198c45aba5769c9baa2 [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 Axboe5921e802008-05-30 15:02:38 +02009#include <fcntl.h>
10#include <sys/types.h>
11#include <sys/stat.h>
Jens Axboe214e1ec2007-03-15 10:48:13 +010012
13#include "fio.h"
14#include "parse.h"
Jens Axboe90059d62007-07-30 09:33:12 +020015#include "fls.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010016
Jens Axboe2dc1bbe2007-03-15 15:01:33 +010017#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010018
19/*
20 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
21 */
22static char *get_opt_postfix(const char *str)
23{
24 char *p = strstr(str, ":");
25
26 if (!p)
27 return NULL;
28
29 p++;
30 strip_blank_front(&p);
31 strip_blank_end(p);
32 return strdup(p);
33}
34
Jens Axboe564ca972007-12-14 12:21:19 +010035static int bs_cmp(const void *p1, const void *p2)
36{
37 const struct bssplit *bsp1 = p1;
38 const struct bssplit *bsp2 = p2;
39
40 return bsp1->perc < bsp2->perc;
41}
42
43static int str_bssplit_cb(void *data, const char *input)
44{
45 struct thread_data *td = data;
46 char *fname, *str, *p;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
49 long long val;
50
51 p = str = strdup(input);
52
53 strip_blank_front(&str);
54 strip_blank_end(str);
55
56 td->o.bssplit_nr = 4;
57 td->o.bssplit = malloc(4 * sizeof(struct bssplit));
58
59 i = 0;
60 max_bs = 0;
61 min_bs = -1;
62 while ((fname = strsep(&str, ":")) != NULL) {
63 char *perc_str;
64
65 if (!strlen(fname))
66 break;
67
68 /*
69 * grow struct buffer, if needed
70 */
71 if (i == td->o.bssplit_nr) {
72 td->o.bssplit_nr <<= 1;
Jens Axboe5ec10ea2008-03-06 15:42:00 +010073 td->o.bssplit = realloc(td->o.bssplit,
74 td->o.bssplit_nr
75 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010076 }
77
78 perc_str = strstr(fname, "/");
79 if (perc_str) {
80 *perc_str = '\0';
81 perc_str++;
82 perc = atoi(perc_str);
83 if (perc > 100)
84 perc = 100;
85 else if (!perc)
86 perc = -1;
87 } else
88 perc = -1;
89
90 if (str_to_decimal(fname, &val, 1)) {
91 log_err("fio: bssplit conversion failed\n");
92 free(td->o.bssplit);
93 return 1;
94 }
95
96 if (val > max_bs)
97 max_bs = val;
98 if (val < min_bs)
99 min_bs = val;
100
101 td->o.bssplit[i].bs = val;
102 td->o.bssplit[i].perc = perc;
103 i++;
104 }
105
106 td->o.bssplit_nr = i;
107
108 /*
109 * Now check if the percentages add up, and how much is missing
110 */
111 perc = perc_missing = 0;
112 for (i = 0; i < td->o.bssplit_nr; i++) {
113 struct bssplit *bsp = &td->o.bssplit[i];
114
115 if (bsp->perc == (unsigned char) -1)
116 perc_missing++;
117 else
118 perc += bsp->perc;
119 }
120
121 if (perc > 100) {
122 log_err("fio: bssplit percentages add to more than 100%%\n");
123 free(td->o.bssplit);
124 return 1;
125 }
126 /*
127 * If values didn't have a percentage set, divide the remains between
128 * them.
129 */
130 if (perc_missing) {
131 for (i = 0; i < td->o.bssplit_nr; i++) {
132 struct bssplit *bsp = &td->o.bssplit[i];
133
134 if (bsp->perc == (unsigned char) -1)
135 bsp->perc = (100 - perc) / perc_missing;
136 }
137 }
138
139 td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
140 td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
141
142 /*
143 * now sort based on percentages, for ease of lookup
144 */
145 qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
146
147 free(p);
148 return 0;
149}
150
Jens Axboe211097b2007-03-22 18:56:45 +0100151static int str_rw_cb(void *data, const char *str)
152{
153 struct thread_data *td = data;
154 char *nr = get_opt_postfix(str);
155
Jens Axboefafdba32007-03-26 10:09:12 +0200156 td->o.ddir_nr = 1;
Jens Axboe211097b2007-03-22 18:56:45 +0100157 if (nr)
158 td->o.ddir_nr = atoi(nr);
159
Jens Axboe211097b2007-03-22 18:56:45 +0100160 return 0;
161}
162
Jens Axboe214e1ec2007-03-15 10:48:13 +0100163static int str_mem_cb(void *data, const char *mem)
164{
165 struct thread_data *td = data;
166
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100167 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100168 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100169 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100170 log_err("fio: mmaphuge:/path/to/file\n");
171 return 1;
172 }
173 }
174
175 return 0;
176}
177
178static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
179{
180 mlock_size = *val;
181 return 0;
182}
183
Jens Axboecb499fc2008-05-28 10:33:32 +0200184static int str_rwmix_read_cb(void *data, unsigned int *val)
185{
186 struct thread_data *td = data;
187
188 td->o.rwmix[DDIR_READ] = *val;
189 td->o.rwmix[DDIR_WRITE] = 100 - *val;
190 return 0;
191}
192
193static int str_rwmix_write_cb(void *data, unsigned int *val)
194{
195 struct thread_data *td = data;
196
197 td->o.rwmix[DDIR_WRITE] = *val;
198 td->o.rwmix[DDIR_READ] = 100 - *val;
199 return 0;
200}
201
Jens Axboe214e1ec2007-03-15 10:48:13 +0100202#ifdef FIO_HAVE_IOPRIO
203static int str_prioclass_cb(void *data, unsigned int *val)
204{
205 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200206 unsigned short mask;
207
208 /*
209 * mask off old class bits, str_prio_cb() may have set a default class
210 */
211 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
212 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100213
214 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100215 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100216 return 0;
217}
218
219static int str_prio_cb(void *data, unsigned int *val)
220{
221 struct thread_data *td = data;
222
223 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200224
225 /*
226 * If no class is set, assume BE
227 */
228 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
229 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
230
Jens Axboeac684782007-11-08 08:29:07 +0100231 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100232 return 0;
233}
234#endif
235
236static int str_exitall_cb(void)
237{
238 exitall_on_terminate = 1;
239 return 0;
240}
241
Jens Axboe214e1ec2007-03-15 10:48:13 +0100242#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100243static int str_cpumask_cb(void *data, unsigned int *val)
244{
245 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200246 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100247
Jens Axboed2e268b2007-06-15 10:33:49 +0200248 CPU_ZERO(&td->o.cpumask);
249
250 for (i = 0; i < sizeof(int) * 8; i++)
251 if ((1 << i) & *val)
252 CPU_SET(*val, &td->o.cpumask);
253
Jens Axboe375b2692007-05-22 09:13:02 +0200254 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100255 return 0;
256}
257
Jens Axboed2e268b2007-06-15 10:33:49 +0200258static int str_cpus_allowed_cb(void *data, const char *input)
259{
260 struct thread_data *td = data;
261 char *cpu, *str, *p;
262
263 CPU_ZERO(&td->o.cpumask);
264
265 p = str = strdup(input);
266
267 strip_blank_front(&str);
268 strip_blank_end(str);
269
270 while ((cpu = strsep(&str, ",")) != NULL) {
271 if (!strlen(cpu))
272 break;
273 CPU_SET(atoi(cpu), &td->o.cpumask);
274 }
275
276 free(p);
277 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200278 return 0;
279}
280#endif
281
Jens Axboe214e1ec2007-03-15 10:48:13 +0100282static int str_fst_cb(void *data, const char *str)
283{
284 struct thread_data *td = data;
285 char *nr = get_opt_postfix(str);
286
287 td->file_service_nr = 1;
288 if (nr)
289 td->file_service_nr = atoi(nr);
290
291 return 0;
292}
293
Jens Axboe921c7662008-03-26 09:17:55 +0100294static int check_dir(struct thread_data *td, char *fname)
295{
296 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200297 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100298
Jens Axboebc838912008-04-07 09:00:54 +0200299 if (td->o.directory) {
300 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200301 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200302 elen = strlen(file);
303 }
304
Jens Axboefcef0b32008-05-26 14:53:24 +0200305 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100306 dir = dirname(file);
307
Jens Axboefcef0b32008-05-26 14:53:24 +0200308#if 0
309 {
310 struct stat sb;
311 /*
312 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
313 * yet, so we can't do this check right here...
314 */
Jens Axboe921c7662008-03-26 09:17:55 +0100315 if (lstat(dir, &sb) < 0) {
316 int ret = errno;
317
318 log_err("fio: %s is not a directory\n", dir);
319 td_verror(td, ret, "lstat");
320 return 1;
321 }
322
323 if (!S_ISDIR(sb.st_mode)) {
324 log_err("fio: %s is not a directory\n", dir);
325 return 1;
326 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200327 }
328#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100329
330 return 0;
331}
332
Jens Axboe214e1ec2007-03-15 10:48:13 +0100333static int str_filename_cb(void *data, const char *input)
334{
335 struct thread_data *td = data;
336 char *fname, *str, *p;
337
338 p = str = strdup(input);
339
340 strip_blank_front(&str);
341 strip_blank_end(str);
342
343 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100344 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100345
346 while ((fname = strsep(&str, ":")) != NULL) {
347 if (!strlen(fname))
348 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100349 if (check_dir(td, fname)) {
350 free(p);
351 return 1;
352 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100354 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100355 }
356
357 free(p);
358 return 0;
359}
360
361static int str_directory_cb(void *data, const char fio_unused *str)
362{
363 struct thread_data *td = data;
364 struct stat sb;
365
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100366 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100367 int ret = errno;
368
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100369 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100370 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100371 return 1;
372 }
373 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100374 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100375 return 1;
376 }
377
378 return 0;
379}
380
381static int str_opendir_cb(void *data, const char fio_unused *str)
382{
383 struct thread_data *td = data;
384
385 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100386 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100387
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100388 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100389}
390
Jens Axboea59e1702007-07-30 08:53:27 +0200391static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200392{
393 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200394
Shawn Lewis546a9142007-07-28 21:11:37 +0200395 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200396 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200397 return 1;
398 }
Jens Axboea59e1702007-07-30 08:53:27 +0200399
400 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200401 return 0;
402}
403
Shawn Lewise28218f2008-01-16 11:01:33 +0100404static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200405{
406 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100407 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200408
Shawn Lewise28218f2008-01-16 11:01:33 +0100409 msb = fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200410 if (msb <= 8)
411 td->o.verify_pattern_bytes = 1;
412 else if (msb <= 16)
413 td->o.verify_pattern_bytes = 2;
414 else if (msb <= 24)
415 td->o.verify_pattern_bytes = 3;
416 else
417 td->o.verify_pattern_bytes = 4;
418
Shawn Lewise28218f2008-01-16 11:01:33 +0100419 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200420 return 0;
421}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100422
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100423static int str_lockfile_cb(void *data, const char *str)
424{
425 struct thread_data *td = data;
426 char *nr = get_opt_postfix(str);
427
428 td->o.lockfile_batch = 1;
429 if (nr)
430 td->o.lockfile_batch = atoi(nr);
431
432 return 0;
433}
434
Jens Axboe214e1ec2007-03-15 10:48:13 +0100435#define __stringify_1(x) #x
436#define __stringify(x) __stringify_1(x)
437
438/*
439 * Map of job/command line options
440 */
441static struct fio_option options[] = {
442 {
443 .name = "description",
444 .type = FIO_OPT_STR_STORE,
445 .off1 = td_var_offset(description),
446 .help = "Text job description",
447 },
448 {
449 .name = "name",
450 .type = FIO_OPT_STR_STORE,
451 .off1 = td_var_offset(name),
452 .help = "Name of this job",
453 },
454 {
455 .name = "directory",
456 .type = FIO_OPT_STR_STORE,
457 .off1 = td_var_offset(directory),
458 .cb = str_directory_cb,
459 .help = "Directory to store files in",
460 },
461 {
462 .name = "filename",
463 .type = FIO_OPT_STR_STORE,
464 .off1 = td_var_offset(filename),
465 .cb = str_filename_cb,
466 .help = "File(s) to use for the workload",
467 },
468 {
Jens Axboe29c13492008-03-01 19:25:20 +0100469 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100470 .type = FIO_OPT_STR,
471 .cb = str_lockfile_cb,
472 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100473 .help = "Lock file when doing IO to it",
474 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100475 .def = "none",
476 .posval = {
477 { .ival = "none",
478 .oval = FILE_LOCK_NONE,
479 .help = "No file locking",
480 },
481 { .ival = "exclusive",
482 .oval = FILE_LOCK_EXCLUSIVE,
483 .help = "Exclusive file lock",
484 },
485 {
486 .ival = "readwrite",
487 .oval = FILE_LOCK_READWRITE,
488 .help = "Read vs write lock",
489 },
490 },
Jens Axboe29c13492008-03-01 19:25:20 +0100491 },
492 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100493 .name = "opendir",
494 .type = FIO_OPT_STR_STORE,
495 .off1 = td_var_offset(opendir),
496 .cb = str_opendir_cb,
497 .help = "Recursively add files from this directory and down",
498 },
499 {
500 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100501 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100502 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100503 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100504 .off1 = td_var_offset(td_ddir),
505 .help = "IO direction",
506 .def = "read",
507 .posval = {
508 { .ival = "read",
509 .oval = TD_DDIR_READ,
510 .help = "Sequential read",
511 },
512 { .ival = "write",
513 .oval = TD_DDIR_WRITE,
514 .help = "Sequential write",
515 },
516 { .ival = "randread",
517 .oval = TD_DDIR_RANDREAD,
518 .help = "Random read",
519 },
520 { .ival = "randwrite",
521 .oval = TD_DDIR_RANDWRITE,
522 .help = "Random write",
523 },
524 { .ival = "rw",
525 .oval = TD_DDIR_RW,
526 .help = "Sequential read and write mix",
527 },
528 { .ival = "randrw",
529 .oval = TD_DDIR_RANDRW,
530 .help = "Random read and write mix"
531 },
532 },
533 },
534 {
535 .name = "ioengine",
536 .type = FIO_OPT_STR_STORE,
537 .off1 = td_var_offset(ioengine),
538 .help = "IO engine to use",
539 .def = "sync",
540 .posval = {
541 { .ival = "sync",
542 .help = "Use read/write",
543 },
gurudas paia31041e2007-10-23 15:12:30 +0200544 { .ival = "psync",
545 .help = "Use pread/pwrite",
546 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100547 { .ival = "vsync",
548 .help = "Use readv/writev",
549 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100550#ifdef FIO_HAVE_LIBAIO
551 { .ival = "libaio",
552 .help = "Linux native asynchronous IO",
553 },
554#endif
555#ifdef FIO_HAVE_POSIXAIO
556 { .ival = "posixaio",
557 .help = "POSIX asynchronous IO",
558 },
559#endif
560 { .ival = "mmap",
561 .help = "Memory mapped IO",
562 },
563#ifdef FIO_HAVE_SPLICE
564 { .ival = "splice",
565 .help = "splice/vmsplice based IO",
566 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200567 { .ival = "netsplice",
568 .help = "splice/vmsplice to/from the network",
569 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100570#endif
571#ifdef FIO_HAVE_SGIO
572 { .ival = "sg",
573 .help = "SCSI generic v3 IO",
574 },
575#endif
576 { .ival = "null",
577 .help = "Testing engine (no data transfer)",
578 },
579 { .ival = "net",
580 .help = "Network IO",
581 },
582#ifdef FIO_HAVE_SYSLET
583 { .ival = "syslet-rw",
584 .help = "syslet enabled async pread/pwrite IO",
585 },
586#endif
587 { .ival = "cpuio",
588 .help = "CPU cycler burner engine",
589 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100590#ifdef FIO_HAVE_GUASI
591 { .ival = "guasi",
592 .help = "GUASI IO engine",
593 },
594#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100595 { .ival = "external",
596 .help = "Load external engine (append name)",
597 },
598 },
599 },
600 {
601 .name = "iodepth",
602 .type = FIO_OPT_INT,
603 .off1 = td_var_offset(iodepth),
604 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100605 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100606 .def = "1",
607 },
608 {
609 .name = "iodepth_batch",
610 .type = FIO_OPT_INT,
611 .off1 = td_var_offset(iodepth_batch),
612 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200613 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100614 .minval = 1,
615 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100616 },
617 {
618 .name = "iodepth_low",
619 .type = FIO_OPT_INT,
620 .off1 = td_var_offset(iodepth_low),
621 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200622 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100623 },
624 {
625 .name = "size",
626 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100627 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200628 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100629 .help = "Total size of device or files",
630 },
631 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100632 .name = "fill_device",
633 .type = FIO_OPT_BOOL,
634 .off1 = td_var_offset(fill_device),
635 .help = "Write until an ENOSPC error occurs",
636 .def = "0",
637 },
638 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100639 .name = "filesize",
640 .type = FIO_OPT_STR_VAL,
641 .off1 = td_var_offset(file_size_low),
642 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200643 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100644 .help = "Size of individual files",
645 },
646 {
Jens Axboe67a10002007-07-31 23:12:16 +0200647 .name = "offset",
648 .alias = "fileoffset",
649 .type = FIO_OPT_STR_VAL,
650 .off1 = td_var_offset(start_offset),
651 .help = "Start IO from this offset",
652 .def = "0",
653 },
654 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100655 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100656 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100657 .type = FIO_OPT_STR_VAL_INT,
658 .off1 = td_var_offset(bs[DDIR_READ]),
659 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200660 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100661 .help = "Block size unit",
662 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200663 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100664 },
665 {
666 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100667 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100668 .type = FIO_OPT_RANGE,
669 .off1 = td_var_offset(min_bs[DDIR_READ]),
670 .off2 = td_var_offset(max_bs[DDIR_READ]),
671 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
672 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200673 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100674 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200675 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100676 },
677 {
Jens Axboe564ca972007-12-14 12:21:19 +0100678 .name = "bssplit",
679 .type = FIO_OPT_STR,
680 .cb = str_bssplit_cb,
681 .help = "Set a specific mix of block sizes",
682 .parent = "rw",
683 },
684 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100685 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100686 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100687 .type = FIO_OPT_STR_SET,
688 .off1 = td_var_offset(bs_unaligned),
689 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200690 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100691 },
692 {
693 .name = "randrepeat",
694 .type = FIO_OPT_BOOL,
695 .off1 = td_var_offset(rand_repeatable),
696 .help = "Use repeatable random IO pattern",
697 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200698 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100699 },
700 {
701 .name = "norandommap",
702 .type = FIO_OPT_STR_SET,
703 .off1 = td_var_offset(norandommap),
704 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200705 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100706 },
707 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100708 .name = "softrandommap",
709 .type = FIO_OPT_BOOL,
710 .off1 = td_var_offset(softrandommap),
711 .help = "Allow randommap to fail and continue witout",
712 .parent = "norandommap",
713 .def = "0",
714 },
715 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100716 .name = "nrfiles",
717 .type = FIO_OPT_INT,
718 .off1 = td_var_offset(nr_files),
719 .help = "Split job workload between this number of files",
720 .def = "1",
721 },
722 {
723 .name = "openfiles",
724 .type = FIO_OPT_INT,
725 .off1 = td_var_offset(open_files),
726 .help = "Number of files to keep open at the same time",
727 },
728 {
729 .name = "file_service_type",
730 .type = FIO_OPT_STR,
731 .cb = str_fst_cb,
732 .off1 = td_var_offset(file_service_type),
733 .help = "How to select which file to service next",
734 .def = "roundrobin",
735 .posval = {
736 { .ival = "random",
737 .oval = FIO_FSERVICE_RANDOM,
738 .help = "Choose a file at random",
739 },
740 { .ival = "roundrobin",
741 .oval = FIO_FSERVICE_RR,
742 .help = "Round robin select files",
743 },
744 },
Jens Axboe67a10002007-07-31 23:12:16 +0200745 .parent = "nrfiles",
746 },
747 {
748 .name = "fadvise_hint",
749 .type = FIO_OPT_BOOL,
750 .off1 = td_var_offset(fadvise_hint),
751 .help = "Use fadvise() to advise the kernel on IO pattern",
752 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100753 },
754 {
755 .name = "fsync",
756 .type = FIO_OPT_INT,
757 .off1 = td_var_offset(fsync_blocks),
758 .help = "Issue fsync for writes every given number of blocks",
759 .def = "0",
760 },
761 {
762 .name = "direct",
763 .type = FIO_OPT_BOOL,
764 .off1 = td_var_offset(odirect),
765 .help = "Use O_DIRECT IO (negates buffered)",
766 .def = "0",
767 },
768 {
769 .name = "buffered",
770 .type = FIO_OPT_BOOL,
771 .off1 = td_var_offset(odirect),
772 .neg = 1,
773 .help = "Use buffered IO (negates direct)",
774 .def = "1",
775 },
776 {
777 .name = "overwrite",
778 .type = FIO_OPT_BOOL,
779 .off1 = td_var_offset(overwrite),
780 .help = "When writing, set whether to overwrite current data",
781 .def = "0",
782 },
783 {
784 .name = "loops",
785 .type = FIO_OPT_INT,
786 .off1 = td_var_offset(loops),
787 .help = "Number of times to run the job",
788 .def = "1",
789 },
790 {
791 .name = "numjobs",
792 .type = FIO_OPT_INT,
793 .off1 = td_var_offset(numjobs),
794 .help = "Duplicate this job this many times",
795 .def = "1",
796 },
797 {
798 .name = "startdelay",
799 .type = FIO_OPT_INT,
800 .off1 = td_var_offset(start_delay),
801 .help = "Only start job when this period has passed",
802 .def = "0",
803 },
804 {
805 .name = "runtime",
806 .alias = "timeout",
807 .type = FIO_OPT_STR_VAL_TIME,
808 .off1 = td_var_offset(timeout),
809 .help = "Stop workload when this amount of time has passed",
810 .def = "0",
811 },
812 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200813 .name = "time_based",
814 .type = FIO_OPT_STR_SET,
815 .off1 = td_var_offset(time_based),
816 .help = "Keep running until runtime/timeout is met",
817 },
818 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100819 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100820 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100821 .type = FIO_OPT_STR,
822 .cb = str_mem_cb,
823 .off1 = td_var_offset(mem_type),
824 .help = "Backing type for IO buffers",
825 .def = "malloc",
826 .posval = {
827 { .ival = "malloc",
828 .oval = MEM_MALLOC,
829 .help = "Use malloc(3) for IO buffers",
830 },
Jens Axboeb370e462007-03-19 10:51:49 +0100831 { .ival = "shm",
832 .oval = MEM_SHM,
833 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100834 },
835#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100836 { .ival = "shmhuge",
837 .oval = MEM_SHMHUGE,
838 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100839 },
840#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100841 { .ival = "mmap",
842 .oval = MEM_MMAP,
843 .help = "Use mmap(2) (file or anon) for IO buffers",
844 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100845#ifdef FIO_HAVE_HUGETLB
846 { .ival = "mmaphuge",
847 .oval = MEM_MMAPHUGE,
848 .help = "Like mmap, but use huge pages",
849 },
850#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100851 },
852 },
853 {
854 .name = "verify",
855 .type = FIO_OPT_STR,
856 .off1 = td_var_offset(verify),
857 .help = "Verify data written",
858 .def = "0",
859 .posval = {
860 { .ival = "0",
861 .oval = VERIFY_NONE,
862 .help = "Don't do IO verification",
863 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200864 { .ival = "md5",
865 .oval = VERIFY_MD5,
866 .help = "Use md5 checksums for verification",
867 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200868 { .ival = "crc64",
869 .oval = VERIFY_CRC64,
870 .help = "Use crc64 checksums for verification",
871 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100872 { .ival = "crc32",
873 .oval = VERIFY_CRC32,
874 .help = "Use crc32 checksums for verification",
875 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200876 { .ival = "crc16",
877 .oval = VERIFY_CRC16,
878 .help = "Use crc16 checksums for verification",
879 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200880 { .ival = "crc7",
881 .oval = VERIFY_CRC7,
882 .help = "Use crc7 checksums for verification",
883 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200884 { .ival = "sha256",
885 .oval = VERIFY_SHA256,
886 .help = "Use sha256 checksums for verification",
887 },
888 { .ival = "sha512",
889 .oval = VERIFY_SHA512,
890 .help = "Use sha512 checksums for verification",
891 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200892 { .ival = "meta",
893 .oval = VERIFY_META,
894 .help = "Use io information",
895 },
Jens Axboe36690c92007-03-26 10:23:34 +0200896 {
897 .ival = "null",
898 .oval = VERIFY_NULL,
899 .help = "Pretend to verify",
900 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100901 },
902 },
903 {
Jens Axboe005c5652007-08-02 22:21:36 +0200904 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200905 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200906 .off1 = td_var_offset(do_verify),
907 .help = "Run verification stage after write",
908 .def = "1",
909 .parent = "verify",
910 },
911 {
Jens Axboe160b9662007-03-27 10:59:49 +0200912 .name = "verifysort",
913 .type = FIO_OPT_BOOL,
914 .off1 = td_var_offset(verifysort),
915 .help = "Sort written verify blocks for read back",
916 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200917 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200918 },
919 {
Jens Axboea59e1702007-07-30 08:53:27 +0200920 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200921 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200922 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200923 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200924 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200925 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200926 },
927 {
Jens Axboea59e1702007-07-30 08:53:27 +0200928 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +0200929 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200930 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +0200931 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100932 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +0200933 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +0200934 },
935 {
Shawn Lewise28218f2008-01-16 11:01:33 +0100936 .name = "verify_pattern",
937 .type = FIO_OPT_INT,
938 .cb = str_verify_pattern_cb,
939 .help = "Fill pattern for IO buffers",
940 .parent = "verify",
941 },
942 {
Jens Axboea12a3b42007-08-09 10:20:54 +0200943 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +0200944 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +0200945 .off1 = td_var_offset(verify_fatal),
946 .def = "0",
947 .help = "Exit on a single verify failure, don't continue",
948 .parent = "verify",
949 },
950 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100951 .name = "write_iolog",
952 .type = FIO_OPT_STR_STORE,
953 .off1 = td_var_offset(write_iolog_file),
954 .help = "Store IO pattern to file",
955 },
956 {
957 .name = "read_iolog",
958 .type = FIO_OPT_STR_STORE,
959 .off1 = td_var_offset(read_iolog_file),
960 .help = "Playback IO pattern from file",
961 },
962 {
963 .name = "exec_prerun",
964 .type = FIO_OPT_STR_STORE,
965 .off1 = td_var_offset(exec_prerun),
966 .help = "Execute this file prior to running job",
967 },
968 {
969 .name = "exec_postrun",
970 .type = FIO_OPT_STR_STORE,
971 .off1 = td_var_offset(exec_postrun),
972 .help = "Execute this file after running job",
973 },
974#ifdef FIO_HAVE_IOSCHED_SWITCH
975 {
976 .name = "ioscheduler",
977 .type = FIO_OPT_STR_STORE,
978 .off1 = td_var_offset(ioscheduler),
979 .help = "Use this IO scheduler on the backing device",
980 },
981#endif
982 {
983 .name = "zonesize",
984 .type = FIO_OPT_STR_VAL,
985 .off1 = td_var_offset(zone_size),
986 .help = "Give size of an IO zone",
987 .def = "0",
988 },
989 {
990 .name = "zoneskip",
991 .type = FIO_OPT_STR_VAL,
992 .off1 = td_var_offset(zone_skip),
993 .help = "Space between IO zones",
994 .def = "0",
995 },
996 {
997 .name = "lockmem",
998 .type = FIO_OPT_STR_VAL,
999 .cb = str_lockmem_cb,
1000 .help = "Lock down this amount of memory",
1001 .def = "0",
1002 },
1003 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001004 .name = "rwmixread",
1005 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001006 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001007 .maxval = 100,
1008 .help = "Percentage of mixed workload that is reads",
1009 .def = "50",
1010 },
1011 {
1012 .name = "rwmixwrite",
1013 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001014 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001015 .maxval = 100,
1016 .help = "Percentage of mixed workload that is writes",
1017 .def = "50",
1018 },
1019 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001020 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001021 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001022 },
1023 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001024 .name = "nice",
1025 .type = FIO_OPT_INT,
1026 .off1 = td_var_offset(nice),
1027 .help = "Set job CPU nice value",
1028 .minval = -19,
1029 .maxval = 20,
1030 .def = "0",
1031 },
1032#ifdef FIO_HAVE_IOPRIO
1033 {
1034 .name = "prio",
1035 .type = FIO_OPT_INT,
1036 .cb = str_prio_cb,
1037 .help = "Set job IO priority value",
1038 .minval = 0,
1039 .maxval = 7,
1040 },
1041 {
1042 .name = "prioclass",
1043 .type = FIO_OPT_INT,
1044 .cb = str_prioclass_cb,
1045 .help = "Set job IO priority class",
1046 .minval = 0,
1047 .maxval = 3,
1048 },
1049#endif
1050 {
1051 .name = "thinktime",
1052 .type = FIO_OPT_INT,
1053 .off1 = td_var_offset(thinktime),
1054 .help = "Idle time between IO buffers (usec)",
1055 .def = "0",
1056 },
1057 {
1058 .name = "thinktime_spin",
1059 .type = FIO_OPT_INT,
1060 .off1 = td_var_offset(thinktime_spin),
1061 .help = "Start think time by spinning this amount (usec)",
1062 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001063 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001064 },
1065 {
1066 .name = "thinktime_blocks",
1067 .type = FIO_OPT_INT,
1068 .off1 = td_var_offset(thinktime_blocks),
1069 .help = "IO buffer period between 'thinktime'",
1070 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001071 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001072 },
1073 {
1074 .name = "rate",
1075 .type = FIO_OPT_INT,
1076 .off1 = td_var_offset(rate),
1077 .help = "Set bandwidth rate",
1078 },
1079 {
1080 .name = "ratemin",
1081 .type = FIO_OPT_INT,
1082 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001083 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001084 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001085 },
1086 {
1087 .name = "rate_iops",
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(rate_iops),
1090 .help = "Limit IO used to this number of IO operations/sec",
1091 },
1092 {
1093 .name = "rate_iops_min",
1094 .type = FIO_OPT_INT,
1095 .off1 = td_var_offset(rate_iops_min),
1096 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001097 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001098 },
1099 {
1100 .name = "ratecycle",
1101 .type = FIO_OPT_INT,
1102 .off1 = td_var_offset(ratecycle),
1103 .help = "Window average for rate limits (msec)",
1104 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001105 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001106 },
1107 {
1108 .name = "invalidate",
1109 .type = FIO_OPT_BOOL,
1110 .off1 = td_var_offset(invalidate_cache),
1111 .help = "Invalidate buffer/page cache prior to running job",
1112 .def = "1",
1113 },
1114 {
1115 .name = "sync",
1116 .type = FIO_OPT_BOOL,
1117 .off1 = td_var_offset(sync_io),
1118 .help = "Use O_SYNC for buffered writes",
1119 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001120 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001121 },
1122 {
1123 .name = "bwavgtime",
1124 .type = FIO_OPT_INT,
1125 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001126 .help = "Time window over which to calculate bandwidth"
1127 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001128 .def = "500",
1129 },
1130 {
1131 .name = "create_serialize",
1132 .type = FIO_OPT_BOOL,
1133 .off1 = td_var_offset(create_serialize),
1134 .help = "Serialize creating of job files",
1135 .def = "1",
1136 },
1137 {
1138 .name = "create_fsync",
1139 .type = FIO_OPT_BOOL,
1140 .off1 = td_var_offset(create_fsync),
1141 .help = "Fsync file after creation",
1142 .def = "1",
1143 },
1144 {
1145 .name = "cpuload",
1146 .type = FIO_OPT_INT,
1147 .off1 = td_var_offset(cpuload),
1148 .help = "Use this percentage of CPU",
1149 },
1150 {
1151 .name = "cpuchunks",
1152 .type = FIO_OPT_INT,
1153 .off1 = td_var_offset(cpucycle),
1154 .help = "Length of the CPU burn cycles (usecs)",
1155 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001156 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001157 },
1158#ifdef FIO_HAVE_CPU_AFFINITY
1159 {
1160 .name = "cpumask",
1161 .type = FIO_OPT_INT,
1162 .cb = str_cpumask_cb,
1163 .help = "CPU affinity mask",
1164 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001165 {
1166 .name = "cpus_allowed",
1167 .type = FIO_OPT_STR,
1168 .cb = str_cpus_allowed_cb,
1169 .help = "Set CPUs allowed",
1170 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001171#endif
1172 {
1173 .name = "end_fsync",
1174 .type = FIO_OPT_BOOL,
1175 .off1 = td_var_offset(end_fsync),
1176 .help = "Include fsync at the end of job",
1177 .def = "0",
1178 },
1179 {
1180 .name = "fsync_on_close",
1181 .type = FIO_OPT_BOOL,
1182 .off1 = td_var_offset(fsync_on_close),
1183 .help = "fsync files on close",
1184 .def = "0",
1185 },
1186 {
1187 .name = "unlink",
1188 .type = FIO_OPT_BOOL,
1189 .off1 = td_var_offset(unlink),
1190 .help = "Unlink created files after job has completed",
1191 .def = "0",
1192 },
1193 {
1194 .name = "exitall",
1195 .type = FIO_OPT_STR_SET,
1196 .cb = str_exitall_cb,
1197 .help = "Terminate all jobs when one exits",
1198 },
1199 {
1200 .name = "stonewall",
1201 .type = FIO_OPT_STR_SET,
1202 .off1 = td_var_offset(stonewall),
1203 .help = "Insert a hard barrier between this job and previous",
1204 },
1205 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001206 .name = "new_group",
1207 .type = FIO_OPT_STR_SET,
1208 .off1 = td_var_offset(new_group),
1209 .help = "Mark the start of a new group (for reporting)",
1210 },
1211 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001212 .name = "thread",
1213 .type = FIO_OPT_STR_SET,
1214 .off1 = td_var_offset(use_thread),
1215 .help = "Use threads instead of forks",
1216 },
1217 {
1218 .name = "write_bw_log",
1219 .type = FIO_OPT_STR_SET,
1220 .off1 = td_var_offset(write_bw_log),
1221 .help = "Write log of bandwidth during run",
1222 },
1223 {
1224 .name = "write_lat_log",
1225 .type = FIO_OPT_STR_SET,
1226 .off1 = td_var_offset(write_lat_log),
1227 .help = "Write log of latency during run",
1228 },
1229 {
1230 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001231 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001232 .off1 = td_var_offset(hugepage_size),
1233 .help = "When using hugepages, specify size of each page",
1234 .def = __stringify(FIO_HUGE_PAGE),
1235 },
1236 {
1237 .name = "group_reporting",
1238 .type = FIO_OPT_STR_SET,
1239 .off1 = td_var_offset(group_reporting),
1240 .help = "Do reporting on a per-group basis",
1241 },
1242 {
Jens Axboee9459e52007-04-17 15:46:32 +02001243 .name = "zero_buffers",
1244 .type = FIO_OPT_STR_SET,
1245 .off1 = td_var_offset(zero_buffers),
1246 .help = "Init IO buffers to all zeroes",
1247 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001248 {
1249 .name = "refill_buffers",
1250 .type = FIO_OPT_STR_SET,
1251 .off1 = td_var_offset(refill_buffers),
1252 .help = "Refill IO buffers on every IO submit",
1253 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001254#ifdef FIO_HAVE_DISK_UTIL
1255 {
1256 .name = "disk_util",
1257 .type = FIO_OPT_BOOL,
1258 .off1 = td_var_offset(do_disk_util),
1259 .help = "Log disk utilization stats",
1260 .def = "1",
1261 },
1262#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001263 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001264 .name = NULL,
1265 },
1266};
1267
1268void fio_options_dup_and_init(struct option *long_options)
1269{
1270 struct fio_option *o;
1271 unsigned int i;
1272
1273 options_init(options);
1274
1275 i = 0;
1276 while (long_options[i].name)
1277 i++;
1278
1279 o = &options[0];
1280 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001281 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001282 long_options[i].val = FIO_GETOPT_JOB;
1283 if (o->type == FIO_OPT_STR_SET)
1284 long_options[i].has_arg = no_argument;
1285 else
1286 long_options[i].has_arg = required_argument;
1287
1288 i++;
1289 o++;
1290 assert(i < FIO_NR_OPTIONS);
1291 }
1292}
1293
1294int fio_option_parse(struct thread_data *td, const char *opt)
1295{
1296 return parse_option(opt, options, td);
1297}
1298
1299int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1300{
1301 return parse_cmd_option(opt, val, options, td);
1302}
1303
1304void fio_fill_default_options(struct thread_data *td)
1305{
1306 fill_default_options(td, options);
1307}
1308
1309int fio_show_option_help(const char *opt)
1310{
1311 return show_cmd_help(options, opt);
1312}
Jens Axboed23bb322007-03-23 15:57:56 +01001313
1314static void __options_mem(struct thread_data *td, int alloc)
1315{
1316 struct thread_options *o = &td->o;
1317 struct fio_option *opt;
1318 char **ptr;
1319 int i;
1320
1321 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1322 if (opt->type != FIO_OPT_STR_STORE)
1323 continue;
1324
1325 ptr = (void *) o + opt->off1;
1326 if (*ptr) {
1327 if (alloc)
1328 *ptr = strdup(*ptr);
1329 else {
1330 free(*ptr);
1331 *ptr = NULL;
1332 }
1333 }
1334 }
1335}
1336
1337/*
1338 * dupe FIO_OPT_STR_STORE options
1339 */
1340void options_mem_dupe(struct thread_data *td)
1341{
1342 __options_mem(td, 1);
1343}
1344
Jens Axboe22d66212007-03-27 20:06:25 +02001345void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001346{
Jens Axboe22d66212007-03-27 20:06:25 +02001347#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001348 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001349#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001350}