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 | ||
9af4a244 JA |
845 | /* |
846 | * Option grouping | |
847 | */ | |
848 | static struct opt_group fio_opt_groups[] = { | |
849 | { | |
e8b0e958 JA |
850 | .name = "General", |
851 | .mask = FIO_OPT_C_GENERAL, | |
9af4a244 JA |
852 | }, |
853 | { | |
e8b0e958 JA |
854 | .name = "I/O", |
855 | .mask = FIO_OPT_C_IO, | |
9af4a244 JA |
856 | }, |
857 | { | |
e8b0e958 JA |
858 | .name = "File", |
859 | .mask = FIO_OPT_C_FILE, | |
9af4a244 JA |
860 | }, |
861 | { | |
e8b0e958 JA |
862 | .name = "Statistics", |
863 | .mask = FIO_OPT_C_STAT, | |
9af4a244 JA |
864 | }, |
865 | { | |
e8b0e958 JA |
866 | .name = "Logging", |
867 | .mask = FIO_OPT_C_LOG, | |
9af4a244 | 868 | }, |
e231bbe6 | 869 | { |
e8b0e958 | 870 | .name = NULL, |
e231bbe6 | 871 | }, |
e8b0e958 JA |
872 | }; |
873 | ||
874 | static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask, | |
875 | unsigned int inv_mask) | |
876 | { | |
877 | struct opt_group *og; | |
878 | int i; | |
879 | ||
880 | if (*mask == inv_mask || !*mask) | |
881 | return NULL; | |
882 | ||
883 | for (i = 0; ogs[i].name; i++) { | |
884 | og = &ogs[i]; | |
885 | ||
886 | if (*mask & og->mask) { | |
887 | *mask &= ~(og->mask); | |
888 | return og; | |
889 | } | |
890 | } | |
891 | ||
892 | return NULL; | |
893 | } | |
894 | ||
895 | struct opt_group *opt_group_from_mask(unsigned int *mask) | |
896 | { | |
897 | return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); | |
898 | } | |
899 | ||
900 | static struct opt_group fio_opt_cat_groups[] = { | |
9af4a244 | 901 | { |
e8b0e958 JA |
902 | .name = "Rate", |
903 | .mask = FIO_OPT_G_RATE, | |
9af4a244 JA |
904 | }, |
905 | { | |
e8b0e958 JA |
906 | .name = "Zone", |
907 | .mask = FIO_OPT_G_ZONE, | |
9af4a244 JA |
908 | }, |
909 | { | |
e8b0e958 JA |
910 | .name = "Read/write mix", |
911 | .mask = FIO_OPT_G_RWMIX, | |
9af4a244 JA |
912 | }, |
913 | { | |
914 | .name = "Verify", | |
915 | .mask = FIO_OPT_G_VERIFY, | |
916 | }, | |
917 | { | |
e8b0e958 JA |
918 | .name = "Trim", |
919 | .mask = FIO_OPT_G_TRIM, | |
9af4a244 JA |
920 | }, |
921 | { | |
e8b0e958 JA |
922 | .name = "I/O Logging", |
923 | .mask = FIO_OPT_G_IOLOG, | |
9af4a244 JA |
924 | }, |
925 | { | |
e8b0e958 JA |
926 | .name = "I/O Depth", |
927 | .mask = FIO_OPT_G_IO_DEPTH, | |
9af4a244 JA |
928 | }, |
929 | { | |
e8b0e958 JA |
930 | .name = "I/O Flow", |
931 | .mask = FIO_OPT_G_IO_FLOW, | |
9af4a244 | 932 | }, |
0626037e JA |
933 | { |
934 | .name = "Description", | |
935 | .mask = FIO_OPT_G_DESC, | |
936 | }, | |
937 | { | |
938 | .name = "Filename", | |
939 | .mask = FIO_OPT_G_FILENAME, | |
940 | }, | |
941 | { | |
942 | .name = "General I/O", | |
943 | .mask = FIO_OPT_G_IO_BASIC, | |
944 | }, | |
a1f6afec JA |
945 | { |
946 | .name = "Cgroups", | |
947 | .mask = FIO_OPT_G_CGROUP, | |
948 | }, | |
949 | { | |
950 | .name = "Runtime", | |
951 | .mask = FIO_OPT_G_RUNTIME, | |
952 | }, | |
10860056 JA |
953 | { |
954 | .name = "Process", | |
955 | .mask = FIO_OPT_G_PROCESS, | |
956 | }, | |
957 | { | |
958 | .name = "Job credentials / priority", | |
959 | .mask = FIO_OPT_G_CRED, | |
960 | }, | |
961 | { | |
962 | .name = "Clock settings", | |
963 | .mask = FIO_OPT_G_CLOCK, | |
964 | }, | |
9af4a244 JA |
965 | { |
966 | .name = NULL, | |
e8b0e958 | 967 | } |
9af4a244 JA |
968 | }; |
969 | ||
e8b0e958 | 970 | struct opt_group *opt_group_cat_from_mask(unsigned int *mask) |
9af4a244 | 971 | { |
e8b0e958 | 972 | return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); |
9af4a244 JA |
973 | } |
974 | ||
214e1eca JA |
975 | /* |
976 | * Map of job/command line options | |
977 | */ | |
9af4a244 | 978 | struct fio_option fio_options[FIO_MAX_OPTS] = { |
214e1eca JA |
979 | { |
980 | .name = "description", | |
e8b0e958 | 981 | .lname = "Description of job", |
214e1eca JA |
982 | .type = FIO_OPT_STR_STORE, |
983 | .off1 = td_var_offset(description), | |
984 | .help = "Text job description", | |
e8b0e958 | 985 | .category = FIO_OPT_C_GENERAL, |
0626037e | 986 | .group = FIO_OPT_G_DESC, |
214e1eca JA |
987 | }, |
988 | { | |
989 | .name = "name", | |
e8b0e958 | 990 | .lname = "Job name", |
214e1eca JA |
991 | .type = FIO_OPT_STR_STORE, |
992 | .off1 = td_var_offset(name), | |
993 | .help = "Name of this job", | |
e8b0e958 | 994 | .category = FIO_OPT_C_GENERAL, |
0626037e | 995 | .group = FIO_OPT_G_DESC, |
214e1eca | 996 | }, |
214e1eca JA |
997 | { |
998 | .name = "filename", | |
e8b0e958 | 999 | .lname = "Filename(s)", |
214e1eca JA |
1000 | .type = FIO_OPT_STR_STORE, |
1001 | .off1 = td_var_offset(filename), | |
1002 | .cb = str_filename_cb, | |
f0d524b0 | 1003 | .prio = -1, /* must come after "directory" */ |
214e1eca | 1004 | .help = "File(s) to use for the workload", |
e8b0e958 | 1005 | .category = FIO_OPT_C_FILE, |
0626037e | 1006 | .group = FIO_OPT_G_FILENAME, |
214e1eca | 1007 | }, |
90fef2d1 | 1008 | { |
e8b0e958 JA |
1009 | .name = "directory", |
1010 | .lname = "Directory", | |
1011 | .type = FIO_OPT_STR_STORE, | |
1012 | .off1 = td_var_offset(directory), | |
1013 | .cb = str_directory_cb, | |
1014 | .help = "Directory to store files in", | |
1015 | .category = FIO_OPT_C_FILE, | |
0626037e | 1016 | .group = FIO_OPT_G_FILENAME, |
90fef2d1 | 1017 | }, |
29c1349f JA |
1018 | { |
1019 | .name = "lockfile", | |
e8b0e958 | 1020 | .lname = "Lockfile", |
4d4e80f2 JA |
1021 | .type = FIO_OPT_STR, |
1022 | .cb = str_lockfile_cb, | |
1023 | .off1 = td_var_offset(file_lock_mode), | |
29c1349f JA |
1024 | .help = "Lock file when doing IO to it", |
1025 | .parent = "filename", | |
d71c154c | 1026 | .hide = 0, |
4d4e80f2 | 1027 | .def = "none", |
e8b0e958 | 1028 | .category = FIO_OPT_C_FILE, |
0626037e | 1029 | .group = FIO_OPT_G_FILENAME, |
4d4e80f2 JA |
1030 | .posval = { |
1031 | { .ival = "none", | |
1032 | .oval = FILE_LOCK_NONE, | |
1033 | .help = "No file locking", | |
1034 | }, | |
1035 | { .ival = "exclusive", | |
1036 | .oval = FILE_LOCK_EXCLUSIVE, | |
1037 | .help = "Exclusive file lock", | |
1038 | }, | |
1039 | { | |
1040 | .ival = "readwrite", | |
1041 | .oval = FILE_LOCK_READWRITE, | |
1042 | .help = "Read vs write lock", | |
1043 | }, | |
1044 | }, | |
29c1349f | 1045 | }, |
214e1eca JA |
1046 | { |
1047 | .name = "opendir", | |
e8b0e958 | 1048 | .lname = "Open directory", |
214e1eca JA |
1049 | .type = FIO_OPT_STR_STORE, |
1050 | .off1 = td_var_offset(opendir), | |
1051 | .cb = str_opendir_cb, | |
1052 | .help = "Recursively add files from this directory and down", | |
e8b0e958 | 1053 | .category = FIO_OPT_C_FILE, |
0626037e | 1054 | .group = FIO_OPT_G_FILENAME, |
214e1eca JA |
1055 | }, |
1056 | { | |
1057 | .name = "rw", | |
e8b0e958 | 1058 | .lname = "Read/write", |
d3aad8f2 | 1059 | .alias = "readwrite", |
214e1eca | 1060 | .type = FIO_OPT_STR, |
211097b2 | 1061 | .cb = str_rw_cb, |
214e1eca JA |
1062 | .off1 = td_var_offset(td_ddir), |
1063 | .help = "IO direction", | |
1064 | .def = "read", | |
896cac2a | 1065 | .verify = rw_verify, |
e8b0e958 | 1066 | .category = FIO_OPT_C_IO, |
0626037e | 1067 | .group = FIO_OPT_G_IO_BASIC, |
214e1eca JA |
1068 | .posval = { |
1069 | { .ival = "read", | |
1070 | .oval = TD_DDIR_READ, | |
1071 | .help = "Sequential read", | |
1072 | }, | |
1073 | { .ival = "write", | |
1074 | .oval = TD_DDIR_WRITE, | |
1075 | .help = "Sequential write", | |
1076 | }, | |
1077 | { .ival = "randread", | |
1078 | .oval = TD_DDIR_RANDREAD, | |
1079 | .help = "Random read", | |
1080 | }, | |
1081 | { .ival = "randwrite", | |
1082 | .oval = TD_DDIR_RANDWRITE, | |
1083 | .help = "Random write", | |
1084 | }, | |
1085 | { .ival = "rw", | |
1086 | .oval = TD_DDIR_RW, | |
1087 | .help = "Sequential read and write mix", | |
1088 | }, | |
1089 | { .ival = "randrw", | |
1090 | .oval = TD_DDIR_RANDRW, | |
1091 | .help = "Random read and write mix" | |
1092 | }, | |
1093 | }, | |
1094 | }, | |
38dad62d JA |
1095 | { |
1096 | .name = "rw_sequencer", | |
e8b0e958 | 1097 | .lname = "RW Sequencer", |
38dad62d JA |
1098 | .type = FIO_OPT_STR, |
1099 | .off1 = td_var_offset(rw_seq), | |
1100 | .help = "IO offset generator modifier", | |
1101 | .def = "sequential", | |
e8b0e958 | 1102 | .category = FIO_OPT_C_IO, |
0626037e | 1103 | .group = FIO_OPT_G_IO_BASIC, |
38dad62d JA |
1104 | .posval = { |
1105 | { .ival = "sequential", | |
1106 | .oval = RW_SEQ_SEQ, | |
1107 | .help = "Generate sequential offsets", | |
1108 | }, | |
1109 | { .ival = "identical", | |
1110 | .oval = RW_SEQ_IDENT, | |
1111 | .help = "Generate identical offsets", | |
1112 | }, | |
1113 | }, | |
1114 | }, | |
1115 | ||
214e1eca JA |
1116 | { |
1117 | .name = "ioengine", | |
e8b0e958 | 1118 | .lname = "IO Engine", |
214e1eca JA |
1119 | .type = FIO_OPT_STR_STORE, |
1120 | .off1 = td_var_offset(ioengine), | |
1121 | .help = "IO engine to use", | |
58483fa4 | 1122 | .def = FIO_PREFERRED_ENGINE, |
e8b0e958 | 1123 | .category = FIO_OPT_C_IO, |
0626037e | 1124 | .group = FIO_OPT_G_IO_BASIC, |
214e1eca JA |
1125 | .posval = { |
1126 | { .ival = "sync", | |
1127 | .help = "Use read/write", | |
1128 | }, | |
a31041ea | 1129 | { .ival = "psync", |
1130 | .help = "Use pread/pwrite", | |
1131 | }, | |
1d2af02a | 1132 | { .ival = "vsync", |
03e20d68 | 1133 | .help = "Use readv/writev", |
1d2af02a | 1134 | }, |
214e1eca JA |
1135 | #ifdef FIO_HAVE_LIBAIO |
1136 | { .ival = "libaio", | |
1137 | .help = "Linux native asynchronous IO", | |
1138 | }, | |
1139 | #endif | |
1140 | #ifdef FIO_HAVE_POSIXAIO | |
1141 | { .ival = "posixaio", | |
1142 | .help = "POSIX asynchronous IO", | |
1143 | }, | |
417f0068 JA |
1144 | #endif |
1145 | #ifdef FIO_HAVE_SOLARISAIO | |
1146 | { .ival = "solarisaio", | |
1147 | .help = "Solaris native asynchronous IO", | |
1148 | }, | |
214e1eca | 1149 | #endif |
03e20d68 BC |
1150 | #ifdef FIO_HAVE_WINDOWSAIO |
1151 | { .ival = "windowsaio", | |
3be80071 | 1152 | .help = "Windows native asynchronous IO" |
de890a1e | 1153 | }, |
3be80071 | 1154 | #endif |
214e1eca | 1155 | { .ival = "mmap", |
03e20d68 | 1156 | .help = "Memory mapped IO" |
214e1eca JA |
1157 | }, |
1158 | #ifdef FIO_HAVE_SPLICE | |
1159 | { .ival = "splice", | |
1160 | .help = "splice/vmsplice based IO", | |
1161 | }, | |
9cce02e8 JA |
1162 | { .ival = "netsplice", |
1163 | .help = "splice/vmsplice to/from the network", | |
1164 | }, | |
214e1eca JA |
1165 | #endif |
1166 | #ifdef FIO_HAVE_SGIO | |
1167 | { .ival = "sg", | |
1168 | .help = "SCSI generic v3 IO", | |
1169 | }, | |
1170 | #endif | |
1171 | { .ival = "null", | |
1172 | .help = "Testing engine (no data transfer)", | |
1173 | }, | |
1174 | { .ival = "net", | |
1175 | .help = "Network IO", | |
1176 | }, | |
1177 | #ifdef FIO_HAVE_SYSLET | |
1178 | { .ival = "syslet-rw", | |
1179 | .help = "syslet enabled async pread/pwrite IO", | |
1180 | }, | |
1181 | #endif | |
1182 | { .ival = "cpuio", | |
03e20d68 | 1183 | .help = "CPU cycle burner engine", |
214e1eca | 1184 | }, |
b8c82a46 JA |
1185 | #ifdef FIO_HAVE_GUASI |
1186 | { .ival = "guasi", | |
1187 | .help = "GUASI IO engine", | |
1188 | }, | |
79a43187 JA |
1189 | #endif |
1190 | #ifdef FIO_HAVE_BINJECT | |
1191 | { .ival = "binject", | |
1192 | .help = "binject direct inject block engine", | |
1193 | }, | |
21b8aee8 | 1194 | #endif |
1195 | #ifdef FIO_HAVE_RDMA | |
1196 | { .ival = "rdma", | |
1197 | .help = "RDMA IO engine", | |
1198 | }, | |
b8c82a46 | 1199 | #endif |
214e1eca JA |
1200 | { .ival = "external", |
1201 | .help = "Load external engine (append name)", | |
1202 | }, | |
1203 | }, | |
1204 | }, | |
1205 | { | |
1206 | .name = "iodepth", | |
e8b0e958 | 1207 | .lname = "IO Depth", |
214e1eca JA |
1208 | .type = FIO_OPT_INT, |
1209 | .off1 = td_var_offset(iodepth), | |
03e20d68 | 1210 | .help = "Number of IO buffers to keep in flight", |
757aff4f | 1211 | .minval = 1, |
20eb06bd | 1212 | .interval = 1, |
214e1eca | 1213 | .def = "1", |
e8b0e958 | 1214 | .category = FIO_OPT_C_IO, |
0626037e | 1215 | .group = FIO_OPT_G_IO_BASIC, |
214e1eca JA |
1216 | }, |
1217 | { | |
1218 | .name = "iodepth_batch", | |
e8b0e958 | 1219 | .lname = "IO Depth batch", |
4950421a | 1220 | .alias = "iodepth_batch_submit", |
214e1eca JA |
1221 | .type = FIO_OPT_INT, |
1222 | .off1 = td_var_offset(iodepth_batch), | |
d65db441 | 1223 | .help = "Number of IO buffers to submit in one go", |
afdf9352 | 1224 | .parent = "iodepth", |
d71c154c | 1225 | .hide = 1, |
a2e6f8ac | 1226 | .minval = 1, |
20eb06bd | 1227 | .interval = 1, |
a2e6f8ac | 1228 | .def = "1", |
e8b0e958 | 1229 | .category = FIO_OPT_C_IO, |
0626037e | 1230 | .group = FIO_OPT_G_IO_BASIC, |
4950421a JA |
1231 | }, |
1232 | { | |
1233 | .name = "iodepth_batch_complete", | |
e8b0e958 | 1234 | .lname = "IO Depth batch complete", |
4950421a JA |
1235 | .type = FIO_OPT_INT, |
1236 | .off1 = td_var_offset(iodepth_batch_complete), | |
d65db441 | 1237 | .help = "Number of IO buffers to retrieve in one go", |
4950421a | 1238 | .parent = "iodepth", |
d71c154c | 1239 | .hide = 1, |
4950421a | 1240 | .minval = 0, |
20eb06bd | 1241 | .interval = 1, |
4950421a | 1242 | .def = "1", |
e8b0e958 | 1243 | .category = FIO_OPT_C_IO, |
0626037e | 1244 | .group = FIO_OPT_G_IO_BASIC, |
214e1eca JA |
1245 | }, |
1246 | { | |
1247 | .name = "iodepth_low", | |
e8b0e958 | 1248 | .lname = "IO Depth batch low", |
214e1eca JA |
1249 | .type = FIO_OPT_INT, |
1250 | .off1 = td_var_offset(iodepth_low), | |
1251 | .help = "Low water mark for queuing depth", | |
afdf9352 | 1252 | .parent = "iodepth", |
d71c154c | 1253 | .hide = 1, |
20eb06bd | 1254 | .interval = 1, |
e8b0e958 | 1255 | .category = FIO_OPT_C_IO, |
0626037e | 1256 | .group = FIO_OPT_G_IO_BASIC, |
214e1eca JA |
1257 | }, |
1258 | { | |
1259 | .name = "size", | |
e8b0e958 | 1260 | .lname = "Size", |
214e1eca | 1261 | .type = FIO_OPT_STR_VAL, |
7bb59102 | 1262 | .cb = str_size_cb, |
214e1eca | 1263 | .help = "Total size of device or files", |
20eb06bd | 1264 | .interval = 1024 * 1024, |
e8b0e958 JA |
1265 | .category = FIO_OPT_C_IO, |
1266 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1267 | }, |
aa31f1f1 SL |
1268 | { |
1269 | .name = "fill_device", | |
e8b0e958 | 1270 | .lname = "Fill device", |
74586c1e | 1271 | .alias = "fill_fs", |
aa31f1f1 SL |
1272 | .type = FIO_OPT_BOOL, |
1273 | .off1 = td_var_offset(fill_device), | |
1274 | .help = "Write until an ENOSPC error occurs", | |
1275 | .def = "0", | |
e8b0e958 JA |
1276 | .category = FIO_OPT_C_FILE, |
1277 | .group = FIO_OPT_G_INVALID, | |
aa31f1f1 | 1278 | }, |
214e1eca JA |
1279 | { |
1280 | .name = "filesize", | |
e8b0e958 | 1281 | .lname = "File size", |
214e1eca JA |
1282 | .type = FIO_OPT_STR_VAL, |
1283 | .off1 = td_var_offset(file_size_low), | |
1284 | .off2 = td_var_offset(file_size_high), | |
c3edbdba | 1285 | .minval = 1, |
214e1eca | 1286 | .help = "Size of individual files", |
20eb06bd | 1287 | .interval = 1024 * 1024, |
e8b0e958 JA |
1288 | .category = FIO_OPT_C_FILE, |
1289 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1290 | }, |
67a1000f JA |
1291 | { |
1292 | .name = "offset", | |
e8b0e958 | 1293 | .lname = "IO offset", |
67a1000f JA |
1294 | .alias = "fileoffset", |
1295 | .type = FIO_OPT_STR_VAL, | |
1296 | .off1 = td_var_offset(start_offset), | |
1297 | .help = "Start IO from this offset", | |
1298 | .def = "0", | |
20eb06bd | 1299 | .interval = 1024 * 1024, |
e8b0e958 JA |
1300 | .category = FIO_OPT_C_IO, |
1301 | .group = FIO_OPT_G_INVALID, | |
67a1000f | 1302 | }, |
2d7cd868 JA |
1303 | { |
1304 | .name = "offset_increment", | |
e8b0e958 | 1305 | .lname = "IO offset increment", |
2d7cd868 JA |
1306 | .type = FIO_OPT_STR_VAL, |
1307 | .off1 = td_var_offset(offset_increment), | |
1308 | .help = "What is the increment from one offset to the next", | |
1309 | .parent = "offset", | |
d71c154c | 1310 | .hide = 1, |
2d7cd868 | 1311 | .def = "0", |
20eb06bd | 1312 | .interval = 1024 * 1024, |
e8b0e958 JA |
1313 | .category = FIO_OPT_C_IO, |
1314 | .group = FIO_OPT_G_INVALID, | |
2d7cd868 | 1315 | }, |
214e1eca JA |
1316 | { |
1317 | .name = "bs", | |
e8b0e958 | 1318 | .lname = "Block size", |
d3aad8f2 | 1319 | .alias = "blocksize", |
e01b22b8 | 1320 | .type = FIO_OPT_INT, |
214e1eca JA |
1321 | .off1 = td_var_offset(bs[DDIR_READ]), |
1322 | .off2 = td_var_offset(bs[DDIR_WRITE]), | |
c3edbdba | 1323 | .minval = 1, |
214e1eca JA |
1324 | .help = "Block size unit", |
1325 | .def = "4k", | |
67a1000f | 1326 | .parent = "rw", |
d71c154c | 1327 | .hide = 1, |
20eb06bd | 1328 | .interval = 512, |
e8b0e958 JA |
1329 | .category = FIO_OPT_C_IO, |
1330 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1331 | }, |
2b7a01d0 JA |
1332 | { |
1333 | .name = "ba", | |
e8b0e958 | 1334 | .lname = "Block size align", |
2b7a01d0 | 1335 | .alias = "blockalign", |
e01b22b8 | 1336 | .type = FIO_OPT_INT, |
2b7a01d0 JA |
1337 | .off1 = td_var_offset(ba[DDIR_READ]), |
1338 | .off2 = td_var_offset(ba[DDIR_WRITE]), | |
1339 | .minval = 1, | |
1340 | .help = "IO block offset alignment", | |
1341 | .parent = "rw", | |
d71c154c | 1342 | .hide = 1, |
20eb06bd | 1343 | .interval = 512, |
e8b0e958 JA |
1344 | .category = FIO_OPT_C_IO, |
1345 | .group = FIO_OPT_G_INVALID, | |
2b7a01d0 | 1346 | }, |
214e1eca JA |
1347 | { |
1348 | .name = "bsrange", | |
e8b0e958 | 1349 | .lname = "Block size range", |
d3aad8f2 | 1350 | .alias = "blocksize_range", |
214e1eca JA |
1351 | .type = FIO_OPT_RANGE, |
1352 | .off1 = td_var_offset(min_bs[DDIR_READ]), | |
1353 | .off2 = td_var_offset(max_bs[DDIR_READ]), | |
1354 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), | |
1355 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), | |
c3edbdba | 1356 | .minval = 1, |
214e1eca | 1357 | .help = "Set block size range (in more detail than bs)", |
67a1000f | 1358 | .parent = "rw", |
d71c154c | 1359 | .hide = 1, |
20eb06bd | 1360 | .interval = 4096, |
e8b0e958 JA |
1361 | .category = FIO_OPT_C_IO, |
1362 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1363 | }, |
564ca972 JA |
1364 | { |
1365 | .name = "bssplit", | |
e8b0e958 | 1366 | .lname = "Block size split", |
564ca972 JA |
1367 | .type = FIO_OPT_STR, |
1368 | .cb = str_bssplit_cb, | |
1369 | .help = "Set a specific mix of block sizes", | |
1370 | .parent = "rw", | |
d71c154c | 1371 | .hide = 1, |
e8b0e958 JA |
1372 | .category = FIO_OPT_C_IO, |
1373 | .group = FIO_OPT_G_INVALID, | |
564ca972 | 1374 | }, |
214e1eca JA |
1375 | { |
1376 | .name = "bs_unaligned", | |
e8b0e958 | 1377 | .lname = "Block size unaligned", |
d3aad8f2 | 1378 | .alias = "blocksize_unaligned", |
214e1eca JA |
1379 | .type = FIO_OPT_STR_SET, |
1380 | .off1 = td_var_offset(bs_unaligned), | |
1381 | .help = "Don't sector align IO buffer sizes", | |
67a1000f | 1382 | .parent = "rw", |
d71c154c | 1383 | .hide = 1, |
e8b0e958 JA |
1384 | .category = FIO_OPT_C_IO, |
1385 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1386 | }, |
1387 | { | |
1388 | .name = "randrepeat", | |
e8b0e958 | 1389 | .lname = "Random repeatable", |
214e1eca JA |
1390 | .type = FIO_OPT_BOOL, |
1391 | .off1 = td_var_offset(rand_repeatable), | |
1392 | .help = "Use repeatable random IO pattern", | |
1393 | .def = "1", | |
67a1000f | 1394 | .parent = "rw", |
d71c154c | 1395 | .hide = 1, |
e8b0e958 JA |
1396 | .category = FIO_OPT_C_IO, |
1397 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1398 | }, |
2615cc4b JA |
1399 | { |
1400 | .name = "use_os_rand", | |
e8b0e958 | 1401 | .lname = "Use OS random", |
2615cc4b JA |
1402 | .type = FIO_OPT_BOOL, |
1403 | .off1 = td_var_offset(use_os_rand), | |
1404 | .help = "Set to use OS random generator", | |
1405 | .def = "0", | |
1406 | .parent = "rw", | |
d71c154c | 1407 | .hide = 1, |
e8b0e958 JA |
1408 | .category = FIO_OPT_C_IO, |
1409 | .group = FIO_OPT_G_INVALID, | |
2615cc4b | 1410 | }, |
214e1eca JA |
1411 | { |
1412 | .name = "norandommap", | |
e8b0e958 | 1413 | .lname = "No randommap", |
214e1eca JA |
1414 | .type = FIO_OPT_STR_SET, |
1415 | .off1 = td_var_offset(norandommap), | |
1416 | .help = "Accept potential duplicate random blocks", | |
67a1000f | 1417 | .parent = "rw", |
d71c154c | 1418 | .hide = 1, |
e8b0e958 JA |
1419 | .category = FIO_OPT_C_IO, |
1420 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1421 | }, |
2b386d25 JA |
1422 | { |
1423 | .name = "softrandommap", | |
e8b0e958 | 1424 | .lname = "Soft randommap", |
2b386d25 JA |
1425 | .type = FIO_OPT_BOOL, |
1426 | .off1 = td_var_offset(softrandommap), | |
f66ab3c8 | 1427 | .help = "Set norandommap if randommap allocation fails", |
2b386d25 | 1428 | .parent = "norandommap", |
d71c154c | 1429 | .hide = 1, |
2b386d25 | 1430 | .def = "0", |
e8b0e958 JA |
1431 | .category = FIO_OPT_C_IO, |
1432 | .group = FIO_OPT_G_INVALID, | |
2b386d25 | 1433 | }, |
214e1eca JA |
1434 | { |
1435 | .name = "nrfiles", | |
e8b0e958 | 1436 | .lname = "Number of files", |
d7c8be03 | 1437 | .alias = "nr_files", |
214e1eca JA |
1438 | .type = FIO_OPT_INT, |
1439 | .off1 = td_var_offset(nr_files), | |
1440 | .help = "Split job workload between this number of files", | |
1441 | .def = "1", | |
20eb06bd | 1442 | .interval = 1, |
e8b0e958 JA |
1443 | .category = FIO_OPT_C_FILE, |
1444 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1445 | }, |
1446 | { | |
1447 | .name = "openfiles", | |
e8b0e958 | 1448 | .lname = "Number of open files", |
214e1eca JA |
1449 | .type = FIO_OPT_INT, |
1450 | .off1 = td_var_offset(open_files), | |
1451 | .help = "Number of files to keep open at the same time", | |
e8b0e958 JA |
1452 | .category = FIO_OPT_C_FILE, |
1453 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1454 | }, |
1455 | { | |
1456 | .name = "file_service_type", | |
e8b0e958 | 1457 | .lname = "File service type", |
214e1eca JA |
1458 | .type = FIO_OPT_STR, |
1459 | .cb = str_fst_cb, | |
1460 | .off1 = td_var_offset(file_service_type), | |
1461 | .help = "How to select which file to service next", | |
1462 | .def = "roundrobin", | |
e8b0e958 JA |
1463 | .category = FIO_OPT_C_FILE, |
1464 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1465 | .posval = { |
1466 | { .ival = "random", | |
1467 | .oval = FIO_FSERVICE_RANDOM, | |
1468 | .help = "Choose a file at random", | |
1469 | }, | |
1470 | { .ival = "roundrobin", | |
1471 | .oval = FIO_FSERVICE_RR, | |
1472 | .help = "Round robin select files", | |
1473 | }, | |
a086c257 JA |
1474 | { .ival = "sequential", |
1475 | .oval = FIO_FSERVICE_SEQ, | |
1476 | .help = "Finish one file before moving to the next", | |
1477 | }, | |
214e1eca | 1478 | }, |
67a1000f | 1479 | .parent = "nrfiles", |
d71c154c | 1480 | .hide = 1, |
67a1000f | 1481 | }, |
7bc8c2cf JA |
1482 | #ifdef FIO_HAVE_FALLOCATE |
1483 | { | |
1484 | .name = "fallocate", | |
e8b0e958 | 1485 | .lname = "Fallocate", |
a596f047 EG |
1486 | .type = FIO_OPT_STR, |
1487 | .off1 = td_var_offset(fallocate_mode), | |
1488 | .help = "Whether pre-allocation is performed when laying out files", | |
1489 | .def = "posix", | |
e8b0e958 JA |
1490 | .category = FIO_OPT_C_FILE, |
1491 | .group = FIO_OPT_G_INVALID, | |
a596f047 EG |
1492 | .posval = { |
1493 | { .ival = "none", | |
1494 | .oval = FIO_FALLOCATE_NONE, | |
1495 | .help = "Do not pre-allocate space", | |
1496 | }, | |
1497 | { .ival = "posix", | |
1498 | .oval = FIO_FALLOCATE_POSIX, | |
1499 | .help = "Use posix_fallocate()", | |
1500 | }, | |
1501 | #ifdef FIO_HAVE_LINUX_FALLOCATE | |
1502 | { .ival = "keep", | |
1503 | .oval = FIO_FALLOCATE_KEEP_SIZE, | |
1504 | .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", | |
1505 | }, | |
7bc8c2cf | 1506 | #endif |
a596f047 EG |
1507 | /* Compatibility with former boolean values */ |
1508 | { .ival = "0", | |
1509 | .oval = FIO_FALLOCATE_NONE, | |
1510 | .help = "Alias for 'none'", | |
1511 | }, | |
1512 | { .ival = "1", | |
1513 | .oval = FIO_FALLOCATE_POSIX, | |
1514 | .help = "Alias for 'posix'", | |
1515 | }, | |
1516 | }, | |
1517 | }, | |
1518 | #endif /* FIO_HAVE_FALLOCATE */ | |
67a1000f JA |
1519 | { |
1520 | .name = "fadvise_hint", | |
e8b0e958 | 1521 | .lname = "Fadvise hint", |
67a1000f JA |
1522 | .type = FIO_OPT_BOOL, |
1523 | .off1 = td_var_offset(fadvise_hint), | |
1524 | .help = "Use fadvise() to advise the kernel on IO pattern", | |
1525 | .def = "1", | |
e8b0e958 JA |
1526 | .category = FIO_OPT_C_FILE, |
1527 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1528 | }, |
1529 | { | |
1530 | .name = "fsync", | |
e8b0e958 | 1531 | .lname = "Fsync", |
214e1eca JA |
1532 | .type = FIO_OPT_INT, |
1533 | .off1 = td_var_offset(fsync_blocks), | |
1534 | .help = "Issue fsync for writes every given number of blocks", | |
1535 | .def = "0", | |
20eb06bd | 1536 | .interval = 1, |
e8b0e958 JA |
1537 | .category = FIO_OPT_C_FILE, |
1538 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 1539 | }, |
5f9099ea JA |
1540 | { |
1541 | .name = "fdatasync", | |
e8b0e958 | 1542 | .lname = "Fdatasync", |
5f9099ea JA |
1543 | .type = FIO_OPT_INT, |
1544 | .off1 = td_var_offset(fdatasync_blocks), | |
1545 | .help = "Issue fdatasync for writes every given number of blocks", | |
1546 | .def = "0", | |
20eb06bd | 1547 | .interval = 1, |
e8b0e958 JA |
1548 | .category = FIO_OPT_C_FILE, |
1549 | .group = FIO_OPT_G_INVALID, | |
5f9099ea | 1550 | }, |
1ef2b6be JA |
1551 | { |
1552 | .name = "write_barrier", | |
e8b0e958 | 1553 | .lname = "Write barrier", |
1ef2b6be JA |
1554 | .type = FIO_OPT_INT, |
1555 | .off1 = td_var_offset(barrier_blocks), | |
1556 | .help = "Make every Nth write a barrier write", | |
1557 | .def = "0", | |
20eb06bd | 1558 | .interval = 1, |
e8b0e958 JA |
1559 | .category = FIO_OPT_C_IO, |
1560 | .group = FIO_OPT_G_INVALID, | |
1ef2b6be | 1561 | }, |
44f29692 JA |
1562 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
1563 | { | |
1564 | .name = "sync_file_range", | |
e8b0e958 | 1565 | .lname = "Sync file range", |
44f29692 JA |
1566 | .posval = { |
1567 | { .ival = "wait_before", | |
1568 | .oval = SYNC_FILE_RANGE_WAIT_BEFORE, | |
1569 | .help = "SYNC_FILE_RANGE_WAIT_BEFORE", | |
3843deb3 | 1570 | .or = 1, |
44f29692 JA |
1571 | }, |
1572 | { .ival = "write", | |
1573 | .oval = SYNC_FILE_RANGE_WRITE, | |
1574 | .help = "SYNC_FILE_RANGE_WRITE", | |
3843deb3 | 1575 | .or = 1, |
44f29692 JA |
1576 | }, |
1577 | { | |
1578 | .ival = "wait_after", | |
1579 | .oval = SYNC_FILE_RANGE_WAIT_AFTER, | |
1580 | .help = "SYNC_FILE_RANGE_WAIT_AFTER", | |
3843deb3 | 1581 | .or = 1, |
44f29692 JA |
1582 | }, |
1583 | }, | |
3843deb3 | 1584 | .type = FIO_OPT_STR_MULTI, |
44f29692 JA |
1585 | .cb = str_sfr_cb, |
1586 | .off1 = td_var_offset(sync_file_range), | |
1587 | .help = "Use sync_file_range()", | |
e8b0e958 JA |
1588 | .category = FIO_OPT_C_FILE, |
1589 | .group = FIO_OPT_G_INVALID, | |
44f29692 JA |
1590 | }, |
1591 | #endif | |
214e1eca JA |
1592 | { |
1593 | .name = "direct", | |
e8b0e958 | 1594 | .lname = "Direct I/O", |
214e1eca JA |
1595 | .type = FIO_OPT_BOOL, |
1596 | .off1 = td_var_offset(odirect), | |
1597 | .help = "Use O_DIRECT IO (negates buffered)", | |
1598 | .def = "0", | |
e8b0e958 JA |
1599 | .category = FIO_OPT_C_IO, |
1600 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1601 | }, |
1602 | { | |
1603 | .name = "buffered", | |
e8b0e958 | 1604 | .lname = "Buffered I/O", |
214e1eca JA |
1605 | .type = FIO_OPT_BOOL, |
1606 | .off1 = td_var_offset(odirect), | |
1607 | .neg = 1, | |
1608 | .help = "Use buffered IO (negates direct)", | |
1609 | .def = "1", | |
e8b0e958 JA |
1610 | .category = FIO_OPT_C_IO, |
1611 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1612 | }, |
1613 | { | |
1614 | .name = "overwrite", | |
e8b0e958 | 1615 | .lname = "Overwrite", |
214e1eca JA |
1616 | .type = FIO_OPT_BOOL, |
1617 | .off1 = td_var_offset(overwrite), | |
1618 | .help = "When writing, set whether to overwrite current data", | |
1619 | .def = "0", | |
e8b0e958 JA |
1620 | .category = FIO_OPT_C_FILE, |
1621 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1622 | }, |
1623 | { | |
1624 | .name = "loops", | |
e8b0e958 | 1625 | .lname = "Loops", |
214e1eca JA |
1626 | .type = FIO_OPT_INT, |
1627 | .off1 = td_var_offset(loops), | |
1628 | .help = "Number of times to run the job", | |
1629 | .def = "1", | |
20eb06bd | 1630 | .interval = 1, |
e8b0e958 | 1631 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1632 | .group = FIO_OPT_G_RUNTIME, |
214e1eca JA |
1633 | }, |
1634 | { | |
1635 | .name = "numjobs", | |
e8b0e958 | 1636 | .lname = "Number of jobs", |
214e1eca JA |
1637 | .type = FIO_OPT_INT, |
1638 | .off1 = td_var_offset(numjobs), | |
1639 | .help = "Duplicate this job this many times", | |
1640 | .def = "1", | |
20eb06bd | 1641 | .interval = 1, |
e8b0e958 | 1642 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1643 | .group = FIO_OPT_G_RUNTIME, |
214e1eca JA |
1644 | }, |
1645 | { | |
1646 | .name = "startdelay", | |
e8b0e958 | 1647 | .lname = "Start delay", |
a5737c93 | 1648 | .type = FIO_OPT_STR_VAL_TIME, |
214e1eca JA |
1649 | .off1 = td_var_offset(start_delay), |
1650 | .help = "Only start job when this period has passed", | |
1651 | .def = "0", | |
e8b0e958 | 1652 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1653 | .group = FIO_OPT_G_RUNTIME, |
214e1eca JA |
1654 | }, |
1655 | { | |
1656 | .name = "runtime", | |
e8b0e958 | 1657 | .lname = "Runtime", |
214e1eca JA |
1658 | .alias = "timeout", |
1659 | .type = FIO_OPT_STR_VAL_TIME, | |
1660 | .off1 = td_var_offset(timeout), | |
1661 | .help = "Stop workload when this amount of time has passed", | |
1662 | .def = "0", | |
e8b0e958 | 1663 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1664 | .group = FIO_OPT_G_RUNTIME, |
214e1eca | 1665 | }, |
cf4464ca JA |
1666 | { |
1667 | .name = "time_based", | |
e8b0e958 | 1668 | .lname = "Time based", |
cf4464ca JA |
1669 | .type = FIO_OPT_STR_SET, |
1670 | .off1 = td_var_offset(time_based), | |
1671 | .help = "Keep running until runtime/timeout is met", | |
e8b0e958 | 1672 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1673 | .group = FIO_OPT_G_RUNTIME, |
cf4464ca | 1674 | }, |
721938ae JA |
1675 | { |
1676 | .name = "ramp_time", | |
e8b0e958 | 1677 | .lname = "Ramp time", |
721938ae JA |
1678 | .type = FIO_OPT_STR_VAL_TIME, |
1679 | .off1 = td_var_offset(ramp_time), | |
1680 | .help = "Ramp up time before measuring performance", | |
e8b0e958 | 1681 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 1682 | .group = FIO_OPT_G_RUNTIME, |
721938ae | 1683 | }, |
c223da83 JA |
1684 | { |
1685 | .name = "clocksource", | |
e8b0e958 | 1686 | .lname = "Clock source", |
c223da83 JA |
1687 | .type = FIO_OPT_STR, |
1688 | .cb = fio_clock_source_cb, | |
1689 | .off1 = td_var_offset(clocksource), | |
1690 | .help = "What type of timing source to use", | |
e8b0e958 | 1691 | .category = FIO_OPT_C_GENERAL, |
10860056 | 1692 | .group = FIO_OPT_G_CLOCK, |
c223da83 JA |
1693 | .posval = { |
1694 | { .ival = "gettimeofday", | |
1695 | .oval = CS_GTOD, | |
1696 | .help = "Use gettimeofday(2) for timing", | |
1697 | }, | |
1698 | { .ival = "clock_gettime", | |
1699 | .oval = CS_CGETTIME, | |
1700 | .help = "Use clock_gettime(2) for timing", | |
1701 | }, | |
1702 | #ifdef ARCH_HAVE_CPU_CLOCK | |
1703 | { .ival = "cpu", | |
1704 | .oval = CS_CPUCLOCK, | |
1705 | .help = "Use CPU private clock", | |
1706 | }, | |
1707 | #endif | |
1708 | }, | |
1709 | }, | |
214e1eca JA |
1710 | { |
1711 | .name = "mem", | |
d3aad8f2 | 1712 | .alias = "iomem", |
e8b0e958 | 1713 | .lname = "I/O Memory", |
214e1eca JA |
1714 | .type = FIO_OPT_STR, |
1715 | .cb = str_mem_cb, | |
1716 | .off1 = td_var_offset(mem_type), | |
1717 | .help = "Backing type for IO buffers", | |
1718 | .def = "malloc", | |
e8b0e958 JA |
1719 | .category = FIO_OPT_C_IO, |
1720 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1721 | .posval = { |
1722 | { .ival = "malloc", | |
1723 | .oval = MEM_MALLOC, | |
1724 | .help = "Use malloc(3) for IO buffers", | |
1725 | }, | |
37c8cdfe JA |
1726 | { .ival = "shm", |
1727 | .oval = MEM_SHM, | |
1728 | .help = "Use shared memory segments for IO buffers", | |
1729 | }, | |
214e1eca JA |
1730 | #ifdef FIO_HAVE_HUGETLB |
1731 | { .ival = "shmhuge", | |
1732 | .oval = MEM_SHMHUGE, | |
1733 | .help = "Like shm, but use huge pages", | |
1734 | }, | |
b370e46a | 1735 | #endif |
37c8cdfe JA |
1736 | { .ival = "mmap", |
1737 | .oval = MEM_MMAP, | |
1738 | .help = "Use mmap(2) (file or anon) for IO buffers", | |
1739 | }, | |
214e1eca JA |
1740 | #ifdef FIO_HAVE_HUGETLB |
1741 | { .ival = "mmaphuge", | |
1742 | .oval = MEM_MMAPHUGE, | |
1743 | .help = "Like mmap, but use huge pages", | |
1744 | }, | |
1745 | #endif | |
1746 | }, | |
1747 | }, | |
d529ee19 JA |
1748 | { |
1749 | .name = "iomem_align", | |
1750 | .alias = "mem_align", | |
e8b0e958 | 1751 | .lname = "I/O memory alignment", |
d529ee19 JA |
1752 | .type = FIO_OPT_INT, |
1753 | .off1 = td_var_offset(mem_align), | |
1754 | .minval = 0, | |
1755 | .help = "IO memory buffer offset alignment", | |
1756 | .def = "0", | |
1757 | .parent = "iomem", | |
d71c154c | 1758 | .hide = 1, |
e8b0e958 JA |
1759 | .category = FIO_OPT_C_IO, |
1760 | .group = FIO_OPT_G_INVALID, | |
d529ee19 | 1761 | }, |
214e1eca JA |
1762 | { |
1763 | .name = "verify", | |
e8b0e958 | 1764 | .lname = "Verify", |
214e1eca JA |
1765 | .type = FIO_OPT_STR, |
1766 | .off1 = td_var_offset(verify), | |
1767 | .help = "Verify data written", | |
5d7c5d34 | 1768 | .cb = str_verify_cb, |
214e1eca | 1769 | .def = "0", |
e8b0e958 JA |
1770 | .category = FIO_OPT_C_IO, |
1771 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
1772 | .posval = { |
1773 | { .ival = "0", | |
1774 | .oval = VERIFY_NONE, | |
1775 | .help = "Don't do IO verification", | |
1776 | }, | |
fcca4b58 JA |
1777 | { .ival = "md5", |
1778 | .oval = VERIFY_MD5, | |
1779 | .help = "Use md5 checksums for verification", | |
1780 | }, | |
d77a7af3 JA |
1781 | { .ival = "crc64", |
1782 | .oval = VERIFY_CRC64, | |
1783 | .help = "Use crc64 checksums for verification", | |
1784 | }, | |
214e1eca JA |
1785 | { .ival = "crc32", |
1786 | .oval = VERIFY_CRC32, | |
1787 | .help = "Use crc32 checksums for verification", | |
1788 | }, | |
af497e6a | 1789 | { .ival = "crc32c-intel", |
e3aaafc4 JA |
1790 | .oval = VERIFY_CRC32C, |
1791 | .help = "Use crc32c checksums for verification (hw assisted, if available)", | |
af497e6a | 1792 | }, |
bac39e0e JA |
1793 | { .ival = "crc32c", |
1794 | .oval = VERIFY_CRC32C, | |
e3aaafc4 | 1795 | .help = "Use crc32c checksums for verification (hw assisted, if available)", |
bac39e0e | 1796 | }, |
969f7ed3 JA |
1797 | { .ival = "crc16", |
1798 | .oval = VERIFY_CRC16, | |
1799 | .help = "Use crc16 checksums for verification", | |
1800 | }, | |
1e154bdb JA |
1801 | { .ival = "crc7", |
1802 | .oval = VERIFY_CRC7, | |
1803 | .help = "Use crc7 checksums for verification", | |
1804 | }, | |
7c353ceb JA |
1805 | { .ival = "sha1", |
1806 | .oval = VERIFY_SHA1, | |
1807 | .help = "Use sha1 checksums for verification", | |
1808 | }, | |
cd14cc10 JA |
1809 | { .ival = "sha256", |
1810 | .oval = VERIFY_SHA256, | |
1811 | .help = "Use sha256 checksums for verification", | |
1812 | }, | |
1813 | { .ival = "sha512", | |
1814 | .oval = VERIFY_SHA512, | |
1815 | .help = "Use sha512 checksums for verification", | |
1816 | }, | |
7437ee87 SL |
1817 | { .ival = "meta", |
1818 | .oval = VERIFY_META, | |
1819 | .help = "Use io information", | |
1820 | }, | |
36690c9b JA |
1821 | { |
1822 | .ival = "null", | |
1823 | .oval = VERIFY_NULL, | |
1824 | .help = "Pretend to verify", | |
1825 | }, | |
214e1eca JA |
1826 | }, |
1827 | }, | |
005c565a JA |
1828 | { |
1829 | .name = "do_verify", | |
e8b0e958 | 1830 | .lname = "Perform verify step", |
68e1f29a | 1831 | .type = FIO_OPT_BOOL, |
005c565a JA |
1832 | .off1 = td_var_offset(do_verify), |
1833 | .help = "Run verification stage after write", | |
1834 | .def = "1", | |
1835 | .parent = "verify", | |
d71c154c | 1836 | .hide = 1, |
e8b0e958 JA |
1837 | .category = FIO_OPT_C_IO, |
1838 | .group = FIO_OPT_G_VERIFY, | |
005c565a | 1839 | }, |
160b966d JA |
1840 | { |
1841 | .name = "verifysort", | |
e8b0e958 | 1842 | .lname = "Verify sort", |
160b966d JA |
1843 | .type = FIO_OPT_BOOL, |
1844 | .off1 = td_var_offset(verifysort), | |
1845 | .help = "Sort written verify blocks for read back", | |
1846 | .def = "1", | |
c83f2df1 | 1847 | .parent = "verify", |
d71c154c | 1848 | .hide = 1, |
e8b0e958 JA |
1849 | .category = FIO_OPT_C_IO, |
1850 | .group = FIO_OPT_G_VERIFY, | |
160b966d | 1851 | }, |
3f9f4e26 | 1852 | { |
a59e170d | 1853 | .name = "verify_interval", |
e8b0e958 | 1854 | .lname = "Verify interval", |
e01b22b8 | 1855 | .type = FIO_OPT_INT, |
a59e170d | 1856 | .off1 = td_var_offset(verify_interval), |
819a9680 | 1857 | .minval = 2 * sizeof(struct verify_header), |
a59e170d | 1858 | .help = "Store verify buffer header every N bytes", |
afdf9352 | 1859 | .parent = "verify", |
d71c154c | 1860 | .hide = 1, |
20eb06bd | 1861 | .interval = 2 * sizeof(struct verify_header), |
e8b0e958 JA |
1862 | .category = FIO_OPT_C_IO, |
1863 | .group = FIO_OPT_G_VERIFY, | |
3f9f4e26 | 1864 | }, |
546a9142 | 1865 | { |
a59e170d | 1866 | .name = "verify_offset", |
e8b0e958 | 1867 | .lname = "Verify offset", |
e01b22b8 | 1868 | .type = FIO_OPT_INT, |
a59e170d | 1869 | .help = "Offset verify header location by N bytes", |
546a9142 | 1870 | .def = "0", |
5ec10eaa | 1871 | .cb = str_verify_offset_cb, |
afdf9352 | 1872 | .parent = "verify", |
d71c154c | 1873 | .hide = 1, |
e8b0e958 JA |
1874 | .category = FIO_OPT_C_IO, |
1875 | .group = FIO_OPT_G_VERIFY, | |
546a9142 | 1876 | }, |
e28218f3 SL |
1877 | { |
1878 | .name = "verify_pattern", | |
e8b0e958 | 1879 | .lname = "Verify pattern", |
0e92f873 | 1880 | .type = FIO_OPT_STR, |
e28218f3 SL |
1881 | .cb = str_verify_pattern_cb, |
1882 | .help = "Fill pattern for IO buffers", | |
1883 | .parent = "verify", | |
d71c154c | 1884 | .hide = 1, |
e8b0e958 JA |
1885 | .category = FIO_OPT_C_IO, |
1886 | .group = FIO_OPT_G_VERIFY, | |
e28218f3 | 1887 | }, |
a12a3b4d JA |
1888 | { |
1889 | .name = "verify_fatal", | |
e8b0e958 | 1890 | .lname = "Verify fatal", |
68e1f29a | 1891 | .type = FIO_OPT_BOOL, |
a12a3b4d JA |
1892 | .off1 = td_var_offset(verify_fatal), |
1893 | .def = "0", | |
1894 | .help = "Exit on a single verify failure, don't continue", | |
1895 | .parent = "verify", | |
d71c154c | 1896 | .hide = 1, |
e8b0e958 JA |
1897 | .category = FIO_OPT_C_IO, |
1898 | .group = FIO_OPT_G_VERIFY, | |
a12a3b4d | 1899 | }, |
b463e936 JA |
1900 | { |
1901 | .name = "verify_dump", | |
e8b0e958 | 1902 | .lname = "Verify dump", |
b463e936 JA |
1903 | .type = FIO_OPT_BOOL, |
1904 | .off1 = td_var_offset(verify_dump), | |
ef71e317 | 1905 | .def = "0", |
b463e936 JA |
1906 | .help = "Dump contents of good and bad blocks on failure", |
1907 | .parent = "verify", | |
d71c154c | 1908 | .hide = 1, |
e8b0e958 JA |
1909 | .category = FIO_OPT_C_IO, |
1910 | .group = FIO_OPT_G_VERIFY, | |
b463e936 | 1911 | }, |
e8462bd8 JA |
1912 | { |
1913 | .name = "verify_async", | |
e8b0e958 | 1914 | .lname = "Verify asynchronously", |
e8462bd8 JA |
1915 | .type = FIO_OPT_INT, |
1916 | .off1 = td_var_offset(verify_async), | |
1917 | .def = "0", | |
1918 | .help = "Number of async verifier threads to use", | |
1919 | .parent = "verify", | |
d71c154c | 1920 | .hide = 1, |
e8b0e958 JA |
1921 | .category = FIO_OPT_C_IO, |
1922 | .group = FIO_OPT_G_VERIFY, | |
e8462bd8 | 1923 | }, |
9e144189 JA |
1924 | { |
1925 | .name = "verify_backlog", | |
e8b0e958 | 1926 | .lname = "Verify backlog", |
9e144189 JA |
1927 | .type = FIO_OPT_STR_VAL, |
1928 | .off1 = td_var_offset(verify_backlog), | |
1929 | .help = "Verify after this number of blocks are written", | |
1930 | .parent = "verify", | |
d71c154c | 1931 | .hide = 1, |
e8b0e958 JA |
1932 | .category = FIO_OPT_C_IO, |
1933 | .group = FIO_OPT_G_VERIFY, | |
9e144189 JA |
1934 | }, |
1935 | { | |
1936 | .name = "verify_backlog_batch", | |
e8b0e958 | 1937 | .lname = "Verify backlog batch", |
9e144189 JA |
1938 | .type = FIO_OPT_INT, |
1939 | .off1 = td_var_offset(verify_batch), | |
1940 | .help = "Verify this number of IO blocks", | |
0d29de83 | 1941 | .parent = "verify", |
d71c154c | 1942 | .hide = 1, |
e8b0e958 JA |
1943 | .category = FIO_OPT_C_IO, |
1944 | .group = FIO_OPT_G_VERIFY, | |
9e144189 | 1945 | }, |
e8462bd8 JA |
1946 | #ifdef FIO_HAVE_CPU_AFFINITY |
1947 | { | |
1948 | .name = "verify_async_cpus", | |
e8b0e958 | 1949 | .lname = "Async verify CPUs", |
e8462bd8 JA |
1950 | .type = FIO_OPT_STR, |
1951 | .cb = str_verify_cpus_allowed_cb, | |
1952 | .help = "Set CPUs allowed for async verify threads", | |
1953 | .parent = "verify_async", | |
d71c154c | 1954 | .hide = 1, |
e8b0e958 JA |
1955 | .category = FIO_OPT_C_IO, |
1956 | .group = FIO_OPT_G_VERIFY, | |
e8462bd8 | 1957 | }, |
0d29de83 JA |
1958 | #endif |
1959 | #ifdef FIO_HAVE_TRIM | |
1960 | { | |
1961 | .name = "trim_percentage", | |
e8b0e958 | 1962 | .lname = "Trim percentage", |
0d29de83 JA |
1963 | .type = FIO_OPT_INT, |
1964 | .cb = str_verify_trim_cb, | |
20eb06bd | 1965 | .minval = 0, |
0d29de83 JA |
1966 | .maxval = 100, |
1967 | .help = "Number of verify blocks to discard/trim", | |
1968 | .parent = "verify", | |
1969 | .def = "0", | |
20eb06bd | 1970 | .interval = 1, |
d71c154c | 1971 | .hide = 1, |
e8b0e958 JA |
1972 | .category = FIO_OPT_C_IO, |
1973 | .group = FIO_OPT_G_TRIM, | |
0d29de83 JA |
1974 | }, |
1975 | { | |
1976 | .name = "trim_verify_zero", | |
e8b0e958 | 1977 | .lname = "Verify trim zero", |
20eb06bd | 1978 | .type = FIO_OPT_BOOL, |
0d29de83 JA |
1979 | .help = "Verify that trim/discarded blocks are returned as zeroes", |
1980 | .off1 = td_var_offset(trim_zero), | |
1981 | .parent = "trim_percentage", | |
d71c154c | 1982 | .hide = 1, |
0d29de83 | 1983 | .def = "1", |
e8b0e958 JA |
1984 | .category = FIO_OPT_C_IO, |
1985 | .group = FIO_OPT_G_TRIM, | |
0d29de83 JA |
1986 | }, |
1987 | { | |
1988 | .name = "trim_backlog", | |
e8b0e958 | 1989 | .lname = "Trim backlog", |
0d29de83 JA |
1990 | .type = FIO_OPT_STR_VAL, |
1991 | .off1 = td_var_offset(trim_backlog), | |
1992 | .help = "Trim after this number of blocks are written", | |
1993 | .parent = "trim_percentage", | |
d71c154c | 1994 | .hide = 1, |
20eb06bd | 1995 | .interval = 1, |
e8b0e958 JA |
1996 | .category = FIO_OPT_C_IO, |
1997 | .group = FIO_OPT_G_TRIM, | |
0d29de83 JA |
1998 | }, |
1999 | { | |
2000 | .name = "trim_backlog_batch", | |
e8b0e958 | 2001 | .lname = "Trim backlog batch", |
0d29de83 JA |
2002 | .type = FIO_OPT_INT, |
2003 | .off1 = td_var_offset(trim_batch), | |
2004 | .help = "Trim this number of IO blocks", | |
2005 | .parent = "trim_percentage", | |
d71c154c | 2006 | .hide = 1, |
20eb06bd | 2007 | .interval = 1, |
e8b0e958 JA |
2008 | .category = FIO_OPT_C_IO, |
2009 | .group = FIO_OPT_G_TRIM, | |
0d29de83 | 2010 | }, |
e8462bd8 | 2011 | #endif |
214e1eca JA |
2012 | { |
2013 | .name = "write_iolog", | |
e8b0e958 | 2014 | .lname = "Write I/O log", |
214e1eca JA |
2015 | .type = FIO_OPT_STR_STORE, |
2016 | .off1 = td_var_offset(write_iolog_file), | |
2017 | .help = "Store IO pattern to file", | |
e8b0e958 JA |
2018 | .category = FIO_OPT_C_IO, |
2019 | .group = FIO_OPT_G_IOLOG, | |
214e1eca JA |
2020 | }, |
2021 | { | |
2022 | .name = "read_iolog", | |
e8b0e958 | 2023 | .lname = "Read I/O log", |
214e1eca JA |
2024 | .type = FIO_OPT_STR_STORE, |
2025 | .off1 = td_var_offset(read_iolog_file), | |
2026 | .help = "Playback IO pattern from file", | |
e8b0e958 JA |
2027 | .category = FIO_OPT_C_IO, |
2028 | .group = FIO_OPT_G_IOLOG, | |
214e1eca | 2029 | }, |
64bbb865 DN |
2030 | { |
2031 | .name = "replay_no_stall", | |
e8b0e958 | 2032 | .lname = "Don't stall on replay", |
20eb06bd | 2033 | .type = FIO_OPT_BOOL, |
64bbb865 DN |
2034 | .off1 = td_var_offset(no_stall), |
2035 | .def = "0", | |
87e7a972 | 2036 | .parent = "read_iolog", |
d71c154c | 2037 | .hide = 1, |
64bbb865 | 2038 | .help = "Playback IO pattern file as fast as possible without stalls", |
e8b0e958 JA |
2039 | .category = FIO_OPT_C_IO, |
2040 | .group = FIO_OPT_G_IOLOG, | |
64bbb865 | 2041 | }, |
d1c46c04 DN |
2042 | { |
2043 | .name = "replay_redirect", | |
e8b0e958 | 2044 | .lname = "Redirect device for replay", |
d1c46c04 DN |
2045 | .type = FIO_OPT_STR_STORE, |
2046 | .off1 = td_var_offset(replay_redirect), | |
2047 | .parent = "read_iolog", | |
d71c154c | 2048 | .hide = 1, |
d1c46c04 | 2049 | .help = "Replay all I/O onto this device, regardless of trace device", |
e8b0e958 JA |
2050 | .category = FIO_OPT_C_IO, |
2051 | .group = FIO_OPT_G_IOLOG, | |
d1c46c04 | 2052 | }, |
214e1eca JA |
2053 | { |
2054 | .name = "exec_prerun", | |
e8b0e958 | 2055 | .lname = "Pre-execute runnable", |
214e1eca JA |
2056 | .type = FIO_OPT_STR_STORE, |
2057 | .off1 = td_var_offset(exec_prerun), | |
2058 | .help = "Execute this file prior to running job", | |
e8b0e958 JA |
2059 | .category = FIO_OPT_C_GENERAL, |
2060 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2061 | }, |
2062 | { | |
2063 | .name = "exec_postrun", | |
e8b0e958 | 2064 | .lname = "Post-execute runnable", |
214e1eca JA |
2065 | .type = FIO_OPT_STR_STORE, |
2066 | .off1 = td_var_offset(exec_postrun), | |
2067 | .help = "Execute this file after running job", | |
e8b0e958 JA |
2068 | .category = FIO_OPT_C_GENERAL, |
2069 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2070 | }, |
2071 | #ifdef FIO_HAVE_IOSCHED_SWITCH | |
2072 | { | |
2073 | .name = "ioscheduler", | |
e8b0e958 | 2074 | .lname = "I/O scheduler", |
214e1eca JA |
2075 | .type = FIO_OPT_STR_STORE, |
2076 | .off1 = td_var_offset(ioscheduler), | |
2077 | .help = "Use this IO scheduler on the backing device", | |
e8b0e958 JA |
2078 | .category = FIO_OPT_C_FILE, |
2079 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2080 | }, |
2081 | #endif | |
2082 | { | |
2083 | .name = "zonesize", | |
e8b0e958 | 2084 | .lname = "Zone size", |
214e1eca JA |
2085 | .type = FIO_OPT_STR_VAL, |
2086 | .off1 = td_var_offset(zone_size), | |
ed335855 SN |
2087 | .help = "Amount of data to read per zone", |
2088 | .def = "0", | |
20eb06bd | 2089 | .interval = 1024 * 1024, |
e8b0e958 JA |
2090 | .category = FIO_OPT_C_IO, |
2091 | .group = FIO_OPT_G_ZONE, | |
ed335855 SN |
2092 | }, |
2093 | { | |
2094 | .name = "zonerange", | |
e8b0e958 | 2095 | .lname = "Zone range", |
ed335855 SN |
2096 | .type = FIO_OPT_STR_VAL, |
2097 | .off1 = td_var_offset(zone_range), | |
214e1eca JA |
2098 | .help = "Give size of an IO zone", |
2099 | .def = "0", | |
20eb06bd | 2100 | .interval = 1024 * 1024, |
e8b0e958 JA |
2101 | .category = FIO_OPT_C_IO, |
2102 | .group = FIO_OPT_G_ZONE, | |
214e1eca JA |
2103 | }, |
2104 | { | |
2105 | .name = "zoneskip", | |
e8b0e958 | 2106 | .lname = "Zone skip", |
214e1eca JA |
2107 | .type = FIO_OPT_STR_VAL, |
2108 | .off1 = td_var_offset(zone_skip), | |
2109 | .help = "Space between IO zones", | |
2110 | .def = "0", | |
20eb06bd | 2111 | .interval = 1024 * 1024, |
e8b0e958 JA |
2112 | .category = FIO_OPT_C_IO, |
2113 | .group = FIO_OPT_G_ZONE, | |
214e1eca JA |
2114 | }, |
2115 | { | |
2116 | .name = "lockmem", | |
e8b0e958 | 2117 | .lname = "Lock memory", |
214e1eca JA |
2118 | .type = FIO_OPT_STR_VAL, |
2119 | .cb = str_lockmem_cb, | |
2120 | .help = "Lock down this amount of memory", | |
2121 | .def = "0", | |
20eb06bd | 2122 | .interval = 1024 * 1024, |
e8b0e958 JA |
2123 | .category = FIO_OPT_C_GENERAL, |
2124 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 2125 | }, |
214e1eca JA |
2126 | { |
2127 | .name = "rwmixread", | |
e8b0e958 | 2128 | .lname = "Read/write mix read", |
214e1eca | 2129 | .type = FIO_OPT_INT, |
cb499fc4 | 2130 | .cb = str_rwmix_read_cb, |
214e1eca JA |
2131 | .maxval = 100, |
2132 | .help = "Percentage of mixed workload that is reads", | |
2133 | .def = "50", | |
20eb06bd | 2134 | .interval = 5, |
90265353 | 2135 | .inverse = "rwmixwrite", |
e8b0e958 JA |
2136 | .category = FIO_OPT_C_IO, |
2137 | .group = FIO_OPT_G_RWMIX, | |
214e1eca JA |
2138 | }, |
2139 | { | |
2140 | .name = "rwmixwrite", | |
e8b0e958 | 2141 | .lname = "Read/write mix write", |
214e1eca | 2142 | .type = FIO_OPT_INT, |
cb499fc4 | 2143 | .cb = str_rwmix_write_cb, |
214e1eca JA |
2144 | .maxval = 100, |
2145 | .help = "Percentage of mixed workload that is writes", | |
2146 | .def = "50", | |
20eb06bd | 2147 | .interval = 5, |
90265353 | 2148 | .inverse = "rwmixread", |
e8b0e958 JA |
2149 | .category = FIO_OPT_C_IO, |
2150 | .group = FIO_OPT_G_RWMIX, | |
214e1eca | 2151 | }, |
afdf9352 JA |
2152 | { |
2153 | .name = "rwmixcycle", | |
e8b0e958 | 2154 | .lname = "Read/write mix cycle", |
15ca150e | 2155 | .type = FIO_OPT_DEPRECATED, |
e8b0e958 JA |
2156 | .category = FIO_OPT_C_IO, |
2157 | .group = FIO_OPT_G_RWMIX, | |
afdf9352 | 2158 | }, |
214e1eca JA |
2159 | { |
2160 | .name = "nice", | |
e8b0e958 | 2161 | .lname = "Nice", |
214e1eca JA |
2162 | .type = FIO_OPT_INT, |
2163 | .off1 = td_var_offset(nice), | |
2164 | .help = "Set job CPU nice value", | |
2165 | .minval = -19, | |
2166 | .maxval = 20, | |
2167 | .def = "0", | |
20eb06bd | 2168 | .interval = 1, |
e8b0e958 | 2169 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2170 | .group = FIO_OPT_G_CRED, |
214e1eca JA |
2171 | }, |
2172 | #ifdef FIO_HAVE_IOPRIO | |
2173 | { | |
2174 | .name = "prio", | |
e8b0e958 | 2175 | .lname = "I/O nice priority", |
214e1eca JA |
2176 | .type = FIO_OPT_INT, |
2177 | .cb = str_prio_cb, | |
2178 | .help = "Set job IO priority value", | |
2179 | .minval = 0, | |
2180 | .maxval = 7, | |
20eb06bd | 2181 | .interval = 1, |
e8b0e958 | 2182 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2183 | .group = FIO_OPT_G_CRED, |
214e1eca JA |
2184 | }, |
2185 | { | |
2186 | .name = "prioclass", | |
e8b0e958 | 2187 | .lname = "I/O nice priority class", |
214e1eca JA |
2188 | .type = FIO_OPT_INT, |
2189 | .cb = str_prioclass_cb, | |
2190 | .help = "Set job IO priority class", | |
2191 | .minval = 0, | |
2192 | .maxval = 3, | |
20eb06bd | 2193 | .interval = 1, |
e8b0e958 | 2194 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2195 | .group = FIO_OPT_G_CRED, |
214e1eca JA |
2196 | }, |
2197 | #endif | |
2198 | { | |
2199 | .name = "thinktime", | |
e8b0e958 | 2200 | .lname = "Thinktime", |
214e1eca JA |
2201 | .type = FIO_OPT_INT, |
2202 | .off1 = td_var_offset(thinktime), | |
2203 | .help = "Idle time between IO buffers (usec)", | |
2204 | .def = "0", | |
e8b0e958 JA |
2205 | .category = FIO_OPT_C_IO, |
2206 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2207 | }, |
2208 | { | |
2209 | .name = "thinktime_spin", | |
e8b0e958 | 2210 | .lname = "Thinktime spin", |
214e1eca JA |
2211 | .type = FIO_OPT_INT, |
2212 | .off1 = td_var_offset(thinktime_spin), | |
2213 | .help = "Start think time by spinning this amount (usec)", | |
2214 | .def = "0", | |
afdf9352 | 2215 | .parent = "thinktime", |
d71c154c | 2216 | .hide = 1, |
e8b0e958 JA |
2217 | .category = FIO_OPT_C_IO, |
2218 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2219 | }, |
2220 | { | |
2221 | .name = "thinktime_blocks", | |
e8b0e958 | 2222 | .lname = "Thinktime blocks", |
214e1eca JA |
2223 | .type = FIO_OPT_INT, |
2224 | .off1 = td_var_offset(thinktime_blocks), | |
2225 | .help = "IO buffer period between 'thinktime'", | |
2226 | .def = "1", | |
afdf9352 | 2227 | .parent = "thinktime", |
d71c154c | 2228 | .hide = 1, |
e8b0e958 JA |
2229 | .category = FIO_OPT_C_IO, |
2230 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2231 | }, |
2232 | { | |
2233 | .name = "rate", | |
e8b0e958 | 2234 | .lname = "I/O rate", |
e01b22b8 | 2235 | .type = FIO_OPT_INT, |
581e7141 JA |
2236 | .off1 = td_var_offset(rate[0]), |
2237 | .off2 = td_var_offset(rate[1]), | |
214e1eca | 2238 | .help = "Set bandwidth rate", |
e8b0e958 JA |
2239 | .category = FIO_OPT_C_IO, |
2240 | .group = FIO_OPT_G_RATE, | |
214e1eca JA |
2241 | }, |
2242 | { | |
2243 | .name = "ratemin", | |
e8b0e958 | 2244 | .lname = "I/O min rate", |
e01b22b8 | 2245 | .type = FIO_OPT_INT, |
581e7141 JA |
2246 | .off1 = td_var_offset(ratemin[0]), |
2247 | .off2 = td_var_offset(ratemin[1]), | |
4e991c23 | 2248 | .help = "Job must meet this rate or it will be shutdown", |
afdf9352 | 2249 | .parent = "rate", |
d71c154c | 2250 | .hide = 1, |
e8b0e958 JA |
2251 | .category = FIO_OPT_C_IO, |
2252 | .group = FIO_OPT_G_RATE, | |
4e991c23 JA |
2253 | }, |
2254 | { | |
2255 | .name = "rate_iops", | |
e8b0e958 | 2256 | .lname = "I/O rate IOPS", |
e01b22b8 | 2257 | .type = FIO_OPT_INT, |
581e7141 JA |
2258 | .off1 = td_var_offset(rate_iops[0]), |
2259 | .off2 = td_var_offset(rate_iops[1]), | |
4e991c23 | 2260 | .help = "Limit IO used to this number of IO operations/sec", |
d71c154c | 2261 | .hide = 1, |
e8b0e958 JA |
2262 | .category = FIO_OPT_C_IO, |
2263 | .group = FIO_OPT_G_RATE, | |
4e991c23 JA |
2264 | }, |
2265 | { | |
2266 | .name = "rate_iops_min", | |
e8b0e958 | 2267 | .lname = "I/O min rate IOPS", |
e01b22b8 | 2268 | .type = FIO_OPT_INT, |
581e7141 JA |
2269 | .off1 = td_var_offset(rate_iops_min[0]), |
2270 | .off2 = td_var_offset(rate_iops_min[1]), | |
03e20d68 | 2271 | .help = "Job must meet this rate or it will be shut down", |
afdf9352 | 2272 | .parent = "rate_iops", |
d71c154c | 2273 | .hide = 1, |
e8b0e958 JA |
2274 | .category = FIO_OPT_C_IO, |
2275 | .group = FIO_OPT_G_RATE, | |
214e1eca JA |
2276 | }, |
2277 | { | |
2278 | .name = "ratecycle", | |
e8b0e958 | 2279 | .lname = "I/O rate cycle", |
214e1eca JA |
2280 | .type = FIO_OPT_INT, |
2281 | .off1 = td_var_offset(ratecycle), | |
2282 | .help = "Window average for rate limits (msec)", | |
2283 | .def = "1000", | |
afdf9352 | 2284 | .parent = "rate", |
d71c154c | 2285 | .hide = 1, |
e8b0e958 JA |
2286 | .category = FIO_OPT_C_IO, |
2287 | .group = FIO_OPT_G_RATE, | |
214e1eca JA |
2288 | }, |
2289 | { | |
2290 | .name = "invalidate", | |
e8b0e958 | 2291 | .lname = "Cache invalidate", |
214e1eca JA |
2292 | .type = FIO_OPT_BOOL, |
2293 | .off1 = td_var_offset(invalidate_cache), | |
2294 | .help = "Invalidate buffer/page cache prior to running job", | |
2295 | .def = "1", | |
e8b0e958 JA |
2296 | .category = FIO_OPT_C_IO, |
2297 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2298 | }, |
2299 | { | |
2300 | .name = "sync", | |
e8b0e958 | 2301 | .lname = "Synchronous I/O", |
214e1eca JA |
2302 | .type = FIO_OPT_BOOL, |
2303 | .off1 = td_var_offset(sync_io), | |
2304 | .help = "Use O_SYNC for buffered writes", | |
2305 | .def = "0", | |
67a1000f | 2306 | .parent = "buffered", |
d71c154c | 2307 | .hide = 1, |
e8b0e958 JA |
2308 | .category = FIO_OPT_C_IO, |
2309 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2310 | }, |
2311 | { | |
2312 | .name = "bwavgtime", | |
e8b0e958 | 2313 | .lname = "Bandwidth average time", |
214e1eca JA |
2314 | .type = FIO_OPT_INT, |
2315 | .off1 = td_var_offset(bw_avg_time), | |
5ec10eaa JA |
2316 | .help = "Time window over which to calculate bandwidth" |
2317 | " (msec)", | |
214e1eca | 2318 | .def = "500", |
c8eeb9df | 2319 | .parent = "write_bw_log", |
d71c154c | 2320 | .hide = 1, |
20eb06bd | 2321 | .interval = 100, |
e8b0e958 JA |
2322 | .category = FIO_OPT_C_LOG, |
2323 | .group = FIO_OPT_G_INVALID, | |
c8eeb9df JA |
2324 | }, |
2325 | { | |
2326 | .name = "iopsavgtime", | |
e8b0e958 | 2327 | .lname = "IOPS average time", |
c8eeb9df JA |
2328 | .type = FIO_OPT_INT, |
2329 | .off1 = td_var_offset(iops_avg_time), | |
2330 | .help = "Time window over which to calculate IOPS (msec)", | |
2331 | .def = "500", | |
2332 | .parent = "write_iops_log", | |
d71c154c | 2333 | .hide = 1, |
20eb06bd | 2334 | .interval = 100, |
e8b0e958 JA |
2335 | .category = FIO_OPT_C_LOG, |
2336 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2337 | }, |
2338 | { | |
2339 | .name = "create_serialize", | |
e8b0e958 | 2340 | .lname = "Create serialize", |
214e1eca JA |
2341 | .type = FIO_OPT_BOOL, |
2342 | .off1 = td_var_offset(create_serialize), | |
2343 | .help = "Serialize creating of job files", | |
2344 | .def = "1", | |
e8b0e958 JA |
2345 | .category = FIO_OPT_C_FILE, |
2346 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2347 | }, |
2348 | { | |
2349 | .name = "create_fsync", | |
e8b0e958 | 2350 | .lname = "Create fsync", |
214e1eca JA |
2351 | .type = FIO_OPT_BOOL, |
2352 | .off1 = td_var_offset(create_fsync), | |
03e20d68 | 2353 | .help = "fsync file after creation", |
214e1eca | 2354 | .def = "1", |
e8b0e958 JA |
2355 | .category = FIO_OPT_C_FILE, |
2356 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 2357 | }, |
814452bd JA |
2358 | { |
2359 | .name = "create_on_open", | |
e8b0e958 | 2360 | .lname = "Create on open", |
814452bd JA |
2361 | .type = FIO_OPT_BOOL, |
2362 | .off1 = td_var_offset(create_on_open), | |
2363 | .help = "Create files when they are opened for IO", | |
2364 | .def = "0", | |
e8b0e958 JA |
2365 | .category = FIO_OPT_C_FILE, |
2366 | .group = FIO_OPT_G_INVALID, | |
814452bd | 2367 | }, |
0b9d69ec | 2368 | { |
afad68f7 | 2369 | .name = "pre_read", |
e8b0e958 | 2370 | .lname = "Pre-read files", |
afad68f7 ZY |
2371 | .type = FIO_OPT_BOOL, |
2372 | .off1 = td_var_offset(pre_read), | |
03e20d68 | 2373 | .help = "Pre-read files before starting official testing", |
afad68f7 | 2374 | .def = "0", |
e8b0e958 JA |
2375 | .category = FIO_OPT_C_FILE, |
2376 | .group = FIO_OPT_G_INVALID, | |
afad68f7 | 2377 | }, |
214e1eca JA |
2378 | { |
2379 | .name = "cpuload", | |
e8b0e958 | 2380 | .lname = "CPU load", |
214e1eca JA |
2381 | .type = FIO_OPT_INT, |
2382 | .off1 = td_var_offset(cpuload), | |
2383 | .help = "Use this percentage of CPU", | |
e8b0e958 JA |
2384 | .category = FIO_OPT_C_GENERAL, |
2385 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2386 | }, |
2387 | { | |
2388 | .name = "cpuchunks", | |
e8b0e958 | 2389 | .lname = "CPU chunk", |
214e1eca JA |
2390 | .type = FIO_OPT_INT, |
2391 | .off1 = td_var_offset(cpucycle), | |
2392 | .help = "Length of the CPU burn cycles (usecs)", | |
2393 | .def = "50000", | |
67a1000f | 2394 | .parent = "cpuload", |
d71c154c | 2395 | .hide = 1, |
e8b0e958 JA |
2396 | .category = FIO_OPT_C_GENERAL, |
2397 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2398 | }, |
2399 | #ifdef FIO_HAVE_CPU_AFFINITY | |
2400 | { | |
2401 | .name = "cpumask", | |
e8b0e958 | 2402 | .lname = "CPU mask", |
214e1eca JA |
2403 | .type = FIO_OPT_INT, |
2404 | .cb = str_cpumask_cb, | |
2405 | .help = "CPU affinity mask", | |
e8b0e958 | 2406 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2407 | .group = FIO_OPT_G_CRED, |
214e1eca | 2408 | }, |
d2e268b0 JA |
2409 | { |
2410 | .name = "cpus_allowed", | |
e8b0e958 | 2411 | .lname = "CPUs allowed", |
d2e268b0 JA |
2412 | .type = FIO_OPT_STR, |
2413 | .cb = str_cpus_allowed_cb, | |
2414 | .help = "Set CPUs allowed", | |
e8b0e958 | 2415 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2416 | .group = FIO_OPT_G_CRED, |
d2e268b0 | 2417 | }, |
214e1eca JA |
2418 | #endif |
2419 | { | |
2420 | .name = "end_fsync", | |
e8b0e958 | 2421 | .lname = "End fsync", |
214e1eca JA |
2422 | .type = FIO_OPT_BOOL, |
2423 | .off1 = td_var_offset(end_fsync), | |
2424 | .help = "Include fsync at the end of job", | |
2425 | .def = "0", | |
e8b0e958 JA |
2426 | .category = FIO_OPT_C_FILE, |
2427 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2428 | }, |
2429 | { | |
2430 | .name = "fsync_on_close", | |
e8b0e958 | 2431 | .lname = "Fsync on close", |
214e1eca JA |
2432 | .type = FIO_OPT_BOOL, |
2433 | .off1 = td_var_offset(fsync_on_close), | |
2434 | .help = "fsync files on close", | |
2435 | .def = "0", | |
e8b0e958 JA |
2436 | .category = FIO_OPT_C_FILE, |
2437 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2438 | }, |
2439 | { | |
2440 | .name = "unlink", | |
e8b0e958 | 2441 | .lname = "Unlink file", |
214e1eca JA |
2442 | .type = FIO_OPT_BOOL, |
2443 | .off1 = td_var_offset(unlink), | |
2444 | .help = "Unlink created files after job has completed", | |
2445 | .def = "0", | |
e8b0e958 JA |
2446 | .category = FIO_OPT_C_FILE, |
2447 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2448 | }, |
2449 | { | |
2450 | .name = "exitall", | |
e8b0e958 | 2451 | .lname = "Exit-all on terminate", |
214e1eca JA |
2452 | .type = FIO_OPT_STR_SET, |
2453 | .cb = str_exitall_cb, | |
2454 | .help = "Terminate all jobs when one exits", | |
e8b0e958 | 2455 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 2456 | .group = FIO_OPT_G_PROCESS, |
214e1eca JA |
2457 | }, |
2458 | { | |
2459 | .name = "stonewall", | |
e8b0e958 | 2460 | .lname = "Wait for previous", |
d392365e | 2461 | .alias = "wait_for_previous", |
214e1eca JA |
2462 | .type = FIO_OPT_STR_SET, |
2463 | .off1 = td_var_offset(stonewall), | |
2464 | .help = "Insert a hard barrier between this job and previous", | |
e8b0e958 | 2465 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 2466 | .group = FIO_OPT_G_PROCESS, |
214e1eca | 2467 | }, |
b3d62a75 JA |
2468 | { |
2469 | .name = "new_group", | |
e8b0e958 | 2470 | .lname = "New group", |
b3d62a75 JA |
2471 | .type = FIO_OPT_STR_SET, |
2472 | .off1 = td_var_offset(new_group), | |
2473 | .help = "Mark the start of a new group (for reporting)", | |
e8b0e958 | 2474 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 2475 | .group = FIO_OPT_G_PROCESS, |
b3d62a75 | 2476 | }, |
214e1eca JA |
2477 | { |
2478 | .name = "thread", | |
e8b0e958 | 2479 | .lname = "Thread", |
214e1eca JA |
2480 | .type = FIO_OPT_STR_SET, |
2481 | .off1 = td_var_offset(use_thread), | |
20eb06bd | 2482 | .help = "Use threads instead of processes", |
e8b0e958 | 2483 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 2484 | .group = FIO_OPT_G_PROCESS, |
214e1eca JA |
2485 | }, |
2486 | { | |
2487 | .name = "write_bw_log", | |
e8b0e958 | 2488 | .lname = "Write bandwidth log", |
e3cedca7 | 2489 | .type = FIO_OPT_STR, |
214e1eca | 2490 | .off1 = td_var_offset(write_bw_log), |
e3cedca7 | 2491 | .cb = str_write_bw_log_cb, |
214e1eca | 2492 | .help = "Write log of bandwidth during run", |
e8b0e958 JA |
2493 | .category = FIO_OPT_C_LOG, |
2494 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2495 | }, |
2496 | { | |
2497 | .name = "write_lat_log", | |
e8b0e958 | 2498 | .lname = "Write latency log", |
e3cedca7 | 2499 | .type = FIO_OPT_STR, |
214e1eca | 2500 | .off1 = td_var_offset(write_lat_log), |
e3cedca7 | 2501 | .cb = str_write_lat_log_cb, |
214e1eca | 2502 | .help = "Write log of latency during run", |
e8b0e958 JA |
2503 | .category = FIO_OPT_C_LOG, |
2504 | .group = FIO_OPT_G_INVALID, | |
214e1eca | 2505 | }, |
c8eeb9df JA |
2506 | { |
2507 | .name = "write_iops_log", | |
e8b0e958 | 2508 | .lname = "Write IOPS log", |
c8eeb9df JA |
2509 | .type = FIO_OPT_STR, |
2510 | .off1 = td_var_offset(write_iops_log), | |
2511 | .cb = str_write_iops_log_cb, | |
2512 | .help = "Write log of IOPS during run", | |
e8b0e958 JA |
2513 | .category = FIO_OPT_C_LOG, |
2514 | .group = FIO_OPT_G_INVALID, | |
c8eeb9df | 2515 | }, |
b8bc8cba JA |
2516 | { |
2517 | .name = "log_avg_msec", | |
e8b0e958 | 2518 | .lname = "Log averaging (msec)", |
b8bc8cba JA |
2519 | .type = FIO_OPT_INT, |
2520 | .off1 = td_var_offset(log_avg_msec), | |
2521 | .help = "Average bw/iops/lat logs over this period of time", | |
2522 | .def = "0", | |
e8b0e958 JA |
2523 | .category = FIO_OPT_C_LOG, |
2524 | .group = FIO_OPT_G_INVALID, | |
b8bc8cba | 2525 | }, |
214e1eca JA |
2526 | { |
2527 | .name = "hugepage-size", | |
e8b0e958 | 2528 | .lname = "Hugepage size", |
e01b22b8 | 2529 | .type = FIO_OPT_INT, |
214e1eca JA |
2530 | .off1 = td_var_offset(hugepage_size), |
2531 | .help = "When using hugepages, specify size of each page", | |
81179eec | 2532 | .def = __fio_stringify(FIO_HUGE_PAGE), |
20eb06bd | 2533 | .interval = 1024 * 1024, |
e8b0e958 JA |
2534 | .category = FIO_OPT_C_GENERAL, |
2535 | .group = FIO_OPT_G_INVALID, | |
214e1eca JA |
2536 | }, |
2537 | { | |
2538 | .name = "group_reporting", | |
e8b0e958 JA |
2539 | .lname = "Group reporting", |
2540 | .type = FIO_OPT_BOOL, | |
214e1eca JA |
2541 | .off1 = td_var_offset(group_reporting), |
2542 | .help = "Do reporting on a per-group basis", | |
e8b0e958 | 2543 | .def = "1", |
10860056 | 2544 | .category = FIO_OPT_C_STAT, |
e8b0e958 | 2545 | .group = FIO_OPT_G_INVALID, |
214e1eca | 2546 | }, |
e9459e5a JA |
2547 | { |
2548 | .name = "zero_buffers", | |
e8b0e958 | 2549 | .lname = "Zero I/O buffers", |
e9459e5a JA |
2550 | .type = FIO_OPT_STR_SET, |
2551 | .off1 = td_var_offset(zero_buffers), | |
2552 | .help = "Init IO buffers to all zeroes", | |
e8b0e958 JA |
2553 | .category = FIO_OPT_C_IO, |
2554 | .group = FIO_OPT_G_INVALID, | |
e9459e5a | 2555 | }, |
5973cafb JA |
2556 | { |
2557 | .name = "refill_buffers", | |
e8b0e958 | 2558 | .lname = "Refill I/O buffers", |
5973cafb JA |
2559 | .type = FIO_OPT_STR_SET, |
2560 | .off1 = td_var_offset(refill_buffers), | |
2561 | .help = "Refill IO buffers on every IO submit", | |
e8b0e958 JA |
2562 | .category = FIO_OPT_C_IO, |
2563 | .group = FIO_OPT_G_INVALID, | |
5973cafb | 2564 | }, |
fd68418e JA |
2565 | { |
2566 | .name = "scramble_buffers", | |
e8b0e958 | 2567 | .lname = "Scramble I/O buffers", |
fd68418e JA |
2568 | .type = FIO_OPT_BOOL, |
2569 | .off1 = td_var_offset(scramble_buffers), | |
2570 | .help = "Slightly scramble buffers on every IO submit", | |
2571 | .def = "1", | |
e8b0e958 JA |
2572 | .category = FIO_OPT_C_IO, |
2573 | .group = FIO_OPT_G_INVALID, | |
fd68418e | 2574 | }, |
9c42684e JA |
2575 | { |
2576 | .name = "buffer_compress_percentage", | |
e8b0e958 | 2577 | .lname = "Buffer compression percentage", |
9c42684e JA |
2578 | .type = FIO_OPT_INT, |
2579 | .off1 = td_var_offset(compress_percentage), | |
2580 | .maxval = 100, | |
2581 | .minval = 1, | |
2582 | .help = "How compressible the buffer is (approximately)", | |
20eb06bd | 2583 | .interval = 5, |
e8b0e958 JA |
2584 | .category = FIO_OPT_C_IO, |
2585 | .group = FIO_OPT_G_INVALID, | |
9c42684e | 2586 | }, |
f97a43a1 JA |
2587 | { |
2588 | .name = "buffer_compress_chunk", | |
e8b0e958 | 2589 | .lname = "Buffer compression chunk size", |
f97a43a1 JA |
2590 | .type = FIO_OPT_INT, |
2591 | .off1 = td_var_offset(compress_chunk), | |
207b18e4 | 2592 | .parent = "buffer_compress_percentage", |
d71c154c | 2593 | .hide = 1, |
f97a43a1 | 2594 | .help = "Size of compressible region in buffer", |
20eb06bd | 2595 | .interval = 256, |
e8b0e958 JA |
2596 | .category = FIO_OPT_C_IO, |
2597 | .group = FIO_OPT_G_INVALID, | |
f97a43a1 | 2598 | }, |
83349190 YH |
2599 | { |
2600 | .name = "clat_percentiles", | |
e8b0e958 | 2601 | .lname = "Completion latency percentiles", |
83349190 YH |
2602 | .type = FIO_OPT_BOOL, |
2603 | .off1 = td_var_offset(clat_percentiles), | |
2604 | .help = "Enable the reporting of completion latency percentiles", | |
467b35ed | 2605 | .def = "1", |
e8b0e958 JA |
2606 | .category = FIO_OPT_C_STAT, |
2607 | .group = FIO_OPT_G_INVALID, | |
83349190 YH |
2608 | }, |
2609 | { | |
2610 | .name = "percentile_list", | |
e8b0e958 | 2611 | .lname = "Completion latency percentile list", |
83349190 YH |
2612 | .type = FIO_OPT_FLOAT_LIST, |
2613 | .off1 = td_var_offset(percentile_list), | |
2614 | .off2 = td_var_offset(overwrite_plist), | |
2615 | .help = "Specify a custom list of percentiles to report", | |
2616 | .maxlen = FIO_IO_U_LIST_MAX_LEN, | |
2617 | .minfp = 0.0, | |
2618 | .maxfp = 100.0, | |
e8b0e958 JA |
2619 | .category = FIO_OPT_C_STAT, |
2620 | .group = FIO_OPT_G_INVALID, | |
83349190 YH |
2621 | }, |
2622 | ||
0a839f30 JA |
2623 | #ifdef FIO_HAVE_DISK_UTIL |
2624 | { | |
2625 | .name = "disk_util", | |
e8b0e958 | 2626 | .lname = "Disk utilization", |
0a839f30 JA |
2627 | .type = FIO_OPT_BOOL, |
2628 | .off1 = td_var_offset(do_disk_util), | |
f66ab3c8 | 2629 | .help = "Log disk utilization statistics", |
0a839f30 | 2630 | .def = "1", |
e8b0e958 JA |
2631 | .category = FIO_OPT_C_STAT, |
2632 | .group = FIO_OPT_G_INVALID, | |
0a839f30 JA |
2633 | }, |
2634 | #endif | |
993bf48b JA |
2635 | { |
2636 | .name = "gtod_reduce", | |
e8b0e958 | 2637 | .lname = "Reduce gettimeofday() calls", |
993bf48b JA |
2638 | .type = FIO_OPT_BOOL, |
2639 | .help = "Greatly reduce number of gettimeofday() calls", | |
2640 | .cb = str_gtod_reduce_cb, | |
2641 | .def = "0", | |
e8b0e958 JA |
2642 | .category = FIO_OPT_C_STAT, |
2643 | .group = FIO_OPT_G_INVALID, | |
993bf48b | 2644 | }, |
02af0988 JA |
2645 | { |
2646 | .name = "disable_lat", | |
e8b0e958 | 2647 | .lname = "Disable all latency stats", |
02af0988 JA |
2648 | .type = FIO_OPT_BOOL, |
2649 | .off1 = td_var_offset(disable_lat), | |
2650 | .help = "Disable latency numbers", | |
2651 | .parent = "gtod_reduce", | |
d71c154c | 2652 | .hide = 1, |
02af0988 | 2653 | .def = "0", |
e8b0e958 JA |
2654 | .category = FIO_OPT_C_STAT, |
2655 | .group = FIO_OPT_G_INVALID, | |
02af0988 | 2656 | }, |
9520ebb9 JA |
2657 | { |
2658 | .name = "disable_clat", | |
e8b0e958 | 2659 | .lname = "Disable completion latency stats", |
9520ebb9 JA |
2660 | .type = FIO_OPT_BOOL, |
2661 | .off1 = td_var_offset(disable_clat), | |
2662 | .help = "Disable completion latency numbers", | |
993bf48b | 2663 | .parent = "gtod_reduce", |
d71c154c | 2664 | .hide = 1, |
9520ebb9 | 2665 | .def = "0", |
e8b0e958 JA |
2666 | .category = FIO_OPT_C_STAT, |
2667 | .group = FIO_OPT_G_INVALID, | |
9520ebb9 JA |
2668 | }, |
2669 | { | |
2670 | .name = "disable_slat", | |
e8b0e958 | 2671 | .lname = "Disable submission latency stats", |
9520ebb9 JA |
2672 | .type = FIO_OPT_BOOL, |
2673 | .off1 = td_var_offset(disable_slat), | |
03e20d68 | 2674 | .help = "Disable submission latency numbers", |
993bf48b | 2675 | .parent = "gtod_reduce", |
d71c154c | 2676 | .hide = 1, |
9520ebb9 | 2677 | .def = "0", |
e8b0e958 JA |
2678 | .category = FIO_OPT_C_STAT, |
2679 | .group = FIO_OPT_G_INVALID, | |
9520ebb9 JA |
2680 | }, |
2681 | { | |
2682 | .name = "disable_bw_measurement", | |
e8b0e958 | 2683 | .lname = "Disable bandwidth stats", |
9520ebb9 JA |
2684 | .type = FIO_OPT_BOOL, |
2685 | .off1 = td_var_offset(disable_bw), | |
2686 | .help = "Disable bandwidth logging", | |
993bf48b | 2687 | .parent = "gtod_reduce", |
d71c154c | 2688 | .hide = 1, |
9520ebb9 | 2689 | .def = "0", |
e8b0e958 JA |
2690 | .category = FIO_OPT_C_STAT, |
2691 | .group = FIO_OPT_G_INVALID, | |
9520ebb9 | 2692 | }, |
be4ecfdf JA |
2693 | { |
2694 | .name = "gtod_cpu", | |
e8b0e958 | 2695 | .lname = "Dedicated gettimeofday() CPU", |
be4ecfdf JA |
2696 | .type = FIO_OPT_INT, |
2697 | .cb = str_gtod_cpu_cb, | |
03e20d68 | 2698 | .help = "Set up dedicated gettimeofday() thread on this CPU", |
29d43ff9 | 2699 | .verify = gtod_cpu_verify, |
e8b0e958 | 2700 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2701 | .group = FIO_OPT_G_CLOCK, |
be4ecfdf | 2702 | }, |
f2bba182 RR |
2703 | { |
2704 | .name = "continue_on_error", | |
e8b0e958 | 2705 | .lname = "Continue on error", |
06842027 | 2706 | .type = FIO_OPT_STR, |
f2bba182 | 2707 | .off1 = td_var_offset(continue_on_error), |
03e20d68 | 2708 | .help = "Continue on non-fatal errors during IO", |
06842027 | 2709 | .def = "none", |
e8b0e958 JA |
2710 | .category = FIO_OPT_C_GENERAL, |
2711 | .group = FIO_OPT_G_INVALID, | |
06842027 SL |
2712 | .posval = { |
2713 | { .ival = "none", | |
2714 | .oval = ERROR_TYPE_NONE, | |
2715 | .help = "Exit when an error is encountered", | |
2716 | }, | |
2717 | { .ival = "read", | |
2718 | .oval = ERROR_TYPE_READ, | |
2719 | .help = "Continue on read errors only", | |
2720 | }, | |
2721 | { .ival = "write", | |
2722 | .oval = ERROR_TYPE_WRITE, | |
2723 | .help = "Continue on write errors only", | |
2724 | }, | |
2725 | { .ival = "io", | |
2726 | .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE, | |
2727 | .help = "Continue on any IO errors", | |
2728 | }, | |
2729 | { .ival = "verify", | |
2730 | .oval = ERROR_TYPE_VERIFY, | |
2731 | .help = "Continue on verify errors only", | |
2732 | }, | |
2733 | { .ival = "all", | |
2734 | .oval = ERROR_TYPE_ANY, | |
2735 | .help = "Continue on all io and verify errors", | |
2736 | }, | |
2737 | { .ival = "0", | |
2738 | .oval = ERROR_TYPE_NONE, | |
2739 | .help = "Alias for 'none'", | |
2740 | }, | |
2741 | { .ival = "1", | |
2742 | .oval = ERROR_TYPE_ANY, | |
2743 | .help = "Alias for 'all'", | |
2744 | }, | |
2745 | }, | |
f2bba182 | 2746 | }, |
9ac8a797 JA |
2747 | { |
2748 | .name = "profile", | |
e8b0e958 | 2749 | .lname = "Profile", |
79d16311 | 2750 | .type = FIO_OPT_STR_STORE, |
9ac8a797 | 2751 | .off1 = td_var_offset(profile), |
9ac8a797 | 2752 | .help = "Select a specific builtin performance test", |
e8b0e958 JA |
2753 | .category = FIO_OPT_C_GENERAL, |
2754 | .group = FIO_OPT_G_INVALID, | |
9ac8a797 | 2755 | }, |
a696fa2a JA |
2756 | { |
2757 | .name = "cgroup", | |
e8b0e958 | 2758 | .lname = "Cgroup", |
a696fa2a JA |
2759 | .type = FIO_OPT_STR_STORE, |
2760 | .off1 = td_var_offset(cgroup), | |
2761 | .help = "Add job to cgroup of this name", | |
e8b0e958 | 2762 | .category = FIO_OPT_C_GENERAL, |
a1f6afec JA |
2763 | .group = FIO_OPT_G_CGROUP, |
2764 | }, | |
2765 | { | |
2766 | .name = "cgroup_nodelete", | |
2767 | .lname = "Cgroup no-delete", | |
2768 | .type = FIO_OPT_BOOL, | |
2769 | .off1 = td_var_offset(cgroup_nodelete), | |
2770 | .help = "Do not delete cgroups after job completion", | |
2771 | .def = "0", | |
2772 | .parent = "cgroup", | |
2773 | .category = FIO_OPT_C_GENERAL, | |
2774 | .group = FIO_OPT_G_CGROUP, | |
a696fa2a JA |
2775 | }, |
2776 | { | |
2777 | .name = "cgroup_weight", | |
e8b0e958 | 2778 | .lname = "Cgroup weight", |
a696fa2a JA |
2779 | .type = FIO_OPT_INT, |
2780 | .off1 = td_var_offset(cgroup_weight), | |
2781 | .help = "Use given weight for cgroup", | |
2782 | .minval = 100, | |
2783 | .maxval = 1000, | |
a1f6afec | 2784 | .parent = "cgroup", |
e8b0e958 | 2785 | .category = FIO_OPT_C_GENERAL, |
a1f6afec | 2786 | .group = FIO_OPT_G_CGROUP, |
7de87099 | 2787 | }, |
e0b0d892 JA |
2788 | { |
2789 | .name = "uid", | |
e8b0e958 | 2790 | .lname = "User ID", |
e0b0d892 JA |
2791 | .type = FIO_OPT_INT, |
2792 | .off1 = td_var_offset(uid), | |
2793 | .help = "Run job with this user ID", | |
e8b0e958 | 2794 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2795 | .group = FIO_OPT_G_CRED, |
e0b0d892 JA |
2796 | }, |
2797 | { | |
2798 | .name = "gid", | |
e8b0e958 | 2799 | .lname = "Group ID", |
e0b0d892 JA |
2800 | .type = FIO_OPT_INT, |
2801 | .off1 = td_var_offset(gid), | |
2802 | .help = "Run job with this group ID", | |
e8b0e958 | 2803 | .category = FIO_OPT_C_GENERAL, |
10860056 | 2804 | .group = FIO_OPT_G_CRED, |
e0b0d892 | 2805 | }, |
a1f6afec JA |
2806 | { |
2807 | .name = "kb_base", | |
2808 | .lname = "KB Base", | |
2809 | .type = FIO_OPT_INT, | |
2810 | .off1 = td_var_offset(kb_base), | |
2811 | .verify = kb_base_verify, | |
2812 | .prio = 1, | |
2813 | .def = "1024", | |
2814 | .help = "How many bytes per KB for reporting (1000 or 1024)", | |
2815 | .category = FIO_OPT_C_GENERAL, | |
2816 | .group = FIO_OPT_G_INVALID, | |
2817 | }, | |
9e684a49 DE |
2818 | { |
2819 | .name = "flow_id", | |
e8b0e958 | 2820 | .lname = "I/O flow ID", |
9e684a49 DE |
2821 | .type = FIO_OPT_INT, |
2822 | .off1 = td_var_offset(flow_id), | |
2823 | .help = "The flow index ID to use", | |
2824 | .def = "0", | |
e8b0e958 JA |
2825 | .category = FIO_OPT_C_IO, |
2826 | .group = FIO_OPT_G_IO_FLOW, | |
9e684a49 DE |
2827 | }, |
2828 | { | |
2829 | .name = "flow", | |
e8b0e958 | 2830 | .lname = "I/O flow weight", |
9e684a49 DE |
2831 | .type = FIO_OPT_INT, |
2832 | .off1 = td_var_offset(flow), | |
2833 | .help = "Weight for flow control of this job", | |
2834 | .parent = "flow_id", | |
d71c154c | 2835 | .hide = 1, |
9e684a49 | 2836 | .def = "0", |
e8b0e958 JA |
2837 | .category = FIO_OPT_C_IO, |
2838 | .group = FIO_OPT_G_IO_FLOW, | |
9e684a49 DE |
2839 | }, |
2840 | { | |
2841 | .name = "flow_watermark", | |
e8b0e958 | 2842 | .lname = "I/O flow watermark", |
9e684a49 DE |
2843 | .type = FIO_OPT_INT, |
2844 | .off1 = td_var_offset(flow_watermark), | |
2845 | .help = "High watermark for flow control. This option" | |
2846 | " should be set to the same value for all threads" | |
2847 | " with non-zero flow.", | |
2848 | .parent = "flow_id", | |
d71c154c | 2849 | .hide = 1, |
9e684a49 | 2850 | .def = "1024", |
e8b0e958 JA |
2851 | .category = FIO_OPT_C_IO, |
2852 | .group = FIO_OPT_G_IO_FLOW, | |
9e684a49 DE |
2853 | }, |
2854 | { | |
2855 | .name = "flow_sleep", | |
e8b0e958 | 2856 | .lname = "I/O flow sleep", |
9e684a49 DE |
2857 | .type = FIO_OPT_INT, |
2858 | .off1 = td_var_offset(flow_sleep), | |
2859 | .help = "How many microseconds to sleep after being held" | |
2860 | " back by the flow control mechanism", | |
2861 | .parent = "flow_id", | |
d71c154c | 2862 | .hide = 1, |
9e684a49 | 2863 | .def = "0", |
e8b0e958 JA |
2864 | .category = FIO_OPT_C_IO, |
2865 | .group = FIO_OPT_G_IO_FLOW, | |
9e684a49 | 2866 | }, |
214e1eca JA |
2867 | { |
2868 | .name = NULL, | |
2869 | }, | |
2870 | }; | |
2871 | ||
17af15d4 | 2872 | static void add_to_lopt(struct option *lopt, struct fio_option *o, |
de890a1e | 2873 | const char *name, int val) |
9f81736c | 2874 | { |
17af15d4 | 2875 | lopt->name = (char *) name; |
de890a1e | 2876 | lopt->val = val; |
9f81736c JA |
2877 | if (o->type == FIO_OPT_STR_SET) |
2878 | lopt->has_arg = no_argument; | |
2879 | else | |
2880 | lopt->has_arg = required_argument; | |
2881 | } | |
2882 | ||
de890a1e SL |
2883 | static void options_to_lopts(struct fio_option *opts, |
2884 | struct option *long_options, | |
2885 | int i, int option_type) | |
214e1eca | 2886 | { |
de890a1e | 2887 | struct fio_option *o = &opts[0]; |
214e1eca | 2888 | while (o->name) { |
de890a1e | 2889 | add_to_lopt(&long_options[i], o, o->name, option_type); |
17af15d4 JA |
2890 | if (o->alias) { |
2891 | i++; | |
de890a1e | 2892 | add_to_lopt(&long_options[i], o, o->alias, option_type); |
17af15d4 | 2893 | } |
214e1eca JA |
2894 | |
2895 | i++; | |
2896 | o++; | |
2897 | assert(i < FIO_NR_OPTIONS); | |
2898 | } | |
2899 | } | |
2900 | ||
de890a1e SL |
2901 | void fio_options_set_ioengine_opts(struct option *long_options, |
2902 | struct thread_data *td) | |
2903 | { | |
2904 | unsigned int i; | |
2905 | ||
2906 | i = 0; | |
2907 | while (long_options[i].name) { | |
2908 | if (long_options[i].val == FIO_GETOPT_IOENGINE) { | |
2909 | memset(&long_options[i], 0, sizeof(*long_options)); | |
2910 | break; | |
2911 | } | |
2912 | i++; | |
2913 | } | |
2914 | ||
2915 | /* | |
2916 | * Just clear out the prior ioengine options. | |
2917 | */ | |
2918 | if (!td || !td->eo) | |
2919 | return; | |
2920 | ||
2921 | options_to_lopts(td->io_ops->options, long_options, i, | |
2922 | FIO_GETOPT_IOENGINE); | |
2923 | } | |
2924 | ||
2925 | void fio_options_dup_and_init(struct option *long_options) | |
2926 | { | |
2927 | unsigned int i; | |
2928 | ||
9af4a244 | 2929 | options_init(fio_options); |
de890a1e SL |
2930 | |
2931 | i = 0; | |
2932 | while (long_options[i].name) | |
2933 | i++; | |
2934 | ||
9af4a244 | 2935 | options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB); |
de890a1e SL |
2936 | } |
2937 | ||
74929ac2 JA |
2938 | struct fio_keyword { |
2939 | const char *word; | |
2940 | const char *desc; | |
2941 | char *replace; | |
2942 | }; | |
2943 | ||
2944 | static struct fio_keyword fio_keywords[] = { | |
2945 | { | |
2946 | .word = "$pagesize", | |
2947 | .desc = "Page size in the system", | |
2948 | }, | |
2949 | { | |
2950 | .word = "$mb_memory", | |
2951 | .desc = "Megabytes of memory online", | |
2952 | }, | |
2953 | { | |
2954 | .word = "$ncpus", | |
2955 | .desc = "Number of CPUs online in the system", | |
2956 | }, | |
2957 | { | |
2958 | .word = NULL, | |
2959 | }, | |
2960 | }; | |
2961 | ||
2962 | void fio_keywords_init(void) | |
2963 | { | |
3b2e1464 | 2964 | unsigned long long mb_memory; |
74929ac2 JA |
2965 | char buf[128]; |
2966 | long l; | |
2967 | ||
2968 | sprintf(buf, "%lu", page_size); | |
2969 | fio_keywords[0].replace = strdup(buf); | |
2970 | ||
8eb016d3 | 2971 | mb_memory = os_phys_mem() / (1024 * 1024); |
3b2e1464 | 2972 | sprintf(buf, "%llu", mb_memory); |
74929ac2 JA |
2973 | fio_keywords[1].replace = strdup(buf); |
2974 | ||
c00a2289 | 2975 | l = cpus_online(); |
74929ac2 JA |
2976 | sprintf(buf, "%lu", l); |
2977 | fio_keywords[2].replace = strdup(buf); | |
2978 | } | |
2979 | ||
892a6ffc JA |
2980 | #define BC_APP "bc" |
2981 | ||
2982 | static char *bc_calc(char *str) | |
2983 | { | |
d0c814ec | 2984 | char buf[128], *tmp; |
892a6ffc JA |
2985 | FILE *f; |
2986 | int ret; | |
2987 | ||
2988 | /* | |
2989 | * No math, just return string | |
2990 | */ | |
d0c814ec SL |
2991 | if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && |
2992 | !strchr(str, '/')) || strchr(str, '\'')) | |
892a6ffc JA |
2993 | return str; |
2994 | ||
2995 | /* | |
2996 | * Split option from value, we only need to calculate the value | |
2997 | */ | |
2998 | tmp = strchr(str, '='); | |
2999 | if (!tmp) | |
3000 | return str; | |
3001 | ||
3002 | tmp++; | |
892a6ffc | 3003 | |
d0c814ec SL |
3004 | /* |
3005 | * Prevent buffer overflows; such a case isn't reasonable anyway | |
3006 | */ | |
3007 | if (strlen(str) >= 128 || strlen(tmp) > 100) | |
3008 | return str; | |
892a6ffc JA |
3009 | |
3010 | sprintf(buf, "which %s > /dev/null", BC_APP); | |
3011 | if (system(buf)) { | |
3012 | log_err("fio: bc is needed for performing math\n"); | |
892a6ffc JA |
3013 | return NULL; |
3014 | } | |
3015 | ||
d0c814ec | 3016 | sprintf(buf, "echo '%s' | %s", tmp, BC_APP); |
892a6ffc JA |
3017 | f = popen(buf, "r"); |
3018 | if (!f) { | |
892a6ffc JA |
3019 | return NULL; |
3020 | } | |
3021 | ||
d0c814ec | 3022 | ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f); |
892a6ffc | 3023 | if (ret <= 0) { |
892a6ffc JA |
3024 | return NULL; |
3025 | } | |
3026 | ||
892a6ffc | 3027 | pclose(f); |
d0c814ec SL |
3028 | buf[(tmp - str) + ret - 1] = '\0'; |
3029 | memcpy(buf, str, tmp - str); | |
892a6ffc | 3030 | free(str); |
d0c814ec SL |
3031 | return strdup(buf); |
3032 | } | |
3033 | ||
3034 | /* | |
3035 | * Return a copy of the input string with substrings of the form ${VARNAME} | |
3036 | * substituted with the value of the environment variable VARNAME. The | |
3037 | * substitution always occurs, even if VARNAME is empty or the corresponding | |
3038 | * environment variable undefined. | |
3039 | */ | |
3040 | static char *option_dup_subs(const char *opt) | |
3041 | { | |
3042 | char out[OPT_LEN_MAX+1]; | |
3043 | char in[OPT_LEN_MAX+1]; | |
3044 | char *outptr = out; | |
3045 | char *inptr = in; | |
3046 | char *ch1, *ch2, *env; | |
3047 | ssize_t nchr = OPT_LEN_MAX; | |
3048 | size_t envlen; | |
3049 | ||
3050 | if (strlen(opt) + 1 > OPT_LEN_MAX) { | |
3051 | log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); | |
3052 | return NULL; | |
3053 | } | |
3054 | ||
3055 | in[OPT_LEN_MAX] = '\0'; | |
3056 | strncpy(in, opt, OPT_LEN_MAX); | |
3057 | ||
3058 | while (*inptr && nchr > 0) { | |
3059 | if (inptr[0] == '$' && inptr[1] == '{') { | |
3060 | ch2 = strchr(inptr, '}'); | |
3061 | if (ch2 && inptr+1 < ch2) { | |
3062 | ch1 = inptr+2; | |
3063 | inptr = ch2+1; | |
3064 | *ch2 = '\0'; | |
3065 | ||
3066 | env = getenv(ch1); | |
3067 | if (env) { | |
3068 | envlen = strlen(env); | |
3069 | if (envlen <= nchr) { | |
3070 | memcpy(outptr, env, envlen); | |
3071 | outptr += envlen; | |
3072 | nchr -= envlen; | |
3073 | } | |
3074 | } | |
3075 | ||
3076 | continue; | |
3077 | } | |
3078 | } | |
3079 | ||
3080 | *outptr++ = *inptr++; | |
3081 | --nchr; | |
3082 | } | |
3083 | ||
3084 | *outptr = '\0'; | |
3085 | return strdup(out); | |
892a6ffc JA |
3086 | } |
3087 | ||
74929ac2 JA |
3088 | /* |
3089 | * Look for reserved variable names and replace them with real values | |
3090 | */ | |
3091 | static char *fio_keyword_replace(char *opt) | |
3092 | { | |
3093 | char *s; | |
3094 | int i; | |
d0c814ec | 3095 | int docalc = 0; |
74929ac2 JA |
3096 | |
3097 | for (i = 0; fio_keywords[i].word != NULL; i++) { | |
3098 | struct fio_keyword *kw = &fio_keywords[i]; | |
3099 | ||
3100 | while ((s = strstr(opt, kw->word)) != NULL) { | |
3101 | char *new = malloc(strlen(opt) + 1); | |
3102 | char *o_org = opt; | |
3103 | int olen = s - opt; | |
3104 | int len; | |
3105 | ||
3106 | /* | |
3107 | * Copy part of the string before the keyword and | |
3108 | * sprintf() the replacement after it. | |
3109 | */ | |
3110 | memcpy(new, opt, olen); | |
3111 | len = sprintf(new + olen, "%s", kw->replace); | |
3112 | ||
3113 | /* | |
3114 | * If there's more in the original string, copy that | |
3115 | * in too | |
3116 | */ | |
3117 | opt += strlen(kw->word) + olen; | |
3118 | if (strlen(opt)) | |
3119 | memcpy(new + olen + len, opt, opt - o_org - 1); | |
3120 | ||
3121 | /* | |
3122 | * replace opt and free the old opt | |
3123 | */ | |
3124 | opt = new; | |
d0c814ec | 3125 | free(o_org); |
7a958bd5 | 3126 | |
d0c814ec | 3127 | docalc = 1; |
74929ac2 JA |
3128 | } |
3129 | } | |
3130 | ||
d0c814ec SL |
3131 | /* |
3132 | * Check for potential math and invoke bc, if possible | |
3133 | */ | |
3134 | if (docalc) | |
3135 | opt = bc_calc(opt); | |
3136 | ||
7a958bd5 | 3137 | return opt; |
74929ac2 JA |
3138 | } |
3139 | ||
d0c814ec SL |
3140 | static char **dup_and_sub_options(char **opts, int num_opts) |
3141 | { | |
3142 | int i; | |
3143 | char **opts_copy = malloc(num_opts * sizeof(*opts)); | |
3144 | for (i = 0; i < num_opts; i++) { | |
3145 | opts_copy[i] = option_dup_subs(opts[i]); | |
3146 | if (!opts_copy[i]) | |
3147 | continue; | |
3148 | opts_copy[i] = fio_keyword_replace(opts_copy[i]); | |
3149 | } | |
3150 | return opts_copy; | |
3151 | } | |
3152 | ||
3b8b7135 | 3153 | int fio_options_parse(struct thread_data *td, char **opts, int num_opts) |
214e1eca | 3154 | { |
de890a1e | 3155 | int i, ret, unknown; |
d0c814ec | 3156 | char **opts_copy; |
3b8b7135 | 3157 | |
9af4a244 | 3158 | sort_options(opts, fio_options, num_opts); |
d0c814ec | 3159 | opts_copy = dup_and_sub_options(opts, num_opts); |
3b8b7135 | 3160 | |
de890a1e SL |
3161 | for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) { |
3162 | struct fio_option *o; | |
9af4a244 JA |
3163 | int newret = parse_option(opts_copy[i], opts[i], fio_options, |
3164 | &o, td); | |
d0c814ec | 3165 | |
de890a1e SL |
3166 | if (opts_copy[i]) { |
3167 | if (newret && !o) { | |
3168 | unknown++; | |
3169 | continue; | |
3170 | } | |
d0c814ec | 3171 | free(opts_copy[i]); |
de890a1e SL |
3172 | opts_copy[i] = NULL; |
3173 | } | |
3174 | ||
3175 | ret |= newret; | |
3176 | } | |
3177 | ||
3178 | if (unknown) { | |
3179 | ret |= ioengine_load(td); | |
3180 | if (td->eo) { | |
3181 | sort_options(opts_copy, td->io_ops->options, num_opts); | |
3182 | opts = opts_copy; | |
3183 | } | |
3184 | for (i = 0; i < num_opts; i++) { | |
3185 | struct fio_option *o = NULL; | |
3186 | int newret = 1; | |
3187 | if (!opts_copy[i]) | |
3188 | continue; | |
3189 | ||
3190 | if (td->eo) | |
3191 | newret = parse_option(opts_copy[i], opts[i], | |
3192 | td->io_ops->options, &o, | |
3193 | td->eo); | |
3194 | ||
3195 | ret |= newret; | |
3196 | if (!o) | |
3197 | log_err("Bad option <%s>\n", opts[i]); | |
3198 | ||
3199 | free(opts_copy[i]); | |
3200 | opts_copy[i] = NULL; | |
3201 | } | |
74929ac2 | 3202 | } |
3b8b7135 | 3203 | |
d0c814ec | 3204 | free(opts_copy); |
3b8b7135 | 3205 | return ret; |
214e1eca JA |
3206 | } |
3207 | ||
3208 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) | |
3209 | { | |
9af4a244 | 3210 | return parse_cmd_option(opt, val, fio_options, td); |
214e1eca JA |
3211 | } |
3212 | ||
de890a1e SL |
3213 | int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt, |
3214 | char *val) | |
3215 | { | |
3216 | return parse_cmd_option(opt, val, td->io_ops->options, td); | |
3217 | } | |
3218 | ||
214e1eca JA |
3219 | void fio_fill_default_options(struct thread_data *td) |
3220 | { | |
9af4a244 | 3221 | fill_default_options(td, fio_options); |
214e1eca JA |
3222 | } |
3223 | ||
3224 | int fio_show_option_help(const char *opt) | |
3225 | { | |
9af4a244 | 3226 | return show_cmd_help(fio_options, opt); |
214e1eca | 3227 | } |
d23bb327 | 3228 | |
de890a1e | 3229 | void options_mem_dupe(void *data, struct fio_option *options) |
d23bb327 | 3230 | { |
de890a1e | 3231 | struct fio_option *o; |
d23bb327 | 3232 | char **ptr; |
d23bb327 | 3233 | |
de890a1e SL |
3234 | for (o = &options[0]; o->name; o++) { |
3235 | if (o->type != FIO_OPT_STR_STORE) | |
d23bb327 JA |
3236 | continue; |
3237 | ||
de890a1e | 3238 | ptr = td_var(data, o->off1); |
7e356b2d JA |
3239 | if (*ptr) |
3240 | *ptr = strdup(*ptr); | |
d23bb327 JA |
3241 | } |
3242 | } | |
3243 | ||
de890a1e SL |
3244 | /* |
3245 | * dupe FIO_OPT_STR_STORE options | |
3246 | */ | |
3247 | void fio_options_mem_dupe(struct thread_data *td) | |
3248 | { | |
9af4a244 | 3249 | options_mem_dupe(&td->o, fio_options); |
1647f592 JA |
3250 | |
3251 | if (td->eo && td->io_ops) { | |
de890a1e | 3252 | void *oldeo = td->eo; |
1647f592 | 3253 | |
de890a1e SL |
3254 | td->eo = malloc(td->io_ops->option_struct_size); |
3255 | memcpy(td->eo, oldeo, td->io_ops->option_struct_size); | |
3256 | options_mem_dupe(td->eo, td->io_ops->options); | |
3257 | } | |
3258 | } | |
3259 | ||
d6978a32 JA |
3260 | unsigned int fio_get_kb_base(void *data) |
3261 | { | |
3262 | struct thread_data *td = data; | |
3263 | unsigned int kb_base = 0; | |
3264 | ||
3265 | if (td) | |
3266 | kb_base = td->o.kb_base; | |
3267 | if (!kb_base) | |
3268 | kb_base = 1024; | |
3269 | ||
3270 | return kb_base; | |
3271 | } | |
9f988e2e | 3272 | |
07b3232d | 3273 | int add_option(struct fio_option *o) |
9f988e2e | 3274 | { |
07b3232d JA |
3275 | struct fio_option *__o; |
3276 | int opt_index = 0; | |
3277 | ||
9af4a244 | 3278 | __o = fio_options; |
07b3232d JA |
3279 | while (__o->name) { |
3280 | opt_index++; | |
3281 | __o++; | |
3282 | } | |
3283 | ||
9af4a244 | 3284 | memcpy(&fio_options[opt_index], o, sizeof(*o)); |
07b3232d | 3285 | return 0; |
9f988e2e | 3286 | } |
e2de69da | 3287 | |
07b3232d | 3288 | void invalidate_profile_options(const char *prof_name) |
e2de69da | 3289 | { |
07b3232d | 3290 | struct fio_option *o; |
e2de69da | 3291 | |
9af4a244 | 3292 | o = fio_options; |
07b3232d JA |
3293 | while (o->name) { |
3294 | if (o->prof_name && !strcmp(o->prof_name, prof_name)) { | |
3295 | o->type = FIO_OPT_INVALID; | |
3296 | o->prof_name = NULL; | |
3297 | } | |
3298 | o++; | |
e2de69da JA |
3299 | } |
3300 | } | |
f5b6bb85 JA |
3301 | |
3302 | void add_opt_posval(const char *optname, const char *ival, const char *help) | |
3303 | { | |
3304 | struct fio_option *o; | |
3305 | unsigned int i; | |
3306 | ||
9af4a244 | 3307 | o = find_option(fio_options, optname); |
f5b6bb85 JA |
3308 | if (!o) |
3309 | return; | |
3310 | ||
3311 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
3312 | if (o->posval[i].ival) | |
3313 | continue; | |
3314 | ||
3315 | o->posval[i].ival = ival; | |
3316 | o->posval[i].help = help; | |
3317 | break; | |
3318 | } | |
3319 | } | |
3320 | ||
3321 | void del_opt_posval(const char *optname, const char *ival) | |
3322 | { | |
3323 | struct fio_option *o; | |
3324 | unsigned int i; | |
3325 | ||
9af4a244 | 3326 | o = find_option(fio_options, optname); |
f5b6bb85 JA |
3327 | if (!o) |
3328 | return; | |
3329 | ||
3330 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
3331 | if (!o->posval[i].ival) | |
3332 | continue; | |
3333 | if (strcmp(o->posval[i].ival, ival)) | |
3334 | continue; | |
3335 | ||
3336 | o->posval[i].ival = NULL; | |
3337 | o->posval[i].help = NULL; | |
3338 | } | |
3339 | } | |
7e356b2d JA |
3340 | |
3341 | void fio_options_free(struct thread_data *td) | |
3342 | { | |
9af4a244 | 3343 | options_free(fio_options, td); |
de890a1e SL |
3344 | if (td->eo && td->io_ops && td->io_ops->options) { |
3345 | options_free(td->io_ops->options, td->eo); | |
3346 | free(td->eo); | |
3347 | td->eo = NULL; | |
3348 | } | |
7e356b2d | 3349 | } |