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