blob: c99f102dda6853ddd4c63f03ab6af3ec6d2f6671 [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
Jens Axboe62a72732008-12-08 11:37:01 +0100252 for (i = 0; i < sizeof(int) * 8; i++) {
253 if ((1 << i) & *val) {
254 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboed2e268b2007-06-15 10:33:49 +0200255 CPU_SET(*val, &td->o.cpumask);
Jens Axboe62a72732008-12-08 11:37:01 +0100256 }
257 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200258
Jens Axboe375b2692007-05-22 09:13:02 +0200259 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100260 return 0;
261}
262
Jens Axboed2e268b2007-06-15 10:33:49 +0200263static int str_cpus_allowed_cb(void *data, const char *input)
264{
265 struct thread_data *td = data;
266 char *cpu, *str, *p;
Jens Axboe19608d62008-12-08 15:03:12 +0100267 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200268
269 CPU_ZERO(&td->o.cpumask);
270
271 p = str = strdup(input);
272
273 strip_blank_front(&str);
274 strip_blank_end(str);
275
276 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100277 char *str2, *cpu2;
278 int icpu, icpu2;
279
Jens Axboed2e268b2007-06-15 10:33:49 +0200280 if (!strlen(cpu))
281 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100282
283 str2 = cpu;
284 icpu2 = -1;
285 while ((cpu2 = strsep(&str2, "-")) != NULL) {
286 if (!strlen(cpu2))
287 break;
288
289 icpu2 = atoi(cpu2);
290 }
291
292 icpu = atoi(cpu);
293 if (icpu2 == -1)
294 icpu2 = icpu;
295 while (icpu <= icpu2) {
Jens Axboe19608d62008-12-08 15:03:12 +0100296 if (icpu >= CPU_SETSIZE) {
297 log_err("fio: your OS only supports up to"
298 " %d CPUs\n", (int) CPU_SETSIZE);
299 ret = 1;
300 break;
301 }
302
Jens Axboe62a72732008-12-08 11:37:01 +0100303 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
304 CPU_SET(atoi(cpu), &td->o.cpumask);
305 icpu++;
306 }
Jens Axboe19608d62008-12-08 15:03:12 +0100307 if (ret)
308 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200309 }
310
311 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100312 if (!ret)
313 td->o.cpumask_set = 1;
314 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200315}
316#endif
317
Jens Axboe214e1ec2007-03-15 10:48:13 +0100318static int str_fst_cb(void *data, const char *str)
319{
320 struct thread_data *td = data;
321 char *nr = get_opt_postfix(str);
322
323 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100324 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100325 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100326 free(nr);
327 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100328
329 return 0;
330}
331
Jens Axboe921c7662008-03-26 09:17:55 +0100332static int check_dir(struct thread_data *td, char *fname)
333{
334 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200335 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100336
Jens Axboebc838912008-04-07 09:00:54 +0200337 if (td->o.directory) {
338 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200339 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200340 elen = strlen(file);
341 }
342
Jens Axboefcef0b32008-05-26 14:53:24 +0200343 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100344 dir = dirname(file);
345
Jens Axboefcef0b32008-05-26 14:53:24 +0200346#if 0
347 {
348 struct stat sb;
349 /*
350 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
351 * yet, so we can't do this check right here...
352 */
Jens Axboe921c7662008-03-26 09:17:55 +0100353 if (lstat(dir, &sb) < 0) {
354 int ret = errno;
355
356 log_err("fio: %s is not a directory\n", dir);
357 td_verror(td, ret, "lstat");
358 return 1;
359 }
360
361 if (!S_ISDIR(sb.st_mode)) {
362 log_err("fio: %s is not a directory\n", dir);
363 return 1;
364 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200365 }
366#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100367
368 return 0;
369}
370
Jens Axboe214e1ec2007-03-15 10:48:13 +0100371static int str_filename_cb(void *data, const char *input)
372{
373 struct thread_data *td = data;
374 char *fname, *str, *p;
375
376 p = str = strdup(input);
377
378 strip_blank_front(&str);
379 strip_blank_end(str);
380
381 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100382 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100383
384 while ((fname = strsep(&str, ":")) != NULL) {
385 if (!strlen(fname))
386 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100387 if (check_dir(td, fname)) {
388 free(p);
389 return 1;
390 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100391 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100392 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100393 }
394
395 free(p);
396 return 0;
397}
398
399static int str_directory_cb(void *data, const char fio_unused *str)
400{
401 struct thread_data *td = data;
402 struct stat sb;
403
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100404 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100405 int ret = errno;
406
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100407 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100408 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100409 return 1;
410 }
411 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100412 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100413 return 1;
414 }
415
416 return 0;
417}
418
419static int str_opendir_cb(void *data, const char fio_unused *str)
420{
421 struct thread_data *td = data;
422
423 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100424 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100425
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100426 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100427}
428
Jens Axboea59e1702007-07-30 08:53:27 +0200429static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200430{
431 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200432
Shawn Lewis546a9142007-07-28 21:11:37 +0200433 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200434 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200435 return 1;
436 }
Jens Axboea59e1702007-07-30 08:53:27 +0200437
438 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200439 return 0;
440}
441
Shawn Lewise28218f2008-01-16 11:01:33 +0100442static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200443{
444 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100445 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200446
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200447 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200448 if (msb <= 8)
449 td->o.verify_pattern_bytes = 1;
450 else if (msb <= 16)
451 td->o.verify_pattern_bytes = 2;
452 else if (msb <= 24)
453 td->o.verify_pattern_bytes = 3;
454 else
455 td->o.verify_pattern_bytes = 4;
456
Shawn Lewise28218f2008-01-16 11:01:33 +0100457 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200458 return 0;
459}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100460
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100461static int str_lockfile_cb(void *data, const char *str)
462{
463 struct thread_data *td = data;
464 char *nr = get_opt_postfix(str);
465
466 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100467 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100468 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100469 free(nr);
470 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100471
472 return 0;
473}
474
Jens Axboee3cedca2008-11-19 19:57:52 +0100475static int str_write_bw_log_cb(void *data, const char *str)
476{
477 struct thread_data *td = data;
478
479 if (str)
480 td->o.bw_log_file = strdup(str);
481
482 td->o.write_bw_log = 1;
483 return 0;
484}
485
486static int str_write_lat_log_cb(void *data, const char *str)
487{
488 struct thread_data *td = data;
489
490 if (str)
491 td->o.lat_log_file = strdup(str);
492
493 td->o.write_lat_log = 1;
494 return 0;
495}
496
Jens Axboe993bf482008-11-14 13:04:53 +0100497static int str_gtod_reduce_cb(void *data, int *il)
498{
499 struct thread_data *td = data;
500 int val = *il;
501
502 td->o.disable_clat = !!val;
503 td->o.disable_slat = !!val;
504 td->o.disable_bw = !!val;
505 if (val)
506 td->tv_cache_mask = 63;
507
508 return 0;
509}
510
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100511static int str_gtod_cpu_cb(void *data, int *il)
512{
513 struct thread_data *td = data;
514 int val = *il;
515
516 td->o.gtod_cpu = val;
517 td->o.gtod_offload = 1;
518 return 0;
519}
520
Jens Axboe214e1ec2007-03-15 10:48:13 +0100521#define __stringify_1(x) #x
522#define __stringify(x) __stringify_1(x)
523
524/*
525 * Map of job/command line options
526 */
527static struct fio_option options[] = {
528 {
529 .name = "description",
530 .type = FIO_OPT_STR_STORE,
531 .off1 = td_var_offset(description),
532 .help = "Text job description",
533 },
534 {
535 .name = "name",
536 .type = FIO_OPT_STR_STORE,
537 .off1 = td_var_offset(name),
538 .help = "Name of this job",
539 },
540 {
541 .name = "directory",
542 .type = FIO_OPT_STR_STORE,
543 .off1 = td_var_offset(directory),
544 .cb = str_directory_cb,
545 .help = "Directory to store files in",
546 },
547 {
548 .name = "filename",
549 .type = FIO_OPT_STR_STORE,
550 .off1 = td_var_offset(filename),
551 .cb = str_filename_cb,
Jens Axboe3b8b7132008-06-10 19:46:23 +0200552 .prio = 1, /* must come before "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100553 .help = "File(s) to use for the workload",
554 },
555 {
Jens Axboe29c13492008-03-01 19:25:20 +0100556 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100557 .type = FIO_OPT_STR,
558 .cb = str_lockfile_cb,
559 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100560 .help = "Lock file when doing IO to it",
561 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100562 .def = "none",
563 .posval = {
564 { .ival = "none",
565 .oval = FILE_LOCK_NONE,
566 .help = "No file locking",
567 },
568 { .ival = "exclusive",
569 .oval = FILE_LOCK_EXCLUSIVE,
570 .help = "Exclusive file lock",
571 },
572 {
573 .ival = "readwrite",
574 .oval = FILE_LOCK_READWRITE,
575 .help = "Read vs write lock",
576 },
577 },
Jens Axboe29c13492008-03-01 19:25:20 +0100578 },
579 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100580 .name = "opendir",
581 .type = FIO_OPT_STR_STORE,
582 .off1 = td_var_offset(opendir),
583 .cb = str_opendir_cb,
584 .help = "Recursively add files from this directory and down",
585 },
586 {
587 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100588 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100589 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100590 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100591 .off1 = td_var_offset(td_ddir),
592 .help = "IO direction",
593 .def = "read",
594 .posval = {
595 { .ival = "read",
596 .oval = TD_DDIR_READ,
597 .help = "Sequential read",
598 },
599 { .ival = "write",
600 .oval = TD_DDIR_WRITE,
601 .help = "Sequential write",
602 },
603 { .ival = "randread",
604 .oval = TD_DDIR_RANDREAD,
605 .help = "Random read",
606 },
607 { .ival = "randwrite",
608 .oval = TD_DDIR_RANDWRITE,
609 .help = "Random write",
610 },
611 { .ival = "rw",
612 .oval = TD_DDIR_RW,
613 .help = "Sequential read and write mix",
614 },
615 { .ival = "randrw",
616 .oval = TD_DDIR_RANDRW,
617 .help = "Random read and write mix"
618 },
619 },
620 },
621 {
622 .name = "ioengine",
623 .type = FIO_OPT_STR_STORE,
624 .off1 = td_var_offset(ioengine),
625 .help = "IO engine to use",
626 .def = "sync",
627 .posval = {
628 { .ival = "sync",
629 .help = "Use read/write",
630 },
gurudas paia31041e2007-10-23 15:12:30 +0200631 { .ival = "psync",
632 .help = "Use pread/pwrite",
633 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100634 { .ival = "vsync",
635 .help = "Use readv/writev",
636 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100637#ifdef FIO_HAVE_LIBAIO
638 { .ival = "libaio",
639 .help = "Linux native asynchronous IO",
640 },
641#endif
642#ifdef FIO_HAVE_POSIXAIO
643 { .ival = "posixaio",
644 .help = "POSIX asynchronous IO",
645 },
646#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200647#ifdef FIO_HAVE_SOLARISAIO
648 { .ival = "solarisaio",
649 .help = "Solaris native asynchronous IO",
650 },
651#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100652 { .ival = "mmap",
653 .help = "Memory mapped IO",
654 },
655#ifdef FIO_HAVE_SPLICE
656 { .ival = "splice",
657 .help = "splice/vmsplice based IO",
658 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200659 { .ival = "netsplice",
660 .help = "splice/vmsplice to/from the network",
661 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100662#endif
663#ifdef FIO_HAVE_SGIO
664 { .ival = "sg",
665 .help = "SCSI generic v3 IO",
666 },
667#endif
668 { .ival = "null",
669 .help = "Testing engine (no data transfer)",
670 },
671 { .ival = "net",
672 .help = "Network IO",
673 },
674#ifdef FIO_HAVE_SYSLET
675 { .ival = "syslet-rw",
676 .help = "syslet enabled async pread/pwrite IO",
677 },
678#endif
679 { .ival = "cpuio",
680 .help = "CPU cycler burner engine",
681 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100682#ifdef FIO_HAVE_GUASI
683 { .ival = "guasi",
684 .help = "GUASI IO engine",
685 },
686#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100687 { .ival = "external",
688 .help = "Load external engine (append name)",
689 },
690 },
691 },
692 {
693 .name = "iodepth",
694 .type = FIO_OPT_INT,
695 .off1 = td_var_offset(iodepth),
696 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100697 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100698 .def = "1",
699 },
700 {
701 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200702 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100703 .type = FIO_OPT_INT,
704 .off1 = td_var_offset(iodepth_batch),
705 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200706 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100707 .minval = 1,
708 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100709 },
710 {
Jens Axboe49504212008-06-05 09:03:30 +0200711 .name = "iodepth_batch_complete",
712 .type = FIO_OPT_INT,
713 .off1 = td_var_offset(iodepth_batch_complete),
714 .help = "Number of IO to retrieve in one go",
715 .parent = "iodepth",
716 .minval = 0,
717 .def = "1",
718 },
719 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100720 .name = "iodepth_low",
721 .type = FIO_OPT_INT,
722 .off1 = td_var_offset(iodepth_low),
723 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200724 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100725 },
726 {
727 .name = "size",
728 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100729 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200730 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100731 .help = "Total size of device or files",
732 },
733 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100734 .name = "fill_device",
735 .type = FIO_OPT_BOOL,
736 .off1 = td_var_offset(fill_device),
737 .help = "Write until an ENOSPC error occurs",
738 .def = "0",
739 },
740 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100741 .name = "filesize",
742 .type = FIO_OPT_STR_VAL,
743 .off1 = td_var_offset(file_size_low),
744 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200745 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100746 .help = "Size of individual files",
747 },
748 {
Jens Axboe67a10002007-07-31 23:12:16 +0200749 .name = "offset",
750 .alias = "fileoffset",
751 .type = FIO_OPT_STR_VAL,
752 .off1 = td_var_offset(start_offset),
753 .help = "Start IO from this offset",
754 .def = "0",
755 },
756 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100757 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100758 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100759 .type = FIO_OPT_STR_VAL_INT,
760 .off1 = td_var_offset(bs[DDIR_READ]),
761 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200762 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100763 .help = "Block size unit",
764 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200765 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100766 },
767 {
768 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100769 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100770 .type = FIO_OPT_RANGE,
771 .off1 = td_var_offset(min_bs[DDIR_READ]),
772 .off2 = td_var_offset(max_bs[DDIR_READ]),
773 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
774 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200775 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100776 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200777 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100778 },
779 {
Jens Axboe564ca972007-12-14 12:21:19 +0100780 .name = "bssplit",
781 .type = FIO_OPT_STR,
782 .cb = str_bssplit_cb,
783 .help = "Set a specific mix of block sizes",
784 .parent = "rw",
785 },
786 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100787 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100788 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100789 .type = FIO_OPT_STR_SET,
790 .off1 = td_var_offset(bs_unaligned),
791 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200792 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100793 },
794 {
795 .name = "randrepeat",
796 .type = FIO_OPT_BOOL,
797 .off1 = td_var_offset(rand_repeatable),
798 .help = "Use repeatable random IO pattern",
799 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200800 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100801 },
802 {
803 .name = "norandommap",
804 .type = FIO_OPT_STR_SET,
805 .off1 = td_var_offset(norandommap),
806 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200807 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100808 },
809 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100810 .name = "softrandommap",
811 .type = FIO_OPT_BOOL,
812 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200813 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100814 .parent = "norandommap",
815 .def = "0",
816 },
817 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100818 .name = "nrfiles",
819 .type = FIO_OPT_INT,
820 .off1 = td_var_offset(nr_files),
821 .help = "Split job workload between this number of files",
822 .def = "1",
823 },
824 {
825 .name = "openfiles",
826 .type = FIO_OPT_INT,
827 .off1 = td_var_offset(open_files),
828 .help = "Number of files to keep open at the same time",
829 },
830 {
831 .name = "file_service_type",
832 .type = FIO_OPT_STR,
833 .cb = str_fst_cb,
834 .off1 = td_var_offset(file_service_type),
835 .help = "How to select which file to service next",
836 .def = "roundrobin",
837 .posval = {
838 { .ival = "random",
839 .oval = FIO_FSERVICE_RANDOM,
840 .help = "Choose a file at random",
841 },
842 { .ival = "roundrobin",
843 .oval = FIO_FSERVICE_RR,
844 .help = "Round robin select files",
845 },
846 },
Jens Axboe67a10002007-07-31 23:12:16 +0200847 .parent = "nrfiles",
848 },
849 {
850 .name = "fadvise_hint",
851 .type = FIO_OPT_BOOL,
852 .off1 = td_var_offset(fadvise_hint),
853 .help = "Use fadvise() to advise the kernel on IO pattern",
854 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100855 },
856 {
857 .name = "fsync",
858 .type = FIO_OPT_INT,
859 .off1 = td_var_offset(fsync_blocks),
860 .help = "Issue fsync for writes every given number of blocks",
861 .def = "0",
862 },
863 {
864 .name = "direct",
865 .type = FIO_OPT_BOOL,
866 .off1 = td_var_offset(odirect),
867 .help = "Use O_DIRECT IO (negates buffered)",
868 .def = "0",
869 },
870 {
871 .name = "buffered",
872 .type = FIO_OPT_BOOL,
873 .off1 = td_var_offset(odirect),
874 .neg = 1,
875 .help = "Use buffered IO (negates direct)",
876 .def = "1",
877 },
878 {
879 .name = "overwrite",
880 .type = FIO_OPT_BOOL,
881 .off1 = td_var_offset(overwrite),
882 .help = "When writing, set whether to overwrite current data",
883 .def = "0",
884 },
885 {
886 .name = "loops",
887 .type = FIO_OPT_INT,
888 .off1 = td_var_offset(loops),
889 .help = "Number of times to run the job",
890 .def = "1",
891 },
892 {
893 .name = "numjobs",
894 .type = FIO_OPT_INT,
895 .off1 = td_var_offset(numjobs),
896 .help = "Duplicate this job this many times",
897 .def = "1",
898 },
899 {
900 .name = "startdelay",
901 .type = FIO_OPT_INT,
902 .off1 = td_var_offset(start_delay),
903 .help = "Only start job when this period has passed",
904 .def = "0",
905 },
906 {
907 .name = "runtime",
908 .alias = "timeout",
909 .type = FIO_OPT_STR_VAL_TIME,
910 .off1 = td_var_offset(timeout),
911 .help = "Stop workload when this amount of time has passed",
912 .def = "0",
913 },
914 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200915 .name = "time_based",
916 .type = FIO_OPT_STR_SET,
917 .off1 = td_var_offset(time_based),
918 .help = "Keep running until runtime/timeout is met",
919 },
920 {
Jens Axboe721938a2008-09-10 09:46:16 +0200921 .name = "ramp_time",
922 .type = FIO_OPT_STR_VAL_TIME,
923 .off1 = td_var_offset(ramp_time),
924 .help = "Ramp up time before measuring performance",
925 },
926 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100927 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100928 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100929 .type = FIO_OPT_STR,
930 .cb = str_mem_cb,
931 .off1 = td_var_offset(mem_type),
932 .help = "Backing type for IO buffers",
933 .def = "malloc",
934 .posval = {
935 { .ival = "malloc",
936 .oval = MEM_MALLOC,
937 .help = "Use malloc(3) for IO buffers",
938 },
Jens Axboeb370e462007-03-19 10:51:49 +0100939 { .ival = "shm",
940 .oval = MEM_SHM,
941 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100942 },
943#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100944 { .ival = "shmhuge",
945 .oval = MEM_SHMHUGE,
946 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100947 },
948#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100949 { .ival = "mmap",
950 .oval = MEM_MMAP,
951 .help = "Use mmap(2) (file or anon) for IO buffers",
952 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100953#ifdef FIO_HAVE_HUGETLB
954 { .ival = "mmaphuge",
955 .oval = MEM_MMAPHUGE,
956 .help = "Like mmap, but use huge pages",
957 },
958#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100959 },
960 },
961 {
962 .name = "verify",
963 .type = FIO_OPT_STR,
964 .off1 = td_var_offset(verify),
965 .help = "Verify data written",
966 .def = "0",
967 .posval = {
968 { .ival = "0",
969 .oval = VERIFY_NONE,
970 .help = "Don't do IO verification",
971 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200972 { .ival = "md5",
973 .oval = VERIFY_MD5,
974 .help = "Use md5 checksums for verification",
975 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200976 { .ival = "crc64",
977 .oval = VERIFY_CRC64,
978 .help = "Use crc64 checksums for verification",
979 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100980 { .ival = "crc32",
981 .oval = VERIFY_CRC32,
982 .help = "Use crc32 checksums for verification",
983 },
Jens Axboeaf497e62008-08-04 15:40:35 +0200984 { .ival = "crc32c-intel",
985 .oval = VERIFY_CRC32C_INTEL,
986 .help = "Use hw crc32c checksums for verification",
987 },
Jens Axboebac39e02008-06-11 20:46:19 +0200988 { .ival = "crc32c",
989 .oval = VERIFY_CRC32C,
990 .help = "Use crc32c checksums for verification",
991 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200992 { .ival = "crc16",
993 .oval = VERIFY_CRC16,
994 .help = "Use crc16 checksums for verification",
995 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200996 { .ival = "crc7",
997 .oval = VERIFY_CRC7,
998 .help = "Use crc7 checksums for verification",
999 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001000 { .ival = "sha256",
1001 .oval = VERIFY_SHA256,
1002 .help = "Use sha256 checksums for verification",
1003 },
1004 { .ival = "sha512",
1005 .oval = VERIFY_SHA512,
1006 .help = "Use sha512 checksums for verification",
1007 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001008 { .ival = "meta",
1009 .oval = VERIFY_META,
1010 .help = "Use io information",
1011 },
Jens Axboe36690c92007-03-26 10:23:34 +02001012 {
1013 .ival = "null",
1014 .oval = VERIFY_NULL,
1015 .help = "Pretend to verify",
1016 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001017 },
1018 },
1019 {
Jens Axboe005c5652007-08-02 22:21:36 +02001020 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001021 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001022 .off1 = td_var_offset(do_verify),
1023 .help = "Run verification stage after write",
1024 .def = "1",
1025 .parent = "verify",
1026 },
1027 {
Jens Axboe160b9662007-03-27 10:59:49 +02001028 .name = "verifysort",
1029 .type = FIO_OPT_BOOL,
1030 .off1 = td_var_offset(verifysort),
1031 .help = "Sort written verify blocks for read back",
1032 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001033 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001034 },
1035 {
Jens Axboea59e1702007-07-30 08:53:27 +02001036 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001037 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001038 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001039 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001040 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001041 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001042 },
1043 {
Jens Axboea59e1702007-07-30 08:53:27 +02001044 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +02001045 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001046 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001047 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001048 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001049 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001050 },
1051 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001052 .name = "verify_pattern",
1053 .type = FIO_OPT_INT,
1054 .cb = str_verify_pattern_cb,
1055 .help = "Fill pattern for IO buffers",
1056 .parent = "verify",
1057 },
1058 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001059 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001060 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001061 .off1 = td_var_offset(verify_fatal),
1062 .def = "0",
1063 .help = "Exit on a single verify failure, don't continue",
1064 .parent = "verify",
1065 },
1066 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001067 .name = "write_iolog",
1068 .type = FIO_OPT_STR_STORE,
1069 .off1 = td_var_offset(write_iolog_file),
1070 .help = "Store IO pattern to file",
1071 },
1072 {
1073 .name = "read_iolog",
1074 .type = FIO_OPT_STR_STORE,
1075 .off1 = td_var_offset(read_iolog_file),
1076 .help = "Playback IO pattern from file",
1077 },
1078 {
1079 .name = "exec_prerun",
1080 .type = FIO_OPT_STR_STORE,
1081 .off1 = td_var_offset(exec_prerun),
1082 .help = "Execute this file prior to running job",
1083 },
1084 {
1085 .name = "exec_postrun",
1086 .type = FIO_OPT_STR_STORE,
1087 .off1 = td_var_offset(exec_postrun),
1088 .help = "Execute this file after running job",
1089 },
1090#ifdef FIO_HAVE_IOSCHED_SWITCH
1091 {
1092 .name = "ioscheduler",
1093 .type = FIO_OPT_STR_STORE,
1094 .off1 = td_var_offset(ioscheduler),
1095 .help = "Use this IO scheduler on the backing device",
1096 },
1097#endif
1098 {
1099 .name = "zonesize",
1100 .type = FIO_OPT_STR_VAL,
1101 .off1 = td_var_offset(zone_size),
1102 .help = "Give size of an IO zone",
1103 .def = "0",
1104 },
1105 {
1106 .name = "zoneskip",
1107 .type = FIO_OPT_STR_VAL,
1108 .off1 = td_var_offset(zone_skip),
1109 .help = "Space between IO zones",
1110 .def = "0",
1111 },
1112 {
1113 .name = "lockmem",
1114 .type = FIO_OPT_STR_VAL,
1115 .cb = str_lockmem_cb,
1116 .help = "Lock down this amount of memory",
1117 .def = "0",
1118 },
1119 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001120 .name = "rwmixread",
1121 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001122 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001123 .maxval = 100,
1124 .help = "Percentage of mixed workload that is reads",
1125 .def = "50",
1126 },
1127 {
1128 .name = "rwmixwrite",
1129 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001130 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001131 .maxval = 100,
1132 .help = "Percentage of mixed workload that is writes",
1133 .def = "50",
1134 },
1135 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001136 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001137 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001138 },
1139 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001140 .name = "nice",
1141 .type = FIO_OPT_INT,
1142 .off1 = td_var_offset(nice),
1143 .help = "Set job CPU nice value",
1144 .minval = -19,
1145 .maxval = 20,
1146 .def = "0",
1147 },
1148#ifdef FIO_HAVE_IOPRIO
1149 {
1150 .name = "prio",
1151 .type = FIO_OPT_INT,
1152 .cb = str_prio_cb,
1153 .help = "Set job IO priority value",
1154 .minval = 0,
1155 .maxval = 7,
1156 },
1157 {
1158 .name = "prioclass",
1159 .type = FIO_OPT_INT,
1160 .cb = str_prioclass_cb,
1161 .help = "Set job IO priority class",
1162 .minval = 0,
1163 .maxval = 3,
1164 },
1165#endif
1166 {
1167 .name = "thinktime",
1168 .type = FIO_OPT_INT,
1169 .off1 = td_var_offset(thinktime),
1170 .help = "Idle time between IO buffers (usec)",
1171 .def = "0",
1172 },
1173 {
1174 .name = "thinktime_spin",
1175 .type = FIO_OPT_INT,
1176 .off1 = td_var_offset(thinktime_spin),
1177 .help = "Start think time by spinning this amount (usec)",
1178 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001179 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001180 },
1181 {
1182 .name = "thinktime_blocks",
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(thinktime_blocks),
1185 .help = "IO buffer period between 'thinktime'",
1186 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001187 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001188 },
1189 {
1190 .name = "rate",
1191 .type = FIO_OPT_INT,
1192 .off1 = td_var_offset(rate),
1193 .help = "Set bandwidth rate",
1194 },
1195 {
1196 .name = "ratemin",
1197 .type = FIO_OPT_INT,
1198 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001199 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001200 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001201 },
1202 {
1203 .name = "rate_iops",
1204 .type = FIO_OPT_INT,
1205 .off1 = td_var_offset(rate_iops),
1206 .help = "Limit IO used to this number of IO operations/sec",
1207 },
1208 {
1209 .name = "rate_iops_min",
1210 .type = FIO_OPT_INT,
1211 .off1 = td_var_offset(rate_iops_min),
1212 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001213 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001214 },
1215 {
1216 .name = "ratecycle",
1217 .type = FIO_OPT_INT,
1218 .off1 = td_var_offset(ratecycle),
1219 .help = "Window average for rate limits (msec)",
1220 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001221 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001222 },
1223 {
1224 .name = "invalidate",
1225 .type = FIO_OPT_BOOL,
1226 .off1 = td_var_offset(invalidate_cache),
1227 .help = "Invalidate buffer/page cache prior to running job",
1228 .def = "1",
1229 },
1230 {
1231 .name = "sync",
1232 .type = FIO_OPT_BOOL,
1233 .off1 = td_var_offset(sync_io),
1234 .help = "Use O_SYNC for buffered writes",
1235 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001236 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001237 },
1238 {
1239 .name = "bwavgtime",
1240 .type = FIO_OPT_INT,
1241 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001242 .help = "Time window over which to calculate bandwidth"
1243 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001244 .def = "500",
1245 },
1246 {
1247 .name = "create_serialize",
1248 .type = FIO_OPT_BOOL,
1249 .off1 = td_var_offset(create_serialize),
1250 .help = "Serialize creating of job files",
1251 .def = "1",
1252 },
1253 {
1254 .name = "create_fsync",
1255 .type = FIO_OPT_BOOL,
1256 .off1 = td_var_offset(create_fsync),
1257 .help = "Fsync file after creation",
1258 .def = "1",
1259 },
1260 {
1261 .name = "cpuload",
1262 .type = FIO_OPT_INT,
1263 .off1 = td_var_offset(cpuload),
1264 .help = "Use this percentage of CPU",
1265 },
1266 {
1267 .name = "cpuchunks",
1268 .type = FIO_OPT_INT,
1269 .off1 = td_var_offset(cpucycle),
1270 .help = "Length of the CPU burn cycles (usecs)",
1271 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001272 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001273 },
1274#ifdef FIO_HAVE_CPU_AFFINITY
1275 {
1276 .name = "cpumask",
1277 .type = FIO_OPT_INT,
1278 .cb = str_cpumask_cb,
1279 .help = "CPU affinity mask",
1280 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001281 {
1282 .name = "cpus_allowed",
1283 .type = FIO_OPT_STR,
1284 .cb = str_cpus_allowed_cb,
1285 .help = "Set CPUs allowed",
1286 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001287#endif
1288 {
1289 .name = "end_fsync",
1290 .type = FIO_OPT_BOOL,
1291 .off1 = td_var_offset(end_fsync),
1292 .help = "Include fsync at the end of job",
1293 .def = "0",
1294 },
1295 {
1296 .name = "fsync_on_close",
1297 .type = FIO_OPT_BOOL,
1298 .off1 = td_var_offset(fsync_on_close),
1299 .help = "fsync files on close",
1300 .def = "0",
1301 },
1302 {
1303 .name = "unlink",
1304 .type = FIO_OPT_BOOL,
1305 .off1 = td_var_offset(unlink),
1306 .help = "Unlink created files after job has completed",
1307 .def = "0",
1308 },
1309 {
1310 .name = "exitall",
1311 .type = FIO_OPT_STR_SET,
1312 .cb = str_exitall_cb,
1313 .help = "Terminate all jobs when one exits",
1314 },
1315 {
1316 .name = "stonewall",
1317 .type = FIO_OPT_STR_SET,
1318 .off1 = td_var_offset(stonewall),
1319 .help = "Insert a hard barrier between this job and previous",
1320 },
1321 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001322 .name = "new_group",
1323 .type = FIO_OPT_STR_SET,
1324 .off1 = td_var_offset(new_group),
1325 .help = "Mark the start of a new group (for reporting)",
1326 },
1327 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001328 .name = "thread",
1329 .type = FIO_OPT_STR_SET,
1330 .off1 = td_var_offset(use_thread),
1331 .help = "Use threads instead of forks",
1332 },
1333 {
1334 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001335 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001336 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001337 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001338 .help = "Write log of bandwidth during run",
1339 },
1340 {
1341 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001342 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001343 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001344 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001345 .help = "Write log of latency during run",
1346 },
1347 {
1348 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001349 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001350 .off1 = td_var_offset(hugepage_size),
1351 .help = "When using hugepages, specify size of each page",
1352 .def = __stringify(FIO_HUGE_PAGE),
1353 },
1354 {
1355 .name = "group_reporting",
1356 .type = FIO_OPT_STR_SET,
1357 .off1 = td_var_offset(group_reporting),
1358 .help = "Do reporting on a per-group basis",
1359 },
1360 {
Jens Axboee9459e52007-04-17 15:46:32 +02001361 .name = "zero_buffers",
1362 .type = FIO_OPT_STR_SET,
1363 .off1 = td_var_offset(zero_buffers),
1364 .help = "Init IO buffers to all zeroes",
1365 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001366 {
1367 .name = "refill_buffers",
1368 .type = FIO_OPT_STR_SET,
1369 .off1 = td_var_offset(refill_buffers),
1370 .help = "Refill IO buffers on every IO submit",
1371 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001372#ifdef FIO_HAVE_DISK_UTIL
1373 {
1374 .name = "disk_util",
1375 .type = FIO_OPT_BOOL,
1376 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001377 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001378 .def = "1",
1379 },
1380#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001381 {
Jens Axboe993bf482008-11-14 13:04:53 +01001382 .name = "gtod_reduce",
1383 .type = FIO_OPT_BOOL,
1384 .help = "Greatly reduce number of gettimeofday() calls",
1385 .cb = str_gtod_reduce_cb,
1386 .def = "0",
1387 },
1388 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001389 .name = "disable_clat",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(disable_clat),
1392 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001393 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001394 .def = "0",
1395 },
1396 {
1397 .name = "disable_slat",
1398 .type = FIO_OPT_BOOL,
1399 .off1 = td_var_offset(disable_slat),
1400 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001401 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001402 .def = "0",
1403 },
1404 {
1405 .name = "disable_bw_measurement",
1406 .type = FIO_OPT_BOOL,
1407 .off1 = td_var_offset(disable_bw),
1408 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001409 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001410 .def = "0",
1411 },
1412 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001413 .name = "gtod_cpu",
1414 .type = FIO_OPT_INT,
1415 .cb = str_gtod_cpu_cb,
1416 .help = "Setup dedicated gettimeofday() thread on this CPU",
1417 },
1418 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001419 .name = NULL,
1420 },
1421};
1422
1423void fio_options_dup_and_init(struct option *long_options)
1424{
1425 struct fio_option *o;
1426 unsigned int i;
1427
1428 options_init(options);
1429
1430 i = 0;
1431 while (long_options[i].name)
1432 i++;
1433
1434 o = &options[0];
1435 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001436 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001437 long_options[i].val = FIO_GETOPT_JOB;
1438 if (o->type == FIO_OPT_STR_SET)
1439 long_options[i].has_arg = no_argument;
1440 else
1441 long_options[i].has_arg = required_argument;
1442
1443 i++;
1444 o++;
1445 assert(i < FIO_NR_OPTIONS);
1446 }
1447}
1448
Jens Axboe3b8b7132008-06-10 19:46:23 +02001449int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001450{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001451 int i, ret;
1452
1453 sort_options(opts, options, num_opts);
1454
1455 for (ret = 0, i = 0; i < num_opts; i++)
1456 ret |= parse_option(opts[i], options, td);
1457
1458 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001459}
1460
1461int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1462{
1463 return parse_cmd_option(opt, val, options, td);
1464}
1465
1466void fio_fill_default_options(struct thread_data *td)
1467{
1468 fill_default_options(td, options);
1469}
1470
1471int fio_show_option_help(const char *opt)
1472{
1473 return show_cmd_help(options, opt);
1474}
Jens Axboed23bb322007-03-23 15:57:56 +01001475
1476static void __options_mem(struct thread_data *td, int alloc)
1477{
1478 struct thread_options *o = &td->o;
1479 struct fio_option *opt;
1480 char **ptr;
1481 int i;
1482
1483 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1484 if (opt->type != FIO_OPT_STR_STORE)
1485 continue;
1486
1487 ptr = (void *) o + opt->off1;
1488 if (*ptr) {
1489 if (alloc)
1490 *ptr = strdup(*ptr);
1491 else {
1492 free(*ptr);
1493 *ptr = NULL;
1494 }
1495 }
1496 }
1497}
1498
1499/*
1500 * dupe FIO_OPT_STR_STORE options
1501 */
1502void options_mem_dupe(struct thread_data *td)
1503{
1504 __options_mem(td, 1);
1505}
1506
Jens Axboe22d66212007-03-27 20:06:25 +02001507void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001508{
Jens Axboe22d66212007-03-27 20:06:25 +02001509#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001510 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001511#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001512}