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