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