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