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