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> | |
214e1eca | 6 | #include <assert.h> |
921c766f | 7 | #include <libgen.h> |
5921e80c JA |
8 | #include <fcntl.h> |
9 | #include <sys/types.h> | |
10 | #include <sys/stat.h> | |
214e1eca JA |
11 | |
12 | #include "fio.h" | |
4f5af7b2 | 13 | #include "verify.h" |
214e1eca | 14 | #include "parse.h" |
eef32359 | 15 | #include "lib/fls.h" |
9f988e2e | 16 | #include "options.h" |
214e1eca | 17 | |
5d7c5d34 JA |
18 | #include "crc/crc32c.h" |
19 | ||
214e1eca JA |
20 | /* |
21 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. | |
22 | */ | |
23 | static char *get_opt_postfix(const char *str) | |
24 | { | |
25 | char *p = strstr(str, ":"); | |
26 | ||
27 | if (!p) | |
28 | return NULL; | |
29 | ||
30 | p++; | |
31 | strip_blank_front(&p); | |
32 | strip_blank_end(p); | |
33 | return strdup(p); | |
34 | } | |
35 | ||
0e92f873 RR |
36 | static int converthexchartoint(char a) |
37 | { | |
38 | int base; | |
39 | ||
40 | switch(a) { | |
41 | case '0'...'9': | |
42 | base = '0'; | |
43 | break; | |
44 | case 'A'...'F': | |
45 | base = 'A' - 10; | |
46 | break; | |
47 | case 'a'...'f': | |
48 | base = 'a' - 10; | |
49 | break; | |
50 | default: | |
51 | base = 0; | |
52 | } | |
53 | return (a - base); | |
54 | } | |
55 | ||
564ca972 JA |
56 | static int bs_cmp(const void *p1, const void *p2) |
57 | { | |
58 | const struct bssplit *bsp1 = p1; | |
59 | const struct bssplit *bsp2 = p2; | |
60 | ||
61 | return bsp1->perc < bsp2->perc; | |
62 | } | |
63 | ||
720e84ad | 64 | static int bssplit_ddir(struct thread_data *td, int ddir, char *str) |
564ca972 | 65 | { |
720e84ad | 66 | struct bssplit *bssplit; |
564ca972 JA |
67 | unsigned int i, perc, perc_missing; |
68 | unsigned int max_bs, min_bs; | |
69 | long long val; | |
720e84ad | 70 | char *fname; |
564ca972 | 71 | |
720e84ad JA |
72 | td->o.bssplit_nr[ddir] = 4; |
73 | bssplit = malloc(4 * sizeof(struct bssplit)); | |
564ca972 JA |
74 | |
75 | i = 0; | |
76 | max_bs = 0; | |
77 | min_bs = -1; | |
78 | while ((fname = strsep(&str, ":")) != NULL) { | |
79 | char *perc_str; | |
80 | ||
81 | if (!strlen(fname)) | |
82 | break; | |
83 | ||
84 | /* | |
85 | * grow struct buffer, if needed | |
86 | */ | |
720e84ad JA |
87 | if (i == td->o.bssplit_nr[ddir]) { |
88 | td->o.bssplit_nr[ddir] <<= 1; | |
89 | bssplit = realloc(bssplit, td->o.bssplit_nr[ddir] | |
5ec10eaa | 90 | * sizeof(struct bssplit)); |
564ca972 JA |
91 | } |
92 | ||
93 | perc_str = strstr(fname, "/"); | |
94 | if (perc_str) { | |
95 | *perc_str = '\0'; | |
96 | perc_str++; | |
97 | perc = atoi(perc_str); | |
98 | if (perc > 100) | |
99 | perc = 100; | |
100 | else if (!perc) | |
101 | perc = -1; | |
102 | } else | |
103 | perc = -1; | |
104 | ||
6925dd35 | 105 | if (str_to_decimal(fname, &val, 1, td)) { |
564ca972 JA |
106 | log_err("fio: bssplit conversion failed\n"); |
107 | free(td->o.bssplit); | |
108 | return 1; | |
109 | } | |
110 | ||
111 | if (val > max_bs) | |
112 | max_bs = val; | |
113 | if (val < min_bs) | |
114 | min_bs = val; | |
115 | ||
720e84ad JA |
116 | bssplit[i].bs = val; |
117 | bssplit[i].perc = perc; | |
564ca972 JA |
118 | i++; |
119 | } | |
120 | ||
720e84ad | 121 | td->o.bssplit_nr[ddir] = i; |
564ca972 JA |
122 | |
123 | /* | |
124 | * Now check if the percentages add up, and how much is missing | |
125 | */ | |
126 | perc = perc_missing = 0; | |
720e84ad JA |
127 | for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { |
128 | struct bssplit *bsp = &bssplit[i]; | |
564ca972 JA |
129 | |
130 | if (bsp->perc == (unsigned char) -1) | |
131 | perc_missing++; | |
132 | else | |
133 | perc += bsp->perc; | |
134 | } | |
135 | ||
136 | if (perc > 100) { | |
137 | log_err("fio: bssplit percentages add to more than 100%%\n"); | |
720e84ad | 138 | free(bssplit); |
564ca972 JA |
139 | return 1; |
140 | } | |
141 | /* | |
142 | * If values didn't have a percentage set, divide the remains between | |
143 | * them. | |
144 | */ | |
145 | if (perc_missing) { | |
720e84ad JA |
146 | for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { |
147 | struct bssplit *bsp = &bssplit[i]; | |
564ca972 JA |
148 | |
149 | if (bsp->perc == (unsigned char) -1) | |
150 | bsp->perc = (100 - perc) / perc_missing; | |
151 | } | |
152 | } | |
153 | ||
720e84ad JA |
154 | td->o.min_bs[ddir] = min_bs; |
155 | td->o.max_bs[ddir] = max_bs; | |
564ca972 JA |
156 | |
157 | /* | |
158 | * now sort based on percentages, for ease of lookup | |
159 | */ | |
720e84ad JA |
160 | qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp); |
161 | td->o.bssplit[ddir] = bssplit; | |
162 | return 0; | |
720e84ad JA |
163 | } |
164 | ||
165 | static int str_bssplit_cb(void *data, const char *input) | |
166 | { | |
167 | struct thread_data *td = data; | |
168 | char *str, *p, *odir; | |
169 | int ret = 0; | |
170 | ||
171 | p = str = strdup(input); | |
172 | ||
173 | strip_blank_front(&str); | |
174 | strip_blank_end(str); | |
175 | ||
176 | odir = strchr(str, ','); | |
177 | if (odir) { | |
178 | ret = bssplit_ddir(td, DDIR_WRITE, odir + 1); | |
179 | if (!ret) { | |
180 | *odir = '\0'; | |
181 | ret = bssplit_ddir(td, DDIR_READ, str); | |
182 | } | |
183 | } else { | |
184 | char *op; | |
185 | ||
186 | op = strdup(str); | |
187 | ||
188 | ret = bssplit_ddir(td, DDIR_READ, str); | |
189 | if (!ret) | |
190 | ret = bssplit_ddir(td, DDIR_WRITE, op); | |
191 | ||
192 | free(op); | |
193 | } | |
564ca972 JA |
194 | |
195 | free(p); | |
720e84ad | 196 | return ret; |
564ca972 JA |
197 | } |
198 | ||
211097b2 JA |
199 | static int str_rw_cb(void *data, const char *str) |
200 | { | |
201 | struct thread_data *td = data; | |
202 | char *nr = get_opt_postfix(str); | |
203 | ||
5736c10d | 204 | td->o.ddir_seq_nr = 1; |
059b0802 JA |
205 | td->o.ddir_seq_add = 0; |
206 | ||
207 | if (!nr) | |
208 | return 0; | |
209 | ||
210 | if (td_random(td)) | |
5736c10d | 211 | td->o.ddir_seq_nr = atoi(nr); |
059b0802 JA |
212 | else { |
213 | long long val; | |
214 | ||
6925dd35 | 215 | if (str_to_decimal(nr, &val, 1, td)) { |
059b0802 JA |
216 | log_err("fio: rw postfix parsing failed\n"); |
217 | free(nr); | |
218 | return 1; | |
219 | } | |
220 | ||
221 | td->o.ddir_seq_add = val; | |
182ec6ee | 222 | } |
211097b2 | 223 | |
059b0802 | 224 | free(nr); |
211097b2 JA |
225 | return 0; |
226 | } | |
227 | ||
214e1eca JA |
228 | static int str_mem_cb(void *data, const char *mem) |
229 | { | |
230 | struct thread_data *td = data; | |
231 | ||
2dc1bbeb | 232 | if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) { |
214e1eca | 233 | td->mmapfile = get_opt_postfix(mem); |
2dc1bbeb | 234 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
214e1eca JA |
235 | log_err("fio: mmaphuge:/path/to/file\n"); |
236 | return 1; | |
237 | } | |
238 | } | |
239 | ||
240 | return 0; | |
241 | } | |
242 | ||
5d7c5d34 JA |
243 | static int str_verify_cb(void *data, const char *mem) |
244 | { | |
245 | struct thread_data *td = data; | |
246 | ||
e3aaafc4 JA |
247 | if (td->o.verify == VERIFY_CRC32C_INTEL || |
248 | td->o.verify == VERIFY_CRC32C) { | |
249 | crc32c_intel_probe(); | |
5d7c5d34 JA |
250 | } |
251 | ||
252 | return 0; | |
253 | } | |
254 | ||
c223da83 JA |
255 | static int fio_clock_source_cb(void *data, const char *str) |
256 | { | |
257 | struct thread_data *td = data; | |
258 | ||
259 | fio_clock_source = td->o.clocksource; | |
260 | fio_time_init(); | |
261 | return 0; | |
262 | } | |
263 | ||
85bc833b | 264 | static int str_lockmem_cb(void fio_unused *data, unsigned long long *val) |
214e1eca JA |
265 | { |
266 | mlock_size = *val; | |
267 | return 0; | |
268 | } | |
269 | ||
85bc833b | 270 | static int str_rwmix_read_cb(void *data, unsigned long long *val) |
cb499fc4 JA |
271 | { |
272 | struct thread_data *td = data; | |
273 | ||
274 | td->o.rwmix[DDIR_READ] = *val; | |
275 | td->o.rwmix[DDIR_WRITE] = 100 - *val; | |
276 | return 0; | |
277 | } | |
278 | ||
85bc833b | 279 | static int str_rwmix_write_cb(void *data, unsigned long long *val) |
cb499fc4 JA |
280 | { |
281 | struct thread_data *td = data; | |
282 | ||
283 | td->o.rwmix[DDIR_WRITE] = *val; | |
284 | td->o.rwmix[DDIR_READ] = 100 - *val; | |
285 | return 0; | |
286 | } | |
287 | ||
214e1eca | 288 | #ifdef FIO_HAVE_IOPRIO |
85bc833b | 289 | static int str_prioclass_cb(void *data, unsigned long long *val) |
214e1eca JA |
290 | { |
291 | struct thread_data *td = data; | |
6cefbe33 JA |
292 | unsigned short mask; |
293 | ||
294 | /* | |
295 | * mask off old class bits, str_prio_cb() may have set a default class | |
296 | */ | |
297 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; | |
298 | td->ioprio &= mask; | |
214e1eca JA |
299 | |
300 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; | |
ac684785 | 301 | td->ioprio_set = 1; |
214e1eca JA |
302 | return 0; |
303 | } | |
304 | ||
85bc833b | 305 | static int str_prio_cb(void *data, unsigned long long *val) |
214e1eca JA |
306 | { |
307 | struct thread_data *td = data; | |
308 | ||
309 | td->ioprio |= *val; | |
6cefbe33 JA |
310 | |
311 | /* | |
312 | * If no class is set, assume BE | |
313 | */ | |
314 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) | |
315 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; | |
316 | ||
ac684785 | 317 | td->ioprio_set = 1; |
214e1eca JA |
318 | return 0; |
319 | } | |
320 | #endif | |
321 | ||
322 | static int str_exitall_cb(void) | |
323 | { | |
324 | exitall_on_terminate = 1; | |
325 | return 0; | |
326 | } | |
327 | ||
214e1eca | 328 | #ifdef FIO_HAVE_CPU_AFFINITY |
85bc833b | 329 | static int str_cpumask_cb(void *data, unsigned long long *val) |
d2e268b0 JA |
330 | { |
331 | struct thread_data *td = data; | |
214e1eca | 332 | unsigned int i; |
b03daafb | 333 | long max_cpu; |
d2ce18b5 JA |
334 | int ret; |
335 | ||
336 | ret = fio_cpuset_init(&td->o.cpumask); | |
337 | if (ret < 0) { | |
338 | log_err("fio: cpuset_init failed\n"); | |
339 | td_verror(td, ret, "fio_cpuset_init"); | |
340 | return 1; | |
341 | } | |
214e1eca | 342 | |
c00a2289 | 343 | max_cpu = cpus_online(); |
214e1eca | 344 | |
62a7273d JA |
345 | for (i = 0; i < sizeof(int) * 8; i++) { |
346 | if ((1 << i) & *val) { | |
b03daafb JA |
347 | if (i > max_cpu) { |
348 | log_err("fio: CPU %d too large (max=%ld)\n", i, | |
349 | max_cpu); | |
350 | return 1; | |
351 | } | |
62a7273d | 352 | dprint(FD_PARSE, "set cpu allowed %d\n", i); |
6d459ee7 | 353 | fio_cpu_set(&td->o.cpumask, i); |
62a7273d JA |
354 | } |
355 | } | |
d2e268b0 JA |
356 | |
357 | td->o.cpumask_set = 1; | |
358 | return 0; | |
214e1eca JA |
359 | } |
360 | ||
e8462bd8 JA |
361 | static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask, |
362 | const char *input) | |
214e1eca | 363 | { |
d2e268b0 | 364 | char *cpu, *str, *p; |
b03daafb | 365 | long max_cpu; |
19608d6c | 366 | int ret = 0; |
d2e268b0 | 367 | |
e8462bd8 | 368 | ret = fio_cpuset_init(mask); |
d2ce18b5 JA |
369 | if (ret < 0) { |
370 | log_err("fio: cpuset_init failed\n"); | |
371 | td_verror(td, ret, "fio_cpuset_init"); | |
372 | return 1; | |
373 | } | |
d2e268b0 JA |
374 | |
375 | p = str = strdup(input); | |
214e1eca | 376 | |
d2e268b0 JA |
377 | strip_blank_front(&str); |
378 | strip_blank_end(str); | |
379 | ||
c00a2289 | 380 | max_cpu = cpus_online(); |
b03daafb | 381 | |
d2e268b0 | 382 | while ((cpu = strsep(&str, ",")) != NULL) { |
62a7273d JA |
383 | char *str2, *cpu2; |
384 | int icpu, icpu2; | |
385 | ||
d2e268b0 JA |
386 | if (!strlen(cpu)) |
387 | break; | |
62a7273d JA |
388 | |
389 | str2 = cpu; | |
390 | icpu2 = -1; | |
391 | while ((cpu2 = strsep(&str2, "-")) != NULL) { | |
392 | if (!strlen(cpu2)) | |
393 | break; | |
394 | ||
395 | icpu2 = atoi(cpu2); | |
396 | } | |
397 | ||
398 | icpu = atoi(cpu); | |
399 | if (icpu2 == -1) | |
400 | icpu2 = icpu; | |
401 | while (icpu <= icpu2) { | |
6d459ee7 | 402 | if (icpu >= FIO_MAX_CPUS) { |
19608d6c | 403 | log_err("fio: your OS only supports up to" |
6d459ee7 | 404 | " %d CPUs\n", (int) FIO_MAX_CPUS); |
19608d6c JA |
405 | ret = 1; |
406 | break; | |
407 | } | |
b03daafb JA |
408 | if (icpu > max_cpu) { |
409 | log_err("fio: CPU %d too large (max=%ld)\n", | |
410 | icpu, max_cpu); | |
411 | ret = 1; | |
412 | break; | |
413 | } | |
0b9d69ec | 414 | |
62a7273d | 415 | dprint(FD_PARSE, "set cpu allowed %d\n", icpu); |
e8462bd8 | 416 | fio_cpu_set(mask, icpu); |
62a7273d JA |
417 | icpu++; |
418 | } | |
19608d6c JA |
419 | if (ret) |
420 | break; | |
d2e268b0 JA |
421 | } |
422 | ||
423 | free(p); | |
19608d6c JA |
424 | if (!ret) |
425 | td->o.cpumask_set = 1; | |
426 | return ret; | |
214e1eca | 427 | } |
e8462bd8 JA |
428 | |
429 | static int str_cpus_allowed_cb(void *data, const char *input) | |
430 | { | |
431 | struct thread_data *td = data; | |
432 | int ret; | |
433 | ||
434 | ret = set_cpus_allowed(td, &td->o.cpumask, input); | |
435 | if (!ret) | |
436 | td->o.cpumask_set = 1; | |
437 | ||
438 | return ret; | |
439 | } | |
440 | ||
441 | static int str_verify_cpus_allowed_cb(void *data, const char *input) | |
442 | { | |
443 | struct thread_data *td = data; | |
444 | int ret; | |
445 | ||
446 | ret = set_cpus_allowed(td, &td->o.verify_cpumask, input); | |
447 | if (!ret) | |
448 | td->o.verify_cpumask_set = 1; | |
449 | ||
450 | return ret; | |
451 | } | |
d2e268b0 | 452 | #endif |
214e1eca | 453 | |
0d29de83 JA |
454 | #ifdef FIO_HAVE_TRIM |
455 | static int str_verify_trim_cb(void *data, unsigned long long *val) | |
456 | { | |
457 | struct thread_data *td = data; | |
458 | ||
459 | td->o.trim_percentage = *val; | |
460 | return 0; | |
461 | } | |
462 | #endif | |
463 | ||
214e1eca JA |
464 | static int str_fst_cb(void *data, const char *str) |
465 | { | |
466 | struct thread_data *td = data; | |
467 | char *nr = get_opt_postfix(str); | |
468 | ||
469 | td->file_service_nr = 1; | |
182ec6ee | 470 | if (nr) { |
214e1eca | 471 | td->file_service_nr = atoi(nr); |
182ec6ee JA |
472 | free(nr); |
473 | } | |
214e1eca JA |
474 | |
475 | return 0; | |
476 | } | |
477 | ||
3ae06371 | 478 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
44f29692 JA |
479 | static int str_sfr_cb(void *data, const char *str) |
480 | { | |
481 | struct thread_data *td = data; | |
482 | char *nr = get_opt_postfix(str); | |
483 | ||
484 | td->sync_file_range_nr = 1; | |
485 | if (nr) { | |
486 | td->sync_file_range_nr = atoi(nr); | |
487 | free(nr); | |
488 | } | |
489 | ||
490 | return 0; | |
491 | } | |
3ae06371 | 492 | #endif |
44f29692 | 493 | |
921c766f JA |
494 | static int check_dir(struct thread_data *td, char *fname) |
495 | { | |
3f0ca9b9 | 496 | #if 0 |
921c766f | 497 | char file[PATH_MAX], *dir; |
bc838919 | 498 | int elen = 0; |
921c766f | 499 | |
bc838919 JA |
500 | if (td->o.directory) { |
501 | strcpy(file, td->o.directory); | |
fcef0b35 | 502 | strcat(file, "/"); |
bc838919 JA |
503 | elen = strlen(file); |
504 | } | |
505 | ||
fcef0b35 | 506 | sprintf(file + elen, "%s", fname); |
921c766f JA |
507 | dir = dirname(file); |
508 | ||
fcef0b35 JA |
509 | { |
510 | struct stat sb; | |
511 | /* | |
512 | * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded | |
513 | * yet, so we can't do this check right here... | |
514 | */ | |
921c766f JA |
515 | if (lstat(dir, &sb) < 0) { |
516 | int ret = errno; | |
517 | ||
518 | log_err("fio: %s is not a directory\n", dir); | |
519 | td_verror(td, ret, "lstat"); | |
520 | return 1; | |
521 | } | |
522 | ||
523 | if (!S_ISDIR(sb.st_mode)) { | |
524 | log_err("fio: %s is not a directory\n", dir); | |
525 | return 1; | |
526 | } | |
fcef0b35 JA |
527 | } |
528 | #endif | |
921c766f JA |
529 | |
530 | return 0; | |
531 | } | |
532 | ||
8e827d35 JA |
533 | /* |
534 | * Return next file in the string. Files are separated with ':'. If the ':' | |
535 | * is escaped with a '\', then that ':' is part of the filename and does not | |
536 | * indicate a new file. | |
537 | */ | |
538 | static char *get_next_file_name(char **ptr) | |
539 | { | |
540 | char *str = *ptr; | |
541 | char *p, *start; | |
542 | ||
543 | if (!str || !strlen(str)) | |
544 | return NULL; | |
545 | ||
546 | start = str; | |
547 | do { | |
548 | /* | |
549 | * No colon, we are done | |
550 | */ | |
551 | p = strchr(str, ':'); | |
552 | if (!p) { | |
553 | *ptr = NULL; | |
554 | break; | |
555 | } | |
556 | ||
557 | /* | |
558 | * We got a colon, but it's the first character. Skip and | |
559 | * continue | |
560 | */ | |
561 | if (p == start) { | |
562 | str = ++start; | |
563 | continue; | |
564 | } | |
565 | ||
566 | if (*(p - 1) != '\\') { | |
567 | *p = '\0'; | |
568 | *ptr = p + 1; | |
569 | break; | |
570 | } | |
571 | ||
572 | memmove(p - 1, p, strlen(p) + 1); | |
573 | str = p; | |
574 | } while (1); | |
575 | ||
576 | return start; | |
577 | } | |
578 | ||
214e1eca JA |
579 | static int str_filename_cb(void *data, const char *input) |
580 | { | |
581 | struct thread_data *td = data; | |
582 | char *fname, *str, *p; | |
583 | ||
584 | p = str = strdup(input); | |
585 | ||
586 | strip_blank_front(&str); | |
587 | strip_blank_end(str); | |
588 | ||
589 | if (!td->files_index) | |
2dc1bbeb | 590 | td->o.nr_files = 0; |
214e1eca | 591 | |
8e827d35 | 592 | while ((fname = get_next_file_name(&str)) != NULL) { |
214e1eca JA |
593 | if (!strlen(fname)) |
594 | break; | |
921c766f JA |
595 | if (check_dir(td, fname)) { |
596 | free(p); | |
597 | return 1; | |
598 | } | |
214e1eca | 599 | add_file(td, fname); |
2dc1bbeb | 600 | td->o.nr_files++; |
214e1eca JA |
601 | } |
602 | ||
603 | free(p); | |
604 | return 0; | |
605 | } | |
606 | ||
607 | static int str_directory_cb(void *data, const char fio_unused *str) | |
608 | { | |
609 | struct thread_data *td = data; | |
610 | struct stat sb; | |
611 | ||
2dc1bbeb | 612 | if (lstat(td->o.directory, &sb) < 0) { |
921c766f JA |
613 | int ret = errno; |
614 | ||
2dc1bbeb | 615 | log_err("fio: %s is not a directory\n", td->o.directory); |
921c766f | 616 | td_verror(td, ret, "lstat"); |
214e1eca JA |
617 | return 1; |
618 | } | |
619 | if (!S_ISDIR(sb.st_mode)) { | |
2dc1bbeb | 620 | log_err("fio: %s is not a directory\n", td->o.directory); |
214e1eca JA |
621 | return 1; |
622 | } | |
623 | ||
624 | return 0; | |
625 | } | |
626 | ||
627 | static int str_opendir_cb(void *data, const char fio_unused *str) | |
628 | { | |
629 | struct thread_data *td = data; | |
630 | ||
631 | if (!td->files_index) | |
2dc1bbeb | 632 | td->o.nr_files = 0; |
214e1eca | 633 | |
2dc1bbeb | 634 | return add_dir_files(td, td->o.opendir); |
214e1eca JA |
635 | } |
636 | ||
85bc833b | 637 | static int str_verify_offset_cb(void *data, unsigned long long *off) |
546a9142 SL |
638 | { |
639 | struct thread_data *td = data; | |
a59e170d | 640 | |
546a9142 | 641 | if (*off && *off < sizeof(struct verify_header)) { |
a59e170d | 642 | log_err("fio: verify_offset too small\n"); |
546a9142 SL |
643 | return 1; |
644 | } | |
a59e170d JA |
645 | |
646 | td->o.verify_offset = *off; | |
546a9142 SL |
647 | return 0; |
648 | } | |
649 | ||
0e92f873 | 650 | static int str_verify_pattern_cb(void *data, const char *input) |
90059d65 JA |
651 | { |
652 | struct thread_data *td = data; | |
0e92f873 RR |
653 | long off; |
654 | int i = 0, j = 0, len, k, base = 10; | |
655 | char* loc1, * loc2; | |
656 | ||
657 | loc1 = strstr(input, "0x"); | |
658 | loc2 = strstr(input, "0X"); | |
659 | if (loc1 || loc2) | |
660 | base = 16; | |
661 | off = strtol(input, NULL, base); | |
662 | if (off != LONG_MAX || errno != ERANGE) { | |
663 | while (off) { | |
664 | td->o.verify_pattern[i] = off & 0xff; | |
665 | off >>= 8; | |
666 | i++; | |
667 | } | |
668 | } else { | |
669 | len = strlen(input); | |
670 | k = len - 1; | |
671 | if (base == 16) { | |
672 | if (loc1) | |
673 | j = loc1 - input + 2; | |
674 | else | |
675 | j = loc2 - input + 2; | |
676 | } else | |
677 | return 1; | |
678 | if (len - j < MAX_PATTERN_SIZE * 2) { | |
679 | while (k >= j) { | |
680 | off = converthexchartoint(input[k--]); | |
681 | if (k >= j) | |
682 | off += (converthexchartoint(input[k--]) | |
683 | * 16); | |
684 | td->o.verify_pattern[i++] = (char) off; | |
685 | } | |
686 | } | |
687 | } | |
efcd9dcc SL |
688 | |
689 | /* | |
690 | * Fill the pattern all the way to the end. This greatly reduces | |
691 | * the number of memcpy's we have to do when verifying the IO. | |
692 | */ | |
693 | while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) { | |
694 | memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i); | |
695 | i *= 2; | |
696 | } | |
9a2a86d0 SL |
697 | if (i == 1) { |
698 | /* | |
699 | * The code in verify_io_u_pattern assumes a single byte pattern | |
700 | * fills the whole verify pattern buffer. | |
701 | */ | |
702 | memset(td->o.verify_pattern, td->o.verify_pattern[0], | |
703 | MAX_PATTERN_SIZE); | |
704 | } | |
efcd9dcc | 705 | |
0e92f873 | 706 | td->o.verify_pattern_bytes = i; |
efcd9dcc | 707 | |
92bf48d5 JA |
708 | /* |
709 | * VERIFY_META could already be set | |
710 | */ | |
711 | if (td->o.verify == VERIFY_NONE) | |
712 | td->o.verify = VERIFY_PATTERN; | |
efcd9dcc | 713 | |
90059d65 JA |
714 | return 0; |
715 | } | |
214e1eca | 716 | |
4d4e80f2 JA |
717 | static int str_lockfile_cb(void *data, const char *str) |
718 | { | |
719 | struct thread_data *td = data; | |
720 | char *nr = get_opt_postfix(str); | |
721 | ||
722 | td->o.lockfile_batch = 1; | |
182ec6ee | 723 | if (nr) { |
4d4e80f2 | 724 | td->o.lockfile_batch = atoi(nr); |
182ec6ee JA |
725 | free(nr); |
726 | } | |
4d4e80f2 JA |
727 | |
728 | return 0; | |
729 | } | |
730 | ||
e3cedca7 JA |
731 | static int str_write_bw_log_cb(void *data, const char *str) |
732 | { | |
733 | struct thread_data *td = data; | |
734 | ||
735 | if (str) | |
736 | td->o.bw_log_file = strdup(str); | |
737 | ||
738 | td->o.write_bw_log = 1; | |
739 | return 0; | |
740 | } | |
741 | ||
742 | static int str_write_lat_log_cb(void *data, const char *str) | |
743 | { | |
744 | struct thread_data *td = data; | |
745 | ||
746 | if (str) | |
747 | td->o.lat_log_file = strdup(str); | |
748 | ||
749 | td->o.write_lat_log = 1; | |
750 | return 0; | |
751 | } | |
752 | ||
c8eeb9df JA |
753 | static int str_write_iops_log_cb(void *data, const char *str) |
754 | { | |
755 | struct thread_data *td = data; | |
756 | ||
757 | if (str) | |
758 | td->o.iops_log_file = strdup(str); | |
759 | ||
760 | td->o.write_iops_log = 1; | |
761 | return 0; | |
762 | } | |
763 | ||
993bf48b JA |
764 | static int str_gtod_reduce_cb(void *data, int *il) |
765 | { | |
766 | struct thread_data *td = data; | |
767 | int val = *il; | |
768 | ||
02af0988 | 769 | td->o.disable_lat = !!val; |
993bf48b JA |
770 | td->o.disable_clat = !!val; |
771 | td->o.disable_slat = !!val; | |
772 | td->o.disable_bw = !!val; | |
0dc1bc03 | 773 | td->o.clat_percentiles = !val; |
993bf48b JA |
774 | if (val) |
775 | td->tv_cache_mask = 63; | |
776 | ||
777 | return 0; | |
778 | } | |
779 | ||
85bc833b | 780 | static int str_gtod_cpu_cb(void *data, long long *il) |
be4ecfdf JA |
781 | { |
782 | struct thread_data *td = data; | |
783 | int val = *il; | |
784 | ||
785 | td->o.gtod_cpu = val; | |
786 | td->o.gtod_offload = 1; | |
787 | return 0; | |
788 | } | |
789 | ||
7bb59102 JA |
790 | static int str_size_cb(void *data, unsigned long long *__val) |
791 | { | |
792 | struct thread_data *td = data; | |
793 | unsigned long long v = *__val; | |
794 | ||
795 | if (parse_is_percent(v)) { | |
796 | td->o.size = 0; | |
797 | td->o.size_percent = -1ULL - v; | |
798 | } else | |
799 | td->o.size = v; | |
800 | ||
801 | return 0; | |
802 | } | |
803 | ||
896cac2a JA |
804 | static int rw_verify(struct fio_option *o, void *data) |
805 | { | |
806 | struct thread_data *td = data; | |
807 | ||
808 | if (read_only && td_write(td)) { | |
809 | log_err("fio: job <%s> has write bit set, but fio is in" | |
810 | " read-only mode\n", td->o.name); | |
811 | return 1; | |
812 | } | |
813 | ||
814 | return 0; | |
815 | } | |
816 | ||
276ca4f7 | 817 | static int gtod_cpu_verify(struct fio_option *o, void *data) |
29d43ff9 | 818 | { |
276ca4f7 | 819 | #ifndef FIO_HAVE_CPU_AFFINITY |
29d43ff9 JA |
820 | struct thread_data *td = data; |
821 | ||
29d43ff9 JA |
822 | if (td->o.gtod_cpu) { |
823 | log_err("fio: platform must support CPU affinity for" | |
824 | "gettimeofday() offloading\n"); | |
825 | return 1; | |
826 | } | |
827 | #endif | |
828 | ||
829 | return 0; | |
830 | } | |
831 | ||
90fef2d1 JA |
832 | static int kb_base_verify(struct fio_option *o, void *data) |
833 | { | |
834 | struct thread_data *td = data; | |
835 | ||
836 | if (td->o.kb_base != 1024 && td->o.kb_base != 1000) { | |
837 | log_err("fio: kb_base set to nonsensical value: %u\n", | |
838 | td->o.kb_base); | |
839 | return 1; | |
840 | } | |
841 | ||
842 | return 0; | |
843 | } | |
844 | ||
214e1eca JA |
845 | /* |
846 | * Map of job/command line options | |
847 | */ | |
07b3232d | 848 | static struct fio_option options[FIO_MAX_OPTS] = { |
214e1eca JA |
849 | { |
850 | .name = "description", | |
851 | .type = FIO_OPT_STR_STORE, | |
852 | .off1 = td_var_offset(description), | |
853 | .help = "Text job description", | |
c9c63318 | 854 | .category = FIO_OPT_G_DESC, |
214e1eca JA |
855 | }, |
856 | { | |
857 | .name = "name", | |
858 | .type = FIO_OPT_STR_STORE, | |
859 | .off1 = td_var_offset(name), | |
860 | .help = "Name of this job", | |
c9c63318 | 861 | .category = FIO_OPT_G_DESC, |
214e1eca JA |
862 | }, |
863 | { | |
864 | .name = "directory", | |
865 | .type = FIO_OPT_STR_STORE, | |
866 | .off1 = td_var_offset(directory), | |
867 | .cb = str_directory_cb, | |
868 | .help = "Directory to store files in", | |
c9c63318 | 869 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
870 | }, |
871 | { | |
872 | .name = "filename", | |
873 | .type = FIO_OPT_STR_STORE, | |
874 | .off1 = td_var_offset(filename), | |
875 | .cb = str_filename_cb, | |
f0d524b0 | 876 | .prio = -1, /* must come after "directory" */ |
214e1eca | 877 | .help = "File(s) to use for the workload", |
c9c63318 | 878 | .category = FIO_OPT_G_FILE, |
214e1eca | 879 | }, |
90fef2d1 JA |
880 | { |
881 | .name = "kb_base", | |
882 | .type = FIO_OPT_INT, | |
883 | .off1 = td_var_offset(kb_base), | |
90fef2d1 | 884 | .verify = kb_base_verify, |
a639f0bb | 885 | .prio = 1, |
90fef2d1 | 886 | .def = "1024", |
a639f0bb | 887 | .help = "How many bytes per KB for reporting (1000 or 1024)", |
c9c63318 | 888 | .category = FIO_OPT_G_MISC, |
90fef2d1 | 889 | }, |
29c1349f JA |
890 | { |
891 | .name = "lockfile", | |
4d4e80f2 JA |
892 | .type = FIO_OPT_STR, |
893 | .cb = str_lockfile_cb, | |
894 | .off1 = td_var_offset(file_lock_mode), | |
29c1349f JA |
895 | .help = "Lock file when doing IO to it", |
896 | .parent = "filename", | |
4d4e80f2 | 897 | .def = "none", |
c9c63318 | 898 | .category = FIO_OPT_G_FILE, |
4d4e80f2 JA |
899 | .posval = { |
900 | { .ival = "none", | |
901 | .oval = FILE_LOCK_NONE, | |
902 | .help = "No file locking", | |
903 | }, | |
904 | { .ival = "exclusive", | |
905 | .oval = FILE_LOCK_EXCLUSIVE, | |
906 | .help = "Exclusive file lock", | |
907 | }, | |
908 | { | |
909 | .ival = "readwrite", | |
910 | .oval = FILE_LOCK_READWRITE, | |
911 | .help = "Read vs write lock", | |
912 | }, | |
913 | }, | |
29c1349f | 914 | }, |
214e1eca JA |
915 | { |
916 | .name = "opendir", | |
917 | .type = FIO_OPT_STR_STORE, | |
918 | .off1 = td_var_offset(opendir), | |
919 | .cb = str_opendir_cb, | |
920 | .help = "Recursively add files from this directory and down", | |
c9c63318 | 921 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
922 | }, |
923 | { | |
924 | .name = "rw", | |
d3aad8f2 | 925 | .alias = "readwrite", |
214e1eca | 926 | .type = FIO_OPT_STR, |
211097b2 | 927 | .cb = str_rw_cb, |
214e1eca JA |
928 | .off1 = td_var_offset(td_ddir), |
929 | .help = "IO direction", | |
930 | .def = "read", | |
896cac2a | 931 | .verify = rw_verify, |
c9c63318 | 932 | .category = FIO_OPT_G_IO_DDIR, |
214e1eca JA |
933 | .posval = { |
934 | { .ival = "read", | |
935 | .oval = TD_DDIR_READ, | |
936 | .help = "Sequential read", | |
937 | }, | |
938 | { .ival = "write", | |
939 | .oval = TD_DDIR_WRITE, | |
940 | .help = "Sequential write", | |
941 | }, | |
942 | { .ival = "randread", | |
943 | .oval = TD_DDIR_RANDREAD, | |
944 | .help = "Random read", | |
945 | }, | |
946 | { .ival = "randwrite", | |
947 | .oval = TD_DDIR_RANDWRITE, | |
948 | .help = "Random write", | |
949 | }, | |
950 | { .ival = "rw", | |
951 | .oval = TD_DDIR_RW, | |
952 | .help = "Sequential read and write mix", | |
953 | }, | |
954 | { .ival = "randrw", | |
955 | .oval = TD_DDIR_RANDRW, | |
956 | .help = "Random read and write mix" | |
957 | }, | |
958 | }, | |
959 | }, | |
38dad62d JA |
960 | { |
961 | .name = "rw_sequencer", | |
962 | .type = FIO_OPT_STR, | |
963 | .off1 = td_var_offset(rw_seq), | |
964 | .help = "IO offset generator modifier", | |
965 | .def = "sequential", | |
c9c63318 | 966 | .category = FIO_OPT_G_IO_DDIR, |
38dad62d JA |
967 | .posval = { |
968 | { .ival = "sequential", | |
969 | .oval = RW_SEQ_SEQ, | |
970 | .help = "Generate sequential offsets", | |
971 | }, | |
972 | { .ival = "identical", | |
973 | .oval = RW_SEQ_IDENT, | |
974 | .help = "Generate identical offsets", | |
975 | }, | |
976 | }, | |
977 | }, | |
978 | ||
214e1eca JA |
979 | { |
980 | .name = "ioengine", | |
981 | .type = FIO_OPT_STR_STORE, | |
982 | .off1 = td_var_offset(ioengine), | |
983 | .help = "IO engine to use", | |
58483fa4 | 984 | .def = FIO_PREFERRED_ENGINE, |
c9c63318 | 985 | .category = FIO_OPT_G_IO, |
214e1eca JA |
986 | .posval = { |
987 | { .ival = "sync", | |
988 | .help = "Use read/write", | |
989 | }, | |
a31041ea | 990 | { .ival = "psync", |
991 | .help = "Use pread/pwrite", | |
992 | }, | |
1d2af02a | 993 | { .ival = "vsync", |
03e20d68 | 994 | .help = "Use readv/writev", |
1d2af02a | 995 | }, |
214e1eca JA |
996 | #ifdef FIO_HAVE_LIBAIO |
997 | { .ival = "libaio", | |
998 | .help = "Linux native asynchronous IO", | |
999 | }, | |
1000 | #endif | |
1001 | #ifdef FIO_HAVE_POSIXAIO | |
1002 | { .ival = "posixaio", | |
1003 | .help = "POSIX asynchronous IO", | |
1004 | }, | |
417f0068 JA |
1005 | #endif |
1006 | #ifdef FIO_HAVE_SOLARISAIO | |
1007 | { .ival = "solarisaio", | |
1008 | .help = "Solaris native asynchronous IO", | |
1009 | }, | |
214e1eca | 1010 | #endif |
03e20d68 BC |
1011 | #ifdef FIO_HAVE_WINDOWSAIO |
1012 | { .ival = "windowsaio", | |
3be80071 | 1013 | .help = "Windows native asynchronous IO" |
de890a1e | 1014 | }, |
3be80071 | 1015 | #endif |
214e1eca | 1016 | { .ival = "mmap", |
03e20d68 | 1017 | .help = "Memory mapped IO" |
214e1eca JA |
1018 | }, |
1019 | #ifdef FIO_HAVE_SPLICE | |
1020 | { .ival = "splice", | |
1021 | .help = "splice/vmsplice based IO", | |
1022 | }, | |
9cce02e8 JA |
1023 | { .ival = "netsplice", |
1024 | .help = "splice/vmsplice to/from the network", | |
1025 | }, | |
214e1eca JA |
1026 | #endif |
1027 | #ifdef FIO_HAVE_SGIO | |
1028 | { .ival = "sg", | |
1029 | .help = "SCSI generic v3 IO", | |
1030 | }, | |
1031 | #endif | |
1032 | { .ival = "null", | |
1033 | .help = "Testing engine (no data transfer)", | |
1034 | }, | |
1035 | { .ival = "net", | |
1036 | .help = "Network IO", | |
1037 | }, | |
1038 | #ifdef FIO_HAVE_SYSLET | |
1039 | { .ival = "syslet-rw", | |
1040 | .help = "syslet enabled async pread/pwrite IO", | |
1041 | }, | |
1042 | #endif | |
1043 | { .ival = "cpuio", | |
03e20d68 | 1044 | .help = "CPU cycle burner engine", |
214e1eca | 1045 | }, |
b8c82a46 JA |
1046 | #ifdef FIO_HAVE_GUASI |
1047 | { .ival = "guasi", | |
1048 | .help = "GUASI IO engine", | |
1049 | }, | |
79a43187 JA |
1050 | #endif |
1051 | #ifdef FIO_HAVE_BINJECT | |
1052 | { .ival = "binject", | |
1053 | .help = "binject direct inject block engine", | |
1054 | }, | |
21b8aee8 | 1055 | #endif |
1056 | #ifdef FIO_HAVE_RDMA | |
1057 | { .ival = "rdma", | |
1058 | .help = "RDMA IO engine", | |
1059 | }, | |
b8c82a46 | 1060 | #endif |
214e1eca JA |
1061 | { .ival = "external", |
1062 | .help = "Load external engine (append name)", | |
1063 | }, | |
1064 | }, | |
1065 | }, | |
1066 | { | |
1067 | .name = "iodepth", | |
1068 | .type = FIO_OPT_INT, | |
1069 | .off1 = td_var_offset(iodepth), | |
03e20d68 | 1070 | .help = "Number of IO buffers to keep in flight", |
757aff4f | 1071 | .minval = 1, |
214e1eca | 1072 | .def = "1", |
c9c63318 | 1073 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1074 | }, |
1075 | { | |
1076 | .name = "iodepth_batch", | |
4950421a | 1077 | .alias = "iodepth_batch_submit", |
214e1eca JA |
1078 | .type = FIO_OPT_INT, |
1079 | .off1 = td_var_offset(iodepth_batch), | |
d65db441 | 1080 | .help = "Number of IO buffers to submit in one go", |
afdf9352 | 1081 | .parent = "iodepth", |
a2e6f8ac JA |
1082 | .minval = 1, |
1083 | .def = "1", | |
c9c63318 | 1084 | .category = FIO_OPT_G_IO, |
4950421a JA |
1085 | }, |
1086 | { | |
1087 | .name = "iodepth_batch_complete", | |
1088 | .type = FIO_OPT_INT, | |
1089 | .off1 = td_var_offset(iodepth_batch_complete), | |
d65db441 | 1090 | .help = "Number of IO buffers to retrieve in one go", |
4950421a JA |
1091 | .parent = "iodepth", |
1092 | .minval = 0, | |
1093 | .def = "1", | |
c9c63318 | 1094 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1095 | }, |
1096 | { | |
1097 | .name = "iodepth_low", | |
1098 | .type = FIO_OPT_INT, | |
1099 | .off1 = td_var_offset(iodepth_low), | |
1100 | .help = "Low water mark for queuing depth", | |
afdf9352 | 1101 | .parent = "iodepth", |
c9c63318 | 1102 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1103 | }, |
1104 | { | |
1105 | .name = "size", | |
1106 | .type = FIO_OPT_STR_VAL, | |
7bb59102 | 1107 | .cb = str_size_cb, |
214e1eca | 1108 | .help = "Total size of device or files", |
c9c63318 | 1109 | .category = FIO_OPT_G_IO, |
214e1eca | 1110 | }, |
aa31f1f1 SL |
1111 | { |
1112 | .name = "fill_device", | |
74586c1e | 1113 | .alias = "fill_fs", |
aa31f1f1 SL |
1114 | .type = FIO_OPT_BOOL, |
1115 | .off1 = td_var_offset(fill_device), | |
1116 | .help = "Write until an ENOSPC error occurs", | |
1117 | .def = "0", | |
c9c63318 | 1118 | .category = FIO_OPT_G_IO, |
aa31f1f1 | 1119 | }, |
214e1eca JA |
1120 | { |
1121 | .name = "filesize", | |
1122 | .type = FIO_OPT_STR_VAL, | |
1123 | .off1 = td_var_offset(file_size_low), | |
1124 | .off2 = td_var_offset(file_size_high), | |
c3edbdba | 1125 | .minval = 1, |
214e1eca | 1126 | .help = "Size of individual files", |
c9c63318 | 1127 | .category = FIO_OPT_G_IO | FIO_OPT_G_FILE, |
214e1eca | 1128 | }, |
67a1000f JA |
1129 | { |
1130 | .name = "offset", | |
1131 | .alias = "fileoffset", | |
1132 | .type = FIO_OPT_STR_VAL, | |
1133 | .off1 = td_var_offset(start_offset), | |
1134 | .help = "Start IO from this offset", | |
1135 | .def = "0", | |
c9c63318 | 1136 | .category = FIO_OPT_G_IO, |
67a1000f | 1137 | }, |
214e1eca JA |
1138 | { |
1139 | .name = "bs", | |
d3aad8f2 | 1140 | .alias = "blocksize", |
e01b22b8 | 1141 | .type = FIO_OPT_INT, |
214e1eca JA |
1142 | .off1 = td_var_offset(bs[DDIR_READ]), |
1143 | .off2 = td_var_offset(bs[DDIR_WRITE]), | |
c3edbdba | 1144 | .minval = 1, |
214e1eca JA |
1145 | .help = "Block size unit", |
1146 | .def = "4k", | |
67a1000f | 1147 | .parent = "rw", |
c9c63318 | 1148 | .category = FIO_OPT_G_IO, |
214e1eca | 1149 | }, |
2b7a01d0 JA |
1150 | { |
1151 | .name = "ba", | |
1152 | .alias = "blockalign", | |
e01b22b8 | 1153 | .type = FIO_OPT_INT, |
2b7a01d0 JA |
1154 | .off1 = td_var_offset(ba[DDIR_READ]), |
1155 | .off2 = td_var_offset(ba[DDIR_WRITE]), | |
1156 | .minval = 1, | |
1157 | .help = "IO block offset alignment", | |
1158 | .parent = "rw", | |
c9c63318 | 1159 | .category = FIO_OPT_G_IO | FIO_OPT_G_IO_BUF, |
2b7a01d0 | 1160 | }, |
214e1eca JA |
1161 | { |
1162 | .name = "bsrange", | |
d3aad8f2 | 1163 | .alias = "blocksize_range", |
214e1eca JA |
1164 | .type = FIO_OPT_RANGE, |
1165 | .off1 = td_var_offset(min_bs[DDIR_READ]), | |
1166 | .off2 = td_var_offset(max_bs[DDIR_READ]), | |
1167 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), | |
1168 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), | |
c3edbdba | 1169 | .minval = 1, |
214e1eca | 1170 | .help = "Set block size range (in more detail than bs)", |
67a1000f | 1171 | .parent = "rw", |
c9c63318 | 1172 | .category = FIO_OPT_G_IO, |
214e1eca | 1173 | }, |
564ca972 JA |
1174 | { |
1175 | .name = "bssplit", | |
1176 | .type = FIO_OPT_STR, | |
1177 | .cb = str_bssplit_cb, | |
1178 | .help = "Set a specific mix of block sizes", | |
1179 | .parent = "rw", | |
c9c63318 | 1180 | .category = FIO_OPT_G_IO, |
564ca972 | 1181 | }, |
214e1eca JA |
1182 | { |
1183 | .name = "bs_unaligned", | |
d3aad8f2 | 1184 | .alias = "blocksize_unaligned", |
214e1eca JA |
1185 | .type = FIO_OPT_STR_SET, |
1186 | .off1 = td_var_offset(bs_unaligned), | |
1187 | .help = "Don't sector align IO buffer sizes", | |
67a1000f | 1188 | .parent = "rw", |
c9c63318 | 1189 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1190 | }, |
1191 | { | |
1192 | .name = "randrepeat", | |
1193 | .type = FIO_OPT_BOOL, | |
1194 | .off1 = td_var_offset(rand_repeatable), | |
1195 | .help = "Use repeatable random IO pattern", | |
1196 | .def = "1", | |
67a1000f | 1197 | .parent = "rw", |
c9c63318 | 1198 | .category = FIO_OPT_G_IO | FIO_OPT_G_RAND, |
214e1eca | 1199 | }, |
2615cc4b JA |
1200 | { |
1201 | .name = "use_os_rand", | |
1202 | .type = FIO_OPT_BOOL, | |
1203 | .off1 = td_var_offset(use_os_rand), | |
1204 | .help = "Set to use OS random generator", | |
1205 | .def = "0", | |
1206 | .parent = "rw", | |
c9c63318 | 1207 | .category = FIO_OPT_G_RAND, |
2615cc4b | 1208 | }, |
214e1eca JA |
1209 | { |
1210 | .name = "norandommap", | |
1211 | .type = FIO_OPT_STR_SET, | |
1212 | .off1 = td_var_offset(norandommap), | |
1213 | .help = "Accept potential duplicate random blocks", | |
67a1000f | 1214 | .parent = "rw", |
c9c63318 | 1215 | .category = FIO_OPT_G_RAND, |
214e1eca | 1216 | }, |
2b386d25 JA |
1217 | { |
1218 | .name = "softrandommap", | |
1219 | .type = FIO_OPT_BOOL, | |
1220 | .off1 = td_var_offset(softrandommap), | |
f66ab3c8 | 1221 | .help = "Set norandommap if randommap allocation fails", |
2b386d25 JA |
1222 | .parent = "norandommap", |
1223 | .def = "0", | |
c9c63318 | 1224 | .category = FIO_OPT_G_RAND, |
2b386d25 | 1225 | }, |
214e1eca JA |
1226 | { |
1227 | .name = "nrfiles", | |
d7c8be03 | 1228 | .alias = "nr_files", |
214e1eca JA |
1229 | .type = FIO_OPT_INT, |
1230 | .off1 = td_var_offset(nr_files), | |
1231 | .help = "Split job workload between this number of files", | |
1232 | .def = "1", | |
c9c63318 | 1233 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
1234 | }, |
1235 | { | |
1236 | .name = "openfiles", | |
1237 | .type = FIO_OPT_INT, | |
1238 | .off1 = td_var_offset(open_files), | |
1239 | .help = "Number of files to keep open at the same time", | |
c9c63318 | 1240 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
1241 | }, |
1242 | { | |
1243 | .name = "file_service_type", | |
1244 | .type = FIO_OPT_STR, | |
1245 | .cb = str_fst_cb, | |
1246 | .off1 = td_var_offset(file_service_type), | |
1247 | .help = "How to select which file to service next", | |
1248 | .def = "roundrobin", | |
c9c63318 | 1249 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
1250 | .posval = { |
1251 | { .ival = "random", | |
1252 | .oval = FIO_FSERVICE_RANDOM, | |
1253 | .help = "Choose a file at random", | |
1254 | }, | |
1255 | { .ival = "roundrobin", | |
1256 | .oval = FIO_FSERVICE_RR, | |
1257 | .help = "Round robin select files", | |
1258 | }, | |
a086c257 JA |
1259 | { .ival = "sequential", |
1260 | .oval = FIO_FSERVICE_SEQ, | |
1261 | .help = "Finish one file before moving to the next", | |
1262 | }, | |
214e1eca | 1263 | }, |
67a1000f JA |
1264 | .parent = "nrfiles", |
1265 | }, | |
7bc8c2cf JA |
1266 | #ifdef FIO_HAVE_FALLOCATE |
1267 | { | |
1268 | .name = "fallocate", | |
a596f047 EG |
1269 | .type = FIO_OPT_STR, |
1270 | .off1 = td_var_offset(fallocate_mode), | |
1271 | .help = "Whether pre-allocation is performed when laying out files", | |
1272 | .def = "posix", | |
c9c63318 | 1273 | .category = FIO_OPT_G_FILE, |
a596f047 EG |
1274 | .posval = { |
1275 | { .ival = "none", | |
1276 | .oval = FIO_FALLOCATE_NONE, | |
1277 | .help = "Do not pre-allocate space", | |
1278 | }, | |
1279 | { .ival = "posix", | |
1280 | .oval = FIO_FALLOCATE_POSIX, | |
1281 | .help = "Use posix_fallocate()", | |
1282 | }, | |
1283 | #ifdef FIO_HAVE_LINUX_FALLOCATE | |
1284 | { .ival = "keep", | |
1285 | .oval = FIO_FALLOCATE_KEEP_SIZE, | |
1286 | .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", | |
1287 | }, | |
7bc8c2cf | 1288 | #endif |
a596f047 EG |
1289 | /* Compatibility with former boolean values */ |
1290 | { .ival = "0", | |
1291 | .oval = FIO_FALLOCATE_NONE, | |
1292 | .help = "Alias for 'none'", | |
1293 | }, | |
1294 | { .ival = "1", | |
1295 | .oval = FIO_FALLOCATE_POSIX, | |
1296 | .help = "Alias for 'posix'", | |
1297 | }, | |
1298 | }, | |
1299 | }, | |
1300 | #endif /* FIO_HAVE_FALLOCATE */ | |
67a1000f JA |
1301 | { |
1302 | .name = "fadvise_hint", | |
1303 | .type = FIO_OPT_BOOL, | |
1304 | .off1 = td_var_offset(fadvise_hint), | |
1305 | .help = "Use fadvise() to advise the kernel on IO pattern", | |
1306 | .def = "1", | |
c9c63318 | 1307 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
1308 | }, |
1309 | { | |
1310 | .name = "fsync", | |
1311 | .type = FIO_OPT_INT, | |
1312 | .off1 = td_var_offset(fsync_blocks), | |
1313 | .help = "Issue fsync for writes every given number of blocks", | |
1314 | .def = "0", | |
c9c63318 | 1315 | .category = FIO_OPT_G_FILE, |
214e1eca | 1316 | }, |
5f9099ea JA |
1317 | { |
1318 | .name = "fdatasync", | |
1319 | .type = FIO_OPT_INT, | |
1320 | .off1 = td_var_offset(fdatasync_blocks), | |
1321 | .help = "Issue fdatasync for writes every given number of blocks", | |
1322 | .def = "0", | |
c9c63318 | 1323 | .category = FIO_OPT_G_FILE, |
5f9099ea | 1324 | }, |
1ef2b6be JA |
1325 | { |
1326 | .name = "write_barrier", | |
1327 | .type = FIO_OPT_INT, | |
1328 | .off1 = td_var_offset(barrier_blocks), | |
1329 | .help = "Make every Nth write a barrier write", | |
1330 | .def = "0", | |
c9c63318 | 1331 | .category = FIO_OPT_G_IO, |
1ef2b6be | 1332 | }, |
44f29692 JA |
1333 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
1334 | { | |
1335 | .name = "sync_file_range", | |
1336 | .posval = { | |
1337 | { .ival = "wait_before", | |
1338 | .oval = SYNC_FILE_RANGE_WAIT_BEFORE, | |
1339 | .help = "SYNC_FILE_RANGE_WAIT_BEFORE", | |
3843deb3 | 1340 | .or = 1, |
44f29692 JA |
1341 | }, |
1342 | { .ival = "write", | |
1343 | .oval = SYNC_FILE_RANGE_WRITE, | |
1344 | .help = "SYNC_FILE_RANGE_WRITE", | |
3843deb3 | 1345 | .or = 1, |
44f29692 JA |
1346 | }, |
1347 | { | |
1348 | .ival = "wait_after", | |
1349 | .oval = SYNC_FILE_RANGE_WAIT_AFTER, | |
1350 | .help = "SYNC_FILE_RANGE_WAIT_AFTER", | |
3843deb3 | 1351 | .or = 1, |
44f29692 JA |
1352 | }, |
1353 | }, | |
3843deb3 | 1354 | .type = FIO_OPT_STR_MULTI, |
44f29692 JA |
1355 | .cb = str_sfr_cb, |
1356 | .off1 = td_var_offset(sync_file_range), | |
1357 | .help = "Use sync_file_range()", | |
c9c63318 | 1358 | .category = FIO_OPT_G_FILE, |
44f29692 JA |
1359 | }, |
1360 | #endif | |
214e1eca JA |
1361 | { |
1362 | .name = "direct", | |
1363 | .type = FIO_OPT_BOOL, | |
1364 | .off1 = td_var_offset(odirect), | |
1365 | .help = "Use O_DIRECT IO (negates buffered)", | |
1366 | .def = "0", | |
c9c63318 | 1367 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1368 | }, |
1369 | { | |
1370 | .name = "buffered", | |
1371 | .type = FIO_OPT_BOOL, | |
1372 | .off1 = td_var_offset(odirect), | |
1373 | .neg = 1, | |
1374 | .help = "Use buffered IO (negates direct)", | |
1375 | .def = "1", | |
c9c63318 | 1376 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1377 | }, |
1378 | { | |
1379 | .name = "overwrite", | |
1380 | .type = FIO_OPT_BOOL, | |
1381 | .off1 = td_var_offset(overwrite), | |
1382 | .help = "When writing, set whether to overwrite current data", | |
1383 | .def = "0", | |
c9c63318 | 1384 | .category = FIO_OPT_G_IO | FIO_OPT_G_FILE, |
214e1eca JA |
1385 | }, |
1386 | { | |
1387 | .name = "loops", | |
1388 | .type = FIO_OPT_INT, | |
1389 | .off1 = td_var_offset(loops), | |
1390 | .help = "Number of times to run the job", | |
1391 | .def = "1", | |
c9c63318 | 1392 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1393 | }, |
1394 | { | |
1395 | .name = "numjobs", | |
1396 | .type = FIO_OPT_INT, | |
1397 | .off1 = td_var_offset(numjobs), | |
1398 | .help = "Duplicate this job this many times", | |
1399 | .def = "1", | |
c9c63318 | 1400 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1401 | }, |
1402 | { | |
1403 | .name = "startdelay", | |
a5737c93 | 1404 | .type = FIO_OPT_STR_VAL_TIME, |
214e1eca JA |
1405 | .off1 = td_var_offset(start_delay), |
1406 | .help = "Only start job when this period has passed", | |
1407 | .def = "0", | |
c9c63318 | 1408 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1409 | }, |
1410 | { | |
1411 | .name = "runtime", | |
1412 | .alias = "timeout", | |
1413 | .type = FIO_OPT_STR_VAL_TIME, | |
1414 | .off1 = td_var_offset(timeout), | |
1415 | .help = "Stop workload when this amount of time has passed", | |
1416 | .def = "0", | |
c9c63318 | 1417 | .category = FIO_OPT_G_MISC, |
214e1eca | 1418 | }, |
cf4464ca JA |
1419 | { |
1420 | .name = "time_based", | |
1421 | .type = FIO_OPT_STR_SET, | |
1422 | .off1 = td_var_offset(time_based), | |
1423 | .help = "Keep running until runtime/timeout is met", | |
c9c63318 | 1424 | .category = FIO_OPT_G_MISC, |
cf4464ca | 1425 | }, |
721938ae JA |
1426 | { |
1427 | .name = "ramp_time", | |
1428 | .type = FIO_OPT_STR_VAL_TIME, | |
1429 | .off1 = td_var_offset(ramp_time), | |
1430 | .help = "Ramp up time before measuring performance", | |
c9c63318 | 1431 | .category = FIO_OPT_G_MISC, |
721938ae | 1432 | }, |
c223da83 JA |
1433 | { |
1434 | .name = "clocksource", | |
1435 | .type = FIO_OPT_STR, | |
1436 | .cb = fio_clock_source_cb, | |
1437 | .off1 = td_var_offset(clocksource), | |
1438 | .help = "What type of timing source to use", | |
c9c63318 | 1439 | .category = FIO_OPT_G_OS, |
c223da83 JA |
1440 | .posval = { |
1441 | { .ival = "gettimeofday", | |
1442 | .oval = CS_GTOD, | |
1443 | .help = "Use gettimeofday(2) for timing", | |
1444 | }, | |
1445 | { .ival = "clock_gettime", | |
1446 | .oval = CS_CGETTIME, | |
1447 | .help = "Use clock_gettime(2) for timing", | |
1448 | }, | |
1449 | #ifdef ARCH_HAVE_CPU_CLOCK | |
1450 | { .ival = "cpu", | |
1451 | .oval = CS_CPUCLOCK, | |
1452 | .help = "Use CPU private clock", | |
1453 | }, | |
1454 | #endif | |
1455 | }, | |
1456 | }, | |
214e1eca JA |
1457 | { |
1458 | .name = "mem", | |
d3aad8f2 | 1459 | .alias = "iomem", |
214e1eca JA |
1460 | .type = FIO_OPT_STR, |
1461 | .cb = str_mem_cb, | |
1462 | .off1 = td_var_offset(mem_type), | |
1463 | .help = "Backing type for IO buffers", | |
1464 | .def = "malloc", | |
c9c63318 | 1465 | .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM, |
214e1eca JA |
1466 | .posval = { |
1467 | { .ival = "malloc", | |
1468 | .oval = MEM_MALLOC, | |
1469 | .help = "Use malloc(3) for IO buffers", | |
1470 | }, | |
37c8cdfe JA |
1471 | { .ival = "shm", |
1472 | .oval = MEM_SHM, | |
1473 | .help = "Use shared memory segments for IO buffers", | |
1474 | }, | |
214e1eca JA |
1475 | #ifdef FIO_HAVE_HUGETLB |
1476 | { .ival = "shmhuge", | |
1477 | .oval = MEM_SHMHUGE, | |
1478 | .help = "Like shm, but use huge pages", | |
1479 | }, | |
b370e46a | 1480 | #endif |
37c8cdfe JA |
1481 | { .ival = "mmap", |
1482 | .oval = MEM_MMAP, | |
1483 | .help = "Use mmap(2) (file or anon) for IO buffers", | |
1484 | }, | |
214e1eca JA |
1485 | #ifdef FIO_HAVE_HUGETLB |
1486 | { .ival = "mmaphuge", | |
1487 | .oval = MEM_MMAPHUGE, | |
1488 | .help = "Like mmap, but use huge pages", | |
1489 | }, | |
1490 | #endif | |
1491 | }, | |
1492 | }, | |
d529ee19 JA |
1493 | { |
1494 | .name = "iomem_align", | |
1495 | .alias = "mem_align", | |
1496 | .type = FIO_OPT_INT, | |
1497 | .off1 = td_var_offset(mem_align), | |
1498 | .minval = 0, | |
1499 | .help = "IO memory buffer offset alignment", | |
1500 | .def = "0", | |
1501 | .parent = "iomem", | |
c9c63318 | 1502 | .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM, |
d529ee19 | 1503 | }, |
214e1eca JA |
1504 | { |
1505 | .name = "verify", | |
1506 | .type = FIO_OPT_STR, | |
1507 | .off1 = td_var_offset(verify), | |
1508 | .help = "Verify data written", | |
5d7c5d34 | 1509 | .cb = str_verify_cb, |
214e1eca | 1510 | .def = "0", |
c9c63318 | 1511 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
214e1eca JA |
1512 | .posval = { |
1513 | { .ival = "0", | |
1514 | .oval = VERIFY_NONE, | |
1515 | .help = "Don't do IO verification", | |
1516 | }, | |
fcca4b58 JA |
1517 | { .ival = "md5", |
1518 | .oval = VERIFY_MD5, | |
1519 | .help = "Use md5 checksums for verification", | |
1520 | }, | |
d77a7af3 JA |
1521 | { .ival = "crc64", |
1522 | .oval = VERIFY_CRC64, | |
1523 | .help = "Use crc64 checksums for verification", | |
1524 | }, | |
214e1eca JA |
1525 | { .ival = "crc32", |
1526 | .oval = VERIFY_CRC32, | |
1527 | .help = "Use crc32 checksums for verification", | |
1528 | }, | |
af497e6a | 1529 | { .ival = "crc32c-intel", |
e3aaafc4 JA |
1530 | .oval = VERIFY_CRC32C, |
1531 | .help = "Use crc32c checksums for verification (hw assisted, if available)", | |
af497e6a | 1532 | }, |
bac39e0e JA |
1533 | { .ival = "crc32c", |
1534 | .oval = VERIFY_CRC32C, | |
e3aaafc4 | 1535 | .help = "Use crc32c checksums for verification (hw assisted, if available)", |
bac39e0e | 1536 | }, |
969f7ed3 JA |
1537 | { .ival = "crc16", |
1538 | .oval = VERIFY_CRC16, | |
1539 | .help = "Use crc16 checksums for verification", | |
1540 | }, | |
1e154bdb JA |
1541 | { .ival = "crc7", |
1542 | .oval = VERIFY_CRC7, | |
1543 | .help = "Use crc7 checksums for verification", | |
1544 | }, | |
7c353ceb JA |
1545 | { .ival = "sha1", |
1546 | .oval = VERIFY_SHA1, | |
1547 | .help = "Use sha1 checksums for verification", | |
1548 | }, | |
cd14cc10 JA |
1549 | { .ival = "sha256", |
1550 | .oval = VERIFY_SHA256, | |
1551 | .help = "Use sha256 checksums for verification", | |
1552 | }, | |
1553 | { .ival = "sha512", | |
1554 | .oval = VERIFY_SHA512, | |
1555 | .help = "Use sha512 checksums for verification", | |
1556 | }, | |
7437ee87 SL |
1557 | { .ival = "meta", |
1558 | .oval = VERIFY_META, | |
1559 | .help = "Use io information", | |
1560 | }, | |
36690c9b JA |
1561 | { |
1562 | .ival = "null", | |
1563 | .oval = VERIFY_NULL, | |
1564 | .help = "Pretend to verify", | |
1565 | }, | |
214e1eca JA |
1566 | }, |
1567 | }, | |
005c565a JA |
1568 | { |
1569 | .name = "do_verify", | |
68e1f29a | 1570 | .type = FIO_OPT_BOOL, |
005c565a JA |
1571 | .off1 = td_var_offset(do_verify), |
1572 | .help = "Run verification stage after write", | |
1573 | .def = "1", | |
1574 | .parent = "verify", | |
c9c63318 | 1575 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
005c565a | 1576 | }, |
160b966d JA |
1577 | { |
1578 | .name = "verifysort", | |
1579 | .type = FIO_OPT_BOOL, | |
1580 | .off1 = td_var_offset(verifysort), | |
1581 | .help = "Sort written verify blocks for read back", | |
1582 | .def = "1", | |
c83f2df1 | 1583 | .parent = "verify", |
c9c63318 | 1584 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
160b966d | 1585 | }, |
3f9f4e26 | 1586 | { |
a59e170d | 1587 | .name = "verify_interval", |
e01b22b8 | 1588 | .type = FIO_OPT_INT, |
a59e170d | 1589 | .off1 = td_var_offset(verify_interval), |
819a9680 | 1590 | .minval = 2 * sizeof(struct verify_header), |
a59e170d | 1591 | .help = "Store verify buffer header every N bytes", |
afdf9352 | 1592 | .parent = "verify", |
c9c63318 | 1593 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
3f9f4e26 | 1594 | }, |
546a9142 | 1595 | { |
a59e170d | 1596 | .name = "verify_offset", |
e01b22b8 | 1597 | .type = FIO_OPT_INT, |
a59e170d | 1598 | .help = "Offset verify header location by N bytes", |
546a9142 | 1599 | .def = "0", |
5ec10eaa | 1600 | .cb = str_verify_offset_cb, |
afdf9352 | 1601 | .parent = "verify", |
c9c63318 | 1602 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
546a9142 | 1603 | }, |
e28218f3 SL |
1604 | { |
1605 | .name = "verify_pattern", | |
0e92f873 | 1606 | .type = FIO_OPT_STR, |
e28218f3 SL |
1607 | .cb = str_verify_pattern_cb, |
1608 | .help = "Fill pattern for IO buffers", | |
1609 | .parent = "verify", | |
c9c63318 | 1610 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
e28218f3 | 1611 | }, |
a12a3b4d JA |
1612 | { |
1613 | .name = "verify_fatal", | |
68e1f29a | 1614 | .type = FIO_OPT_BOOL, |
a12a3b4d JA |
1615 | .off1 = td_var_offset(verify_fatal), |
1616 | .def = "0", | |
1617 | .help = "Exit on a single verify failure, don't continue", | |
1618 | .parent = "verify", | |
c9c63318 | 1619 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR, |
a12a3b4d | 1620 | }, |
b463e936 JA |
1621 | { |
1622 | .name = "verify_dump", | |
1623 | .type = FIO_OPT_BOOL, | |
1624 | .off1 = td_var_offset(verify_dump), | |
ef71e317 | 1625 | .def = "0", |
b463e936 JA |
1626 | .help = "Dump contents of good and bad blocks on failure", |
1627 | .parent = "verify", | |
c9c63318 | 1628 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR, |
b463e936 | 1629 | }, |
e8462bd8 JA |
1630 | { |
1631 | .name = "verify_async", | |
1632 | .type = FIO_OPT_INT, | |
1633 | .off1 = td_var_offset(verify_async), | |
1634 | .def = "0", | |
1635 | .help = "Number of async verifier threads to use", | |
1636 | .parent = "verify", | |
c9c63318 | 1637 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
e8462bd8 | 1638 | }, |
9e144189 JA |
1639 | { |
1640 | .name = "verify_backlog", | |
1641 | .type = FIO_OPT_STR_VAL, | |
1642 | .off1 = td_var_offset(verify_backlog), | |
1643 | .help = "Verify after this number of blocks are written", | |
1644 | .parent = "verify", | |
c9c63318 | 1645 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
9e144189 JA |
1646 | }, |
1647 | { | |
1648 | .name = "verify_backlog_batch", | |
1649 | .type = FIO_OPT_INT, | |
1650 | .off1 = td_var_offset(verify_batch), | |
1651 | .help = "Verify this number of IO blocks", | |
0d29de83 | 1652 | .parent = "verify", |
c9c63318 | 1653 | .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY, |
9e144189 | 1654 | }, |
e8462bd8 JA |
1655 | #ifdef FIO_HAVE_CPU_AFFINITY |
1656 | { | |
1657 | .name = "verify_async_cpus", | |
1658 | .type = FIO_OPT_STR, | |
1659 | .cb = str_verify_cpus_allowed_cb, | |
1660 | .help = "Set CPUs allowed for async verify threads", | |
1661 | .parent = "verify_async", | |
c9c63318 | 1662 | .category = FIO_OPT_G_OS | FIO_OPT_G_CPU | FIO_OPT_G_VERIFY, |
e8462bd8 | 1663 | }, |
0d29de83 JA |
1664 | #endif |
1665 | #ifdef FIO_HAVE_TRIM | |
1666 | { | |
1667 | .name = "trim_percentage", | |
1668 | .type = FIO_OPT_INT, | |
1669 | .cb = str_verify_trim_cb, | |
1670 | .maxval = 100, | |
1671 | .help = "Number of verify blocks to discard/trim", | |
1672 | .parent = "verify", | |
1673 | .def = "0", | |
c9c63318 | 1674 | .category = FIO_OPT_G_IO, |
0d29de83 JA |
1675 | }, |
1676 | { | |
1677 | .name = "trim_verify_zero", | |
1678 | .type = FIO_OPT_INT, | |
1679 | .help = "Verify that trim/discarded blocks are returned as zeroes", | |
1680 | .off1 = td_var_offset(trim_zero), | |
1681 | .parent = "trim_percentage", | |
1682 | .def = "1", | |
c9c63318 | 1683 | .category = FIO_OPT_G_IO, |
0d29de83 JA |
1684 | }, |
1685 | { | |
1686 | .name = "trim_backlog", | |
1687 | .type = FIO_OPT_STR_VAL, | |
1688 | .off1 = td_var_offset(trim_backlog), | |
1689 | .help = "Trim after this number of blocks are written", | |
1690 | .parent = "trim_percentage", | |
c9c63318 | 1691 | .category = FIO_OPT_G_IO, |
0d29de83 JA |
1692 | }, |
1693 | { | |
1694 | .name = "trim_backlog_batch", | |
1695 | .type = FIO_OPT_INT, | |
1696 | .off1 = td_var_offset(trim_batch), | |
1697 | .help = "Trim this number of IO blocks", | |
1698 | .parent = "trim_percentage", | |
c9c63318 | 1699 | .category = FIO_OPT_G_IO, |
0d29de83 | 1700 | }, |
e8462bd8 | 1701 | #endif |
214e1eca JA |
1702 | { |
1703 | .name = "write_iolog", | |
1704 | .type = FIO_OPT_STR_STORE, | |
1705 | .off1 = td_var_offset(write_iolog_file), | |
1706 | .help = "Store IO pattern to file", | |
c9c63318 | 1707 | .category = FIO_OPT_G_IO | FIO_OPT_G_LOG, |
214e1eca JA |
1708 | }, |
1709 | { | |
1710 | .name = "read_iolog", | |
1711 | .type = FIO_OPT_STR_STORE, | |
1712 | .off1 = td_var_offset(read_iolog_file), | |
1713 | .help = "Playback IO pattern from file", | |
c9c63318 | 1714 | .category = FIO_OPT_G_IO | FIO_OPT_G_LOG, |
214e1eca | 1715 | }, |
64bbb865 DN |
1716 | { |
1717 | .name = "replay_no_stall", | |
1718 | .type = FIO_OPT_INT, | |
1719 | .off1 = td_var_offset(no_stall), | |
1720 | .def = "0", | |
87e7a972 | 1721 | .parent = "read_iolog", |
64bbb865 | 1722 | .help = "Playback IO pattern file as fast as possible without stalls", |
c9c63318 | 1723 | .category = FIO_OPT_G_IO | FIO_OPT_G_LOG, |
64bbb865 | 1724 | }, |
d1c46c04 DN |
1725 | { |
1726 | .name = "replay_redirect", | |
1727 | .type = FIO_OPT_STR_STORE, | |
1728 | .off1 = td_var_offset(replay_redirect), | |
1729 | .parent = "read_iolog", | |
1730 | .help = "Replay all I/O onto this device, regardless of trace device", | |
c9c63318 | 1731 | .category = FIO_OPT_G_IO | FIO_OPT_G_LOG, |
d1c46c04 | 1732 | }, |
214e1eca JA |
1733 | { |
1734 | .name = "exec_prerun", | |
1735 | .type = FIO_OPT_STR_STORE, | |
1736 | .off1 = td_var_offset(exec_prerun), | |
1737 | .help = "Execute this file prior to running job", | |
c9c63318 | 1738 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS, |
214e1eca JA |
1739 | }, |
1740 | { | |
1741 | .name = "exec_postrun", | |
1742 | .type = FIO_OPT_STR_STORE, | |
1743 | .off1 = td_var_offset(exec_postrun), | |
1744 | .help = "Execute this file after running job", | |
c9c63318 | 1745 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS, |
214e1eca JA |
1746 | }, |
1747 | #ifdef FIO_HAVE_IOSCHED_SWITCH | |
1748 | { | |
1749 | .name = "ioscheduler", | |
1750 | .type = FIO_OPT_STR_STORE, | |
1751 | .off1 = td_var_offset(ioscheduler), | |
1752 | .help = "Use this IO scheduler on the backing device", | |
c9c63318 | 1753 | .category = FIO_OPT_G_OS | FIO_OPT_G_IO, |
214e1eca JA |
1754 | }, |
1755 | #endif | |
1756 | { | |
1757 | .name = "zonesize", | |
1758 | .type = FIO_OPT_STR_VAL, | |
1759 | .off1 = td_var_offset(zone_size), | |
ed335855 SN |
1760 | .help = "Amount of data to read per zone", |
1761 | .def = "0", | |
c9c63318 | 1762 | .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE, |
ed335855 SN |
1763 | }, |
1764 | { | |
1765 | .name = "zonerange", | |
1766 | .type = FIO_OPT_STR_VAL, | |
1767 | .off1 = td_var_offset(zone_range), | |
214e1eca JA |
1768 | .help = "Give size of an IO zone", |
1769 | .def = "0", | |
c9c63318 | 1770 | .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE, |
214e1eca JA |
1771 | }, |
1772 | { | |
1773 | .name = "zoneskip", | |
1774 | .type = FIO_OPT_STR_VAL, | |
1775 | .off1 = td_var_offset(zone_skip), | |
1776 | .help = "Space between IO zones", | |
1777 | .def = "0", | |
c9c63318 | 1778 | .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE, |
214e1eca JA |
1779 | }, |
1780 | { | |
1781 | .name = "lockmem", | |
1782 | .type = FIO_OPT_STR_VAL, | |
1783 | .cb = str_lockmem_cb, | |
1784 | .help = "Lock down this amount of memory", | |
1785 | .def = "0", | |
c9c63318 | 1786 | .category = FIO_OPT_G_OS | FIO_OPT_G_MEM, |
214e1eca | 1787 | }, |
214e1eca JA |
1788 | { |
1789 | .name = "rwmixread", | |
1790 | .type = FIO_OPT_INT, | |
cb499fc4 | 1791 | .cb = str_rwmix_read_cb, |
214e1eca JA |
1792 | .maxval = 100, |
1793 | .help = "Percentage of mixed workload that is reads", | |
1794 | .def = "50", | |
c9c63318 | 1795 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1796 | }, |
1797 | { | |
1798 | .name = "rwmixwrite", | |
1799 | .type = FIO_OPT_INT, | |
cb499fc4 | 1800 | .cb = str_rwmix_write_cb, |
214e1eca JA |
1801 | .maxval = 100, |
1802 | .help = "Percentage of mixed workload that is writes", | |
1803 | .def = "50", | |
c9c63318 | 1804 | .category = FIO_OPT_G_IO, |
214e1eca | 1805 | }, |
afdf9352 JA |
1806 | { |
1807 | .name = "rwmixcycle", | |
15ca150e | 1808 | .type = FIO_OPT_DEPRECATED, |
c9c63318 | 1809 | .category = FIO_OPT_G_IO, |
afdf9352 | 1810 | }, |
214e1eca JA |
1811 | { |
1812 | .name = "nice", | |
1813 | .type = FIO_OPT_INT, | |
1814 | .off1 = td_var_offset(nice), | |
1815 | .help = "Set job CPU nice value", | |
1816 | .minval = -19, | |
1817 | .maxval = 20, | |
1818 | .def = "0", | |
c9c63318 | 1819 | .category = FIO_OPT_G_OS | FIO_OPT_G_CPU, |
214e1eca JA |
1820 | }, |
1821 | #ifdef FIO_HAVE_IOPRIO | |
1822 | { | |
1823 | .name = "prio", | |
1824 | .type = FIO_OPT_INT, | |
1825 | .cb = str_prio_cb, | |
1826 | .help = "Set job IO priority value", | |
1827 | .minval = 0, | |
1828 | .maxval = 7, | |
c9c63318 | 1829 | .category = FIO_OPT_G_OS | FIO_OPT_G_CPU, |
214e1eca JA |
1830 | }, |
1831 | { | |
1832 | .name = "prioclass", | |
1833 | .type = FIO_OPT_INT, | |
1834 | .cb = str_prioclass_cb, | |
1835 | .help = "Set job IO priority class", | |
1836 | .minval = 0, | |
1837 | .maxval = 3, | |
c9c63318 | 1838 | .category = FIO_OPT_G_OS | FIO_OPT_G_CPU, |
214e1eca JA |
1839 | }, |
1840 | #endif | |
1841 | { | |
1842 | .name = "thinktime", | |
1843 | .type = FIO_OPT_INT, | |
1844 | .off1 = td_var_offset(thinktime), | |
1845 | .help = "Idle time between IO buffers (usec)", | |
1846 | .def = "0", | |
c9c63318 | 1847 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1848 | }, |
1849 | { | |
1850 | .name = "thinktime_spin", | |
1851 | .type = FIO_OPT_INT, | |
1852 | .off1 = td_var_offset(thinktime_spin), | |
1853 | .help = "Start think time by spinning this amount (usec)", | |
1854 | .def = "0", | |
afdf9352 | 1855 | .parent = "thinktime", |
c9c63318 | 1856 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1857 | }, |
1858 | { | |
1859 | .name = "thinktime_blocks", | |
1860 | .type = FIO_OPT_INT, | |
1861 | .off1 = td_var_offset(thinktime_blocks), | |
1862 | .help = "IO buffer period between 'thinktime'", | |
1863 | .def = "1", | |
afdf9352 | 1864 | .parent = "thinktime", |
c9c63318 | 1865 | .category = FIO_OPT_G_MISC, |
214e1eca JA |
1866 | }, |
1867 | { | |
1868 | .name = "rate", | |
e01b22b8 | 1869 | .type = FIO_OPT_INT, |
581e7141 JA |
1870 | .off1 = td_var_offset(rate[0]), |
1871 | .off2 = td_var_offset(rate[1]), | |
214e1eca | 1872 | .help = "Set bandwidth rate", |
c9c63318 | 1873 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1874 | }, |
1875 | { | |
1876 | .name = "ratemin", | |
e01b22b8 | 1877 | .type = FIO_OPT_INT, |
581e7141 JA |
1878 | .off1 = td_var_offset(ratemin[0]), |
1879 | .off2 = td_var_offset(ratemin[1]), | |
4e991c23 | 1880 | .help = "Job must meet this rate or it will be shutdown", |
afdf9352 | 1881 | .parent = "rate", |
c9c63318 | 1882 | .category = FIO_OPT_G_IO, |
4e991c23 JA |
1883 | }, |
1884 | { | |
1885 | .name = "rate_iops", | |
e01b22b8 | 1886 | .type = FIO_OPT_INT, |
581e7141 JA |
1887 | .off1 = td_var_offset(rate_iops[0]), |
1888 | .off2 = td_var_offset(rate_iops[1]), | |
4e991c23 | 1889 | .help = "Limit IO used to this number of IO operations/sec", |
c9c63318 | 1890 | .category = FIO_OPT_G_IO, |
4e991c23 JA |
1891 | }, |
1892 | { | |
1893 | .name = "rate_iops_min", | |
e01b22b8 | 1894 | .type = FIO_OPT_INT, |
581e7141 JA |
1895 | .off1 = td_var_offset(rate_iops_min[0]), |
1896 | .off2 = td_var_offset(rate_iops_min[1]), | |
03e20d68 | 1897 | .help = "Job must meet this rate or it will be shut down", |
afdf9352 | 1898 | .parent = "rate_iops", |
c9c63318 | 1899 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1900 | }, |
1901 | { | |
1902 | .name = "ratecycle", | |
1903 | .type = FIO_OPT_INT, | |
1904 | .off1 = td_var_offset(ratecycle), | |
1905 | .help = "Window average for rate limits (msec)", | |
1906 | .def = "1000", | |
afdf9352 | 1907 | .parent = "rate", |
c9c63318 | 1908 | .category = FIO_OPT_G_IO, |
214e1eca JA |
1909 | }, |
1910 | { | |
1911 | .name = "invalidate", | |
1912 | .type = FIO_OPT_BOOL, | |
1913 | .off1 = td_var_offset(invalidate_cache), | |
1914 | .help = "Invalidate buffer/page cache prior to running job", | |
1915 | .def = "1", | |
c9c63318 | 1916 | .category = FIO_OPT_G_IO | FIO_OPT_G_CACHE, |
214e1eca JA |
1917 | }, |
1918 | { | |
1919 | .name = "sync", | |
1920 | .type = FIO_OPT_BOOL, | |
1921 | .off1 = td_var_offset(sync_io), | |
1922 | .help = "Use O_SYNC for buffered writes", | |
1923 | .def = "0", | |
67a1000f | 1924 | .parent = "buffered", |
c9c63318 | 1925 | .category = FIO_OPT_G_IO | FIO_OPT_G_FILE, |
214e1eca JA |
1926 | }, |
1927 | { | |
1928 | .name = "bwavgtime", | |
1929 | .type = FIO_OPT_INT, | |
1930 | .off1 = td_var_offset(bw_avg_time), | |
5ec10eaa JA |
1931 | .help = "Time window over which to calculate bandwidth" |
1932 | " (msec)", | |
214e1eca | 1933 | .def = "500", |
c8eeb9df | 1934 | .parent = "write_bw_log", |
c9c63318 | 1935 | .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT, |
c8eeb9df JA |
1936 | }, |
1937 | { | |
1938 | .name = "iopsavgtime", | |
1939 | .type = FIO_OPT_INT, | |
1940 | .off1 = td_var_offset(iops_avg_time), | |
1941 | .help = "Time window over which to calculate IOPS (msec)", | |
1942 | .def = "500", | |
1943 | .parent = "write_iops_log", | |
c9c63318 | 1944 | .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT, |
214e1eca JA |
1945 | }, |
1946 | { | |
1947 | .name = "create_serialize", | |
1948 | .type = FIO_OPT_BOOL, | |
1949 | .off1 = td_var_offset(create_serialize), | |
1950 | .help = "Serialize creating of job files", | |
1951 | .def = "1", | |
c9c63318 | 1952 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
1953 | }, |
1954 | { | |
1955 | .name = "create_fsync", | |
1956 | .type = FIO_OPT_BOOL, | |
1957 | .off1 = td_var_offset(create_fsync), | |
03e20d68 | 1958 | .help = "fsync file after creation", |
214e1eca | 1959 | .def = "1", |
c9c63318 | 1960 | .category = FIO_OPT_G_FILE, |
214e1eca | 1961 | }, |
814452bd JA |
1962 | { |
1963 | .name = "create_on_open", | |
1964 | .type = FIO_OPT_BOOL, | |
1965 | .off1 = td_var_offset(create_on_open), | |
1966 | .help = "Create files when they are opened for IO", | |
1967 | .def = "0", | |
c9c63318 | 1968 | .category = FIO_OPT_G_FILE, |
814452bd | 1969 | }, |
0b9d69ec | 1970 | { |
afad68f7 ZY |
1971 | .name = "pre_read", |
1972 | .type = FIO_OPT_BOOL, | |
1973 | .off1 = td_var_offset(pre_read), | |
03e20d68 | 1974 | .help = "Pre-read files before starting official testing", |
afad68f7 | 1975 | .def = "0", |
c9c63318 | 1976 | .category = FIO_OPT_G_FILE | FIO_OPT_G_CACHE, |
afad68f7 | 1977 | }, |
214e1eca JA |
1978 | { |
1979 | .name = "cpuload", | |
1980 | .type = FIO_OPT_INT, | |
1981 | .off1 = td_var_offset(cpuload), | |
1982 | .help = "Use this percentage of CPU", | |
c9c63318 | 1983 | .category = FIO_OPT_G_CPU, |
214e1eca JA |
1984 | }, |
1985 | { | |
1986 | .name = "cpuchunks", | |
1987 | .type = FIO_OPT_INT, | |
1988 | .off1 = td_var_offset(cpucycle), | |
1989 | .help = "Length of the CPU burn cycles (usecs)", | |
1990 | .def = "50000", | |
67a1000f | 1991 | .parent = "cpuload", |
c9c63318 | 1992 | .category = FIO_OPT_G_CPU, |
214e1eca JA |
1993 | }, |
1994 | #ifdef FIO_HAVE_CPU_AFFINITY | |
1995 | { | |
1996 | .name = "cpumask", | |
1997 | .type = FIO_OPT_INT, | |
1998 | .cb = str_cpumask_cb, | |
1999 | .help = "CPU affinity mask", | |
c9c63318 | 2000 | .category = FIO_OPT_G_CPU | FIO_OPT_G_OS, |
214e1eca | 2001 | }, |
d2e268b0 JA |
2002 | { |
2003 | .name = "cpus_allowed", | |
2004 | .type = FIO_OPT_STR, | |
2005 | .cb = str_cpus_allowed_cb, | |
2006 | .help = "Set CPUs allowed", | |
c9c63318 | 2007 | .category = FIO_OPT_G_CPU | FIO_OPT_G_OS, |
d2e268b0 | 2008 | }, |
214e1eca JA |
2009 | #endif |
2010 | { | |
2011 | .name = "end_fsync", | |
2012 | .type = FIO_OPT_BOOL, | |
2013 | .off1 = td_var_offset(end_fsync), | |
2014 | .help = "Include fsync at the end of job", | |
2015 | .def = "0", | |
c9c63318 | 2016 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
2017 | }, |
2018 | { | |
2019 | .name = "fsync_on_close", | |
2020 | .type = FIO_OPT_BOOL, | |
2021 | .off1 = td_var_offset(fsync_on_close), | |
2022 | .help = "fsync files on close", | |
2023 | .def = "0", | |
c9c63318 | 2024 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
2025 | }, |
2026 | { | |
2027 | .name = "unlink", | |
2028 | .type = FIO_OPT_BOOL, | |
2029 | .off1 = td_var_offset(unlink), | |
2030 | .help = "Unlink created files after job has completed", | |
2031 | .def = "0", | |
c9c63318 | 2032 | .category = FIO_OPT_G_FILE, |
214e1eca JA |
2033 | }, |
2034 | { | |
2035 | .name = "exitall", | |
2036 | .type = FIO_OPT_STR_SET, | |
2037 | .cb = str_exitall_cb, | |
2038 | .help = "Terminate all jobs when one exits", | |
c9c63318 | 2039 | .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB, |
214e1eca JA |
2040 | }, |
2041 | { | |
2042 | .name = "stonewall", | |
d392365e | 2043 | .alias = "wait_for_previous", |
214e1eca JA |
2044 | .type = FIO_OPT_STR_SET, |
2045 | .off1 = td_var_offset(stonewall), | |
2046 | .help = "Insert a hard barrier between this job and previous", | |
c9c63318 | 2047 | .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB, |
214e1eca | 2048 | }, |
b3d62a75 JA |
2049 | { |
2050 | .name = "new_group", | |
2051 | .type = FIO_OPT_STR_SET, | |
2052 | .off1 = td_var_offset(new_group), | |
2053 | .help = "Mark the start of a new group (for reporting)", | |
c9c63318 | 2054 | .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB, |
b3d62a75 | 2055 | }, |
214e1eca JA |
2056 | { |
2057 | .name = "thread", | |
2058 | .type = FIO_OPT_STR_SET, | |
2059 | .off1 = td_var_offset(use_thread), | |
2060 | .help = "Use threads instead of forks", | |
c9c63318 | 2061 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS | FIO_OPT_G_JOB, |
214e1eca JA |
2062 | }, |
2063 | { | |
2064 | .name = "write_bw_log", | |
e3cedca7 | 2065 | .type = FIO_OPT_STR, |
214e1eca | 2066 | .off1 = td_var_offset(write_bw_log), |
e3cedca7 | 2067 | .cb = str_write_bw_log_cb, |
214e1eca | 2068 | .help = "Write log of bandwidth during run", |
c9c63318 | 2069 | .category = FIO_OPT_G_LOG, |
214e1eca JA |
2070 | }, |
2071 | { | |
2072 | .name = "write_lat_log", | |
e3cedca7 | 2073 | .type = FIO_OPT_STR, |
214e1eca | 2074 | .off1 = td_var_offset(write_lat_log), |
e3cedca7 | 2075 | .cb = str_write_lat_log_cb, |
214e1eca | 2076 | .help = "Write log of latency during run", |
c9c63318 | 2077 | .category = FIO_OPT_G_LOG, |
214e1eca | 2078 | }, |
c8eeb9df JA |
2079 | { |
2080 | .name = "write_iops_log", | |
2081 | .type = FIO_OPT_STR, | |
2082 | .off1 = td_var_offset(write_iops_log), | |
2083 | .cb = str_write_iops_log_cb, | |
2084 | .help = "Write log of IOPS during run", | |
c9c63318 | 2085 | .category = FIO_OPT_G_LOG, |
c8eeb9df | 2086 | }, |
b8bc8cba JA |
2087 | { |
2088 | .name = "log_avg_msec", | |
2089 | .type = FIO_OPT_INT, | |
2090 | .off1 = td_var_offset(log_avg_msec), | |
2091 | .help = "Average bw/iops/lat logs over this period of time", | |
2092 | .def = "0", | |
c9c63318 | 2093 | .category = FIO_OPT_G_LOG, |
b8bc8cba | 2094 | }, |
214e1eca JA |
2095 | { |
2096 | .name = "hugepage-size", | |
e01b22b8 | 2097 | .type = FIO_OPT_INT, |
214e1eca JA |
2098 | .off1 = td_var_offset(hugepage_size), |
2099 | .help = "When using hugepages, specify size of each page", | |
81179eec | 2100 | .def = __fio_stringify(FIO_HUGE_PAGE), |
c9c63318 | 2101 | .category = FIO_OPT_G_OS | FIO_OPT_G_MEM, |
214e1eca JA |
2102 | }, |
2103 | { | |
2104 | .name = "group_reporting", | |
2105 | .type = FIO_OPT_STR_SET, | |
2106 | .off1 = td_var_offset(group_reporting), | |
2107 | .help = "Do reporting on a per-group basis", | |
c9c63318 | 2108 | .category = FIO_OPT_G_MISC, |
214e1eca | 2109 | }, |
e9459e5a JA |
2110 | { |
2111 | .name = "zero_buffers", | |
2112 | .type = FIO_OPT_STR_SET, | |
2113 | .off1 = td_var_offset(zero_buffers), | |
2114 | .help = "Init IO buffers to all zeroes", | |
c9c63318 | 2115 | .category = FIO_OPT_G_IO_BUF, |
e9459e5a | 2116 | }, |
5973cafb JA |
2117 | { |
2118 | .name = "refill_buffers", | |
2119 | .type = FIO_OPT_STR_SET, | |
2120 | .off1 = td_var_offset(refill_buffers), | |
2121 | .help = "Refill IO buffers on every IO submit", | |
c9c63318 | 2122 | .category = FIO_OPT_G_IO_BUF, |
5973cafb | 2123 | }, |
fd68418e JA |
2124 | { |
2125 | .name = "scramble_buffers", | |
2126 | .type = FIO_OPT_BOOL, | |
2127 | .off1 = td_var_offset(scramble_buffers), | |
2128 | .help = "Slightly scramble buffers on every IO submit", | |
2129 | .def = "1", | |
c9c63318 | 2130 | .category = FIO_OPT_G_IO_BUF, |
fd68418e | 2131 | }, |
9c42684e JA |
2132 | { |
2133 | .name = "buffer_compress_percentage", | |
2134 | .type = FIO_OPT_INT, | |
2135 | .off1 = td_var_offset(compress_percentage), | |
2136 | .maxval = 100, | |
2137 | .minval = 1, | |
2138 | .help = "How compressible the buffer is (approximately)", | |
2139 | }, | |
f97a43a1 JA |
2140 | { |
2141 | .name = "buffer_compress_chunk", | |
2142 | .type = FIO_OPT_INT, | |
2143 | .off1 = td_var_offset(compress_chunk), | |
207b18e4 | 2144 | .parent = "buffer_compress_percentage", |
f97a43a1 JA |
2145 | .help = "Size of compressible region in buffer", |
2146 | }, | |
83349190 YH |
2147 | { |
2148 | .name = "clat_percentiles", | |
2149 | .type = FIO_OPT_BOOL, | |
2150 | .off1 = td_var_offset(clat_percentiles), | |
2151 | .help = "Enable the reporting of completion latency percentiles", | |
467b35ed | 2152 | .def = "1", |
c9c63318 | 2153 | .category = FIO_OPT_G_STAT, |
83349190 YH |
2154 | }, |
2155 | { | |
2156 | .name = "percentile_list", | |
2157 | .type = FIO_OPT_FLOAT_LIST, | |
2158 | .off1 = td_var_offset(percentile_list), | |
2159 | .off2 = td_var_offset(overwrite_plist), | |
2160 | .help = "Specify a custom list of percentiles to report", | |
2161 | .maxlen = FIO_IO_U_LIST_MAX_LEN, | |
2162 | .minfp = 0.0, | |
2163 | .maxfp = 100.0, | |
c9c63318 | 2164 | .category = FIO_OPT_G_STAT, |
83349190 YH |
2165 | }, |
2166 | ||
0a839f30 JA |
2167 | #ifdef FIO_HAVE_DISK_UTIL |
2168 | { | |
2169 | .name = "disk_util", | |
2170 | .type = FIO_OPT_BOOL, | |
2171 | .off1 = td_var_offset(do_disk_util), | |
f66ab3c8 | 2172 | .help = "Log disk utilization statistics", |
0a839f30 | 2173 | .def = "1", |
c9c63318 | 2174 | .category = FIO_OPT_G_OS | FIO_OPT_G_STAT, |
0a839f30 JA |
2175 | }, |
2176 | #endif | |
993bf48b JA |
2177 | { |
2178 | .name = "gtod_reduce", | |
2179 | .type = FIO_OPT_BOOL, | |
2180 | .help = "Greatly reduce number of gettimeofday() calls", | |
2181 | .cb = str_gtod_reduce_cb, | |
2182 | .def = "0", | |
c9c63318 | 2183 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
993bf48b | 2184 | }, |
02af0988 JA |
2185 | { |
2186 | .name = "disable_lat", | |
2187 | .type = FIO_OPT_BOOL, | |
2188 | .off1 = td_var_offset(disable_lat), | |
2189 | .help = "Disable latency numbers", | |
2190 | .parent = "gtod_reduce", | |
2191 | .def = "0", | |
c9c63318 | 2192 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
02af0988 | 2193 | }, |
9520ebb9 JA |
2194 | { |
2195 | .name = "disable_clat", | |
2196 | .type = FIO_OPT_BOOL, | |
2197 | .off1 = td_var_offset(disable_clat), | |
2198 | .help = "Disable completion latency numbers", | |
993bf48b | 2199 | .parent = "gtod_reduce", |
9520ebb9 | 2200 | .def = "0", |
c9c63318 | 2201 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
9520ebb9 JA |
2202 | }, |
2203 | { | |
2204 | .name = "disable_slat", | |
2205 | .type = FIO_OPT_BOOL, | |
2206 | .off1 = td_var_offset(disable_slat), | |
03e20d68 | 2207 | .help = "Disable submission latency numbers", |
993bf48b | 2208 | .parent = "gtod_reduce", |
9520ebb9 | 2209 | .def = "0", |
c9c63318 | 2210 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
9520ebb9 JA |
2211 | }, |
2212 | { | |
2213 | .name = "disable_bw_measurement", | |
2214 | .type = FIO_OPT_BOOL, | |
2215 | .off1 = td_var_offset(disable_bw), | |
2216 | .help = "Disable bandwidth logging", | |
993bf48b | 2217 | .parent = "gtod_reduce", |
9520ebb9 | 2218 | .def = "0", |
c9c63318 | 2219 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
9520ebb9 | 2220 | }, |
be4ecfdf JA |
2221 | { |
2222 | .name = "gtod_cpu", | |
2223 | .type = FIO_OPT_INT, | |
2224 | .cb = str_gtod_cpu_cb, | |
03e20d68 | 2225 | .help = "Set up dedicated gettimeofday() thread on this CPU", |
29d43ff9 | 2226 | .verify = gtod_cpu_verify, |
c9c63318 | 2227 | .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT, |
be4ecfdf | 2228 | }, |
f2bba182 RR |
2229 | { |
2230 | .name = "continue_on_error", | |
06842027 | 2231 | .type = FIO_OPT_STR, |
f2bba182 | 2232 | .off1 = td_var_offset(continue_on_error), |
03e20d68 | 2233 | .help = "Continue on non-fatal errors during IO", |
06842027 | 2234 | .def = "none", |
c9c63318 | 2235 | .category = FIO_OPT_G_MISC | FIO_OPT_G_ERR, |
06842027 SL |
2236 | .posval = { |
2237 | { .ival = "none", | |
2238 | .oval = ERROR_TYPE_NONE, | |
2239 | .help = "Exit when an error is encountered", | |
2240 | }, | |
2241 | { .ival = "read", | |
2242 | .oval = ERROR_TYPE_READ, | |
2243 | .help = "Continue on read errors only", | |
2244 | }, | |
2245 | { .ival = "write", | |
2246 | .oval = ERROR_TYPE_WRITE, | |
2247 | .help = "Continue on write errors only", | |
2248 | }, | |
2249 | { .ival = "io", | |
2250 | .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE, | |
2251 | .help = "Continue on any IO errors", | |
2252 | }, | |
2253 | { .ival = "verify", | |
2254 | .oval = ERROR_TYPE_VERIFY, | |
2255 | .help = "Continue on verify errors only", | |
2256 | }, | |
2257 | { .ival = "all", | |
2258 | .oval = ERROR_TYPE_ANY, | |
2259 | .help = "Continue on all io and verify errors", | |
2260 | }, | |
2261 | { .ival = "0", | |
2262 | .oval = ERROR_TYPE_NONE, | |
2263 | .help = "Alias for 'none'", | |
2264 | }, | |
2265 | { .ival = "1", | |
2266 | .oval = ERROR_TYPE_ANY, | |
2267 | .help = "Alias for 'all'", | |
2268 | }, | |
2269 | }, | |
f2bba182 | 2270 | }, |
9ac8a797 JA |
2271 | { |
2272 | .name = "profile", | |
79d16311 | 2273 | .type = FIO_OPT_STR_STORE, |
9ac8a797 | 2274 | .off1 = td_var_offset(profile), |
9ac8a797 | 2275 | .help = "Select a specific builtin performance test", |
c9c63318 | 2276 | .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB, |
9ac8a797 | 2277 | }, |
a696fa2a JA |
2278 | { |
2279 | .name = "cgroup", | |
2280 | .type = FIO_OPT_STR_STORE, | |
2281 | .off1 = td_var_offset(cgroup), | |
2282 | .help = "Add job to cgroup of this name", | |
c9c63318 | 2283 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS, |
a696fa2a JA |
2284 | }, |
2285 | { | |
2286 | .name = "cgroup_weight", | |
2287 | .type = FIO_OPT_INT, | |
2288 | .off1 = td_var_offset(cgroup_weight), | |
2289 | .help = "Use given weight for cgroup", | |
2290 | .minval = 100, | |
2291 | .maxval = 1000, | |
c9c63318 | 2292 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS, |
a696fa2a | 2293 | }, |
7de87099 VG |
2294 | { |
2295 | .name = "cgroup_nodelete", | |
2296 | .type = FIO_OPT_BOOL, | |
2297 | .off1 = td_var_offset(cgroup_nodelete), | |
2298 | .help = "Do not delete cgroups after job completion", | |
2299 | .def = "0", | |
c9c63318 | 2300 | .category = FIO_OPT_G_MISC | FIO_OPT_G_OS, |
7de87099 | 2301 | }, |
e0b0d892 JA |
2302 | { |
2303 | .name = "uid", | |
2304 | .type = FIO_OPT_INT, | |
2305 | .off1 = td_var_offset(uid), | |
2306 | .help = "Run job with this user ID", | |
c9c63318 | 2307 | .category = FIO_OPT_G_OS | FIO_OPT_G_JOB, |
e0b0d892 JA |
2308 | }, |
2309 | { | |
2310 | .name = "gid", | |
2311 | .type = FIO_OPT_INT, | |
2312 | .off1 = td_var_offset(gid), | |
2313 | .help = "Run job with this group ID", | |
c9c63318 | 2314 | .category = FIO_OPT_G_OS | FIO_OPT_G_JOB, |
e0b0d892 | 2315 | }, |
9e684a49 DE |
2316 | { |
2317 | .name = "flow_id", | |
2318 | .type = FIO_OPT_INT, | |
2319 | .off1 = td_var_offset(flow_id), | |
2320 | .help = "The flow index ID to use", | |
2321 | .def = "0", | |
c9c63318 | 2322 | .category = FIO_OPT_G_IO, |
9e684a49 DE |
2323 | }, |
2324 | { | |
2325 | .name = "flow", | |
2326 | .type = FIO_OPT_INT, | |
2327 | .off1 = td_var_offset(flow), | |
2328 | .help = "Weight for flow control of this job", | |
2329 | .parent = "flow_id", | |
2330 | .def = "0", | |
c9c63318 | 2331 | .category = FIO_OPT_G_IO, |
9e684a49 DE |
2332 | }, |
2333 | { | |
2334 | .name = "flow_watermark", | |
2335 | .type = FIO_OPT_INT, | |
2336 | .off1 = td_var_offset(flow_watermark), | |
2337 | .help = "High watermark for flow control. This option" | |
2338 | " should be set to the same value for all threads" | |
2339 | " with non-zero flow.", | |
2340 | .parent = "flow_id", | |
2341 | .def = "1024", | |
c9c63318 | 2342 | .category = FIO_OPT_G_IO, |
9e684a49 DE |
2343 | }, |
2344 | { | |
2345 | .name = "flow_sleep", | |
2346 | .type = FIO_OPT_INT, | |
2347 | .off1 = td_var_offset(flow_sleep), | |
2348 | .help = "How many microseconds to sleep after being held" | |
2349 | " back by the flow control mechanism", | |
2350 | .parent = "flow_id", | |
2351 | .def = "0", | |
c9c63318 | 2352 | .category = FIO_OPT_G_IO, |
9e684a49 | 2353 | }, |
214e1eca JA |
2354 | { |
2355 | .name = NULL, | |
2356 | }, | |
2357 | }; | |
2358 | ||
17af15d4 | 2359 | static void add_to_lopt(struct option *lopt, struct fio_option *o, |
de890a1e | 2360 | const char *name, int val) |
9f81736c | 2361 | { |
17af15d4 | 2362 | lopt->name = (char *) name; |
de890a1e | 2363 | lopt->val = val; |
9f81736c JA |
2364 | if (o->type == FIO_OPT_STR_SET) |
2365 | lopt->has_arg = no_argument; | |
2366 | else | |
2367 | lopt->has_arg = required_argument; | |
2368 | } | |
2369 | ||
de890a1e SL |
2370 | static void options_to_lopts(struct fio_option *opts, |
2371 | struct option *long_options, | |
2372 | int i, int option_type) | |
214e1eca | 2373 | { |
de890a1e | 2374 | struct fio_option *o = &opts[0]; |
214e1eca | 2375 | while (o->name) { |
de890a1e | 2376 | add_to_lopt(&long_options[i], o, o->name, option_type); |
17af15d4 JA |
2377 | if (o->alias) { |
2378 | i++; | |
de890a1e | 2379 | add_to_lopt(&long_options[i], o, o->alias, option_type); |
17af15d4 | 2380 | } |
214e1eca JA |
2381 | |
2382 | i++; | |
2383 | o++; | |
2384 | assert(i < FIO_NR_OPTIONS); | |
2385 | } | |
2386 | } | |
2387 | ||
de890a1e SL |
2388 | void fio_options_set_ioengine_opts(struct option *long_options, |
2389 | struct thread_data *td) | |
2390 | { | |
2391 | unsigned int i; | |
2392 | ||
2393 | i = 0; | |
2394 | while (long_options[i].name) { | |
2395 | if (long_options[i].val == FIO_GETOPT_IOENGINE) { | |
2396 | memset(&long_options[i], 0, sizeof(*long_options)); | |
2397 | break; | |
2398 | } | |
2399 | i++; | |
2400 | } | |
2401 | ||
2402 | /* | |
2403 | * Just clear out the prior ioengine options. | |
2404 | */ | |
2405 | if (!td || !td->eo) | |
2406 | return; | |
2407 | ||
2408 | options_to_lopts(td->io_ops->options, long_options, i, | |
2409 | FIO_GETOPT_IOENGINE); | |
2410 | } | |
2411 | ||
2412 | void fio_options_dup_and_init(struct option *long_options) | |
2413 | { | |
2414 | unsigned int i; | |
2415 | ||
2416 | options_init(options); | |
2417 | ||
2418 | i = 0; | |
2419 | while (long_options[i].name) | |
2420 | i++; | |
2421 | ||
2422 | options_to_lopts(options, long_options, i, FIO_GETOPT_JOB); | |
2423 | } | |
2424 | ||
74929ac2 JA |
2425 | struct fio_keyword { |
2426 | const char *word; | |
2427 | const char *desc; | |
2428 | char *replace; | |
2429 | }; | |
2430 | ||
2431 | static struct fio_keyword fio_keywords[] = { | |
2432 | { | |
2433 | .word = "$pagesize", | |
2434 | .desc = "Page size in the system", | |
2435 | }, | |
2436 | { | |
2437 | .word = "$mb_memory", | |
2438 | .desc = "Megabytes of memory online", | |
2439 | }, | |
2440 | { | |
2441 | .word = "$ncpus", | |
2442 | .desc = "Number of CPUs online in the system", | |
2443 | }, | |
2444 | { | |
2445 | .word = NULL, | |
2446 | }, | |
2447 | }; | |
2448 | ||
2449 | void fio_keywords_init(void) | |
2450 | { | |
3b2e1464 | 2451 | unsigned long long mb_memory; |
74929ac2 JA |
2452 | char buf[128]; |
2453 | long l; | |
2454 | ||
2455 | sprintf(buf, "%lu", page_size); | |
2456 | fio_keywords[0].replace = strdup(buf); | |
2457 | ||
8eb016d3 | 2458 | mb_memory = os_phys_mem() / (1024 * 1024); |
3b2e1464 | 2459 | sprintf(buf, "%llu", mb_memory); |
74929ac2 JA |
2460 | fio_keywords[1].replace = strdup(buf); |
2461 | ||
c00a2289 | 2462 | l = cpus_online(); |
74929ac2 JA |
2463 | sprintf(buf, "%lu", l); |
2464 | fio_keywords[2].replace = strdup(buf); | |
2465 | } | |
2466 | ||
892a6ffc JA |
2467 | #define BC_APP "bc" |
2468 | ||
2469 | static char *bc_calc(char *str) | |
2470 | { | |
d0c814ec | 2471 | char buf[128], *tmp; |
892a6ffc JA |
2472 | FILE *f; |
2473 | int ret; | |
2474 | ||
2475 | /* | |
2476 | * No math, just return string | |
2477 | */ | |
d0c814ec SL |
2478 | if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && |
2479 | !strchr(str, '/')) || strchr(str, '\'')) | |
892a6ffc JA |
2480 | return str; |
2481 | ||
2482 | /* | |
2483 | * Split option from value, we only need to calculate the value | |
2484 | */ | |
2485 | tmp = strchr(str, '='); | |
2486 | if (!tmp) | |
2487 | return str; | |
2488 | ||
2489 | tmp++; | |
892a6ffc | 2490 | |
d0c814ec SL |
2491 | /* |
2492 | * Prevent buffer overflows; such a case isn't reasonable anyway | |
2493 | */ | |
2494 | if (strlen(str) >= 128 || strlen(tmp) > 100) | |
2495 | return str; | |
892a6ffc JA |
2496 | |
2497 | sprintf(buf, "which %s > /dev/null", BC_APP); | |
2498 | if (system(buf)) { | |
2499 | log_err("fio: bc is needed for performing math\n"); | |
892a6ffc JA |
2500 | return NULL; |
2501 | } | |
2502 | ||
d0c814ec | 2503 | sprintf(buf, "echo '%s' | %s", tmp, BC_APP); |
892a6ffc JA |
2504 | f = popen(buf, "r"); |
2505 | if (!f) { | |
892a6ffc JA |
2506 | return NULL; |
2507 | } | |
2508 | ||
d0c814ec | 2509 | ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f); |
892a6ffc | 2510 | if (ret <= 0) { |
892a6ffc JA |
2511 | return NULL; |
2512 | } | |
2513 | ||
892a6ffc | 2514 | pclose(f); |
d0c814ec SL |
2515 | buf[(tmp - str) + ret - 1] = '\0'; |
2516 | memcpy(buf, str, tmp - str); | |
892a6ffc | 2517 | free(str); |
d0c814ec SL |
2518 | return strdup(buf); |
2519 | } | |
2520 | ||
2521 | /* | |
2522 | * Return a copy of the input string with substrings of the form ${VARNAME} | |
2523 | * substituted with the value of the environment variable VARNAME. The | |
2524 | * substitution always occurs, even if VARNAME is empty or the corresponding | |
2525 | * environment variable undefined. | |
2526 | */ | |
2527 | static char *option_dup_subs(const char *opt) | |
2528 | { | |
2529 | char out[OPT_LEN_MAX+1]; | |
2530 | char in[OPT_LEN_MAX+1]; | |
2531 | char *outptr = out; | |
2532 | char *inptr = in; | |
2533 | char *ch1, *ch2, *env; | |
2534 | ssize_t nchr = OPT_LEN_MAX; | |
2535 | size_t envlen; | |
2536 | ||
2537 | if (strlen(opt) + 1 > OPT_LEN_MAX) { | |
2538 | log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); | |
2539 | return NULL; | |
2540 | } | |
2541 | ||
2542 | in[OPT_LEN_MAX] = '\0'; | |
2543 | strncpy(in, opt, OPT_LEN_MAX); | |
2544 | ||
2545 | while (*inptr && nchr > 0) { | |
2546 | if (inptr[0] == '$' && inptr[1] == '{') { | |
2547 | ch2 = strchr(inptr, '}'); | |
2548 | if (ch2 && inptr+1 < ch2) { | |
2549 | ch1 = inptr+2; | |
2550 | inptr = ch2+1; | |
2551 | *ch2 = '\0'; | |
2552 | ||
2553 | env = getenv(ch1); | |
2554 | if (env) { | |
2555 | envlen = strlen(env); | |
2556 | if (envlen <= nchr) { | |
2557 | memcpy(outptr, env, envlen); | |
2558 | outptr += envlen; | |
2559 | nchr -= envlen; | |
2560 | } | |
2561 | } | |
2562 | ||
2563 | continue; | |
2564 | } | |
2565 | } | |
2566 | ||
2567 | *outptr++ = *inptr++; | |
2568 | --nchr; | |
2569 | } | |
2570 | ||
2571 | *outptr = '\0'; | |
2572 | return strdup(out); | |
892a6ffc JA |
2573 | } |
2574 | ||
74929ac2 JA |
2575 | /* |
2576 | * Look for reserved variable names and replace them with real values | |
2577 | */ | |
2578 | static char *fio_keyword_replace(char *opt) | |
2579 | { | |
2580 | char *s; | |
2581 | int i; | |
d0c814ec | 2582 | int docalc = 0; |
74929ac2 JA |
2583 | |
2584 | for (i = 0; fio_keywords[i].word != NULL; i++) { | |
2585 | struct fio_keyword *kw = &fio_keywords[i]; | |
2586 | ||
2587 | while ((s = strstr(opt, kw->word)) != NULL) { | |
2588 | char *new = malloc(strlen(opt) + 1); | |
2589 | char *o_org = opt; | |
2590 | int olen = s - opt; | |
2591 | int len; | |
2592 | ||
2593 | /* | |
2594 | * Copy part of the string before the keyword and | |
2595 | * sprintf() the replacement after it. | |
2596 | */ | |
2597 | memcpy(new, opt, olen); | |
2598 | len = sprintf(new + olen, "%s", kw->replace); | |
2599 | ||
2600 | /* | |
2601 | * If there's more in the original string, copy that | |
2602 | * in too | |
2603 | */ | |
2604 | opt += strlen(kw->word) + olen; | |
2605 | if (strlen(opt)) | |
2606 | memcpy(new + olen + len, opt, opt - o_org - 1); | |
2607 | ||
2608 | /* | |
2609 | * replace opt and free the old opt | |
2610 | */ | |
2611 | opt = new; | |
d0c814ec | 2612 | free(o_org); |
7a958bd5 | 2613 | |
d0c814ec | 2614 | docalc = 1; |
74929ac2 JA |
2615 | } |
2616 | } | |
2617 | ||
d0c814ec SL |
2618 | /* |
2619 | * Check for potential math and invoke bc, if possible | |
2620 | */ | |
2621 | if (docalc) | |
2622 | opt = bc_calc(opt); | |
2623 | ||
7a958bd5 | 2624 | return opt; |
74929ac2 JA |
2625 | } |
2626 | ||
d0c814ec SL |
2627 | static char **dup_and_sub_options(char **opts, int num_opts) |
2628 | { | |
2629 | int i; | |
2630 | char **opts_copy = malloc(num_opts * sizeof(*opts)); | |
2631 | for (i = 0; i < num_opts; i++) { | |
2632 | opts_copy[i] = option_dup_subs(opts[i]); | |
2633 | if (!opts_copy[i]) | |
2634 | continue; | |
2635 | opts_copy[i] = fio_keyword_replace(opts_copy[i]); | |
2636 | } | |
2637 | return opts_copy; | |
2638 | } | |
2639 | ||
3b8b7135 | 2640 | int fio_options_parse(struct thread_data *td, char **opts, int num_opts) |
214e1eca | 2641 | { |
de890a1e | 2642 | int i, ret, unknown; |
d0c814ec | 2643 | char **opts_copy; |
3b8b7135 JA |
2644 | |
2645 | sort_options(opts, options, num_opts); | |
d0c814ec | 2646 | opts_copy = dup_and_sub_options(opts, num_opts); |
3b8b7135 | 2647 | |
de890a1e SL |
2648 | for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) { |
2649 | struct fio_option *o; | |
2650 | int newret = parse_option(opts_copy[i], opts[i], options, &o, | |
2651 | td); | |
d0c814ec | 2652 | |
de890a1e SL |
2653 | if (opts_copy[i]) { |
2654 | if (newret && !o) { | |
2655 | unknown++; | |
2656 | continue; | |
2657 | } | |
d0c814ec | 2658 | free(opts_copy[i]); |
de890a1e SL |
2659 | opts_copy[i] = NULL; |
2660 | } | |
2661 | ||
2662 | ret |= newret; | |
2663 | } | |
2664 | ||
2665 | if (unknown) { | |
2666 | ret |= ioengine_load(td); | |
2667 | if (td->eo) { | |
2668 | sort_options(opts_copy, td->io_ops->options, num_opts); | |
2669 | opts = opts_copy; | |
2670 | } | |
2671 | for (i = 0; i < num_opts; i++) { | |
2672 | struct fio_option *o = NULL; | |
2673 | int newret = 1; | |
2674 | if (!opts_copy[i]) | |
2675 | continue; | |
2676 | ||
2677 | if (td->eo) | |
2678 | newret = parse_option(opts_copy[i], opts[i], | |
2679 | td->io_ops->options, &o, | |
2680 | td->eo); | |
2681 | ||
2682 | ret |= newret; | |
2683 | if (!o) | |
2684 | log_err("Bad option <%s>\n", opts[i]); | |
2685 | ||
2686 | free(opts_copy[i]); | |
2687 | opts_copy[i] = NULL; | |
2688 | } | |
74929ac2 | 2689 | } |
3b8b7135 | 2690 | |
d0c814ec | 2691 | free(opts_copy); |
3b8b7135 | 2692 | return ret; |
214e1eca JA |
2693 | } |
2694 | ||
2695 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) | |
2696 | { | |
07b3232d | 2697 | return parse_cmd_option(opt, val, options, td); |
214e1eca JA |
2698 | } |
2699 | ||
de890a1e SL |
2700 | int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt, |
2701 | char *val) | |
2702 | { | |
2703 | return parse_cmd_option(opt, val, td->io_ops->options, td); | |
2704 | } | |
2705 | ||
214e1eca JA |
2706 | void fio_fill_default_options(struct thread_data *td) |
2707 | { | |
2708 | fill_default_options(td, options); | |
2709 | } | |
2710 | ||
2711 | int fio_show_option_help(const char *opt) | |
2712 | { | |
07b3232d | 2713 | return show_cmd_help(options, opt); |
214e1eca | 2714 | } |
d23bb327 | 2715 | |
de890a1e | 2716 | void options_mem_dupe(void *data, struct fio_option *options) |
d23bb327 | 2717 | { |
de890a1e | 2718 | struct fio_option *o; |
d23bb327 | 2719 | char **ptr; |
d23bb327 | 2720 | |
de890a1e SL |
2721 | for (o = &options[0]; o->name; o++) { |
2722 | if (o->type != FIO_OPT_STR_STORE) | |
d23bb327 JA |
2723 | continue; |
2724 | ||
de890a1e | 2725 | ptr = td_var(data, o->off1); |
7e356b2d JA |
2726 | if (*ptr) |
2727 | *ptr = strdup(*ptr); | |
d23bb327 JA |
2728 | } |
2729 | } | |
2730 | ||
de890a1e SL |
2731 | /* |
2732 | * dupe FIO_OPT_STR_STORE options | |
2733 | */ | |
2734 | void fio_options_mem_dupe(struct thread_data *td) | |
2735 | { | |
2736 | options_mem_dupe(&td->o, options); | |
1647f592 JA |
2737 | |
2738 | if (td->eo && td->io_ops) { | |
de890a1e | 2739 | void *oldeo = td->eo; |
1647f592 | 2740 | |
de890a1e SL |
2741 | td->eo = malloc(td->io_ops->option_struct_size); |
2742 | memcpy(td->eo, oldeo, td->io_ops->option_struct_size); | |
2743 | options_mem_dupe(td->eo, td->io_ops->options); | |
2744 | } | |
2745 | } | |
2746 | ||
d6978a32 JA |
2747 | unsigned int fio_get_kb_base(void *data) |
2748 | { | |
2749 | struct thread_data *td = data; | |
2750 | unsigned int kb_base = 0; | |
2751 | ||
2752 | if (td) | |
2753 | kb_base = td->o.kb_base; | |
2754 | if (!kb_base) | |
2755 | kb_base = 1024; | |
2756 | ||
2757 | return kb_base; | |
2758 | } | |
9f988e2e | 2759 | |
07b3232d | 2760 | int add_option(struct fio_option *o) |
9f988e2e | 2761 | { |
07b3232d JA |
2762 | struct fio_option *__o; |
2763 | int opt_index = 0; | |
2764 | ||
2765 | __o = options; | |
2766 | while (__o->name) { | |
2767 | opt_index++; | |
2768 | __o++; | |
2769 | } | |
2770 | ||
2771 | memcpy(&options[opt_index], o, sizeof(*o)); | |
2772 | return 0; | |
9f988e2e | 2773 | } |
e2de69da | 2774 | |
07b3232d | 2775 | void invalidate_profile_options(const char *prof_name) |
e2de69da | 2776 | { |
07b3232d | 2777 | struct fio_option *o; |
e2de69da | 2778 | |
07b3232d JA |
2779 | o = options; |
2780 | while (o->name) { | |
2781 | if (o->prof_name && !strcmp(o->prof_name, prof_name)) { | |
2782 | o->type = FIO_OPT_INVALID; | |
2783 | o->prof_name = NULL; | |
2784 | } | |
2785 | o++; | |
e2de69da JA |
2786 | } |
2787 | } | |
f5b6bb85 JA |
2788 | |
2789 | void add_opt_posval(const char *optname, const char *ival, const char *help) | |
2790 | { | |
2791 | struct fio_option *o; | |
2792 | unsigned int i; | |
2793 | ||
2794 | o = find_option(options, optname); | |
2795 | if (!o) | |
2796 | return; | |
2797 | ||
2798 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
2799 | if (o->posval[i].ival) | |
2800 | continue; | |
2801 | ||
2802 | o->posval[i].ival = ival; | |
2803 | o->posval[i].help = help; | |
2804 | break; | |
2805 | } | |
2806 | } | |
2807 | ||
2808 | void del_opt_posval(const char *optname, const char *ival) | |
2809 | { | |
2810 | struct fio_option *o; | |
2811 | unsigned int i; | |
2812 | ||
2813 | o = find_option(options, optname); | |
2814 | if (!o) | |
2815 | return; | |
2816 | ||
2817 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
2818 | if (!o->posval[i].ival) | |
2819 | continue; | |
2820 | if (strcmp(o->posval[i].ival, ival)) | |
2821 | continue; | |
2822 | ||
2823 | o->posval[i].ival = NULL; | |
2824 | o->posval[i].help = NULL; | |
2825 | } | |
2826 | } | |
7e356b2d JA |
2827 | |
2828 | void fio_options_free(struct thread_data *td) | |
2829 | { | |
2830 | options_free(options, td); | |
de890a1e SL |
2831 | if (td->eo && td->io_ops && td->io_ops->options) { |
2832 | options_free(td->io_ops->options, td->eo); | |
2833 | free(td->eo); | |
2834 | td->eo = NULL; | |
2835 | } | |
7e356b2d | 2836 | } |