blob: d1cf7e8a70ba6480c9dc1b1021b5a739c5dec9f9 [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;
163
164}
165
166static int str_bssplit_cb(void *data, const char *input)
167{
168 struct thread_data *td = data;
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200169 char *str, *p, *odir, *ddir;
Jens Axboe720e84a2009-04-21 08:29:55 +0200170 int ret = 0;
171
172 p = str = strdup(input);
173
174 strip_blank_front(&str);
175 strip_blank_end(str);
176
177 odir = strchr(str, ',');
178 if (odir) {
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200179 ddir = strchr(odir + 1, ',');
180 if (ddir) {
181 ret = bssplit_ddir(td, DDIR_TRIM, ddir + 1);
182 if (!ret)
183 *ddir = '\0';
184 } else {
185 char *op;
186
187 op = strdup(odir + 1);
188 ret = bssplit_ddir(td, DDIR_TRIM, op);
189
190 free(op);
191 }
192 if (!ret)
193 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
Jens Axboe720e84a2009-04-21 08:29:55 +0200194 if (!ret) {
195 *odir = '\0';
196 ret = bssplit_ddir(td, DDIR_READ, str);
197 }
198 } else {
199 char *op;
200
201 op = strdup(str);
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200202 ret = bssplit_ddir(td, DDIR_WRITE, op);
Jens Axboe720e84a2009-04-21 08:29:55 +0200203 free(op);
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200204
205 if (!ret) {
206 op = strdup(str);
207 ret = bssplit_ddir(td, DDIR_TRIM, op);
208 free(op);
209 }
210 ret = bssplit_ddir(td, DDIR_READ, str);
Jens Axboe720e84a2009-04-21 08:29:55 +0200211 }
Jens Axboe564ca972007-12-14 12:21:19 +0100212
213 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200214 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100215}
216
Jens Axboe211097b2007-03-22 18:56:45 +0100217static int str_rw_cb(void *data, const char *str)
218{
219 struct thread_data *td = data;
220 char *nr = get_opt_postfix(str);
221
Jens Axboe5736c102010-07-20 12:03:25 -0600222 td->o.ddir_seq_nr = 1;
Jens Axboe059b0802011-08-25 09:09:37 +0200223 td->o.ddir_seq_add = 0;
224
225 if (!nr)
226 return 0;
227
228 if (td_random(td))
Jens Axboe5736c102010-07-20 12:03:25 -0600229 td->o.ddir_seq_nr = atoi(nr);
Jens Axboe059b0802011-08-25 09:09:37 +0200230 else {
231 long long val;
232
Jens Axboe6925dd32011-09-07 22:10:11 +0200233 if (str_to_decimal(nr, &val, 1, td)) {
Jens Axboe059b0802011-08-25 09:09:37 +0200234 log_err("fio: rw postfix parsing failed\n");
235 free(nr);
236 return 1;
237 }
238
239 td->o.ddir_seq_add = val;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100240 }
Jens Axboe211097b2007-03-22 18:56:45 +0100241
Jens Axboe059b0802011-08-25 09:09:37 +0200242 free(nr);
Jens Axboe211097b2007-03-22 18:56:45 +0100243 return 0;
244}
245
Jens Axboe214e1ec2007-03-15 10:48:13 +0100246static int str_mem_cb(void *data, const char *mem)
247{
248 struct thread_data *td = data;
249
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100250 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100251 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100252 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100253 log_err("fio: mmaphuge:/path/to/file\n");
254 return 1;
255 }
256 }
257
258 return 0;
259}
260
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200261static int str_verify_cb(void *data, const char *mem)
262{
263 struct thread_data *td = data;
264
Jens Axboee3aaafc2012-02-22 20:28:17 +0100265 if (td->o.verify == VERIFY_CRC32C_INTEL ||
266 td->o.verify == VERIFY_CRC32C) {
267 crc32c_intel_probe();
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200268 }
269
270 return 0;
271}
272
Jens Axboec223da82010-03-24 13:23:53 +0100273static int fio_clock_source_cb(void *data, const char *str)
274{
275 struct thread_data *td = data;
276
277 fio_clock_source = td->o.clocksource;
278 fio_time_init();
279 return 0;
280}
281
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400282static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100283{
284 mlock_size = *val;
285 return 0;
286}
287
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400288static int str_rwmix_read_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200289{
290 struct thread_data *td = data;
291
292 td->o.rwmix[DDIR_READ] = *val;
293 td->o.rwmix[DDIR_WRITE] = 100 - *val;
294 return 0;
295}
296
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400297static int str_rwmix_write_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200298{
299 struct thread_data *td = data;
300
301 td->o.rwmix[DDIR_WRITE] = *val;
302 td->o.rwmix[DDIR_READ] = 100 - *val;
303 return 0;
304}
305
Jens Axboe214e1ec2007-03-15 10:48:13 +0100306#ifdef FIO_HAVE_IOPRIO
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400307static int str_prioclass_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100308{
309 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200310 unsigned short mask;
311
312 /*
313 * mask off old class bits, str_prio_cb() may have set a default class
314 */
315 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
316 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100317
318 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100319 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100320 return 0;
321}
322
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400323static int str_prio_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100324{
325 struct thread_data *td = data;
326
327 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200328
329 /*
330 * If no class is set, assume BE
331 */
332 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
333 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
334
Jens Axboeac684782007-11-08 08:29:07 +0100335 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100336 return 0;
337}
338#endif
339
340static int str_exitall_cb(void)
341{
342 exitall_on_terminate = 1;
343 return 0;
344}
345
Jens Axboe214e1ec2007-03-15 10:48:13 +0100346#ifdef FIO_HAVE_CPU_AFFINITY
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400347static int str_cpumask_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100348{
349 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200350 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100351 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100352 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353
Jens Axboed2ce18b2008-12-12 20:51:40 +0100354 ret = fio_cpuset_init(&td->o.cpumask);
355 if (ret < 0) {
356 log_err("fio: cpuset_init failed\n");
357 td_verror(td, ret, "fio_cpuset_init");
358 return 1;
359 }
360
Jens Axboec00a2282011-07-08 20:56:06 +0200361 max_cpu = cpus_online();
Jens Axboed2e268b2007-06-15 10:33:49 +0200362
Jens Axboe62a72732008-12-08 11:37:01 +0100363 for (i = 0; i < sizeof(int) * 8; i++) {
364 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100365 if (i > max_cpu) {
366 log_err("fio: CPU %d too large (max=%ld)\n", i,
367 max_cpu);
368 return 1;
369 }
Jens Axboe62a72732008-12-08 11:37:01 +0100370 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100371 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100372 }
373 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200374
Jens Axboe375b2692007-05-22 09:13:02 +0200375 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100376 return 0;
377}
378
Jens Axboee8462bd2009-07-06 12:59:04 +0200379static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
380 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200381{
Jens Axboed2e268b2007-06-15 10:33:49 +0200382 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100383 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100384 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200385
Jens Axboee8462bd2009-07-06 12:59:04 +0200386 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100387 if (ret < 0) {
388 log_err("fio: cpuset_init failed\n");
389 td_verror(td, ret, "fio_cpuset_init");
390 return 1;
391 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200392
393 p = str = strdup(input);
394
395 strip_blank_front(&str);
396 strip_blank_end(str);
397
Jens Axboec00a2282011-07-08 20:56:06 +0200398 max_cpu = cpus_online();
Jens Axboeb03daaf2008-12-08 20:31:43 +0100399
Jens Axboed2e268b2007-06-15 10:33:49 +0200400 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100401 char *str2, *cpu2;
402 int icpu, icpu2;
403
Jens Axboed2e268b2007-06-15 10:33:49 +0200404 if (!strlen(cpu))
405 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100406
407 str2 = cpu;
408 icpu2 = -1;
409 while ((cpu2 = strsep(&str2, "-")) != NULL) {
410 if (!strlen(cpu2))
411 break;
412
413 icpu2 = atoi(cpu2);
414 }
415
416 icpu = atoi(cpu);
417 if (icpu2 == -1)
418 icpu2 = icpu;
419 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100420 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100421 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100422 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100423 ret = 1;
424 break;
425 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100426 if (icpu > max_cpu) {
427 log_err("fio: CPU %d too large (max=%ld)\n",
428 icpu, max_cpu);
429 ret = 1;
430 break;
431 }
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200432
Jens Axboe62a72732008-12-08 11:37:01 +0100433 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200434 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100435 icpu++;
436 }
Jens Axboe19608d62008-12-08 15:03:12 +0100437 if (ret)
438 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200439 }
440
441 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100442 if (!ret)
443 td->o.cpumask_set = 1;
444 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200445}
Jens Axboee8462bd2009-07-06 12:59:04 +0200446
447static int str_cpus_allowed_cb(void *data, const char *input)
448{
449 struct thread_data *td = data;
450 int ret;
451
452 ret = set_cpus_allowed(td, &td->o.cpumask, input);
453 if (!ret)
454 td->o.cpumask_set = 1;
455
456 return ret;
457}
458
459static int str_verify_cpus_allowed_cb(void *data, const char *input)
460{
461 struct thread_data *td = data;
462 int ret;
463
464 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
465 if (!ret)
466 td->o.verify_cpumask_set = 1;
467
468 return ret;
469}
Jens Axboed2e268b2007-06-15 10:33:49 +0200470#endif
471
Jens Axboe0d29de82010-09-01 13:54:15 +0200472#ifdef FIO_HAVE_TRIM
473static int str_verify_trim_cb(void *data, unsigned long long *val)
474{
475 struct thread_data *td = data;
476
477 td->o.trim_percentage = *val;
478 return 0;
479}
480#endif
481
Jens Axboe214e1ec2007-03-15 10:48:13 +0100482static int str_fst_cb(void *data, const char *str)
483{
484 struct thread_data *td = data;
485 char *nr = get_opt_postfix(str);
486
487 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100488 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100489 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100490 free(nr);
491 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100492
493 return 0;
494}
495
Jens Axboe3ae06372010-03-19 19:17:15 +0100496#ifdef FIO_HAVE_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +0100497static int str_sfr_cb(void *data, const char *str)
498{
499 struct thread_data *td = data;
500 char *nr = get_opt_postfix(str);
501
502 td->sync_file_range_nr = 1;
503 if (nr) {
504 td->sync_file_range_nr = atoi(nr);
505 free(nr);
506 }
507
508 return 0;
509}
Jens Axboe3ae06372010-03-19 19:17:15 +0100510#endif
Jens Axboe44f29692010-03-09 20:09:44 +0100511
Jens Axboe921c7662008-03-26 09:17:55 +0100512static int check_dir(struct thread_data *td, char *fname)
513{
Jens Axboe3f0ca9b2011-05-24 21:36:24 +0200514#if 0
Jens Axboe921c7662008-03-26 09:17:55 +0100515 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200516 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100517
Jens Axboebc838912008-04-07 09:00:54 +0200518 if (td->o.directory) {
519 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200520 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200521 elen = strlen(file);
522 }
523
Jens Axboefcef0b32008-05-26 14:53:24 +0200524 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100525 dir = dirname(file);
526
Jens Axboefcef0b32008-05-26 14:53:24 +0200527 {
528 struct stat sb;
529 /*
530 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
531 * yet, so we can't do this check right here...
532 */
Jens Axboe921c7662008-03-26 09:17:55 +0100533 if (lstat(dir, &sb) < 0) {
534 int ret = errno;
535
536 log_err("fio: %s is not a directory\n", dir);
537 td_verror(td, ret, "lstat");
538 return 1;
539 }
540
541 if (!S_ISDIR(sb.st_mode)) {
542 log_err("fio: %s is not a directory\n", dir);
543 return 1;
544 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200545 }
546#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100547
548 return 0;
549}
550
Jens Axboe8e827d32009-08-04 09:51:48 +0200551/*
552 * Return next file in the string. Files are separated with ':'. If the ':'
553 * is escaped with a '\', then that ':' is part of the filename and does not
554 * indicate a new file.
555 */
556static char *get_next_file_name(char **ptr)
557{
558 char *str = *ptr;
559 char *p, *start;
560
561 if (!str || !strlen(str))
562 return NULL;
563
564 start = str;
565 do {
566 /*
567 * No colon, we are done
568 */
569 p = strchr(str, ':');
570 if (!p) {
571 *ptr = NULL;
572 break;
573 }
574
575 /*
576 * We got a colon, but it's the first character. Skip and
577 * continue
578 */
579 if (p == start) {
580 str = ++start;
581 continue;
582 }
583
584 if (*(p - 1) != '\\') {
585 *p = '\0';
586 *ptr = p + 1;
587 break;
588 }
589
590 memmove(p - 1, p, strlen(p) + 1);
591 str = p;
592 } while (1);
593
594 return start;
595}
596
Jens Axboe214e1ec2007-03-15 10:48:13 +0100597static int str_filename_cb(void *data, const char *input)
598{
599 struct thread_data *td = data;
600 char *fname, *str, *p;
601
602 p = str = strdup(input);
603
604 strip_blank_front(&str);
605 strip_blank_end(str);
606
607 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100608 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100609
Jens Axboe8e827d32009-08-04 09:51:48 +0200610 while ((fname = get_next_file_name(&str)) != NULL) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100611 if (!strlen(fname))
612 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100613 if (check_dir(td, fname)) {
614 free(p);
615 return 1;
616 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100617 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100618 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100619 }
620
621 free(p);
622 return 0;
623}
624
625static int str_directory_cb(void *data, const char fio_unused *str)
626{
627 struct thread_data *td = data;
628 struct stat sb;
629
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100630 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100631 int ret = errno;
632
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100633 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100634 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100635 return 1;
636 }
637 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100638 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100639 return 1;
640 }
641
642 return 0;
643}
644
645static int str_opendir_cb(void *data, const char fio_unused *str)
646{
647 struct thread_data *td = data;
648
649 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100650 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100651
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100652 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100653}
654
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400655static int str_verify_offset_cb(void *data, unsigned long long *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200656{
657 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200658
Shawn Lewis546a9142007-07-28 21:11:37 +0200659 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200660 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200661 return 1;
662 }
Jens Axboea59e1702007-07-30 08:53:27 +0200663
664 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200665 return 0;
666}
667
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100668static int str_verify_pattern_cb(void *data, const char *input)
Jens Axboe90059d62007-07-30 09:33:12 +0200669{
670 struct thread_data *td = data;
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100671 long off;
672 int i = 0, j = 0, len, k, base = 10;
673 char* loc1, * loc2;
Jens Axboe90059d62007-07-30 09:33:12 +0200674
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100675 loc1 = strstr(input, "0x");
676 loc2 = strstr(input, "0X");
677 if (loc1 || loc2)
678 base = 16;
679 off = strtol(input, NULL, base);
680 if (off != LONG_MAX || errno != ERANGE) {
681 while (off) {
682 td->o.verify_pattern[i] = off & 0xff;
683 off >>= 8;
684 i++;
685 }
686 } else {
687 len = strlen(input);
688 k = len - 1;
689 if (base == 16) {
690 if (loc1)
691 j = loc1 - input + 2;
692 else
693 j = loc2 - input + 2;
694 } else
695 return 1;
696 if (len - j < MAX_PATTERN_SIZE * 2) {
697 while (k >= j) {
698 off = converthexchartoint(input[k--]);
699 if (k >= j)
700 off += (converthexchartoint(input[k--])
701 * 16);
702 td->o.verify_pattern[i++] = (char) off;
703 }
704 }
705 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100706
707 /*
708 * Fill the pattern all the way to the end. This greatly reduces
709 * the number of memcpy's we have to do when verifying the IO.
710 */
711 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
712 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
713 i *= 2;
714 }
Steven Lang9a2a86d2012-02-07 09:42:59 +0100715 if (i == 1) {
716 /*
717 * The code in verify_io_u_pattern assumes a single byte pattern
718 * fills the whole verify pattern buffer.
719 */
720 memset(td->o.verify_pattern, td->o.verify_pattern[0],
721 MAX_PATTERN_SIZE);
722 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100723
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100724 td->o.verify_pattern_bytes = i;
Steven Langefcd9dc2012-02-02 20:22:04 +0100725
Jens Axboe92bf48d2011-01-14 21:20:42 +0100726 /*
727 * VERIFY_META could already be set
728 */
729 if (td->o.verify == VERIFY_NONE)
730 td->o.verify = VERIFY_PATTERN;
Steven Langefcd9dc2012-02-02 20:22:04 +0100731
Jens Axboe90059d62007-07-30 09:33:12 +0200732 return 0;
733}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100734
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100735static int str_lockfile_cb(void *data, const char *str)
736{
737 struct thread_data *td = data;
738 char *nr = get_opt_postfix(str);
739
740 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100741 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100742 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100743 free(nr);
744 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100745
746 return 0;
747}
748
Jens Axboee3cedca2008-11-19 19:57:52 +0100749static int str_write_bw_log_cb(void *data, const char *str)
750{
751 struct thread_data *td = data;
752
753 if (str)
754 td->o.bw_log_file = strdup(str);
755
756 td->o.write_bw_log = 1;
757 return 0;
758}
759
760static int str_write_lat_log_cb(void *data, const char *str)
761{
762 struct thread_data *td = data;
763
764 if (str)
765 td->o.lat_log_file = strdup(str);
766
767 td->o.write_lat_log = 1;
768 return 0;
769}
770
Jens Axboec8eeb9d2011-10-05 14:02:22 +0200771static int str_write_iops_log_cb(void *data, const char *str)
772{
773 struct thread_data *td = data;
774
775 if (str)
776 td->o.iops_log_file = strdup(str);
777
778 td->o.write_iops_log = 1;
779 return 0;
780}
781
Jens Axboe993bf482008-11-14 13:04:53 +0100782static int str_gtod_reduce_cb(void *data, int *il)
783{
784 struct thread_data *td = data;
785 int val = *il;
786
Jens Axboe02af0982010-06-24 09:59:34 +0200787 td->o.disable_lat = !!val;
Jens Axboe993bf482008-11-14 13:04:53 +0100788 td->o.disable_clat = !!val;
789 td->o.disable_slat = !!val;
790 td->o.disable_bw = !!val;
Jens Axboe0dc1bc02011-10-13 08:55:29 +0200791 td->o.clat_percentiles = !val;
Jens Axboe993bf482008-11-14 13:04:53 +0100792 if (val)
793 td->tv_cache_mask = 63;
794
795 return 0;
796}
797
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400798static int str_gtod_cpu_cb(void *data, long long *il)
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100799{
800 struct thread_data *td = data;
801 int val = *il;
802
803 td->o.gtod_cpu = val;
804 td->o.gtod_offload = 1;
805 return 0;
806}
807
Jens Axboe7bb59102011-07-12 19:47:03 +0200808static int str_size_cb(void *data, unsigned long long *__val)
809{
810 struct thread_data *td = data;
811 unsigned long long v = *__val;
812
813 if (parse_is_percent(v)) {
814 td->o.size = 0;
815 td->o.size_percent = -1ULL - v;
816 } else
817 td->o.size = v;
818
819 return 0;
820}
821
Jens Axboe896cac22009-07-01 10:38:35 +0200822static int rw_verify(struct fio_option *o, void *data)
823{
824 struct thread_data *td = data;
825
826 if (read_only && td_write(td)) {
827 log_err("fio: job <%s> has write bit set, but fio is in"
828 " read-only mode\n", td->o.name);
829 return 1;
830 }
831
832 return 0;
833}
834
Jens Axboe276ca4f2009-07-01 10:43:05 +0200835static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200836{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200837#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200838 struct thread_data *td = data;
839
Jens Axboe29d43ff2009-07-01 10:42:18 +0200840 if (td->o.gtod_cpu) {
841 log_err("fio: platform must support CPU affinity for"
842 "gettimeofday() offloading\n");
843 return 1;
844 }
845#endif
846
847 return 0;
848}
849
Jens Axboe90fef2d2009-07-17 22:33:32 +0200850static int kb_base_verify(struct fio_option *o, void *data)
851{
852 struct thread_data *td = data;
853
854 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
855 log_err("fio: kb_base set to nonsensical value: %u\n",
856 td->o.kb_base);
857 return 1;
858 }
859
860 return 0;
861}
862
Jens Axboe214e1ec2007-03-15 10:48:13 +0100863/*
864 * Map of job/command line options
865 */
Jens Axboe07b32322010-03-05 09:48:44 +0100866static struct fio_option options[FIO_MAX_OPTS] = {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100867 {
868 .name = "description",
869 .type = FIO_OPT_STR_STORE,
870 .off1 = td_var_offset(description),
871 .help = "Text job description",
872 },
873 {
874 .name = "name",
875 .type = FIO_OPT_STR_STORE,
876 .off1 = td_var_offset(name),
877 .help = "Name of this job",
878 },
879 {
880 .name = "directory",
881 .type = FIO_OPT_STR_STORE,
882 .off1 = td_var_offset(directory),
883 .cb = str_directory_cb,
884 .help = "Directory to store files in",
885 },
886 {
887 .name = "filename",
888 .type = FIO_OPT_STR_STORE,
889 .off1 = td_var_offset(filename),
890 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200891 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100892 .help = "File(s) to use for the workload",
893 },
894 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200895 .name = "kb_base",
896 .type = FIO_OPT_INT,
897 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200898 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200899 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200900 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200901 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +0200902 },
903 {
Jens Axboe29c13492008-03-01 19:25:20 +0100904 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100905 .type = FIO_OPT_STR,
906 .cb = str_lockfile_cb,
907 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100908 .help = "Lock file when doing IO to it",
909 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100910 .def = "none",
911 .posval = {
912 { .ival = "none",
913 .oval = FILE_LOCK_NONE,
914 .help = "No file locking",
915 },
916 { .ival = "exclusive",
917 .oval = FILE_LOCK_EXCLUSIVE,
918 .help = "Exclusive file lock",
919 },
920 {
921 .ival = "readwrite",
922 .oval = FILE_LOCK_READWRITE,
923 .help = "Read vs write lock",
924 },
925 },
Jens Axboe29c13492008-03-01 19:25:20 +0100926 },
927 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100928 .name = "opendir",
929 .type = FIO_OPT_STR_STORE,
930 .off1 = td_var_offset(opendir),
931 .cb = str_opendir_cb,
932 .help = "Recursively add files from this directory and down",
933 },
934 {
935 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100936 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100937 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100938 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100939 .off1 = td_var_offset(td_ddir),
940 .help = "IO direction",
941 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +0200942 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100943 .posval = {
944 { .ival = "read",
945 .oval = TD_DDIR_READ,
946 .help = "Sequential read",
947 },
948 { .ival = "write",
949 .oval = TD_DDIR_WRITE,
950 .help = "Sequential write",
951 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200952 { .ival = "trim",
953 .oval = TD_DDIR_TRIM,
954 .help = "Sequential trim",
955 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100956 { .ival = "randread",
957 .oval = TD_DDIR_RANDREAD,
958 .help = "Random read",
959 },
960 { .ival = "randwrite",
961 .oval = TD_DDIR_RANDWRITE,
962 .help = "Random write",
963 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200964 { .ival = "randtrim",
965 .oval = TD_DDIR_RANDTRIM,
966 .help = "Random trim",
967 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100968 { .ival = "rw",
969 .oval = TD_DDIR_RW,
970 .help = "Sequential read and write mix",
971 },
Jens Axboe10b023d2012-03-23 13:40:06 +0100972 { .ival = "readwrite",
973 .oval = TD_DDIR_RW,
974 .help = "Sequential read and write mix",
975 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100976 { .ival = "randrw",
977 .oval = TD_DDIR_RANDRW,
978 .help = "Random read and write mix"
979 },
980 },
981 },
982 {
Jens Axboe38dad622010-07-20 14:46:00 -0600983 .name = "rw_sequencer",
984 .type = FIO_OPT_STR,
985 .off1 = td_var_offset(rw_seq),
986 .help = "IO offset generator modifier",
987 .def = "sequential",
988 .posval = {
989 { .ival = "sequential",
990 .oval = RW_SEQ_SEQ,
991 .help = "Generate sequential offsets",
992 },
993 { .ival = "identical",
994 .oval = RW_SEQ_IDENT,
995 .help = "Generate identical offsets",
996 },
997 },
998 },
999
1000 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001001 .name = "ioengine",
1002 .type = FIO_OPT_STR_STORE,
1003 .off1 = td_var_offset(ioengine),
1004 .help = "IO engine to use",
Jens Axboe58483fa2011-01-19 11:09:58 -07001005 .def = FIO_PREFERRED_ENGINE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001006 .posval = {
1007 { .ival = "sync",
1008 .help = "Use read/write",
1009 },
gurudas paia31041e2007-10-23 15:12:30 +02001010 { .ival = "psync",
1011 .help = "Use pread/pwrite",
1012 },
Jens Axboe1d2af022008-02-04 10:59:07 +01001013 { .ival = "vsync",
Bruce Cran03e20d62011-01-02 20:14:54 +01001014 .help = "Use readv/writev",
Jens Axboe1d2af022008-02-04 10:59:07 +01001015 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001016#ifdef FIO_HAVE_LIBAIO
1017 { .ival = "libaio",
1018 .help = "Linux native asynchronous IO",
1019 },
1020#endif
1021#ifdef FIO_HAVE_POSIXAIO
1022 { .ival = "posixaio",
1023 .help = "POSIX asynchronous IO",
1024 },
1025#endif
Jens Axboe417f0062008-06-02 11:59:30 +02001026#ifdef FIO_HAVE_SOLARISAIO
1027 { .ival = "solarisaio",
1028 .help = "Solaris native asynchronous IO",
1029 },
1030#endif
Bruce Cran03e20d62011-01-02 20:14:54 +01001031#ifdef FIO_HAVE_WINDOWSAIO
1032 { .ival = "windowsaio",
Jens Axboe3be80072011-01-19 11:07:28 -07001033 .help = "Windows native asynchronous IO"
Steven Langde890a12011-11-09 14:03:34 +01001034 },
Jens Axboe3be80072011-01-19 11:07:28 -07001035#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001036 { .ival = "mmap",
Bruce Cran03e20d62011-01-02 20:14:54 +01001037 .help = "Memory mapped IO"
Jens Axboe214e1ec2007-03-15 10:48:13 +01001038 },
1039#ifdef FIO_HAVE_SPLICE
1040 { .ival = "splice",
1041 .help = "splice/vmsplice based IO",
1042 },
Jens Axboe9cce02e2007-06-22 15:42:21 +02001043 { .ival = "netsplice",
1044 .help = "splice/vmsplice to/from the network",
1045 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001046#endif
1047#ifdef FIO_HAVE_SGIO
1048 { .ival = "sg",
1049 .help = "SCSI generic v3 IO",
1050 },
1051#endif
1052 { .ival = "null",
1053 .help = "Testing engine (no data transfer)",
1054 },
1055 { .ival = "net",
1056 .help = "Network IO",
1057 },
1058#ifdef FIO_HAVE_SYSLET
1059 { .ival = "syslet-rw",
1060 .help = "syslet enabled async pread/pwrite IO",
1061 },
1062#endif
1063 { .ival = "cpuio",
Bruce Cran03e20d62011-01-02 20:14:54 +01001064 .help = "CPU cycle burner engine",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001065 },
Jens Axboeb8c82a42007-03-21 08:48:26 +01001066#ifdef FIO_HAVE_GUASI
1067 { .ival = "guasi",
1068 .help = "GUASI IO engine",
1069 },
1070#endif
Jens Axboe79a43182010-09-07 13:28:58 +02001071#ifdef FIO_HAVE_BINJECT
1072 { .ival = "binject",
1073 .help = "binject direct inject block engine",
1074 },
1075#endif
ren yufei21b8aee2011-08-01 10:01:57 +02001076#ifdef FIO_HAVE_RDMA
1077 { .ival = "rdma",
1078 .help = "RDMA IO engine",
1079 },
1080#endif
Jens Axboe8200b8c2012-09-18 23:55:43 +02001081#ifdef FIO_HAVE_FUSION_AW
1082 { .ival = "fusion-aw-sync",
1083 .help = "Fusion-io atomic write engine",
1084 },
1085#endif
Jens Axboe1ecc95c2012-09-20 13:46:34 +02001086#ifdef FIO_HAVE_E4_ENG
1087 { .ival = "e4defrag",
1088 .help = "ext4 defrag engine",
1089 },
1090#endif
1091#ifdef FIO_HAVE_FALLOC_ENG
1092 { .ival = "falloc",
1093 .help = "fallocate() file based engine",
1094 },
1095#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001096 { .ival = "external",
1097 .help = "Load external engine (append name)",
1098 },
1099 },
1100 },
1101 {
1102 .name = "iodepth",
1103 .type = FIO_OPT_INT,
1104 .off1 = td_var_offset(iodepth),
Bruce Cran03e20d62011-01-02 20:14:54 +01001105 .help = "Number of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +01001106 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001107 .def = "1",
1108 },
1109 {
1110 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +02001111 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001112 .type = FIO_OPT_INT,
1113 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +01001114 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +02001115 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +01001116 .minval = 1,
1117 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001118 },
1119 {
Jens Axboe49504212008-06-05 09:03:30 +02001120 .name = "iodepth_batch_complete",
1121 .type = FIO_OPT_INT,
1122 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +01001123 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +02001124 .parent = "iodepth",
1125 .minval = 0,
1126 .def = "1",
1127 },
1128 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001129 .name = "iodepth_low",
1130 .type = FIO_OPT_INT,
1131 .off1 = td_var_offset(iodepth_low),
1132 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +02001133 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001134 },
1135 {
1136 .name = "size",
1137 .type = FIO_OPT_STR_VAL,
Jens Axboe7bb59102011-07-12 19:47:03 +02001138 .cb = str_size_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001139 .help = "Total size of device or files",
1140 },
1141 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001142 .name = "fill_device",
Jens Axboe74586c12011-01-20 10:16:03 -07001143 .alias = "fill_fs",
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001144 .type = FIO_OPT_BOOL,
1145 .off1 = td_var_offset(fill_device),
1146 .help = "Write until an ENOSPC error occurs",
1147 .def = "0",
1148 },
1149 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001150 .name = "filesize",
1151 .type = FIO_OPT_STR_VAL,
1152 .off1 = td_var_offset(file_size_low),
1153 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001154 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001155 .help = "Size of individual files",
1156 },
1157 {
Jens Axboe67a10002007-07-31 23:12:16 +02001158 .name = "offset",
1159 .alias = "fileoffset",
1160 .type = FIO_OPT_STR_VAL,
1161 .off1 = td_var_offset(start_offset),
1162 .help = "Start IO from this offset",
1163 .def = "0",
1164 },
1165 {
Jens Axboe2d7cd862012-03-15 14:53:38 +01001166 .name = "offset_increment",
1167 .type = FIO_OPT_STR_VAL,
1168 .off1 = td_var_offset(offset_increment),
1169 .help = "What is the increment from one offset to the next",
1170 .parent = "offset",
1171 .def = "0",
1172 },
1173 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001174 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001175 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +02001176 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001177 .off1 = td_var_offset(bs[DDIR_READ]),
1178 .off2 = td_var_offset(bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001179 .off3 = td_var_offset(bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001180 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001181 .help = "Block size unit",
1182 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +02001183 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001184 },
1185 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001186 .name = "ba",
1187 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +02001188 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001189 .off1 = td_var_offset(ba[DDIR_READ]),
1190 .off2 = td_var_offset(ba[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001191 .off3 = td_var_offset(ba[DDIR_TRIM]),
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001192 .minval = 1,
1193 .help = "IO block offset alignment",
1194 .parent = "rw",
1195 },
1196 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001197 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001198 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001199 .type = FIO_OPT_RANGE,
1200 .off1 = td_var_offset(min_bs[DDIR_READ]),
1201 .off2 = td_var_offset(max_bs[DDIR_READ]),
1202 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1203 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001204 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1205 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001206 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001207 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +02001208 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001209 },
1210 {
Jens Axboe564ca972007-12-14 12:21:19 +01001211 .name = "bssplit",
1212 .type = FIO_OPT_STR,
1213 .cb = str_bssplit_cb,
1214 .help = "Set a specific mix of block sizes",
1215 .parent = "rw",
1216 },
1217 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001218 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001219 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001220 .type = FIO_OPT_STR_SET,
1221 .off1 = td_var_offset(bs_unaligned),
1222 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +02001223 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001224 },
1225 {
1226 .name = "randrepeat",
1227 .type = FIO_OPT_BOOL,
1228 .off1 = td_var_offset(rand_repeatable),
1229 .help = "Use repeatable random IO pattern",
1230 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +02001231 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001232 },
1233 {
Jens Axboe2615cc42011-03-28 09:35:09 +02001234 .name = "use_os_rand",
1235 .type = FIO_OPT_BOOL,
1236 .off1 = td_var_offset(use_os_rand),
1237 .help = "Set to use OS random generator",
1238 .def = "0",
1239 .parent = "rw",
1240 },
1241 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001242 .name = "norandommap",
1243 .type = FIO_OPT_STR_SET,
1244 .off1 = td_var_offset(norandommap),
1245 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +02001246 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001247 },
1248 {
Jens Axboe2b386d22008-03-26 10:32:57 +01001249 .name = "softrandommap",
1250 .type = FIO_OPT_BOOL,
1251 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001252 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +01001253 .parent = "norandommap",
1254 .def = "0",
1255 },
1256 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001257 .name = "nrfiles",
Jens Axboed7c8be02010-11-25 08:21:39 +01001258 .alias = "nr_files",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001259 .type = FIO_OPT_INT,
1260 .off1 = td_var_offset(nr_files),
1261 .help = "Split job workload between this number of files",
1262 .def = "1",
1263 },
1264 {
1265 .name = "openfiles",
1266 .type = FIO_OPT_INT,
1267 .off1 = td_var_offset(open_files),
1268 .help = "Number of files to keep open at the same time",
1269 },
1270 {
1271 .name = "file_service_type",
1272 .type = FIO_OPT_STR,
1273 .cb = str_fst_cb,
1274 .off1 = td_var_offset(file_service_type),
1275 .help = "How to select which file to service next",
1276 .def = "roundrobin",
1277 .posval = {
1278 { .ival = "random",
1279 .oval = FIO_FSERVICE_RANDOM,
1280 .help = "Choose a file at random",
1281 },
1282 { .ival = "roundrobin",
1283 .oval = FIO_FSERVICE_RR,
1284 .help = "Round robin select files",
1285 },
Jens Axboea086c252009-03-04 08:27:37 +01001286 { .ival = "sequential",
1287 .oval = FIO_FSERVICE_SEQ,
1288 .help = "Finish one file before moving to the next",
1289 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001290 },
Jens Axboe67a10002007-07-31 23:12:16 +02001291 .parent = "nrfiles",
1292 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001293#ifdef FIO_HAVE_FALLOCATE
1294 {
1295 .name = "fallocate",
Eric Gourioua596f042011-06-17 09:11:45 +02001296 .type = FIO_OPT_STR,
1297 .off1 = td_var_offset(fallocate_mode),
1298 .help = "Whether pre-allocation is performed when laying out files",
1299 .def = "posix",
1300 .posval = {
1301 { .ival = "none",
1302 .oval = FIO_FALLOCATE_NONE,
1303 .help = "Do not pre-allocate space",
1304 },
1305 { .ival = "posix",
1306 .oval = FIO_FALLOCATE_POSIX,
1307 .help = "Use posix_fallocate()",
1308 },
1309#ifdef FIO_HAVE_LINUX_FALLOCATE
1310 { .ival = "keep",
1311 .oval = FIO_FALLOCATE_KEEP_SIZE,
1312 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1313 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001314#endif
Eric Gourioua596f042011-06-17 09:11:45 +02001315 /* Compatibility with former boolean values */
1316 { .ival = "0",
1317 .oval = FIO_FALLOCATE_NONE,
1318 .help = "Alias for 'none'",
1319 },
1320 { .ival = "1",
1321 .oval = FIO_FALLOCATE_POSIX,
1322 .help = "Alias for 'posix'",
1323 },
1324 },
1325 },
1326#endif /* FIO_HAVE_FALLOCATE */
Jens Axboe67a10002007-07-31 23:12:16 +02001327 {
1328 .name = "fadvise_hint",
1329 .type = FIO_OPT_BOOL,
1330 .off1 = td_var_offset(fadvise_hint),
1331 .help = "Use fadvise() to advise the kernel on IO pattern",
1332 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001333 },
1334 {
1335 .name = "fsync",
1336 .type = FIO_OPT_INT,
1337 .off1 = td_var_offset(fsync_blocks),
1338 .help = "Issue fsync for writes every given number of blocks",
1339 .def = "0",
1340 },
1341 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001342 .name = "fdatasync",
1343 .type = FIO_OPT_INT,
1344 .off1 = td_var_offset(fdatasync_blocks),
1345 .help = "Issue fdatasync for writes every given number of blocks",
1346 .def = "0",
1347 },
Jens Axboe1ef2b6b2010-10-08 15:07:01 +02001348 {
1349 .name = "write_barrier",
1350 .type = FIO_OPT_INT,
1351 .off1 = td_var_offset(barrier_blocks),
1352 .help = "Make every Nth write a barrier write",
1353 .def = "0",
1354 },
Jens Axboe44f29692010-03-09 20:09:44 +01001355#ifdef FIO_HAVE_SYNC_FILE_RANGE
1356 {
1357 .name = "sync_file_range",
1358 .posval = {
1359 { .ival = "wait_before",
1360 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1361 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001362 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001363 },
1364 { .ival = "write",
1365 .oval = SYNC_FILE_RANGE_WRITE,
1366 .help = "SYNC_FILE_RANGE_WRITE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001367 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001368 },
1369 {
1370 .ival = "wait_after",
1371 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1372 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
Jens Axboe3843deb2010-03-09 20:41:15 +01001373 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001374 },
1375 },
Jens Axboe3843deb2010-03-09 20:41:15 +01001376 .type = FIO_OPT_STR_MULTI,
Jens Axboe44f29692010-03-09 20:09:44 +01001377 .cb = str_sfr_cb,
1378 .off1 = td_var_offset(sync_file_range),
1379 .help = "Use sync_file_range()",
1380 },
1381#endif
Jens Axboe5f9099e2009-06-16 22:40:26 +02001382 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001383 .name = "direct",
1384 .type = FIO_OPT_BOOL,
1385 .off1 = td_var_offset(odirect),
1386 .help = "Use O_DIRECT IO (negates buffered)",
1387 .def = "0",
1388 },
1389 {
1390 .name = "buffered",
1391 .type = FIO_OPT_BOOL,
1392 .off1 = td_var_offset(odirect),
1393 .neg = 1,
1394 .help = "Use buffered IO (negates direct)",
1395 .def = "1",
1396 },
1397 {
1398 .name = "overwrite",
1399 .type = FIO_OPT_BOOL,
1400 .off1 = td_var_offset(overwrite),
1401 .help = "When writing, set whether to overwrite current data",
1402 .def = "0",
1403 },
1404 {
1405 .name = "loops",
1406 .type = FIO_OPT_INT,
1407 .off1 = td_var_offset(loops),
1408 .help = "Number of times to run the job",
1409 .def = "1",
1410 },
1411 {
1412 .name = "numjobs",
1413 .type = FIO_OPT_INT,
1414 .off1 = td_var_offset(numjobs),
1415 .help = "Duplicate this job this many times",
1416 .def = "1",
1417 },
1418 {
1419 .name = "startdelay",
Jens Axboea5737c92010-06-29 10:40:30 +02001420 .type = FIO_OPT_STR_VAL_TIME,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001421 .off1 = td_var_offset(start_delay),
1422 .help = "Only start job when this period has passed",
1423 .def = "0",
1424 },
1425 {
1426 .name = "runtime",
1427 .alias = "timeout",
1428 .type = FIO_OPT_STR_VAL_TIME,
1429 .off1 = td_var_offset(timeout),
1430 .help = "Stop workload when this amount of time has passed",
1431 .def = "0",
1432 },
1433 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001434 .name = "time_based",
1435 .type = FIO_OPT_STR_SET,
1436 .off1 = td_var_offset(time_based),
1437 .help = "Keep running until runtime/timeout is met",
1438 },
1439 {
Jens Axboe721938a2008-09-10 09:46:16 +02001440 .name = "ramp_time",
1441 .type = FIO_OPT_STR_VAL_TIME,
1442 .off1 = td_var_offset(ramp_time),
1443 .help = "Ramp up time before measuring performance",
1444 },
1445 {
Jens Axboec223da82010-03-24 13:23:53 +01001446 .name = "clocksource",
1447 .type = FIO_OPT_STR,
1448 .cb = fio_clock_source_cb,
1449 .off1 = td_var_offset(clocksource),
1450 .help = "What type of timing source to use",
Jens Axboec223da82010-03-24 13:23:53 +01001451 .posval = {
1452 { .ival = "gettimeofday",
1453 .oval = CS_GTOD,
1454 .help = "Use gettimeofday(2) for timing",
1455 },
1456 { .ival = "clock_gettime",
1457 .oval = CS_CGETTIME,
1458 .help = "Use clock_gettime(2) for timing",
1459 },
1460#ifdef ARCH_HAVE_CPU_CLOCK
1461 { .ival = "cpu",
1462 .oval = CS_CPUCLOCK,
1463 .help = "Use CPU private clock",
1464 },
1465#endif
1466 },
1467 },
1468 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001469 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001470 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001471 .type = FIO_OPT_STR,
1472 .cb = str_mem_cb,
1473 .off1 = td_var_offset(mem_type),
1474 .help = "Backing type for IO buffers",
1475 .def = "malloc",
1476 .posval = {
1477 { .ival = "malloc",
1478 .oval = MEM_MALLOC,
1479 .help = "Use malloc(3) for IO buffers",
1480 },
Jens Axboeb370e462007-03-19 10:51:49 +01001481 { .ival = "shm",
1482 .oval = MEM_SHM,
1483 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001484 },
1485#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001486 { .ival = "shmhuge",
1487 .oval = MEM_SHMHUGE,
1488 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001489 },
1490#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001491 { .ival = "mmap",
1492 .oval = MEM_MMAP,
1493 .help = "Use mmap(2) (file or anon) for IO buffers",
1494 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001495#ifdef FIO_HAVE_HUGETLB
1496 { .ival = "mmaphuge",
1497 .oval = MEM_MMAPHUGE,
1498 .help = "Like mmap, but use huge pages",
1499 },
1500#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001501 },
1502 },
1503 {
Jens Axboed529ee12009-07-01 10:33:03 +02001504 .name = "iomem_align",
1505 .alias = "mem_align",
1506 .type = FIO_OPT_INT,
1507 .off1 = td_var_offset(mem_align),
1508 .minval = 0,
1509 .help = "IO memory buffer offset alignment",
1510 .def = "0",
1511 .parent = "iomem",
1512 },
1513 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001514 .name = "verify",
1515 .type = FIO_OPT_STR,
1516 .off1 = td_var_offset(verify),
1517 .help = "Verify data written",
Jens Axboe5d7c5d32010-06-21 15:08:17 +02001518 .cb = str_verify_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001519 .def = "0",
1520 .posval = {
1521 { .ival = "0",
1522 .oval = VERIFY_NONE,
1523 .help = "Don't do IO verification",
1524 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001525 { .ival = "md5",
1526 .oval = VERIFY_MD5,
1527 .help = "Use md5 checksums for verification",
1528 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001529 { .ival = "crc64",
1530 .oval = VERIFY_CRC64,
1531 .help = "Use crc64 checksums for verification",
1532 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001533 { .ival = "crc32",
1534 .oval = VERIFY_CRC32,
1535 .help = "Use crc32 checksums for verification",
1536 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001537 { .ival = "crc32c-intel",
Jens Axboee3aaafc2012-02-22 20:28:17 +01001538 .oval = VERIFY_CRC32C,
1539 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboeaf497e62008-08-04 15:40:35 +02001540 },
Jens Axboebac39e02008-06-11 20:46:19 +02001541 { .ival = "crc32c",
1542 .oval = VERIFY_CRC32C,
Jens Axboee3aaafc2012-02-22 20:28:17 +01001543 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboebac39e02008-06-11 20:46:19 +02001544 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001545 { .ival = "crc16",
1546 .oval = VERIFY_CRC16,
1547 .help = "Use crc16 checksums for verification",
1548 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001549 { .ival = "crc7",
1550 .oval = VERIFY_CRC7,
1551 .help = "Use crc7 checksums for verification",
1552 },
Jens Axboe7c353ce2009-08-09 22:40:33 +02001553 { .ival = "sha1",
1554 .oval = VERIFY_SHA1,
1555 .help = "Use sha1 checksums for verification",
1556 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001557 { .ival = "sha256",
1558 .oval = VERIFY_SHA256,
1559 .help = "Use sha256 checksums for verification",
1560 },
1561 { .ival = "sha512",
1562 .oval = VERIFY_SHA512,
1563 .help = "Use sha512 checksums for verification",
1564 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001565 { .ival = "meta",
1566 .oval = VERIFY_META,
1567 .help = "Use io information",
1568 },
Jens Axboe36690c92007-03-26 10:23:34 +02001569 {
1570 .ival = "null",
1571 .oval = VERIFY_NULL,
1572 .help = "Pretend to verify",
1573 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001574 },
1575 },
1576 {
Jens Axboe005c5652007-08-02 22:21:36 +02001577 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001578 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001579 .off1 = td_var_offset(do_verify),
1580 .help = "Run verification stage after write",
1581 .def = "1",
1582 .parent = "verify",
1583 },
1584 {
Jens Axboe160b9662007-03-27 10:59:49 +02001585 .name = "verifysort",
1586 .type = FIO_OPT_BOOL,
1587 .off1 = td_var_offset(verifysort),
1588 .help = "Sort written verify blocks for read back",
1589 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001590 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001591 },
1592 {
Jens Axboea59e1702007-07-30 08:53:27 +02001593 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001594 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001595 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001596 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001597 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001598 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001599 },
1600 {
Jens Axboea59e1702007-07-30 08:53:27 +02001601 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001602 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001603 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001604 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001605 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001606 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001607 },
1608 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001609 .name = "verify_pattern",
Radha Ramachandran0e92f872009-10-27 20:14:27 +01001610 .type = FIO_OPT_STR,
Shawn Lewise28218f2008-01-16 11:01:33 +01001611 .cb = str_verify_pattern_cb,
1612 .help = "Fill pattern for IO buffers",
1613 .parent = "verify",
1614 },
1615 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001616 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001617 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001618 .off1 = td_var_offset(verify_fatal),
1619 .def = "0",
1620 .help = "Exit on a single verify failure, don't continue",
1621 .parent = "verify",
1622 },
1623 {
Jens Axboeb463e932011-01-12 09:03:23 +01001624 .name = "verify_dump",
1625 .type = FIO_OPT_BOOL,
1626 .off1 = td_var_offset(verify_dump),
Jens Axboeef71e312011-10-25 22:43:36 +02001627 .def = "0",
Jens Axboeb463e932011-01-12 09:03:23 +01001628 .help = "Dump contents of good and bad blocks on failure",
1629 .parent = "verify",
1630 },
1631 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001632 .name = "verify_async",
1633 .type = FIO_OPT_INT,
1634 .off1 = td_var_offset(verify_async),
1635 .def = "0",
1636 .help = "Number of async verifier threads to use",
1637 .parent = "verify",
1638 },
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",
1645 },
1646 {
1647 .name = "verify_backlog_batch",
1648 .type = FIO_OPT_INT,
1649 .off1 = td_var_offset(verify_batch),
1650 .help = "Verify this number of IO blocks",
Jens Axboe0d29de82010-09-01 13:54:15 +02001651 .parent = "verify",
Jens Axboe9e144182010-06-15 14:25:36 +02001652 },
Jens Axboee8462bd2009-07-06 12:59:04 +02001653#ifdef FIO_HAVE_CPU_AFFINITY
1654 {
1655 .name = "verify_async_cpus",
1656 .type = FIO_OPT_STR,
1657 .cb = str_verify_cpus_allowed_cb,
1658 .help = "Set CPUs allowed for async verify threads",
1659 .parent = "verify_async",
1660 },
1661#endif
Jens Axboe0d29de82010-09-01 13:54:15 +02001662#ifdef FIO_HAVE_TRIM
1663 {
1664 .name = "trim_percentage",
1665 .type = FIO_OPT_INT,
1666 .cb = str_verify_trim_cb,
1667 .maxval = 100,
1668 .help = "Number of verify blocks to discard/trim",
1669 .parent = "verify",
1670 .def = "0",
1671 },
1672 {
1673 .name = "trim_verify_zero",
1674 .type = FIO_OPT_INT,
1675 .help = "Verify that trim/discarded blocks are returned as zeroes",
1676 .off1 = td_var_offset(trim_zero),
1677 .parent = "trim_percentage",
1678 .def = "1",
1679 },
1680 {
1681 .name = "trim_backlog",
1682 .type = FIO_OPT_STR_VAL,
1683 .off1 = td_var_offset(trim_backlog),
1684 .help = "Trim after this number of blocks are written",
1685 .parent = "trim_percentage",
1686 },
1687 {
1688 .name = "trim_backlog_batch",
1689 .type = FIO_OPT_INT,
1690 .off1 = td_var_offset(trim_batch),
1691 .help = "Trim this number of IO blocks",
1692 .parent = "trim_percentage",
1693 },
1694#endif
Jens Axboee8462bd2009-07-06 12:59:04 +02001695 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001696 .name = "write_iolog",
1697 .type = FIO_OPT_STR_STORE,
1698 .off1 = td_var_offset(write_iolog_file),
1699 .help = "Store IO pattern to file",
1700 },
1701 {
1702 .name = "read_iolog",
1703 .type = FIO_OPT_STR_STORE,
1704 .off1 = td_var_offset(read_iolog_file),
1705 .help = "Playback IO pattern from file",
1706 },
1707 {
David Nellans64bbb862010-08-24 22:13:30 +02001708 .name = "replay_no_stall",
1709 .type = FIO_OPT_INT,
1710 .off1 = td_var_offset(no_stall),
1711 .def = "0",
Jens Axboe87e7a972010-08-25 09:01:25 +02001712 .parent = "read_iolog",
David Nellans64bbb862010-08-24 22:13:30 +02001713 .help = "Playback IO pattern file as fast as possible without stalls",
1714 },
1715 {
David Nellansd1c46c02010-08-31 21:20:47 +02001716 .name = "replay_redirect",
1717 .type = FIO_OPT_STR_STORE,
1718 .off1 = td_var_offset(replay_redirect),
1719 .parent = "read_iolog",
1720 .help = "Replay all I/O onto this device, regardless of trace device",
1721 },
1722 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001723 .name = "exec_prerun",
1724 .type = FIO_OPT_STR_STORE,
1725 .off1 = td_var_offset(exec_prerun),
1726 .help = "Execute this file prior to running job",
1727 },
1728 {
1729 .name = "exec_postrun",
1730 .type = FIO_OPT_STR_STORE,
1731 .off1 = td_var_offset(exec_postrun),
1732 .help = "Execute this file after running job",
1733 },
1734#ifdef FIO_HAVE_IOSCHED_SWITCH
1735 {
1736 .name = "ioscheduler",
1737 .type = FIO_OPT_STR_STORE,
1738 .off1 = td_var_offset(ioscheduler),
1739 .help = "Use this IO scheduler on the backing device",
1740 },
1741#endif
1742 {
1743 .name = "zonesize",
1744 .type = FIO_OPT_STR_VAL,
1745 .off1 = td_var_offset(zone_size),
Steven Noonaned335852012-01-31 13:58:00 +01001746 .help = "Amount of data to read per zone",
1747 .def = "0",
1748 },
1749 {
1750 .name = "zonerange",
1751 .type = FIO_OPT_STR_VAL,
1752 .off1 = td_var_offset(zone_range),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001753 .help = "Give size of an IO zone",
1754 .def = "0",
1755 },
1756 {
1757 .name = "zoneskip",
1758 .type = FIO_OPT_STR_VAL,
1759 .off1 = td_var_offset(zone_skip),
1760 .help = "Space between IO zones",
1761 .def = "0",
1762 },
1763 {
1764 .name = "lockmem",
1765 .type = FIO_OPT_STR_VAL,
1766 .cb = str_lockmem_cb,
1767 .help = "Lock down this amount of memory",
1768 .def = "0",
1769 },
1770 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001771 .name = "rwmixread",
1772 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001773 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001774 .maxval = 100,
1775 .help = "Percentage of mixed workload that is reads",
1776 .def = "50",
1777 },
1778 {
1779 .name = "rwmixwrite",
1780 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001781 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001782 .maxval = 100,
1783 .help = "Percentage of mixed workload that is writes",
1784 .def = "50",
1785 },
1786 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001787 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001788 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001789 },
1790 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001791 .name = "nice",
1792 .type = FIO_OPT_INT,
1793 .off1 = td_var_offset(nice),
1794 .help = "Set job CPU nice value",
1795 .minval = -19,
1796 .maxval = 20,
1797 .def = "0",
1798 },
1799#ifdef FIO_HAVE_IOPRIO
1800 {
1801 .name = "prio",
1802 .type = FIO_OPT_INT,
1803 .cb = str_prio_cb,
1804 .help = "Set job IO priority value",
1805 .minval = 0,
1806 .maxval = 7,
1807 },
1808 {
1809 .name = "prioclass",
1810 .type = FIO_OPT_INT,
1811 .cb = str_prioclass_cb,
1812 .help = "Set job IO priority class",
1813 .minval = 0,
1814 .maxval = 3,
1815 },
1816#endif
1817 {
1818 .name = "thinktime",
1819 .type = FIO_OPT_INT,
1820 .off1 = td_var_offset(thinktime),
1821 .help = "Idle time between IO buffers (usec)",
1822 .def = "0",
1823 },
1824 {
1825 .name = "thinktime_spin",
1826 .type = FIO_OPT_INT,
1827 .off1 = td_var_offset(thinktime_spin),
1828 .help = "Start think time by spinning this amount (usec)",
1829 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001830 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001831 },
1832 {
1833 .name = "thinktime_blocks",
1834 .type = FIO_OPT_INT,
1835 .off1 = td_var_offset(thinktime_blocks),
1836 .help = "IO buffer period between 'thinktime'",
1837 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001838 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001839 },
1840 {
1841 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001842 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001843 .off1 = td_var_offset(rate[DDIR_READ]),
1844 .off2 = td_var_offset(rate[DDIR_WRITE]),
1845 .off3 = td_var_offset(rate[DDIR_TRIM]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001846 .help = "Set bandwidth rate",
1847 },
1848 {
1849 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001850 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001851 .off1 = td_var_offset(ratemin[DDIR_READ]),
1852 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
1853 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001854 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001855 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001856 },
1857 {
1858 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001859 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001860 .off1 = td_var_offset(rate_iops[DDIR_READ]),
1861 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
1862 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001863 .help = "Limit IO used to this number of IO operations/sec",
1864 },
1865 {
1866 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001867 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001868 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
1869 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
1870 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
Bruce Cran03e20d62011-01-02 20:14:54 +01001871 .help = "Job must meet this rate or it will be shut down",
Jens Axboeafdf9352007-07-31 16:14:34 +02001872 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001873 },
1874 {
1875 .name = "ratecycle",
1876 .type = FIO_OPT_INT,
1877 .off1 = td_var_offset(ratecycle),
1878 .help = "Window average for rate limits (msec)",
1879 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001880 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001881 },
1882 {
1883 .name = "invalidate",
1884 .type = FIO_OPT_BOOL,
1885 .off1 = td_var_offset(invalidate_cache),
1886 .help = "Invalidate buffer/page cache prior to running job",
1887 .def = "1",
1888 },
1889 {
1890 .name = "sync",
1891 .type = FIO_OPT_BOOL,
1892 .off1 = td_var_offset(sync_io),
1893 .help = "Use O_SYNC for buffered writes",
1894 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001895 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001896 },
1897 {
1898 .name = "bwavgtime",
1899 .type = FIO_OPT_INT,
1900 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001901 .help = "Time window over which to calculate bandwidth"
1902 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001903 .def = "500",
Jens Axboec8eeb9d2011-10-05 14:02:22 +02001904 .parent = "write_bw_log",
1905 },
1906 {
1907 .name = "iopsavgtime",
1908 .type = FIO_OPT_INT,
1909 .off1 = td_var_offset(iops_avg_time),
1910 .help = "Time window over which to calculate IOPS (msec)",
1911 .def = "500",
1912 .parent = "write_iops_log",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001913 },
1914 {
1915 .name = "create_serialize",
1916 .type = FIO_OPT_BOOL,
1917 .off1 = td_var_offset(create_serialize),
1918 .help = "Serialize creating of job files",
1919 .def = "1",
1920 },
1921 {
1922 .name = "create_fsync",
1923 .type = FIO_OPT_BOOL,
1924 .off1 = td_var_offset(create_fsync),
Bruce Cran03e20d62011-01-02 20:14:54 +01001925 .help = "fsync file after creation",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001926 .def = "1",
1927 },
1928 {
Jens Axboe814452b2009-03-04 12:53:13 +01001929 .name = "create_on_open",
1930 .type = FIO_OPT_BOOL,
1931 .off1 = td_var_offset(create_on_open),
1932 .help = "Create files when they are opened for IO",
1933 .def = "0",
1934 },
Jens Axboe0b9d69e2009-09-11 22:29:54 +02001935 {
Jens Axboe25460cf2012-05-02 13:58:02 +02001936 .name = "create_only",
1937 .type = FIO_OPT_BOOL,
1938 .off1 = td_var_offset(create_only),
1939 .help = "Only perform file creation phase",
1940 .def = "0",
1941 },
1942 {
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001943 .name = "pre_read",
1944 .type = FIO_OPT_BOOL,
1945 .off1 = td_var_offset(pre_read),
Bruce Cran03e20d62011-01-02 20:14:54 +01001946 .help = "Pre-read files before starting official testing",
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001947 .def = "0",
1948 },
Jens Axboe814452b2009-03-04 12:53:13 +01001949 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001950 .name = "cpuload",
1951 .type = FIO_OPT_INT,
1952 .off1 = td_var_offset(cpuload),
1953 .help = "Use this percentage of CPU",
1954 },
1955 {
1956 .name = "cpuchunks",
1957 .type = FIO_OPT_INT,
1958 .off1 = td_var_offset(cpucycle),
1959 .help = "Length of the CPU burn cycles (usecs)",
1960 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001961 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001962 },
1963#ifdef FIO_HAVE_CPU_AFFINITY
1964 {
1965 .name = "cpumask",
1966 .type = FIO_OPT_INT,
1967 .cb = str_cpumask_cb,
1968 .help = "CPU affinity mask",
1969 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001970 {
1971 .name = "cpus_allowed",
1972 .type = FIO_OPT_STR,
1973 .cb = str_cpus_allowed_cb,
1974 .help = "Set CPUs allowed",
1975 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001976#endif
1977 {
1978 .name = "end_fsync",
1979 .type = FIO_OPT_BOOL,
1980 .off1 = td_var_offset(end_fsync),
1981 .help = "Include fsync at the end of job",
1982 .def = "0",
1983 },
1984 {
1985 .name = "fsync_on_close",
1986 .type = FIO_OPT_BOOL,
1987 .off1 = td_var_offset(fsync_on_close),
1988 .help = "fsync files on close",
1989 .def = "0",
1990 },
1991 {
1992 .name = "unlink",
1993 .type = FIO_OPT_BOOL,
1994 .off1 = td_var_offset(unlink),
1995 .help = "Unlink created files after job has completed",
1996 .def = "0",
1997 },
1998 {
1999 .name = "exitall",
2000 .type = FIO_OPT_STR_SET,
2001 .cb = str_exitall_cb,
2002 .help = "Terminate all jobs when one exits",
2003 },
2004 {
2005 .name = "stonewall",
Jens Axboed3923652011-08-03 12:38:39 +02002006 .alias = "wait_for_previous",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002007 .type = FIO_OPT_STR_SET,
2008 .off1 = td_var_offset(stonewall),
2009 .help = "Insert a hard barrier between this job and previous",
2010 },
2011 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01002012 .name = "new_group",
2013 .type = FIO_OPT_STR_SET,
2014 .off1 = td_var_offset(new_group),
2015 .help = "Mark the start of a new group (for reporting)",
2016 },
2017 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002018 .name = "thread",
2019 .type = FIO_OPT_STR_SET,
2020 .off1 = td_var_offset(use_thread),
2021 .help = "Use threads instead of forks",
2022 },
2023 {
2024 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002025 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002026 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002027 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002028 .help = "Write log of bandwidth during run",
2029 },
2030 {
2031 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002032 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002033 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002034 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002035 .help = "Write log of latency during run",
2036 },
2037 {
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002038 .name = "write_iops_log",
2039 .type = FIO_OPT_STR,
2040 .off1 = td_var_offset(write_iops_log),
2041 .cb = str_write_iops_log_cb,
2042 .help = "Write log of IOPS during run",
2043 },
2044 {
Jens Axboeb8bc8cb2011-12-01 09:04:31 +01002045 .name = "log_avg_msec",
2046 .type = FIO_OPT_INT,
2047 .off1 = td_var_offset(log_avg_msec),
2048 .help = "Average bw/iops/lat logs over this period of time",
2049 .def = "0",
2050 },
2051 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002052 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02002053 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002054 .off1 = td_var_offset(hugepage_size),
2055 .help = "When using hugepages, specify size of each page",
Jens Axboe81179ee2011-10-04 12:42:06 +02002056 .def = __fio_stringify(FIO_HUGE_PAGE),
Jens Axboe214e1ec2007-03-15 10:48:13 +01002057 },
2058 {
2059 .name = "group_reporting",
2060 .type = FIO_OPT_STR_SET,
2061 .off1 = td_var_offset(group_reporting),
2062 .help = "Do reporting on a per-group basis",
2063 },
2064 {
Jens Axboee9459e52007-04-17 15:46:32 +02002065 .name = "zero_buffers",
2066 .type = FIO_OPT_STR_SET,
2067 .off1 = td_var_offset(zero_buffers),
2068 .help = "Init IO buffers to all zeroes",
2069 },
Jens Axboe5973caf2008-05-21 19:52:35 +02002070 {
2071 .name = "refill_buffers",
2072 .type = FIO_OPT_STR_SET,
2073 .off1 = td_var_offset(refill_buffers),
2074 .help = "Refill IO buffers on every IO submit",
2075 },
Yu-ju Hong83349192011-08-13 00:53:44 +02002076 {
Jens Axboefd684182011-09-19 09:24:44 +02002077 .name = "scramble_buffers",
2078 .type = FIO_OPT_BOOL,
2079 .off1 = td_var_offset(scramble_buffers),
2080 .help = "Slightly scramble buffers on every IO submit",
2081 .def = "1",
2082 },
2083 {
Jens Axboe9c426842012-03-02 21:02:12 +01002084 .name = "buffer_compress_percentage",
2085 .type = FIO_OPT_INT,
2086 .off1 = td_var_offset(compress_percentage),
2087 .maxval = 100,
2088 .minval = 1,
2089 .help = "How compressible the buffer is (approximately)",
2090 },
2091 {
Jens Axboef97a43a2012-03-09 19:06:24 +01002092 .name = "buffer_compress_chunk",
2093 .type = FIO_OPT_INT,
2094 .off1 = td_var_offset(compress_chunk),
Jens Axboe207b18e2012-03-09 19:11:25 +01002095 .parent = "buffer_compress_percentage",
Jens Axboef97a43a2012-03-09 19:06:24 +01002096 .help = "Size of compressible region in buffer",
2097 },
2098 {
Yu-ju Hong83349192011-08-13 00:53:44 +02002099 .name = "clat_percentiles",
2100 .type = FIO_OPT_BOOL,
2101 .off1 = td_var_offset(clat_percentiles),
2102 .help = "Enable the reporting of completion latency percentiles",
Jens Axboe467b35e2011-10-13 08:53:24 +02002103 .def = "1",
Yu-ju Hong83349192011-08-13 00:53:44 +02002104 },
2105 {
2106 .name = "percentile_list",
2107 .type = FIO_OPT_FLOAT_LIST,
2108 .off1 = td_var_offset(percentile_list),
2109 .off2 = td_var_offset(overwrite_plist),
2110 .help = "Specify a custom list of percentiles to report",
2111 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2112 .minfp = 0.0,
2113 .maxfp = 100.0,
2114 },
2115
Jens Axboe0a839f32007-04-26 09:02:34 +02002116#ifdef FIO_HAVE_DISK_UTIL
2117 {
2118 .name = "disk_util",
2119 .type = FIO_OPT_BOOL,
2120 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02002121 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02002122 .def = "1",
2123 },
2124#endif
Jens Axboee9459e52007-04-17 15:46:32 +02002125 {
Jens Axboe993bf482008-11-14 13:04:53 +01002126 .name = "gtod_reduce",
2127 .type = FIO_OPT_BOOL,
2128 .help = "Greatly reduce number of gettimeofday() calls",
2129 .cb = str_gtod_reduce_cb,
2130 .def = "0",
2131 },
2132 {
Jens Axboe02af0982010-06-24 09:59:34 +02002133 .name = "disable_lat",
2134 .type = FIO_OPT_BOOL,
2135 .off1 = td_var_offset(disable_lat),
2136 .help = "Disable latency numbers",
2137 .parent = "gtod_reduce",
2138 .def = "0",
2139 },
2140 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02002141 .name = "disable_clat",
2142 .type = FIO_OPT_BOOL,
2143 .off1 = td_var_offset(disable_clat),
2144 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002145 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002146 .def = "0",
2147 },
2148 {
2149 .name = "disable_slat",
2150 .type = FIO_OPT_BOOL,
2151 .off1 = td_var_offset(disable_slat),
Bruce Cran03e20d62011-01-02 20:14:54 +01002152 .help = "Disable submission latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002153 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002154 .def = "0",
2155 },
2156 {
2157 .name = "disable_bw_measurement",
2158 .type = FIO_OPT_BOOL,
2159 .off1 = td_var_offset(disable_bw),
2160 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01002161 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002162 .def = "0",
2163 },
2164 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002165 .name = "gtod_cpu",
2166 .type = FIO_OPT_INT,
2167 .cb = str_gtod_cpu_cb,
Bruce Cran03e20d62011-01-02 20:14:54 +01002168 .help = "Set up dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02002169 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002170 },
2171 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002172 .name = "continue_on_error",
Steven Lang06842022011-11-17 09:45:17 +01002173 .type = FIO_OPT_STR,
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002174 .off1 = td_var_offset(continue_on_error),
Bruce Cran03e20d62011-01-02 20:14:54 +01002175 .help = "Continue on non-fatal errors during IO",
Steven Lang06842022011-11-17 09:45:17 +01002176 .def = "none",
2177 .posval = {
2178 { .ival = "none",
2179 .oval = ERROR_TYPE_NONE,
2180 .help = "Exit when an error is encountered",
2181 },
2182 { .ival = "read",
2183 .oval = ERROR_TYPE_READ,
2184 .help = "Continue on read errors only",
2185 },
2186 { .ival = "write",
2187 .oval = ERROR_TYPE_WRITE,
2188 .help = "Continue on write errors only",
2189 },
2190 { .ival = "io",
2191 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2192 .help = "Continue on any IO errors",
2193 },
2194 { .ival = "verify",
2195 .oval = ERROR_TYPE_VERIFY,
2196 .help = "Continue on verify errors only",
2197 },
2198 { .ival = "all",
2199 .oval = ERROR_TYPE_ANY,
2200 .help = "Continue on all io and verify errors",
2201 },
2202 { .ival = "0",
2203 .oval = ERROR_TYPE_NONE,
2204 .help = "Alias for 'none'",
2205 },
2206 { .ival = "1",
2207 .oval = ERROR_TYPE_ANY,
2208 .help = "Alias for 'all'",
2209 },
2210 },
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002211 },
2212 {
Jens Axboe9ac8a792009-11-13 21:23:07 +01002213 .name = "profile",
Jens Axboe79d16312010-03-04 12:43:20 +01002214 .type = FIO_OPT_STR_STORE,
Jens Axboe9ac8a792009-11-13 21:23:07 +01002215 .off1 = td_var_offset(profile),
Jens Axboe9ac8a792009-11-13 21:23:07 +01002216 .help = "Select a specific builtin performance test",
2217 },
2218 {
Jens Axboea696fa22009-12-04 10:05:02 +01002219 .name = "cgroup",
2220 .type = FIO_OPT_STR_STORE,
2221 .off1 = td_var_offset(cgroup),
2222 .help = "Add job to cgroup of this name",
2223 },
2224 {
2225 .name = "cgroup_weight",
2226 .type = FIO_OPT_INT,
2227 .off1 = td_var_offset(cgroup_weight),
2228 .help = "Use given weight for cgroup",
2229 .minval = 100,
2230 .maxval = 1000,
Jens Axboea696fa22009-12-04 10:05:02 +01002231 },
2232 {
Vivek Goyal7de87092010-03-31 22:55:15 +02002233 .name = "cgroup_nodelete",
2234 .type = FIO_OPT_BOOL,
2235 .off1 = td_var_offset(cgroup_nodelete),
2236 .help = "Do not delete cgroups after job completion",
2237 .def = "0",
2238 },
2239 {
Jens Axboee0b0d892009-12-08 10:10:14 +01002240 .name = "uid",
2241 .type = FIO_OPT_INT,
2242 .off1 = td_var_offset(uid),
2243 .help = "Run job with this user ID",
2244 },
2245 {
2246 .name = "gid",
2247 .type = FIO_OPT_INT,
2248 .off1 = td_var_offset(gid),
2249 .help = "Run job with this group ID",
2250 },
2251 {
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002252 .name = "flow_id",
2253 .type = FIO_OPT_INT,
2254 .off1 = td_var_offset(flow_id),
2255 .help = "The flow index ID to use",
2256 .def = "0",
2257 },
2258 {
2259 .name = "flow",
2260 .type = FIO_OPT_INT,
2261 .off1 = td_var_offset(flow),
2262 .help = "Weight for flow control of this job",
2263 .parent = "flow_id",
2264 .def = "0",
2265 },
2266 {
2267 .name = "flow_watermark",
2268 .type = FIO_OPT_INT,
2269 .off1 = td_var_offset(flow_watermark),
2270 .help = "High watermark for flow control. This option"
2271 " should be set to the same value for all threads"
2272 " with non-zero flow.",
2273 .parent = "flow_id",
2274 .def = "1024",
2275 },
2276 {
2277 .name = "flow_sleep",
2278 .type = FIO_OPT_INT,
2279 .off1 = td_var_offset(flow_sleep),
2280 .help = "How many microseconds to sleep after being held"
2281 " back by the flow control mechanism",
2282 .parent = "flow_id",
2283 .def = "0",
2284 },
2285 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002286 .name = NULL,
2287 },
2288};
2289
Jens Axboe17af15d2010-04-13 10:38:16 +02002290static void add_to_lopt(struct option *lopt, struct fio_option *o,
Steven Langde890a12011-11-09 14:03:34 +01002291 const char *name, int val)
Jens Axboe9f817362010-03-04 14:38:10 +01002292{
Jens Axboe17af15d2010-04-13 10:38:16 +02002293 lopt->name = (char *) name;
Steven Langde890a12011-11-09 14:03:34 +01002294 lopt->val = val;
Jens Axboe9f817362010-03-04 14:38:10 +01002295 if (o->type == FIO_OPT_STR_SET)
2296 lopt->has_arg = no_argument;
2297 else
2298 lopt->has_arg = required_argument;
2299}
2300
Steven Langde890a12011-11-09 14:03:34 +01002301static void options_to_lopts(struct fio_option *opts,
2302 struct option *long_options,
2303 int i, int option_type)
2304{
2305 struct fio_option *o = &opts[0];
2306 while (o->name) {
2307 add_to_lopt(&long_options[i], o, o->name, option_type);
2308 if (o->alias) {
2309 i++;
2310 add_to_lopt(&long_options[i], o, o->alias, option_type);
2311 }
2312
2313 i++;
2314 o++;
2315 assert(i < FIO_NR_OPTIONS);
2316 }
2317}
2318
2319void fio_options_set_ioengine_opts(struct option *long_options,
2320 struct thread_data *td)
2321{
2322 unsigned int i;
2323
2324 i = 0;
2325 while (long_options[i].name) {
2326 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2327 memset(&long_options[i], 0, sizeof(*long_options));
2328 break;
2329 }
2330 i++;
2331 }
2332
2333 /*
2334 * Just clear out the prior ioengine options.
2335 */
2336 if (!td || !td->eo)
2337 return;
2338
2339 options_to_lopts(td->io_ops->options, long_options, i,
2340 FIO_GETOPT_IOENGINE);
2341}
2342
Jens Axboe214e1ec2007-03-15 10:48:13 +01002343void fio_options_dup_and_init(struct option *long_options)
2344{
Jens Axboe214e1ec2007-03-15 10:48:13 +01002345 unsigned int i;
2346
2347 options_init(options);
2348
2349 i = 0;
2350 while (long_options[i].name)
2351 i++;
2352
Steven Langde890a12011-11-09 14:03:34 +01002353 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002354}
2355
Jens Axboe74929ac2009-08-05 11:42:37 +02002356struct fio_keyword {
2357 const char *word;
2358 const char *desc;
2359 char *replace;
2360};
2361
2362static struct fio_keyword fio_keywords[] = {
2363 {
2364 .word = "$pagesize",
2365 .desc = "Page size in the system",
2366 },
2367 {
2368 .word = "$mb_memory",
2369 .desc = "Megabytes of memory online",
2370 },
2371 {
2372 .word = "$ncpus",
2373 .desc = "Number of CPUs online in the system",
2374 },
2375 {
2376 .word = NULL,
2377 },
2378};
2379
2380void fio_keywords_init(void)
2381{
Jens Axboe3b2e1462009-12-15 08:58:10 +01002382 unsigned long long mb_memory;
Jens Axboe74929ac2009-08-05 11:42:37 +02002383 char buf[128];
2384 long l;
2385
2386 sprintf(buf, "%lu", page_size);
2387 fio_keywords[0].replace = strdup(buf);
2388
Jens Axboe8eb016d2011-07-11 10:24:20 +02002389 mb_memory = os_phys_mem() / (1024 * 1024);
Jens Axboe3b2e1462009-12-15 08:58:10 +01002390 sprintf(buf, "%llu", mb_memory);
Jens Axboe74929ac2009-08-05 11:42:37 +02002391 fio_keywords[1].replace = strdup(buf);
2392
Jens Axboec00a2282011-07-08 20:56:06 +02002393 l = cpus_online();
Jens Axboe74929ac2009-08-05 11:42:37 +02002394 sprintf(buf, "%lu", l);
2395 fio_keywords[2].replace = strdup(buf);
2396}
2397
Jens Axboe892a6ff2009-11-13 12:19:49 +01002398#define BC_APP "bc"
2399
2400static char *bc_calc(char *str)
2401{
Steven Langd0c814e2011-10-28 08:37:13 +02002402 char buf[128], *tmp;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002403 FILE *f;
2404 int ret;
2405
2406 /*
2407 * No math, just return string
2408 */
Steven Langd0c814e2011-10-28 08:37:13 +02002409 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2410 !strchr(str, '/')) || strchr(str, '\''))
Jens Axboe892a6ff2009-11-13 12:19:49 +01002411 return str;
2412
2413 /*
2414 * Split option from value, we only need to calculate the value
2415 */
2416 tmp = strchr(str, '=');
2417 if (!tmp)
2418 return str;
2419
2420 tmp++;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002421
Steven Langd0c814e2011-10-28 08:37:13 +02002422 /*
2423 * Prevent buffer overflows; such a case isn't reasonable anyway
2424 */
2425 if (strlen(str) >= 128 || strlen(tmp) > 100)
2426 return str;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002427
2428 sprintf(buf, "which %s > /dev/null", BC_APP);
2429 if (system(buf)) {
2430 log_err("fio: bc is needed for performing math\n");
Jens Axboe892a6ff2009-11-13 12:19:49 +01002431 return NULL;
2432 }
2433
Steven Langd0c814e2011-10-28 08:37:13 +02002434 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002435 f = popen(buf, "r");
2436 if (!f) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002437 return NULL;
2438 }
2439
Steven Langd0c814e2011-10-28 08:37:13 +02002440 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002441 if (ret <= 0) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002442 return NULL;
2443 }
2444
Jens Axboe892a6ff2009-11-13 12:19:49 +01002445 pclose(f);
Steven Langd0c814e2011-10-28 08:37:13 +02002446 buf[(tmp - str) + ret - 1] = '\0';
2447 memcpy(buf, str, tmp - str);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002448 free(str);
Steven Langd0c814e2011-10-28 08:37:13 +02002449 return strdup(buf);
2450}
2451
2452/*
2453 * Return a copy of the input string with substrings of the form ${VARNAME}
2454 * substituted with the value of the environment variable VARNAME. The
2455 * substitution always occurs, even if VARNAME is empty or the corresponding
2456 * environment variable undefined.
2457 */
2458static char *option_dup_subs(const char *opt)
2459{
2460 char out[OPT_LEN_MAX+1];
2461 char in[OPT_LEN_MAX+1];
2462 char *outptr = out;
2463 char *inptr = in;
2464 char *ch1, *ch2, *env;
2465 ssize_t nchr = OPT_LEN_MAX;
2466 size_t envlen;
2467
2468 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2469 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2470 return NULL;
2471 }
2472
2473 in[OPT_LEN_MAX] = '\0';
2474 strncpy(in, opt, OPT_LEN_MAX);
2475
2476 while (*inptr && nchr > 0) {
2477 if (inptr[0] == '$' && inptr[1] == '{') {
2478 ch2 = strchr(inptr, '}');
2479 if (ch2 && inptr+1 < ch2) {
2480 ch1 = inptr+2;
2481 inptr = ch2+1;
2482 *ch2 = '\0';
2483
2484 env = getenv(ch1);
2485 if (env) {
2486 envlen = strlen(env);
2487 if (envlen <= nchr) {
2488 memcpy(outptr, env, envlen);
2489 outptr += envlen;
2490 nchr -= envlen;
2491 }
2492 }
2493
2494 continue;
2495 }
2496 }
2497
2498 *outptr++ = *inptr++;
2499 --nchr;
2500 }
2501
2502 *outptr = '\0';
2503 return strdup(out);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002504}
2505
Jens Axboe74929ac2009-08-05 11:42:37 +02002506/*
2507 * Look for reserved variable names and replace them with real values
2508 */
2509static char *fio_keyword_replace(char *opt)
2510{
2511 char *s;
2512 int i;
Steven Langd0c814e2011-10-28 08:37:13 +02002513 int docalc = 0;
Jens Axboe74929ac2009-08-05 11:42:37 +02002514
2515 for (i = 0; fio_keywords[i].word != NULL; i++) {
2516 struct fio_keyword *kw = &fio_keywords[i];
2517
2518 while ((s = strstr(opt, kw->word)) != NULL) {
2519 char *new = malloc(strlen(opt) + 1);
2520 char *o_org = opt;
2521 int olen = s - opt;
2522 int len;
2523
2524 /*
2525 * Copy part of the string before the keyword and
2526 * sprintf() the replacement after it.
2527 */
2528 memcpy(new, opt, olen);
2529 len = sprintf(new + olen, "%s", kw->replace);
2530
2531 /*
2532 * If there's more in the original string, copy that
2533 * in too
2534 */
2535 opt += strlen(kw->word) + olen;
2536 if (strlen(opt))
2537 memcpy(new + olen + len, opt, opt - o_org - 1);
2538
2539 /*
2540 * replace opt and free the old opt
2541 */
2542 opt = new;
Steven Langd0c814e2011-10-28 08:37:13 +02002543 free(o_org);
Jens Axboe7a958bd2009-11-13 12:33:54 +01002544
Steven Langd0c814e2011-10-28 08:37:13 +02002545 docalc = 1;
Jens Axboe74929ac2009-08-05 11:42:37 +02002546 }
2547 }
2548
Steven Langd0c814e2011-10-28 08:37:13 +02002549 /*
2550 * Check for potential math and invoke bc, if possible
2551 */
2552 if (docalc)
2553 opt = bc_calc(opt);
2554
Jens Axboe7a958bd2009-11-13 12:33:54 +01002555 return opt;
Jens Axboe74929ac2009-08-05 11:42:37 +02002556}
2557
Steven Langd0c814e2011-10-28 08:37:13 +02002558static char **dup_and_sub_options(char **opts, int num_opts)
2559{
2560 int i;
2561 char **opts_copy = malloc(num_opts * sizeof(*opts));
2562 for (i = 0; i < num_opts; i++) {
2563 opts_copy[i] = option_dup_subs(opts[i]);
2564 if (!opts_copy[i])
2565 continue;
2566 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2567 }
2568 return opts_copy;
2569}
2570
Jens Axboe3b8b7132008-06-10 19:46:23 +02002571int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01002572{
Steven Langde890a12011-11-09 14:03:34 +01002573 int i, ret, unknown;
Steven Langd0c814e2011-10-28 08:37:13 +02002574 char **opts_copy;
Jens Axboe3b8b7132008-06-10 19:46:23 +02002575
2576 sort_options(opts, options, num_opts);
Steven Langd0c814e2011-10-28 08:37:13 +02002577 opts_copy = dup_and_sub_options(opts, num_opts);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002578
Steven Langde890a12011-11-09 14:03:34 +01002579 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2580 struct fio_option *o;
2581 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2582 td);
Steven Langd0c814e2011-10-28 08:37:13 +02002583
Steven Langde890a12011-11-09 14:03:34 +01002584 if (opts_copy[i]) {
2585 if (newret && !o) {
2586 unknown++;
2587 continue;
2588 }
Steven Langd0c814e2011-10-28 08:37:13 +02002589 free(opts_copy[i]);
Steven Langde890a12011-11-09 14:03:34 +01002590 opts_copy[i] = NULL;
2591 }
2592
2593 ret |= newret;
2594 }
2595
2596 if (unknown) {
2597 ret |= ioengine_load(td);
2598 if (td->eo) {
2599 sort_options(opts_copy, td->io_ops->options, num_opts);
2600 opts = opts_copy;
2601 }
2602 for (i = 0; i < num_opts; i++) {
2603 struct fio_option *o = NULL;
2604 int newret = 1;
2605 if (!opts_copy[i])
2606 continue;
2607
2608 if (td->eo)
2609 newret = parse_option(opts_copy[i], opts[i],
2610 td->io_ops->options, &o,
2611 td->eo);
2612
2613 ret |= newret;
2614 if (!o)
2615 log_err("Bad option <%s>\n", opts[i]);
2616
2617 free(opts_copy[i]);
2618 opts_copy[i] = NULL;
2619 }
Jens Axboe74929ac2009-08-05 11:42:37 +02002620 }
Jens Axboe3b8b7132008-06-10 19:46:23 +02002621
Steven Langd0c814e2011-10-28 08:37:13 +02002622 free(opts_copy);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002623 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01002624}
2625
2626int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2627{
Jens Axboe07b32322010-03-05 09:48:44 +01002628 return parse_cmd_option(opt, val, options, td);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002629}
2630
Steven Langde890a12011-11-09 14:03:34 +01002631int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2632 char *val)
2633{
2634 return parse_cmd_option(opt, val, td->io_ops->options, td);
2635}
2636
Jens Axboe214e1ec2007-03-15 10:48:13 +01002637void fio_fill_default_options(struct thread_data *td)
2638{
2639 fill_default_options(td, options);
2640}
2641
2642int fio_show_option_help(const char *opt)
2643{
Jens Axboe07b32322010-03-05 09:48:44 +01002644 return show_cmd_help(options, opt);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002645}
Jens Axboed23bb322007-03-23 15:57:56 +01002646
Steven Langde890a12011-11-09 14:03:34 +01002647void options_mem_dupe(void *data, struct fio_option *options)
2648{
2649 struct fio_option *o;
2650 char **ptr;
2651
2652 for (o = &options[0]; o->name; o++) {
2653 if (o->type != FIO_OPT_STR_STORE)
2654 continue;
2655
2656 ptr = td_var(data, o->off1);
2657 if (*ptr)
2658 *ptr = strdup(*ptr);
2659 }
2660}
2661
Jens Axboe7e356b22011-10-14 10:55:16 +02002662/*
2663 * dupe FIO_OPT_STR_STORE options
2664 */
Steven Langde890a12011-11-09 14:03:34 +01002665void fio_options_mem_dupe(struct thread_data *td)
Jens Axboed23bb322007-03-23 15:57:56 +01002666{
Steven Langde890a12011-11-09 14:03:34 +01002667 options_mem_dupe(&td->o, options);
Jens Axboe1647f592011-11-09 20:25:21 +01002668
2669 if (td->eo && td->io_ops) {
Steven Langde890a12011-11-09 14:03:34 +01002670 void *oldeo = td->eo;
Jens Axboe1647f592011-11-09 20:25:21 +01002671
Steven Langde890a12011-11-09 14:03:34 +01002672 td->eo = malloc(td->io_ops->option_struct_size);
2673 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2674 options_mem_dupe(td->eo, td->io_ops->options);
Jens Axboed23bb322007-03-23 15:57:56 +01002675 }
2676}
2677
Jens Axboed6978a32009-07-18 21:04:09 +02002678unsigned int fio_get_kb_base(void *data)
2679{
2680 struct thread_data *td = data;
2681 unsigned int kb_base = 0;
2682
2683 if (td)
2684 kb_base = td->o.kb_base;
2685 if (!kb_base)
2686 kb_base = 1024;
2687
2688 return kb_base;
2689}
Jens Axboe9f988e22010-03-04 10:42:38 +01002690
Jens Axboe07b32322010-03-05 09:48:44 +01002691int add_option(struct fio_option *o)
Jens Axboe9f988e22010-03-04 10:42:38 +01002692{
Jens Axboe07b32322010-03-05 09:48:44 +01002693 struct fio_option *__o;
2694 int opt_index = 0;
2695
2696 __o = options;
2697 while (__o->name) {
2698 opt_index++;
2699 __o++;
2700 }
2701
2702 memcpy(&options[opt_index], o, sizeof(*o));
2703 return 0;
Jens Axboe9f988e22010-03-04 10:42:38 +01002704}
Jens Axboee2de69d2010-03-04 14:05:48 +01002705
Jens Axboe07b32322010-03-05 09:48:44 +01002706void invalidate_profile_options(const char *prof_name)
Jens Axboee2de69d2010-03-04 14:05:48 +01002707{
Jens Axboe07b32322010-03-05 09:48:44 +01002708 struct fio_option *o;
Jens Axboee2de69d2010-03-04 14:05:48 +01002709
Jens Axboe07b32322010-03-05 09:48:44 +01002710 o = options;
2711 while (o->name) {
2712 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2713 o->type = FIO_OPT_INVALID;
2714 o->prof_name = NULL;
2715 }
2716 o++;
Jens Axboee2de69d2010-03-04 14:05:48 +01002717 }
2718}
Jens Axboef5b6bb82010-03-05 10:09:59 +01002719
2720void add_opt_posval(const char *optname, const char *ival, const char *help)
2721{
2722 struct fio_option *o;
2723 unsigned int i;
2724
2725 o = find_option(options, optname);
2726 if (!o)
2727 return;
2728
2729 for (i = 0; i < PARSE_MAX_VP; i++) {
2730 if (o->posval[i].ival)
2731 continue;
2732
2733 o->posval[i].ival = ival;
2734 o->posval[i].help = help;
2735 break;
2736 }
2737}
2738
2739void del_opt_posval(const char *optname, const char *ival)
2740{
2741 struct fio_option *o;
2742 unsigned int i;
2743
2744 o = find_option(options, optname);
2745 if (!o)
2746 return;
2747
2748 for (i = 0; i < PARSE_MAX_VP; i++) {
2749 if (!o->posval[i].ival)
2750 continue;
2751 if (strcmp(o->posval[i].ival, ival))
2752 continue;
2753
2754 o->posval[i].ival = NULL;
2755 o->posval[i].help = NULL;
2756 }
2757}
Jens Axboe7e356b22011-10-14 10:55:16 +02002758
2759void fio_options_free(struct thread_data *td)
2760{
2761 options_free(options, td);
Steven Langde890a12011-11-09 14:03:34 +01002762 if (td->eo && td->io_ops && td->io_ops->options) {
2763 options_free(td->io_ops->options, td->eo);
2764 free(td->eo);
2765 td->eo = NULL;
2766 }
Jens Axboe7e356b22011-10-14 10:55:16 +02002767}