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