blob: fd8ec93516148f829ecd8a98bad7b1285fb8b116 [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 Axboe214e1ec2007-03-15 10:48:13 +0100250
Jens Axboed2e268b2007-06-15 10:33:49 +0200251 CPU_ZERO(&td->o.cpumask);
Jens Axboeb03daaf2008-12-08 20:31:43 +0100252 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
Jens Axboed2e268b2007-06-15 10:33:49 +0200253
Jens Axboe62a72732008-12-08 11:37:01 +0100254 for (i = 0; i < sizeof(int) * 8; i++) {
255 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100256 if (i > max_cpu) {
257 log_err("fio: CPU %d too large (max=%ld)\n", i,
258 max_cpu);
259 return 1;
260 }
Jens Axboe62a72732008-12-08 11:37:01 +0100261 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboeb03daaf2008-12-08 20:31:43 +0100262 CPU_SET(i, &td->o.cpumask);
Jens Axboe62a72732008-12-08 11:37:01 +0100263 }
264 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200265
Jens Axboe375b2692007-05-22 09:13:02 +0200266 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100267 return 0;
268}
269
Jens Axboed2e268b2007-06-15 10:33:49 +0200270static int str_cpus_allowed_cb(void *data, const char *input)
271{
272 struct thread_data *td = data;
273 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100274 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100275 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200276
277 CPU_ZERO(&td->o.cpumask);
278
279 p = str = strdup(input);
280
281 strip_blank_front(&str);
282 strip_blank_end(str);
283
Jens Axboeb03daaf2008-12-08 20:31:43 +0100284 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
285
Jens Axboed2e268b2007-06-15 10:33:49 +0200286 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100287 char *str2, *cpu2;
288 int icpu, icpu2;
289
Jens Axboed2e268b2007-06-15 10:33:49 +0200290 if (!strlen(cpu))
291 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100292
293 str2 = cpu;
294 icpu2 = -1;
295 while ((cpu2 = strsep(&str2, "-")) != NULL) {
296 if (!strlen(cpu2))
297 break;
298
299 icpu2 = atoi(cpu2);
300 }
301
302 icpu = atoi(cpu);
303 if (icpu2 == -1)
304 icpu2 = icpu;
305 while (icpu <= icpu2) {
Jens Axboe19608d62008-12-08 15:03:12 +0100306 if (icpu >= CPU_SETSIZE) {
307 log_err("fio: your OS only supports up to"
308 " %d CPUs\n", (int) CPU_SETSIZE);
309 ret = 1;
310 break;
311 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100312 if (icpu > max_cpu) {
313 log_err("fio: CPU %d too large (max=%ld)\n",
314 icpu, max_cpu);
315 ret = 1;
316 break;
317 }
318
Jens Axboe62a72732008-12-08 11:37:01 +0100319 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
320 CPU_SET(atoi(cpu), &td->o.cpumask);
321 icpu++;
322 }
Jens Axboe19608d62008-12-08 15:03:12 +0100323 if (ret)
324 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200325 }
326
327 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100328 if (!ret)
329 td->o.cpumask_set = 1;
330 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200331}
332#endif
333
Jens Axboe214e1ec2007-03-15 10:48:13 +0100334static int str_fst_cb(void *data, const char *str)
335{
336 struct thread_data *td = data;
337 char *nr = get_opt_postfix(str);
338
339 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100340 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100341 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100342 free(nr);
343 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100344
345 return 0;
346}
347
Jens Axboe921c7662008-03-26 09:17:55 +0100348static int check_dir(struct thread_data *td, char *fname)
349{
350 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200351 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100352
Jens Axboebc838912008-04-07 09:00:54 +0200353 if (td->o.directory) {
354 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200355 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200356 elen = strlen(file);
357 }
358
Jens Axboefcef0b32008-05-26 14:53:24 +0200359 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100360 dir = dirname(file);
361
Jens Axboefcef0b32008-05-26 14:53:24 +0200362#if 0
363 {
364 struct stat sb;
365 /*
366 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
367 * yet, so we can't do this check right here...
368 */
Jens Axboe921c7662008-03-26 09:17:55 +0100369 if (lstat(dir, &sb) < 0) {
370 int ret = errno;
371
372 log_err("fio: %s is not a directory\n", dir);
373 td_verror(td, ret, "lstat");
374 return 1;
375 }
376
377 if (!S_ISDIR(sb.st_mode)) {
378 log_err("fio: %s is not a directory\n", dir);
379 return 1;
380 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200381 }
382#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100383
384 return 0;
385}
386
Jens Axboe214e1ec2007-03-15 10:48:13 +0100387static int str_filename_cb(void *data, const char *input)
388{
389 struct thread_data *td = data;
390 char *fname, *str, *p;
391
392 p = str = strdup(input);
393
394 strip_blank_front(&str);
395 strip_blank_end(str);
396
397 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100398 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100399
400 while ((fname = strsep(&str, ":")) != NULL) {
401 if (!strlen(fname))
402 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100403 if (check_dir(td, fname)) {
404 free(p);
405 return 1;
406 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100407 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100408 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100409 }
410
411 free(p);
412 return 0;
413}
414
415static int str_directory_cb(void *data, const char fio_unused *str)
416{
417 struct thread_data *td = data;
418 struct stat sb;
419
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100420 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100421 int ret = errno;
422
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100423 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100424 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100425 return 1;
426 }
427 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100428 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100429 return 1;
430 }
431
432 return 0;
433}
434
435static int str_opendir_cb(void *data, const char fio_unused *str)
436{
437 struct thread_data *td = data;
438
439 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100440 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100441
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100442 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100443}
444
Jens Axboea59e1702007-07-30 08:53:27 +0200445static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200446{
447 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200448
Shawn Lewis546a9142007-07-28 21:11:37 +0200449 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200450 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200451 return 1;
452 }
Jens Axboea59e1702007-07-30 08:53:27 +0200453
454 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200455 return 0;
456}
457
Shawn Lewise28218f2008-01-16 11:01:33 +0100458static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200459{
460 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100461 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200462
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200463 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200464 if (msb <= 8)
465 td->o.verify_pattern_bytes = 1;
466 else if (msb <= 16)
467 td->o.verify_pattern_bytes = 2;
468 else if (msb <= 24)
469 td->o.verify_pattern_bytes = 3;
470 else
471 td->o.verify_pattern_bytes = 4;
472
Shawn Lewise28218f2008-01-16 11:01:33 +0100473 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200474 return 0;
475}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100476
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100477static int str_lockfile_cb(void *data, const char *str)
478{
479 struct thread_data *td = data;
480 char *nr = get_opt_postfix(str);
481
482 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100483 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100484 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100485 free(nr);
486 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100487
488 return 0;
489}
490
Jens Axboee3cedca2008-11-19 19:57:52 +0100491static int str_write_bw_log_cb(void *data, const char *str)
492{
493 struct thread_data *td = data;
494
495 if (str)
496 td->o.bw_log_file = strdup(str);
497
498 td->o.write_bw_log = 1;
499 return 0;
500}
501
502static int str_write_lat_log_cb(void *data, const char *str)
503{
504 struct thread_data *td = data;
505
506 if (str)
507 td->o.lat_log_file = strdup(str);
508
509 td->o.write_lat_log = 1;
510 return 0;
511}
512
Jens Axboe993bf482008-11-14 13:04:53 +0100513static int str_gtod_reduce_cb(void *data, int *il)
514{
515 struct thread_data *td = data;
516 int val = *il;
517
518 td->o.disable_clat = !!val;
519 td->o.disable_slat = !!val;
520 td->o.disable_bw = !!val;
521 if (val)
522 td->tv_cache_mask = 63;
523
524 return 0;
525}
526
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100527static int str_gtod_cpu_cb(void *data, int *il)
528{
529 struct thread_data *td = data;
530 int val = *il;
531
532 td->o.gtod_cpu = val;
533 td->o.gtod_offload = 1;
534 return 0;
535}
536
Jens Axboe214e1ec2007-03-15 10:48:13 +0100537#define __stringify_1(x) #x
538#define __stringify(x) __stringify_1(x)
539
540/*
541 * Map of job/command line options
542 */
543static struct fio_option options[] = {
544 {
545 .name = "description",
546 .type = FIO_OPT_STR_STORE,
547 .off1 = td_var_offset(description),
548 .help = "Text job description",
549 },
550 {
551 .name = "name",
552 .type = FIO_OPT_STR_STORE,
553 .off1 = td_var_offset(name),
554 .help = "Name of this job",
555 },
556 {
557 .name = "directory",
558 .type = FIO_OPT_STR_STORE,
559 .off1 = td_var_offset(directory),
560 .cb = str_directory_cb,
561 .help = "Directory to store files in",
562 },
563 {
564 .name = "filename",
565 .type = FIO_OPT_STR_STORE,
566 .off1 = td_var_offset(filename),
567 .cb = str_filename_cb,
Jens Axboe3b8b7132008-06-10 19:46:23 +0200568 .prio = 1, /* must come before "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100569 .help = "File(s) to use for the workload",
570 },
571 {
Jens Axboe29c13492008-03-01 19:25:20 +0100572 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100573 .type = FIO_OPT_STR,
574 .cb = str_lockfile_cb,
575 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100576 .help = "Lock file when doing IO to it",
577 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100578 .def = "none",
579 .posval = {
580 { .ival = "none",
581 .oval = FILE_LOCK_NONE,
582 .help = "No file locking",
583 },
584 { .ival = "exclusive",
585 .oval = FILE_LOCK_EXCLUSIVE,
586 .help = "Exclusive file lock",
587 },
588 {
589 .ival = "readwrite",
590 .oval = FILE_LOCK_READWRITE,
591 .help = "Read vs write lock",
592 },
593 },
Jens Axboe29c13492008-03-01 19:25:20 +0100594 },
595 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100596 .name = "opendir",
597 .type = FIO_OPT_STR_STORE,
598 .off1 = td_var_offset(opendir),
599 .cb = str_opendir_cb,
600 .help = "Recursively add files from this directory and down",
601 },
602 {
603 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100604 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100605 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100606 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100607 .off1 = td_var_offset(td_ddir),
608 .help = "IO direction",
609 .def = "read",
610 .posval = {
611 { .ival = "read",
612 .oval = TD_DDIR_READ,
613 .help = "Sequential read",
614 },
615 { .ival = "write",
616 .oval = TD_DDIR_WRITE,
617 .help = "Sequential write",
618 },
619 { .ival = "randread",
620 .oval = TD_DDIR_RANDREAD,
621 .help = "Random read",
622 },
623 { .ival = "randwrite",
624 .oval = TD_DDIR_RANDWRITE,
625 .help = "Random write",
626 },
627 { .ival = "rw",
628 .oval = TD_DDIR_RW,
629 .help = "Sequential read and write mix",
630 },
631 { .ival = "randrw",
632 .oval = TD_DDIR_RANDRW,
633 .help = "Random read and write mix"
634 },
635 },
636 },
637 {
638 .name = "ioengine",
639 .type = FIO_OPT_STR_STORE,
640 .off1 = td_var_offset(ioengine),
641 .help = "IO engine to use",
642 .def = "sync",
643 .posval = {
644 { .ival = "sync",
645 .help = "Use read/write",
646 },
gurudas paia31041e2007-10-23 15:12:30 +0200647 { .ival = "psync",
648 .help = "Use pread/pwrite",
649 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100650 { .ival = "vsync",
651 .help = "Use readv/writev",
652 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100653#ifdef FIO_HAVE_LIBAIO
654 { .ival = "libaio",
655 .help = "Linux native asynchronous IO",
656 },
657#endif
658#ifdef FIO_HAVE_POSIXAIO
659 { .ival = "posixaio",
660 .help = "POSIX asynchronous IO",
661 },
662#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200663#ifdef FIO_HAVE_SOLARISAIO
664 { .ival = "solarisaio",
665 .help = "Solaris native asynchronous IO",
666 },
667#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100668 { .ival = "mmap",
669 .help = "Memory mapped IO",
670 },
671#ifdef FIO_HAVE_SPLICE
672 { .ival = "splice",
673 .help = "splice/vmsplice based IO",
674 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200675 { .ival = "netsplice",
676 .help = "splice/vmsplice to/from the network",
677 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100678#endif
679#ifdef FIO_HAVE_SGIO
680 { .ival = "sg",
681 .help = "SCSI generic v3 IO",
682 },
683#endif
684 { .ival = "null",
685 .help = "Testing engine (no data transfer)",
686 },
687 { .ival = "net",
688 .help = "Network IO",
689 },
690#ifdef FIO_HAVE_SYSLET
691 { .ival = "syslet-rw",
692 .help = "syslet enabled async pread/pwrite IO",
693 },
694#endif
695 { .ival = "cpuio",
696 .help = "CPU cycler burner engine",
697 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100698#ifdef FIO_HAVE_GUASI
699 { .ival = "guasi",
700 .help = "GUASI IO engine",
701 },
702#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100703 { .ival = "external",
704 .help = "Load external engine (append name)",
705 },
706 },
707 },
708 {
709 .name = "iodepth",
710 .type = FIO_OPT_INT,
711 .off1 = td_var_offset(iodepth),
712 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100713 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100714 .def = "1",
715 },
716 {
717 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200718 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100719 .type = FIO_OPT_INT,
720 .off1 = td_var_offset(iodepth_batch),
721 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200722 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100723 .minval = 1,
724 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100725 },
726 {
Jens Axboe49504212008-06-05 09:03:30 +0200727 .name = "iodepth_batch_complete",
728 .type = FIO_OPT_INT,
729 .off1 = td_var_offset(iodepth_batch_complete),
730 .help = "Number of IO to retrieve in one go",
731 .parent = "iodepth",
732 .minval = 0,
733 .def = "1",
734 },
735 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100736 .name = "iodepth_low",
737 .type = FIO_OPT_INT,
738 .off1 = td_var_offset(iodepth_low),
739 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200740 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100741 },
742 {
743 .name = "size",
744 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100745 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200746 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100747 .help = "Total size of device or files",
748 },
749 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100750 .name = "fill_device",
751 .type = FIO_OPT_BOOL,
752 .off1 = td_var_offset(fill_device),
753 .help = "Write until an ENOSPC error occurs",
754 .def = "0",
755 },
756 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100757 .name = "filesize",
758 .type = FIO_OPT_STR_VAL,
759 .off1 = td_var_offset(file_size_low),
760 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200761 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100762 .help = "Size of individual files",
763 },
764 {
Jens Axboe67a10002007-07-31 23:12:16 +0200765 .name = "offset",
766 .alias = "fileoffset",
767 .type = FIO_OPT_STR_VAL,
768 .off1 = td_var_offset(start_offset),
769 .help = "Start IO from this offset",
770 .def = "0",
771 },
772 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100773 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100774 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100775 .type = FIO_OPT_STR_VAL_INT,
776 .off1 = td_var_offset(bs[DDIR_READ]),
777 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200778 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100779 .help = "Block size unit",
780 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200781 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100782 },
783 {
784 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100785 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100786 .type = FIO_OPT_RANGE,
787 .off1 = td_var_offset(min_bs[DDIR_READ]),
788 .off2 = td_var_offset(max_bs[DDIR_READ]),
789 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
790 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200791 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100792 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200793 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100794 },
795 {
Jens Axboe564ca972007-12-14 12:21:19 +0100796 .name = "bssplit",
797 .type = FIO_OPT_STR,
798 .cb = str_bssplit_cb,
799 .help = "Set a specific mix of block sizes",
800 .parent = "rw",
801 },
802 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100803 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100804 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100805 .type = FIO_OPT_STR_SET,
806 .off1 = td_var_offset(bs_unaligned),
807 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200808 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100809 },
810 {
811 .name = "randrepeat",
812 .type = FIO_OPT_BOOL,
813 .off1 = td_var_offset(rand_repeatable),
814 .help = "Use repeatable random IO pattern",
815 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200816 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100817 },
818 {
819 .name = "norandommap",
820 .type = FIO_OPT_STR_SET,
821 .off1 = td_var_offset(norandommap),
822 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200823 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100824 },
825 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100826 .name = "softrandommap",
827 .type = FIO_OPT_BOOL,
828 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200829 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100830 .parent = "norandommap",
831 .def = "0",
832 },
833 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100834 .name = "nrfiles",
835 .type = FIO_OPT_INT,
836 .off1 = td_var_offset(nr_files),
837 .help = "Split job workload between this number of files",
838 .def = "1",
839 },
840 {
841 .name = "openfiles",
842 .type = FIO_OPT_INT,
843 .off1 = td_var_offset(open_files),
844 .help = "Number of files to keep open at the same time",
845 },
846 {
847 .name = "file_service_type",
848 .type = FIO_OPT_STR,
849 .cb = str_fst_cb,
850 .off1 = td_var_offset(file_service_type),
851 .help = "How to select which file to service next",
852 .def = "roundrobin",
853 .posval = {
854 { .ival = "random",
855 .oval = FIO_FSERVICE_RANDOM,
856 .help = "Choose a file at random",
857 },
858 { .ival = "roundrobin",
859 .oval = FIO_FSERVICE_RR,
860 .help = "Round robin select files",
861 },
862 },
Jens Axboe67a10002007-07-31 23:12:16 +0200863 .parent = "nrfiles",
864 },
865 {
866 .name = "fadvise_hint",
867 .type = FIO_OPT_BOOL,
868 .off1 = td_var_offset(fadvise_hint),
869 .help = "Use fadvise() to advise the kernel on IO pattern",
870 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100871 },
872 {
873 .name = "fsync",
874 .type = FIO_OPT_INT,
875 .off1 = td_var_offset(fsync_blocks),
876 .help = "Issue fsync for writes every given number of blocks",
877 .def = "0",
878 },
879 {
880 .name = "direct",
881 .type = FIO_OPT_BOOL,
882 .off1 = td_var_offset(odirect),
883 .help = "Use O_DIRECT IO (negates buffered)",
884 .def = "0",
885 },
886 {
887 .name = "buffered",
888 .type = FIO_OPT_BOOL,
889 .off1 = td_var_offset(odirect),
890 .neg = 1,
891 .help = "Use buffered IO (negates direct)",
892 .def = "1",
893 },
894 {
895 .name = "overwrite",
896 .type = FIO_OPT_BOOL,
897 .off1 = td_var_offset(overwrite),
898 .help = "When writing, set whether to overwrite current data",
899 .def = "0",
900 },
901 {
902 .name = "loops",
903 .type = FIO_OPT_INT,
904 .off1 = td_var_offset(loops),
905 .help = "Number of times to run the job",
906 .def = "1",
907 },
908 {
909 .name = "numjobs",
910 .type = FIO_OPT_INT,
911 .off1 = td_var_offset(numjobs),
912 .help = "Duplicate this job this many times",
913 .def = "1",
914 },
915 {
916 .name = "startdelay",
917 .type = FIO_OPT_INT,
918 .off1 = td_var_offset(start_delay),
919 .help = "Only start job when this period has passed",
920 .def = "0",
921 },
922 {
923 .name = "runtime",
924 .alias = "timeout",
925 .type = FIO_OPT_STR_VAL_TIME,
926 .off1 = td_var_offset(timeout),
927 .help = "Stop workload when this amount of time has passed",
928 .def = "0",
929 },
930 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200931 .name = "time_based",
932 .type = FIO_OPT_STR_SET,
933 .off1 = td_var_offset(time_based),
934 .help = "Keep running until runtime/timeout is met",
935 },
936 {
Jens Axboe721938a2008-09-10 09:46:16 +0200937 .name = "ramp_time",
938 .type = FIO_OPT_STR_VAL_TIME,
939 .off1 = td_var_offset(ramp_time),
940 .help = "Ramp up time before measuring performance",
941 },
942 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100943 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100944 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100945 .type = FIO_OPT_STR,
946 .cb = str_mem_cb,
947 .off1 = td_var_offset(mem_type),
948 .help = "Backing type for IO buffers",
949 .def = "malloc",
950 .posval = {
951 { .ival = "malloc",
952 .oval = MEM_MALLOC,
953 .help = "Use malloc(3) for IO buffers",
954 },
Jens Axboeb370e462007-03-19 10:51:49 +0100955 { .ival = "shm",
956 .oval = MEM_SHM,
957 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100958 },
959#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100960 { .ival = "shmhuge",
961 .oval = MEM_SHMHUGE,
962 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100963 },
964#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100965 { .ival = "mmap",
966 .oval = MEM_MMAP,
967 .help = "Use mmap(2) (file or anon) for IO buffers",
968 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100969#ifdef FIO_HAVE_HUGETLB
970 { .ival = "mmaphuge",
971 .oval = MEM_MMAPHUGE,
972 .help = "Like mmap, but use huge pages",
973 },
974#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100975 },
976 },
977 {
978 .name = "verify",
979 .type = FIO_OPT_STR,
980 .off1 = td_var_offset(verify),
981 .help = "Verify data written",
982 .def = "0",
983 .posval = {
984 { .ival = "0",
985 .oval = VERIFY_NONE,
986 .help = "Don't do IO verification",
987 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200988 { .ival = "md5",
989 .oval = VERIFY_MD5,
990 .help = "Use md5 checksums for verification",
991 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200992 { .ival = "crc64",
993 .oval = VERIFY_CRC64,
994 .help = "Use crc64 checksums for verification",
995 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100996 { .ival = "crc32",
997 .oval = VERIFY_CRC32,
998 .help = "Use crc32 checksums for verification",
999 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001000 { .ival = "crc32c-intel",
1001 .oval = VERIFY_CRC32C_INTEL,
1002 .help = "Use hw crc32c checksums for verification",
1003 },
Jens Axboebac39e02008-06-11 20:46:19 +02001004 { .ival = "crc32c",
1005 .oval = VERIFY_CRC32C,
1006 .help = "Use crc32c checksums for verification",
1007 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001008 { .ival = "crc16",
1009 .oval = VERIFY_CRC16,
1010 .help = "Use crc16 checksums for verification",
1011 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001012 { .ival = "crc7",
1013 .oval = VERIFY_CRC7,
1014 .help = "Use crc7 checksums for verification",
1015 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001016 { .ival = "sha256",
1017 .oval = VERIFY_SHA256,
1018 .help = "Use sha256 checksums for verification",
1019 },
1020 { .ival = "sha512",
1021 .oval = VERIFY_SHA512,
1022 .help = "Use sha512 checksums for verification",
1023 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001024 { .ival = "meta",
1025 .oval = VERIFY_META,
1026 .help = "Use io information",
1027 },
Jens Axboe36690c92007-03-26 10:23:34 +02001028 {
1029 .ival = "null",
1030 .oval = VERIFY_NULL,
1031 .help = "Pretend to verify",
1032 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001033 },
1034 },
1035 {
Jens Axboe005c5652007-08-02 22:21:36 +02001036 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001037 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001038 .off1 = td_var_offset(do_verify),
1039 .help = "Run verification stage after write",
1040 .def = "1",
1041 .parent = "verify",
1042 },
1043 {
Jens Axboe160b9662007-03-27 10:59:49 +02001044 .name = "verifysort",
1045 .type = FIO_OPT_BOOL,
1046 .off1 = td_var_offset(verifysort),
1047 .help = "Sort written verify blocks for read back",
1048 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001049 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001050 },
1051 {
Jens Axboea59e1702007-07-30 08:53:27 +02001052 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001053 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001054 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001055 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001056 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001057 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001058 },
1059 {
Jens Axboea59e1702007-07-30 08:53:27 +02001060 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +02001061 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001062 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001063 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001064 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001065 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001066 },
1067 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001068 .name = "verify_pattern",
1069 .type = FIO_OPT_INT,
1070 .cb = str_verify_pattern_cb,
1071 .help = "Fill pattern for IO buffers",
1072 .parent = "verify",
1073 },
1074 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001075 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001076 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001077 .off1 = td_var_offset(verify_fatal),
1078 .def = "0",
1079 .help = "Exit on a single verify failure, don't continue",
1080 .parent = "verify",
1081 },
1082 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001083 .name = "write_iolog",
1084 .type = FIO_OPT_STR_STORE,
1085 .off1 = td_var_offset(write_iolog_file),
1086 .help = "Store IO pattern to file",
1087 },
1088 {
1089 .name = "read_iolog",
1090 .type = FIO_OPT_STR_STORE,
1091 .off1 = td_var_offset(read_iolog_file),
1092 .help = "Playback IO pattern from file",
1093 },
1094 {
1095 .name = "exec_prerun",
1096 .type = FIO_OPT_STR_STORE,
1097 .off1 = td_var_offset(exec_prerun),
1098 .help = "Execute this file prior to running job",
1099 },
1100 {
1101 .name = "exec_postrun",
1102 .type = FIO_OPT_STR_STORE,
1103 .off1 = td_var_offset(exec_postrun),
1104 .help = "Execute this file after running job",
1105 },
1106#ifdef FIO_HAVE_IOSCHED_SWITCH
1107 {
1108 .name = "ioscheduler",
1109 .type = FIO_OPT_STR_STORE,
1110 .off1 = td_var_offset(ioscheduler),
1111 .help = "Use this IO scheduler on the backing device",
1112 },
1113#endif
1114 {
1115 .name = "zonesize",
1116 .type = FIO_OPT_STR_VAL,
1117 .off1 = td_var_offset(zone_size),
1118 .help = "Give size of an IO zone",
1119 .def = "0",
1120 },
1121 {
1122 .name = "zoneskip",
1123 .type = FIO_OPT_STR_VAL,
1124 .off1 = td_var_offset(zone_skip),
1125 .help = "Space between IO zones",
1126 .def = "0",
1127 },
1128 {
1129 .name = "lockmem",
1130 .type = FIO_OPT_STR_VAL,
1131 .cb = str_lockmem_cb,
1132 .help = "Lock down this amount of memory",
1133 .def = "0",
1134 },
1135 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001136 .name = "rwmixread",
1137 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001138 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001139 .maxval = 100,
1140 .help = "Percentage of mixed workload that is reads",
1141 .def = "50",
1142 },
1143 {
1144 .name = "rwmixwrite",
1145 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001146 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001147 .maxval = 100,
1148 .help = "Percentage of mixed workload that is writes",
1149 .def = "50",
1150 },
1151 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001152 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001153 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001154 },
1155 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001156 .name = "nice",
1157 .type = FIO_OPT_INT,
1158 .off1 = td_var_offset(nice),
1159 .help = "Set job CPU nice value",
1160 .minval = -19,
1161 .maxval = 20,
1162 .def = "0",
1163 },
1164#ifdef FIO_HAVE_IOPRIO
1165 {
1166 .name = "prio",
1167 .type = FIO_OPT_INT,
1168 .cb = str_prio_cb,
1169 .help = "Set job IO priority value",
1170 .minval = 0,
1171 .maxval = 7,
1172 },
1173 {
1174 .name = "prioclass",
1175 .type = FIO_OPT_INT,
1176 .cb = str_prioclass_cb,
1177 .help = "Set job IO priority class",
1178 .minval = 0,
1179 .maxval = 3,
1180 },
1181#endif
1182 {
1183 .name = "thinktime",
1184 .type = FIO_OPT_INT,
1185 .off1 = td_var_offset(thinktime),
1186 .help = "Idle time between IO buffers (usec)",
1187 .def = "0",
1188 },
1189 {
1190 .name = "thinktime_spin",
1191 .type = FIO_OPT_INT,
1192 .off1 = td_var_offset(thinktime_spin),
1193 .help = "Start think time by spinning this amount (usec)",
1194 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001195 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001196 },
1197 {
1198 .name = "thinktime_blocks",
1199 .type = FIO_OPT_INT,
1200 .off1 = td_var_offset(thinktime_blocks),
1201 .help = "IO buffer period between 'thinktime'",
1202 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001203 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001204 },
1205 {
1206 .name = "rate",
1207 .type = FIO_OPT_INT,
1208 .off1 = td_var_offset(rate),
1209 .help = "Set bandwidth rate",
1210 },
1211 {
1212 .name = "ratemin",
1213 .type = FIO_OPT_INT,
1214 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001215 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001216 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001217 },
1218 {
1219 .name = "rate_iops",
1220 .type = FIO_OPT_INT,
1221 .off1 = td_var_offset(rate_iops),
1222 .help = "Limit IO used to this number of IO operations/sec",
1223 },
1224 {
1225 .name = "rate_iops_min",
1226 .type = FIO_OPT_INT,
1227 .off1 = td_var_offset(rate_iops_min),
1228 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001229 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001230 },
1231 {
1232 .name = "ratecycle",
1233 .type = FIO_OPT_INT,
1234 .off1 = td_var_offset(ratecycle),
1235 .help = "Window average for rate limits (msec)",
1236 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001237 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001238 },
1239 {
1240 .name = "invalidate",
1241 .type = FIO_OPT_BOOL,
1242 .off1 = td_var_offset(invalidate_cache),
1243 .help = "Invalidate buffer/page cache prior to running job",
1244 .def = "1",
1245 },
1246 {
1247 .name = "sync",
1248 .type = FIO_OPT_BOOL,
1249 .off1 = td_var_offset(sync_io),
1250 .help = "Use O_SYNC for buffered writes",
1251 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001252 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001253 },
1254 {
1255 .name = "bwavgtime",
1256 .type = FIO_OPT_INT,
1257 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001258 .help = "Time window over which to calculate bandwidth"
1259 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001260 .def = "500",
1261 },
1262 {
1263 .name = "create_serialize",
1264 .type = FIO_OPT_BOOL,
1265 .off1 = td_var_offset(create_serialize),
1266 .help = "Serialize creating of job files",
1267 .def = "1",
1268 },
1269 {
1270 .name = "create_fsync",
1271 .type = FIO_OPT_BOOL,
1272 .off1 = td_var_offset(create_fsync),
1273 .help = "Fsync file after creation",
1274 .def = "1",
1275 },
1276 {
1277 .name = "cpuload",
1278 .type = FIO_OPT_INT,
1279 .off1 = td_var_offset(cpuload),
1280 .help = "Use this percentage of CPU",
1281 },
1282 {
1283 .name = "cpuchunks",
1284 .type = FIO_OPT_INT,
1285 .off1 = td_var_offset(cpucycle),
1286 .help = "Length of the CPU burn cycles (usecs)",
1287 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001288 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001289 },
1290#ifdef FIO_HAVE_CPU_AFFINITY
1291 {
1292 .name = "cpumask",
1293 .type = FIO_OPT_INT,
1294 .cb = str_cpumask_cb,
1295 .help = "CPU affinity mask",
1296 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001297 {
1298 .name = "cpus_allowed",
1299 .type = FIO_OPT_STR,
1300 .cb = str_cpus_allowed_cb,
1301 .help = "Set CPUs allowed",
1302 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001303#endif
1304 {
1305 .name = "end_fsync",
1306 .type = FIO_OPT_BOOL,
1307 .off1 = td_var_offset(end_fsync),
1308 .help = "Include fsync at the end of job",
1309 .def = "0",
1310 },
1311 {
1312 .name = "fsync_on_close",
1313 .type = FIO_OPT_BOOL,
1314 .off1 = td_var_offset(fsync_on_close),
1315 .help = "fsync files on close",
1316 .def = "0",
1317 },
1318 {
1319 .name = "unlink",
1320 .type = FIO_OPT_BOOL,
1321 .off1 = td_var_offset(unlink),
1322 .help = "Unlink created files after job has completed",
1323 .def = "0",
1324 },
1325 {
1326 .name = "exitall",
1327 .type = FIO_OPT_STR_SET,
1328 .cb = str_exitall_cb,
1329 .help = "Terminate all jobs when one exits",
1330 },
1331 {
1332 .name = "stonewall",
1333 .type = FIO_OPT_STR_SET,
1334 .off1 = td_var_offset(stonewall),
1335 .help = "Insert a hard barrier between this job and previous",
1336 },
1337 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001338 .name = "new_group",
1339 .type = FIO_OPT_STR_SET,
1340 .off1 = td_var_offset(new_group),
1341 .help = "Mark the start of a new group (for reporting)",
1342 },
1343 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001344 .name = "thread",
1345 .type = FIO_OPT_STR_SET,
1346 .off1 = td_var_offset(use_thread),
1347 .help = "Use threads instead of forks",
1348 },
1349 {
1350 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001351 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001352 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001353 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001354 .help = "Write log of bandwidth during run",
1355 },
1356 {
1357 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001358 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001359 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001360 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001361 .help = "Write log of latency during run",
1362 },
1363 {
1364 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001365 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001366 .off1 = td_var_offset(hugepage_size),
1367 .help = "When using hugepages, specify size of each page",
1368 .def = __stringify(FIO_HUGE_PAGE),
1369 },
1370 {
1371 .name = "group_reporting",
1372 .type = FIO_OPT_STR_SET,
1373 .off1 = td_var_offset(group_reporting),
1374 .help = "Do reporting on a per-group basis",
1375 },
1376 {
Jens Axboee9459e52007-04-17 15:46:32 +02001377 .name = "zero_buffers",
1378 .type = FIO_OPT_STR_SET,
1379 .off1 = td_var_offset(zero_buffers),
1380 .help = "Init IO buffers to all zeroes",
1381 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001382 {
1383 .name = "refill_buffers",
1384 .type = FIO_OPT_STR_SET,
1385 .off1 = td_var_offset(refill_buffers),
1386 .help = "Refill IO buffers on every IO submit",
1387 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001388#ifdef FIO_HAVE_DISK_UTIL
1389 {
1390 .name = "disk_util",
1391 .type = FIO_OPT_BOOL,
1392 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001393 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001394 .def = "1",
1395 },
1396#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001397 {
Jens Axboe993bf482008-11-14 13:04:53 +01001398 .name = "gtod_reduce",
1399 .type = FIO_OPT_BOOL,
1400 .help = "Greatly reduce number of gettimeofday() calls",
1401 .cb = str_gtod_reduce_cb,
1402 .def = "0",
1403 },
1404 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001405 .name = "disable_clat",
1406 .type = FIO_OPT_BOOL,
1407 .off1 = td_var_offset(disable_clat),
1408 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001409 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001410 .def = "0",
1411 },
1412 {
1413 .name = "disable_slat",
1414 .type = FIO_OPT_BOOL,
1415 .off1 = td_var_offset(disable_slat),
1416 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001417 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001418 .def = "0",
1419 },
1420 {
1421 .name = "disable_bw_measurement",
1422 .type = FIO_OPT_BOOL,
1423 .off1 = td_var_offset(disable_bw),
1424 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001425 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001426 .def = "0",
1427 },
1428 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001429 .name = "gtod_cpu",
1430 .type = FIO_OPT_INT,
1431 .cb = str_gtod_cpu_cb,
1432 .help = "Setup dedicated gettimeofday() thread on this CPU",
1433 },
1434 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001435 .name = NULL,
1436 },
1437};
1438
1439void fio_options_dup_and_init(struct option *long_options)
1440{
1441 struct fio_option *o;
1442 unsigned int i;
1443
1444 options_init(options);
1445
1446 i = 0;
1447 while (long_options[i].name)
1448 i++;
1449
1450 o = &options[0];
1451 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001452 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001453 long_options[i].val = FIO_GETOPT_JOB;
1454 if (o->type == FIO_OPT_STR_SET)
1455 long_options[i].has_arg = no_argument;
1456 else
1457 long_options[i].has_arg = required_argument;
1458
1459 i++;
1460 o++;
1461 assert(i < FIO_NR_OPTIONS);
1462 }
1463}
1464
Jens Axboe3b8b7132008-06-10 19:46:23 +02001465int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001466{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001467 int i, ret;
1468
1469 sort_options(opts, options, num_opts);
1470
1471 for (ret = 0, i = 0; i < num_opts; i++)
1472 ret |= parse_option(opts[i], options, td);
1473
1474 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001475}
1476
1477int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1478{
1479 return parse_cmd_option(opt, val, options, td);
1480}
1481
1482void fio_fill_default_options(struct thread_data *td)
1483{
1484 fill_default_options(td, options);
1485}
1486
1487int fio_show_option_help(const char *opt)
1488{
1489 return show_cmd_help(options, opt);
1490}
Jens Axboed23bb322007-03-23 15:57:56 +01001491
1492static void __options_mem(struct thread_data *td, int alloc)
1493{
1494 struct thread_options *o = &td->o;
1495 struct fio_option *opt;
1496 char **ptr;
1497 int i;
1498
1499 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1500 if (opt->type != FIO_OPT_STR_STORE)
1501 continue;
1502
1503 ptr = (void *) o + opt->off1;
1504 if (*ptr) {
1505 if (alloc)
1506 *ptr = strdup(*ptr);
1507 else {
1508 free(*ptr);
1509 *ptr = NULL;
1510 }
1511 }
1512 }
1513}
1514
1515/*
1516 * dupe FIO_OPT_STR_STORE options
1517 */
1518void options_mem_dupe(struct thread_data *td)
1519{
1520 __options_mem(td, 1);
1521}
1522
Jens Axboe22d66212007-03-27 20:06:25 +02001523void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001524{
Jens Axboe22d66212007-03-27 20:06:25 +02001525#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001526 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001527#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001528}