blob: 714741a038ae94e248357a3295cb78db155ec7d9 [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>
Jens Axboe214e1ec2007-03-15 10:48:13 +01006#include <assert.h>
Jens Axboe921c7662008-03-26 09:17:55 +01007#include <libgen.h>
Jens Axboe5921e802008-05-30 15:02:38 +02008#include <fcntl.h>
9#include <sys/types.h>
10#include <sys/stat.h>
Jens Axboe214e1ec2007-03-15 10:48:13 +010011
12#include "fio.h"
Jens Axboe4f5af7b2009-06-03 08:45:40 +020013#include "verify.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010014#include "parse.h"
Jens Axboeeef32352008-06-02 13:31:26 +020015#include "lib/fls.h"
Jens Axboe9f988e22010-03-04 10:42:38 +010016#include "options.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010017
Jens Axboe5d7c5d32010-06-21 15:08:17 +020018#include "crc/crc32c.h"
19
Jens Axboe214e1ec2007-03-15 10:48:13 +010020/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
Radha Ramachandran0e92f872009-10-27 20:14:27 +010036static int converthexchartoint(char a)
37{
38 int base;
39
40 switch(a) {
41 case '0'...'9':
42 base = '0';
43 break;
44 case 'A'...'F':
45 base = 'A' - 10;
46 break;
47 case 'a'...'f':
48 base = 'a' - 10;
49 break;
50 default:
51 base = 0;
52 }
53 return (a - base);
54}
55
Jens Axboe564ca972007-12-14 12:21:19 +010056static int bs_cmp(const void *p1, const void *p2)
57{
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
60
61 return bsp1->perc < bsp2->perc;
62}
63
Jens Axboe720e84a2009-04-21 08:29:55 +020064static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
Jens Axboe564ca972007-12-14 12:21:19 +010065{
Jens Axboe720e84a2009-04-21 08:29:55 +020066 struct bssplit *bssplit;
Jens Axboe564ca972007-12-14 12:21:19 +010067 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
69 long long val;
Jens Axboe720e84a2009-04-21 08:29:55 +020070 char *fname;
Jens Axboe564ca972007-12-14 12:21:19 +010071
Jens Axboe720e84a2009-04-21 08:29:55 +020072 td->o.bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010074
75 i = 0;
76 max_bs = 0;
77 min_bs = -1;
78 while ((fname = strsep(&str, ":")) != NULL) {
79 char *perc_str;
80
81 if (!strlen(fname))
82 break;
83
84 /*
85 * grow struct buffer, if needed
86 */
Jens Axboe720e84a2009-04-21 08:29:55 +020087 if (i == td->o.bssplit_nr[ddir]) {
88 td->o.bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
Jens Axboe5ec10ea2008-03-06 15:42:00 +010090 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010091 }
92
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
97 perc = atoi(perc_str);
98 if (perc > 100)
99 perc = 100;
100 else if (!perc)
101 perc = -1;
102 } else
103 perc = -1;
104
Jens Axboe6925dd32011-09-07 22:10:11 +0200105 if (str_to_decimal(fname, &val, 1, td)) {
Jens Axboe564ca972007-12-14 12:21:19 +0100106 log_err("fio: bssplit conversion failed\n");
107 free(td->o.bssplit);
108 return 1;
109 }
110
111 if (val > max_bs)
112 max_bs = val;
113 if (val < min_bs)
114 min_bs = val;
115
Jens Axboe720e84a2009-04-21 08:29:55 +0200116 bssplit[i].bs = val;
117 bssplit[i].perc = perc;
Jens Axboe564ca972007-12-14 12:21:19 +0100118 i++;
119 }
120
Jens Axboe720e84a2009-04-21 08:29:55 +0200121 td->o.bssplit_nr[ddir] = i;
Jens Axboe564ca972007-12-14 12:21:19 +0100122
123 /*
124 * Now check if the percentages add up, and how much is missing
125 */
126 perc = perc_missing = 0;
Jens Axboe720e84a2009-04-21 08:29:55 +0200127 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100129
130 if (bsp->perc == (unsigned char) -1)
131 perc_missing++;
132 else
133 perc += bsp->perc;
134 }
135
136 if (perc > 100) {
137 log_err("fio: bssplit percentages add to more than 100%%\n");
Jens Axboe720e84a2009-04-21 08:29:55 +0200138 free(bssplit);
Jens Axboe564ca972007-12-14 12:21:19 +0100139 return 1;
140 }
141 /*
142 * If values didn't have a percentage set, divide the remains between
143 * them.
144 */
145 if (perc_missing) {
Jens Axboe720e84a2009-04-21 08:29:55 +0200146 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100148
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
151 }
152 }
153
Jens Axboe720e84a2009-04-21 08:29:55 +0200154 td->o.min_bs[ddir] = min_bs;
155 td->o.max_bs[ddir] = max_bs;
Jens Axboe564ca972007-12-14 12:21:19 +0100156
157 /*
158 * now sort based on percentages, for ease of lookup
159 */
Jens Axboe720e84a2009-04-21 08:29:55 +0200160 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 td->o.bssplit[ddir] = bssplit;
162 return 0;
Jens Axboe720e84a2009-04-21 08:29:55 +0200163}
164
165static int str_bssplit_cb(void *data, const char *input)
166{
167 struct thread_data *td = data;
168 char *str, *p, *odir;
169 int ret = 0;
170
171 p = str = strdup(input);
172
173 strip_blank_front(&str);
174 strip_blank_end(str);
175
176 odir = strchr(str, ',');
177 if (odir) {
178 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
179 if (!ret) {
180 *odir = '\0';
181 ret = bssplit_ddir(td, DDIR_READ, str);
182 }
183 } else {
184 char *op;
185
186 op = strdup(str);
187
188 ret = bssplit_ddir(td, DDIR_READ, str);
189 if (!ret)
190 ret = bssplit_ddir(td, DDIR_WRITE, op);
191
192 free(op);
193 }
Jens Axboe564ca972007-12-14 12:21:19 +0100194
195 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200196 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100197}
198
Jens Axboe211097b2007-03-22 18:56:45 +0100199static int str_rw_cb(void *data, const char *str)
200{
201 struct thread_data *td = data;
202 char *nr = get_opt_postfix(str);
203
Jens Axboe5736c102010-07-20 12:03:25 -0600204 td->o.ddir_seq_nr = 1;
Jens Axboe059b0802011-08-25 09:09:37 +0200205 td->o.ddir_seq_add = 0;
206
207 if (!nr)
208 return 0;
209
210 if (td_random(td))
Jens Axboe5736c102010-07-20 12:03:25 -0600211 td->o.ddir_seq_nr = atoi(nr);
Jens Axboe059b0802011-08-25 09:09:37 +0200212 else {
213 long long val;
214
Jens Axboe6925dd32011-09-07 22:10:11 +0200215 if (str_to_decimal(nr, &val, 1, td)) {
Jens Axboe059b0802011-08-25 09:09:37 +0200216 log_err("fio: rw postfix parsing failed\n");
217 free(nr);
218 return 1;
219 }
220
221 td->o.ddir_seq_add = val;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100222 }
Jens Axboe211097b2007-03-22 18:56:45 +0100223
Jens Axboe059b0802011-08-25 09:09:37 +0200224 free(nr);
Jens Axboe211097b2007-03-22 18:56:45 +0100225 return 0;
226}
227
Jens Axboe214e1ec2007-03-15 10:48:13 +0100228static int str_mem_cb(void *data, const char *mem)
229{
230 struct thread_data *td = data;
231
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100232 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100233 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100234 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100235 log_err("fio: mmaphuge:/path/to/file\n");
236 return 1;
237 }
238 }
239
240 return 0;
241}
242
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200243static int str_verify_cb(void *data, const char *mem)
244{
245 struct thread_data *td = data;
246
Jens Axboee3aaafc2012-02-22 20:28:17 +0100247 if (td->o.verify == VERIFY_CRC32C_INTEL ||
248 td->o.verify == VERIFY_CRC32C) {
249 crc32c_intel_probe();
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200250 }
251
252 return 0;
253}
254
Jens Axboec223da82010-03-24 13:23:53 +0100255static int fio_clock_source_cb(void *data, const char *str)
256{
257 struct thread_data *td = data;
258
259 fio_clock_source = td->o.clocksource;
260 fio_time_init();
261 return 0;
262}
263
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400264static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100265{
266 mlock_size = *val;
267 return 0;
268}
269
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400270static int str_rwmix_read_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200271{
272 struct thread_data *td = data;
273
274 td->o.rwmix[DDIR_READ] = *val;
275 td->o.rwmix[DDIR_WRITE] = 100 - *val;
276 return 0;
277}
278
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400279static int str_rwmix_write_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200280{
281 struct thread_data *td = data;
282
283 td->o.rwmix[DDIR_WRITE] = *val;
284 td->o.rwmix[DDIR_READ] = 100 - *val;
285 return 0;
286}
287
Jens Axboe214e1ec2007-03-15 10:48:13 +0100288#ifdef FIO_HAVE_IOPRIO
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400289static int str_prioclass_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100290{
291 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200292 unsigned short mask;
293
294 /*
295 * mask off old class bits, str_prio_cb() may have set a default class
296 */
297 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
298 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100299
300 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100301 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100302 return 0;
303}
304
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400305static int str_prio_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100306{
307 struct thread_data *td = data;
308
309 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200310
311 /*
312 * If no class is set, assume BE
313 */
314 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
315 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
316
Jens Axboeac684782007-11-08 08:29:07 +0100317 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100318 return 0;
319}
320#endif
321
322static int str_exitall_cb(void)
323{
324 exitall_on_terminate = 1;
325 return 0;
326}
327
Jens Axboe214e1ec2007-03-15 10:48:13 +0100328#ifdef FIO_HAVE_CPU_AFFINITY
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400329static int str_cpumask_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100330{
331 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200332 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100333 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100334 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100335
Jens Axboed2ce18b2008-12-12 20:51:40 +0100336 ret = fio_cpuset_init(&td->o.cpumask);
337 if (ret < 0) {
338 log_err("fio: cpuset_init failed\n");
339 td_verror(td, ret, "fio_cpuset_init");
340 return 1;
341 }
342
Jens Axboec00a2282011-07-08 20:56:06 +0200343 max_cpu = cpus_online();
Jens Axboed2e268b2007-06-15 10:33:49 +0200344
Jens Axboe62a72732008-12-08 11:37:01 +0100345 for (i = 0; i < sizeof(int) * 8; i++) {
346 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100347 if (i > max_cpu) {
348 log_err("fio: CPU %d too large (max=%ld)\n", i,
349 max_cpu);
350 return 1;
351 }
Jens Axboe62a72732008-12-08 11:37:01 +0100352 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100353 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100354 }
355 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200356
Jens Axboe375b2692007-05-22 09:13:02 +0200357 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100358 return 0;
359}
360
Jens Axboee8462bd2009-07-06 12:59:04 +0200361static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
362 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200363{
Jens Axboed2e268b2007-06-15 10:33:49 +0200364 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100365 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100366 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200367
Jens Axboee8462bd2009-07-06 12:59:04 +0200368 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100369 if (ret < 0) {
370 log_err("fio: cpuset_init failed\n");
371 td_verror(td, ret, "fio_cpuset_init");
372 return 1;
373 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200374
375 p = str = strdup(input);
376
377 strip_blank_front(&str);
378 strip_blank_end(str);
379
Jens Axboec00a2282011-07-08 20:56:06 +0200380 max_cpu = cpus_online();
Jens Axboeb03daaf2008-12-08 20:31:43 +0100381
Jens Axboed2e268b2007-06-15 10:33:49 +0200382 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100383 char *str2, *cpu2;
384 int icpu, icpu2;
385
Jens Axboed2e268b2007-06-15 10:33:49 +0200386 if (!strlen(cpu))
387 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100388
389 str2 = cpu;
390 icpu2 = -1;
391 while ((cpu2 = strsep(&str2, "-")) != NULL) {
392 if (!strlen(cpu2))
393 break;
394
395 icpu2 = atoi(cpu2);
396 }
397
398 icpu = atoi(cpu);
399 if (icpu2 == -1)
400 icpu2 = icpu;
401 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100402 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100403 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100404 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100405 ret = 1;
406 break;
407 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100408 if (icpu > max_cpu) {
409 log_err("fio: CPU %d too large (max=%ld)\n",
410 icpu, max_cpu);
411 ret = 1;
412 break;
413 }
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200414
Jens Axboe62a72732008-12-08 11:37:01 +0100415 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200416 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100417 icpu++;
418 }
Jens Axboe19608d62008-12-08 15:03:12 +0100419 if (ret)
420 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200421 }
422
423 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100424 if (!ret)
425 td->o.cpumask_set = 1;
426 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200427}
Jens Axboee8462bd2009-07-06 12:59:04 +0200428
429static int str_cpus_allowed_cb(void *data, const char *input)
430{
431 struct thread_data *td = data;
432 int ret;
433
434 ret = set_cpus_allowed(td, &td->o.cpumask, input);
435 if (!ret)
436 td->o.cpumask_set = 1;
437
438 return ret;
439}
440
441static int str_verify_cpus_allowed_cb(void *data, const char *input)
442{
443 struct thread_data *td = data;
444 int ret;
445
446 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
447 if (!ret)
448 td->o.verify_cpumask_set = 1;
449
450 return ret;
451}
Jens Axboed2e268b2007-06-15 10:33:49 +0200452#endif
453
Jens Axboe0d29de82010-09-01 13:54:15 +0200454#ifdef FIO_HAVE_TRIM
455static int str_verify_trim_cb(void *data, unsigned long long *val)
456{
457 struct thread_data *td = data;
458
459 td->o.trim_percentage = *val;
460 return 0;
461}
462#endif
463
Jens Axboe214e1ec2007-03-15 10:48:13 +0100464static int str_fst_cb(void *data, const char *str)
465{
466 struct thread_data *td = data;
467 char *nr = get_opt_postfix(str);
468
469 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100470 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100471 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100472 free(nr);
473 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100474
475 return 0;
476}
477
Jens Axboe3ae06372010-03-19 19:17:15 +0100478#ifdef FIO_HAVE_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +0100479static int str_sfr_cb(void *data, const char *str)
480{
481 struct thread_data *td = data;
482 char *nr = get_opt_postfix(str);
483
484 td->sync_file_range_nr = 1;
485 if (nr) {
486 td->sync_file_range_nr = atoi(nr);
487 free(nr);
488 }
489
490 return 0;
491}
Jens Axboe3ae06372010-03-19 19:17:15 +0100492#endif
Jens Axboe44f29692010-03-09 20:09:44 +0100493
Jens Axboe921c7662008-03-26 09:17:55 +0100494static int check_dir(struct thread_data *td, char *fname)
495{
Jens Axboe3f0ca9b2011-05-24 21:36:24 +0200496#if 0
Jens Axboe921c7662008-03-26 09:17:55 +0100497 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200498 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100499
Jens Axboebc838912008-04-07 09:00:54 +0200500 if (td->o.directory) {
501 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200502 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200503 elen = strlen(file);
504 }
505
Jens Axboefcef0b32008-05-26 14:53:24 +0200506 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100507 dir = dirname(file);
508
Jens Axboefcef0b32008-05-26 14:53:24 +0200509 {
510 struct stat sb;
511 /*
512 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
513 * yet, so we can't do this check right here...
514 */
Jens Axboe921c7662008-03-26 09:17:55 +0100515 if (lstat(dir, &sb) < 0) {
516 int ret = errno;
517
518 log_err("fio: %s is not a directory\n", dir);
519 td_verror(td, ret, "lstat");
520 return 1;
521 }
522
523 if (!S_ISDIR(sb.st_mode)) {
524 log_err("fio: %s is not a directory\n", dir);
525 return 1;
526 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200527 }
528#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100529
530 return 0;
531}
532
Jens Axboe8e827d32009-08-04 09:51:48 +0200533/*
534 * Return next file in the string. Files are separated with ':'. If the ':'
535 * is escaped with a '\', then that ':' is part of the filename and does not
536 * indicate a new file.
537 */
538static char *get_next_file_name(char **ptr)
539{
540 char *str = *ptr;
541 char *p, *start;
542
543 if (!str || !strlen(str))
544 return NULL;
545
546 start = str;
547 do {
548 /*
549 * No colon, we are done
550 */
551 p = strchr(str, ':');
552 if (!p) {
553 *ptr = NULL;
554 break;
555 }
556
557 /*
558 * We got a colon, but it's the first character. Skip and
559 * continue
560 */
561 if (p == start) {
562 str = ++start;
563 continue;
564 }
565
566 if (*(p - 1) != '\\') {
567 *p = '\0';
568 *ptr = p + 1;
569 break;
570 }
571
572 memmove(p - 1, p, strlen(p) + 1);
573 str = p;
574 } while (1);
575
576 return start;
577}
578
Jens Axboe214e1ec2007-03-15 10:48:13 +0100579static int str_filename_cb(void *data, const char *input)
580{
581 struct thread_data *td = data;
582 char *fname, *str, *p;
583
584 p = str = strdup(input);
585
586 strip_blank_front(&str);
587 strip_blank_end(str);
588
589 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100590 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100591
Jens Axboe8e827d32009-08-04 09:51:48 +0200592 while ((fname = get_next_file_name(&str)) != NULL) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100593 if (!strlen(fname))
594 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100595 if (check_dir(td, fname)) {
596 free(p);
597 return 1;
598 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100599 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100600 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100601 }
602
603 free(p);
604 return 0;
605}
606
607static int str_directory_cb(void *data, const char fio_unused *str)
608{
609 struct thread_data *td = data;
610 struct stat sb;
611
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100612 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100613 int ret = errno;
614
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100615 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100616 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100617 return 1;
618 }
619 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100620 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100621 return 1;
622 }
623
624 return 0;
625}
626
627static int str_opendir_cb(void *data, const char fio_unused *str)
628{
629 struct thread_data *td = data;
630
631 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100632 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100633
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100634 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100635}
636
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400637static int str_verify_offset_cb(void *data, unsigned long long *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200638{
639 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200640
Shawn Lewis546a9142007-07-28 21:11:37 +0200641 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200642 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200643 return 1;
644 }
Jens Axboea59e1702007-07-30 08:53:27 +0200645
646 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200647 return 0;
648}
649
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100650static int str_verify_pattern_cb(void *data, const char *input)
Jens Axboe90059d62007-07-30 09:33:12 +0200651{
652 struct thread_data *td = data;
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100653 long off;
654 int i = 0, j = 0, len, k, base = 10;
655 char* loc1, * loc2;
Jens Axboe90059d62007-07-30 09:33:12 +0200656
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100657 loc1 = strstr(input, "0x");
658 loc2 = strstr(input, "0X");
659 if (loc1 || loc2)
660 base = 16;
661 off = strtol(input, NULL, base);
662 if (off != LONG_MAX || errno != ERANGE) {
663 while (off) {
664 td->o.verify_pattern[i] = off & 0xff;
665 off >>= 8;
666 i++;
667 }
668 } else {
669 len = strlen(input);
670 k = len - 1;
671 if (base == 16) {
672 if (loc1)
673 j = loc1 - input + 2;
674 else
675 j = loc2 - input + 2;
676 } else
677 return 1;
678 if (len - j < MAX_PATTERN_SIZE * 2) {
679 while (k >= j) {
680 off = converthexchartoint(input[k--]);
681 if (k >= j)
682 off += (converthexchartoint(input[k--])
683 * 16);
684 td->o.verify_pattern[i++] = (char) off;
685 }
686 }
687 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100688
689 /*
690 * Fill the pattern all the way to the end. This greatly reduces
691 * the number of memcpy's we have to do when verifying the IO.
692 */
693 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
694 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
695 i *= 2;
696 }
Steven Lang9a2a86d2012-02-07 09:42:59 +0100697 if (i == 1) {
698 /*
699 * The code in verify_io_u_pattern assumes a single byte pattern
700 * fills the whole verify pattern buffer.
701 */
702 memset(td->o.verify_pattern, td->o.verify_pattern[0],
703 MAX_PATTERN_SIZE);
704 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100705
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100706 td->o.verify_pattern_bytes = i;
Steven Langefcd9dc2012-02-02 20:22:04 +0100707
Jens Axboe92bf48d2011-01-14 21:20:42 +0100708 /*
709 * VERIFY_META could already be set
710 */
711 if (td->o.verify == VERIFY_NONE)
712 td->o.verify = VERIFY_PATTERN;
Steven Langefcd9dc2012-02-02 20:22:04 +0100713
Jens Axboe90059d62007-07-30 09:33:12 +0200714 return 0;
715}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100716
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100717static int str_lockfile_cb(void *data, const char *str)
718{
719 struct thread_data *td = data;
720 char *nr = get_opt_postfix(str);
721
722 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100723 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100724 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100725 free(nr);
726 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100727
728 return 0;
729}
730
Jens Axboee3cedca2008-11-19 19:57:52 +0100731static int str_write_bw_log_cb(void *data, const char *str)
732{
733 struct thread_data *td = data;
734
735 if (str)
736 td->o.bw_log_file = strdup(str);
737
738 td->o.write_bw_log = 1;
739 return 0;
740}
741
742static int str_write_lat_log_cb(void *data, const char *str)
743{
744 struct thread_data *td = data;
745
746 if (str)
747 td->o.lat_log_file = strdup(str);
748
749 td->o.write_lat_log = 1;
750 return 0;
751}
752
Jens Axboec8eeb9d2011-10-05 14:02:22 +0200753static int str_write_iops_log_cb(void *data, const char *str)
754{
755 struct thread_data *td = data;
756
757 if (str)
758 td->o.iops_log_file = strdup(str);
759
760 td->o.write_iops_log = 1;
761 return 0;
762}
763
Jens Axboe993bf482008-11-14 13:04:53 +0100764static int str_gtod_reduce_cb(void *data, int *il)
765{
766 struct thread_data *td = data;
767 int val = *il;
768
Jens Axboe02af0982010-06-24 09:59:34 +0200769 td->o.disable_lat = !!val;
Jens Axboe993bf482008-11-14 13:04:53 +0100770 td->o.disable_clat = !!val;
771 td->o.disable_slat = !!val;
772 td->o.disable_bw = !!val;
Jens Axboe0dc1bc02011-10-13 08:55:29 +0200773 td->o.clat_percentiles = !val;
Jens Axboe993bf482008-11-14 13:04:53 +0100774 if (val)
775 td->tv_cache_mask = 63;
776
777 return 0;
778}
779
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400780static int str_gtod_cpu_cb(void *data, long long *il)
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100781{
782 struct thread_data *td = data;
783 int val = *il;
784
785 td->o.gtod_cpu = val;
786 td->o.gtod_offload = 1;
787 return 0;
788}
789
Jens Axboe7bb59102011-07-12 19:47:03 +0200790static int str_size_cb(void *data, unsigned long long *__val)
791{
792 struct thread_data *td = data;
793 unsigned long long v = *__val;
794
795 if (parse_is_percent(v)) {
796 td->o.size = 0;
797 td->o.size_percent = -1ULL - v;
798 } else
799 td->o.size = v;
800
801 return 0;
802}
803
Jens Axboe896cac22009-07-01 10:38:35 +0200804static int rw_verify(struct fio_option *o, void *data)
805{
806 struct thread_data *td = data;
807
808 if (read_only && td_write(td)) {
809 log_err("fio: job <%s> has write bit set, but fio is in"
810 " read-only mode\n", td->o.name);
811 return 1;
812 }
813
814 return 0;
815}
816
Jens Axboe276ca4f2009-07-01 10:43:05 +0200817static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200818{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200819#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200820 struct thread_data *td = data;
821
Jens Axboe29d43ff2009-07-01 10:42:18 +0200822 if (td->o.gtod_cpu) {
823 log_err("fio: platform must support CPU affinity for"
824 "gettimeofday() offloading\n");
825 return 1;
826 }
827#endif
828
829 return 0;
830}
831
Jens Axboe90fef2d2009-07-17 22:33:32 +0200832static int kb_base_verify(struct fio_option *o, void *data)
833{
834 struct thread_data *td = data;
835
836 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
837 log_err("fio: kb_base set to nonsensical value: %u\n",
838 td->o.kb_base);
839 return 1;
840 }
841
842 return 0;
843}
844
Jens Axboe214e1ec2007-03-15 10:48:13 +0100845/*
846 * Map of job/command line options
847 */
Jens Axboe07b32322010-03-05 09:48:44 +0100848static struct fio_option options[FIO_MAX_OPTS] = {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100849 {
850 .name = "description",
851 .type = FIO_OPT_STR_STORE,
852 .off1 = td_var_offset(description),
853 .help = "Text job description",
Jens Axboec9c63312012-03-12 10:46:43 +0100854 .category = FIO_OPT_G_DESC,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100855 },
856 {
857 .name = "name",
858 .type = FIO_OPT_STR_STORE,
859 .off1 = td_var_offset(name),
860 .help = "Name of this job",
Jens Axboec9c63312012-03-12 10:46:43 +0100861 .category = FIO_OPT_G_DESC,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100862 },
863 {
864 .name = "directory",
865 .type = FIO_OPT_STR_STORE,
866 .off1 = td_var_offset(directory),
867 .cb = str_directory_cb,
868 .help = "Directory to store files in",
Jens Axboec9c63312012-03-12 10:46:43 +0100869 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100870 },
871 {
872 .name = "filename",
873 .type = FIO_OPT_STR_STORE,
874 .off1 = td_var_offset(filename),
875 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200876 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100877 .help = "File(s) to use for the workload",
Jens Axboec9c63312012-03-12 10:46:43 +0100878 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100879 },
880 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200881 .name = "kb_base",
882 .type = FIO_OPT_INT,
883 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200884 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200885 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200886 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200887 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboec9c63312012-03-12 10:46:43 +0100888 .category = FIO_OPT_G_MISC,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200889 },
890 {
Jens Axboe29c13492008-03-01 19:25:20 +0100891 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100892 .type = FIO_OPT_STR,
893 .cb = str_lockfile_cb,
894 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100895 .help = "Lock file when doing IO to it",
896 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100897 .def = "none",
Jens Axboec9c63312012-03-12 10:46:43 +0100898 .category = FIO_OPT_G_FILE,
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100899 .posval = {
900 { .ival = "none",
901 .oval = FILE_LOCK_NONE,
902 .help = "No file locking",
903 },
904 { .ival = "exclusive",
905 .oval = FILE_LOCK_EXCLUSIVE,
906 .help = "Exclusive file lock",
907 },
908 {
909 .ival = "readwrite",
910 .oval = FILE_LOCK_READWRITE,
911 .help = "Read vs write lock",
912 },
913 },
Jens Axboe29c13492008-03-01 19:25:20 +0100914 },
915 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100916 .name = "opendir",
917 .type = FIO_OPT_STR_STORE,
918 .off1 = td_var_offset(opendir),
919 .cb = str_opendir_cb,
920 .help = "Recursively add files from this directory and down",
Jens Axboec9c63312012-03-12 10:46:43 +0100921 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100922 },
923 {
924 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100925 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100926 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100927 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100928 .off1 = td_var_offset(td_ddir),
929 .help = "IO direction",
930 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +0200931 .verify = rw_verify,
Jens Axboec9c63312012-03-12 10:46:43 +0100932 .category = FIO_OPT_G_IO_DDIR,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100933 .posval = {
934 { .ival = "read",
935 .oval = TD_DDIR_READ,
936 .help = "Sequential read",
937 },
938 { .ival = "write",
939 .oval = TD_DDIR_WRITE,
940 .help = "Sequential write",
941 },
942 { .ival = "randread",
943 .oval = TD_DDIR_RANDREAD,
944 .help = "Random read",
945 },
946 { .ival = "randwrite",
947 .oval = TD_DDIR_RANDWRITE,
948 .help = "Random write",
949 },
950 { .ival = "rw",
951 .oval = TD_DDIR_RW,
952 .help = "Sequential read and write mix",
953 },
954 { .ival = "randrw",
955 .oval = TD_DDIR_RANDRW,
956 .help = "Random read and write mix"
957 },
958 },
959 },
960 {
Jens Axboe38dad622010-07-20 14:46:00 -0600961 .name = "rw_sequencer",
962 .type = FIO_OPT_STR,
963 .off1 = td_var_offset(rw_seq),
964 .help = "IO offset generator modifier",
965 .def = "sequential",
Jens Axboec9c63312012-03-12 10:46:43 +0100966 .category = FIO_OPT_G_IO_DDIR,
Jens Axboe38dad622010-07-20 14:46:00 -0600967 .posval = {
968 { .ival = "sequential",
969 .oval = RW_SEQ_SEQ,
970 .help = "Generate sequential offsets",
971 },
972 { .ival = "identical",
973 .oval = RW_SEQ_IDENT,
974 .help = "Generate identical offsets",
975 },
976 },
977 },
978
979 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100980 .name = "ioengine",
981 .type = FIO_OPT_STR_STORE,
982 .off1 = td_var_offset(ioengine),
983 .help = "IO engine to use",
Jens Axboe58483fa2011-01-19 11:09:58 -0700984 .def = FIO_PREFERRED_ENGINE,
Jens Axboec9c63312012-03-12 10:46:43 +0100985 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100986 .posval = {
987 { .ival = "sync",
988 .help = "Use read/write",
989 },
gurudas paia31041e2007-10-23 15:12:30 +0200990 { .ival = "psync",
991 .help = "Use pread/pwrite",
992 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100993 { .ival = "vsync",
Bruce Cran03e20d62011-01-02 20:14:54 +0100994 .help = "Use readv/writev",
Jens Axboe1d2af022008-02-04 10:59:07 +0100995 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100996#ifdef FIO_HAVE_LIBAIO
997 { .ival = "libaio",
998 .help = "Linux native asynchronous IO",
999 },
1000#endif
1001#ifdef FIO_HAVE_POSIXAIO
1002 { .ival = "posixaio",
1003 .help = "POSIX asynchronous IO",
1004 },
1005#endif
Jens Axboe417f0062008-06-02 11:59:30 +02001006#ifdef FIO_HAVE_SOLARISAIO
1007 { .ival = "solarisaio",
1008 .help = "Solaris native asynchronous IO",
1009 },
1010#endif
Bruce Cran03e20d62011-01-02 20:14:54 +01001011#ifdef FIO_HAVE_WINDOWSAIO
1012 { .ival = "windowsaio",
Jens Axboe3be80072011-01-19 11:07:28 -07001013 .help = "Windows native asynchronous IO"
Steven Langde890a12011-11-09 14:03:34 +01001014 },
Jens Axboe3be80072011-01-19 11:07:28 -07001015#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001016 { .ival = "mmap",
Bruce Cran03e20d62011-01-02 20:14:54 +01001017 .help = "Memory mapped IO"
Jens Axboe214e1ec2007-03-15 10:48:13 +01001018 },
1019#ifdef FIO_HAVE_SPLICE
1020 { .ival = "splice",
1021 .help = "splice/vmsplice based IO",
1022 },
Jens Axboe9cce02e2007-06-22 15:42:21 +02001023 { .ival = "netsplice",
1024 .help = "splice/vmsplice to/from the network",
1025 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001026#endif
1027#ifdef FIO_HAVE_SGIO
1028 { .ival = "sg",
1029 .help = "SCSI generic v3 IO",
1030 },
1031#endif
1032 { .ival = "null",
1033 .help = "Testing engine (no data transfer)",
1034 },
1035 { .ival = "net",
1036 .help = "Network IO",
1037 },
1038#ifdef FIO_HAVE_SYSLET
1039 { .ival = "syslet-rw",
1040 .help = "syslet enabled async pread/pwrite IO",
1041 },
1042#endif
1043 { .ival = "cpuio",
Bruce Cran03e20d62011-01-02 20:14:54 +01001044 .help = "CPU cycle burner engine",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001045 },
Jens Axboeb8c82a42007-03-21 08:48:26 +01001046#ifdef FIO_HAVE_GUASI
1047 { .ival = "guasi",
1048 .help = "GUASI IO engine",
1049 },
1050#endif
Jens Axboe79a43182010-09-07 13:28:58 +02001051#ifdef FIO_HAVE_BINJECT
1052 { .ival = "binject",
1053 .help = "binject direct inject block engine",
1054 },
1055#endif
ren yufei21b8aee2011-08-01 10:01:57 +02001056#ifdef FIO_HAVE_RDMA
1057 { .ival = "rdma",
1058 .help = "RDMA IO engine",
1059 },
1060#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001061 { .ival = "external",
1062 .help = "Load external engine (append name)",
1063 },
1064 },
1065 },
1066 {
1067 .name = "iodepth",
1068 .type = FIO_OPT_INT,
1069 .off1 = td_var_offset(iodepth),
Bruce Cran03e20d62011-01-02 20:14:54 +01001070 .help = "Number of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +01001071 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001072 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001073 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001074 },
1075 {
1076 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +02001077 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001078 .type = FIO_OPT_INT,
1079 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +01001080 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +02001081 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +01001082 .minval = 1,
1083 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001084 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001085 },
1086 {
Jens Axboe49504212008-06-05 09:03:30 +02001087 .name = "iodepth_batch_complete",
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +01001090 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +02001091 .parent = "iodepth",
1092 .minval = 0,
1093 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001094 .category = FIO_OPT_G_IO,
Jens Axboe49504212008-06-05 09:03:30 +02001095 },
1096 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001097 .name = "iodepth_low",
1098 .type = FIO_OPT_INT,
1099 .off1 = td_var_offset(iodepth_low),
1100 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +02001101 .parent = "iodepth",
Jens Axboec9c63312012-03-12 10:46:43 +01001102 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001103 },
1104 {
1105 .name = "size",
1106 .type = FIO_OPT_STR_VAL,
Jens Axboe7bb59102011-07-12 19:47:03 +02001107 .cb = str_size_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001108 .help = "Total size of device or files",
Jens Axboec9c63312012-03-12 10:46:43 +01001109 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001110 },
1111 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001112 .name = "fill_device",
Jens Axboe74586c12011-01-20 10:16:03 -07001113 .alias = "fill_fs",
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001114 .type = FIO_OPT_BOOL,
1115 .off1 = td_var_offset(fill_device),
1116 .help = "Write until an ENOSPC error occurs",
1117 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001118 .category = FIO_OPT_G_IO,
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001119 },
1120 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001121 .name = "filesize",
1122 .type = FIO_OPT_STR_VAL,
1123 .off1 = td_var_offset(file_size_low),
1124 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001125 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001126 .help = "Size of individual files",
Jens Axboec9c63312012-03-12 10:46:43 +01001127 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001128 },
1129 {
Jens Axboe67a10002007-07-31 23:12:16 +02001130 .name = "offset",
1131 .alias = "fileoffset",
1132 .type = FIO_OPT_STR_VAL,
1133 .off1 = td_var_offset(start_offset),
1134 .help = "Start IO from this offset",
1135 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001136 .category = FIO_OPT_G_IO,
Jens Axboe67a10002007-07-31 23:12:16 +02001137 },
1138 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001139 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001140 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +02001141 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001142 .off1 = td_var_offset(bs[DDIR_READ]),
1143 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001144 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001145 .help = "Block size unit",
1146 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +02001147 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001148 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001149 },
1150 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001151 .name = "ba",
1152 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +02001153 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001154 .off1 = td_var_offset(ba[DDIR_READ]),
1155 .off2 = td_var_offset(ba[DDIR_WRITE]),
1156 .minval = 1,
1157 .help = "IO block offset alignment",
1158 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001159 .category = FIO_OPT_G_IO | FIO_OPT_G_IO_BUF,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001160 },
1161 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001162 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001163 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001164 .type = FIO_OPT_RANGE,
1165 .off1 = td_var_offset(min_bs[DDIR_READ]),
1166 .off2 = td_var_offset(max_bs[DDIR_READ]),
1167 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1168 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001169 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001170 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +02001171 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001172 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001173 },
1174 {
Jens Axboe564ca972007-12-14 12:21:19 +01001175 .name = "bssplit",
1176 .type = FIO_OPT_STR,
1177 .cb = str_bssplit_cb,
1178 .help = "Set a specific mix of block sizes",
1179 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001180 .category = FIO_OPT_G_IO,
Jens Axboe564ca972007-12-14 12:21:19 +01001181 },
1182 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001183 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001184 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001185 .type = FIO_OPT_STR_SET,
1186 .off1 = td_var_offset(bs_unaligned),
1187 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +02001188 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001189 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001190 },
1191 {
1192 .name = "randrepeat",
1193 .type = FIO_OPT_BOOL,
1194 .off1 = td_var_offset(rand_repeatable),
1195 .help = "Use repeatable random IO pattern",
1196 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +02001197 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001198 .category = FIO_OPT_G_IO | FIO_OPT_G_RAND,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001199 },
1200 {
Jens Axboe2615cc42011-03-28 09:35:09 +02001201 .name = "use_os_rand",
1202 .type = FIO_OPT_BOOL,
1203 .off1 = td_var_offset(use_os_rand),
1204 .help = "Set to use OS random generator",
1205 .def = "0",
1206 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001207 .category = FIO_OPT_G_RAND,
Jens Axboe2615cc42011-03-28 09:35:09 +02001208 },
1209 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001210 .name = "norandommap",
1211 .type = FIO_OPT_STR_SET,
1212 .off1 = td_var_offset(norandommap),
1213 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +02001214 .parent = "rw",
Jens Axboec9c63312012-03-12 10:46:43 +01001215 .category = FIO_OPT_G_RAND,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001216 },
1217 {
Jens Axboe2b386d22008-03-26 10:32:57 +01001218 .name = "softrandommap",
1219 .type = FIO_OPT_BOOL,
1220 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001221 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +01001222 .parent = "norandommap",
1223 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001224 .category = FIO_OPT_G_RAND,
Jens Axboe2b386d22008-03-26 10:32:57 +01001225 },
1226 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001227 .name = "nrfiles",
Jens Axboed7c8be02010-11-25 08:21:39 +01001228 .alias = "nr_files",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001229 .type = FIO_OPT_INT,
1230 .off1 = td_var_offset(nr_files),
1231 .help = "Split job workload between this number of files",
1232 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001233 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001234 },
1235 {
1236 .name = "openfiles",
1237 .type = FIO_OPT_INT,
1238 .off1 = td_var_offset(open_files),
1239 .help = "Number of files to keep open at the same time",
Jens Axboec9c63312012-03-12 10:46:43 +01001240 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001241 },
1242 {
1243 .name = "file_service_type",
1244 .type = FIO_OPT_STR,
1245 .cb = str_fst_cb,
1246 .off1 = td_var_offset(file_service_type),
1247 .help = "How to select which file to service next",
1248 .def = "roundrobin",
Jens Axboec9c63312012-03-12 10:46:43 +01001249 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001250 .posval = {
1251 { .ival = "random",
1252 .oval = FIO_FSERVICE_RANDOM,
1253 .help = "Choose a file at random",
1254 },
1255 { .ival = "roundrobin",
1256 .oval = FIO_FSERVICE_RR,
1257 .help = "Round robin select files",
1258 },
Jens Axboea086c252009-03-04 08:27:37 +01001259 { .ival = "sequential",
1260 .oval = FIO_FSERVICE_SEQ,
1261 .help = "Finish one file before moving to the next",
1262 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001263 },
Jens Axboe67a10002007-07-31 23:12:16 +02001264 .parent = "nrfiles",
1265 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001266#ifdef FIO_HAVE_FALLOCATE
1267 {
1268 .name = "fallocate",
Eric Gourioua596f042011-06-17 09:11:45 +02001269 .type = FIO_OPT_STR,
1270 .off1 = td_var_offset(fallocate_mode),
1271 .help = "Whether pre-allocation is performed when laying out files",
1272 .def = "posix",
Jens Axboec9c63312012-03-12 10:46:43 +01001273 .category = FIO_OPT_G_FILE,
Eric Gourioua596f042011-06-17 09:11:45 +02001274 .posval = {
1275 { .ival = "none",
1276 .oval = FIO_FALLOCATE_NONE,
1277 .help = "Do not pre-allocate space",
1278 },
1279 { .ival = "posix",
1280 .oval = FIO_FALLOCATE_POSIX,
1281 .help = "Use posix_fallocate()",
1282 },
1283#ifdef FIO_HAVE_LINUX_FALLOCATE
1284 { .ival = "keep",
1285 .oval = FIO_FALLOCATE_KEEP_SIZE,
1286 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1287 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001288#endif
Eric Gourioua596f042011-06-17 09:11:45 +02001289 /* Compatibility with former boolean values */
1290 { .ival = "0",
1291 .oval = FIO_FALLOCATE_NONE,
1292 .help = "Alias for 'none'",
1293 },
1294 { .ival = "1",
1295 .oval = FIO_FALLOCATE_POSIX,
1296 .help = "Alias for 'posix'",
1297 },
1298 },
1299 },
1300#endif /* FIO_HAVE_FALLOCATE */
Jens Axboe67a10002007-07-31 23:12:16 +02001301 {
1302 .name = "fadvise_hint",
1303 .type = FIO_OPT_BOOL,
1304 .off1 = td_var_offset(fadvise_hint),
1305 .help = "Use fadvise() to advise the kernel on IO pattern",
1306 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001307 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001308 },
1309 {
1310 .name = "fsync",
1311 .type = FIO_OPT_INT,
1312 .off1 = td_var_offset(fsync_blocks),
1313 .help = "Issue fsync for writes every given number of blocks",
1314 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001315 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001316 },
1317 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001318 .name = "fdatasync",
1319 .type = FIO_OPT_INT,
1320 .off1 = td_var_offset(fdatasync_blocks),
1321 .help = "Issue fdatasync for writes every given number of blocks",
1322 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001323 .category = FIO_OPT_G_FILE,
Jens Axboe5f9099e2009-06-16 22:40:26 +02001324 },
Jens Axboe1ef2b6b2010-10-08 15:07:01 +02001325 {
1326 .name = "write_barrier",
1327 .type = FIO_OPT_INT,
1328 .off1 = td_var_offset(barrier_blocks),
1329 .help = "Make every Nth write a barrier write",
1330 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001331 .category = FIO_OPT_G_IO,
Jens Axboe1ef2b6b2010-10-08 15:07:01 +02001332 },
Jens Axboe44f29692010-03-09 20:09:44 +01001333#ifdef FIO_HAVE_SYNC_FILE_RANGE
1334 {
1335 .name = "sync_file_range",
1336 .posval = {
1337 { .ival = "wait_before",
1338 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1339 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001340 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001341 },
1342 { .ival = "write",
1343 .oval = SYNC_FILE_RANGE_WRITE,
1344 .help = "SYNC_FILE_RANGE_WRITE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001345 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001346 },
1347 {
1348 .ival = "wait_after",
1349 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1350 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
Jens Axboe3843deb2010-03-09 20:41:15 +01001351 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001352 },
1353 },
Jens Axboe3843deb2010-03-09 20:41:15 +01001354 .type = FIO_OPT_STR_MULTI,
Jens Axboe44f29692010-03-09 20:09:44 +01001355 .cb = str_sfr_cb,
1356 .off1 = td_var_offset(sync_file_range),
1357 .help = "Use sync_file_range()",
Jens Axboec9c63312012-03-12 10:46:43 +01001358 .category = FIO_OPT_G_FILE,
Jens Axboe44f29692010-03-09 20:09:44 +01001359 },
1360#endif
Jens Axboe5f9099e2009-06-16 22:40:26 +02001361 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001362 .name = "direct",
1363 .type = FIO_OPT_BOOL,
1364 .off1 = td_var_offset(odirect),
1365 .help = "Use O_DIRECT IO (negates buffered)",
1366 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001367 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001368 },
1369 {
1370 .name = "buffered",
1371 .type = FIO_OPT_BOOL,
1372 .off1 = td_var_offset(odirect),
1373 .neg = 1,
1374 .help = "Use buffered IO (negates direct)",
1375 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001376 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001377 },
1378 {
1379 .name = "overwrite",
1380 .type = FIO_OPT_BOOL,
1381 .off1 = td_var_offset(overwrite),
1382 .help = "When writing, set whether to overwrite current data",
1383 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001384 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001385 },
1386 {
1387 .name = "loops",
1388 .type = FIO_OPT_INT,
1389 .off1 = td_var_offset(loops),
1390 .help = "Number of times to run the job",
1391 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001392 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001393 },
1394 {
1395 .name = "numjobs",
1396 .type = FIO_OPT_INT,
1397 .off1 = td_var_offset(numjobs),
1398 .help = "Duplicate this job this many times",
1399 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001400 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001401 },
1402 {
1403 .name = "startdelay",
Jens Axboea5737c92010-06-29 10:40:30 +02001404 .type = FIO_OPT_STR_VAL_TIME,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001405 .off1 = td_var_offset(start_delay),
1406 .help = "Only start job when this period has passed",
1407 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001408 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001409 },
1410 {
1411 .name = "runtime",
1412 .alias = "timeout",
1413 .type = FIO_OPT_STR_VAL_TIME,
1414 .off1 = td_var_offset(timeout),
1415 .help = "Stop workload when this amount of time has passed",
1416 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001417 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001418 },
1419 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001420 .name = "time_based",
1421 .type = FIO_OPT_STR_SET,
1422 .off1 = td_var_offset(time_based),
1423 .help = "Keep running until runtime/timeout is met",
Jens Axboec9c63312012-03-12 10:46:43 +01001424 .category = FIO_OPT_G_MISC,
Jens Axboecf4464c2007-04-17 20:14:42 +02001425 },
1426 {
Jens Axboe721938a2008-09-10 09:46:16 +02001427 .name = "ramp_time",
1428 .type = FIO_OPT_STR_VAL_TIME,
1429 .off1 = td_var_offset(ramp_time),
1430 .help = "Ramp up time before measuring performance",
Jens Axboec9c63312012-03-12 10:46:43 +01001431 .category = FIO_OPT_G_MISC,
Jens Axboe721938a2008-09-10 09:46:16 +02001432 },
1433 {
Jens Axboec223da82010-03-24 13:23:53 +01001434 .name = "clocksource",
1435 .type = FIO_OPT_STR,
1436 .cb = fio_clock_source_cb,
1437 .off1 = td_var_offset(clocksource),
1438 .help = "What type of timing source to use",
Jens Axboec9c63312012-03-12 10:46:43 +01001439 .category = FIO_OPT_G_OS,
Jens Axboec223da82010-03-24 13:23:53 +01001440 .posval = {
1441 { .ival = "gettimeofday",
1442 .oval = CS_GTOD,
1443 .help = "Use gettimeofday(2) for timing",
1444 },
1445 { .ival = "clock_gettime",
1446 .oval = CS_CGETTIME,
1447 .help = "Use clock_gettime(2) for timing",
1448 },
1449#ifdef ARCH_HAVE_CPU_CLOCK
1450 { .ival = "cpu",
1451 .oval = CS_CPUCLOCK,
1452 .help = "Use CPU private clock",
1453 },
1454#endif
1455 },
1456 },
1457 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001458 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001459 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001460 .type = FIO_OPT_STR,
1461 .cb = str_mem_cb,
1462 .off1 = td_var_offset(mem_type),
1463 .help = "Backing type for IO buffers",
1464 .def = "malloc",
Jens Axboec9c63312012-03-12 10:46:43 +01001465 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001466 .posval = {
1467 { .ival = "malloc",
1468 .oval = MEM_MALLOC,
1469 .help = "Use malloc(3) for IO buffers",
1470 },
Jens Axboeb370e462007-03-19 10:51:49 +01001471 { .ival = "shm",
1472 .oval = MEM_SHM,
1473 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001474 },
1475#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001476 { .ival = "shmhuge",
1477 .oval = MEM_SHMHUGE,
1478 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001479 },
1480#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001481 { .ival = "mmap",
1482 .oval = MEM_MMAP,
1483 .help = "Use mmap(2) (file or anon) for IO buffers",
1484 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001485#ifdef FIO_HAVE_HUGETLB
1486 { .ival = "mmaphuge",
1487 .oval = MEM_MMAPHUGE,
1488 .help = "Like mmap, but use huge pages",
1489 },
1490#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001491 },
1492 },
1493 {
Jens Axboed529ee12009-07-01 10:33:03 +02001494 .name = "iomem_align",
1495 .alias = "mem_align",
1496 .type = FIO_OPT_INT,
1497 .off1 = td_var_offset(mem_align),
1498 .minval = 0,
1499 .help = "IO memory buffer offset alignment",
1500 .def = "0",
1501 .parent = "iomem",
Jens Axboec9c63312012-03-12 10:46:43 +01001502 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
Jens Axboed529ee12009-07-01 10:33:03 +02001503 },
1504 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001505 .name = "verify",
1506 .type = FIO_OPT_STR,
1507 .off1 = td_var_offset(verify),
1508 .help = "Verify data written",
Jens Axboe5d7c5d32010-06-21 15:08:17 +02001509 .cb = str_verify_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001510 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001511 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001512 .posval = {
1513 { .ival = "0",
1514 .oval = VERIFY_NONE,
1515 .help = "Don't do IO verification",
1516 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001517 { .ival = "md5",
1518 .oval = VERIFY_MD5,
1519 .help = "Use md5 checksums for verification",
1520 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001521 { .ival = "crc64",
1522 .oval = VERIFY_CRC64,
1523 .help = "Use crc64 checksums for verification",
1524 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001525 { .ival = "crc32",
1526 .oval = VERIFY_CRC32,
1527 .help = "Use crc32 checksums for verification",
1528 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001529 { .ival = "crc32c-intel",
Jens Axboee3aaafc2012-02-22 20:28:17 +01001530 .oval = VERIFY_CRC32C,
1531 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboeaf497e62008-08-04 15:40:35 +02001532 },
Jens Axboebac39e02008-06-11 20:46:19 +02001533 { .ival = "crc32c",
1534 .oval = VERIFY_CRC32C,
Jens Axboee3aaafc2012-02-22 20:28:17 +01001535 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboebac39e02008-06-11 20:46:19 +02001536 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001537 { .ival = "crc16",
1538 .oval = VERIFY_CRC16,
1539 .help = "Use crc16 checksums for verification",
1540 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001541 { .ival = "crc7",
1542 .oval = VERIFY_CRC7,
1543 .help = "Use crc7 checksums for verification",
1544 },
Jens Axboe7c353ce2009-08-09 22:40:33 +02001545 { .ival = "sha1",
1546 .oval = VERIFY_SHA1,
1547 .help = "Use sha1 checksums for verification",
1548 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001549 { .ival = "sha256",
1550 .oval = VERIFY_SHA256,
1551 .help = "Use sha256 checksums for verification",
1552 },
1553 { .ival = "sha512",
1554 .oval = VERIFY_SHA512,
1555 .help = "Use sha512 checksums for verification",
1556 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001557 { .ival = "meta",
1558 .oval = VERIFY_META,
1559 .help = "Use io information",
1560 },
Jens Axboe36690c92007-03-26 10:23:34 +02001561 {
1562 .ival = "null",
1563 .oval = VERIFY_NULL,
1564 .help = "Pretend to verify",
1565 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001566 },
1567 },
1568 {
Jens Axboe005c5652007-08-02 22:21:36 +02001569 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001570 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001571 .off1 = td_var_offset(do_verify),
1572 .help = "Run verification stage after write",
1573 .def = "1",
1574 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001575 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboe005c5652007-08-02 22:21:36 +02001576 },
1577 {
Jens Axboe160b9662007-03-27 10:59:49 +02001578 .name = "verifysort",
1579 .type = FIO_OPT_BOOL,
1580 .off1 = td_var_offset(verifysort),
1581 .help = "Sort written verify blocks for read back",
1582 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001583 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001584 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboe160b9662007-03-27 10:59:49 +02001585 },
1586 {
Jens Axboea59e1702007-07-30 08:53:27 +02001587 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001588 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001589 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001590 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001591 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001592 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001593 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001594 },
1595 {
Jens Axboea59e1702007-07-30 08:53:27 +02001596 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001597 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001598 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001599 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001600 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001601 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001602 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Shawn Lewis546a9142007-07-28 21:11:37 +02001603 },
1604 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001605 .name = "verify_pattern",
Radha Ramachandran0e92f872009-10-27 20:14:27 +01001606 .type = FIO_OPT_STR,
Shawn Lewise28218f2008-01-16 11:01:33 +01001607 .cb = str_verify_pattern_cb,
1608 .help = "Fill pattern for IO buffers",
1609 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001610 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Shawn Lewise28218f2008-01-16 11:01:33 +01001611 },
1612 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001613 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001614 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001615 .off1 = td_var_offset(verify_fatal),
1616 .def = "0",
1617 .help = "Exit on a single verify failure, don't continue",
1618 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001619 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
Jens Axboea12a3b42007-08-09 10:20:54 +02001620 },
1621 {
Jens Axboeb463e932011-01-12 09:03:23 +01001622 .name = "verify_dump",
1623 .type = FIO_OPT_BOOL,
1624 .off1 = td_var_offset(verify_dump),
Jens Axboeef71e312011-10-25 22:43:36 +02001625 .def = "0",
Jens Axboeb463e932011-01-12 09:03:23 +01001626 .help = "Dump contents of good and bad blocks on failure",
1627 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001628 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
Jens Axboeb463e932011-01-12 09:03:23 +01001629 },
1630 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001631 .name = "verify_async",
1632 .type = FIO_OPT_INT,
1633 .off1 = td_var_offset(verify_async),
1634 .def = "0",
1635 .help = "Number of async verifier threads to use",
1636 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001637 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboee8462bd2009-07-06 12:59:04 +02001638 },
Jens Axboe9e144182010-06-15 14:25:36 +02001639 {
1640 .name = "verify_backlog",
1641 .type = FIO_OPT_STR_VAL,
1642 .off1 = td_var_offset(verify_backlog),
1643 .help = "Verify after this number of blocks are written",
1644 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001645 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboe9e144182010-06-15 14:25:36 +02001646 },
1647 {
1648 .name = "verify_backlog_batch",
1649 .type = FIO_OPT_INT,
1650 .off1 = td_var_offset(verify_batch),
1651 .help = "Verify this number of IO blocks",
Jens Axboe0d29de82010-09-01 13:54:15 +02001652 .parent = "verify",
Jens Axboec9c63312012-03-12 10:46:43 +01001653 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
Jens Axboe9e144182010-06-15 14:25:36 +02001654 },
Jens Axboee8462bd2009-07-06 12:59:04 +02001655#ifdef FIO_HAVE_CPU_AFFINITY
1656 {
1657 .name = "verify_async_cpus",
1658 .type = FIO_OPT_STR,
1659 .cb = str_verify_cpus_allowed_cb,
1660 .help = "Set CPUs allowed for async verify threads",
1661 .parent = "verify_async",
Jens Axboec9c63312012-03-12 10:46:43 +01001662 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU | FIO_OPT_G_VERIFY,
Jens Axboee8462bd2009-07-06 12:59:04 +02001663 },
1664#endif
Jens Axboe0d29de82010-09-01 13:54:15 +02001665#ifdef FIO_HAVE_TRIM
1666 {
1667 .name = "trim_percentage",
1668 .type = FIO_OPT_INT,
1669 .cb = str_verify_trim_cb,
1670 .maxval = 100,
1671 .help = "Number of verify blocks to discard/trim",
1672 .parent = "verify",
1673 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001674 .category = FIO_OPT_G_IO,
Jens Axboe0d29de82010-09-01 13:54:15 +02001675 },
1676 {
1677 .name = "trim_verify_zero",
1678 .type = FIO_OPT_INT,
1679 .help = "Verify that trim/discarded blocks are returned as zeroes",
1680 .off1 = td_var_offset(trim_zero),
1681 .parent = "trim_percentage",
1682 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001683 .category = FIO_OPT_G_IO,
Jens Axboe0d29de82010-09-01 13:54:15 +02001684 },
1685 {
1686 .name = "trim_backlog",
1687 .type = FIO_OPT_STR_VAL,
1688 .off1 = td_var_offset(trim_backlog),
1689 .help = "Trim after this number of blocks are written",
1690 .parent = "trim_percentage",
Jens Axboec9c63312012-03-12 10:46:43 +01001691 .category = FIO_OPT_G_IO,
Jens Axboe0d29de82010-09-01 13:54:15 +02001692 },
1693 {
1694 .name = "trim_backlog_batch",
1695 .type = FIO_OPT_INT,
1696 .off1 = td_var_offset(trim_batch),
1697 .help = "Trim this number of IO blocks",
1698 .parent = "trim_percentage",
Jens Axboec9c63312012-03-12 10:46:43 +01001699 .category = FIO_OPT_G_IO,
Jens Axboe0d29de82010-09-01 13:54:15 +02001700 },
1701#endif
Jens Axboee8462bd2009-07-06 12:59:04 +02001702 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001703 .name = "write_iolog",
1704 .type = FIO_OPT_STR_STORE,
1705 .off1 = td_var_offset(write_iolog_file),
1706 .help = "Store IO pattern to file",
Jens Axboec9c63312012-03-12 10:46:43 +01001707 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001708 },
1709 {
1710 .name = "read_iolog",
1711 .type = FIO_OPT_STR_STORE,
1712 .off1 = td_var_offset(read_iolog_file),
1713 .help = "Playback IO pattern from file",
Jens Axboec9c63312012-03-12 10:46:43 +01001714 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001715 },
1716 {
David Nellans64bbb862010-08-24 22:13:30 +02001717 .name = "replay_no_stall",
1718 .type = FIO_OPT_INT,
1719 .off1 = td_var_offset(no_stall),
1720 .def = "0",
Jens Axboe87e7a972010-08-25 09:01:25 +02001721 .parent = "read_iolog",
David Nellans64bbb862010-08-24 22:13:30 +02001722 .help = "Playback IO pattern file as fast as possible without stalls",
Jens Axboec9c63312012-03-12 10:46:43 +01001723 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
David Nellans64bbb862010-08-24 22:13:30 +02001724 },
1725 {
David Nellansd1c46c02010-08-31 21:20:47 +02001726 .name = "replay_redirect",
1727 .type = FIO_OPT_STR_STORE,
1728 .off1 = td_var_offset(replay_redirect),
1729 .parent = "read_iolog",
1730 .help = "Replay all I/O onto this device, regardless of trace device",
Jens Axboec9c63312012-03-12 10:46:43 +01001731 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
David Nellansd1c46c02010-08-31 21:20:47 +02001732 },
1733 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001734 .name = "exec_prerun",
1735 .type = FIO_OPT_STR_STORE,
1736 .off1 = td_var_offset(exec_prerun),
1737 .help = "Execute this file prior to running job",
Jens Axboec9c63312012-03-12 10:46:43 +01001738 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001739 },
1740 {
1741 .name = "exec_postrun",
1742 .type = FIO_OPT_STR_STORE,
1743 .off1 = td_var_offset(exec_postrun),
1744 .help = "Execute this file after running job",
Jens Axboec9c63312012-03-12 10:46:43 +01001745 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001746 },
1747#ifdef FIO_HAVE_IOSCHED_SWITCH
1748 {
1749 .name = "ioscheduler",
1750 .type = FIO_OPT_STR_STORE,
1751 .off1 = td_var_offset(ioscheduler),
1752 .help = "Use this IO scheduler on the backing device",
Jens Axboec9c63312012-03-12 10:46:43 +01001753 .category = FIO_OPT_G_OS | FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001754 },
1755#endif
1756 {
1757 .name = "zonesize",
1758 .type = FIO_OPT_STR_VAL,
1759 .off1 = td_var_offset(zone_size),
Steven Noonaned335852012-01-31 13:58:00 +01001760 .help = "Amount of data to read per zone",
1761 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001762 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
Steven Noonaned335852012-01-31 13:58:00 +01001763 },
1764 {
1765 .name = "zonerange",
1766 .type = FIO_OPT_STR_VAL,
1767 .off1 = td_var_offset(zone_range),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001768 .help = "Give size of an IO zone",
1769 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001770 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001771 },
1772 {
1773 .name = "zoneskip",
1774 .type = FIO_OPT_STR_VAL,
1775 .off1 = td_var_offset(zone_skip),
1776 .help = "Space between IO zones",
1777 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001778 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001779 },
1780 {
1781 .name = "lockmem",
1782 .type = FIO_OPT_STR_VAL,
1783 .cb = str_lockmem_cb,
1784 .help = "Lock down this amount of memory",
1785 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001786 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001787 },
1788 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001789 .name = "rwmixread",
1790 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001791 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001792 .maxval = 100,
1793 .help = "Percentage of mixed workload that is reads",
1794 .def = "50",
Jens Axboec9c63312012-03-12 10:46:43 +01001795 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001796 },
1797 {
1798 .name = "rwmixwrite",
1799 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001800 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001801 .maxval = 100,
1802 .help = "Percentage of mixed workload that is writes",
1803 .def = "50",
Jens Axboec9c63312012-03-12 10:46:43 +01001804 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001805 },
1806 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001807 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001808 .type = FIO_OPT_DEPRECATED,
Jens Axboec9c63312012-03-12 10:46:43 +01001809 .category = FIO_OPT_G_IO,
Jens Axboeafdf9352007-07-31 16:14:34 +02001810 },
1811 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001812 .name = "nice",
1813 .type = FIO_OPT_INT,
1814 .off1 = td_var_offset(nice),
1815 .help = "Set job CPU nice value",
1816 .minval = -19,
1817 .maxval = 20,
1818 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001819 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001820 },
1821#ifdef FIO_HAVE_IOPRIO
1822 {
1823 .name = "prio",
1824 .type = FIO_OPT_INT,
1825 .cb = str_prio_cb,
1826 .help = "Set job IO priority value",
1827 .minval = 0,
1828 .maxval = 7,
Jens Axboec9c63312012-03-12 10:46:43 +01001829 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001830 },
1831 {
1832 .name = "prioclass",
1833 .type = FIO_OPT_INT,
1834 .cb = str_prioclass_cb,
1835 .help = "Set job IO priority class",
1836 .minval = 0,
1837 .maxval = 3,
Jens Axboec9c63312012-03-12 10:46:43 +01001838 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001839 },
1840#endif
1841 {
1842 .name = "thinktime",
1843 .type = FIO_OPT_INT,
1844 .off1 = td_var_offset(thinktime),
1845 .help = "Idle time between IO buffers (usec)",
1846 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001847 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001848 },
1849 {
1850 .name = "thinktime_spin",
1851 .type = FIO_OPT_INT,
1852 .off1 = td_var_offset(thinktime_spin),
1853 .help = "Start think time by spinning this amount (usec)",
1854 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001855 .parent = "thinktime",
Jens Axboec9c63312012-03-12 10:46:43 +01001856 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001857 },
1858 {
1859 .name = "thinktime_blocks",
1860 .type = FIO_OPT_INT,
1861 .off1 = td_var_offset(thinktime_blocks),
1862 .help = "IO buffer period between 'thinktime'",
1863 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001864 .parent = "thinktime",
Jens Axboec9c63312012-03-12 10:46:43 +01001865 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001866 },
1867 {
1868 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001869 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001870 .off1 = td_var_offset(rate[0]),
1871 .off2 = td_var_offset(rate[1]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001872 .help = "Set bandwidth rate",
Jens Axboec9c63312012-03-12 10:46:43 +01001873 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001874 },
1875 {
1876 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001877 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001878 .off1 = td_var_offset(ratemin[0]),
1879 .off2 = td_var_offset(ratemin[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001880 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001881 .parent = "rate",
Jens Axboec9c63312012-03-12 10:46:43 +01001882 .category = FIO_OPT_G_IO,
Jens Axboe4e991c22007-03-15 11:41:11 +01001883 },
1884 {
1885 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001886 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001887 .off1 = td_var_offset(rate_iops[0]),
1888 .off2 = td_var_offset(rate_iops[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001889 .help = "Limit IO used to this number of IO operations/sec",
Jens Axboec9c63312012-03-12 10:46:43 +01001890 .category = FIO_OPT_G_IO,
Jens Axboe4e991c22007-03-15 11:41:11 +01001891 },
1892 {
1893 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001894 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001895 .off1 = td_var_offset(rate_iops_min[0]),
1896 .off2 = td_var_offset(rate_iops_min[1]),
Bruce Cran03e20d62011-01-02 20:14:54 +01001897 .help = "Job must meet this rate or it will be shut down",
Jens Axboeafdf9352007-07-31 16:14:34 +02001898 .parent = "rate_iops",
Jens Axboec9c63312012-03-12 10:46:43 +01001899 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001900 },
1901 {
1902 .name = "ratecycle",
1903 .type = FIO_OPT_INT,
1904 .off1 = td_var_offset(ratecycle),
1905 .help = "Window average for rate limits (msec)",
1906 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001907 .parent = "rate",
Jens Axboec9c63312012-03-12 10:46:43 +01001908 .category = FIO_OPT_G_IO,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001909 },
1910 {
1911 .name = "invalidate",
1912 .type = FIO_OPT_BOOL,
1913 .off1 = td_var_offset(invalidate_cache),
1914 .help = "Invalidate buffer/page cache prior to running job",
1915 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001916 .category = FIO_OPT_G_IO | FIO_OPT_G_CACHE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001917 },
1918 {
1919 .name = "sync",
1920 .type = FIO_OPT_BOOL,
1921 .off1 = td_var_offset(sync_io),
1922 .help = "Use O_SYNC for buffered writes",
1923 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001924 .parent = "buffered",
Jens Axboec9c63312012-03-12 10:46:43 +01001925 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001926 },
1927 {
1928 .name = "bwavgtime",
1929 .type = FIO_OPT_INT,
1930 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001931 .help = "Time window over which to calculate bandwidth"
1932 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001933 .def = "500",
Jens Axboec8eeb9d2011-10-05 14:02:22 +02001934 .parent = "write_bw_log",
Jens Axboec9c63312012-03-12 10:46:43 +01001935 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
Jens Axboec8eeb9d2011-10-05 14:02:22 +02001936 },
1937 {
1938 .name = "iopsavgtime",
1939 .type = FIO_OPT_INT,
1940 .off1 = td_var_offset(iops_avg_time),
1941 .help = "Time window over which to calculate IOPS (msec)",
1942 .def = "500",
1943 .parent = "write_iops_log",
Jens Axboec9c63312012-03-12 10:46:43 +01001944 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001945 },
1946 {
1947 .name = "create_serialize",
1948 .type = FIO_OPT_BOOL,
1949 .off1 = td_var_offset(create_serialize),
1950 .help = "Serialize creating of job files",
1951 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001952 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001953 },
1954 {
1955 .name = "create_fsync",
1956 .type = FIO_OPT_BOOL,
1957 .off1 = td_var_offset(create_fsync),
Bruce Cran03e20d62011-01-02 20:14:54 +01001958 .help = "fsync file after creation",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001959 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01001960 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001961 },
1962 {
Jens Axboe814452b2009-03-04 12:53:13 +01001963 .name = "create_on_open",
1964 .type = FIO_OPT_BOOL,
1965 .off1 = td_var_offset(create_on_open),
1966 .help = "Create files when they are opened for IO",
1967 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001968 .category = FIO_OPT_G_FILE,
Jens Axboe814452b2009-03-04 12:53:13 +01001969 },
Jens Axboe0b9d69e2009-09-11 22:29:54 +02001970 {
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001971 .name = "pre_read",
1972 .type = FIO_OPT_BOOL,
1973 .off1 = td_var_offset(pre_read),
Bruce Cran03e20d62011-01-02 20:14:54 +01001974 .help = "Pre-read files before starting official testing",
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001975 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01001976 .category = FIO_OPT_G_FILE | FIO_OPT_G_CACHE,
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001977 },
Jens Axboe814452b2009-03-04 12:53:13 +01001978 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001979 .name = "cpuload",
1980 .type = FIO_OPT_INT,
1981 .off1 = td_var_offset(cpuload),
1982 .help = "Use this percentage of CPU",
Jens Axboec9c63312012-03-12 10:46:43 +01001983 .category = FIO_OPT_G_CPU,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001984 },
1985 {
1986 .name = "cpuchunks",
1987 .type = FIO_OPT_INT,
1988 .off1 = td_var_offset(cpucycle),
1989 .help = "Length of the CPU burn cycles (usecs)",
1990 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001991 .parent = "cpuload",
Jens Axboec9c63312012-03-12 10:46:43 +01001992 .category = FIO_OPT_G_CPU,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001993 },
1994#ifdef FIO_HAVE_CPU_AFFINITY
1995 {
1996 .name = "cpumask",
1997 .type = FIO_OPT_INT,
1998 .cb = str_cpumask_cb,
1999 .help = "CPU affinity mask",
Jens Axboec9c63312012-03-12 10:46:43 +01002000 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002001 },
Jens Axboed2e268b2007-06-15 10:33:49 +02002002 {
2003 .name = "cpus_allowed",
2004 .type = FIO_OPT_STR,
2005 .cb = str_cpus_allowed_cb,
2006 .help = "Set CPUs allowed",
Jens Axboec9c63312012-03-12 10:46:43 +01002007 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
Jens Axboed2e268b2007-06-15 10:33:49 +02002008 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01002009#endif
2010 {
2011 .name = "end_fsync",
2012 .type = FIO_OPT_BOOL,
2013 .off1 = td_var_offset(end_fsync),
2014 .help = "Include fsync at the end of job",
2015 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002016 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002017 },
2018 {
2019 .name = "fsync_on_close",
2020 .type = FIO_OPT_BOOL,
2021 .off1 = td_var_offset(fsync_on_close),
2022 .help = "fsync files on close",
2023 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002024 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002025 },
2026 {
2027 .name = "unlink",
2028 .type = FIO_OPT_BOOL,
2029 .off1 = td_var_offset(unlink),
2030 .help = "Unlink created files after job has completed",
2031 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002032 .category = FIO_OPT_G_FILE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002033 },
2034 {
2035 .name = "exitall",
2036 .type = FIO_OPT_STR_SET,
2037 .cb = str_exitall_cb,
2038 .help = "Terminate all jobs when one exits",
Jens Axboec9c63312012-03-12 10:46:43 +01002039 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002040 },
2041 {
2042 .name = "stonewall",
Jens Axboed3923652011-08-03 12:38:39 +02002043 .alias = "wait_for_previous",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002044 .type = FIO_OPT_STR_SET,
2045 .off1 = td_var_offset(stonewall),
2046 .help = "Insert a hard barrier between this job and previous",
Jens Axboec9c63312012-03-12 10:46:43 +01002047 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002048 },
2049 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01002050 .name = "new_group",
2051 .type = FIO_OPT_STR_SET,
2052 .off1 = td_var_offset(new_group),
2053 .help = "Mark the start of a new group (for reporting)",
Jens Axboec9c63312012-03-12 10:46:43 +01002054 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
Jens Axboeb3d62a72007-03-20 14:23:26 +01002055 },
2056 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002057 .name = "thread",
2058 .type = FIO_OPT_STR_SET,
2059 .off1 = td_var_offset(use_thread),
2060 .help = "Use threads instead of forks",
Jens Axboec9c63312012-03-12 10:46:43 +01002061 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS | FIO_OPT_G_JOB,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002062 },
2063 {
2064 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002065 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002066 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002067 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002068 .help = "Write log of bandwidth during run",
Jens Axboec9c63312012-03-12 10:46:43 +01002069 .category = FIO_OPT_G_LOG,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002070 },
2071 {
2072 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002073 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002074 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002075 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002076 .help = "Write log of latency during run",
Jens Axboec9c63312012-03-12 10:46:43 +01002077 .category = FIO_OPT_G_LOG,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002078 },
2079 {
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002080 .name = "write_iops_log",
2081 .type = FIO_OPT_STR,
2082 .off1 = td_var_offset(write_iops_log),
2083 .cb = str_write_iops_log_cb,
2084 .help = "Write log of IOPS during run",
Jens Axboec9c63312012-03-12 10:46:43 +01002085 .category = FIO_OPT_G_LOG,
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002086 },
2087 {
Jens Axboeb8bc8cb2011-12-01 09:04:31 +01002088 .name = "log_avg_msec",
2089 .type = FIO_OPT_INT,
2090 .off1 = td_var_offset(log_avg_msec),
2091 .help = "Average bw/iops/lat logs over this period of time",
2092 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002093 .category = FIO_OPT_G_LOG,
Jens Axboeb8bc8cb2011-12-01 09:04:31 +01002094 },
2095 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002096 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02002097 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002098 .off1 = td_var_offset(hugepage_size),
2099 .help = "When using hugepages, specify size of each page",
Jens Axboe81179ee2011-10-04 12:42:06 +02002100 .def = __fio_stringify(FIO_HUGE_PAGE),
Jens Axboec9c63312012-03-12 10:46:43 +01002101 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002102 },
2103 {
2104 .name = "group_reporting",
2105 .type = FIO_OPT_STR_SET,
2106 .off1 = td_var_offset(group_reporting),
2107 .help = "Do reporting on a per-group basis",
Jens Axboec9c63312012-03-12 10:46:43 +01002108 .category = FIO_OPT_G_MISC,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002109 },
2110 {
Jens Axboee9459e52007-04-17 15:46:32 +02002111 .name = "zero_buffers",
2112 .type = FIO_OPT_STR_SET,
2113 .off1 = td_var_offset(zero_buffers),
2114 .help = "Init IO buffers to all zeroes",
Jens Axboec9c63312012-03-12 10:46:43 +01002115 .category = FIO_OPT_G_IO_BUF,
Jens Axboee9459e52007-04-17 15:46:32 +02002116 },
Jens Axboe5973caf2008-05-21 19:52:35 +02002117 {
2118 .name = "refill_buffers",
2119 .type = FIO_OPT_STR_SET,
2120 .off1 = td_var_offset(refill_buffers),
2121 .help = "Refill IO buffers on every IO submit",
Jens Axboec9c63312012-03-12 10:46:43 +01002122 .category = FIO_OPT_G_IO_BUF,
Jens Axboe5973caf2008-05-21 19:52:35 +02002123 },
Yu-ju Hong83349192011-08-13 00:53:44 +02002124 {
Jens Axboefd684182011-09-19 09:24:44 +02002125 .name = "scramble_buffers",
2126 .type = FIO_OPT_BOOL,
2127 .off1 = td_var_offset(scramble_buffers),
2128 .help = "Slightly scramble buffers on every IO submit",
2129 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01002130 .category = FIO_OPT_G_IO_BUF,
Jens Axboefd684182011-09-19 09:24:44 +02002131 },
2132 {
Jens Axboe9c426842012-03-02 21:02:12 +01002133 .name = "buffer_compress_percentage",
2134 .type = FIO_OPT_INT,
2135 .off1 = td_var_offset(compress_percentage),
2136 .maxval = 100,
2137 .minval = 1,
2138 .help = "How compressible the buffer is (approximately)",
2139 },
2140 {
Jens Axboef97a43a2012-03-09 19:06:24 +01002141 .name = "buffer_compress_chunk",
2142 .type = FIO_OPT_INT,
2143 .off1 = td_var_offset(compress_chunk),
Jens Axboe207b18e2012-03-09 19:11:25 +01002144 .parent = "buffer_compress_percentage",
Jens Axboef97a43a2012-03-09 19:06:24 +01002145 .help = "Size of compressible region in buffer",
2146 },
2147 {
Yu-ju Hong83349192011-08-13 00:53:44 +02002148 .name = "clat_percentiles",
2149 .type = FIO_OPT_BOOL,
2150 .off1 = td_var_offset(clat_percentiles),
2151 .help = "Enable the reporting of completion latency percentiles",
Jens Axboe467b35e2011-10-13 08:53:24 +02002152 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01002153 .category = FIO_OPT_G_STAT,
Yu-ju Hong83349192011-08-13 00:53:44 +02002154 },
2155 {
2156 .name = "percentile_list",
2157 .type = FIO_OPT_FLOAT_LIST,
2158 .off1 = td_var_offset(percentile_list),
2159 .off2 = td_var_offset(overwrite_plist),
2160 .help = "Specify a custom list of percentiles to report",
2161 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2162 .minfp = 0.0,
2163 .maxfp = 100.0,
Jens Axboec9c63312012-03-12 10:46:43 +01002164 .category = FIO_OPT_G_STAT,
Yu-ju Hong83349192011-08-13 00:53:44 +02002165 },
2166
Jens Axboe0a839f32007-04-26 09:02:34 +02002167#ifdef FIO_HAVE_DISK_UTIL
2168 {
2169 .name = "disk_util",
2170 .type = FIO_OPT_BOOL,
2171 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02002172 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02002173 .def = "1",
Jens Axboec9c63312012-03-12 10:46:43 +01002174 .category = FIO_OPT_G_OS | FIO_OPT_G_STAT,
Jens Axboe0a839f32007-04-26 09:02:34 +02002175 },
2176#endif
Jens Axboee9459e52007-04-17 15:46:32 +02002177 {
Jens Axboe993bf482008-11-14 13:04:53 +01002178 .name = "gtod_reduce",
2179 .type = FIO_OPT_BOOL,
2180 .help = "Greatly reduce number of gettimeofday() calls",
2181 .cb = str_gtod_reduce_cb,
2182 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002183 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboe993bf482008-11-14 13:04:53 +01002184 },
2185 {
Jens Axboe02af0982010-06-24 09:59:34 +02002186 .name = "disable_lat",
2187 .type = FIO_OPT_BOOL,
2188 .off1 = td_var_offset(disable_lat),
2189 .help = "Disable latency numbers",
2190 .parent = "gtod_reduce",
2191 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002192 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboe02af0982010-06-24 09:59:34 +02002193 },
2194 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02002195 .name = "disable_clat",
2196 .type = FIO_OPT_BOOL,
2197 .off1 = td_var_offset(disable_clat),
2198 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002199 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002200 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002201 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboe9520ebb2008-10-16 21:03:27 +02002202 },
2203 {
2204 .name = "disable_slat",
2205 .type = FIO_OPT_BOOL,
2206 .off1 = td_var_offset(disable_slat),
Bruce Cran03e20d62011-01-02 20:14:54 +01002207 .help = "Disable submission latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002208 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002209 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002210 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboe9520ebb2008-10-16 21:03:27 +02002211 },
2212 {
2213 .name = "disable_bw_measurement",
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(disable_bw),
2216 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01002217 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002218 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002219 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboe9520ebb2008-10-16 21:03:27 +02002220 },
2221 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002222 .name = "gtod_cpu",
2223 .type = FIO_OPT_INT,
2224 .cb = str_gtod_cpu_cb,
Bruce Cran03e20d62011-01-02 20:14:54 +01002225 .help = "Set up dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02002226 .verify = gtod_cpu_verify,
Jens Axboec9c63312012-03-12 10:46:43 +01002227 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002228 },
2229 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002230 .name = "continue_on_error",
Steven Lang06842022011-11-17 09:45:17 +01002231 .type = FIO_OPT_STR,
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002232 .off1 = td_var_offset(continue_on_error),
Bruce Cran03e20d62011-01-02 20:14:54 +01002233 .help = "Continue on non-fatal errors during IO",
Steven Lang06842022011-11-17 09:45:17 +01002234 .def = "none",
Jens Axboec9c63312012-03-12 10:46:43 +01002235 .category = FIO_OPT_G_MISC | FIO_OPT_G_ERR,
Steven Lang06842022011-11-17 09:45:17 +01002236 .posval = {
2237 { .ival = "none",
2238 .oval = ERROR_TYPE_NONE,
2239 .help = "Exit when an error is encountered",
2240 },
2241 { .ival = "read",
2242 .oval = ERROR_TYPE_READ,
2243 .help = "Continue on read errors only",
2244 },
2245 { .ival = "write",
2246 .oval = ERROR_TYPE_WRITE,
2247 .help = "Continue on write errors only",
2248 },
2249 { .ival = "io",
2250 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2251 .help = "Continue on any IO errors",
2252 },
2253 { .ival = "verify",
2254 .oval = ERROR_TYPE_VERIFY,
2255 .help = "Continue on verify errors only",
2256 },
2257 { .ival = "all",
2258 .oval = ERROR_TYPE_ANY,
2259 .help = "Continue on all io and verify errors",
2260 },
2261 { .ival = "0",
2262 .oval = ERROR_TYPE_NONE,
2263 .help = "Alias for 'none'",
2264 },
2265 { .ival = "1",
2266 .oval = ERROR_TYPE_ANY,
2267 .help = "Alias for 'all'",
2268 },
2269 },
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002270 },
2271 {
Jens Axboe9ac8a792009-11-13 21:23:07 +01002272 .name = "profile",
Jens Axboe79d16312010-03-04 12:43:20 +01002273 .type = FIO_OPT_STR_STORE,
Jens Axboe9ac8a792009-11-13 21:23:07 +01002274 .off1 = td_var_offset(profile),
Jens Axboe9ac8a792009-11-13 21:23:07 +01002275 .help = "Select a specific builtin performance test",
Jens Axboec9c63312012-03-12 10:46:43 +01002276 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
Jens Axboe9ac8a792009-11-13 21:23:07 +01002277 },
2278 {
Jens Axboea696fa22009-12-04 10:05:02 +01002279 .name = "cgroup",
2280 .type = FIO_OPT_STR_STORE,
2281 .off1 = td_var_offset(cgroup),
2282 .help = "Add job to cgroup of this name",
Jens Axboec9c63312012-03-12 10:46:43 +01002283 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
Jens Axboea696fa22009-12-04 10:05:02 +01002284 },
2285 {
2286 .name = "cgroup_weight",
2287 .type = FIO_OPT_INT,
2288 .off1 = td_var_offset(cgroup_weight),
2289 .help = "Use given weight for cgroup",
2290 .minval = 100,
2291 .maxval = 1000,
Jens Axboec9c63312012-03-12 10:46:43 +01002292 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
Jens Axboea696fa22009-12-04 10:05:02 +01002293 },
2294 {
Vivek Goyal7de87092010-03-31 22:55:15 +02002295 .name = "cgroup_nodelete",
2296 .type = FIO_OPT_BOOL,
2297 .off1 = td_var_offset(cgroup_nodelete),
2298 .help = "Do not delete cgroups after job completion",
2299 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002300 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
Vivek Goyal7de87092010-03-31 22:55:15 +02002301 },
2302 {
Jens Axboee0b0d892009-12-08 10:10:14 +01002303 .name = "uid",
2304 .type = FIO_OPT_INT,
2305 .off1 = td_var_offset(uid),
2306 .help = "Run job with this user ID",
Jens Axboec9c63312012-03-12 10:46:43 +01002307 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
Jens Axboee0b0d892009-12-08 10:10:14 +01002308 },
2309 {
2310 .name = "gid",
2311 .type = FIO_OPT_INT,
2312 .off1 = td_var_offset(gid),
2313 .help = "Run job with this group ID",
Jens Axboec9c63312012-03-12 10:46:43 +01002314 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
Jens Axboee0b0d892009-12-08 10:10:14 +01002315 },
2316 {
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002317 .name = "flow_id",
2318 .type = FIO_OPT_INT,
2319 .off1 = td_var_offset(flow_id),
2320 .help = "The flow index ID to use",
2321 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002322 .category = FIO_OPT_G_IO,
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002323 },
2324 {
2325 .name = "flow",
2326 .type = FIO_OPT_INT,
2327 .off1 = td_var_offset(flow),
2328 .help = "Weight for flow control of this job",
2329 .parent = "flow_id",
2330 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002331 .category = FIO_OPT_G_IO,
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002332 },
2333 {
2334 .name = "flow_watermark",
2335 .type = FIO_OPT_INT,
2336 .off1 = td_var_offset(flow_watermark),
2337 .help = "High watermark for flow control. This option"
2338 " should be set to the same value for all threads"
2339 " with non-zero flow.",
2340 .parent = "flow_id",
2341 .def = "1024",
Jens Axboec9c63312012-03-12 10:46:43 +01002342 .category = FIO_OPT_G_IO,
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002343 },
2344 {
2345 .name = "flow_sleep",
2346 .type = FIO_OPT_INT,
2347 .off1 = td_var_offset(flow_sleep),
2348 .help = "How many microseconds to sleep after being held"
2349 " back by the flow control mechanism",
2350 .parent = "flow_id",
2351 .def = "0",
Jens Axboec9c63312012-03-12 10:46:43 +01002352 .category = FIO_OPT_G_IO,
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002353 },
2354 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002355 .name = NULL,
2356 },
2357};
2358
Jens Axboe17af15d2010-04-13 10:38:16 +02002359static void add_to_lopt(struct option *lopt, struct fio_option *o,
Steven Langde890a12011-11-09 14:03:34 +01002360 const char *name, int val)
Jens Axboe9f817362010-03-04 14:38:10 +01002361{
Jens Axboe17af15d2010-04-13 10:38:16 +02002362 lopt->name = (char *) name;
Steven Langde890a12011-11-09 14:03:34 +01002363 lopt->val = val;
Jens Axboe9f817362010-03-04 14:38:10 +01002364 if (o->type == FIO_OPT_STR_SET)
2365 lopt->has_arg = no_argument;
2366 else
2367 lopt->has_arg = required_argument;
2368}
2369
Steven Langde890a12011-11-09 14:03:34 +01002370static void options_to_lopts(struct fio_option *opts,
2371 struct option *long_options,
2372 int i, int option_type)
2373{
2374 struct fio_option *o = &opts[0];
2375 while (o->name) {
2376 add_to_lopt(&long_options[i], o, o->name, option_type);
2377 if (o->alias) {
2378 i++;
2379 add_to_lopt(&long_options[i], o, o->alias, option_type);
2380 }
2381
2382 i++;
2383 o++;
2384 assert(i < FIO_NR_OPTIONS);
2385 }
2386}
2387
2388void fio_options_set_ioengine_opts(struct option *long_options,
2389 struct thread_data *td)
2390{
2391 unsigned int i;
2392
2393 i = 0;
2394 while (long_options[i].name) {
2395 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2396 memset(&long_options[i], 0, sizeof(*long_options));
2397 break;
2398 }
2399 i++;
2400 }
2401
2402 /*
2403 * Just clear out the prior ioengine options.
2404 */
2405 if (!td || !td->eo)
2406 return;
2407
2408 options_to_lopts(td->io_ops->options, long_options, i,
2409 FIO_GETOPT_IOENGINE);
2410}
2411
Jens Axboe214e1ec2007-03-15 10:48:13 +01002412void fio_options_dup_and_init(struct option *long_options)
2413{
Jens Axboe214e1ec2007-03-15 10:48:13 +01002414 unsigned int i;
2415
2416 options_init(options);
2417
2418 i = 0;
2419 while (long_options[i].name)
2420 i++;
2421
Steven Langde890a12011-11-09 14:03:34 +01002422 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002423}
2424
Jens Axboe74929ac2009-08-05 11:42:37 +02002425struct fio_keyword {
2426 const char *word;
2427 const char *desc;
2428 char *replace;
2429};
2430
2431static struct fio_keyword fio_keywords[] = {
2432 {
2433 .word = "$pagesize",
2434 .desc = "Page size in the system",
2435 },
2436 {
2437 .word = "$mb_memory",
2438 .desc = "Megabytes of memory online",
2439 },
2440 {
2441 .word = "$ncpus",
2442 .desc = "Number of CPUs online in the system",
2443 },
2444 {
2445 .word = NULL,
2446 },
2447};
2448
2449void fio_keywords_init(void)
2450{
Jens Axboe3b2e1462009-12-15 08:58:10 +01002451 unsigned long long mb_memory;
Jens Axboe74929ac2009-08-05 11:42:37 +02002452 char buf[128];
2453 long l;
2454
2455 sprintf(buf, "%lu", page_size);
2456 fio_keywords[0].replace = strdup(buf);
2457
Jens Axboe8eb016d2011-07-11 10:24:20 +02002458 mb_memory = os_phys_mem() / (1024 * 1024);
Jens Axboe3b2e1462009-12-15 08:58:10 +01002459 sprintf(buf, "%llu", mb_memory);
Jens Axboe74929ac2009-08-05 11:42:37 +02002460 fio_keywords[1].replace = strdup(buf);
2461
Jens Axboec00a2282011-07-08 20:56:06 +02002462 l = cpus_online();
Jens Axboe74929ac2009-08-05 11:42:37 +02002463 sprintf(buf, "%lu", l);
2464 fio_keywords[2].replace = strdup(buf);
2465}
2466
Jens Axboe892a6ff2009-11-13 12:19:49 +01002467#define BC_APP "bc"
2468
2469static char *bc_calc(char *str)
2470{
Steven Langd0c814e2011-10-28 08:37:13 +02002471 char buf[128], *tmp;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002472 FILE *f;
2473 int ret;
2474
2475 /*
2476 * No math, just return string
2477 */
Steven Langd0c814e2011-10-28 08:37:13 +02002478 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2479 !strchr(str, '/')) || strchr(str, '\''))
Jens Axboe892a6ff2009-11-13 12:19:49 +01002480 return str;
2481
2482 /*
2483 * Split option from value, we only need to calculate the value
2484 */
2485 tmp = strchr(str, '=');
2486 if (!tmp)
2487 return str;
2488
2489 tmp++;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002490
Steven Langd0c814e2011-10-28 08:37:13 +02002491 /*
2492 * Prevent buffer overflows; such a case isn't reasonable anyway
2493 */
2494 if (strlen(str) >= 128 || strlen(tmp) > 100)
2495 return str;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002496
2497 sprintf(buf, "which %s > /dev/null", BC_APP);
2498 if (system(buf)) {
2499 log_err("fio: bc is needed for performing math\n");
Jens Axboe892a6ff2009-11-13 12:19:49 +01002500 return NULL;
2501 }
2502
Steven Langd0c814e2011-10-28 08:37:13 +02002503 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002504 f = popen(buf, "r");
2505 if (!f) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002506 return NULL;
2507 }
2508
Steven Langd0c814e2011-10-28 08:37:13 +02002509 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002510 if (ret <= 0) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002511 return NULL;
2512 }
2513
Jens Axboe892a6ff2009-11-13 12:19:49 +01002514 pclose(f);
Steven Langd0c814e2011-10-28 08:37:13 +02002515 buf[(tmp - str) + ret - 1] = '\0';
2516 memcpy(buf, str, tmp - str);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002517 free(str);
Steven Langd0c814e2011-10-28 08:37:13 +02002518 return strdup(buf);
2519}
2520
2521/*
2522 * Return a copy of the input string with substrings of the form ${VARNAME}
2523 * substituted with the value of the environment variable VARNAME. The
2524 * substitution always occurs, even if VARNAME is empty or the corresponding
2525 * environment variable undefined.
2526 */
2527static char *option_dup_subs(const char *opt)
2528{
2529 char out[OPT_LEN_MAX+1];
2530 char in[OPT_LEN_MAX+1];
2531 char *outptr = out;
2532 char *inptr = in;
2533 char *ch1, *ch2, *env;
2534 ssize_t nchr = OPT_LEN_MAX;
2535 size_t envlen;
2536
2537 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2538 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2539 return NULL;
2540 }
2541
2542 in[OPT_LEN_MAX] = '\0';
2543 strncpy(in, opt, OPT_LEN_MAX);
2544
2545 while (*inptr && nchr > 0) {
2546 if (inptr[0] == '$' && inptr[1] == '{') {
2547 ch2 = strchr(inptr, '}');
2548 if (ch2 && inptr+1 < ch2) {
2549 ch1 = inptr+2;
2550 inptr = ch2+1;
2551 *ch2 = '\0';
2552
2553 env = getenv(ch1);
2554 if (env) {
2555 envlen = strlen(env);
2556 if (envlen <= nchr) {
2557 memcpy(outptr, env, envlen);
2558 outptr += envlen;
2559 nchr -= envlen;
2560 }
2561 }
2562
2563 continue;
2564 }
2565 }
2566
2567 *outptr++ = *inptr++;
2568 --nchr;
2569 }
2570
2571 *outptr = '\0';
2572 return strdup(out);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002573}
2574
Jens Axboe74929ac2009-08-05 11:42:37 +02002575/*
2576 * Look for reserved variable names and replace them with real values
2577 */
2578static char *fio_keyword_replace(char *opt)
2579{
2580 char *s;
2581 int i;
Steven Langd0c814e2011-10-28 08:37:13 +02002582 int docalc = 0;
Jens Axboe74929ac2009-08-05 11:42:37 +02002583
2584 for (i = 0; fio_keywords[i].word != NULL; i++) {
2585 struct fio_keyword *kw = &fio_keywords[i];
2586
2587 while ((s = strstr(opt, kw->word)) != NULL) {
2588 char *new = malloc(strlen(opt) + 1);
2589 char *o_org = opt;
2590 int olen = s - opt;
2591 int len;
2592
2593 /*
2594 * Copy part of the string before the keyword and
2595 * sprintf() the replacement after it.
2596 */
2597 memcpy(new, opt, olen);
2598 len = sprintf(new + olen, "%s", kw->replace);
2599
2600 /*
2601 * If there's more in the original string, copy that
2602 * in too
2603 */
2604 opt += strlen(kw->word) + olen;
2605 if (strlen(opt))
2606 memcpy(new + olen + len, opt, opt - o_org - 1);
2607
2608 /*
2609 * replace opt and free the old opt
2610 */
2611 opt = new;
Steven Langd0c814e2011-10-28 08:37:13 +02002612 free(o_org);
Jens Axboe7a958bd2009-11-13 12:33:54 +01002613
Steven Langd0c814e2011-10-28 08:37:13 +02002614 docalc = 1;
Jens Axboe74929ac2009-08-05 11:42:37 +02002615 }
2616 }
2617
Steven Langd0c814e2011-10-28 08:37:13 +02002618 /*
2619 * Check for potential math and invoke bc, if possible
2620 */
2621 if (docalc)
2622 opt = bc_calc(opt);
2623
Jens Axboe7a958bd2009-11-13 12:33:54 +01002624 return opt;
Jens Axboe74929ac2009-08-05 11:42:37 +02002625}
2626
Steven Langd0c814e2011-10-28 08:37:13 +02002627static char **dup_and_sub_options(char **opts, int num_opts)
2628{
2629 int i;
2630 char **opts_copy = malloc(num_opts * sizeof(*opts));
2631 for (i = 0; i < num_opts; i++) {
2632 opts_copy[i] = option_dup_subs(opts[i]);
2633 if (!opts_copy[i])
2634 continue;
2635 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2636 }
2637 return opts_copy;
2638}
2639
Jens Axboe3b8b7132008-06-10 19:46:23 +02002640int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01002641{
Steven Langde890a12011-11-09 14:03:34 +01002642 int i, ret, unknown;
Steven Langd0c814e2011-10-28 08:37:13 +02002643 char **opts_copy;
Jens Axboe3b8b7132008-06-10 19:46:23 +02002644
2645 sort_options(opts, options, num_opts);
Steven Langd0c814e2011-10-28 08:37:13 +02002646 opts_copy = dup_and_sub_options(opts, num_opts);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002647
Steven Langde890a12011-11-09 14:03:34 +01002648 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2649 struct fio_option *o;
2650 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2651 td);
Steven Langd0c814e2011-10-28 08:37:13 +02002652
Steven Langde890a12011-11-09 14:03:34 +01002653 if (opts_copy[i]) {
2654 if (newret && !o) {
2655 unknown++;
2656 continue;
2657 }
Steven Langd0c814e2011-10-28 08:37:13 +02002658 free(opts_copy[i]);
Steven Langde890a12011-11-09 14:03:34 +01002659 opts_copy[i] = NULL;
2660 }
2661
2662 ret |= newret;
2663 }
2664
2665 if (unknown) {
2666 ret |= ioengine_load(td);
2667 if (td->eo) {
2668 sort_options(opts_copy, td->io_ops->options, num_opts);
2669 opts = opts_copy;
2670 }
2671 for (i = 0; i < num_opts; i++) {
2672 struct fio_option *o = NULL;
2673 int newret = 1;
2674 if (!opts_copy[i])
2675 continue;
2676
2677 if (td->eo)
2678 newret = parse_option(opts_copy[i], opts[i],
2679 td->io_ops->options, &o,
2680 td->eo);
2681
2682 ret |= newret;
2683 if (!o)
2684 log_err("Bad option <%s>\n", opts[i]);
2685
2686 free(opts_copy[i]);
2687 opts_copy[i] = NULL;
2688 }
Jens Axboe74929ac2009-08-05 11:42:37 +02002689 }
Jens Axboe3b8b7132008-06-10 19:46:23 +02002690
Steven Langd0c814e2011-10-28 08:37:13 +02002691 free(opts_copy);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002692 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01002693}
2694
2695int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2696{
Jens Axboe07b32322010-03-05 09:48:44 +01002697 return parse_cmd_option(opt, val, options, td);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002698}
2699
Steven Langde890a12011-11-09 14:03:34 +01002700int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2701 char *val)
2702{
2703 return parse_cmd_option(opt, val, td->io_ops->options, td);
2704}
2705
Jens Axboe214e1ec2007-03-15 10:48:13 +01002706void fio_fill_default_options(struct thread_data *td)
2707{
2708 fill_default_options(td, options);
2709}
2710
2711int fio_show_option_help(const char *opt)
2712{
Jens Axboe07b32322010-03-05 09:48:44 +01002713 return show_cmd_help(options, opt);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002714}
Jens Axboed23bb322007-03-23 15:57:56 +01002715
Steven Langde890a12011-11-09 14:03:34 +01002716void options_mem_dupe(void *data, struct fio_option *options)
2717{
2718 struct fio_option *o;
2719 char **ptr;
2720
2721 for (o = &options[0]; o->name; o++) {
2722 if (o->type != FIO_OPT_STR_STORE)
2723 continue;
2724
2725 ptr = td_var(data, o->off1);
2726 if (*ptr)
2727 *ptr = strdup(*ptr);
2728 }
2729}
2730
Jens Axboe7e356b22011-10-14 10:55:16 +02002731/*
2732 * dupe FIO_OPT_STR_STORE options
2733 */
Steven Langde890a12011-11-09 14:03:34 +01002734void fio_options_mem_dupe(struct thread_data *td)
Jens Axboed23bb322007-03-23 15:57:56 +01002735{
Steven Langde890a12011-11-09 14:03:34 +01002736 options_mem_dupe(&td->o, options);
Jens Axboe1647f592011-11-09 20:25:21 +01002737
2738 if (td->eo && td->io_ops) {
Steven Langde890a12011-11-09 14:03:34 +01002739 void *oldeo = td->eo;
Jens Axboe1647f592011-11-09 20:25:21 +01002740
Steven Langde890a12011-11-09 14:03:34 +01002741 td->eo = malloc(td->io_ops->option_struct_size);
2742 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2743 options_mem_dupe(td->eo, td->io_ops->options);
Jens Axboed23bb322007-03-23 15:57:56 +01002744 }
2745}
2746
Jens Axboed6978a32009-07-18 21:04:09 +02002747unsigned int fio_get_kb_base(void *data)
2748{
2749 struct thread_data *td = data;
2750 unsigned int kb_base = 0;
2751
2752 if (td)
2753 kb_base = td->o.kb_base;
2754 if (!kb_base)
2755 kb_base = 1024;
2756
2757 return kb_base;
2758}
Jens Axboe9f988e22010-03-04 10:42:38 +01002759
Jens Axboe07b32322010-03-05 09:48:44 +01002760int add_option(struct fio_option *o)
Jens Axboe9f988e22010-03-04 10:42:38 +01002761{
Jens Axboe07b32322010-03-05 09:48:44 +01002762 struct fio_option *__o;
2763 int opt_index = 0;
2764
2765 __o = options;
2766 while (__o->name) {
2767 opt_index++;
2768 __o++;
2769 }
2770
2771 memcpy(&options[opt_index], o, sizeof(*o));
2772 return 0;
Jens Axboe9f988e22010-03-04 10:42:38 +01002773}
Jens Axboee2de69d2010-03-04 14:05:48 +01002774
Jens Axboe07b32322010-03-05 09:48:44 +01002775void invalidate_profile_options(const char *prof_name)
Jens Axboee2de69d2010-03-04 14:05:48 +01002776{
Jens Axboe07b32322010-03-05 09:48:44 +01002777 struct fio_option *o;
Jens Axboee2de69d2010-03-04 14:05:48 +01002778
Jens Axboe07b32322010-03-05 09:48:44 +01002779 o = options;
2780 while (o->name) {
2781 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2782 o->type = FIO_OPT_INVALID;
2783 o->prof_name = NULL;
2784 }
2785 o++;
Jens Axboee2de69d2010-03-04 14:05:48 +01002786 }
2787}
Jens Axboef5b6bb82010-03-05 10:09:59 +01002788
2789void add_opt_posval(const char *optname, const char *ival, const char *help)
2790{
2791 struct fio_option *o;
2792 unsigned int i;
2793
2794 o = find_option(options, optname);
2795 if (!o)
2796 return;
2797
2798 for (i = 0; i < PARSE_MAX_VP; i++) {
2799 if (o->posval[i].ival)
2800 continue;
2801
2802 o->posval[i].ival = ival;
2803 o->posval[i].help = help;
2804 break;
2805 }
2806}
2807
2808void del_opt_posval(const char *optname, const char *ival)
2809{
2810 struct fio_option *o;
2811 unsigned int i;
2812
2813 o = find_option(options, optname);
2814 if (!o)
2815 return;
2816
2817 for (i = 0; i < PARSE_MAX_VP; i++) {
2818 if (!o->posval[i].ival)
2819 continue;
2820 if (strcmp(o->posval[i].ival, ival))
2821 continue;
2822
2823 o->posval[i].ival = NULL;
2824 o->posval[i].help = NULL;
2825 }
2826}
Jens Axboe7e356b22011-10-14 10:55:16 +02002827
2828void fio_options_free(struct thread_data *td)
2829{
2830 options_free(options, td);
Steven Langde890a12011-11-09 14:03:34 +01002831 if (td->eo && td->io_ops && td->io_ops->options) {
2832 options_free(td->io_ops->options, td->eo);
2833 free(td->eo);
2834 td->eo = NULL;
2835 }
Jens Axboe7e356b22011-10-14 10:55:16 +02002836}