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, |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 466 | .prio = 1, /* must come before "directory" */ |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 467 | .help = "File(s) to use for the workload", |
| 468 | }, |
| 469 | { |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 470 | .name = "lockfile", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 471 | .type = FIO_OPT_STR, |
| 472 | .cb = str_lockfile_cb, |
| 473 | .off1 = td_var_offset(file_lock_mode), |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 474 | .help = "Lock file when doing IO to it", |
| 475 | .parent = "filename", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 476 | .def = "none", |
| 477 | .posval = { |
| 478 | { .ival = "none", |
| 479 | .oval = FILE_LOCK_NONE, |
| 480 | .help = "No file locking", |
| 481 | }, |
| 482 | { .ival = "exclusive", |
| 483 | .oval = FILE_LOCK_EXCLUSIVE, |
| 484 | .help = "Exclusive file lock", |
| 485 | }, |
| 486 | { |
| 487 | .ival = "readwrite", |
| 488 | .oval = FILE_LOCK_READWRITE, |
| 489 | .help = "Read vs write lock", |
| 490 | }, |
| 491 | }, |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 492 | }, |
| 493 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 494 | .name = "opendir", |
| 495 | .type = FIO_OPT_STR_STORE, |
| 496 | .off1 = td_var_offset(opendir), |
| 497 | .cb = str_opendir_cb, |
| 498 | .help = "Recursively add files from this directory and down", |
| 499 | }, |
| 500 | { |
| 501 | .name = "rw", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 502 | .alias = "readwrite", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 503 | .type = FIO_OPT_STR, |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 504 | .cb = str_rw_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 505 | .off1 = td_var_offset(td_ddir), |
| 506 | .help = "IO direction", |
| 507 | .def = "read", |
| 508 | .posval = { |
| 509 | { .ival = "read", |
| 510 | .oval = TD_DDIR_READ, |
| 511 | .help = "Sequential read", |
| 512 | }, |
| 513 | { .ival = "write", |
| 514 | .oval = TD_DDIR_WRITE, |
| 515 | .help = "Sequential write", |
| 516 | }, |
| 517 | { .ival = "randread", |
| 518 | .oval = TD_DDIR_RANDREAD, |
| 519 | .help = "Random read", |
| 520 | }, |
| 521 | { .ival = "randwrite", |
| 522 | .oval = TD_DDIR_RANDWRITE, |
| 523 | .help = "Random write", |
| 524 | }, |
| 525 | { .ival = "rw", |
| 526 | .oval = TD_DDIR_RW, |
| 527 | .help = "Sequential read and write mix", |
| 528 | }, |
| 529 | { .ival = "randrw", |
| 530 | .oval = TD_DDIR_RANDRW, |
| 531 | .help = "Random read and write mix" |
| 532 | }, |
| 533 | }, |
| 534 | }, |
| 535 | { |
| 536 | .name = "ioengine", |
| 537 | .type = FIO_OPT_STR_STORE, |
| 538 | .off1 = td_var_offset(ioengine), |
| 539 | .help = "IO engine to use", |
| 540 | .def = "sync", |
| 541 | .posval = { |
| 542 | { .ival = "sync", |
| 543 | .help = "Use read/write", |
| 544 | }, |
gurudas pai | a31041e | 2007-10-23 15:12:30 +0200 | [diff] [blame] | 545 | { .ival = "psync", |
| 546 | .help = "Use pread/pwrite", |
| 547 | }, |
Jens Axboe | 1d2af02 | 2008-02-04 10:59:07 +0100 | [diff] [blame] | 548 | { .ival = "vsync", |
| 549 | .help = "Use readv/writev", |
| 550 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 551 | #ifdef FIO_HAVE_LIBAIO |
| 552 | { .ival = "libaio", |
| 553 | .help = "Linux native asynchronous IO", |
| 554 | }, |
| 555 | #endif |
| 556 | #ifdef FIO_HAVE_POSIXAIO |
| 557 | { .ival = "posixaio", |
| 558 | .help = "POSIX asynchronous IO", |
| 559 | }, |
| 560 | #endif |
Jens Axboe | 417f006 | 2008-06-02 11:59:30 +0200 | [diff] [blame] | 561 | #ifdef FIO_HAVE_SOLARISAIO |
| 562 | { .ival = "solarisaio", |
| 563 | .help = "Solaris native asynchronous IO", |
| 564 | }, |
| 565 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 566 | { .ival = "mmap", |
| 567 | .help = "Memory mapped IO", |
| 568 | }, |
| 569 | #ifdef FIO_HAVE_SPLICE |
| 570 | { .ival = "splice", |
| 571 | .help = "splice/vmsplice based IO", |
| 572 | }, |
Jens Axboe | 9cce02e | 2007-06-22 15:42:21 +0200 | [diff] [blame] | 573 | { .ival = "netsplice", |
| 574 | .help = "splice/vmsplice to/from the network", |
| 575 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 576 | #endif |
| 577 | #ifdef FIO_HAVE_SGIO |
| 578 | { .ival = "sg", |
| 579 | .help = "SCSI generic v3 IO", |
| 580 | }, |
| 581 | #endif |
| 582 | { .ival = "null", |
| 583 | .help = "Testing engine (no data transfer)", |
| 584 | }, |
| 585 | { .ival = "net", |
| 586 | .help = "Network IO", |
| 587 | }, |
| 588 | #ifdef FIO_HAVE_SYSLET |
| 589 | { .ival = "syslet-rw", |
| 590 | .help = "syslet enabled async pread/pwrite IO", |
| 591 | }, |
| 592 | #endif |
| 593 | { .ival = "cpuio", |
| 594 | .help = "CPU cycler burner engine", |
| 595 | }, |
Jens Axboe | b8c82a4 | 2007-03-21 08:48:26 +0100 | [diff] [blame] | 596 | #ifdef FIO_HAVE_GUASI |
| 597 | { .ival = "guasi", |
| 598 | .help = "GUASI IO engine", |
| 599 | }, |
| 600 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 601 | { .ival = "external", |
| 602 | .help = "Load external engine (append name)", |
| 603 | }, |
| 604 | }, |
| 605 | }, |
| 606 | { |
| 607 | .name = "iodepth", |
| 608 | .type = FIO_OPT_INT, |
| 609 | .off1 = td_var_offset(iodepth), |
| 610 | .help = "Amount of IO buffers to keep in flight", |
Jens Axboe | 757aff4 | 2007-12-12 19:42:13 +0100 | [diff] [blame] | 611 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 612 | .def = "1", |
| 613 | }, |
| 614 | { |
| 615 | .name = "iodepth_batch", |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 616 | .alias = "iodepth_batch_submit", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 617 | .type = FIO_OPT_INT, |
| 618 | .off1 = td_var_offset(iodepth_batch), |
| 619 | .help = "Number of IO to submit in one go", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 620 | .parent = "iodepth", |
Jens Axboe | a2e6f8a | 2008-01-18 10:28:11 +0100 | [diff] [blame] | 621 | .minval = 1, |
| 622 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 623 | }, |
| 624 | { |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 625 | .name = "iodepth_batch_complete", |
| 626 | .type = FIO_OPT_INT, |
| 627 | .off1 = td_var_offset(iodepth_batch_complete), |
| 628 | .help = "Number of IO to retrieve in one go", |
| 629 | .parent = "iodepth", |
| 630 | .minval = 0, |
| 631 | .def = "1", |
| 632 | }, |
| 633 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 634 | .name = "iodepth_low", |
| 635 | .type = FIO_OPT_INT, |
| 636 | .off1 = td_var_offset(iodepth_low), |
| 637 | .help = "Low water mark for queuing depth", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 638 | .parent = "iodepth", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 639 | }, |
| 640 | { |
| 641 | .name = "size", |
| 642 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 643 | .off1 = td_var_offset(size), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 644 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 645 | .help = "Total size of device or files", |
| 646 | }, |
| 647 | { |
Shawn Lewis | aa31f1f | 2008-01-11 09:45:11 +0100 | [diff] [blame] | 648 | .name = "fill_device", |
| 649 | .type = FIO_OPT_BOOL, |
| 650 | .off1 = td_var_offset(fill_device), |
| 651 | .help = "Write until an ENOSPC error occurs", |
| 652 | .def = "0", |
| 653 | }, |
| 654 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 655 | .name = "filesize", |
| 656 | .type = FIO_OPT_STR_VAL, |
| 657 | .off1 = td_var_offset(file_size_low), |
| 658 | .off2 = td_var_offset(file_size_high), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 659 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 660 | .help = "Size of individual files", |
| 661 | }, |
| 662 | { |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 663 | .name = "offset", |
| 664 | .alias = "fileoffset", |
| 665 | .type = FIO_OPT_STR_VAL, |
| 666 | .off1 = td_var_offset(start_offset), |
| 667 | .help = "Start IO from this offset", |
| 668 | .def = "0", |
| 669 | }, |
| 670 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 671 | .name = "bs", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 672 | .alias = "blocksize", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 673 | .type = FIO_OPT_STR_VAL_INT, |
| 674 | .off1 = td_var_offset(bs[DDIR_READ]), |
| 675 | .off2 = td_var_offset(bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 676 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 677 | .help = "Block size unit", |
| 678 | .def = "4k", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 679 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 680 | }, |
| 681 | { |
| 682 | .name = "bsrange", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 683 | .alias = "blocksize_range", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 684 | .type = FIO_OPT_RANGE, |
| 685 | .off1 = td_var_offset(min_bs[DDIR_READ]), |
| 686 | .off2 = td_var_offset(max_bs[DDIR_READ]), |
| 687 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), |
| 688 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 689 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 690 | .help = "Set block size range (in more detail than bs)", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 691 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 692 | }, |
| 693 | { |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 694 | .name = "bssplit", |
| 695 | .type = FIO_OPT_STR, |
| 696 | .cb = str_bssplit_cb, |
| 697 | .help = "Set a specific mix of block sizes", |
| 698 | .parent = "rw", |
| 699 | }, |
| 700 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 701 | .name = "bs_unaligned", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 702 | .alias = "blocksize_unaligned", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 703 | .type = FIO_OPT_STR_SET, |
| 704 | .off1 = td_var_offset(bs_unaligned), |
| 705 | .help = "Don't sector align IO buffer sizes", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 706 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 707 | }, |
| 708 | { |
| 709 | .name = "randrepeat", |
| 710 | .type = FIO_OPT_BOOL, |
| 711 | .off1 = td_var_offset(rand_repeatable), |
| 712 | .help = "Use repeatable random IO pattern", |
| 713 | .def = "1", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 714 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 715 | }, |
| 716 | { |
| 717 | .name = "norandommap", |
| 718 | .type = FIO_OPT_STR_SET, |
| 719 | .off1 = td_var_offset(norandommap), |
| 720 | .help = "Accept potential duplicate random blocks", |
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 | { |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 724 | .name = "softrandommap", |
| 725 | .type = FIO_OPT_BOOL, |
| 726 | .off1 = td_var_offset(softrandommap), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 727 | .help = "Set norandommap if randommap allocation fails", |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 728 | .parent = "norandommap", |
| 729 | .def = "0", |
| 730 | }, |
| 731 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 732 | .name = "nrfiles", |
| 733 | .type = FIO_OPT_INT, |
| 734 | .off1 = td_var_offset(nr_files), |
| 735 | .help = "Split job workload between this number of files", |
| 736 | .def = "1", |
| 737 | }, |
| 738 | { |
| 739 | .name = "openfiles", |
| 740 | .type = FIO_OPT_INT, |
| 741 | .off1 = td_var_offset(open_files), |
| 742 | .help = "Number of files to keep open at the same time", |
| 743 | }, |
| 744 | { |
| 745 | .name = "file_service_type", |
| 746 | .type = FIO_OPT_STR, |
| 747 | .cb = str_fst_cb, |
| 748 | .off1 = td_var_offset(file_service_type), |
| 749 | .help = "How to select which file to service next", |
| 750 | .def = "roundrobin", |
| 751 | .posval = { |
| 752 | { .ival = "random", |
| 753 | .oval = FIO_FSERVICE_RANDOM, |
| 754 | .help = "Choose a file at random", |
| 755 | }, |
| 756 | { .ival = "roundrobin", |
| 757 | .oval = FIO_FSERVICE_RR, |
| 758 | .help = "Round robin select files", |
| 759 | }, |
| 760 | }, |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 761 | .parent = "nrfiles", |
| 762 | }, |
| 763 | { |
| 764 | .name = "fadvise_hint", |
| 765 | .type = FIO_OPT_BOOL, |
| 766 | .off1 = td_var_offset(fadvise_hint), |
| 767 | .help = "Use fadvise() to advise the kernel on IO pattern", |
| 768 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 769 | }, |
| 770 | { |
| 771 | .name = "fsync", |
| 772 | .type = FIO_OPT_INT, |
| 773 | .off1 = td_var_offset(fsync_blocks), |
| 774 | .help = "Issue fsync for writes every given number of blocks", |
| 775 | .def = "0", |
| 776 | }, |
| 777 | { |
| 778 | .name = "direct", |
| 779 | .type = FIO_OPT_BOOL, |
| 780 | .off1 = td_var_offset(odirect), |
| 781 | .help = "Use O_DIRECT IO (negates buffered)", |
| 782 | .def = "0", |
| 783 | }, |
| 784 | { |
| 785 | .name = "buffered", |
| 786 | .type = FIO_OPT_BOOL, |
| 787 | .off1 = td_var_offset(odirect), |
| 788 | .neg = 1, |
| 789 | .help = "Use buffered IO (negates direct)", |
| 790 | .def = "1", |
| 791 | }, |
| 792 | { |
| 793 | .name = "overwrite", |
| 794 | .type = FIO_OPT_BOOL, |
| 795 | .off1 = td_var_offset(overwrite), |
| 796 | .help = "When writing, set whether to overwrite current data", |
| 797 | .def = "0", |
| 798 | }, |
| 799 | { |
| 800 | .name = "loops", |
| 801 | .type = FIO_OPT_INT, |
| 802 | .off1 = td_var_offset(loops), |
| 803 | .help = "Number of times to run the job", |
| 804 | .def = "1", |
| 805 | }, |
| 806 | { |
| 807 | .name = "numjobs", |
| 808 | .type = FIO_OPT_INT, |
| 809 | .off1 = td_var_offset(numjobs), |
| 810 | .help = "Duplicate this job this many times", |
| 811 | .def = "1", |
| 812 | }, |
| 813 | { |
| 814 | .name = "startdelay", |
| 815 | .type = FIO_OPT_INT, |
| 816 | .off1 = td_var_offset(start_delay), |
| 817 | .help = "Only start job when this period has passed", |
| 818 | .def = "0", |
| 819 | }, |
| 820 | { |
| 821 | .name = "runtime", |
| 822 | .alias = "timeout", |
| 823 | .type = FIO_OPT_STR_VAL_TIME, |
| 824 | .off1 = td_var_offset(timeout), |
| 825 | .help = "Stop workload when this amount of time has passed", |
| 826 | .def = "0", |
| 827 | }, |
| 828 | { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 829 | .name = "time_based", |
| 830 | .type = FIO_OPT_STR_SET, |
| 831 | .off1 = td_var_offset(time_based), |
| 832 | .help = "Keep running until runtime/timeout is met", |
| 833 | }, |
| 834 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 835 | .name = "mem", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 836 | .alias = "iomem", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 837 | .type = FIO_OPT_STR, |
| 838 | .cb = str_mem_cb, |
| 839 | .off1 = td_var_offset(mem_type), |
| 840 | .help = "Backing type for IO buffers", |
| 841 | .def = "malloc", |
| 842 | .posval = { |
| 843 | { .ival = "malloc", |
| 844 | .oval = MEM_MALLOC, |
| 845 | .help = "Use malloc(3) for IO buffers", |
| 846 | }, |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 847 | { .ival = "shm", |
| 848 | .oval = MEM_SHM, |
| 849 | .help = "Use shared memory segments for IO buffers", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 850 | }, |
| 851 | #ifdef FIO_HAVE_HUGETLB |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 852 | { .ival = "shmhuge", |
| 853 | .oval = MEM_SHMHUGE, |
| 854 | .help = "Like shm, but use huge pages", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 855 | }, |
| 856 | #endif |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 857 | { .ival = "mmap", |
| 858 | .oval = MEM_MMAP, |
| 859 | .help = "Use mmap(2) (file or anon) for IO buffers", |
| 860 | }, |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 861 | #ifdef FIO_HAVE_HUGETLB |
| 862 | { .ival = "mmaphuge", |
| 863 | .oval = MEM_MMAPHUGE, |
| 864 | .help = "Like mmap, but use huge pages", |
| 865 | }, |
| 866 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 867 | }, |
| 868 | }, |
| 869 | { |
| 870 | .name = "verify", |
| 871 | .type = FIO_OPT_STR, |
| 872 | .off1 = td_var_offset(verify), |
| 873 | .help = "Verify data written", |
| 874 | .def = "0", |
| 875 | .posval = { |
| 876 | { .ival = "0", |
| 877 | .oval = VERIFY_NONE, |
| 878 | .help = "Don't do IO verification", |
| 879 | }, |
Jens Axboe | fcca4b5 | 2007-07-27 15:42:00 +0200 | [diff] [blame] | 880 | { .ival = "md5", |
| 881 | .oval = VERIFY_MD5, |
| 882 | .help = "Use md5 checksums for verification", |
| 883 | }, |
Jens Axboe | d77a7af | 2007-07-27 15:35:06 +0200 | [diff] [blame] | 884 | { .ival = "crc64", |
| 885 | .oval = VERIFY_CRC64, |
| 886 | .help = "Use crc64 checksums for verification", |
| 887 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 888 | { .ival = "crc32", |
| 889 | .oval = VERIFY_CRC32, |
| 890 | .help = "Use crc32 checksums for verification", |
| 891 | }, |
Jens Axboe | bac39e0 | 2008-06-11 20:46:19 +0200 | [diff] [blame^] | 892 | { .ival = "crc32c", |
| 893 | .oval = VERIFY_CRC32C, |
| 894 | .help = "Use crc32c checksums for verification", |
| 895 | }, |
Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 896 | { .ival = "crc16", |
| 897 | .oval = VERIFY_CRC16, |
| 898 | .help = "Use crc16 checksums for verification", |
| 899 | }, |
Jens Axboe | 1e154bd | 2007-07-27 09:52:40 +0200 | [diff] [blame] | 900 | { .ival = "crc7", |
| 901 | .oval = VERIFY_CRC7, |
| 902 | .help = "Use crc7 checksums for verification", |
| 903 | }, |
Jens Axboe | cd14cc1 | 2007-07-30 10:59:33 +0200 | [diff] [blame] | 904 | { .ival = "sha256", |
| 905 | .oval = VERIFY_SHA256, |
| 906 | .help = "Use sha256 checksums for verification", |
| 907 | }, |
| 908 | { .ival = "sha512", |
| 909 | .oval = VERIFY_SHA512, |
| 910 | .help = "Use sha512 checksums for verification", |
| 911 | }, |
Shawn Lewis | 7437ee8 | 2007-08-02 21:05:58 +0200 | [diff] [blame] | 912 | { .ival = "meta", |
| 913 | .oval = VERIFY_META, |
| 914 | .help = "Use io information", |
| 915 | }, |
Jens Axboe | 36690c9 | 2007-03-26 10:23:34 +0200 | [diff] [blame] | 916 | { |
| 917 | .ival = "null", |
| 918 | .oval = VERIFY_NULL, |
| 919 | .help = "Pretend to verify", |
| 920 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 921 | }, |
| 922 | }, |
| 923 | { |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 924 | .name = "do_verify", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 925 | .type = FIO_OPT_BOOL, |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 926 | .off1 = td_var_offset(do_verify), |
| 927 | .help = "Run verification stage after write", |
| 928 | .def = "1", |
| 929 | .parent = "verify", |
| 930 | }, |
| 931 | { |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 932 | .name = "verifysort", |
| 933 | .type = FIO_OPT_BOOL, |
| 934 | .off1 = td_var_offset(verifysort), |
| 935 | .help = "Sort written verify blocks for read back", |
| 936 | .def = "1", |
Jens Axboe | c83f2df | 2007-07-31 22:51:47 +0200 | [diff] [blame] | 937 | .parent = "verify", |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 938 | }, |
| 939 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 940 | .name = "verify_interval", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 941 | .type = FIO_OPT_STR_VAL_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 942 | .off1 = td_var_offset(verify_interval), |
Jens Axboe | 819a968 | 2007-07-28 21:30:31 +0200 | [diff] [blame] | 943 | .minval = 2 * sizeof(struct verify_header), |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 944 | .help = "Store verify buffer header every N bytes", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 945 | .parent = "verify", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 946 | }, |
| 947 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 948 | .name = "verify_offset", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 949 | .type = FIO_OPT_STR_VAL_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 950 | .help = "Offset verify header location by N bytes", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 951 | .def = "0", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 952 | .cb = str_verify_offset_cb, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 953 | .parent = "verify", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 954 | }, |
| 955 | { |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 956 | .name = "verify_pattern", |
| 957 | .type = FIO_OPT_INT, |
| 958 | .cb = str_verify_pattern_cb, |
| 959 | .help = "Fill pattern for IO buffers", |
| 960 | .parent = "verify", |
| 961 | }, |
| 962 | { |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 963 | .name = "verify_fatal", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 964 | .type = FIO_OPT_BOOL, |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 965 | .off1 = td_var_offset(verify_fatal), |
| 966 | .def = "0", |
| 967 | .help = "Exit on a single verify failure, don't continue", |
| 968 | .parent = "verify", |
| 969 | }, |
| 970 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 971 | .name = "write_iolog", |
| 972 | .type = FIO_OPT_STR_STORE, |
| 973 | .off1 = td_var_offset(write_iolog_file), |
| 974 | .help = "Store IO pattern to file", |
| 975 | }, |
| 976 | { |
| 977 | .name = "read_iolog", |
| 978 | .type = FIO_OPT_STR_STORE, |
| 979 | .off1 = td_var_offset(read_iolog_file), |
| 980 | .help = "Playback IO pattern from file", |
| 981 | }, |
| 982 | { |
| 983 | .name = "exec_prerun", |
| 984 | .type = FIO_OPT_STR_STORE, |
| 985 | .off1 = td_var_offset(exec_prerun), |
| 986 | .help = "Execute this file prior to running job", |
| 987 | }, |
| 988 | { |
| 989 | .name = "exec_postrun", |
| 990 | .type = FIO_OPT_STR_STORE, |
| 991 | .off1 = td_var_offset(exec_postrun), |
| 992 | .help = "Execute this file after running job", |
| 993 | }, |
| 994 | #ifdef FIO_HAVE_IOSCHED_SWITCH |
| 995 | { |
| 996 | .name = "ioscheduler", |
| 997 | .type = FIO_OPT_STR_STORE, |
| 998 | .off1 = td_var_offset(ioscheduler), |
| 999 | .help = "Use this IO scheduler on the backing device", |
| 1000 | }, |
| 1001 | #endif |
| 1002 | { |
| 1003 | .name = "zonesize", |
| 1004 | .type = FIO_OPT_STR_VAL, |
| 1005 | .off1 = td_var_offset(zone_size), |
| 1006 | .help = "Give size of an IO zone", |
| 1007 | .def = "0", |
| 1008 | }, |
| 1009 | { |
| 1010 | .name = "zoneskip", |
| 1011 | .type = FIO_OPT_STR_VAL, |
| 1012 | .off1 = td_var_offset(zone_skip), |
| 1013 | .help = "Space between IO zones", |
| 1014 | .def = "0", |
| 1015 | }, |
| 1016 | { |
| 1017 | .name = "lockmem", |
| 1018 | .type = FIO_OPT_STR_VAL, |
| 1019 | .cb = str_lockmem_cb, |
| 1020 | .help = "Lock down this amount of memory", |
| 1021 | .def = "0", |
| 1022 | }, |
| 1023 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1024 | .name = "rwmixread", |
| 1025 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1026 | .cb = str_rwmix_read_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1027 | .maxval = 100, |
| 1028 | .help = "Percentage of mixed workload that is reads", |
| 1029 | .def = "50", |
| 1030 | }, |
| 1031 | { |
| 1032 | .name = "rwmixwrite", |
| 1033 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1034 | .cb = str_rwmix_write_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1035 | .maxval = 100, |
| 1036 | .help = "Percentage of mixed workload that is writes", |
| 1037 | .def = "50", |
| 1038 | }, |
| 1039 | { |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1040 | .name = "rwmixcycle", |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 1041 | .type = FIO_OPT_DEPRECATED, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1042 | }, |
| 1043 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1044 | .name = "nice", |
| 1045 | .type = FIO_OPT_INT, |
| 1046 | .off1 = td_var_offset(nice), |
| 1047 | .help = "Set job CPU nice value", |
| 1048 | .minval = -19, |
| 1049 | .maxval = 20, |
| 1050 | .def = "0", |
| 1051 | }, |
| 1052 | #ifdef FIO_HAVE_IOPRIO |
| 1053 | { |
| 1054 | .name = "prio", |
| 1055 | .type = FIO_OPT_INT, |
| 1056 | .cb = str_prio_cb, |
| 1057 | .help = "Set job IO priority value", |
| 1058 | .minval = 0, |
| 1059 | .maxval = 7, |
| 1060 | }, |
| 1061 | { |
| 1062 | .name = "prioclass", |
| 1063 | .type = FIO_OPT_INT, |
| 1064 | .cb = str_prioclass_cb, |
| 1065 | .help = "Set job IO priority class", |
| 1066 | .minval = 0, |
| 1067 | .maxval = 3, |
| 1068 | }, |
| 1069 | #endif |
| 1070 | { |
| 1071 | .name = "thinktime", |
| 1072 | .type = FIO_OPT_INT, |
| 1073 | .off1 = td_var_offset(thinktime), |
| 1074 | .help = "Idle time between IO buffers (usec)", |
| 1075 | .def = "0", |
| 1076 | }, |
| 1077 | { |
| 1078 | .name = "thinktime_spin", |
| 1079 | .type = FIO_OPT_INT, |
| 1080 | .off1 = td_var_offset(thinktime_spin), |
| 1081 | .help = "Start think time by spinning this amount (usec)", |
| 1082 | .def = "0", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1083 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1084 | }, |
| 1085 | { |
| 1086 | .name = "thinktime_blocks", |
| 1087 | .type = FIO_OPT_INT, |
| 1088 | .off1 = td_var_offset(thinktime_blocks), |
| 1089 | .help = "IO buffer period between 'thinktime'", |
| 1090 | .def = "1", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1091 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1092 | }, |
| 1093 | { |
| 1094 | .name = "rate", |
| 1095 | .type = FIO_OPT_INT, |
| 1096 | .off1 = td_var_offset(rate), |
| 1097 | .help = "Set bandwidth rate", |
| 1098 | }, |
| 1099 | { |
| 1100 | .name = "ratemin", |
| 1101 | .type = FIO_OPT_INT, |
| 1102 | .off1 = td_var_offset(ratemin), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1103 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1104 | .parent = "rate", |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1105 | }, |
| 1106 | { |
| 1107 | .name = "rate_iops", |
| 1108 | .type = FIO_OPT_INT, |
| 1109 | .off1 = td_var_offset(rate_iops), |
| 1110 | .help = "Limit IO used to this number of IO operations/sec", |
| 1111 | }, |
| 1112 | { |
| 1113 | .name = "rate_iops_min", |
| 1114 | .type = FIO_OPT_INT, |
| 1115 | .off1 = td_var_offset(rate_iops_min), |
| 1116 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1117 | .parent = "rate_iops", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1118 | }, |
| 1119 | { |
| 1120 | .name = "ratecycle", |
| 1121 | .type = FIO_OPT_INT, |
| 1122 | .off1 = td_var_offset(ratecycle), |
| 1123 | .help = "Window average for rate limits (msec)", |
| 1124 | .def = "1000", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1125 | .parent = "rate", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1126 | }, |
| 1127 | { |
| 1128 | .name = "invalidate", |
| 1129 | .type = FIO_OPT_BOOL, |
| 1130 | .off1 = td_var_offset(invalidate_cache), |
| 1131 | .help = "Invalidate buffer/page cache prior to running job", |
| 1132 | .def = "1", |
| 1133 | }, |
| 1134 | { |
| 1135 | .name = "sync", |
| 1136 | .type = FIO_OPT_BOOL, |
| 1137 | .off1 = td_var_offset(sync_io), |
| 1138 | .help = "Use O_SYNC for buffered writes", |
| 1139 | .def = "0", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1140 | .parent = "buffered", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1141 | }, |
| 1142 | { |
| 1143 | .name = "bwavgtime", |
| 1144 | .type = FIO_OPT_INT, |
| 1145 | .off1 = td_var_offset(bw_avg_time), |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 1146 | .help = "Time window over which to calculate bandwidth" |
| 1147 | " (msec)", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1148 | .def = "500", |
| 1149 | }, |
| 1150 | { |
| 1151 | .name = "create_serialize", |
| 1152 | .type = FIO_OPT_BOOL, |
| 1153 | .off1 = td_var_offset(create_serialize), |
| 1154 | .help = "Serialize creating of job files", |
| 1155 | .def = "1", |
| 1156 | }, |
| 1157 | { |
| 1158 | .name = "create_fsync", |
| 1159 | .type = FIO_OPT_BOOL, |
| 1160 | .off1 = td_var_offset(create_fsync), |
| 1161 | .help = "Fsync file after creation", |
| 1162 | .def = "1", |
| 1163 | }, |
| 1164 | { |
| 1165 | .name = "cpuload", |
| 1166 | .type = FIO_OPT_INT, |
| 1167 | .off1 = td_var_offset(cpuload), |
| 1168 | .help = "Use this percentage of CPU", |
| 1169 | }, |
| 1170 | { |
| 1171 | .name = "cpuchunks", |
| 1172 | .type = FIO_OPT_INT, |
| 1173 | .off1 = td_var_offset(cpucycle), |
| 1174 | .help = "Length of the CPU burn cycles (usecs)", |
| 1175 | .def = "50000", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1176 | .parent = "cpuload", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1177 | }, |
| 1178 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1179 | { |
| 1180 | .name = "cpumask", |
| 1181 | .type = FIO_OPT_INT, |
| 1182 | .cb = str_cpumask_cb, |
| 1183 | .help = "CPU affinity mask", |
| 1184 | }, |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 1185 | { |
| 1186 | .name = "cpus_allowed", |
| 1187 | .type = FIO_OPT_STR, |
| 1188 | .cb = str_cpus_allowed_cb, |
| 1189 | .help = "Set CPUs allowed", |
| 1190 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1191 | #endif |
| 1192 | { |
| 1193 | .name = "end_fsync", |
| 1194 | .type = FIO_OPT_BOOL, |
| 1195 | .off1 = td_var_offset(end_fsync), |
| 1196 | .help = "Include fsync at the end of job", |
| 1197 | .def = "0", |
| 1198 | }, |
| 1199 | { |
| 1200 | .name = "fsync_on_close", |
| 1201 | .type = FIO_OPT_BOOL, |
| 1202 | .off1 = td_var_offset(fsync_on_close), |
| 1203 | .help = "fsync files on close", |
| 1204 | .def = "0", |
| 1205 | }, |
| 1206 | { |
| 1207 | .name = "unlink", |
| 1208 | .type = FIO_OPT_BOOL, |
| 1209 | .off1 = td_var_offset(unlink), |
| 1210 | .help = "Unlink created files after job has completed", |
| 1211 | .def = "0", |
| 1212 | }, |
| 1213 | { |
| 1214 | .name = "exitall", |
| 1215 | .type = FIO_OPT_STR_SET, |
| 1216 | .cb = str_exitall_cb, |
| 1217 | .help = "Terminate all jobs when one exits", |
| 1218 | }, |
| 1219 | { |
| 1220 | .name = "stonewall", |
| 1221 | .type = FIO_OPT_STR_SET, |
| 1222 | .off1 = td_var_offset(stonewall), |
| 1223 | .help = "Insert a hard barrier between this job and previous", |
| 1224 | }, |
| 1225 | { |
Jens Axboe | b3d62a7 | 2007-03-20 14:23:26 +0100 | [diff] [blame] | 1226 | .name = "new_group", |
| 1227 | .type = FIO_OPT_STR_SET, |
| 1228 | .off1 = td_var_offset(new_group), |
| 1229 | .help = "Mark the start of a new group (for reporting)", |
| 1230 | }, |
| 1231 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1232 | .name = "thread", |
| 1233 | .type = FIO_OPT_STR_SET, |
| 1234 | .off1 = td_var_offset(use_thread), |
| 1235 | .help = "Use threads instead of forks", |
| 1236 | }, |
| 1237 | { |
| 1238 | .name = "write_bw_log", |
| 1239 | .type = FIO_OPT_STR_SET, |
| 1240 | .off1 = td_var_offset(write_bw_log), |
| 1241 | .help = "Write log of bandwidth during run", |
| 1242 | }, |
| 1243 | { |
| 1244 | .name = "write_lat_log", |
| 1245 | .type = FIO_OPT_STR_SET, |
| 1246 | .off1 = td_var_offset(write_lat_log), |
| 1247 | .help = "Write log of latency during run", |
| 1248 | }, |
| 1249 | { |
| 1250 | .name = "hugepage-size", |
Aaron Carroll | 357f618 | 2008-02-20 09:14:13 +0100 | [diff] [blame] | 1251 | .type = FIO_OPT_STR_VAL_INT, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1252 | .off1 = td_var_offset(hugepage_size), |
| 1253 | .help = "When using hugepages, specify size of each page", |
| 1254 | .def = __stringify(FIO_HUGE_PAGE), |
| 1255 | }, |
| 1256 | { |
| 1257 | .name = "group_reporting", |
| 1258 | .type = FIO_OPT_STR_SET, |
| 1259 | .off1 = td_var_offset(group_reporting), |
| 1260 | .help = "Do reporting on a per-group basis", |
| 1261 | }, |
| 1262 | { |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1263 | .name = "zero_buffers", |
| 1264 | .type = FIO_OPT_STR_SET, |
| 1265 | .off1 = td_var_offset(zero_buffers), |
| 1266 | .help = "Init IO buffers to all zeroes", |
| 1267 | }, |
Jens Axboe | 5973caf | 2008-05-21 19:52:35 +0200 | [diff] [blame] | 1268 | { |
| 1269 | .name = "refill_buffers", |
| 1270 | .type = FIO_OPT_STR_SET, |
| 1271 | .off1 = td_var_offset(refill_buffers), |
| 1272 | .help = "Refill IO buffers on every IO submit", |
| 1273 | }, |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 1274 | #ifdef FIO_HAVE_DISK_UTIL |
| 1275 | { |
| 1276 | .name = "disk_util", |
| 1277 | .type = FIO_OPT_BOOL, |
| 1278 | .off1 = td_var_offset(do_disk_util), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 1279 | .help = "Log disk utilization statistics", |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 1280 | .def = "1", |
| 1281 | }, |
| 1282 | #endif |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1283 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1284 | .name = NULL, |
| 1285 | }, |
| 1286 | }; |
| 1287 | |
| 1288 | void fio_options_dup_and_init(struct option *long_options) |
| 1289 | { |
| 1290 | struct fio_option *o; |
| 1291 | unsigned int i; |
| 1292 | |
| 1293 | options_init(options); |
| 1294 | |
| 1295 | i = 0; |
| 1296 | while (long_options[i].name) |
| 1297 | i++; |
| 1298 | |
| 1299 | o = &options[0]; |
| 1300 | while (o->name) { |
Jens Axboe | 5921e80 | 2008-05-30 15:02:38 +0200 | [diff] [blame] | 1301 | long_options[i].name = (char *) o->name; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1302 | long_options[i].val = FIO_GETOPT_JOB; |
| 1303 | if (o->type == FIO_OPT_STR_SET) |
| 1304 | long_options[i].has_arg = no_argument; |
| 1305 | else |
| 1306 | long_options[i].has_arg = required_argument; |
| 1307 | |
| 1308 | i++; |
| 1309 | o++; |
| 1310 | assert(i < FIO_NR_OPTIONS); |
| 1311 | } |
| 1312 | } |
| 1313 | |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 1314 | 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] | 1315 | { |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 1316 | int i, ret; |
| 1317 | |
| 1318 | sort_options(opts, options, num_opts); |
| 1319 | |
| 1320 | for (ret = 0, i = 0; i < num_opts; i++) |
| 1321 | ret |= parse_option(opts[i], options, td); |
| 1322 | |
| 1323 | return ret; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) |
| 1327 | { |
| 1328 | return parse_cmd_option(opt, val, options, td); |
| 1329 | } |
| 1330 | |
| 1331 | void fio_fill_default_options(struct thread_data *td) |
| 1332 | { |
| 1333 | fill_default_options(td, options); |
| 1334 | } |
| 1335 | |
| 1336 | int fio_show_option_help(const char *opt) |
| 1337 | { |
| 1338 | return show_cmd_help(options, opt); |
| 1339 | } |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1340 | |
| 1341 | static void __options_mem(struct thread_data *td, int alloc) |
| 1342 | { |
| 1343 | struct thread_options *o = &td->o; |
| 1344 | struct fio_option *opt; |
| 1345 | char **ptr; |
| 1346 | int i; |
| 1347 | |
| 1348 | for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) { |
| 1349 | if (opt->type != FIO_OPT_STR_STORE) |
| 1350 | continue; |
| 1351 | |
| 1352 | ptr = (void *) o + opt->off1; |
| 1353 | if (*ptr) { |
| 1354 | if (alloc) |
| 1355 | *ptr = strdup(*ptr); |
| 1356 | else { |
| 1357 | free(*ptr); |
| 1358 | *ptr = NULL; |
| 1359 | } |
| 1360 | } |
| 1361 | } |
| 1362 | } |
| 1363 | |
| 1364 | /* |
| 1365 | * dupe FIO_OPT_STR_STORE options |
| 1366 | */ |
| 1367 | void options_mem_dupe(struct thread_data *td) |
| 1368 | { |
| 1369 | __options_mem(td, 1); |
| 1370 | } |
| 1371 | |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1372 | void options_mem_free(struct thread_data fio_unused *td) |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1373 | { |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1374 | #if 0 |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1375 | __options_mem(td, 0); |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 1376 | #endif |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 1377 | } |