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