blob: cec7bb79d2422b19f79df258b784c0ab033fbc4b [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 Axboeb03daaf2008-12-08 20:31:43 +0100249 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100250 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100251
Jens Axboed2ce18b2008-12-12 20:51:40 +0100252 ret = fio_cpuset_init(&td->o.cpumask);
253 if (ret < 0) {
254 log_err("fio: cpuset_init failed\n");
255 td_verror(td, ret, "fio_cpuset_init");
256 return 1;
257 }
258
Jens Axboeb03daaf2008-12-08 20:31:43 +0100259 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
Jens Axboed2e268b2007-06-15 10:33:49 +0200260
Jens Axboe62a72732008-12-08 11:37:01 +0100261 for (i = 0; i < sizeof(int) * 8; i++) {
262 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100263 if (i > max_cpu) {
264 log_err("fio: CPU %d too large (max=%ld)\n", i,
265 max_cpu);
266 return 1;
267 }
Jens Axboe62a72732008-12-08 11:37:01 +0100268 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100269 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100270 }
271 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200272
Jens Axboe375b2692007-05-22 09:13:02 +0200273 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100274 return 0;
275}
276
Jens Axboed2e268b2007-06-15 10:33:49 +0200277static int str_cpus_allowed_cb(void *data, const char *input)
278{
279 struct thread_data *td = data;
280 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100281 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100282 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200283
Jens Axboed2ce18b2008-12-12 20:51:40 +0100284 ret = fio_cpuset_init(&td->o.cpumask);
285 if (ret < 0) {
286 log_err("fio: cpuset_init failed\n");
287 td_verror(td, ret, "fio_cpuset_init");
288 return 1;
289 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200290
291 p = str = strdup(input);
292
293 strip_blank_front(&str);
294 strip_blank_end(str);
295
Jens Axboeb03daaf2008-12-08 20:31:43 +0100296 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
297
Jens Axboed2e268b2007-06-15 10:33:49 +0200298 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100299 char *str2, *cpu2;
300 int icpu, icpu2;
301
Jens Axboed2e268b2007-06-15 10:33:49 +0200302 if (!strlen(cpu))
303 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100304
305 str2 = cpu;
306 icpu2 = -1;
307 while ((cpu2 = strsep(&str2, "-")) != NULL) {
308 if (!strlen(cpu2))
309 break;
310
311 icpu2 = atoi(cpu2);
312 }
313
314 icpu = atoi(cpu);
315 if (icpu2 == -1)
316 icpu2 = icpu;
317 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100318 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100319 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100320 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100321 ret = 1;
322 break;
323 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100324 if (icpu > max_cpu) {
325 log_err("fio: CPU %d too large (max=%ld)\n",
326 icpu, max_cpu);
327 ret = 1;
328 break;
329 }
330
Jens Axboe62a72732008-12-08 11:37:01 +0100331 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100332 fio_cpu_set(&td->o.cpumask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100333 icpu++;
334 }
Jens Axboe19608d62008-12-08 15:03:12 +0100335 if (ret)
336 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200337 }
338
339 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100340 if (!ret)
341 td->o.cpumask_set = 1;
342 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200343}
344#endif
345
Jens Axboe214e1ec2007-03-15 10:48:13 +0100346static int str_fst_cb(void *data, const char *str)
347{
348 struct thread_data *td = data;
349 char *nr = get_opt_postfix(str);
350
351 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100352 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100354 free(nr);
355 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100356
357 return 0;
358}
359
Jens Axboe921c7662008-03-26 09:17:55 +0100360static int check_dir(struct thread_data *td, char *fname)
361{
362 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200363 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100364
Jens Axboebc838912008-04-07 09:00:54 +0200365 if (td->o.directory) {
366 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200367 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200368 elen = strlen(file);
369 }
370
Jens Axboefcef0b32008-05-26 14:53:24 +0200371 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100372 dir = dirname(file);
373
Jens Axboefcef0b32008-05-26 14:53:24 +0200374#if 0
375 {
376 struct stat sb;
377 /*
378 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
379 * yet, so we can't do this check right here...
380 */
Jens Axboe921c7662008-03-26 09:17:55 +0100381 if (lstat(dir, &sb) < 0) {
382 int ret = errno;
383
384 log_err("fio: %s is not a directory\n", dir);
385 td_verror(td, ret, "lstat");
386 return 1;
387 }
388
389 if (!S_ISDIR(sb.st_mode)) {
390 log_err("fio: %s is not a directory\n", dir);
391 return 1;
392 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200393 }
394#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100395
396 return 0;
397}
398
Jens Axboe214e1ec2007-03-15 10:48:13 +0100399static int str_filename_cb(void *data, const char *input)
400{
401 struct thread_data *td = data;
402 char *fname, *str, *p;
403
404 p = str = strdup(input);
405
406 strip_blank_front(&str);
407 strip_blank_end(str);
408
409 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100410 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100411
412 while ((fname = strsep(&str, ":")) != NULL) {
413 if (!strlen(fname))
414 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100415 if (check_dir(td, fname)) {
416 free(p);
417 return 1;
418 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100419 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100420 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100421 }
422
423 free(p);
424 return 0;
425}
426
427static int str_directory_cb(void *data, const char fio_unused *str)
428{
429 struct thread_data *td = data;
430 struct stat sb;
431
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100432 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100433 int ret = errno;
434
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100435 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100436 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100437 return 1;
438 }
439 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100440 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100441 return 1;
442 }
443
444 return 0;
445}
446
447static int str_opendir_cb(void *data, const char fio_unused *str)
448{
449 struct thread_data *td = data;
450
451 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100452 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100453
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100454 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100455}
456
Jens Axboea59e1702007-07-30 08:53:27 +0200457static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200458{
459 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200460
Shawn Lewis546a9142007-07-28 21:11:37 +0200461 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200462 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200463 return 1;
464 }
Jens Axboea59e1702007-07-30 08:53:27 +0200465
466 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200467 return 0;
468}
469
Shawn Lewise28218f2008-01-16 11:01:33 +0100470static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200471{
472 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100473 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200474
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200475 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200476 if (msb <= 8)
477 td->o.verify_pattern_bytes = 1;
478 else if (msb <= 16)
479 td->o.verify_pattern_bytes = 2;
480 else if (msb <= 24)
481 td->o.verify_pattern_bytes = 3;
482 else
483 td->o.verify_pattern_bytes = 4;
484
Shawn Lewise28218f2008-01-16 11:01:33 +0100485 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200486 return 0;
487}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100488
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100489static int str_lockfile_cb(void *data, const char *str)
490{
491 struct thread_data *td = data;
492 char *nr = get_opt_postfix(str);
493
494 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100495 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100496 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100497 free(nr);
498 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100499
500 return 0;
501}
502
Jens Axboee3cedca2008-11-19 19:57:52 +0100503static int str_write_bw_log_cb(void *data, const char *str)
504{
505 struct thread_data *td = data;
506
507 if (str)
508 td->o.bw_log_file = strdup(str);
509
510 td->o.write_bw_log = 1;
511 return 0;
512}
513
514static int str_write_lat_log_cb(void *data, const char *str)
515{
516 struct thread_data *td = data;
517
518 if (str)
519 td->o.lat_log_file = strdup(str);
520
521 td->o.write_lat_log = 1;
522 return 0;
523}
524
Jens Axboe993bf482008-11-14 13:04:53 +0100525static int str_gtod_reduce_cb(void *data, int *il)
526{
527 struct thread_data *td = data;
528 int val = *il;
529
530 td->o.disable_clat = !!val;
531 td->o.disable_slat = !!val;
532 td->o.disable_bw = !!val;
533 if (val)
534 td->tv_cache_mask = 63;
535
536 return 0;
537}
538
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100539static int str_gtod_cpu_cb(void *data, int *il)
540{
541 struct thread_data *td = data;
542 int val = *il;
543
544 td->o.gtod_cpu = val;
545 td->o.gtod_offload = 1;
546 return 0;
547}
548
Jens Axboe214e1ec2007-03-15 10:48:13 +0100549#define __stringify_1(x) #x
550#define __stringify(x) __stringify_1(x)
551
552/*
553 * Map of job/command line options
554 */
555static struct fio_option options[] = {
556 {
557 .name = "description",
558 .type = FIO_OPT_STR_STORE,
559 .off1 = td_var_offset(description),
560 .help = "Text job description",
561 },
562 {
563 .name = "name",
564 .type = FIO_OPT_STR_STORE,
565 .off1 = td_var_offset(name),
566 .help = "Name of this job",
567 },
568 {
569 .name = "directory",
570 .type = FIO_OPT_STR_STORE,
571 .off1 = td_var_offset(directory),
572 .cb = str_directory_cb,
573 .help = "Directory to store files in",
574 },
575 {
576 .name = "filename",
577 .type = FIO_OPT_STR_STORE,
578 .off1 = td_var_offset(filename),
579 .cb = str_filename_cb,
Jens Axboe3b8b7132008-06-10 19:46:23 +0200580 .prio = 1, /* must come before "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100581 .help = "File(s) to use for the workload",
582 },
583 {
Jens Axboe29c13492008-03-01 19:25:20 +0100584 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100585 .type = FIO_OPT_STR,
586 .cb = str_lockfile_cb,
587 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100588 .help = "Lock file when doing IO to it",
589 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100590 .def = "none",
591 .posval = {
592 { .ival = "none",
593 .oval = FILE_LOCK_NONE,
594 .help = "No file locking",
595 },
596 { .ival = "exclusive",
597 .oval = FILE_LOCK_EXCLUSIVE,
598 .help = "Exclusive file lock",
599 },
600 {
601 .ival = "readwrite",
602 .oval = FILE_LOCK_READWRITE,
603 .help = "Read vs write lock",
604 },
605 },
Jens Axboe29c13492008-03-01 19:25:20 +0100606 },
607 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100608 .name = "opendir",
609 .type = FIO_OPT_STR_STORE,
610 .off1 = td_var_offset(opendir),
611 .cb = str_opendir_cb,
612 .help = "Recursively add files from this directory and down",
613 },
614 {
615 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100616 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100617 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100618 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100619 .off1 = td_var_offset(td_ddir),
620 .help = "IO direction",
621 .def = "read",
622 .posval = {
623 { .ival = "read",
624 .oval = TD_DDIR_READ,
625 .help = "Sequential read",
626 },
627 { .ival = "write",
628 .oval = TD_DDIR_WRITE,
629 .help = "Sequential write",
630 },
631 { .ival = "randread",
632 .oval = TD_DDIR_RANDREAD,
633 .help = "Random read",
634 },
635 { .ival = "randwrite",
636 .oval = TD_DDIR_RANDWRITE,
637 .help = "Random write",
638 },
639 { .ival = "rw",
640 .oval = TD_DDIR_RW,
641 .help = "Sequential read and write mix",
642 },
643 { .ival = "randrw",
644 .oval = TD_DDIR_RANDRW,
645 .help = "Random read and write mix"
646 },
647 },
648 },
649 {
650 .name = "ioengine",
651 .type = FIO_OPT_STR_STORE,
652 .off1 = td_var_offset(ioengine),
653 .help = "IO engine to use",
654 .def = "sync",
655 .posval = {
656 { .ival = "sync",
657 .help = "Use read/write",
658 },
gurudas paia31041e2007-10-23 15:12:30 +0200659 { .ival = "psync",
660 .help = "Use pread/pwrite",
661 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100662 { .ival = "vsync",
663 .help = "Use readv/writev",
664 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100665#ifdef FIO_HAVE_LIBAIO
666 { .ival = "libaio",
667 .help = "Linux native asynchronous IO",
668 },
669#endif
670#ifdef FIO_HAVE_POSIXAIO
671 { .ival = "posixaio",
672 .help = "POSIX asynchronous IO",
673 },
674#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200675#ifdef FIO_HAVE_SOLARISAIO
676 { .ival = "solarisaio",
677 .help = "Solaris native asynchronous IO",
678 },
679#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100680 { .ival = "mmap",
681 .help = "Memory mapped IO",
682 },
683#ifdef FIO_HAVE_SPLICE
684 { .ival = "splice",
685 .help = "splice/vmsplice based IO",
686 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200687 { .ival = "netsplice",
688 .help = "splice/vmsplice to/from the network",
689 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100690#endif
691#ifdef FIO_HAVE_SGIO
692 { .ival = "sg",
693 .help = "SCSI generic v3 IO",
694 },
695#endif
696 { .ival = "null",
697 .help = "Testing engine (no data transfer)",
698 },
699 { .ival = "net",
700 .help = "Network IO",
701 },
702#ifdef FIO_HAVE_SYSLET
703 { .ival = "syslet-rw",
704 .help = "syslet enabled async pread/pwrite IO",
705 },
706#endif
707 { .ival = "cpuio",
708 .help = "CPU cycler burner engine",
709 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100710#ifdef FIO_HAVE_GUASI
711 { .ival = "guasi",
712 .help = "GUASI IO engine",
713 },
714#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100715 { .ival = "external",
716 .help = "Load external engine (append name)",
717 },
718 },
719 },
720 {
721 .name = "iodepth",
722 .type = FIO_OPT_INT,
723 .off1 = td_var_offset(iodepth),
724 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100725 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100726 .def = "1",
727 },
728 {
729 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200730 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100731 .type = FIO_OPT_INT,
732 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +0100733 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200734 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100735 .minval = 1,
736 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100737 },
738 {
Jens Axboe49504212008-06-05 09:03:30 +0200739 .name = "iodepth_batch_complete",
740 .type = FIO_OPT_INT,
741 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +0100742 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +0200743 .parent = "iodepth",
744 .minval = 0,
745 .def = "1",
746 },
747 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100748 .name = "iodepth_low",
749 .type = FIO_OPT_INT,
750 .off1 = td_var_offset(iodepth_low),
751 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200752 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100753 },
754 {
755 .name = "size",
756 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100757 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200758 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100759 .help = "Total size of device or files",
760 },
761 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100762 .name = "fill_device",
763 .type = FIO_OPT_BOOL,
764 .off1 = td_var_offset(fill_device),
765 .help = "Write until an ENOSPC error occurs",
766 .def = "0",
767 },
768 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100769 .name = "filesize",
770 .type = FIO_OPT_STR_VAL,
771 .off1 = td_var_offset(file_size_low),
772 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200773 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100774 .help = "Size of individual files",
775 },
776 {
Jens Axboe67a10002007-07-31 23:12:16 +0200777 .name = "offset",
778 .alias = "fileoffset",
779 .type = FIO_OPT_STR_VAL,
780 .off1 = td_var_offset(start_offset),
781 .help = "Start IO from this offset",
782 .def = "0",
783 },
784 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100785 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100786 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100787 .type = FIO_OPT_STR_VAL_INT,
788 .off1 = td_var_offset(bs[DDIR_READ]),
789 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200790 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100791 .help = "Block size unit",
792 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200793 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100794 },
795 {
796 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100797 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100798 .type = FIO_OPT_RANGE,
799 .off1 = td_var_offset(min_bs[DDIR_READ]),
800 .off2 = td_var_offset(max_bs[DDIR_READ]),
801 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
802 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200803 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100804 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200805 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100806 },
807 {
Jens Axboe564ca972007-12-14 12:21:19 +0100808 .name = "bssplit",
809 .type = FIO_OPT_STR,
810 .cb = str_bssplit_cb,
811 .help = "Set a specific mix of block sizes",
812 .parent = "rw",
813 },
814 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100815 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100816 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100817 .type = FIO_OPT_STR_SET,
818 .off1 = td_var_offset(bs_unaligned),
819 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200820 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100821 },
822 {
823 .name = "randrepeat",
824 .type = FIO_OPT_BOOL,
825 .off1 = td_var_offset(rand_repeatable),
826 .help = "Use repeatable random IO pattern",
827 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200828 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100829 },
830 {
831 .name = "norandommap",
832 .type = FIO_OPT_STR_SET,
833 .off1 = td_var_offset(norandommap),
834 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200835 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100836 },
837 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100838 .name = "softrandommap",
839 .type = FIO_OPT_BOOL,
840 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200841 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100842 .parent = "norandommap",
843 .def = "0",
844 },
845 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100846 .name = "nrfiles",
847 .type = FIO_OPT_INT,
848 .off1 = td_var_offset(nr_files),
849 .help = "Split job workload between this number of files",
850 .def = "1",
851 },
852 {
853 .name = "openfiles",
854 .type = FIO_OPT_INT,
855 .off1 = td_var_offset(open_files),
856 .help = "Number of files to keep open at the same time",
857 },
858 {
859 .name = "file_service_type",
860 .type = FIO_OPT_STR,
861 .cb = str_fst_cb,
862 .off1 = td_var_offset(file_service_type),
863 .help = "How to select which file to service next",
864 .def = "roundrobin",
865 .posval = {
866 { .ival = "random",
867 .oval = FIO_FSERVICE_RANDOM,
868 .help = "Choose a file at random",
869 },
870 { .ival = "roundrobin",
871 .oval = FIO_FSERVICE_RR,
872 .help = "Round robin select files",
873 },
Jens Axboea086c252009-03-04 08:27:37 +0100874 { .ival = "sequential",
875 .oval = FIO_FSERVICE_SEQ,
876 .help = "Finish one file before moving to the next",
877 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100878 },
Jens Axboe67a10002007-07-31 23:12:16 +0200879 .parent = "nrfiles",
880 },
881 {
882 .name = "fadvise_hint",
883 .type = FIO_OPT_BOOL,
884 .off1 = td_var_offset(fadvise_hint),
885 .help = "Use fadvise() to advise the kernel on IO pattern",
886 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100887 },
888 {
889 .name = "fsync",
890 .type = FIO_OPT_INT,
891 .off1 = td_var_offset(fsync_blocks),
892 .help = "Issue fsync for writes every given number of blocks",
893 .def = "0",
894 },
895 {
896 .name = "direct",
897 .type = FIO_OPT_BOOL,
898 .off1 = td_var_offset(odirect),
899 .help = "Use O_DIRECT IO (negates buffered)",
900 .def = "0",
901 },
902 {
903 .name = "buffered",
904 .type = FIO_OPT_BOOL,
905 .off1 = td_var_offset(odirect),
906 .neg = 1,
907 .help = "Use buffered IO (negates direct)",
908 .def = "1",
909 },
910 {
911 .name = "overwrite",
912 .type = FIO_OPT_BOOL,
913 .off1 = td_var_offset(overwrite),
914 .help = "When writing, set whether to overwrite current data",
915 .def = "0",
916 },
917 {
918 .name = "loops",
919 .type = FIO_OPT_INT,
920 .off1 = td_var_offset(loops),
921 .help = "Number of times to run the job",
922 .def = "1",
923 },
924 {
925 .name = "numjobs",
926 .type = FIO_OPT_INT,
927 .off1 = td_var_offset(numjobs),
928 .help = "Duplicate this job this many times",
929 .def = "1",
930 },
931 {
932 .name = "startdelay",
933 .type = FIO_OPT_INT,
934 .off1 = td_var_offset(start_delay),
935 .help = "Only start job when this period has passed",
936 .def = "0",
937 },
938 {
939 .name = "runtime",
940 .alias = "timeout",
941 .type = FIO_OPT_STR_VAL_TIME,
942 .off1 = td_var_offset(timeout),
943 .help = "Stop workload when this amount of time has passed",
944 .def = "0",
945 },
946 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200947 .name = "time_based",
948 .type = FIO_OPT_STR_SET,
949 .off1 = td_var_offset(time_based),
950 .help = "Keep running until runtime/timeout is met",
951 },
952 {
Jens Axboe721938a2008-09-10 09:46:16 +0200953 .name = "ramp_time",
954 .type = FIO_OPT_STR_VAL_TIME,
955 .off1 = td_var_offset(ramp_time),
956 .help = "Ramp up time before measuring performance",
957 },
958 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100959 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100960 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100961 .type = FIO_OPT_STR,
962 .cb = str_mem_cb,
963 .off1 = td_var_offset(mem_type),
964 .help = "Backing type for IO buffers",
965 .def = "malloc",
966 .posval = {
967 { .ival = "malloc",
968 .oval = MEM_MALLOC,
969 .help = "Use malloc(3) for IO buffers",
970 },
Jens Axboeb370e462007-03-19 10:51:49 +0100971 { .ival = "shm",
972 .oval = MEM_SHM,
973 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100974 },
975#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100976 { .ival = "shmhuge",
977 .oval = MEM_SHMHUGE,
978 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100979 },
980#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100981 { .ival = "mmap",
982 .oval = MEM_MMAP,
983 .help = "Use mmap(2) (file or anon) for IO buffers",
984 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100985#ifdef FIO_HAVE_HUGETLB
986 { .ival = "mmaphuge",
987 .oval = MEM_MMAPHUGE,
988 .help = "Like mmap, but use huge pages",
989 },
990#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100991 },
992 },
993 {
994 .name = "verify",
995 .type = FIO_OPT_STR,
996 .off1 = td_var_offset(verify),
997 .help = "Verify data written",
998 .def = "0",
999 .posval = {
1000 { .ival = "0",
1001 .oval = VERIFY_NONE,
1002 .help = "Don't do IO verification",
1003 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001004 { .ival = "md5",
1005 .oval = VERIFY_MD5,
1006 .help = "Use md5 checksums for verification",
1007 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001008 { .ival = "crc64",
1009 .oval = VERIFY_CRC64,
1010 .help = "Use crc64 checksums for verification",
1011 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001012 { .ival = "crc32",
1013 .oval = VERIFY_CRC32,
1014 .help = "Use crc32 checksums for verification",
1015 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001016 { .ival = "crc32c-intel",
1017 .oval = VERIFY_CRC32C_INTEL,
1018 .help = "Use hw crc32c checksums for verification",
1019 },
Jens Axboebac39e02008-06-11 20:46:19 +02001020 { .ival = "crc32c",
1021 .oval = VERIFY_CRC32C,
1022 .help = "Use crc32c checksums for verification",
1023 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001024 { .ival = "crc16",
1025 .oval = VERIFY_CRC16,
1026 .help = "Use crc16 checksums for verification",
1027 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001028 { .ival = "crc7",
1029 .oval = VERIFY_CRC7,
1030 .help = "Use crc7 checksums for verification",
1031 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001032 { .ival = "sha256",
1033 .oval = VERIFY_SHA256,
1034 .help = "Use sha256 checksums for verification",
1035 },
1036 { .ival = "sha512",
1037 .oval = VERIFY_SHA512,
1038 .help = "Use sha512 checksums for verification",
1039 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001040 { .ival = "meta",
1041 .oval = VERIFY_META,
1042 .help = "Use io information",
1043 },
Jens Axboe36690c92007-03-26 10:23:34 +02001044 {
1045 .ival = "null",
1046 .oval = VERIFY_NULL,
1047 .help = "Pretend to verify",
1048 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001049 },
1050 },
1051 {
Jens Axboe005c5652007-08-02 22:21:36 +02001052 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001053 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001054 .off1 = td_var_offset(do_verify),
1055 .help = "Run verification stage after write",
1056 .def = "1",
1057 .parent = "verify",
1058 },
1059 {
Jens Axboe160b9662007-03-27 10:59:49 +02001060 .name = "verifysort",
1061 .type = FIO_OPT_BOOL,
1062 .off1 = td_var_offset(verifysort),
1063 .help = "Sort written verify blocks for read back",
1064 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001065 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001066 },
1067 {
Jens Axboea59e1702007-07-30 08:53:27 +02001068 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001069 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001070 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001071 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001072 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001073 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001074 },
1075 {
Jens Axboea59e1702007-07-30 08:53:27 +02001076 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +02001077 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001078 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001079 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001080 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001081 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001082 },
1083 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001084 .name = "verify_pattern",
1085 .type = FIO_OPT_INT,
1086 .cb = str_verify_pattern_cb,
1087 .help = "Fill pattern for IO buffers",
1088 .parent = "verify",
1089 },
1090 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001091 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001092 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001093 .off1 = td_var_offset(verify_fatal),
1094 .def = "0",
1095 .help = "Exit on a single verify failure, don't continue",
1096 .parent = "verify",
1097 },
1098 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001099 .name = "write_iolog",
1100 .type = FIO_OPT_STR_STORE,
1101 .off1 = td_var_offset(write_iolog_file),
1102 .help = "Store IO pattern to file",
1103 },
1104 {
1105 .name = "read_iolog",
1106 .type = FIO_OPT_STR_STORE,
1107 .off1 = td_var_offset(read_iolog_file),
1108 .help = "Playback IO pattern from file",
1109 },
1110 {
1111 .name = "exec_prerun",
1112 .type = FIO_OPT_STR_STORE,
1113 .off1 = td_var_offset(exec_prerun),
1114 .help = "Execute this file prior to running job",
1115 },
1116 {
1117 .name = "exec_postrun",
1118 .type = FIO_OPT_STR_STORE,
1119 .off1 = td_var_offset(exec_postrun),
1120 .help = "Execute this file after running job",
1121 },
1122#ifdef FIO_HAVE_IOSCHED_SWITCH
1123 {
1124 .name = "ioscheduler",
1125 .type = FIO_OPT_STR_STORE,
1126 .off1 = td_var_offset(ioscheduler),
1127 .help = "Use this IO scheduler on the backing device",
1128 },
1129#endif
1130 {
1131 .name = "zonesize",
1132 .type = FIO_OPT_STR_VAL,
1133 .off1 = td_var_offset(zone_size),
1134 .help = "Give size of an IO zone",
1135 .def = "0",
1136 },
1137 {
1138 .name = "zoneskip",
1139 .type = FIO_OPT_STR_VAL,
1140 .off1 = td_var_offset(zone_skip),
1141 .help = "Space between IO zones",
1142 .def = "0",
1143 },
1144 {
1145 .name = "lockmem",
1146 .type = FIO_OPT_STR_VAL,
1147 .cb = str_lockmem_cb,
1148 .help = "Lock down this amount of memory",
1149 .def = "0",
1150 },
1151 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001152 .name = "rwmixread",
1153 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001154 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001155 .maxval = 100,
1156 .help = "Percentage of mixed workload that is reads",
1157 .def = "50",
1158 },
1159 {
1160 .name = "rwmixwrite",
1161 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001162 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001163 .maxval = 100,
1164 .help = "Percentage of mixed workload that is writes",
1165 .def = "50",
1166 },
1167 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001168 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001169 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001170 },
1171 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001172 .name = "nice",
1173 .type = FIO_OPT_INT,
1174 .off1 = td_var_offset(nice),
1175 .help = "Set job CPU nice value",
1176 .minval = -19,
1177 .maxval = 20,
1178 .def = "0",
1179 },
1180#ifdef FIO_HAVE_IOPRIO
1181 {
1182 .name = "prio",
1183 .type = FIO_OPT_INT,
1184 .cb = str_prio_cb,
1185 .help = "Set job IO priority value",
1186 .minval = 0,
1187 .maxval = 7,
1188 },
1189 {
1190 .name = "prioclass",
1191 .type = FIO_OPT_INT,
1192 .cb = str_prioclass_cb,
1193 .help = "Set job IO priority class",
1194 .minval = 0,
1195 .maxval = 3,
1196 },
1197#endif
1198 {
1199 .name = "thinktime",
1200 .type = FIO_OPT_INT,
1201 .off1 = td_var_offset(thinktime),
1202 .help = "Idle time between IO buffers (usec)",
1203 .def = "0",
1204 },
1205 {
1206 .name = "thinktime_spin",
1207 .type = FIO_OPT_INT,
1208 .off1 = td_var_offset(thinktime_spin),
1209 .help = "Start think time by spinning this amount (usec)",
1210 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001211 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001212 },
1213 {
1214 .name = "thinktime_blocks",
1215 .type = FIO_OPT_INT,
1216 .off1 = td_var_offset(thinktime_blocks),
1217 .help = "IO buffer period between 'thinktime'",
1218 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001219 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001220 },
1221 {
1222 .name = "rate",
1223 .type = FIO_OPT_INT,
1224 .off1 = td_var_offset(rate),
1225 .help = "Set bandwidth rate",
1226 },
1227 {
1228 .name = "ratemin",
1229 .type = FIO_OPT_INT,
1230 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001231 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001232 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001233 },
1234 {
1235 .name = "rate_iops",
1236 .type = FIO_OPT_INT,
1237 .off1 = td_var_offset(rate_iops),
1238 .help = "Limit IO used to this number of IO operations/sec",
1239 },
1240 {
1241 .name = "rate_iops_min",
1242 .type = FIO_OPT_INT,
1243 .off1 = td_var_offset(rate_iops_min),
1244 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001245 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001246 },
1247 {
1248 .name = "ratecycle",
1249 .type = FIO_OPT_INT,
1250 .off1 = td_var_offset(ratecycle),
1251 .help = "Window average for rate limits (msec)",
1252 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001253 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001254 },
1255 {
1256 .name = "invalidate",
1257 .type = FIO_OPT_BOOL,
1258 .off1 = td_var_offset(invalidate_cache),
1259 .help = "Invalidate buffer/page cache prior to running job",
1260 .def = "1",
1261 },
1262 {
1263 .name = "sync",
1264 .type = FIO_OPT_BOOL,
1265 .off1 = td_var_offset(sync_io),
1266 .help = "Use O_SYNC for buffered writes",
1267 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001268 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001269 },
1270 {
1271 .name = "bwavgtime",
1272 .type = FIO_OPT_INT,
1273 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001274 .help = "Time window over which to calculate bandwidth"
1275 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001276 .def = "500",
1277 },
1278 {
1279 .name = "create_serialize",
1280 .type = FIO_OPT_BOOL,
1281 .off1 = td_var_offset(create_serialize),
1282 .help = "Serialize creating of job files",
1283 .def = "1",
1284 },
1285 {
1286 .name = "create_fsync",
1287 .type = FIO_OPT_BOOL,
1288 .off1 = td_var_offset(create_fsync),
1289 .help = "Fsync file after creation",
1290 .def = "1",
1291 },
1292 {
1293 .name = "cpuload",
1294 .type = FIO_OPT_INT,
1295 .off1 = td_var_offset(cpuload),
1296 .help = "Use this percentage of CPU",
1297 },
1298 {
1299 .name = "cpuchunks",
1300 .type = FIO_OPT_INT,
1301 .off1 = td_var_offset(cpucycle),
1302 .help = "Length of the CPU burn cycles (usecs)",
1303 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001304 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001305 },
1306#ifdef FIO_HAVE_CPU_AFFINITY
1307 {
1308 .name = "cpumask",
1309 .type = FIO_OPT_INT,
1310 .cb = str_cpumask_cb,
1311 .help = "CPU affinity mask",
1312 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001313 {
1314 .name = "cpus_allowed",
1315 .type = FIO_OPT_STR,
1316 .cb = str_cpus_allowed_cb,
1317 .help = "Set CPUs allowed",
1318 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001319#endif
1320 {
1321 .name = "end_fsync",
1322 .type = FIO_OPT_BOOL,
1323 .off1 = td_var_offset(end_fsync),
1324 .help = "Include fsync at the end of job",
1325 .def = "0",
1326 },
1327 {
1328 .name = "fsync_on_close",
1329 .type = FIO_OPT_BOOL,
1330 .off1 = td_var_offset(fsync_on_close),
1331 .help = "fsync files on close",
1332 .def = "0",
1333 },
1334 {
1335 .name = "unlink",
1336 .type = FIO_OPT_BOOL,
1337 .off1 = td_var_offset(unlink),
1338 .help = "Unlink created files after job has completed",
1339 .def = "0",
1340 },
1341 {
1342 .name = "exitall",
1343 .type = FIO_OPT_STR_SET,
1344 .cb = str_exitall_cb,
1345 .help = "Terminate all jobs when one exits",
1346 },
1347 {
1348 .name = "stonewall",
1349 .type = FIO_OPT_STR_SET,
1350 .off1 = td_var_offset(stonewall),
1351 .help = "Insert a hard barrier between this job and previous",
1352 },
1353 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001354 .name = "new_group",
1355 .type = FIO_OPT_STR_SET,
1356 .off1 = td_var_offset(new_group),
1357 .help = "Mark the start of a new group (for reporting)",
1358 },
1359 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001360 .name = "thread",
1361 .type = FIO_OPT_STR_SET,
1362 .off1 = td_var_offset(use_thread),
1363 .help = "Use threads instead of forks",
1364 },
1365 {
1366 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001367 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001368 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001369 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001370 .help = "Write log of bandwidth during run",
1371 },
1372 {
1373 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001374 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001375 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001376 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001377 .help = "Write log of latency during run",
1378 },
1379 {
1380 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001381 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001382 .off1 = td_var_offset(hugepage_size),
1383 .help = "When using hugepages, specify size of each page",
1384 .def = __stringify(FIO_HUGE_PAGE),
1385 },
1386 {
1387 .name = "group_reporting",
1388 .type = FIO_OPT_STR_SET,
1389 .off1 = td_var_offset(group_reporting),
1390 .help = "Do reporting on a per-group basis",
1391 },
1392 {
Jens Axboee9459e52007-04-17 15:46:32 +02001393 .name = "zero_buffers",
1394 .type = FIO_OPT_STR_SET,
1395 .off1 = td_var_offset(zero_buffers),
1396 .help = "Init IO buffers to all zeroes",
1397 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001398 {
1399 .name = "refill_buffers",
1400 .type = FIO_OPT_STR_SET,
1401 .off1 = td_var_offset(refill_buffers),
1402 .help = "Refill IO buffers on every IO submit",
1403 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001404#ifdef FIO_HAVE_DISK_UTIL
1405 {
1406 .name = "disk_util",
1407 .type = FIO_OPT_BOOL,
1408 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001409 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001410 .def = "1",
1411 },
1412#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001413 {
Jens Axboe993bf482008-11-14 13:04:53 +01001414 .name = "gtod_reduce",
1415 .type = FIO_OPT_BOOL,
1416 .help = "Greatly reduce number of gettimeofday() calls",
1417 .cb = str_gtod_reduce_cb,
1418 .def = "0",
1419 },
1420 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001421 .name = "disable_clat",
1422 .type = FIO_OPT_BOOL,
1423 .off1 = td_var_offset(disable_clat),
1424 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001425 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001426 .def = "0",
1427 },
1428 {
1429 .name = "disable_slat",
1430 .type = FIO_OPT_BOOL,
1431 .off1 = td_var_offset(disable_slat),
1432 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001433 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001434 .def = "0",
1435 },
1436 {
1437 .name = "disable_bw_measurement",
1438 .type = FIO_OPT_BOOL,
1439 .off1 = td_var_offset(disable_bw),
1440 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001441 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001442 .def = "0",
1443 },
1444 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001445 .name = "gtod_cpu",
1446 .type = FIO_OPT_INT,
1447 .cb = str_gtod_cpu_cb,
1448 .help = "Setup dedicated gettimeofday() thread on this CPU",
1449 },
1450 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001451 .name = NULL,
1452 },
1453};
1454
1455void fio_options_dup_and_init(struct option *long_options)
1456{
1457 struct fio_option *o;
1458 unsigned int i;
1459
1460 options_init(options);
1461
1462 i = 0;
1463 while (long_options[i].name)
1464 i++;
1465
1466 o = &options[0];
1467 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001468 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001469 long_options[i].val = FIO_GETOPT_JOB;
1470 if (o->type == FIO_OPT_STR_SET)
1471 long_options[i].has_arg = no_argument;
1472 else
1473 long_options[i].has_arg = required_argument;
1474
1475 i++;
1476 o++;
1477 assert(i < FIO_NR_OPTIONS);
1478 }
1479}
1480
Jens Axboe3b8b7132008-06-10 19:46:23 +02001481int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001482{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001483 int i, ret;
1484
1485 sort_options(opts, options, num_opts);
1486
1487 for (ret = 0, i = 0; i < num_opts; i++)
1488 ret |= parse_option(opts[i], options, td);
1489
1490 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001491}
1492
1493int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1494{
1495 return parse_cmd_option(opt, val, options, td);
1496}
1497
1498void fio_fill_default_options(struct thread_data *td)
1499{
1500 fill_default_options(td, options);
1501}
1502
1503int fio_show_option_help(const char *opt)
1504{
1505 return show_cmd_help(options, opt);
1506}
Jens Axboed23bb322007-03-23 15:57:56 +01001507
1508static void __options_mem(struct thread_data *td, int alloc)
1509{
1510 struct thread_options *o = &td->o;
1511 struct fio_option *opt;
1512 char **ptr;
1513 int i;
1514
1515 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1516 if (opt->type != FIO_OPT_STR_STORE)
1517 continue;
1518
1519 ptr = (void *) o + opt->off1;
1520 if (*ptr) {
1521 if (alloc)
1522 *ptr = strdup(*ptr);
1523 else {
1524 free(*ptr);
1525 *ptr = NULL;
1526 }
1527 }
1528 }
1529}
1530
1531/*
1532 * dupe FIO_OPT_STR_STORE options
1533 */
1534void options_mem_dupe(struct thread_data *td)
1535{
1536 __options_mem(td, 1);
1537}
1538
Jens Axboe22d66212007-03-27 20:06:25 +02001539void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001540{
Jens Axboe22d66212007-03-27 20:06:25 +02001541#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001542 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001543#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001544}