blob: 3d27f2551d6b55ab76fd3c93c71036c138e3bbe6 [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 Axboeeef32352008-06-02 13:31:26 +020015#include "lib/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 Axboe182ec6e2008-11-14 13:06:06 +0100157 if (nr) {
Jens Axboe211097b2007-03-22 18:56:45 +0100158 td->o.ddir_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100159 free(nr);
160 }
Jens Axboe211097b2007-03-22 18:56:45 +0100161
Jens Axboe211097b2007-03-22 18:56:45 +0100162 return 0;
163}
164
Jens Axboe214e1ec2007-03-15 10:48:13 +0100165static int str_mem_cb(void *data, const char *mem)
166{
167 struct thread_data *td = data;
168
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100169 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100170 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100171 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100172 log_err("fio: mmaphuge:/path/to/file\n");
173 return 1;
174 }
175 }
176
177 return 0;
178}
179
180static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
181{
182 mlock_size = *val;
183 return 0;
184}
185
Jens Axboecb499fc2008-05-28 10:33:32 +0200186static int str_rwmix_read_cb(void *data, unsigned int *val)
187{
188 struct thread_data *td = data;
189
190 td->o.rwmix[DDIR_READ] = *val;
191 td->o.rwmix[DDIR_WRITE] = 100 - *val;
192 return 0;
193}
194
195static int str_rwmix_write_cb(void *data, unsigned int *val)
196{
197 struct thread_data *td = data;
198
199 td->o.rwmix[DDIR_WRITE] = *val;
200 td->o.rwmix[DDIR_READ] = 100 - *val;
201 return 0;
202}
203
Jens Axboe214e1ec2007-03-15 10:48:13 +0100204#ifdef FIO_HAVE_IOPRIO
205static int str_prioclass_cb(void *data, unsigned int *val)
206{
207 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200208 unsigned short mask;
209
210 /*
211 * mask off old class bits, str_prio_cb() may have set a default class
212 */
213 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
214 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100215
216 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100217 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100218 return 0;
219}
220
221static int str_prio_cb(void *data, unsigned int *val)
222{
223 struct thread_data *td = data;
224
225 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200226
227 /*
228 * If no class is set, assume BE
229 */
230 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
231 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
232
Jens Axboeac684782007-11-08 08:29:07 +0100233 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100234 return 0;
235}
236#endif
237
238static int str_exitall_cb(void)
239{
240 exitall_on_terminate = 1;
241 return 0;
242}
243
Jens Axboe214e1ec2007-03-15 10:48:13 +0100244#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100245static int str_cpumask_cb(void *data, unsigned int *val)
246{
247 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200248 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100249
Jens Axboed2e268b2007-06-15 10:33:49 +0200250 CPU_ZERO(&td->o.cpumask);
251
252 for (i = 0; i < sizeof(int) * 8; i++)
253 if ((1 << i) & *val)
254 CPU_SET(*val, &td->o.cpumask);
255
Jens Axboe375b2692007-05-22 09:13:02 +0200256 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100257 return 0;
258}
259
Jens Axboed2e268b2007-06-15 10:33:49 +0200260static int str_cpus_allowed_cb(void *data, const char *input)
261{
262 struct thread_data *td = data;
263 char *cpu, *str, *p;
264
265 CPU_ZERO(&td->o.cpumask);
266
267 p = str = strdup(input);
268
269 strip_blank_front(&str);
270 strip_blank_end(str);
271
272 while ((cpu = strsep(&str, ",")) != NULL) {
273 if (!strlen(cpu))
274 break;
275 CPU_SET(atoi(cpu), &td->o.cpumask);
276 }
277
278 free(p);
279 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200280 return 0;
281}
282#endif
283
Jens Axboe214e1ec2007-03-15 10:48:13 +0100284static int str_fst_cb(void *data, const char *str)
285{
286 struct thread_data *td = data;
287 char *nr = get_opt_postfix(str);
288
289 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100290 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100291 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100292 free(nr);
293 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100294
295 return 0;
296}
297
Jens Axboe921c7662008-03-26 09:17:55 +0100298static int check_dir(struct thread_data *td, char *fname)
299{
300 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200301 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100302
Jens Axboebc838912008-04-07 09:00:54 +0200303 if (td->o.directory) {
304 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200305 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200306 elen = strlen(file);
307 }
308
Jens Axboefcef0b32008-05-26 14:53:24 +0200309 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100310 dir = dirname(file);
311
Jens Axboefcef0b32008-05-26 14:53:24 +0200312#if 0
313 {
314 struct stat sb;
315 /*
316 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
317 * yet, so we can't do this check right here...
318 */
Jens Axboe921c7662008-03-26 09:17:55 +0100319 if (lstat(dir, &sb) < 0) {
320 int ret = errno;
321
322 log_err("fio: %s is not a directory\n", dir);
323 td_verror(td, ret, "lstat");
324 return 1;
325 }
326
327 if (!S_ISDIR(sb.st_mode)) {
328 log_err("fio: %s is not a directory\n", dir);
329 return 1;
330 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200331 }
332#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100333
334 return 0;
335}
336
Jens Axboe214e1ec2007-03-15 10:48:13 +0100337static int str_filename_cb(void *data, const char *input)
338{
339 struct thread_data *td = data;
340 char *fname, *str, *p;
341
342 p = str = strdup(input);
343
344 strip_blank_front(&str);
345 strip_blank_end(str);
346
347 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100348 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100349
350 while ((fname = strsep(&str, ":")) != NULL) {
351 if (!strlen(fname))
352 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100353 if (check_dir(td, fname)) {
354 free(p);
355 return 1;
356 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100357 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100358 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100359 }
360
361 free(p);
362 return 0;
363}
364
365static int str_directory_cb(void *data, const char fio_unused *str)
366{
367 struct thread_data *td = data;
368 struct stat sb;
369
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100370 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100371 int ret = errno;
372
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100373 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100374 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100375 return 1;
376 }
377 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100378 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100379 return 1;
380 }
381
382 return 0;
383}
384
385static int str_opendir_cb(void *data, const char fio_unused *str)
386{
387 struct thread_data *td = data;
388
389 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100390 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100391
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100392 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100393}
394
Jens Axboea59e1702007-07-30 08:53:27 +0200395static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200396{
397 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200398
Shawn Lewis546a9142007-07-28 21:11:37 +0200399 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200400 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200401 return 1;
402 }
Jens Axboea59e1702007-07-30 08:53:27 +0200403
404 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200405 return 0;
406}
407
Shawn Lewise28218f2008-01-16 11:01:33 +0100408static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200409{
410 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100411 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200412
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200413 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200414 if (msb <= 8)
415 td->o.verify_pattern_bytes = 1;
416 else if (msb <= 16)
417 td->o.verify_pattern_bytes = 2;
418 else if (msb <= 24)
419 td->o.verify_pattern_bytes = 3;
420 else
421 td->o.verify_pattern_bytes = 4;
422
Shawn Lewise28218f2008-01-16 11:01:33 +0100423 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200424 return 0;
425}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100426
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100427static int str_lockfile_cb(void *data, const char *str)
428{
429 struct thread_data *td = data;
430 char *nr = get_opt_postfix(str);
431
432 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100433 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100434 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100435 free(nr);
436 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100437
438 return 0;
439}
440
Jens Axboe993bf482008-11-14 13:04:53 +0100441static int str_gtod_reduce_cb(void *data, int *il)
442{
443 struct thread_data *td = data;
444 int val = *il;
445
446 td->o.disable_clat = !!val;
447 td->o.disable_slat = !!val;
448 td->o.disable_bw = !!val;
449 if (val)
450 td->tv_cache_mask = 63;
451
452 return 0;
453}
454
Jens Axboe214e1ec2007-03-15 10:48:13 +0100455#define __stringify_1(x) #x
456#define __stringify(x) __stringify_1(x)
457
458/*
459 * Map of job/command line options
460 */
461static struct fio_option options[] = {
462 {
463 .name = "description",
464 .type = FIO_OPT_STR_STORE,
465 .off1 = td_var_offset(description),
466 .help = "Text job description",
467 },
468 {
469 .name = "name",
470 .type = FIO_OPT_STR_STORE,
471 .off1 = td_var_offset(name),
472 .help = "Name of this job",
473 },
474 {
475 .name = "directory",
476 .type = FIO_OPT_STR_STORE,
477 .off1 = td_var_offset(directory),
478 .cb = str_directory_cb,
479 .help = "Directory to store files in",
480 },
481 {
482 .name = "filename",
483 .type = FIO_OPT_STR_STORE,
484 .off1 = td_var_offset(filename),
485 .cb = str_filename_cb,
Jens Axboe3b8b7132008-06-10 19:46:23 +0200486 .prio = 1, /* must come before "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100487 .help = "File(s) to use for the workload",
488 },
489 {
Jens Axboe29c13492008-03-01 19:25:20 +0100490 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100491 .type = FIO_OPT_STR,
492 .cb = str_lockfile_cb,
493 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100494 .help = "Lock file when doing IO to it",
495 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100496 .def = "none",
497 .posval = {
498 { .ival = "none",
499 .oval = FILE_LOCK_NONE,
500 .help = "No file locking",
501 },
502 { .ival = "exclusive",
503 .oval = FILE_LOCK_EXCLUSIVE,
504 .help = "Exclusive file lock",
505 },
506 {
507 .ival = "readwrite",
508 .oval = FILE_LOCK_READWRITE,
509 .help = "Read vs write lock",
510 },
511 },
Jens Axboe29c13492008-03-01 19:25:20 +0100512 },
513 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100514 .name = "opendir",
515 .type = FIO_OPT_STR_STORE,
516 .off1 = td_var_offset(opendir),
517 .cb = str_opendir_cb,
518 .help = "Recursively add files from this directory and down",
519 },
520 {
521 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100522 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100523 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100524 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100525 .off1 = td_var_offset(td_ddir),
526 .help = "IO direction",
527 .def = "read",
528 .posval = {
529 { .ival = "read",
530 .oval = TD_DDIR_READ,
531 .help = "Sequential read",
532 },
533 { .ival = "write",
534 .oval = TD_DDIR_WRITE,
535 .help = "Sequential write",
536 },
537 { .ival = "randread",
538 .oval = TD_DDIR_RANDREAD,
539 .help = "Random read",
540 },
541 { .ival = "randwrite",
542 .oval = TD_DDIR_RANDWRITE,
543 .help = "Random write",
544 },
545 { .ival = "rw",
546 .oval = TD_DDIR_RW,
547 .help = "Sequential read and write mix",
548 },
549 { .ival = "randrw",
550 .oval = TD_DDIR_RANDRW,
551 .help = "Random read and write mix"
552 },
553 },
554 },
555 {
556 .name = "ioengine",
557 .type = FIO_OPT_STR_STORE,
558 .off1 = td_var_offset(ioengine),
559 .help = "IO engine to use",
560 .def = "sync",
561 .posval = {
562 { .ival = "sync",
563 .help = "Use read/write",
564 },
gurudas paia31041e2007-10-23 15:12:30 +0200565 { .ival = "psync",
566 .help = "Use pread/pwrite",
567 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100568 { .ival = "vsync",
569 .help = "Use readv/writev",
570 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100571#ifdef FIO_HAVE_LIBAIO
572 { .ival = "libaio",
573 .help = "Linux native asynchronous IO",
574 },
575#endif
576#ifdef FIO_HAVE_POSIXAIO
577 { .ival = "posixaio",
578 .help = "POSIX asynchronous IO",
579 },
580#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200581#ifdef FIO_HAVE_SOLARISAIO
582 { .ival = "solarisaio",
583 .help = "Solaris native asynchronous IO",
584 },
585#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100586 { .ival = "mmap",
587 .help = "Memory mapped IO",
588 },
589#ifdef FIO_HAVE_SPLICE
590 { .ival = "splice",
591 .help = "splice/vmsplice based IO",
592 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200593 { .ival = "netsplice",
594 .help = "splice/vmsplice to/from the network",
595 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100596#endif
597#ifdef FIO_HAVE_SGIO
598 { .ival = "sg",
599 .help = "SCSI generic v3 IO",
600 },
601#endif
602 { .ival = "null",
603 .help = "Testing engine (no data transfer)",
604 },
605 { .ival = "net",
606 .help = "Network IO",
607 },
608#ifdef FIO_HAVE_SYSLET
609 { .ival = "syslet-rw",
610 .help = "syslet enabled async pread/pwrite IO",
611 },
612#endif
613 { .ival = "cpuio",
614 .help = "CPU cycler burner engine",
615 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100616#ifdef FIO_HAVE_GUASI
617 { .ival = "guasi",
618 .help = "GUASI IO engine",
619 },
620#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100621 { .ival = "external",
622 .help = "Load external engine (append name)",
623 },
624 },
625 },
626 {
627 .name = "iodepth",
628 .type = FIO_OPT_INT,
629 .off1 = td_var_offset(iodepth),
630 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100631 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100632 .def = "1",
633 },
634 {
635 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200636 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100637 .type = FIO_OPT_INT,
638 .off1 = td_var_offset(iodepth_batch),
639 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200640 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100641 .minval = 1,
642 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100643 },
644 {
Jens Axboe49504212008-06-05 09:03:30 +0200645 .name = "iodepth_batch_complete",
646 .type = FIO_OPT_INT,
647 .off1 = td_var_offset(iodepth_batch_complete),
648 .help = "Number of IO to retrieve in one go",
649 .parent = "iodepth",
650 .minval = 0,
651 .def = "1",
652 },
653 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100654 .name = "iodepth_low",
655 .type = FIO_OPT_INT,
656 .off1 = td_var_offset(iodepth_low),
657 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200658 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100659 },
660 {
661 .name = "size",
662 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100663 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200664 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100665 .help = "Total size of device or files",
666 },
667 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100668 .name = "fill_device",
669 .type = FIO_OPT_BOOL,
670 .off1 = td_var_offset(fill_device),
671 .help = "Write until an ENOSPC error occurs",
672 .def = "0",
673 },
674 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100675 .name = "filesize",
676 .type = FIO_OPT_STR_VAL,
677 .off1 = td_var_offset(file_size_low),
678 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200679 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100680 .help = "Size of individual files",
681 },
682 {
Jens Axboe67a10002007-07-31 23:12:16 +0200683 .name = "offset",
684 .alias = "fileoffset",
685 .type = FIO_OPT_STR_VAL,
686 .off1 = td_var_offset(start_offset),
687 .help = "Start IO from this offset",
688 .def = "0",
689 },
690 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100691 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100692 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100693 .type = FIO_OPT_STR_VAL_INT,
694 .off1 = td_var_offset(bs[DDIR_READ]),
695 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200696 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100697 .help = "Block size unit",
698 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200699 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100700 },
701 {
702 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100703 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100704 .type = FIO_OPT_RANGE,
705 .off1 = td_var_offset(min_bs[DDIR_READ]),
706 .off2 = td_var_offset(max_bs[DDIR_READ]),
707 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
708 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200709 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100710 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200711 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100712 },
713 {
Jens Axboe564ca972007-12-14 12:21:19 +0100714 .name = "bssplit",
715 .type = FIO_OPT_STR,
716 .cb = str_bssplit_cb,
717 .help = "Set a specific mix of block sizes",
718 .parent = "rw",
719 },
720 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100721 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100722 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100723 .type = FIO_OPT_STR_SET,
724 .off1 = td_var_offset(bs_unaligned),
725 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200726 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100727 },
728 {
729 .name = "randrepeat",
730 .type = FIO_OPT_BOOL,
731 .off1 = td_var_offset(rand_repeatable),
732 .help = "Use repeatable random IO pattern",
733 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200734 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100735 },
736 {
737 .name = "norandommap",
738 .type = FIO_OPT_STR_SET,
739 .off1 = td_var_offset(norandommap),
740 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200741 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100742 },
743 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100744 .name = "softrandommap",
745 .type = FIO_OPT_BOOL,
746 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200747 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100748 .parent = "norandommap",
749 .def = "0",
750 },
751 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100752 .name = "nrfiles",
753 .type = FIO_OPT_INT,
754 .off1 = td_var_offset(nr_files),
755 .help = "Split job workload between this number of files",
756 .def = "1",
757 },
758 {
759 .name = "openfiles",
760 .type = FIO_OPT_INT,
761 .off1 = td_var_offset(open_files),
762 .help = "Number of files to keep open at the same time",
763 },
764 {
765 .name = "file_service_type",
766 .type = FIO_OPT_STR,
767 .cb = str_fst_cb,
768 .off1 = td_var_offset(file_service_type),
769 .help = "How to select which file to service next",
770 .def = "roundrobin",
771 .posval = {
772 { .ival = "random",
773 .oval = FIO_FSERVICE_RANDOM,
774 .help = "Choose a file at random",
775 },
776 { .ival = "roundrobin",
777 .oval = FIO_FSERVICE_RR,
778 .help = "Round robin select files",
779 },
780 },
Jens Axboe67a10002007-07-31 23:12:16 +0200781 .parent = "nrfiles",
782 },
783 {
784 .name = "fadvise_hint",
785 .type = FIO_OPT_BOOL,
786 .off1 = td_var_offset(fadvise_hint),
787 .help = "Use fadvise() to advise the kernel on IO pattern",
788 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100789 },
790 {
791 .name = "fsync",
792 .type = FIO_OPT_INT,
793 .off1 = td_var_offset(fsync_blocks),
794 .help = "Issue fsync for writes every given number of blocks",
795 .def = "0",
796 },
797 {
798 .name = "direct",
799 .type = FIO_OPT_BOOL,
800 .off1 = td_var_offset(odirect),
801 .help = "Use O_DIRECT IO (negates buffered)",
802 .def = "0",
803 },
804 {
805 .name = "buffered",
806 .type = FIO_OPT_BOOL,
807 .off1 = td_var_offset(odirect),
808 .neg = 1,
809 .help = "Use buffered IO (negates direct)",
810 .def = "1",
811 },
812 {
813 .name = "overwrite",
814 .type = FIO_OPT_BOOL,
815 .off1 = td_var_offset(overwrite),
816 .help = "When writing, set whether to overwrite current data",
817 .def = "0",
818 },
819 {
820 .name = "loops",
821 .type = FIO_OPT_INT,
822 .off1 = td_var_offset(loops),
823 .help = "Number of times to run the job",
824 .def = "1",
825 },
826 {
827 .name = "numjobs",
828 .type = FIO_OPT_INT,
829 .off1 = td_var_offset(numjobs),
830 .help = "Duplicate this job this many times",
831 .def = "1",
832 },
833 {
834 .name = "startdelay",
835 .type = FIO_OPT_INT,
836 .off1 = td_var_offset(start_delay),
837 .help = "Only start job when this period has passed",
838 .def = "0",
839 },
840 {
841 .name = "runtime",
842 .alias = "timeout",
843 .type = FIO_OPT_STR_VAL_TIME,
844 .off1 = td_var_offset(timeout),
845 .help = "Stop workload when this amount of time has passed",
846 .def = "0",
847 },
848 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200849 .name = "time_based",
850 .type = FIO_OPT_STR_SET,
851 .off1 = td_var_offset(time_based),
852 .help = "Keep running until runtime/timeout is met",
853 },
854 {
Jens Axboe721938a2008-09-10 09:46:16 +0200855 .name = "ramp_time",
856 .type = FIO_OPT_STR_VAL_TIME,
857 .off1 = td_var_offset(ramp_time),
858 .help = "Ramp up time before measuring performance",
859 },
860 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100861 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100862 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100863 .type = FIO_OPT_STR,
864 .cb = str_mem_cb,
865 .off1 = td_var_offset(mem_type),
866 .help = "Backing type for IO buffers",
867 .def = "malloc",
868 .posval = {
869 { .ival = "malloc",
870 .oval = MEM_MALLOC,
871 .help = "Use malloc(3) for IO buffers",
872 },
Jens Axboeb370e462007-03-19 10:51:49 +0100873 { .ival = "shm",
874 .oval = MEM_SHM,
875 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100876 },
877#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100878 { .ival = "shmhuge",
879 .oval = MEM_SHMHUGE,
880 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100881 },
882#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100883 { .ival = "mmap",
884 .oval = MEM_MMAP,
885 .help = "Use mmap(2) (file or anon) for IO buffers",
886 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100887#ifdef FIO_HAVE_HUGETLB
888 { .ival = "mmaphuge",
889 .oval = MEM_MMAPHUGE,
890 .help = "Like mmap, but use huge pages",
891 },
892#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100893 },
894 },
895 {
896 .name = "verify",
897 .type = FIO_OPT_STR,
898 .off1 = td_var_offset(verify),
899 .help = "Verify data written",
900 .def = "0",
901 .posval = {
902 { .ival = "0",
903 .oval = VERIFY_NONE,
904 .help = "Don't do IO verification",
905 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200906 { .ival = "md5",
907 .oval = VERIFY_MD5,
908 .help = "Use md5 checksums for verification",
909 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200910 { .ival = "crc64",
911 .oval = VERIFY_CRC64,
912 .help = "Use crc64 checksums for verification",
913 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100914 { .ival = "crc32",
915 .oval = VERIFY_CRC32,
916 .help = "Use crc32 checksums for verification",
917 },
Jens Axboeaf497e62008-08-04 15:40:35 +0200918 { .ival = "crc32c-intel",
919 .oval = VERIFY_CRC32C_INTEL,
920 .help = "Use hw crc32c checksums for verification",
921 },
Jens Axboebac39e02008-06-11 20:46:19 +0200922 { .ival = "crc32c",
923 .oval = VERIFY_CRC32C,
924 .help = "Use crc32c checksums for verification",
925 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200926 { .ival = "crc16",
927 .oval = VERIFY_CRC16,
928 .help = "Use crc16 checksums for verification",
929 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200930 { .ival = "crc7",
931 .oval = VERIFY_CRC7,
932 .help = "Use crc7 checksums for verification",
933 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200934 { .ival = "sha256",
935 .oval = VERIFY_SHA256,
936 .help = "Use sha256 checksums for verification",
937 },
938 { .ival = "sha512",
939 .oval = VERIFY_SHA512,
940 .help = "Use sha512 checksums for verification",
941 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200942 { .ival = "meta",
943 .oval = VERIFY_META,
944 .help = "Use io information",
945 },
Jens Axboe36690c92007-03-26 10:23:34 +0200946 {
947 .ival = "null",
948 .oval = VERIFY_NULL,
949 .help = "Pretend to verify",
950 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100951 },
952 },
953 {
Jens Axboe005c5652007-08-02 22:21:36 +0200954 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200955 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200956 .off1 = td_var_offset(do_verify),
957 .help = "Run verification stage after write",
958 .def = "1",
959 .parent = "verify",
960 },
961 {
Jens Axboe160b9662007-03-27 10:59:49 +0200962 .name = "verifysort",
963 .type = FIO_OPT_BOOL,
964 .off1 = td_var_offset(verifysort),
965 .help = "Sort written verify blocks for read back",
966 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200967 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200968 },
969 {
Jens Axboea59e1702007-07-30 08:53:27 +0200970 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200971 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200972 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200973 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200974 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200975 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200976 },
977 {
Jens Axboea59e1702007-07-30 08:53:27 +0200978 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +0200979 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200980 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +0200981 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100982 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +0200983 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +0200984 },
985 {
Shawn Lewise28218f2008-01-16 11:01:33 +0100986 .name = "verify_pattern",
987 .type = FIO_OPT_INT,
988 .cb = str_verify_pattern_cb,
989 .help = "Fill pattern for IO buffers",
990 .parent = "verify",
991 },
992 {
Jens Axboea12a3b42007-08-09 10:20:54 +0200993 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +0200994 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +0200995 .off1 = td_var_offset(verify_fatal),
996 .def = "0",
997 .help = "Exit on a single verify failure, don't continue",
998 .parent = "verify",
999 },
1000 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001001 .name = "write_iolog",
1002 .type = FIO_OPT_STR_STORE,
1003 .off1 = td_var_offset(write_iolog_file),
1004 .help = "Store IO pattern to file",
1005 },
1006 {
1007 .name = "read_iolog",
1008 .type = FIO_OPT_STR_STORE,
1009 .off1 = td_var_offset(read_iolog_file),
1010 .help = "Playback IO pattern from file",
1011 },
1012 {
1013 .name = "exec_prerun",
1014 .type = FIO_OPT_STR_STORE,
1015 .off1 = td_var_offset(exec_prerun),
1016 .help = "Execute this file prior to running job",
1017 },
1018 {
1019 .name = "exec_postrun",
1020 .type = FIO_OPT_STR_STORE,
1021 .off1 = td_var_offset(exec_postrun),
1022 .help = "Execute this file after running job",
1023 },
1024#ifdef FIO_HAVE_IOSCHED_SWITCH
1025 {
1026 .name = "ioscheduler",
1027 .type = FIO_OPT_STR_STORE,
1028 .off1 = td_var_offset(ioscheduler),
1029 .help = "Use this IO scheduler on the backing device",
1030 },
1031#endif
1032 {
1033 .name = "zonesize",
1034 .type = FIO_OPT_STR_VAL,
1035 .off1 = td_var_offset(zone_size),
1036 .help = "Give size of an IO zone",
1037 .def = "0",
1038 },
1039 {
1040 .name = "zoneskip",
1041 .type = FIO_OPT_STR_VAL,
1042 .off1 = td_var_offset(zone_skip),
1043 .help = "Space between IO zones",
1044 .def = "0",
1045 },
1046 {
1047 .name = "lockmem",
1048 .type = FIO_OPT_STR_VAL,
1049 .cb = str_lockmem_cb,
1050 .help = "Lock down this amount of memory",
1051 .def = "0",
1052 },
1053 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001054 .name = "rwmixread",
1055 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001056 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001057 .maxval = 100,
1058 .help = "Percentage of mixed workload that is reads",
1059 .def = "50",
1060 },
1061 {
1062 .name = "rwmixwrite",
1063 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001064 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001065 .maxval = 100,
1066 .help = "Percentage of mixed workload that is writes",
1067 .def = "50",
1068 },
1069 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001070 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001071 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001072 },
1073 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001074 .name = "nice",
1075 .type = FIO_OPT_INT,
1076 .off1 = td_var_offset(nice),
1077 .help = "Set job CPU nice value",
1078 .minval = -19,
1079 .maxval = 20,
1080 .def = "0",
1081 },
1082#ifdef FIO_HAVE_IOPRIO
1083 {
1084 .name = "prio",
1085 .type = FIO_OPT_INT,
1086 .cb = str_prio_cb,
1087 .help = "Set job IO priority value",
1088 .minval = 0,
1089 .maxval = 7,
1090 },
1091 {
1092 .name = "prioclass",
1093 .type = FIO_OPT_INT,
1094 .cb = str_prioclass_cb,
1095 .help = "Set job IO priority class",
1096 .minval = 0,
1097 .maxval = 3,
1098 },
1099#endif
1100 {
1101 .name = "thinktime",
1102 .type = FIO_OPT_INT,
1103 .off1 = td_var_offset(thinktime),
1104 .help = "Idle time between IO buffers (usec)",
1105 .def = "0",
1106 },
1107 {
1108 .name = "thinktime_spin",
1109 .type = FIO_OPT_INT,
1110 .off1 = td_var_offset(thinktime_spin),
1111 .help = "Start think time by spinning this amount (usec)",
1112 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001113 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001114 },
1115 {
1116 .name = "thinktime_blocks",
1117 .type = FIO_OPT_INT,
1118 .off1 = td_var_offset(thinktime_blocks),
1119 .help = "IO buffer period between 'thinktime'",
1120 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001121 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001122 },
1123 {
1124 .name = "rate",
1125 .type = FIO_OPT_INT,
1126 .off1 = td_var_offset(rate),
1127 .help = "Set bandwidth rate",
1128 },
1129 {
1130 .name = "ratemin",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001133 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001134 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001135 },
1136 {
1137 .name = "rate_iops",
1138 .type = FIO_OPT_INT,
1139 .off1 = td_var_offset(rate_iops),
1140 .help = "Limit IO used to this number of IO operations/sec",
1141 },
1142 {
1143 .name = "rate_iops_min",
1144 .type = FIO_OPT_INT,
1145 .off1 = td_var_offset(rate_iops_min),
1146 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001147 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001148 },
1149 {
1150 .name = "ratecycle",
1151 .type = FIO_OPT_INT,
1152 .off1 = td_var_offset(ratecycle),
1153 .help = "Window average for rate limits (msec)",
1154 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001155 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001156 },
1157 {
1158 .name = "invalidate",
1159 .type = FIO_OPT_BOOL,
1160 .off1 = td_var_offset(invalidate_cache),
1161 .help = "Invalidate buffer/page cache prior to running job",
1162 .def = "1",
1163 },
1164 {
1165 .name = "sync",
1166 .type = FIO_OPT_BOOL,
1167 .off1 = td_var_offset(sync_io),
1168 .help = "Use O_SYNC for buffered writes",
1169 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001170 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001171 },
1172 {
1173 .name = "bwavgtime",
1174 .type = FIO_OPT_INT,
1175 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001176 .help = "Time window over which to calculate bandwidth"
1177 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001178 .def = "500",
1179 },
1180 {
1181 .name = "create_serialize",
1182 .type = FIO_OPT_BOOL,
1183 .off1 = td_var_offset(create_serialize),
1184 .help = "Serialize creating of job files",
1185 .def = "1",
1186 },
1187 {
1188 .name = "create_fsync",
1189 .type = FIO_OPT_BOOL,
1190 .off1 = td_var_offset(create_fsync),
1191 .help = "Fsync file after creation",
1192 .def = "1",
1193 },
1194 {
1195 .name = "cpuload",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(cpuload),
1198 .help = "Use this percentage of CPU",
1199 },
1200 {
1201 .name = "cpuchunks",
1202 .type = FIO_OPT_INT,
1203 .off1 = td_var_offset(cpucycle),
1204 .help = "Length of the CPU burn cycles (usecs)",
1205 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001206 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001207 },
1208#ifdef FIO_HAVE_CPU_AFFINITY
1209 {
1210 .name = "cpumask",
1211 .type = FIO_OPT_INT,
1212 .cb = str_cpumask_cb,
1213 .help = "CPU affinity mask",
1214 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001215 {
1216 .name = "cpus_allowed",
1217 .type = FIO_OPT_STR,
1218 .cb = str_cpus_allowed_cb,
1219 .help = "Set CPUs allowed",
1220 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001221#endif
1222 {
1223 .name = "end_fsync",
1224 .type = FIO_OPT_BOOL,
1225 .off1 = td_var_offset(end_fsync),
1226 .help = "Include fsync at the end of job",
1227 .def = "0",
1228 },
1229 {
1230 .name = "fsync_on_close",
1231 .type = FIO_OPT_BOOL,
1232 .off1 = td_var_offset(fsync_on_close),
1233 .help = "fsync files on close",
1234 .def = "0",
1235 },
1236 {
1237 .name = "unlink",
1238 .type = FIO_OPT_BOOL,
1239 .off1 = td_var_offset(unlink),
1240 .help = "Unlink created files after job has completed",
1241 .def = "0",
1242 },
1243 {
1244 .name = "exitall",
1245 .type = FIO_OPT_STR_SET,
1246 .cb = str_exitall_cb,
1247 .help = "Terminate all jobs when one exits",
1248 },
1249 {
1250 .name = "stonewall",
1251 .type = FIO_OPT_STR_SET,
1252 .off1 = td_var_offset(stonewall),
1253 .help = "Insert a hard barrier between this job and previous",
1254 },
1255 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001256 .name = "new_group",
1257 .type = FIO_OPT_STR_SET,
1258 .off1 = td_var_offset(new_group),
1259 .help = "Mark the start of a new group (for reporting)",
1260 },
1261 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001262 .name = "thread",
1263 .type = FIO_OPT_STR_SET,
1264 .off1 = td_var_offset(use_thread),
1265 .help = "Use threads instead of forks",
1266 },
1267 {
1268 .name = "write_bw_log",
1269 .type = FIO_OPT_STR_SET,
1270 .off1 = td_var_offset(write_bw_log),
1271 .help = "Write log of bandwidth during run",
1272 },
1273 {
1274 .name = "write_lat_log",
1275 .type = FIO_OPT_STR_SET,
1276 .off1 = td_var_offset(write_lat_log),
1277 .help = "Write log of latency during run",
1278 },
1279 {
1280 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001281 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001282 .off1 = td_var_offset(hugepage_size),
1283 .help = "When using hugepages, specify size of each page",
1284 .def = __stringify(FIO_HUGE_PAGE),
1285 },
1286 {
1287 .name = "group_reporting",
1288 .type = FIO_OPT_STR_SET,
1289 .off1 = td_var_offset(group_reporting),
1290 .help = "Do reporting on a per-group basis",
1291 },
1292 {
Jens Axboee9459e52007-04-17 15:46:32 +02001293 .name = "zero_buffers",
1294 .type = FIO_OPT_STR_SET,
1295 .off1 = td_var_offset(zero_buffers),
1296 .help = "Init IO buffers to all zeroes",
1297 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001298 {
1299 .name = "refill_buffers",
1300 .type = FIO_OPT_STR_SET,
1301 .off1 = td_var_offset(refill_buffers),
1302 .help = "Refill IO buffers on every IO submit",
1303 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001304#ifdef FIO_HAVE_DISK_UTIL
1305 {
1306 .name = "disk_util",
1307 .type = FIO_OPT_BOOL,
1308 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001309 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001310 .def = "1",
1311 },
1312#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001313 {
Jens Axboe993bf482008-11-14 13:04:53 +01001314 .name = "gtod_reduce",
1315 .type = FIO_OPT_BOOL,
1316 .help = "Greatly reduce number of gettimeofday() calls",
1317 .cb = str_gtod_reduce_cb,
1318 .def = "0",
1319 },
1320 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001321 .name = "disable_clat",
1322 .type = FIO_OPT_BOOL,
1323 .off1 = td_var_offset(disable_clat),
1324 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001325 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001326 .def = "0",
1327 },
1328 {
1329 .name = "disable_slat",
1330 .type = FIO_OPT_BOOL,
1331 .off1 = td_var_offset(disable_slat),
1332 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001333 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001334 .def = "0",
1335 },
1336 {
1337 .name = "disable_bw_measurement",
1338 .type = FIO_OPT_BOOL,
1339 .off1 = td_var_offset(disable_bw),
1340 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001341 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001342 .def = "0",
1343 },
1344 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001345 .name = NULL,
1346 },
1347};
1348
1349void fio_options_dup_and_init(struct option *long_options)
1350{
1351 struct fio_option *o;
1352 unsigned int i;
1353
1354 options_init(options);
1355
1356 i = 0;
1357 while (long_options[i].name)
1358 i++;
1359
1360 o = &options[0];
1361 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001362 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001363 long_options[i].val = FIO_GETOPT_JOB;
1364 if (o->type == FIO_OPT_STR_SET)
1365 long_options[i].has_arg = no_argument;
1366 else
1367 long_options[i].has_arg = required_argument;
1368
1369 i++;
1370 o++;
1371 assert(i < FIO_NR_OPTIONS);
1372 }
1373}
1374
Jens Axboe3b8b7132008-06-10 19:46:23 +02001375int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001376{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001377 int i, ret;
1378
1379 sort_options(opts, options, num_opts);
1380
1381 for (ret = 0, i = 0; i < num_opts; i++)
1382 ret |= parse_option(opts[i], options, td);
1383
1384 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001385}
1386
1387int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1388{
1389 return parse_cmd_option(opt, val, options, td);
1390}
1391
1392void fio_fill_default_options(struct thread_data *td)
1393{
1394 fill_default_options(td, options);
1395}
1396
1397int fio_show_option_help(const char *opt)
1398{
1399 return show_cmd_help(options, opt);
1400}
Jens Axboed23bb322007-03-23 15:57:56 +01001401
1402static void __options_mem(struct thread_data *td, int alloc)
1403{
1404 struct thread_options *o = &td->o;
1405 struct fio_option *opt;
1406 char **ptr;
1407 int i;
1408
1409 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1410 if (opt->type != FIO_OPT_STR_STORE)
1411 continue;
1412
1413 ptr = (void *) o + opt->off1;
1414 if (*ptr) {
1415 if (alloc)
1416 *ptr = strdup(*ptr);
1417 else {
1418 free(*ptr);
1419 *ptr = NULL;
1420 }
1421 }
1422 }
1423}
1424
1425/*
1426 * dupe FIO_OPT_STR_STORE options
1427 */
1428void options_mem_dupe(struct thread_data *td)
1429{
1430 __options_mem(td, 1);
1431}
1432
Jens Axboe22d66212007-03-27 20:06:25 +02001433void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001434{
Jens Axboe22d66212007-03-27 20:06:25 +02001435#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001436 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001437#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001438}