Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <ctype.h> |
| 5 | #include <string.h> |
| 6 | #include <getopt.h> |
| 7 | #include <assert.h> |
| 8 | |
| 9 | #include "fio.h" |
| 10 | #include "parse.h" |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 11 | #include "fls.h" |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 12 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 13 | #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var) |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 14 | |
| 15 | /* |
| 16 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. |
| 17 | */ |
| 18 | static char *get_opt_postfix(const char *str) |
| 19 | { |
| 20 | char *p = strstr(str, ":"); |
| 21 | |
| 22 | if (!p) |
| 23 | return NULL; |
| 24 | |
| 25 | p++; |
| 26 | strip_blank_front(&p); |
| 27 | strip_blank_end(p); |
| 28 | return strdup(p); |
| 29 | } |
| 30 | |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 31 | static int bs_cmp(const void *p1, const void *p2) |
| 32 | { |
| 33 | const struct bssplit *bsp1 = p1; |
| 34 | const struct bssplit *bsp2 = p2; |
| 35 | |
| 36 | return bsp1->perc < bsp2->perc; |
| 37 | } |
| 38 | |
| 39 | static int str_bssplit_cb(void *data, const char *input) |
| 40 | { |
| 41 | struct thread_data *td = data; |
| 42 | char *fname, *str, *p; |
| 43 | unsigned int i, perc, perc_missing; |
| 44 | unsigned int max_bs, min_bs; |
| 45 | long long val; |
| 46 | |
| 47 | p = str = strdup(input); |
| 48 | |
| 49 | strip_blank_front(&str); |
| 50 | strip_blank_end(str); |
| 51 | |
| 52 | td->o.bssplit_nr = 4; |
| 53 | td->o.bssplit = malloc(4 * sizeof(struct bssplit)); |
| 54 | |
| 55 | i = 0; |
| 56 | max_bs = 0; |
| 57 | min_bs = -1; |
| 58 | while ((fname = strsep(&str, ":")) != NULL) { |
| 59 | char *perc_str; |
| 60 | |
| 61 | if (!strlen(fname)) |
| 62 | break; |
| 63 | |
| 64 | /* |
| 65 | * grow struct buffer, if needed |
| 66 | */ |
| 67 | if (i == td->o.bssplit_nr) { |
| 68 | td->o.bssplit_nr <<= 1; |
| 69 | td->o.bssplit = realloc(td->o.bssplit, td->o.bssplit_nr * sizeof(struct bssplit)); |
| 70 | } |
| 71 | |
| 72 | perc_str = strstr(fname, "/"); |
| 73 | if (perc_str) { |
| 74 | *perc_str = '\0'; |
| 75 | perc_str++; |
| 76 | perc = atoi(perc_str); |
| 77 | if (perc > 100) |
| 78 | perc = 100; |
| 79 | else if (!perc) |
| 80 | perc = -1; |
| 81 | } else |
| 82 | perc = -1; |
| 83 | |
| 84 | if (str_to_decimal(fname, &val, 1)) { |
| 85 | log_err("fio: bssplit conversion failed\n"); |
| 86 | free(td->o.bssplit); |
| 87 | return 1; |
| 88 | } |
| 89 | |
| 90 | if (val > max_bs) |
| 91 | max_bs = val; |
| 92 | if (val < min_bs) |
| 93 | min_bs = val; |
| 94 | |
| 95 | td->o.bssplit[i].bs = val; |
| 96 | td->o.bssplit[i].perc = perc; |
| 97 | i++; |
| 98 | } |
| 99 | |
| 100 | td->o.bssplit_nr = i; |
| 101 | |
| 102 | /* |
| 103 | * Now check if the percentages add up, and how much is missing |
| 104 | */ |
| 105 | perc = perc_missing = 0; |
| 106 | for (i = 0; i < td->o.bssplit_nr; i++) { |
| 107 | struct bssplit *bsp = &td->o.bssplit[i]; |
| 108 | |
| 109 | if (bsp->perc == (unsigned char) -1) |
| 110 | perc_missing++; |
| 111 | else |
| 112 | perc += bsp->perc; |
| 113 | } |
| 114 | |
| 115 | if (perc > 100) { |
| 116 | log_err("fio: bssplit percentages add to more than 100%%\n"); |
| 117 | free(td->o.bssplit); |
| 118 | return 1; |
| 119 | } |
| 120 | /* |
| 121 | * If values didn't have a percentage set, divide the remains between |
| 122 | * them. |
| 123 | */ |
| 124 | if (perc_missing) { |
| 125 | for (i = 0; i < td->o.bssplit_nr; i++) { |
| 126 | struct bssplit *bsp = &td->o.bssplit[i]; |
| 127 | |
| 128 | if (bsp->perc == (unsigned char) -1) |
| 129 | bsp->perc = (100 - perc) / perc_missing; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs; |
| 134 | td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs; |
| 135 | |
| 136 | /* |
| 137 | * now sort based on percentages, for ease of lookup |
| 138 | */ |
| 139 | qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp); |
| 140 | |
| 141 | free(p); |
| 142 | return 0; |
| 143 | } |
| 144 | |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 145 | static int str_rw_cb(void *data, const char *str) |
| 146 | { |
| 147 | struct thread_data *td = data; |
| 148 | char *nr = get_opt_postfix(str); |
| 149 | |
Jens Axboe | fafdba3 | 2007-03-26 10:09:12 +0200 | [diff] [blame] | 150 | td->o.ddir_nr = 1; |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 151 | if (nr) |
| 152 | td->o.ddir_nr = atoi(nr); |
| 153 | |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 154 | return 0; |
| 155 | } |
| 156 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 157 | static int str_mem_cb(void *data, const char *mem) |
| 158 | { |
| 159 | struct thread_data *td = data; |
| 160 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 161 | if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 162 | td->mmapfile = get_opt_postfix(mem); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 163 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 164 | log_err("fio: mmaphuge:/path/to/file\n"); |
| 165 | return 1; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | static int str_lockmem_cb(void fio_unused *data, unsigned long *val) |
| 173 | { |
| 174 | mlock_size = *val; |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | #ifdef FIO_HAVE_IOPRIO |
| 179 | static int str_prioclass_cb(void *data, unsigned int *val) |
| 180 | { |
| 181 | struct thread_data *td = data; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 182 | unsigned short mask; |
| 183 | |
| 184 | /* |
| 185 | * mask off old class bits, str_prio_cb() may have set a default class |
| 186 | */ |
| 187 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; |
| 188 | td->ioprio &= mask; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 189 | |
| 190 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 191 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | static int str_prio_cb(void *data, unsigned int *val) |
| 196 | { |
| 197 | struct thread_data *td = data; |
| 198 | |
| 199 | td->ioprio |= *val; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 200 | |
| 201 | /* |
| 202 | * If no class is set, assume BE |
| 203 | */ |
| 204 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) |
| 205 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; |
| 206 | |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 207 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 208 | return 0; |
| 209 | } |
| 210 | #endif |
| 211 | |
| 212 | static int str_exitall_cb(void) |
| 213 | { |
| 214 | exitall_on_terminate = 1; |
| 215 | return 0; |
| 216 | } |
| 217 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 218 | #ifdef FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 219 | static int str_cpumask_cb(void *data, unsigned int *val) |
| 220 | { |
| 221 | struct thread_data *td = data; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 222 | unsigned int i; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 223 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 224 | CPU_ZERO(&td->o.cpumask); |
| 225 | |
| 226 | for (i = 0; i < sizeof(int) * 8; i++) |
| 227 | if ((1 << i) & *val) |
| 228 | CPU_SET(*val, &td->o.cpumask); |
| 229 | |
Jens Axboe | 375b269 | 2007-05-22 09:13:02 +0200 | [diff] [blame] | 230 | td->o.cpumask_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 231 | return 0; |
| 232 | } |
| 233 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 234 | static int str_cpus_allowed_cb(void *data, const char *input) |
| 235 | { |
| 236 | struct thread_data *td = data; |
| 237 | char *cpu, *str, *p; |
| 238 | |
| 239 | CPU_ZERO(&td->o.cpumask); |
| 240 | |
| 241 | p = str = strdup(input); |
| 242 | |
| 243 | strip_blank_front(&str); |
| 244 | strip_blank_end(str); |
| 245 | |
| 246 | while ((cpu = strsep(&str, ",")) != NULL) { |
| 247 | if (!strlen(cpu)) |
| 248 | break; |
| 249 | CPU_SET(atoi(cpu), &td->o.cpumask); |
| 250 | } |
| 251 | |
| 252 | free(p); |
| 253 | td->o.cpumask_set = 1; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 254 | return 0; |
| 255 | } |
| 256 | #endif |
| 257 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 258 | static int str_fst_cb(void *data, const char *str) |
| 259 | { |
| 260 | struct thread_data *td = data; |
| 261 | char *nr = get_opt_postfix(str); |
| 262 | |
| 263 | td->file_service_nr = 1; |
| 264 | if (nr) |
| 265 | td->file_service_nr = atoi(nr); |
| 266 | |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | static int str_filename_cb(void *data, const char *input) |
| 271 | { |
| 272 | struct thread_data *td = data; |
| 273 | char *fname, *str, *p; |
| 274 | |
| 275 | p = str = strdup(input); |
| 276 | |
| 277 | strip_blank_front(&str); |
| 278 | strip_blank_end(str); |
| 279 | |
| 280 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 281 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 282 | |
| 283 | while ((fname = strsep(&str, ":")) != NULL) { |
| 284 | if (!strlen(fname)) |
| 285 | break; |
| 286 | add_file(td, fname); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 287 | td->o.nr_files++; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | free(p); |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | static int str_directory_cb(void *data, const char fio_unused *str) |
| 295 | { |
| 296 | struct thread_data *td = data; |
| 297 | struct stat sb; |
| 298 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 299 | if (lstat(td->o.directory, &sb) < 0) { |
| 300 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 301 | td_verror(td, errno, "lstat"); |
| 302 | return 1; |
| 303 | } |
| 304 | if (!S_ISDIR(sb.st_mode)) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 305 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 306 | return 1; |
| 307 | } |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | static int str_opendir_cb(void *data, const char fio_unused *str) |
| 313 | { |
| 314 | struct thread_data *td = data; |
| 315 | |
| 316 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 317 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 318 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 319 | return add_dir_files(td, td->o.opendir); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 322 | static int str_verify_offset_cb(void *data, unsigned int *off) |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 323 | { |
| 324 | struct thread_data *td = data; |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 325 | |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 326 | if (*off && *off < sizeof(struct verify_header)) { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 327 | log_err("fio: verify_offset too small\n"); |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 328 | return 1; |
| 329 | } |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 330 | |
| 331 | td->o.verify_offset = *off; |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 332 | return 0; |
| 333 | } |
| 334 | |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 335 | static int str_verify_pattern_cb(void *data, unsigned int *off) |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 336 | { |
| 337 | struct thread_data *td = data; |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 338 | unsigned int msb; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 339 | |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 340 | msb = fls(*off); |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 341 | if (msb <= 8) |
| 342 | td->o.verify_pattern_bytes = 1; |
| 343 | else if (msb <= 16) |
| 344 | td->o.verify_pattern_bytes = 2; |
| 345 | else if (msb <= 24) |
| 346 | td->o.verify_pattern_bytes = 3; |
| 347 | else |
| 348 | td->o.verify_pattern_bytes = 4; |
| 349 | |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 350 | td->o.verify_pattern = *off; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 351 | return 0; |
| 352 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 353 | |
| 354 | #define __stringify_1(x) #x |
| 355 | #define __stringify(x) __stringify_1(x) |
| 356 | |
| 357 | /* |
| 358 | * Map of job/command line options |
| 359 | */ |
| 360 | static struct fio_option options[] = { |
| 361 | { |
| 362 | .name = "description", |
| 363 | .type = FIO_OPT_STR_STORE, |
| 364 | .off1 = td_var_offset(description), |
| 365 | .help = "Text job description", |
| 366 | }, |
| 367 | { |
| 368 | .name = "name", |
| 369 | .type = FIO_OPT_STR_STORE, |
| 370 | .off1 = td_var_offset(name), |
| 371 | .help = "Name of this job", |
| 372 | }, |
| 373 | { |
| 374 | .name = "directory", |
| 375 | .type = FIO_OPT_STR_STORE, |
| 376 | .off1 = td_var_offset(directory), |
| 377 | .cb = str_directory_cb, |
| 378 | .help = "Directory to store files in", |
| 379 | }, |
| 380 | { |
| 381 | .name = "filename", |
| 382 | .type = FIO_OPT_STR_STORE, |
| 383 | .off1 = td_var_offset(filename), |
| 384 | .cb = str_filename_cb, |
| 385 | .help = "File(s) to use for the workload", |
| 386 | }, |
| 387 | { |
| 388 | .name = "opendir", |
| 389 | .type = FIO_OPT_STR_STORE, |
| 390 | .off1 = td_var_offset(opendir), |
| 391 | .cb = str_opendir_cb, |
| 392 | .help = "Recursively add files from this directory and down", |
| 393 | }, |
| 394 | { |
| 395 | .name = "rw", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 396 | .alias = "readwrite", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 397 | .type = FIO_OPT_STR, |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 398 | .cb = str_rw_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 399 | .off1 = td_var_offset(td_ddir), |
| 400 | .help = "IO direction", |
| 401 | .def = "read", |
| 402 | .posval = { |
| 403 | { .ival = "read", |
| 404 | .oval = TD_DDIR_READ, |
| 405 | .help = "Sequential read", |
| 406 | }, |
| 407 | { .ival = "write", |
| 408 | .oval = TD_DDIR_WRITE, |
| 409 | .help = "Sequential write", |
| 410 | }, |
| 411 | { .ival = "randread", |
| 412 | .oval = TD_DDIR_RANDREAD, |
| 413 | .help = "Random read", |
| 414 | }, |
| 415 | { .ival = "randwrite", |
| 416 | .oval = TD_DDIR_RANDWRITE, |
| 417 | .help = "Random write", |
| 418 | }, |
| 419 | { .ival = "rw", |
| 420 | .oval = TD_DDIR_RW, |
| 421 | .help = "Sequential read and write mix", |
| 422 | }, |
| 423 | { .ival = "randrw", |
| 424 | .oval = TD_DDIR_RANDRW, |
| 425 | .help = "Random read and write mix" |
| 426 | }, |
| 427 | }, |
| 428 | }, |
| 429 | { |
| 430 | .name = "ioengine", |
| 431 | .type = FIO_OPT_STR_STORE, |
| 432 | .off1 = td_var_offset(ioengine), |
| 433 | .help = "IO engine to use", |
| 434 | .def = "sync", |
| 435 | .posval = { |
| 436 | { .ival = "sync", |
| 437 | .help = "Use read/write", |
| 438 | }, |
gurudas pai | a31041e | 2007-10-23 15:12:30 +0200 | [diff] [blame] | 439 | { .ival = "psync", |
| 440 | .help = "Use pread/pwrite", |
| 441 | }, |
Jens Axboe | 1d2af02 | 2008-02-04 10:59:07 +0100 | [diff] [blame] | 442 | { .ival = "vsync", |
| 443 | .help = "Use readv/writev", |
| 444 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 445 | #ifdef FIO_HAVE_LIBAIO |
| 446 | { .ival = "libaio", |
| 447 | .help = "Linux native asynchronous IO", |
| 448 | }, |
| 449 | #endif |
| 450 | #ifdef FIO_HAVE_POSIXAIO |
| 451 | { .ival = "posixaio", |
| 452 | .help = "POSIX asynchronous IO", |
| 453 | }, |
| 454 | #endif |
| 455 | { .ival = "mmap", |
| 456 | .help = "Memory mapped IO", |
| 457 | }, |
| 458 | #ifdef FIO_HAVE_SPLICE |
| 459 | { .ival = "splice", |
| 460 | .help = "splice/vmsplice based IO", |
| 461 | }, |
Jens Axboe | 9cce02e | 2007-06-22 15:42:21 +0200 | [diff] [blame] | 462 | { .ival = "netsplice", |
| 463 | .help = "splice/vmsplice to/from the network", |
| 464 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 465 | #endif |
| 466 | #ifdef FIO_HAVE_SGIO |
| 467 | { .ival = "sg", |
| 468 | .help = "SCSI generic v3 IO", |
| 469 | }, |
| 470 | #endif |
| 471 | { .ival = "null", |
| 472 | .help = "Testing engine (no data transfer)", |
| 473 | }, |
| 474 | { .ival = "net", |
| 475 | .help = "Network IO", |
| 476 | }, |
| 477 | #ifdef FIO_HAVE_SYSLET |
| 478 | { .ival = "syslet-rw", |
| 479 | .help = "syslet enabled async pread/pwrite IO", |
| 480 | }, |
| 481 | #endif |
| 482 | { .ival = "cpuio", |
| 483 | .help = "CPU cycler burner engine", |
| 484 | }, |
Jens Axboe | b8c82a4 | 2007-03-21 08:48:26 +0100 | [diff] [blame] | 485 | #ifdef FIO_HAVE_GUASI |
| 486 | { .ival = "guasi", |
| 487 | .help = "GUASI IO engine", |
| 488 | }, |
| 489 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 490 | { .ival = "external", |
| 491 | .help = "Load external engine (append name)", |
| 492 | }, |
| 493 | }, |
| 494 | }, |
| 495 | { |
| 496 | .name = "iodepth", |
| 497 | .type = FIO_OPT_INT, |
| 498 | .off1 = td_var_offset(iodepth), |
| 499 | .help = "Amount of IO buffers to keep in flight", |
Jens Axboe | 757aff4 | 2007-12-12 19:42:13 +0100 | [diff] [blame] | 500 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 501 | .def = "1", |
| 502 | }, |
| 503 | { |
| 504 | .name = "iodepth_batch", |
| 505 | .type = FIO_OPT_INT, |
| 506 | .off1 = td_var_offset(iodepth_batch), |
| 507 | .help = "Number of IO to submit in one go", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 508 | .parent = "iodepth", |
Jens Axboe | a2e6f8a | 2008-01-18 10:28:11 +0100 | [diff] [blame] | 509 | .minval = 1, |
| 510 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 511 | }, |
| 512 | { |
| 513 | .name = "iodepth_low", |
| 514 | .type = FIO_OPT_INT, |
| 515 | .off1 = td_var_offset(iodepth_low), |
| 516 | .help = "Low water mark for queuing depth", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 517 | .parent = "iodepth", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 518 | }, |
| 519 | { |
| 520 | .name = "size", |
| 521 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 522 | .off1 = td_var_offset(size), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 523 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 524 | .help = "Total size of device or files", |
| 525 | }, |
| 526 | { |
Shawn Lewis | aa31f1f | 2008-01-11 09:45:11 +0100 | [diff] [blame] | 527 | .name = "fill_device", |
| 528 | .type = FIO_OPT_BOOL, |
| 529 | .off1 = td_var_offset(fill_device), |
| 530 | .help = "Write until an ENOSPC error occurs", |
| 531 | .def = "0", |
| 532 | }, |
| 533 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 534 | .name = "filesize", |
| 535 | .type = FIO_OPT_STR_VAL, |
| 536 | .off1 = td_var_offset(file_size_low), |
| 537 | .off2 = td_var_offset(file_size_high), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 538 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 539 | .help = "Size of individual files", |
| 540 | }, |
| 541 | { |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 542 | .name = "offset", |
| 543 | .alias = "fileoffset", |
| 544 | .type = FIO_OPT_STR_VAL, |
| 545 | .off1 = td_var_offset(start_offset), |
| 546 | .help = "Start IO from this offset", |
| 547 | .def = "0", |
| 548 | }, |
| 549 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 550 | .name = "bs", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 551 | .alias = "blocksize", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 552 | .type = FIO_OPT_STR_VAL_INT, |
| 553 | .off1 = td_var_offset(bs[DDIR_READ]), |
| 554 | .off2 = td_var_offset(bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 555 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 556 | .help = "Block size unit", |
| 557 | .def = "4k", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 558 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 559 | }, |
| 560 | { |
| 561 | .name = "bsrange", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 562 | .alias = "blocksize_range", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 563 | .type = FIO_OPT_RANGE, |
| 564 | .off1 = td_var_offset(min_bs[DDIR_READ]), |
| 565 | .off2 = td_var_offset(max_bs[DDIR_READ]), |
| 566 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), |
| 567 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 568 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 569 | .help = "Set block size range (in more detail than bs)", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 570 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 571 | }, |
| 572 | { |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 573 | .name = "bssplit", |
| 574 | .type = FIO_OPT_STR, |
| 575 | .cb = str_bssplit_cb, |
| 576 | .help = "Set a specific mix of block sizes", |
| 577 | .parent = "rw", |
| 578 | }, |
| 579 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 580 | .name = "bs_unaligned", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 581 | .alias = "blocksize_unaligned", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 582 | .type = FIO_OPT_STR_SET, |
| 583 | .off1 = td_var_offset(bs_unaligned), |
| 584 | .help = "Don't sector align IO buffer sizes", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 585 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 586 | }, |
| 587 | { |
| 588 | .name = "randrepeat", |
| 589 | .type = FIO_OPT_BOOL, |
| 590 | .off1 = td_var_offset(rand_repeatable), |
| 591 | .help = "Use repeatable random IO pattern", |
| 592 | .def = "1", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 593 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 594 | }, |
| 595 | { |
| 596 | .name = "norandommap", |
| 597 | .type = FIO_OPT_STR_SET, |
| 598 | .off1 = td_var_offset(norandommap), |
| 599 | .help = "Accept potential duplicate random blocks", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 600 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 601 | }, |
| 602 | { |
| 603 | .name = "nrfiles", |
| 604 | .type = FIO_OPT_INT, |
| 605 | .off1 = td_var_offset(nr_files), |
| 606 | .help = "Split job workload between this number of files", |
| 607 | .def = "1", |
| 608 | }, |
| 609 | { |
| 610 | .name = "openfiles", |
| 611 | .type = FIO_OPT_INT, |
| 612 | .off1 = td_var_offset(open_files), |
| 613 | .help = "Number of files to keep open at the same time", |
| 614 | }, |
| 615 | { |
| 616 | .name = "file_service_type", |
| 617 | .type = FIO_OPT_STR, |
| 618 | .cb = str_fst_cb, |
| 619 | .off1 = td_var_offset(file_service_type), |
| 620 | .help = "How to select which file to service next", |
| 621 | .def = "roundrobin", |
| 622 | .posval = { |
| 623 | { .ival = "random", |
| 624 | .oval = FIO_FSERVICE_RANDOM, |
| 625 | .help = "Choose a file at random", |
| 626 | }, |
| 627 | { .ival = "roundrobin", |
| 628 | .oval = FIO_FSERVICE_RR, |
| 629 | .help = "Round robin select files", |
| 630 | }, |
| 631 | }, |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 632 | .parent = "nrfiles", |
| 633 | }, |
| 634 | { |
| 635 | .name = "fadvise_hint", |
| 636 | .type = FIO_OPT_BOOL, |
| 637 | .off1 = td_var_offset(fadvise_hint), |
| 638 | .help = "Use fadvise() to advise the kernel on IO pattern", |
| 639 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 640 | }, |
| 641 | { |
| 642 | .name = "fsync", |
| 643 | .type = FIO_OPT_INT, |
| 644 | .off1 = td_var_offset(fsync_blocks), |
| 645 | .help = "Issue fsync for writes every given number of blocks", |
| 646 | .def = "0", |
| 647 | }, |
| 648 | { |
| 649 | .name = "direct", |
| 650 | .type = FIO_OPT_BOOL, |
| 651 | .off1 = td_var_offset(odirect), |
| 652 | .help = "Use O_DIRECT IO (negates buffered)", |
| 653 | .def = "0", |
| 654 | }, |
| 655 | { |
| 656 | .name = "buffered", |
| 657 | .type = FIO_OPT_BOOL, |
| 658 | .off1 = td_var_offset(odirect), |
| 659 | .neg = 1, |
| 660 | .help = "Use buffered IO (negates direct)", |
| 661 | .def = "1", |
| 662 | }, |
| 663 | { |
| 664 | .name = "overwrite", |
| 665 | .type = FIO_OPT_BOOL, |
| 666 | .off1 = td_var_offset(overwrite), |
| 667 | .help = "When writing, set whether to overwrite current data", |
| 668 | .def = "0", |
| 669 | }, |
| 670 | { |
| 671 | .name = "loops", |
| 672 | .type = FIO_OPT_INT, |
| 673 | .off1 = td_var_offset(loops), |
| 674 | .help = "Number of times to run the job", |
| 675 | .def = "1", |
| 676 | }, |
| 677 | { |
| 678 | .name = "numjobs", |
| 679 | .type = FIO_OPT_INT, |
| 680 | .off1 = td_var_offset(numjobs), |
| 681 | .help = "Duplicate this job this many times", |
| 682 | .def = "1", |
| 683 | }, |
| 684 | { |
| 685 | .name = "startdelay", |
| 686 | .type = FIO_OPT_INT, |
| 687 | .off1 = td_var_offset(start_delay), |
| 688 | .help = "Only start job when this period has passed", |
| 689 | .def = "0", |
| 690 | }, |
| 691 | { |
| 692 | .name = "runtime", |
| 693 | .alias = "timeout", |
| 694 | .type = FIO_OPT_STR_VAL_TIME, |
| 695 | .off1 = td_var_offset(timeout), |
| 696 | .help = "Stop workload when this amount of time has passed", |
| 697 | .def = "0", |
| 698 | }, |
| 699 | { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 700 | .name = "time_based", |
| 701 | .type = FIO_OPT_STR_SET, |
| 702 | .off1 = td_var_offset(time_based), |
| 703 | .help = "Keep running until runtime/timeout is met", |
| 704 | }, |
| 705 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 706 | .name = "mem", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 707 | .alias = "iomem", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 708 | .type = FIO_OPT_STR, |
| 709 | .cb = str_mem_cb, |
| 710 | .off1 = td_var_offset(mem_type), |
| 711 | .help = "Backing type for IO buffers", |
| 712 | .def = "malloc", |
| 713 | .posval = { |
| 714 | { .ival = "malloc", |
| 715 | .oval = MEM_MALLOC, |
| 716 | .help = "Use malloc(3) for IO buffers", |
| 717 | }, |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 718 | { .ival = "shm", |
| 719 | .oval = MEM_SHM, |
| 720 | .help = "Use shared memory segments for IO buffers", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 721 | }, |
| 722 | #ifdef FIO_HAVE_HUGETLB |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 723 | { .ival = "shmhuge", |
| 724 | .oval = MEM_SHMHUGE, |
| 725 | .help = "Like shm, but use huge pages", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 726 | }, |
| 727 | #endif |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 728 | { .ival = "mmap", |
| 729 | .oval = MEM_MMAP, |
| 730 | .help = "Use mmap(2) (file or anon) for IO buffers", |
| 731 | }, |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 732 | #ifdef FIO_HAVE_HUGETLB |
| 733 | { .ival = "mmaphuge", |
| 734 | .oval = MEM_MMAPHUGE, |
| 735 | .help = "Like mmap, but use huge pages", |
| 736 | }, |
| 737 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 738 | }, |
| 739 | }, |
| 740 | { |
| 741 | .name = "verify", |
| 742 | .type = FIO_OPT_STR, |
| 743 | .off1 = td_var_offset(verify), |
| 744 | .help = "Verify data written", |
| 745 | .def = "0", |
| 746 | .posval = { |
| 747 | { .ival = "0", |
| 748 | .oval = VERIFY_NONE, |
| 749 | .help = "Don't do IO verification", |
| 750 | }, |
Jens Axboe | fcca4b5 | 2007-07-27 15:42:00 +0200 | [diff] [blame] | 751 | { .ival = "md5", |
| 752 | .oval = VERIFY_MD5, |
| 753 | .help = "Use md5 checksums for verification", |
| 754 | }, |
Jens Axboe | d77a7af | 2007-07-27 15:35:06 +0200 | [diff] [blame] | 755 | { .ival = "crc64", |
| 756 | .oval = VERIFY_CRC64, |
| 757 | .help = "Use crc64 checksums for verification", |
| 758 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 759 | { .ival = "crc32", |
| 760 | .oval = VERIFY_CRC32, |
| 761 | .help = "Use crc32 checksums for verification", |
| 762 | }, |
Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 763 | { .ival = "crc16", |
| 764 | .oval = VERIFY_CRC16, |
| 765 | .help = "Use crc16 checksums for verification", |
| 766 | }, |
Jens Axboe | 1e154bd | 2007-07-27 09:52:40 +0200 | [diff] [blame] | 767 | { .ival = "crc7", |
| 768 | .oval = VERIFY_CRC7, |
| 769 | .help = "Use crc7 checksums for verification", |
| 770 | }, |
Jens Axboe | cd14cc1 | 2007-07-30 10:59:33 +0200 | [diff] [blame] | 771 | { .ival = "sha256", |
| 772 | .oval = VERIFY_SHA256, |
| 773 | .help = "Use sha256 checksums for verification", |
| 774 | }, |
| 775 | { .ival = "sha512", |
| 776 | .oval = VERIFY_SHA512, |
| 777 | .help = "Use sha512 checksums for verification", |
| 778 | }, |
Shawn Lewis | 7437ee8 | 2007-08-02 21:05:58 +0200 | [diff] [blame] | 779 | { .ival = "meta", |
| 780 | .oval = VERIFY_META, |
| 781 | .help = "Use io information", |
| 782 | }, |
Jens Axboe | 36690c9 | 2007-03-26 10:23:34 +0200 | [diff] [blame] | 783 | { |
| 784 | .ival = "null", |
| 785 | .oval = VERIFY_NULL, |
| 786 | .help = "Pretend to verify", |
| 787 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 788 | }, |
| 789 | }, |
| 790 | { |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 791 | .name = "do_verify", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 792 | .type = FIO_OPT_BOOL, |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 793 | .off1 = td_var_offset(do_verify), |
| 794 | .help = "Run verification stage after write", |
| 795 | .def = "1", |
| 796 | .parent = "verify", |
| 797 | }, |
| 798 | { |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 799 | .name = "verifysort", |
| 800 | .type = FIO_OPT_BOOL, |
| 801 | .off1 = td_var_offset(verifysort), |
| 802 | .help = "Sort written verify blocks for read back", |
| 803 | .def = "1", |
Jens Axboe | c83f2df | 2007-07-31 22:51:47 +0200 | [diff] [blame] | 804 | .parent = "verify", |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 805 | }, |
| 806 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 807 | .name = "verify_interval", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 808 | .type = FIO_OPT_STR_VAL_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 809 | .off1 = td_var_offset(verify_interval), |
Jens Axboe | 819a968 | 2007-07-28 21:30:31 +0200 | [diff] [blame] | 810 | .minval = 2 * sizeof(struct verify_header), |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 811 | .help = "Store verify buffer header every N bytes", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 812 | .parent = "verify", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 813 | }, |
| 814 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 815 | .name = "verify_offset", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 816 | .type = FIO_OPT_STR_VAL_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 817 | .help = "Offset verify header location by N bytes", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 818 | .def = "0", |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 819 | .cb = str_verify_offset_cb, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 820 | .parent = "verify", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 821 | }, |
| 822 | { |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 823 | .name = "verify_pattern", |
| 824 | .type = FIO_OPT_INT, |
| 825 | .cb = str_verify_pattern_cb, |
| 826 | .help = "Fill pattern for IO buffers", |
| 827 | .parent = "verify", |
| 828 | }, |
| 829 | { |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 830 | .name = "verify_fatal", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 831 | .type = FIO_OPT_BOOL, |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 832 | .off1 = td_var_offset(verify_fatal), |
| 833 | .def = "0", |
| 834 | .help = "Exit on a single verify failure, don't continue", |
| 835 | .parent = "verify", |
| 836 | }, |
| 837 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 838 | .name = "write_iolog", |
| 839 | .type = FIO_OPT_STR_STORE, |
| 840 | .off1 = td_var_offset(write_iolog_file), |
| 841 | .help = "Store IO pattern to file", |
| 842 | }, |
| 843 | { |
| 844 | .name = "read_iolog", |
| 845 | .type = FIO_OPT_STR_STORE, |
| 846 | .off1 = td_var_offset(read_iolog_file), |
| 847 | .help = "Playback IO pattern from file", |
| 848 | }, |
| 849 | { |
| 850 | .name = "exec_prerun", |
| 851 | .type = FIO_OPT_STR_STORE, |
| 852 | .off1 = td_var_offset(exec_prerun), |
| 853 | .help = "Execute this file prior to running job", |
| 854 | }, |
| 855 | { |
| 856 | .name = "exec_postrun", |
| 857 | .type = FIO_OPT_STR_STORE, |
| 858 | .off1 = td_var_offset(exec_postrun), |
| 859 | .help = "Execute this file after running job", |
| 860 | }, |
| 861 | #ifdef FIO_HAVE_IOSCHED_SWITCH |
| 862 | { |
| 863 | .name = "ioscheduler", |
| 864 | .type = FIO_OPT_STR_STORE, |
| 865 | .off1 = td_var_offset(ioscheduler), |
| 866 | .help = "Use this IO scheduler on the backing device", |
| 867 | }, |
| 868 | #endif |
| 869 | { |
| 870 | .name = "zonesize", |
| 871 | .type = FIO_OPT_STR_VAL, |
| 872 | .off1 = td_var_offset(zone_size), |
| 873 | .help = "Give size of an IO zone", |
| 874 | .def = "0", |
| 875 | }, |
| 876 | { |
| 877 | .name = "zoneskip", |
| 878 | .type = FIO_OPT_STR_VAL, |
| 879 | .off1 = td_var_offset(zone_skip), |
| 880 | .help = "Space between IO zones", |
| 881 | .def = "0", |
| 882 | }, |
| 883 | { |
| 884 | .name = "lockmem", |
| 885 | .type = FIO_OPT_STR_VAL, |
| 886 | .cb = str_lockmem_cb, |
| 887 | .help = "Lock down this amount of memory", |
| 888 | .def = "0", |
| 889 | }, |
| 890 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 891 | .name = "rwmixread", |
| 892 | .type = FIO_OPT_INT, |
Jens Axboe | e47f799 | 2007-03-21 14:05:39 +0100 | [diff] [blame] | 893 | .off1 = td_var_offset(rwmix[DDIR_READ]), |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 894 | .maxval = 100, |
| 895 | .help = "Percentage of mixed workload that is reads", |
| 896 | .def = "50", |
| 897 | }, |
| 898 | { |
| 899 | .name = "rwmixwrite", |
| 900 | .type = FIO_OPT_INT, |
Jens Axboe | e47f799 | 2007-03-21 14:05:39 +0100 | [diff] [blame] | 901 | .off1 = td_var_offset(rwmix[DDIR_WRITE]), |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 902 | .maxval = 100, |
| 903 | .help = "Percentage of mixed workload that is writes", |
| 904 | .def = "50", |
| 905 | }, |
| 906 | { |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 907 | .name = "rwmixcycle", |
| 908 | .type = FIO_OPT_INT, |
| 909 | .off1 = td_var_offset(rwmixcycle), |
| 910 | .help = "Cycle period for mixed read/write workloads (msec)", |
| 911 | .def = "500", |
| 912 | .parent = "rwmixread", |
| 913 | }, |
| 914 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 915 | .name = "nice", |
| 916 | .type = FIO_OPT_INT, |
| 917 | .off1 = td_var_offset(nice), |
| 918 | .help = "Set job CPU nice value", |
| 919 | .minval = -19, |
| 920 | .maxval = 20, |
| 921 | .def = "0", |
| 922 | }, |
| 923 | #ifdef FIO_HAVE_IOPRIO |
| 924 | { |
| 925 | .name = "prio", |
| 926 | .type = FIO_OPT_INT, |
| 927 | .cb = str_prio_cb, |
| 928 | .help = "Set job IO priority value", |
| 929 | .minval = 0, |
| 930 | .maxval = 7, |
| 931 | }, |
| 932 | { |
| 933 | .name = "prioclass", |
| 934 | .type = FIO_OPT_INT, |
| 935 | .cb = str_prioclass_cb, |
| 936 | .help = "Set job IO priority class", |
| 937 | .minval = 0, |
| 938 | .maxval = 3, |
| 939 | }, |
| 940 | #endif |
| 941 | { |
| 942 | .name = "thinktime", |
| 943 | .type = FIO_OPT_INT, |
| 944 | .off1 = td_var_offset(thinktime), |
| 945 | .help = "Idle time between IO buffers (usec)", |
| 946 | .def = "0", |
| 947 | }, |
| 948 | { |
| 949 | .name = "thinktime_spin", |
| 950 | .type = FIO_OPT_INT, |
| 951 | .off1 = td_var_offset(thinktime_spin), |
| 952 | .help = "Start think time by spinning this amount (usec)", |
| 953 | .def = "0", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 954 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 955 | }, |
| 956 | { |
| 957 | .name = "thinktime_blocks", |
| 958 | .type = FIO_OPT_INT, |
| 959 | .off1 = td_var_offset(thinktime_blocks), |
| 960 | .help = "IO buffer period between 'thinktime'", |
| 961 | .def = "1", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 962 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 963 | }, |
| 964 | { |
| 965 | .name = "rate", |
| 966 | .type = FIO_OPT_INT, |
| 967 | .off1 = td_var_offset(rate), |
| 968 | .help = "Set bandwidth rate", |
| 969 | }, |
| 970 | { |
| 971 | .name = "ratemin", |
| 972 | .type = FIO_OPT_INT, |
| 973 | .off1 = td_var_offset(ratemin), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 974 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 975 | .parent = "rate", |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 976 | }, |
| 977 | { |
| 978 | .name = "rate_iops", |
| 979 | .type = FIO_OPT_INT, |
| 980 | .off1 = td_var_offset(rate_iops), |
| 981 | .help = "Limit IO used to this number of IO operations/sec", |
| 982 | }, |
| 983 | { |
| 984 | .name = "rate_iops_min", |
| 985 | .type = FIO_OPT_INT, |
| 986 | .off1 = td_var_offset(rate_iops_min), |
| 987 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 988 | .parent = "rate_iops", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 989 | }, |
| 990 | { |
| 991 | .name = "ratecycle", |
| 992 | .type = FIO_OPT_INT, |
| 993 | .off1 = td_var_offset(ratecycle), |
| 994 | .help = "Window average for rate limits (msec)", |
| 995 | .def = "1000", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 996 | .parent = "rate", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 997 | }, |
| 998 | { |
| 999 | .name = "invalidate", |
| 1000 | .type = FIO_OPT_BOOL, |
| 1001 | .off1 = td_var_offset(invalidate_cache), |
| 1002 | .help = "Invalidate buffer/page cache prior to running job", |
| 1003 | .def = "1", |
| 1004 | }, |
| 1005 | { |
| 1006 | .name = "sync", |
| 1007 | .type = FIO_OPT_BOOL, |
| 1008 | .off1 = td_var_offset(sync_io), |
| 1009 | .help = "Use O_SYNC for buffered writes", |
| 1010 | .def = "0", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1011 | .parent = "buffered", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1012 | }, |
| 1013 | { |
| 1014 | .name = "bwavgtime", |
| 1015 | .type = FIO_OPT_INT, |
| 1016 | .off1 = td_var_offset(bw_avg_time), |
| 1017 | .help = "Time window over which to calculate bandwidth (msec)", |
| 1018 | .def = "500", |
| 1019 | }, |
| 1020 | { |
| 1021 | .name = "create_serialize", |
| 1022 | .type = FIO_OPT_BOOL, |
| 1023 | .off1 = td_var_offset(create_serialize), |
| 1024 | .help = "Serialize creating of job files", |
| 1025 | .def = "1", |
| 1026 | }, |
| 1027 | { |
| 1028 | .name = "create_fsync", |
| 1029 | .type = FIO_OPT_BOOL, |
| 1030 | .off1 = td_var_offset(create_fsync), |
| 1031 | .help = "Fsync file after creation", |
| 1032 | .def = "1", |
| 1033 | }, |
| 1034 | { |
| 1035 | .name = "cpuload", |
| 1036 | .type = FIO_OPT_INT, |
| 1037 | .off1 = td_var_offset(cpuload), |
| 1038 | .help = "Use this percentage of CPU", |
| 1039 | }, |
| 1040 | { |
| 1041 | .name = "cpuchunks", |
| 1042 | .type = FIO_OPT_INT, |
| 1043 | .off1 = td_var_offset(cpucycle), |
| 1044 | .help = "Length of the CPU burn cycles (usecs)", |
| 1045 | .def = "50000", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1046 | .parent = "cpuload", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1047 | }, |
| 1048 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1049 | { |
| 1050 | .name = "cpumask", |
| 1051 | .type = FIO_OPT_INT, |
| 1052 | .cb = str_cpumask_cb, |
| 1053 | .help = "CPU affinity mask", |
| 1054 | }, |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 1055 | { |
| 1056 | .name = "cpus_allowed", |
| 1057 | .type = FIO_OPT_STR, |
| 1058 | .cb = str_cpus_allowed_cb, |
| 1059 | .help = "Set CPUs allowed", |
| 1060 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1061 | #endif |
| 1062 | { |
| 1063 | .name = "end_fsync", |
| 1064 | .type = FIO_OPT_BOOL, |
| 1065 | .off1 = td_var_offset(end_fsync), |
| 1066 | .help = "Include fsync at the end of job", |
| 1067 | .def = "0", |
| 1068 | }, |
| 1069 | { |
| 1070 | .name = "fsync_on_close", |
| 1071 | .type = FIO_OPT_BOOL, |
| 1072 | .off1 = td_var_offset(fsync_on_close), |
| 1073 | .help = "fsync files on close", |
| 1074 | .def = "0", |
| 1075 | }, |
| 1076 | { |
| 1077 | .name = "unlink", |
| 1078 | .type = FIO_OPT_BOOL, |
| 1079 | .off1 = td_var_offset(unlink), |
| 1080 | .help = "Unlink created files after job has completed", |
| 1081 | .def = "0", |
| 1082 | }, |
| 1083 | { |
| 1084 | .name = "exitall", |
| 1085 | .type = FIO_OPT_STR_SET, |
| 1086 | .cb = str_exitall_cb, |
| 1087 | .help = "Terminate all jobs when one exits", |
| 1088 | }, |
| 1089 | { |
| 1090 | .name = "stonewall", |
| 1091 | .type = FIO_OPT_STR_SET, |
| 1092 | .off1 = td_var_offset(stonewall), |
| 1093 | .help = "Insert a hard barrier between this job and previous", |
| 1094 | }, |
| 1095 | { |
Jens Axboe | b3d62a7 | 2007-03-20 14:23:26 +0100 | [diff] [blame] | 1096 | .name = "new_group", |
| 1097 | .type = FIO_OPT_STR_SET, |
| 1098 | .off1 = td_var_offset(new_group), |
| 1099 | .help = "Mark the start of a new group (for reporting)", |
| 1100 | }, |
| 1101 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1102 | .name = "thread", |
| 1103 | .type = FIO_OPT_STR_SET, |
| 1104 | .off1 = td_var_offset(use_thread), |
| 1105 | .help = "Use threads instead of forks", |
| 1106 | }, |
| 1107 | { |
| 1108 | .name = "write_bw_log", |
| 1109 | .type = FIO_OPT_STR_SET, |
| 1110 | .off1 = td_var_offset(write_bw_log), |
| 1111 | .help = "Write log of bandwidth during run", |
| 1112 | }, |
| 1113 | { |
| 1114 | .name = "write_lat_log", |
| 1115 | .type = FIO_OPT_STR_SET, |
| 1116 | .off1 = td_var_offset(write_lat_log), |
| 1117 | .help = "Write log of latency during run", |
| 1118 | }, |
| 1119 | { |
| 1120 | .name = "hugepage-size", |
| 1121 | .type = FIO_OPT_STR_VAL, |
| 1122 | .off1 = td_var_offset(hugepage_size), |
| 1123 | .help = "When using hugepages, specify size of each page", |
| 1124 | .def = __stringify(FIO_HUGE_PAGE), |
| 1125 | }, |
| 1126 | { |
| 1127 | .name = "group_reporting", |
| 1128 | .type = FIO_OPT_STR_SET, |
| 1129 | .off1 = td_var_offset(group_reporting), |
| 1130 | .help = "Do reporting on a per-group basis", |
| 1131 | }, |
| 1132 | { |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1133 | .name = "zero_buffers", |
| 1134 | .type = FIO_OPT_STR_SET, |
| 1135 | .off1 = td_var_offset(zero_buffers), |
| 1136 | .help = "Init IO buffers to all zeroes", |
| 1137 | }, |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 1138 | #ifdef FIO_HAVE_DISK_UTIL |
| 1139 | { |
| 1140 | .name = "disk_util", |
| 1141 | .type = FIO_OPT_BOOL, |
| 1142 | .off1 = td_var_offset(do_disk_util), |
| 1143 | .help = "Log disk utilization stats", |
| 1144 | .def = "1", |
| 1145 | }, |
| 1146 | #endif |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1147 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1148 | .name = NULL, |
| 1149 | }, |
| 1150 | }; |
| 1151 | |
| 1152 | void fio_options_dup_and_init(struct option *long_options) |
| 1153 | { |
| 1154 | struct fio_option *o; |
| 1155 | unsigned int i; |
| 1156 | |
| 1157 | options_init(options); |
| 1158 | |
| 1159 | i = 0; |
| 1160 | while (long_options[i].name) |
| 1161 | i++; |
| 1162 | |
| 1163 | o = &options[0]; |
| 1164 | while (o->name) { |
| 1165 | long_options[i].name = o->name; |
| 1166 | long_options[i].val = FIO_GETOPT_JOB; |
| 1167 | if (o->type == FIO_OPT_STR_SET) |
| 1168 | long_options[i].has_arg = no_argument; |
| 1169 | else |
| 1170 | long_options[i].has_arg = required_argument; |
| 1171 | |
| 1172 | i++; |
| 1173 | o++; |
| 1174 | assert(i < FIO_NR_OPTIONS); |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | int fio_option_parse(struct thread_data *td, const char *opt) |
| 1179 | { |
| 1180 | return parse_option(opt, options, td); |
| 1181 | } |
| 1182 | |
| 1183 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) |
| 1184 | { |
| 1185 | return parse_cmd_option(opt, val, options, td); |
| 1186 | } |
| 1187 | |
| 1188 | void fio_fill_default_options(struct thread_data *td) |
| 1189 | { |
| 1190 | fill_default_options(td, options); |
| 1191 | } |
| 1192 | |
| 1193 | int fio_show_option_help(const char *opt) |
| 1194 | { |
| 1195 | return show_cmd_help(options, opt); |
| 1196 | } |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1197 | |
| 1198 | static void __options_mem(struct thread_data *td, int alloc) |
| 1199 | { |
| 1200 | struct thread_options *o = &td->o; |
| 1201 | struct fio_option *opt; |
| 1202 | char **ptr; |
| 1203 | int i; |
| 1204 | |
| 1205 | for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) { |
| 1206 | if (opt->type != FIO_OPT_STR_STORE) |
| 1207 | continue; |
| 1208 | |
| 1209 | ptr = (void *) o + opt->off1; |
| 1210 | if (*ptr) { |
| 1211 | if (alloc) |
| 1212 | *ptr = strdup(*ptr); |
| 1213 | else { |
| 1214 | free(*ptr); |
| 1215 | *ptr = NULL; |
| 1216 | } |
| 1217 | } |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | /* |
| 1222 | * dupe FIO_OPT_STR_STORE options |
| 1223 | */ |
| 1224 | void options_mem_dupe(struct thread_data *td) |
| 1225 | { |
| 1226 | __options_mem(td, 1); |
| 1227 | } |
| 1228 | |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1229 | void options_mem_free(struct thread_data fio_unused *td) |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1230 | { |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1231 | #if 0 |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1232 | __options_mem(td, 0); |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1233 | #endif |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1234 | } |