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