Commit | Line | Data |
---|---|---|
214e1eca JA |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <unistd.h> | |
4 | #include <ctype.h> | |
5 | #include <string.h> | |
6 | #include <getopt.h> | |
7 | #include <assert.h> | |
921c766f | 8 | #include <libgen.h> |
5921e80c JA |
9 | #include <fcntl.h> |
10 | #include <sys/types.h> | |
11 | #include <sys/stat.h> | |
214e1eca JA |
12 | |
13 | #include "fio.h" | |
14 | #include "parse.h" | |
eef32359 | 15 | #include "lib/fls.h" |
214e1eca | 16 | |
2dc1bbeb | 17 | #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var) |
214e1eca JA |
18 | |
19 | /* | |
20 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. | |
21 | */ | |
22 | static char *get_opt_postfix(const char *str) | |
23 | { | |
24 | char *p = strstr(str, ":"); | |
25 | ||
26 | if (!p) | |
27 | return NULL; | |
28 | ||
29 | p++; | |
30 | strip_blank_front(&p); | |
31 | strip_blank_end(p); | |
32 | return strdup(p); | |
33 | } | |
34 | ||
564ca972 JA |
35 | static int bs_cmp(const void *p1, const void *p2) |
36 | { | |
37 | const struct bssplit *bsp1 = p1; | |
38 | const struct bssplit *bsp2 = p2; | |
39 | ||
40 | return bsp1->perc < bsp2->perc; | |
41 | } | |
42 | ||
43 | static int str_bssplit_cb(void *data, const char *input) | |
44 | { | |
45 | struct thread_data *td = data; | |
46 | char *fname, *str, *p; | |
47 | unsigned int i, perc, perc_missing; | |
48 | unsigned int max_bs, min_bs; | |
49 | long long val; | |
50 | ||
51 | p = str = strdup(input); | |
52 | ||
53 | strip_blank_front(&str); | |
54 | strip_blank_end(str); | |
55 | ||
56 | td->o.bssplit_nr = 4; | |
57 | td->o.bssplit = malloc(4 * sizeof(struct bssplit)); | |
58 | ||
59 | i = 0; | |
60 | max_bs = 0; | |
61 | min_bs = -1; | |
62 | while ((fname = strsep(&str, ":")) != NULL) { | |
63 | char *perc_str; | |
64 | ||
65 | if (!strlen(fname)) | |
66 | break; | |
67 | ||
68 | /* | |
69 | * grow struct buffer, if needed | |
70 | */ | |
71 | if (i == td->o.bssplit_nr) { | |
72 | td->o.bssplit_nr <<= 1; | |
5ec10eaa JA |
73 | td->o.bssplit = realloc(td->o.bssplit, |
74 | td->o.bssplit_nr | |
75 | * sizeof(struct bssplit)); | |
564ca972 JA |
76 | } |
77 | ||
78 | perc_str = strstr(fname, "/"); | |
79 | if (perc_str) { | |
80 | *perc_str = '\0'; | |
81 | perc_str++; | |
82 | perc = atoi(perc_str); | |
83 | if (perc > 100) | |
84 | perc = 100; | |
85 | else if (!perc) | |
86 | perc = -1; | |
87 | } else | |
88 | perc = -1; | |
89 | ||
90 | if (str_to_decimal(fname, &val, 1)) { | |
91 | log_err("fio: bssplit conversion failed\n"); | |
92 | free(td->o.bssplit); | |
93 | return 1; | |
94 | } | |
95 | ||
96 | if (val > max_bs) | |
97 | max_bs = val; | |
98 | if (val < min_bs) | |
99 | min_bs = val; | |
100 | ||
101 | td->o.bssplit[i].bs = val; | |
102 | td->o.bssplit[i].perc = perc; | |
103 | i++; | |
104 | } | |
105 | ||
106 | td->o.bssplit_nr = i; | |
107 | ||
108 | /* | |
109 | * Now check if the percentages add up, and how much is missing | |
110 | */ | |
111 | perc = perc_missing = 0; | |
112 | for (i = 0; i < td->o.bssplit_nr; i++) { | |
113 | struct bssplit *bsp = &td->o.bssplit[i]; | |
114 | ||
115 | if (bsp->perc == (unsigned char) -1) | |
116 | perc_missing++; | |
117 | else | |
118 | perc += bsp->perc; | |
119 | } | |
120 | ||
121 | if (perc > 100) { | |
122 | log_err("fio: bssplit percentages add to more than 100%%\n"); | |
123 | free(td->o.bssplit); | |
124 | return 1; | |
125 | } | |
126 | /* | |
127 | * If values didn't have a percentage set, divide the remains between | |
128 | * them. | |
129 | */ | |
130 | if (perc_missing) { | |
131 | for (i = 0; i < td->o.bssplit_nr; i++) { | |
132 | struct bssplit *bsp = &td->o.bssplit[i]; | |
133 | ||
134 | if (bsp->perc == (unsigned char) -1) | |
135 | bsp->perc = (100 - perc) / perc_missing; | |
136 | } | |
137 | } | |
138 | ||
139 | td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs; | |
140 | td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs; | |
141 | ||
142 | /* | |
143 | * now sort based on percentages, for ease of lookup | |
144 | */ | |
145 | qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp); | |
146 | ||
147 | free(p); | |
148 | return 0; | |
149 | } | |
150 | ||
211097b2 JA |
151 | static int str_rw_cb(void *data, const char *str) |
152 | { | |
153 | struct thread_data *td = data; | |
154 | char *nr = get_opt_postfix(str); | |
155 | ||
fafdba3c | 156 | td->o.ddir_nr = 1; |
182ec6ee | 157 | if (nr) { |
211097b2 | 158 | td->o.ddir_nr = atoi(nr); |
182ec6ee JA |
159 | free(nr); |
160 | } | |
211097b2 | 161 | |
211097b2 JA |
162 | return 0; |
163 | } | |
164 | ||
214e1eca JA |
165 | static int str_mem_cb(void *data, const char *mem) |
166 | { | |
167 | struct thread_data *td = data; | |
168 | ||
2dc1bbeb | 169 | if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) { |
214e1eca | 170 | td->mmapfile = get_opt_postfix(mem); |
2dc1bbeb | 171 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
214e1eca JA |
172 | log_err("fio: mmaphuge:/path/to/file\n"); |
173 | return 1; | |
174 | } | |
175 | } | |
176 | ||
177 | return 0; | |
178 | } | |
179 | ||
180 | static int str_lockmem_cb(void fio_unused *data, unsigned long *val) | |
181 | { | |
182 | mlock_size = *val; | |
183 | return 0; | |
184 | } | |
185 | ||
cb499fc4 JA |
186 | static int str_rwmix_read_cb(void *data, unsigned int *val) |
187 | { | |
188 | struct thread_data *td = data; | |
189 | ||
190 | td->o.rwmix[DDIR_READ] = *val; | |
191 | td->o.rwmix[DDIR_WRITE] = 100 - *val; | |
192 | return 0; | |
193 | } | |
194 | ||
195 | static int str_rwmix_write_cb(void *data, unsigned int *val) | |
196 | { | |
197 | struct thread_data *td = data; | |
198 | ||
199 | td->o.rwmix[DDIR_WRITE] = *val; | |
200 | td->o.rwmix[DDIR_READ] = 100 - *val; | |
201 | return 0; | |
202 | } | |
203 | ||
214e1eca JA |
204 | #ifdef FIO_HAVE_IOPRIO |
205 | static int str_prioclass_cb(void *data, unsigned int *val) | |
206 | { | |
207 | struct thread_data *td = data; | |
6cefbe33 JA |
208 | unsigned short mask; |
209 | ||
210 | /* | |
211 | * mask off old class bits, str_prio_cb() may have set a default class | |
212 | */ | |
213 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; | |
214 | td->ioprio &= mask; | |
214e1eca JA |
215 | |
216 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; | |
ac684785 | 217 | td->ioprio_set = 1; |
214e1eca JA |
218 | return 0; |
219 | } | |
220 | ||
221 | static int str_prio_cb(void *data, unsigned int *val) | |
222 | { | |
223 | struct thread_data *td = data; | |
224 | ||
225 | td->ioprio |= *val; | |
6cefbe33 JA |
226 | |
227 | /* | |
228 | * If no class is set, assume BE | |
229 | */ | |
230 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) | |
231 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; | |
232 | ||
ac684785 | 233 | td->ioprio_set = 1; |
214e1eca JA |
234 | return 0; |
235 | } | |
236 | #endif | |
237 | ||
238 | static int str_exitall_cb(void) | |
239 | { | |
240 | exitall_on_terminate = 1; | |
241 | return 0; | |
242 | } | |
243 | ||
214e1eca | 244 | #ifdef FIO_HAVE_CPU_AFFINITY |
d2e268b0 JA |
245 | static int str_cpumask_cb(void *data, unsigned int *val) |
246 | { | |
247 | struct thread_data *td = data; | |
214e1eca | 248 | unsigned int i; |
b03daafb | 249 | long max_cpu; |
d2ce18b5 JA |
250 | int ret; |
251 | ||
252 | ret = fio_cpuset_init(&td->o.cpumask); | |
253 | if (ret < 0) { | |
254 | log_err("fio: cpuset_init failed\n"); | |
255 | td_verror(td, ret, "fio_cpuset_init"); | |
256 | return 1; | |
257 | } | |
214e1eca | 258 | |
b03daafb | 259 | max_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
214e1eca | 260 | |
62a7273d JA |
261 | for (i = 0; i < sizeof(int) * 8; i++) { |
262 | if ((1 << i) & *val) { | |
b03daafb JA |
263 | if (i > max_cpu) { |
264 | log_err("fio: CPU %d too large (max=%ld)\n", i, | |
265 | max_cpu); | |
266 | return 1; | |
267 | } | |
62a7273d | 268 | dprint(FD_PARSE, "set cpu allowed %d\n", i); |
6d459ee7 | 269 | fio_cpu_set(&td->o.cpumask, i); |
62a7273d JA |
270 | } |
271 | } | |
d2e268b0 JA |
272 | |
273 | td->o.cpumask_set = 1; | |
274 | return 0; | |
214e1eca JA |
275 | } |
276 | ||
d2e268b0 | 277 | static int str_cpus_allowed_cb(void *data, const char *input) |
214e1eca JA |
278 | { |
279 | struct thread_data *td = data; | |
d2e268b0 | 280 | char *cpu, *str, *p; |
b03daafb | 281 | long max_cpu; |
19608d6c | 282 | int ret = 0; |
d2e268b0 | 283 | |
d2ce18b5 JA |
284 | ret = fio_cpuset_init(&td->o.cpumask); |
285 | if (ret < 0) { | |
286 | log_err("fio: cpuset_init failed\n"); | |
287 | td_verror(td, ret, "fio_cpuset_init"); | |
288 | return 1; | |
289 | } | |
d2e268b0 JA |
290 | |
291 | p = str = strdup(input); | |
214e1eca | 292 | |
d2e268b0 JA |
293 | strip_blank_front(&str); |
294 | strip_blank_end(str); | |
295 | ||
b03daafb JA |
296 | max_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
297 | ||
d2e268b0 | 298 | while ((cpu = strsep(&str, ",")) != NULL) { |
62a7273d JA |
299 | char *str2, *cpu2; |
300 | int icpu, icpu2; | |
301 | ||
d2e268b0 JA |
302 | if (!strlen(cpu)) |
303 | break; | |
62a7273d JA |
304 | |
305 | str2 = cpu; | |
306 | icpu2 = -1; | |
307 | while ((cpu2 = strsep(&str2, "-")) != NULL) { | |
308 | if (!strlen(cpu2)) | |
309 | break; | |
310 | ||
311 | icpu2 = atoi(cpu2); | |
312 | } | |
313 | ||
314 | icpu = atoi(cpu); | |
315 | if (icpu2 == -1) | |
316 | icpu2 = icpu; | |
317 | while (icpu <= icpu2) { | |
6d459ee7 | 318 | if (icpu >= FIO_MAX_CPUS) { |
19608d6c | 319 | log_err("fio: your OS only supports up to" |
6d459ee7 | 320 | " %d CPUs\n", (int) FIO_MAX_CPUS); |
19608d6c JA |
321 | ret = 1; |
322 | break; | |
323 | } | |
b03daafb JA |
324 | if (icpu > max_cpu) { |
325 | log_err("fio: CPU %d too large (max=%ld)\n", | |
326 | icpu, max_cpu); | |
327 | ret = 1; | |
328 | break; | |
329 | } | |
330 | ||
62a7273d | 331 | dprint(FD_PARSE, "set cpu allowed %d\n", icpu); |
6d459ee7 | 332 | fio_cpu_set(&td->o.cpumask, icpu); |
62a7273d JA |
333 | icpu++; |
334 | } | |
19608d6c JA |
335 | if (ret) |
336 | break; | |
d2e268b0 JA |
337 | } |
338 | ||
339 | free(p); | |
19608d6c JA |
340 | if (!ret) |
341 | td->o.cpumask_set = 1; | |
342 | return ret; | |
214e1eca | 343 | } |
d2e268b0 | 344 | #endif |
214e1eca JA |
345 | |
346 | static int str_fst_cb(void *data, const char *str) | |
347 | { | |
348 | struct thread_data *td = data; | |
349 | char *nr = get_opt_postfix(str); | |
350 | ||
351 | td->file_service_nr = 1; | |
182ec6ee | 352 | if (nr) { |
214e1eca | 353 | td->file_service_nr = atoi(nr); |
182ec6ee JA |
354 | free(nr); |
355 | } | |
214e1eca JA |
356 | |
357 | return 0; | |
358 | } | |
359 | ||
921c766f JA |
360 | static int check_dir(struct thread_data *td, char *fname) |
361 | { | |
362 | char file[PATH_MAX], *dir; | |
bc838919 | 363 | int elen = 0; |
921c766f | 364 | |
bc838919 JA |
365 | if (td->o.directory) { |
366 | strcpy(file, td->o.directory); | |
fcef0b35 | 367 | strcat(file, "/"); |
bc838919 JA |
368 | elen = strlen(file); |
369 | } | |
370 | ||
fcef0b35 | 371 | sprintf(file + elen, "%s", fname); |
921c766f JA |
372 | dir = dirname(file); |
373 | ||
fcef0b35 JA |
374 | #if 0 |
375 | { | |
376 | struct stat sb; | |
377 | /* | |
378 | * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded | |
379 | * yet, so we can't do this check right here... | |
380 | */ | |
921c766f JA |
381 | if (lstat(dir, &sb) < 0) { |
382 | int ret = errno; | |
383 | ||
384 | log_err("fio: %s is not a directory\n", dir); | |
385 | td_verror(td, ret, "lstat"); | |
386 | return 1; | |
387 | } | |
388 | ||
389 | if (!S_ISDIR(sb.st_mode)) { | |
390 | log_err("fio: %s is not a directory\n", dir); | |
391 | return 1; | |
392 | } | |
fcef0b35 JA |
393 | } |
394 | #endif | |
921c766f JA |
395 | |
396 | return 0; | |
397 | } | |
398 | ||
214e1eca JA |
399 | static int str_filename_cb(void *data, const char *input) |
400 | { | |
401 | struct thread_data *td = data; | |
402 | char *fname, *str, *p; | |
403 | ||
404 | p = str = strdup(input); | |
405 | ||
406 | strip_blank_front(&str); | |
407 | strip_blank_end(str); | |
408 | ||
409 | if (!td->files_index) | |
2dc1bbeb | 410 | td->o.nr_files = 0; |
214e1eca JA |
411 | |
412 | while ((fname = strsep(&str, ":")) != NULL) { | |
413 | if (!strlen(fname)) | |
414 | break; | |
921c766f JA |
415 | if (check_dir(td, fname)) { |
416 | free(p); | |
417 | return 1; | |
418 | } | |
214e1eca | 419 | add_file(td, fname); |
2dc1bbeb | 420 | td->o.nr_files++; |
214e1eca JA |
421 | } |
422 | ||
423 | free(p); | |
424 | return 0; | |
425 | } | |
426 | ||
427 | static int str_directory_cb(void *data, const char fio_unused *str) | |
428 | { | |
429 | struct thread_data *td = data; | |
430 | struct stat sb; | |
431 | ||
2dc1bbeb | 432 | if (lstat(td->o.directory, &sb) < 0) { |
921c766f JA |
433 | int ret = errno; |
434 | ||
2dc1bbeb | 435 | log_err("fio: %s is not a directory\n", td->o.directory); |
921c766f | 436 | td_verror(td, ret, "lstat"); |
214e1eca JA |
437 | return 1; |
438 | } | |
439 | if (!S_ISDIR(sb.st_mode)) { | |
2dc1bbeb | 440 | log_err("fio: %s is not a directory\n", td->o.directory); |
214e1eca JA |
441 | return 1; |
442 | } | |
443 | ||
444 | return 0; | |
445 | } | |
446 | ||
447 | static int str_opendir_cb(void *data, const char fio_unused *str) | |
448 | { | |
449 | struct thread_data *td = data; | |
450 | ||
451 | if (!td->files_index) | |
2dc1bbeb | 452 | td->o.nr_files = 0; |
214e1eca | 453 | |
2dc1bbeb | 454 | return add_dir_files(td, td->o.opendir); |
214e1eca JA |
455 | } |
456 | ||
a59e170d | 457 | static int str_verify_offset_cb(void *data, unsigned int *off) |
546a9142 SL |
458 | { |
459 | struct thread_data *td = data; | |
a59e170d | 460 | |
546a9142 | 461 | if (*off && *off < sizeof(struct verify_header)) { |
a59e170d | 462 | log_err("fio: verify_offset too small\n"); |
546a9142 SL |
463 | return 1; |
464 | } | |
a59e170d JA |
465 | |
466 | td->o.verify_offset = *off; | |
546a9142 SL |
467 | return 0; |
468 | } | |
469 | ||
e28218f3 | 470 | static int str_verify_pattern_cb(void *data, unsigned int *off) |
90059d65 JA |
471 | { |
472 | struct thread_data *td = data; | |
e28218f3 | 473 | unsigned int msb; |
90059d65 | 474 | |
3c48c2c1 | 475 | msb = __fls(*off); |
90059d65 JA |
476 | if (msb <= 8) |
477 | td->o.verify_pattern_bytes = 1; | |
478 | else if (msb <= 16) | |
479 | td->o.verify_pattern_bytes = 2; | |
480 | else if (msb <= 24) | |
481 | td->o.verify_pattern_bytes = 3; | |
482 | else | |
483 | td->o.verify_pattern_bytes = 4; | |
484 | ||
e28218f3 | 485 | td->o.verify_pattern = *off; |
90059d65 JA |
486 | return 0; |
487 | } | |
214e1eca | 488 | |
4d4e80f2 JA |
489 | static int str_lockfile_cb(void *data, const char *str) |
490 | { | |
491 | struct thread_data *td = data; | |
492 | char *nr = get_opt_postfix(str); | |
493 | ||
494 | td->o.lockfile_batch = 1; | |
182ec6ee | 495 | if (nr) { |
4d4e80f2 | 496 | td->o.lockfile_batch = atoi(nr); |
182ec6ee JA |
497 | free(nr); |
498 | } | |
4d4e80f2 JA |
499 | |
500 | return 0; | |
501 | } | |
502 | ||
e3cedca7 JA |
503 | static int str_write_bw_log_cb(void *data, const char *str) |
504 | { | |
505 | struct thread_data *td = data; | |
506 | ||
507 | if (str) | |
508 | td->o.bw_log_file = strdup(str); | |
509 | ||
510 | td->o.write_bw_log = 1; | |
511 | return 0; | |
512 | } | |
513 | ||
514 | static int str_write_lat_log_cb(void *data, const char *str) | |
515 | { | |
516 | struct thread_data *td = data; | |
517 | ||
518 | if (str) | |
519 | td->o.lat_log_file = strdup(str); | |
520 | ||
521 | td->o.write_lat_log = 1; | |
522 | return 0; | |
523 | } | |
524 | ||
993bf48b JA |
525 | static int str_gtod_reduce_cb(void *data, int *il) |
526 | { | |
527 | struct thread_data *td = data; | |
528 | int val = *il; | |
529 | ||
530 | td->o.disable_clat = !!val; | |
531 | td->o.disable_slat = !!val; | |
532 | td->o.disable_bw = !!val; | |
533 | if (val) | |
534 | td->tv_cache_mask = 63; | |
535 | ||
536 | return 0; | |
537 | } | |
538 | ||
be4ecfdf JA |
539 | static int str_gtod_cpu_cb(void *data, int *il) |
540 | { | |
541 | struct thread_data *td = data; | |
542 | int val = *il; | |
543 | ||
544 | td->o.gtod_cpu = val; | |
545 | td->o.gtod_offload = 1; | |
546 | return 0; | |
547 | } | |
548 | ||
214e1eca JA |
549 | #define __stringify_1(x) #x |
550 | #define __stringify(x) __stringify_1(x) | |
551 | ||
552 | /* | |
553 | * Map of job/command line options | |
554 | */ | |
555 | static struct fio_option options[] = { | |
556 | { | |
557 | .name = "description", | |
558 | .type = FIO_OPT_STR_STORE, | |
559 | .off1 = td_var_offset(description), | |
560 | .help = "Text job description", | |
561 | }, | |
562 | { | |
563 | .name = "name", | |
564 | .type = FIO_OPT_STR_STORE, | |
565 | .off1 = td_var_offset(name), | |
566 | .help = "Name of this job", | |
567 | }, | |
568 | { | |
569 | .name = "directory", | |
570 | .type = FIO_OPT_STR_STORE, | |
571 | .off1 = td_var_offset(directory), | |
572 | .cb = str_directory_cb, | |
573 | .help = "Directory to store files in", | |
574 | }, | |
575 | { | |
576 | .name = "filename", | |
577 | .type = FIO_OPT_STR_STORE, | |
578 | .off1 = td_var_offset(filename), | |
579 | .cb = str_filename_cb, | |
3b8b7135 | 580 | .prio = 1, /* must come before "directory" */ |
214e1eca JA |
581 | .help = "File(s) to use for the workload", |
582 | }, | |
29c1349f JA |
583 | { |
584 | .name = "lockfile", | |
4d4e80f2 JA |
585 | .type = FIO_OPT_STR, |
586 | .cb = str_lockfile_cb, | |
587 | .off1 = td_var_offset(file_lock_mode), | |
29c1349f JA |
588 | .help = "Lock file when doing IO to it", |
589 | .parent = "filename", | |
4d4e80f2 JA |
590 | .def = "none", |
591 | .posval = { | |
592 | { .ival = "none", | |
593 | .oval = FILE_LOCK_NONE, | |
594 | .help = "No file locking", | |
595 | }, | |
596 | { .ival = "exclusive", | |
597 | .oval = FILE_LOCK_EXCLUSIVE, | |
598 | .help = "Exclusive file lock", | |
599 | }, | |
600 | { | |
601 | .ival = "readwrite", | |
602 | .oval = FILE_LOCK_READWRITE, | |
603 | .help = "Read vs write lock", | |
604 | }, | |
605 | }, | |
29c1349f | 606 | }, |
214e1eca JA |
607 | { |
608 | .name = "opendir", | |
609 | .type = FIO_OPT_STR_STORE, | |
610 | .off1 = td_var_offset(opendir), | |
611 | .cb = str_opendir_cb, | |
612 | .help = "Recursively add files from this directory and down", | |
613 | }, | |
614 | { | |
615 | .name = "rw", | |
d3aad8f2 | 616 | .alias = "readwrite", |
214e1eca | 617 | .type = FIO_OPT_STR, |
211097b2 | 618 | .cb = str_rw_cb, |
214e1eca JA |
619 | .off1 = td_var_offset(td_ddir), |
620 | .help = "IO direction", | |
621 | .def = "read", | |
622 | .posval = { | |
623 | { .ival = "read", | |
624 | .oval = TD_DDIR_READ, | |
625 | .help = "Sequential read", | |
626 | }, | |
627 | { .ival = "write", | |
628 | .oval = TD_DDIR_WRITE, | |
629 | .help = "Sequential write", | |
630 | }, | |
631 | { .ival = "randread", | |
632 | .oval = TD_DDIR_RANDREAD, | |
633 | .help = "Random read", | |
634 | }, | |
635 | { .ival = "randwrite", | |
636 | .oval = TD_DDIR_RANDWRITE, | |
637 | .help = "Random write", | |
638 | }, | |
639 | { .ival = "rw", | |
640 | .oval = TD_DDIR_RW, | |
641 | .help = "Sequential read and write mix", | |
642 | }, | |
643 | { .ival = "randrw", | |
644 | .oval = TD_DDIR_RANDRW, | |
645 | .help = "Random read and write mix" | |
646 | }, | |
647 | }, | |
648 | }, | |
649 | { | |
650 | .name = "ioengine", | |
651 | .type = FIO_OPT_STR_STORE, | |
652 | .off1 = td_var_offset(ioengine), | |
653 | .help = "IO engine to use", | |
654 | .def = "sync", | |
655 | .posval = { | |
656 | { .ival = "sync", | |
657 | .help = "Use read/write", | |
658 | }, | |
a31041ea | 659 | { .ival = "psync", |
660 | .help = "Use pread/pwrite", | |
661 | }, | |
1d2af02a JA |
662 | { .ival = "vsync", |
663 | .help = "Use readv/writev", | |
664 | }, | |
214e1eca JA |
665 | #ifdef FIO_HAVE_LIBAIO |
666 | { .ival = "libaio", | |
667 | .help = "Linux native asynchronous IO", | |
668 | }, | |
669 | #endif | |
670 | #ifdef FIO_HAVE_POSIXAIO | |
671 | { .ival = "posixaio", | |
672 | .help = "POSIX asynchronous IO", | |
673 | }, | |
417f0068 JA |
674 | #endif |
675 | #ifdef FIO_HAVE_SOLARISAIO | |
676 | { .ival = "solarisaio", | |
677 | .help = "Solaris native asynchronous IO", | |
678 | }, | |
214e1eca JA |
679 | #endif |
680 | { .ival = "mmap", | |
681 | .help = "Memory mapped IO", | |
682 | }, | |
683 | #ifdef FIO_HAVE_SPLICE | |
684 | { .ival = "splice", | |
685 | .help = "splice/vmsplice based IO", | |
686 | }, | |
9cce02e8 JA |
687 | { .ival = "netsplice", |
688 | .help = "splice/vmsplice to/from the network", | |
689 | }, | |
214e1eca JA |
690 | #endif |
691 | #ifdef FIO_HAVE_SGIO | |
692 | { .ival = "sg", | |
693 | .help = "SCSI generic v3 IO", | |
694 | }, | |
695 | #endif | |
696 | { .ival = "null", | |
697 | .help = "Testing engine (no data transfer)", | |
698 | }, | |
699 | { .ival = "net", | |
700 | .help = "Network IO", | |
701 | }, | |
702 | #ifdef FIO_HAVE_SYSLET | |
703 | { .ival = "syslet-rw", | |
704 | .help = "syslet enabled async pread/pwrite IO", | |
705 | }, | |
706 | #endif | |
707 | { .ival = "cpuio", | |
708 | .help = "CPU cycler burner engine", | |
709 | }, | |
b8c82a46 JA |
710 | #ifdef FIO_HAVE_GUASI |
711 | { .ival = "guasi", | |
712 | .help = "GUASI IO engine", | |
713 | }, | |
714 | #endif | |
214e1eca JA |
715 | { .ival = "external", |
716 | .help = "Load external engine (append name)", | |
717 | }, | |
718 | }, | |
719 | }, | |
720 | { | |
721 | .name = "iodepth", | |
722 | .type = FIO_OPT_INT, | |
723 | .off1 = td_var_offset(iodepth), | |
724 | .help = "Amount of IO buffers to keep in flight", | |
757aff4f | 725 | .minval = 1, |
214e1eca JA |
726 | .def = "1", |
727 | }, | |
728 | { | |
729 | .name = "iodepth_batch", | |
4950421a | 730 | .alias = "iodepth_batch_submit", |
214e1eca JA |
731 | .type = FIO_OPT_INT, |
732 | .off1 = td_var_offset(iodepth_batch), | |
d65db441 | 733 | .help = "Number of IO buffers to submit in one go", |
afdf9352 | 734 | .parent = "iodepth", |
a2e6f8ac JA |
735 | .minval = 1, |
736 | .def = "1", | |
4950421a JA |
737 | }, |
738 | { | |
739 | .name = "iodepth_batch_complete", | |
740 | .type = FIO_OPT_INT, | |
741 | .off1 = td_var_offset(iodepth_batch_complete), | |
d65db441 | 742 | .help = "Number of IO buffers to retrieve in one go", |
4950421a JA |
743 | .parent = "iodepth", |
744 | .minval = 0, | |
745 | .def = "1", | |
214e1eca JA |
746 | }, |
747 | { | |
748 | .name = "iodepth_low", | |
749 | .type = FIO_OPT_INT, | |
750 | .off1 = td_var_offset(iodepth_low), | |
751 | .help = "Low water mark for queuing depth", | |
afdf9352 | 752 | .parent = "iodepth", |
214e1eca JA |
753 | }, |
754 | { | |
755 | .name = "size", | |
756 | .type = FIO_OPT_STR_VAL, | |
2dc1bbeb | 757 | .off1 = td_var_offset(size), |
c3edbdba | 758 | .minval = 1, |
214e1eca JA |
759 | .help = "Total size of device or files", |
760 | }, | |
aa31f1f1 SL |
761 | { |
762 | .name = "fill_device", | |
763 | .type = FIO_OPT_BOOL, | |
764 | .off1 = td_var_offset(fill_device), | |
765 | .help = "Write until an ENOSPC error occurs", | |
766 | .def = "0", | |
767 | }, | |
214e1eca JA |
768 | { |
769 | .name = "filesize", | |
770 | .type = FIO_OPT_STR_VAL, | |
771 | .off1 = td_var_offset(file_size_low), | |
772 | .off2 = td_var_offset(file_size_high), | |
c3edbdba | 773 | .minval = 1, |
214e1eca JA |
774 | .help = "Size of individual files", |
775 | }, | |
67a1000f JA |
776 | { |
777 | .name = "offset", | |
778 | .alias = "fileoffset", | |
779 | .type = FIO_OPT_STR_VAL, | |
780 | .off1 = td_var_offset(start_offset), | |
781 | .help = "Start IO from this offset", | |
782 | .def = "0", | |
783 | }, | |
214e1eca JA |
784 | { |
785 | .name = "bs", | |
d3aad8f2 | 786 | .alias = "blocksize", |
214e1eca JA |
787 | .type = FIO_OPT_STR_VAL_INT, |
788 | .off1 = td_var_offset(bs[DDIR_READ]), | |
789 | .off2 = td_var_offset(bs[DDIR_WRITE]), | |
c3edbdba | 790 | .minval = 1, |
214e1eca JA |
791 | .help = "Block size unit", |
792 | .def = "4k", | |
67a1000f | 793 | .parent = "rw", |
214e1eca JA |
794 | }, |
795 | { | |
796 | .name = "bsrange", | |
d3aad8f2 | 797 | .alias = "blocksize_range", |
214e1eca JA |
798 | .type = FIO_OPT_RANGE, |
799 | .off1 = td_var_offset(min_bs[DDIR_READ]), | |
800 | .off2 = td_var_offset(max_bs[DDIR_READ]), | |
801 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), | |
802 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), | |
c3edbdba | 803 | .minval = 1, |
214e1eca | 804 | .help = "Set block size range (in more detail than bs)", |
67a1000f | 805 | .parent = "rw", |
214e1eca | 806 | }, |
564ca972 JA |
807 | { |
808 | .name = "bssplit", | |
809 | .type = FIO_OPT_STR, | |
810 | .cb = str_bssplit_cb, | |
811 | .help = "Set a specific mix of block sizes", | |
812 | .parent = "rw", | |
813 | }, | |
214e1eca JA |
814 | { |
815 | .name = "bs_unaligned", | |
d3aad8f2 | 816 | .alias = "blocksize_unaligned", |
214e1eca JA |
817 | .type = FIO_OPT_STR_SET, |
818 | .off1 = td_var_offset(bs_unaligned), | |
819 | .help = "Don't sector align IO buffer sizes", | |
67a1000f | 820 | .parent = "rw", |
214e1eca JA |
821 | }, |
822 | { | |
823 | .name = "randrepeat", | |
824 | .type = FIO_OPT_BOOL, | |
825 | .off1 = td_var_offset(rand_repeatable), | |
826 | .help = "Use repeatable random IO pattern", | |
827 | .def = "1", | |
67a1000f | 828 | .parent = "rw", |
214e1eca JA |
829 | }, |
830 | { | |
831 | .name = "norandommap", | |
832 | .type = FIO_OPT_STR_SET, | |
833 | .off1 = td_var_offset(norandommap), | |
834 | .help = "Accept potential duplicate random blocks", | |
67a1000f | 835 | .parent = "rw", |
214e1eca | 836 | }, |
2b386d25 JA |
837 | { |
838 | .name = "softrandommap", | |
839 | .type = FIO_OPT_BOOL, | |
840 | .off1 = td_var_offset(softrandommap), | |
f66ab3c8 | 841 | .help = "Set norandommap if randommap allocation fails", |
2b386d25 JA |
842 | .parent = "norandommap", |
843 | .def = "0", | |
844 | }, | |
214e1eca JA |
845 | { |
846 | .name = "nrfiles", | |
847 | .type = FIO_OPT_INT, | |
848 | .off1 = td_var_offset(nr_files), | |
849 | .help = "Split job workload between this number of files", | |
850 | .def = "1", | |
851 | }, | |
852 | { | |
853 | .name = "openfiles", | |
854 | .type = FIO_OPT_INT, | |
855 | .off1 = td_var_offset(open_files), | |
856 | .help = "Number of files to keep open at the same time", | |
857 | }, | |
858 | { | |
859 | .name = "file_service_type", | |
860 | .type = FIO_OPT_STR, | |
861 | .cb = str_fst_cb, | |
862 | .off1 = td_var_offset(file_service_type), | |
863 | .help = "How to select which file to service next", | |
864 | .def = "roundrobin", | |
865 | .posval = { | |
866 | { .ival = "random", | |
867 | .oval = FIO_FSERVICE_RANDOM, | |
868 | .help = "Choose a file at random", | |
869 | }, | |
870 | { .ival = "roundrobin", | |
871 | .oval = FIO_FSERVICE_RR, | |
872 | .help = "Round robin select files", | |
873 | }, | |
874 | }, | |
67a1000f JA |
875 | .parent = "nrfiles", |
876 | }, | |
877 | { | |
878 | .name = "fadvise_hint", | |
879 | .type = FIO_OPT_BOOL, | |
880 | .off1 = td_var_offset(fadvise_hint), | |
881 | .help = "Use fadvise() to advise the kernel on IO pattern", | |
882 | .def = "1", | |
214e1eca JA |
883 | }, |
884 | { | |
885 | .name = "fsync", | |
886 | .type = FIO_OPT_INT, | |
887 | .off1 = td_var_offset(fsync_blocks), | |
888 | .help = "Issue fsync for writes every given number of blocks", | |
889 | .def = "0", | |
890 | }, | |
891 | { | |
892 | .name = "direct", | |
893 | .type = FIO_OPT_BOOL, | |
894 | .off1 = td_var_offset(odirect), | |
895 | .help = "Use O_DIRECT IO (negates buffered)", | |
896 | .def = "0", | |
897 | }, | |
898 | { | |
899 | .name = "buffered", | |
900 | .type = FIO_OPT_BOOL, | |
901 | .off1 = td_var_offset(odirect), | |
902 | .neg = 1, | |
903 | .help = "Use buffered IO (negates direct)", | |
904 | .def = "1", | |
905 | }, | |
906 | { | |
907 | .name = "overwrite", | |
908 | .type = FIO_OPT_BOOL, | |
909 | .off1 = td_var_offset(overwrite), | |
910 | .help = "When writing, set whether to overwrite current data", | |
911 | .def = "0", | |
912 | }, | |
913 | { | |
914 | .name = "loops", | |
915 | .type = FIO_OPT_INT, | |
916 | .off1 = td_var_offset(loops), | |
917 | .help = "Number of times to run the job", | |
918 | .def = "1", | |
919 | }, | |
920 | { | |
921 | .name = "numjobs", | |
922 | .type = FIO_OPT_INT, | |
923 | .off1 = td_var_offset(numjobs), | |
924 | .help = "Duplicate this job this many times", | |
925 | .def = "1", | |
926 | }, | |
927 | { | |
928 | .name = "startdelay", | |
929 | .type = FIO_OPT_INT, | |
930 | .off1 = td_var_offset(start_delay), | |
931 | .help = "Only start job when this period has passed", | |
932 | .def = "0", | |
933 | }, | |
934 | { | |
935 | .name = "runtime", | |
936 | .alias = "timeout", | |
937 | .type = FIO_OPT_STR_VAL_TIME, | |
938 | .off1 = td_var_offset(timeout), | |
939 | .help = "Stop workload when this amount of time has passed", | |
940 | .def = "0", | |
941 | }, | |
cf4464ca JA |
942 | { |
943 | .name = "time_based", | |
944 | .type = FIO_OPT_STR_SET, | |
945 | .off1 = td_var_offset(time_based), | |
946 | .help = "Keep running until runtime/timeout is met", | |
947 | }, | |
721938ae JA |
948 | { |
949 | .name = "ramp_time", | |
950 | .type = FIO_OPT_STR_VAL_TIME, | |
951 | .off1 = td_var_offset(ramp_time), | |
952 | .help = "Ramp up time before measuring performance", | |
953 | }, | |
214e1eca JA |
954 | { |
955 | .name = "mem", | |
d3aad8f2 | 956 | .alias = "iomem", |
214e1eca JA |
957 | .type = FIO_OPT_STR, |
958 | .cb = str_mem_cb, | |
959 | .off1 = td_var_offset(mem_type), | |
960 | .help = "Backing type for IO buffers", | |
961 | .def = "malloc", | |
962 | .posval = { | |
963 | { .ival = "malloc", | |
964 | .oval = MEM_MALLOC, | |
965 | .help = "Use malloc(3) for IO buffers", | |
966 | }, | |
37c8cdfe JA |
967 | { .ival = "shm", |
968 | .oval = MEM_SHM, | |
969 | .help = "Use shared memory segments for IO buffers", | |
970 | }, | |
214e1eca JA |
971 | #ifdef FIO_HAVE_HUGETLB |
972 | { .ival = "shmhuge", | |
973 | .oval = MEM_SHMHUGE, | |
974 | .help = "Like shm, but use huge pages", | |
975 | }, | |
b370e46a | 976 | #endif |
37c8cdfe JA |
977 | { .ival = "mmap", |
978 | .oval = MEM_MMAP, | |
979 | .help = "Use mmap(2) (file or anon) for IO buffers", | |
980 | }, | |
214e1eca JA |
981 | #ifdef FIO_HAVE_HUGETLB |
982 | { .ival = "mmaphuge", | |
983 | .oval = MEM_MMAPHUGE, | |
984 | .help = "Like mmap, but use huge pages", | |
985 | }, | |
986 | #endif | |
987 | }, | |
988 | }, | |
989 | { | |
990 | .name = "verify", | |
991 | .type = FIO_OPT_STR, | |
992 | .off1 = td_var_offset(verify), | |
993 | .help = "Verify data written", | |
994 | .def = "0", | |
995 | .posval = { | |
996 | { .ival = "0", | |
997 | .oval = VERIFY_NONE, | |
998 | .help = "Don't do IO verification", | |
999 | }, | |
fcca4b58 JA |
1000 | { .ival = "md5", |
1001 | .oval = VERIFY_MD5, | |
1002 | .help = "Use md5 checksums for verification", | |
1003 | }, | |
d77a7af3 JA |
1004 | { .ival = "crc64", |
1005 | .oval = VERIFY_CRC64, | |
1006 | .help = "Use crc64 checksums for verification", | |
1007 | }, | |
214e1eca JA |
1008 | { .ival = "crc32", |
1009 | .oval = VERIFY_CRC32, | |
1010 | .help = "Use crc32 checksums for verification", | |
1011 | }, | |
af497e6a JA |
1012 | { .ival = "crc32c-intel", |
1013 | .oval = VERIFY_CRC32C_INTEL, | |
1014 | .help = "Use hw crc32c checksums for verification", | |
1015 | }, | |
bac39e0e JA |
1016 | { .ival = "crc32c", |
1017 | .oval = VERIFY_CRC32C, | |
1018 | .help = "Use crc32c checksums for verification", | |
1019 | }, | |
969f7ed3 JA |
1020 | { .ival = "crc16", |
1021 | .oval = VERIFY_CRC16, | |
1022 | .help = "Use crc16 checksums for verification", | |
1023 | }, | |
1e154bdb JA |
1024 | { .ival = "crc7", |
1025 | .oval = VERIFY_CRC7, | |
1026 | .help = "Use crc7 checksums for verification", | |
1027 | }, | |
cd14cc10 JA |
1028 | { .ival = "sha256", |
1029 | .oval = VERIFY_SHA256, | |
1030 | .help = "Use sha256 checksums for verification", | |
1031 | }, | |
1032 | { .ival = "sha512", | |
1033 | .oval = VERIFY_SHA512, | |
1034 | .help = "Use sha512 checksums for verification", | |
1035 | }, | |
7437ee87 SL |
1036 | { .ival = "meta", |
1037 | .oval = VERIFY_META, | |
1038 | .help = "Use io information", | |
1039 | }, | |
36690c9b JA |
1040 | { |
1041 | .ival = "null", | |
1042 | .oval = VERIFY_NULL, | |
1043 | .help = "Pretend to verify", | |
1044 | }, | |
214e1eca JA |
1045 | }, |
1046 | }, | |
005c565a JA |
1047 | { |
1048 | .name = "do_verify", | |
68e1f29a | 1049 | .type = FIO_OPT_BOOL, |
005c565a JA |
1050 | .off1 = td_var_offset(do_verify), |
1051 | .help = "Run verification stage after write", | |
1052 | .def = "1", | |
1053 | .parent = "verify", | |
1054 | }, | |
160b966d JA |
1055 | { |
1056 | .name = "verifysort", | |
1057 | .type = FIO_OPT_BOOL, | |
1058 | .off1 = td_var_offset(verifysort), | |
1059 | .help = "Sort written verify blocks for read back", | |
1060 | .def = "1", | |
c83f2df1 | 1061 | .parent = "verify", |
160b966d | 1062 | }, |
3f9f4e26 | 1063 | { |
a59e170d | 1064 | .name = "verify_interval", |
3f9f4e26 | 1065 | .type = FIO_OPT_STR_VAL_INT, |
a59e170d | 1066 | .off1 = td_var_offset(verify_interval), |
819a9680 | 1067 | .minval = 2 * sizeof(struct verify_header), |
a59e170d | 1068 | .help = "Store verify buffer header every N bytes", |
afdf9352 | 1069 | .parent = "verify", |
3f9f4e26 | 1070 | }, |
546a9142 | 1071 | { |
a59e170d | 1072 | .name = "verify_offset", |
546a9142 | 1073 | .type = FIO_OPT_STR_VAL_INT, |
a59e170d | 1074 | .help = "Offset verify header location by N bytes", |
546a9142 | 1075 | .def = "0", |
5ec10eaa | 1076 | .cb = str_verify_offset_cb, |
afdf9352 | 1077 | .parent = "verify", |
546a9142 | 1078 | }, |
e28218f3 SL |
1079 | { |
1080 | .name = "verify_pattern", | |
1081 | .type = FIO_OPT_INT, | |
1082 | .cb = str_verify_pattern_cb, | |
1083 | .help = "Fill pattern for IO buffers", | |
1084 | .parent = "verify", | |
1085 | }, | |
a12a3b4d JA |
1086 | { |
1087 | .name = "verify_fatal", | |
68e1f29a | 1088 | .type = FIO_OPT_BOOL, |
a12a3b4d JA |
1089 | .off1 = td_var_offset(verify_fatal), |
1090 | .def = "0", | |
1091 | .help = "Exit on a single verify failure, don't continue", | |
1092 | .parent = "verify", | |
1093 | }, | |
214e1eca JA |
1094 | { |
1095 | .name = "write_iolog", | |
1096 | .type = FIO_OPT_STR_STORE, | |
1097 | .off1 = td_var_offset(write_iolog_file), | |
1098 | .help = "Store IO pattern to file", | |
1099 | }, | |
1100 | { | |
1101 | .name = "read_iolog", | |
1102 | .type = FIO_OPT_STR_STORE, | |
1103 | .off1 = td_var_offset(read_iolog_file), | |
1104 | .help = "Playback IO pattern from file", | |
1105 | }, | |
1106 | { | |
1107 | .name = "exec_prerun", | |
1108 | .type = FIO_OPT_STR_STORE, | |
1109 | .off1 = td_var_offset(exec_prerun), | |
1110 | .help = "Execute this file prior to running job", | |
1111 | }, | |
1112 | { | |
1113 | .name = "exec_postrun", | |
1114 | .type = FIO_OPT_STR_STORE, | |
1115 | .off1 = td_var_offset(exec_postrun), | |
1116 | .help = "Execute this file after running job", | |
1117 | }, | |
1118 | #ifdef FIO_HAVE_IOSCHED_SWITCH | |
1119 | { | |
1120 | .name = "ioscheduler", | |
1121 | .type = FIO_OPT_STR_STORE, | |
1122 | .off1 = td_var_offset(ioscheduler), | |
1123 | .help = "Use this IO scheduler on the backing device", | |
1124 | }, | |
1125 | #endif | |
1126 | { | |
1127 | .name = "zonesize", | |
1128 | .type = FIO_OPT_STR_VAL, | |
1129 | .off1 = td_var_offset(zone_size), | |
1130 | .help = "Give size of an IO zone", | |
1131 | .def = "0", | |
1132 | }, | |
1133 | { | |
1134 | .name = "zoneskip", | |
1135 | .type = FIO_OPT_STR_VAL, | |
1136 | .off1 = td_var_offset(zone_skip), | |
1137 | .help = "Space between IO zones", | |
1138 | .def = "0", | |
1139 | }, | |
1140 | { | |
1141 | .name = "lockmem", | |
1142 | .type = FIO_OPT_STR_VAL, | |
1143 | .cb = str_lockmem_cb, | |
1144 | .help = "Lock down this amount of memory", | |
1145 | .def = "0", | |
1146 | }, | |
214e1eca JA |
1147 | { |
1148 | .name = "rwmixread", | |
1149 | .type = FIO_OPT_INT, | |
cb499fc4 | 1150 | .cb = str_rwmix_read_cb, |
214e1eca JA |
1151 | .maxval = 100, |
1152 | .help = "Percentage of mixed workload that is reads", | |
1153 | .def = "50", | |
1154 | }, | |
1155 | { | |
1156 | .name = "rwmixwrite", | |
1157 | .type = FIO_OPT_INT, | |
cb499fc4 | 1158 | .cb = str_rwmix_write_cb, |
214e1eca JA |
1159 | .maxval = 100, |
1160 | .help = "Percentage of mixed workload that is writes", | |
1161 | .def = "50", | |
1162 | }, | |
afdf9352 JA |
1163 | { |
1164 | .name = "rwmixcycle", | |
15ca150e | 1165 | .type = FIO_OPT_DEPRECATED, |
afdf9352 | 1166 | }, |
214e1eca JA |
1167 | { |
1168 | .name = "nice", | |
1169 | .type = FIO_OPT_INT, | |
1170 | .off1 = td_var_offset(nice), | |
1171 | .help = "Set job CPU nice value", | |
1172 | .minval = -19, | |
1173 | .maxval = 20, | |
1174 | .def = "0", | |
1175 | }, | |
1176 | #ifdef FIO_HAVE_IOPRIO | |
1177 | { | |
1178 | .name = "prio", | |
1179 | .type = FIO_OPT_INT, | |
1180 | .cb = str_prio_cb, | |
1181 | .help = "Set job IO priority value", | |
1182 | .minval = 0, | |
1183 | .maxval = 7, | |
1184 | }, | |
1185 | { | |
1186 | .name = "prioclass", | |
1187 | .type = FIO_OPT_INT, | |
1188 | .cb = str_prioclass_cb, | |
1189 | .help = "Set job IO priority class", | |
1190 | .minval = 0, | |
1191 | .maxval = 3, | |
1192 | }, | |
1193 | #endif | |
1194 | { | |
1195 | .name = "thinktime", | |
1196 | .type = FIO_OPT_INT, | |
1197 | .off1 = td_var_offset(thinktime), | |
1198 | .help = "Idle time between IO buffers (usec)", | |
1199 | .def = "0", | |
1200 | }, | |
1201 | { | |
1202 | .name = "thinktime_spin", | |
1203 | .type = FIO_OPT_INT, | |
1204 | .off1 = td_var_offset(thinktime_spin), | |
1205 | .help = "Start think time by spinning this amount (usec)", | |
1206 | .def = "0", | |
afdf9352 | 1207 | .parent = "thinktime", |
214e1eca JA |
1208 | }, |
1209 | { | |
1210 | .name = "thinktime_blocks", | |
1211 | .type = FIO_OPT_INT, | |
1212 | .off1 = td_var_offset(thinktime_blocks), | |
1213 | .help = "IO buffer period between 'thinktime'", | |
1214 | .def = "1", | |
afdf9352 | 1215 | .parent = "thinktime", |
214e1eca JA |
1216 | }, |
1217 | { | |
1218 | .name = "rate", | |
1219 | .type = FIO_OPT_INT, | |
1220 | .off1 = td_var_offset(rate), | |
1221 | .help = "Set bandwidth rate", | |
1222 | }, | |
1223 | { | |
1224 | .name = "ratemin", | |
1225 | .type = FIO_OPT_INT, | |
1226 | .off1 = td_var_offset(ratemin), | |
4e991c23 | 1227 | .help = "Job must meet this rate or it will be shutdown", |
afdf9352 | 1228 | .parent = "rate", |
4e991c23 JA |
1229 | }, |
1230 | { | |
1231 | .name = "rate_iops", | |
1232 | .type = FIO_OPT_INT, | |
1233 | .off1 = td_var_offset(rate_iops), | |
1234 | .help = "Limit IO used to this number of IO operations/sec", | |
1235 | }, | |
1236 | { | |
1237 | .name = "rate_iops_min", | |
1238 | .type = FIO_OPT_INT, | |
1239 | .off1 = td_var_offset(rate_iops_min), | |
1240 | .help = "Job must meet this rate or it will be shutdown", | |
afdf9352 | 1241 | .parent = "rate_iops", |
214e1eca JA |
1242 | }, |
1243 | { | |
1244 | .name = "ratecycle", | |
1245 | .type = FIO_OPT_INT, | |
1246 | .off1 = td_var_offset(ratecycle), | |
1247 | .help = "Window average for rate limits (msec)", | |
1248 | .def = "1000", | |
afdf9352 | 1249 | .parent = "rate", |
214e1eca JA |
1250 | }, |
1251 | { | |
1252 | .name = "invalidate", | |
1253 | .type = FIO_OPT_BOOL, | |
1254 | .off1 = td_var_offset(invalidate_cache), | |
1255 | .help = "Invalidate buffer/page cache prior to running job", | |
1256 | .def = "1", | |
1257 | }, | |
1258 | { | |
1259 | .name = "sync", | |
1260 | .type = FIO_OPT_BOOL, | |
1261 | .off1 = td_var_offset(sync_io), | |
1262 | .help = "Use O_SYNC for buffered writes", | |
1263 | .def = "0", | |
67a1000f | 1264 | .parent = "buffered", |
214e1eca JA |
1265 | }, |
1266 | { | |
1267 | .name = "bwavgtime", | |
1268 | .type = FIO_OPT_INT, | |
1269 | .off1 = td_var_offset(bw_avg_time), | |
5ec10eaa JA |
1270 | .help = "Time window over which to calculate bandwidth" |
1271 | " (msec)", | |
214e1eca JA |
1272 | .def = "500", |
1273 | }, | |
1274 | { | |
1275 | .name = "create_serialize", | |
1276 | .type = FIO_OPT_BOOL, | |
1277 | .off1 = td_var_offset(create_serialize), | |
1278 | .help = "Serialize creating of job files", | |
1279 | .def = "1", | |
1280 | }, | |
1281 | { | |
1282 | .name = "create_fsync", | |
1283 | .type = FIO_OPT_BOOL, | |
1284 | .off1 = td_var_offset(create_fsync), | |
1285 | .help = "Fsync file after creation", | |
1286 | .def = "1", | |
1287 | }, | |
1288 | { | |
1289 | .name = "cpuload", | |
1290 | .type = FIO_OPT_INT, | |
1291 | .off1 = td_var_offset(cpuload), | |
1292 | .help = "Use this percentage of CPU", | |
1293 | }, | |
1294 | { | |
1295 | .name = "cpuchunks", | |
1296 | .type = FIO_OPT_INT, | |
1297 | .off1 = td_var_offset(cpucycle), | |
1298 | .help = "Length of the CPU burn cycles (usecs)", | |
1299 | .def = "50000", | |
67a1000f | 1300 | .parent = "cpuload", |
214e1eca JA |
1301 | }, |
1302 | #ifdef FIO_HAVE_CPU_AFFINITY | |
1303 | { | |
1304 | .name = "cpumask", | |
1305 | .type = FIO_OPT_INT, | |
1306 | .cb = str_cpumask_cb, | |
1307 | .help = "CPU affinity mask", | |
1308 | }, | |
d2e268b0 JA |
1309 | { |
1310 | .name = "cpus_allowed", | |
1311 | .type = FIO_OPT_STR, | |
1312 | .cb = str_cpus_allowed_cb, | |
1313 | .help = "Set CPUs allowed", | |
1314 | }, | |
214e1eca JA |
1315 | #endif |
1316 | { | |
1317 | .name = "end_fsync", | |
1318 | .type = FIO_OPT_BOOL, | |
1319 | .off1 = td_var_offset(end_fsync), | |
1320 | .help = "Include fsync at the end of job", | |
1321 | .def = "0", | |
1322 | }, | |
1323 | { | |
1324 | .name = "fsync_on_close", | |
1325 | .type = FIO_OPT_BOOL, | |
1326 | .off1 = td_var_offset(fsync_on_close), | |
1327 | .help = "fsync files on close", | |
1328 | .def = "0", | |
1329 | }, | |
1330 | { | |
1331 | .name = "unlink", | |
1332 | .type = FIO_OPT_BOOL, | |
1333 | .off1 = td_var_offset(unlink), | |
1334 | .help = "Unlink created files after job has completed", | |
1335 | .def = "0", | |
1336 | }, | |
1337 | { | |
1338 | .name = "exitall", | |
1339 | .type = FIO_OPT_STR_SET, | |
1340 | .cb = str_exitall_cb, | |
1341 | .help = "Terminate all jobs when one exits", | |
1342 | }, | |
1343 | { | |
1344 | .name = "stonewall", | |
1345 | .type = FIO_OPT_STR_SET, | |
1346 | .off1 = td_var_offset(stonewall), | |
1347 | .help = "Insert a hard barrier between this job and previous", | |
1348 | }, | |
b3d62a75 JA |
1349 | { |
1350 | .name = "new_group", | |
1351 | .type = FIO_OPT_STR_SET, | |
1352 | .off1 = td_var_offset(new_group), | |
1353 | .help = "Mark the start of a new group (for reporting)", | |
1354 | }, | |
214e1eca JA |
1355 | { |
1356 | .name = "thread", | |
1357 | .type = FIO_OPT_STR_SET, | |
1358 | .off1 = td_var_offset(use_thread), | |
1359 | .help = "Use threads instead of forks", | |
1360 | }, | |
1361 | { | |
1362 | .name = "write_bw_log", | |
e3cedca7 | 1363 | .type = FIO_OPT_STR, |
214e1eca | 1364 | .off1 = td_var_offset(write_bw_log), |
e3cedca7 | 1365 | .cb = str_write_bw_log_cb, |
214e1eca JA |
1366 | .help = "Write log of bandwidth during run", |
1367 | }, | |
1368 | { | |
1369 | .name = "write_lat_log", | |
e3cedca7 | 1370 | .type = FIO_OPT_STR, |
214e1eca | 1371 | .off1 = td_var_offset(write_lat_log), |
e3cedca7 | 1372 | .cb = str_write_lat_log_cb, |
214e1eca JA |
1373 | .help = "Write log of latency during run", |
1374 | }, | |
1375 | { | |
1376 | .name = "hugepage-size", | |
357f618e | 1377 | .type = FIO_OPT_STR_VAL_INT, |
214e1eca JA |
1378 | .off1 = td_var_offset(hugepage_size), |
1379 | .help = "When using hugepages, specify size of each page", | |
1380 | .def = __stringify(FIO_HUGE_PAGE), | |
1381 | }, | |
1382 | { | |
1383 | .name = "group_reporting", | |
1384 | .type = FIO_OPT_STR_SET, | |
1385 | .off1 = td_var_offset(group_reporting), | |
1386 | .help = "Do reporting on a per-group basis", | |
1387 | }, | |
e9459e5a JA |
1388 | { |
1389 | .name = "zero_buffers", | |
1390 | .type = FIO_OPT_STR_SET, | |
1391 | .off1 = td_var_offset(zero_buffers), | |
1392 | .help = "Init IO buffers to all zeroes", | |
1393 | }, | |
5973cafb JA |
1394 | { |
1395 | .name = "refill_buffers", | |
1396 | .type = FIO_OPT_STR_SET, | |
1397 | .off1 = td_var_offset(refill_buffers), | |
1398 | .help = "Refill IO buffers on every IO submit", | |
1399 | }, | |
0a839f30 JA |
1400 | #ifdef FIO_HAVE_DISK_UTIL |
1401 | { | |
1402 | .name = "disk_util", | |
1403 | .type = FIO_OPT_BOOL, | |
1404 | .off1 = td_var_offset(do_disk_util), | |
f66ab3c8 | 1405 | .help = "Log disk utilization statistics", |
0a839f30 JA |
1406 | .def = "1", |
1407 | }, | |
1408 | #endif | |
993bf48b JA |
1409 | { |
1410 | .name = "gtod_reduce", | |
1411 | .type = FIO_OPT_BOOL, | |
1412 | .help = "Greatly reduce number of gettimeofday() calls", | |
1413 | .cb = str_gtod_reduce_cb, | |
1414 | .def = "0", | |
1415 | }, | |
9520ebb9 JA |
1416 | { |
1417 | .name = "disable_clat", | |
1418 | .type = FIO_OPT_BOOL, | |
1419 | .off1 = td_var_offset(disable_clat), | |
1420 | .help = "Disable completion latency numbers", | |
993bf48b | 1421 | .parent = "gtod_reduce", |
9520ebb9 JA |
1422 | .def = "0", |
1423 | }, | |
1424 | { | |
1425 | .name = "disable_slat", | |
1426 | .type = FIO_OPT_BOOL, | |
1427 | .off1 = td_var_offset(disable_slat), | |
1428 | .help = "Disable submissionn latency numbers", | |
993bf48b | 1429 | .parent = "gtod_reduce", |
9520ebb9 JA |
1430 | .def = "0", |
1431 | }, | |
1432 | { | |
1433 | .name = "disable_bw_measurement", | |
1434 | .type = FIO_OPT_BOOL, | |
1435 | .off1 = td_var_offset(disable_bw), | |
1436 | .help = "Disable bandwidth logging", | |
993bf48b | 1437 | .parent = "gtod_reduce", |
9520ebb9 JA |
1438 | .def = "0", |
1439 | }, | |
be4ecfdf JA |
1440 | { |
1441 | .name = "gtod_cpu", | |
1442 | .type = FIO_OPT_INT, | |
1443 | .cb = str_gtod_cpu_cb, | |
1444 | .help = "Setup dedicated gettimeofday() thread on this CPU", | |
1445 | }, | |
214e1eca JA |
1446 | { |
1447 | .name = NULL, | |
1448 | }, | |
1449 | }; | |
1450 | ||
1451 | void fio_options_dup_and_init(struct option *long_options) | |
1452 | { | |
1453 | struct fio_option *o; | |
1454 | unsigned int i; | |
1455 | ||
1456 | options_init(options); | |
1457 | ||
1458 | i = 0; | |
1459 | while (long_options[i].name) | |
1460 | i++; | |
1461 | ||
1462 | o = &options[0]; | |
1463 | while (o->name) { | |
5921e80c | 1464 | long_options[i].name = (char *) o->name; |
214e1eca JA |
1465 | long_options[i].val = FIO_GETOPT_JOB; |
1466 | if (o->type == FIO_OPT_STR_SET) | |
1467 | long_options[i].has_arg = no_argument; | |
1468 | else | |
1469 | long_options[i].has_arg = required_argument; | |
1470 | ||
1471 | i++; | |
1472 | o++; | |
1473 | assert(i < FIO_NR_OPTIONS); | |
1474 | } | |
1475 | } | |
1476 | ||
3b8b7135 | 1477 | int fio_options_parse(struct thread_data *td, char **opts, int num_opts) |
214e1eca | 1478 | { |
3b8b7135 JA |
1479 | int i, ret; |
1480 | ||
1481 | sort_options(opts, options, num_opts); | |
1482 | ||
1483 | for (ret = 0, i = 0; i < num_opts; i++) | |
1484 | ret |= parse_option(opts[i], options, td); | |
1485 | ||
1486 | return ret; | |
214e1eca JA |
1487 | } |
1488 | ||
1489 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) | |
1490 | { | |
1491 | return parse_cmd_option(opt, val, options, td); | |
1492 | } | |
1493 | ||
1494 | void fio_fill_default_options(struct thread_data *td) | |
1495 | { | |
1496 | fill_default_options(td, options); | |
1497 | } | |
1498 | ||
1499 | int fio_show_option_help(const char *opt) | |
1500 | { | |
1501 | return show_cmd_help(options, opt); | |
1502 | } | |
d23bb327 JA |
1503 | |
1504 | static void __options_mem(struct thread_data *td, int alloc) | |
1505 | { | |
1506 | struct thread_options *o = &td->o; | |
1507 | struct fio_option *opt; | |
1508 | char **ptr; | |
1509 | int i; | |
1510 | ||
1511 | for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) { | |
1512 | if (opt->type != FIO_OPT_STR_STORE) | |
1513 | continue; | |
1514 | ||
1515 | ptr = (void *) o + opt->off1; | |
1516 | if (*ptr) { | |
1517 | if (alloc) | |
1518 | *ptr = strdup(*ptr); | |
1519 | else { | |
1520 | free(*ptr); | |
1521 | *ptr = NULL; | |
1522 | } | |
1523 | } | |
1524 | } | |
1525 | } | |
1526 | ||
1527 | /* | |
1528 | * dupe FIO_OPT_STR_STORE options | |
1529 | */ | |
1530 | void options_mem_dupe(struct thread_data *td) | |
1531 | { | |
1532 | __options_mem(td, 1); | |
1533 | } | |
1534 | ||
22d66213 | 1535 | void options_mem_free(struct thread_data fio_unused *td) |
d23bb327 | 1536 | { |
22d66213 | 1537 | #if 0 |
d23bb327 | 1538 | __options_mem(td, 0); |
22d66213 | 1539 | #endif |
d23bb327 | 1540 | } |