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 | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 17 | #include "options.h" |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 18 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 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 | |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 35 | static int converthexchartoint(char a) |
| 36 | { |
| 37 | int base; |
| 38 | |
| 39 | switch(a) { |
| 40 | case '0'...'9': |
| 41 | base = '0'; |
| 42 | break; |
| 43 | case 'A'...'F': |
| 44 | base = 'A' - 10; |
| 45 | break; |
| 46 | case 'a'...'f': |
| 47 | base = 'a' - 10; |
| 48 | break; |
| 49 | default: |
| 50 | base = 0; |
| 51 | } |
| 52 | return (a - base); |
| 53 | } |
| 54 | |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 55 | static int bs_cmp(const void *p1, const void *p2) |
| 56 | { |
| 57 | const struct bssplit *bsp1 = p1; |
| 58 | const struct bssplit *bsp2 = p2; |
| 59 | |
| 60 | return bsp1->perc < bsp2->perc; |
| 61 | } |
| 62 | |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 63 | static int bssplit_ddir(struct thread_data *td, int ddir, char *str) |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 64 | { |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 65 | struct bssplit *bssplit; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 66 | unsigned int i, perc, perc_missing; |
| 67 | unsigned int max_bs, min_bs; |
| 68 | long long val; |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 69 | char *fname; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 70 | |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 71 | td->o.bssplit_nr[ddir] = 4; |
| 72 | bssplit = malloc(4 * sizeof(struct bssplit)); |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 73 | |
| 74 | i = 0; |
| 75 | max_bs = 0; |
| 76 | min_bs = -1; |
| 77 | while ((fname = strsep(&str, ":")) != NULL) { |
| 78 | char *perc_str; |
| 79 | |
| 80 | if (!strlen(fname)) |
| 81 | break; |
| 82 | |
| 83 | /* |
| 84 | * grow struct buffer, if needed |
| 85 | */ |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 86 | if (i == td->o.bssplit_nr[ddir]) { |
| 87 | td->o.bssplit_nr[ddir] <<= 1; |
| 88 | bssplit = realloc(bssplit, td->o.bssplit_nr[ddir] |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 89 | * sizeof(struct bssplit)); |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | perc_str = strstr(fname, "/"); |
| 93 | if (perc_str) { |
| 94 | *perc_str = '\0'; |
| 95 | perc_str++; |
| 96 | perc = atoi(perc_str); |
| 97 | if (perc > 100) |
| 98 | perc = 100; |
| 99 | else if (!perc) |
| 100 | perc = -1; |
| 101 | } else |
| 102 | perc = -1; |
| 103 | |
Kenneth Waters | df9cf92 | 2009-10-15 07:08:48 +0200 | [diff] [blame] | 104 | if (str_to_decimal(fname, &val, 1, td)) { |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 105 | log_err("fio: bssplit conversion failed\n"); |
| 106 | free(td->o.bssplit); |
| 107 | return 1; |
| 108 | } |
| 109 | |
| 110 | if (val > max_bs) |
| 111 | max_bs = val; |
| 112 | if (val < min_bs) |
| 113 | min_bs = val; |
| 114 | |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 115 | bssplit[i].bs = val; |
| 116 | bssplit[i].perc = perc; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 117 | i++; |
| 118 | } |
| 119 | |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 120 | td->o.bssplit_nr[ddir] = i; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Now check if the percentages add up, and how much is missing |
| 124 | */ |
| 125 | perc = perc_missing = 0; |
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 | perc_missing++; |
| 131 | else |
| 132 | perc += bsp->perc; |
| 133 | } |
| 134 | |
| 135 | if (perc > 100) { |
| 136 | log_err("fio: bssplit percentages add to more than 100%%\n"); |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 137 | free(bssplit); |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 138 | return 1; |
| 139 | } |
| 140 | /* |
| 141 | * If values didn't have a percentage set, divide the remains between |
| 142 | * them. |
| 143 | */ |
| 144 | if (perc_missing) { |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 145 | for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { |
| 146 | struct bssplit *bsp = &bssplit[i]; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 147 | |
| 148 | if (bsp->perc == (unsigned char) -1) |
| 149 | bsp->perc = (100 - perc) / perc_missing; |
| 150 | } |
| 151 | } |
| 152 | |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 153 | td->o.min_bs[ddir] = min_bs; |
| 154 | td->o.max_bs[ddir] = max_bs; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * now sort based on percentages, for ease of lookup |
| 158 | */ |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 159 | qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp); |
| 160 | td->o.bssplit[ddir] = bssplit; |
| 161 | return 0; |
| 162 | |
| 163 | } |
| 164 | |
| 165 | static int str_bssplit_cb(void *data, const char *input) |
| 166 | { |
| 167 | struct thread_data *td = data; |
| 168 | char *str, *p, *odir; |
| 169 | int ret = 0; |
| 170 | |
| 171 | p = str = strdup(input); |
| 172 | |
| 173 | strip_blank_front(&str); |
| 174 | strip_blank_end(str); |
| 175 | |
| 176 | odir = strchr(str, ','); |
| 177 | if (odir) { |
| 178 | ret = bssplit_ddir(td, DDIR_WRITE, odir + 1); |
| 179 | if (!ret) { |
| 180 | *odir = '\0'; |
| 181 | ret = bssplit_ddir(td, DDIR_READ, str); |
| 182 | } |
| 183 | } else { |
| 184 | char *op; |
| 185 | |
| 186 | op = strdup(str); |
| 187 | |
| 188 | ret = bssplit_ddir(td, DDIR_READ, str); |
| 189 | if (!ret) |
| 190 | ret = bssplit_ddir(td, DDIR_WRITE, op); |
| 191 | |
| 192 | free(op); |
| 193 | } |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 194 | |
| 195 | free(p); |
Jens Axboe | 720e84a | 2009-04-21 08:29:55 +0200 | [diff] [blame] | 196 | return ret; |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 197 | } |
| 198 | |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 199 | static int str_rw_cb(void *data, const char *str) |
| 200 | { |
| 201 | struct thread_data *td = data; |
| 202 | char *nr = get_opt_postfix(str); |
| 203 | |
Jens Axboe | fafdba3 | 2007-03-26 10:09:12 +0200 | [diff] [blame] | 204 | td->o.ddir_nr = 1; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 205 | if (nr) { |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 206 | td->o.ddir_nr = atoi(nr); |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 207 | free(nr); |
| 208 | } |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 209 | |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 210 | return 0; |
| 211 | } |
| 212 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 213 | static int str_mem_cb(void *data, const char *mem) |
| 214 | { |
| 215 | struct thread_data *td = data; |
| 216 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 217 | 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] | 218 | td->mmapfile = get_opt_postfix(mem); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 219 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 220 | log_err("fio: mmaphuge:/path/to/file\n"); |
| 221 | return 1; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 228 | static int fio_clock_source_cb(void *data, const char *str) |
| 229 | { |
| 230 | struct thread_data *td = data; |
| 231 | |
| 232 | fio_clock_source = td->o.clocksource; |
| 233 | fio_time_init(); |
| 234 | return 0; |
| 235 | } |
| 236 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 237 | static int str_lockmem_cb(void fio_unused *data, unsigned long *val) |
| 238 | { |
| 239 | mlock_size = *val; |
| 240 | return 0; |
| 241 | } |
| 242 | |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 243 | static int str_rwmix_read_cb(void *data, unsigned int *val) |
| 244 | { |
| 245 | struct thread_data *td = data; |
| 246 | |
| 247 | td->o.rwmix[DDIR_READ] = *val; |
| 248 | td->o.rwmix[DDIR_WRITE] = 100 - *val; |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | static int str_rwmix_write_cb(void *data, unsigned int *val) |
| 253 | { |
| 254 | struct thread_data *td = data; |
| 255 | |
| 256 | td->o.rwmix[DDIR_WRITE] = *val; |
| 257 | td->o.rwmix[DDIR_READ] = 100 - *val; |
| 258 | return 0; |
| 259 | } |
| 260 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 261 | #ifdef FIO_HAVE_IOPRIO |
| 262 | static int str_prioclass_cb(void *data, unsigned int *val) |
| 263 | { |
| 264 | struct thread_data *td = data; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 265 | unsigned short mask; |
| 266 | |
| 267 | /* |
| 268 | * mask off old class bits, str_prio_cb() may have set a default class |
| 269 | */ |
| 270 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; |
| 271 | td->ioprio &= mask; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 272 | |
| 273 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 274 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | static int str_prio_cb(void *data, unsigned int *val) |
| 279 | { |
| 280 | struct thread_data *td = data; |
| 281 | |
| 282 | td->ioprio |= *val; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 283 | |
| 284 | /* |
| 285 | * If no class is set, assume BE |
| 286 | */ |
| 287 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) |
| 288 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; |
| 289 | |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 290 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 291 | return 0; |
| 292 | } |
| 293 | #endif |
| 294 | |
| 295 | static int str_exitall_cb(void) |
| 296 | { |
| 297 | exitall_on_terminate = 1; |
| 298 | return 0; |
| 299 | } |
| 300 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 301 | #ifdef FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 302 | static int str_cpumask_cb(void *data, unsigned int *val) |
| 303 | { |
| 304 | struct thread_data *td = data; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 305 | unsigned int i; |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 306 | long max_cpu; |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 307 | int ret; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 308 | |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 309 | ret = fio_cpuset_init(&td->o.cpumask); |
| 310 | if (ret < 0) { |
| 311 | log_err("fio: cpuset_init failed\n"); |
| 312 | td_verror(td, ret, "fio_cpuset_init"); |
| 313 | return 1; |
| 314 | } |
| 315 | |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 316 | max_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 317 | |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 318 | for (i = 0; i < sizeof(int) * 8; i++) { |
| 319 | if ((1 << i) & *val) { |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 320 | if (i > max_cpu) { |
| 321 | log_err("fio: CPU %d too large (max=%ld)\n", i, |
| 322 | max_cpu); |
| 323 | return 1; |
| 324 | } |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 325 | dprint(FD_PARSE, "set cpu allowed %d\n", i); |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 326 | fio_cpu_set(&td->o.cpumask, i); |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 327 | } |
| 328 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 329 | |
Jens Axboe | 375b269 | 2007-05-22 09:13:02 +0200 | [diff] [blame] | 330 | td->o.cpumask_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 334 | static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask, |
| 335 | const char *input) |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 336 | { |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 337 | char *cpu, *str, *p; |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 338 | long max_cpu; |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 339 | int ret = 0; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 340 | |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 341 | ret = fio_cpuset_init(mask); |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 342 | if (ret < 0) { |
| 343 | log_err("fio: cpuset_init failed\n"); |
| 344 | td_verror(td, ret, "fio_cpuset_init"); |
| 345 | return 1; |
| 346 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 347 | |
| 348 | p = str = strdup(input); |
| 349 | |
| 350 | strip_blank_front(&str); |
| 351 | strip_blank_end(str); |
| 352 | |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 353 | max_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
| 354 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 355 | while ((cpu = strsep(&str, ",")) != NULL) { |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 356 | char *str2, *cpu2; |
| 357 | int icpu, icpu2; |
| 358 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 359 | if (!strlen(cpu)) |
| 360 | break; |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 361 | |
| 362 | str2 = cpu; |
| 363 | icpu2 = -1; |
| 364 | while ((cpu2 = strsep(&str2, "-")) != NULL) { |
| 365 | if (!strlen(cpu2)) |
| 366 | break; |
| 367 | |
| 368 | icpu2 = atoi(cpu2); |
| 369 | } |
| 370 | |
| 371 | icpu = atoi(cpu); |
| 372 | if (icpu2 == -1) |
| 373 | icpu2 = icpu; |
| 374 | while (icpu <= icpu2) { |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 375 | if (icpu >= FIO_MAX_CPUS) { |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 376 | log_err("fio: your OS only supports up to" |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 377 | " %d CPUs\n", (int) FIO_MAX_CPUS); |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 378 | ret = 1; |
| 379 | break; |
| 380 | } |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 381 | if (icpu > max_cpu) { |
| 382 | log_err("fio: CPU %d too large (max=%ld)\n", |
| 383 | icpu, max_cpu); |
| 384 | ret = 1; |
| 385 | break; |
| 386 | } |
Jens Axboe | 0b9d69e | 2009-09-11 22:29:54 +0200 | [diff] [blame] | 387 | |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 388 | dprint(FD_PARSE, "set cpu allowed %d\n", icpu); |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 389 | fio_cpu_set(mask, icpu); |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 390 | icpu++; |
| 391 | } |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 392 | if (ret) |
| 393 | break; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | free(p); |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 397 | if (!ret) |
| 398 | td->o.cpumask_set = 1; |
| 399 | return ret; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 400 | } |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 401 | |
| 402 | static int str_cpus_allowed_cb(void *data, const char *input) |
| 403 | { |
| 404 | struct thread_data *td = data; |
| 405 | int ret; |
| 406 | |
| 407 | ret = set_cpus_allowed(td, &td->o.cpumask, input); |
| 408 | if (!ret) |
| 409 | td->o.cpumask_set = 1; |
| 410 | |
| 411 | return ret; |
| 412 | } |
| 413 | |
| 414 | static int str_verify_cpus_allowed_cb(void *data, const char *input) |
| 415 | { |
| 416 | struct thread_data *td = data; |
| 417 | int ret; |
| 418 | |
| 419 | ret = set_cpus_allowed(td, &td->o.verify_cpumask, input); |
| 420 | if (!ret) |
| 421 | td->o.verify_cpumask_set = 1; |
| 422 | |
| 423 | return ret; |
| 424 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 425 | #endif |
| 426 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 427 | static int str_fst_cb(void *data, const char *str) |
| 428 | { |
| 429 | struct thread_data *td = data; |
| 430 | char *nr = get_opt_postfix(str); |
| 431 | |
| 432 | td->file_service_nr = 1; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 433 | if (nr) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 434 | td->file_service_nr = atoi(nr); |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 435 | free(nr); |
| 436 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Jens Axboe | 3ae0637 | 2010-03-19 19:17:15 +0100 | [diff] [blame] | 441 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 442 | static int str_sfr_cb(void *data, const char *str) |
| 443 | { |
| 444 | struct thread_data *td = data; |
| 445 | char *nr = get_opt_postfix(str); |
| 446 | |
| 447 | td->sync_file_range_nr = 1; |
| 448 | if (nr) { |
| 449 | td->sync_file_range_nr = atoi(nr); |
| 450 | free(nr); |
| 451 | } |
| 452 | |
| 453 | return 0; |
| 454 | } |
Jens Axboe | 3ae0637 | 2010-03-19 19:17:15 +0100 | [diff] [blame] | 455 | #endif |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 456 | |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 457 | static int check_dir(struct thread_data *td, char *fname) |
| 458 | { |
| 459 | char file[PATH_MAX], *dir; |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 460 | int elen = 0; |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 461 | |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 462 | if (td->o.directory) { |
| 463 | strcpy(file, td->o.directory); |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 464 | strcat(file, "/"); |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 465 | elen = strlen(file); |
| 466 | } |
| 467 | |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 468 | sprintf(file + elen, "%s", fname); |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 469 | dir = dirname(file); |
| 470 | |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 471 | #if 0 |
| 472 | { |
| 473 | struct stat sb; |
| 474 | /* |
| 475 | * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded |
| 476 | * yet, so we can't do this check right here... |
| 477 | */ |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 478 | if (lstat(dir, &sb) < 0) { |
| 479 | int ret = errno; |
| 480 | |
| 481 | log_err("fio: %s is not a directory\n", dir); |
| 482 | td_verror(td, ret, "lstat"); |
| 483 | return 1; |
| 484 | } |
| 485 | |
| 486 | if (!S_ISDIR(sb.st_mode)) { |
| 487 | log_err("fio: %s is not a directory\n", dir); |
| 488 | return 1; |
| 489 | } |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 490 | } |
| 491 | #endif |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 492 | |
| 493 | return 0; |
| 494 | } |
| 495 | |
Jens Axboe | 8e827d3 | 2009-08-04 09:51:48 +0200 | [diff] [blame] | 496 | /* |
| 497 | * Return next file in the string. Files are separated with ':'. If the ':' |
| 498 | * is escaped with a '\', then that ':' is part of the filename and does not |
| 499 | * indicate a new file. |
| 500 | */ |
| 501 | static char *get_next_file_name(char **ptr) |
| 502 | { |
| 503 | char *str = *ptr; |
| 504 | char *p, *start; |
| 505 | |
| 506 | if (!str || !strlen(str)) |
| 507 | return NULL; |
| 508 | |
| 509 | start = str; |
| 510 | do { |
| 511 | /* |
| 512 | * No colon, we are done |
| 513 | */ |
| 514 | p = strchr(str, ':'); |
| 515 | if (!p) { |
| 516 | *ptr = NULL; |
| 517 | break; |
| 518 | } |
| 519 | |
| 520 | /* |
| 521 | * We got a colon, but it's the first character. Skip and |
| 522 | * continue |
| 523 | */ |
| 524 | if (p == start) { |
| 525 | str = ++start; |
| 526 | continue; |
| 527 | } |
| 528 | |
| 529 | if (*(p - 1) != '\\') { |
| 530 | *p = '\0'; |
| 531 | *ptr = p + 1; |
| 532 | break; |
| 533 | } |
| 534 | |
| 535 | memmove(p - 1, p, strlen(p) + 1); |
| 536 | str = p; |
| 537 | } while (1); |
| 538 | |
| 539 | return start; |
| 540 | } |
| 541 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 542 | static int str_filename_cb(void *data, const char *input) |
| 543 | { |
| 544 | struct thread_data *td = data; |
| 545 | char *fname, *str, *p; |
| 546 | |
| 547 | p = str = strdup(input); |
| 548 | |
| 549 | strip_blank_front(&str); |
| 550 | strip_blank_end(str); |
| 551 | |
| 552 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 553 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 554 | |
Jens Axboe | 8e827d3 | 2009-08-04 09:51:48 +0200 | [diff] [blame] | 555 | while ((fname = get_next_file_name(&str)) != NULL) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 556 | if (!strlen(fname)) |
| 557 | break; |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 558 | if (check_dir(td, fname)) { |
| 559 | free(p); |
| 560 | return 1; |
| 561 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 562 | add_file(td, fname); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 563 | td->o.nr_files++; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | free(p); |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | static int str_directory_cb(void *data, const char fio_unused *str) |
| 571 | { |
| 572 | struct thread_data *td = data; |
| 573 | struct stat sb; |
| 574 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 575 | if (lstat(td->o.directory, &sb) < 0) { |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 576 | int ret = errno; |
| 577 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 578 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 579 | td_verror(td, ret, "lstat"); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 580 | return 1; |
| 581 | } |
| 582 | if (!S_ISDIR(sb.st_mode)) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 583 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 584 | return 1; |
| 585 | } |
| 586 | |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | static int str_opendir_cb(void *data, const char fio_unused *str) |
| 591 | { |
| 592 | struct thread_data *td = data; |
| 593 | |
| 594 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 595 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 596 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 597 | return add_dir_files(td, td->o.opendir); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 598 | } |
| 599 | |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 600 | static int str_verify_offset_cb(void *data, unsigned int *off) |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 601 | { |
| 602 | struct thread_data *td = data; |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 603 | |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 604 | if (*off && *off < sizeof(struct verify_header)) { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 605 | log_err("fio: verify_offset too small\n"); |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 606 | return 1; |
| 607 | } |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 608 | |
| 609 | td->o.verify_offset = *off; |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 610 | return 0; |
| 611 | } |
| 612 | |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 613 | static int str_verify_pattern_cb(void *data, const char *input) |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 614 | { |
| 615 | struct thread_data *td = data; |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 616 | long off; |
| 617 | int i = 0, j = 0, len, k, base = 10; |
| 618 | char* loc1, * loc2; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 619 | |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 620 | loc1 = strstr(input, "0x"); |
| 621 | loc2 = strstr(input, "0X"); |
| 622 | if (loc1 || loc2) |
| 623 | base = 16; |
| 624 | off = strtol(input, NULL, base); |
| 625 | if (off != LONG_MAX || errno != ERANGE) { |
| 626 | while (off) { |
| 627 | td->o.verify_pattern[i] = off & 0xff; |
| 628 | off >>= 8; |
| 629 | i++; |
| 630 | } |
| 631 | } else { |
| 632 | len = strlen(input); |
| 633 | k = len - 1; |
| 634 | if (base == 16) { |
| 635 | if (loc1) |
| 636 | j = loc1 - input + 2; |
| 637 | else |
| 638 | j = loc2 - input + 2; |
| 639 | } else |
| 640 | return 1; |
| 641 | if (len - j < MAX_PATTERN_SIZE * 2) { |
| 642 | while (k >= j) { |
| 643 | off = converthexchartoint(input[k--]); |
| 644 | if (k >= j) |
| 645 | off += (converthexchartoint(input[k--]) |
| 646 | * 16); |
| 647 | td->o.verify_pattern[i++] = (char) off; |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | td->o.verify_pattern_bytes = i; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 652 | return 0; |
| 653 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 654 | |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 655 | static int str_lockfile_cb(void *data, const char *str) |
| 656 | { |
| 657 | struct thread_data *td = data; |
| 658 | char *nr = get_opt_postfix(str); |
| 659 | |
| 660 | td->o.lockfile_batch = 1; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 661 | if (nr) { |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 662 | td->o.lockfile_batch = atoi(nr); |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 663 | free(nr); |
| 664 | } |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 665 | |
| 666 | return 0; |
| 667 | } |
| 668 | |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 669 | static int str_write_bw_log_cb(void *data, const char *str) |
| 670 | { |
| 671 | struct thread_data *td = data; |
| 672 | |
| 673 | if (str) |
| 674 | td->o.bw_log_file = strdup(str); |
| 675 | |
| 676 | td->o.write_bw_log = 1; |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | static int str_write_lat_log_cb(void *data, const char *str) |
| 681 | { |
| 682 | struct thread_data *td = data; |
| 683 | |
| 684 | if (str) |
| 685 | td->o.lat_log_file = strdup(str); |
| 686 | |
| 687 | td->o.write_lat_log = 1; |
| 688 | return 0; |
| 689 | } |
| 690 | |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 691 | static int str_gtod_reduce_cb(void *data, int *il) |
| 692 | { |
| 693 | struct thread_data *td = data; |
| 694 | int val = *il; |
| 695 | |
| 696 | td->o.disable_clat = !!val; |
| 697 | td->o.disable_slat = !!val; |
| 698 | td->o.disable_bw = !!val; |
| 699 | if (val) |
| 700 | td->tv_cache_mask = 63; |
| 701 | |
| 702 | return 0; |
| 703 | } |
| 704 | |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 705 | static int str_gtod_cpu_cb(void *data, int *il) |
| 706 | { |
| 707 | struct thread_data *td = data; |
| 708 | int val = *il; |
| 709 | |
| 710 | td->o.gtod_cpu = val; |
| 711 | td->o.gtod_offload = 1; |
| 712 | return 0; |
| 713 | } |
| 714 | |
Jens Axboe | 896cac2 | 2009-07-01 10:38:35 +0200 | [diff] [blame] | 715 | static int rw_verify(struct fio_option *o, void *data) |
| 716 | { |
| 717 | struct thread_data *td = data; |
| 718 | |
| 719 | if (read_only && td_write(td)) { |
| 720 | log_err("fio: job <%s> has write bit set, but fio is in" |
| 721 | " read-only mode\n", td->o.name); |
| 722 | return 1; |
| 723 | } |
| 724 | |
| 725 | return 0; |
| 726 | } |
| 727 | |
Jens Axboe | 276ca4f | 2009-07-01 10:43:05 +0200 | [diff] [blame] | 728 | static int gtod_cpu_verify(struct fio_option *o, void *data) |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 729 | { |
Jens Axboe | 276ca4f | 2009-07-01 10:43:05 +0200 | [diff] [blame] | 730 | #ifndef FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 731 | struct thread_data *td = data; |
| 732 | |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 733 | if (td->o.gtod_cpu) { |
| 734 | log_err("fio: platform must support CPU affinity for" |
| 735 | "gettimeofday() offloading\n"); |
| 736 | return 1; |
| 737 | } |
| 738 | #endif |
| 739 | |
| 740 | return 0; |
| 741 | } |
| 742 | |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 743 | static int kb_base_verify(struct fio_option *o, void *data) |
| 744 | { |
| 745 | struct thread_data *td = data; |
| 746 | |
| 747 | if (td->o.kb_base != 1024 && td->o.kb_base != 1000) { |
| 748 | log_err("fio: kb_base set to nonsensical value: %u\n", |
| 749 | td->o.kb_base); |
| 750 | return 1; |
| 751 | } |
| 752 | |
| 753 | return 0; |
| 754 | } |
| 755 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 756 | #define __stringify_1(x) #x |
| 757 | #define __stringify(x) __stringify_1(x) |
| 758 | |
| 759 | /* |
| 760 | * Map of job/command line options |
| 761 | */ |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 762 | static struct fio_option options[FIO_MAX_OPTS] = { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 763 | { |
| 764 | .name = "description", |
| 765 | .type = FIO_OPT_STR_STORE, |
| 766 | .off1 = td_var_offset(description), |
| 767 | .help = "Text job description", |
| 768 | }, |
| 769 | { |
| 770 | .name = "name", |
| 771 | .type = FIO_OPT_STR_STORE, |
| 772 | .off1 = td_var_offset(name), |
| 773 | .help = "Name of this job", |
| 774 | }, |
| 775 | { |
| 776 | .name = "directory", |
| 777 | .type = FIO_OPT_STR_STORE, |
| 778 | .off1 = td_var_offset(directory), |
| 779 | .cb = str_directory_cb, |
| 780 | .help = "Directory to store files in", |
| 781 | }, |
| 782 | { |
| 783 | .name = "filename", |
| 784 | .type = FIO_OPT_STR_STORE, |
| 785 | .off1 = td_var_offset(filename), |
| 786 | .cb = str_filename_cb, |
Jens Axboe | f0d524b | 2009-04-27 08:00:48 +0200 | [diff] [blame] | 787 | .prio = -1, /* must come after "directory" */ |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 788 | .help = "File(s) to use for the workload", |
| 789 | }, |
| 790 | { |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 791 | .name = "kb_base", |
| 792 | .type = FIO_OPT_INT, |
| 793 | .off1 = td_var_offset(kb_base), |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 794 | .verify = kb_base_verify, |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 795 | .prio = 1, |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 796 | .def = "1024", |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 797 | .help = "How many bytes per KB for reporting (1000 or 1024)", |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 798 | }, |
| 799 | { |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 800 | .name = "lockfile", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 801 | .type = FIO_OPT_STR, |
| 802 | .cb = str_lockfile_cb, |
| 803 | .off1 = td_var_offset(file_lock_mode), |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 804 | .help = "Lock file when doing IO to it", |
| 805 | .parent = "filename", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 806 | .def = "none", |
| 807 | .posval = { |
| 808 | { .ival = "none", |
| 809 | .oval = FILE_LOCK_NONE, |
| 810 | .help = "No file locking", |
| 811 | }, |
| 812 | { .ival = "exclusive", |
| 813 | .oval = FILE_LOCK_EXCLUSIVE, |
| 814 | .help = "Exclusive file lock", |
| 815 | }, |
| 816 | { |
| 817 | .ival = "readwrite", |
| 818 | .oval = FILE_LOCK_READWRITE, |
| 819 | .help = "Read vs write lock", |
| 820 | }, |
| 821 | }, |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 822 | }, |
| 823 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 824 | .name = "opendir", |
| 825 | .type = FIO_OPT_STR_STORE, |
| 826 | .off1 = td_var_offset(opendir), |
| 827 | .cb = str_opendir_cb, |
| 828 | .help = "Recursively add files from this directory and down", |
| 829 | }, |
| 830 | { |
| 831 | .name = "rw", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 832 | .alias = "readwrite", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 833 | .type = FIO_OPT_STR, |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 834 | .cb = str_rw_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 835 | .off1 = td_var_offset(td_ddir), |
| 836 | .help = "IO direction", |
| 837 | .def = "read", |
Jens Axboe | 896cac2 | 2009-07-01 10:38:35 +0200 | [diff] [blame] | 838 | .verify = rw_verify, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 839 | .posval = { |
| 840 | { .ival = "read", |
| 841 | .oval = TD_DDIR_READ, |
| 842 | .help = "Sequential read", |
| 843 | }, |
| 844 | { .ival = "write", |
| 845 | .oval = TD_DDIR_WRITE, |
| 846 | .help = "Sequential write", |
| 847 | }, |
| 848 | { .ival = "randread", |
| 849 | .oval = TD_DDIR_RANDREAD, |
| 850 | .help = "Random read", |
| 851 | }, |
| 852 | { .ival = "randwrite", |
| 853 | .oval = TD_DDIR_RANDWRITE, |
| 854 | .help = "Random write", |
| 855 | }, |
| 856 | { .ival = "rw", |
| 857 | .oval = TD_DDIR_RW, |
| 858 | .help = "Sequential read and write mix", |
| 859 | }, |
| 860 | { .ival = "randrw", |
| 861 | .oval = TD_DDIR_RANDRW, |
| 862 | .help = "Random read and write mix" |
| 863 | }, |
| 864 | }, |
| 865 | }, |
| 866 | { |
| 867 | .name = "ioengine", |
| 868 | .type = FIO_OPT_STR_STORE, |
| 869 | .off1 = td_var_offset(ioengine), |
| 870 | .help = "IO engine to use", |
| 871 | .def = "sync", |
| 872 | .posval = { |
| 873 | { .ival = "sync", |
| 874 | .help = "Use read/write", |
| 875 | }, |
gurudas pai | a31041e | 2007-10-23 15:12:30 +0200 | [diff] [blame] | 876 | { .ival = "psync", |
| 877 | .help = "Use pread/pwrite", |
| 878 | }, |
Jens Axboe | 1d2af02 | 2008-02-04 10:59:07 +0100 | [diff] [blame] | 879 | { .ival = "vsync", |
| 880 | .help = "Use readv/writev", |
| 881 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 882 | #ifdef FIO_HAVE_LIBAIO |
| 883 | { .ival = "libaio", |
| 884 | .help = "Linux native asynchronous IO", |
| 885 | }, |
| 886 | #endif |
| 887 | #ifdef FIO_HAVE_POSIXAIO |
| 888 | { .ival = "posixaio", |
| 889 | .help = "POSIX asynchronous IO", |
| 890 | }, |
| 891 | #endif |
Jens Axboe | 417f006 | 2008-06-02 11:59:30 +0200 | [diff] [blame] | 892 | #ifdef FIO_HAVE_SOLARISAIO |
| 893 | { .ival = "solarisaio", |
| 894 | .help = "Solaris native asynchronous IO", |
| 895 | }, |
| 896 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 897 | { .ival = "mmap", |
| 898 | .help = "Memory mapped IO", |
| 899 | }, |
| 900 | #ifdef FIO_HAVE_SPLICE |
| 901 | { .ival = "splice", |
| 902 | .help = "splice/vmsplice based IO", |
| 903 | }, |
Jens Axboe | 9cce02e | 2007-06-22 15:42:21 +0200 | [diff] [blame] | 904 | { .ival = "netsplice", |
| 905 | .help = "splice/vmsplice to/from the network", |
| 906 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 907 | #endif |
| 908 | #ifdef FIO_HAVE_SGIO |
| 909 | { .ival = "sg", |
| 910 | .help = "SCSI generic v3 IO", |
| 911 | }, |
| 912 | #endif |
| 913 | { .ival = "null", |
| 914 | .help = "Testing engine (no data transfer)", |
| 915 | }, |
| 916 | { .ival = "net", |
| 917 | .help = "Network IO", |
| 918 | }, |
| 919 | #ifdef FIO_HAVE_SYSLET |
| 920 | { .ival = "syslet-rw", |
| 921 | .help = "syslet enabled async pread/pwrite IO", |
| 922 | }, |
| 923 | #endif |
| 924 | { .ival = "cpuio", |
| 925 | .help = "CPU cycler burner engine", |
| 926 | }, |
Jens Axboe | b8c82a4 | 2007-03-21 08:48:26 +0100 | [diff] [blame] | 927 | #ifdef FIO_HAVE_GUASI |
| 928 | { .ival = "guasi", |
| 929 | .help = "GUASI IO engine", |
| 930 | }, |
| 931 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 932 | { .ival = "external", |
| 933 | .help = "Load external engine (append name)", |
| 934 | }, |
| 935 | }, |
| 936 | }, |
| 937 | { |
| 938 | .name = "iodepth", |
| 939 | .type = FIO_OPT_INT, |
| 940 | .off1 = td_var_offset(iodepth), |
| 941 | .help = "Amount of IO buffers to keep in flight", |
Jens Axboe | 757aff4 | 2007-12-12 19:42:13 +0100 | [diff] [blame] | 942 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 943 | .def = "1", |
| 944 | }, |
| 945 | { |
| 946 | .name = "iodepth_batch", |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 947 | .alias = "iodepth_batch_submit", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 948 | .type = FIO_OPT_INT, |
| 949 | .off1 = td_var_offset(iodepth_batch), |
Jens Axboe | d65db44 | 2009-01-16 19:15:33 +0100 | [diff] [blame] | 950 | .help = "Number of IO buffers to submit in one go", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 951 | .parent = "iodepth", |
Jens Axboe | a2e6f8a | 2008-01-18 10:28:11 +0100 | [diff] [blame] | 952 | .minval = 1, |
| 953 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 954 | }, |
| 955 | { |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 956 | .name = "iodepth_batch_complete", |
| 957 | .type = FIO_OPT_INT, |
| 958 | .off1 = td_var_offset(iodepth_batch_complete), |
Jens Axboe | d65db44 | 2009-01-16 19:15:33 +0100 | [diff] [blame] | 959 | .help = "Number of IO buffers to retrieve in one go", |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 960 | .parent = "iodepth", |
| 961 | .minval = 0, |
| 962 | .def = "1", |
| 963 | }, |
| 964 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 965 | .name = "iodepth_low", |
| 966 | .type = FIO_OPT_INT, |
| 967 | .off1 = td_var_offset(iodepth_low), |
| 968 | .help = "Low water mark for queuing depth", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 969 | .parent = "iodepth", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 970 | }, |
| 971 | { |
| 972 | .name = "size", |
| 973 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 974 | .off1 = td_var_offset(size), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 975 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 976 | .help = "Total size of device or files", |
| 977 | }, |
| 978 | { |
Shawn Lewis | aa31f1f | 2008-01-11 09:45:11 +0100 | [diff] [blame] | 979 | .name = "fill_device", |
| 980 | .type = FIO_OPT_BOOL, |
| 981 | .off1 = td_var_offset(fill_device), |
| 982 | .help = "Write until an ENOSPC error occurs", |
| 983 | .def = "0", |
| 984 | }, |
| 985 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 986 | .name = "filesize", |
| 987 | .type = FIO_OPT_STR_VAL, |
| 988 | .off1 = td_var_offset(file_size_low), |
| 989 | .off2 = td_var_offset(file_size_high), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 990 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 991 | .help = "Size of individual files", |
| 992 | }, |
| 993 | { |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 994 | .name = "offset", |
| 995 | .alias = "fileoffset", |
| 996 | .type = FIO_OPT_STR_VAL, |
| 997 | .off1 = td_var_offset(start_offset), |
| 998 | .help = "Start IO from this offset", |
| 999 | .def = "0", |
| 1000 | }, |
| 1001 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1002 | .name = "bs", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1003 | .alias = "blocksize", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1004 | .type = FIO_OPT_INT, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1005 | .off1 = td_var_offset(bs[DDIR_READ]), |
| 1006 | .off2 = td_var_offset(bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 1007 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1008 | .help = "Block size unit", |
| 1009 | .def = "4k", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1010 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1011 | }, |
| 1012 | { |
Jens Axboe | 2b7a01d | 2009-03-11 11:00:13 +0100 | [diff] [blame] | 1013 | .name = "ba", |
| 1014 | .alias = "blockalign", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1015 | .type = FIO_OPT_INT, |
Jens Axboe | 2b7a01d | 2009-03-11 11:00:13 +0100 | [diff] [blame] | 1016 | .off1 = td_var_offset(ba[DDIR_READ]), |
| 1017 | .off2 = td_var_offset(ba[DDIR_WRITE]), |
| 1018 | .minval = 1, |
| 1019 | .help = "IO block offset alignment", |
| 1020 | .parent = "rw", |
| 1021 | }, |
| 1022 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1023 | .name = "bsrange", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1024 | .alias = "blocksize_range", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1025 | .type = FIO_OPT_RANGE, |
| 1026 | .off1 = td_var_offset(min_bs[DDIR_READ]), |
| 1027 | .off2 = td_var_offset(max_bs[DDIR_READ]), |
| 1028 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), |
| 1029 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 1030 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1031 | .help = "Set block size range (in more detail than bs)", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1032 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1033 | }, |
| 1034 | { |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 1035 | .name = "bssplit", |
| 1036 | .type = FIO_OPT_STR, |
| 1037 | .cb = str_bssplit_cb, |
| 1038 | .help = "Set a specific mix of block sizes", |
| 1039 | .parent = "rw", |
| 1040 | }, |
| 1041 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1042 | .name = "bs_unaligned", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1043 | .alias = "blocksize_unaligned", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1044 | .type = FIO_OPT_STR_SET, |
| 1045 | .off1 = td_var_offset(bs_unaligned), |
| 1046 | .help = "Don't sector align IO buffer sizes", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1047 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1048 | }, |
| 1049 | { |
| 1050 | .name = "randrepeat", |
| 1051 | .type = FIO_OPT_BOOL, |
| 1052 | .off1 = td_var_offset(rand_repeatable), |
| 1053 | .help = "Use repeatable random IO pattern", |
| 1054 | .def = "1", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1055 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1056 | }, |
| 1057 | { |
| 1058 | .name = "norandommap", |
| 1059 | .type = FIO_OPT_STR_SET, |
| 1060 | .off1 = td_var_offset(norandommap), |
| 1061 | .help = "Accept potential duplicate random blocks", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1062 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1063 | }, |
| 1064 | { |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 1065 | .name = "softrandommap", |
| 1066 | .type = FIO_OPT_BOOL, |
| 1067 | .off1 = td_var_offset(softrandommap), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 1068 | .help = "Set norandommap if randommap allocation fails", |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 1069 | .parent = "norandommap", |
| 1070 | .def = "0", |
| 1071 | }, |
| 1072 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1073 | .name = "nrfiles", |
| 1074 | .type = FIO_OPT_INT, |
| 1075 | .off1 = td_var_offset(nr_files), |
| 1076 | .help = "Split job workload between this number of files", |
| 1077 | .def = "1", |
| 1078 | }, |
| 1079 | { |
| 1080 | .name = "openfiles", |
| 1081 | .type = FIO_OPT_INT, |
| 1082 | .off1 = td_var_offset(open_files), |
| 1083 | .help = "Number of files to keep open at the same time", |
| 1084 | }, |
| 1085 | { |
| 1086 | .name = "file_service_type", |
| 1087 | .type = FIO_OPT_STR, |
| 1088 | .cb = str_fst_cb, |
| 1089 | .off1 = td_var_offset(file_service_type), |
| 1090 | .help = "How to select which file to service next", |
| 1091 | .def = "roundrobin", |
| 1092 | .posval = { |
| 1093 | { .ival = "random", |
| 1094 | .oval = FIO_FSERVICE_RANDOM, |
| 1095 | .help = "Choose a file at random", |
| 1096 | }, |
| 1097 | { .ival = "roundrobin", |
| 1098 | .oval = FIO_FSERVICE_RR, |
| 1099 | .help = "Round robin select files", |
| 1100 | }, |
Jens Axboe | a086c25 | 2009-03-04 08:27:37 +0100 | [diff] [blame] | 1101 | { .ival = "sequential", |
| 1102 | .oval = FIO_FSERVICE_SEQ, |
| 1103 | .help = "Finish one file before moving to the next", |
| 1104 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1105 | }, |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1106 | .parent = "nrfiles", |
| 1107 | }, |
Jens Axboe | 7bc8c2c | 2010-01-28 11:31:31 +0100 | [diff] [blame] | 1108 | #ifdef FIO_HAVE_FALLOCATE |
| 1109 | { |
| 1110 | .name = "fallocate", |
| 1111 | .type = FIO_OPT_BOOL, |
| 1112 | .off1 = td_var_offset(fallocate), |
| 1113 | .help = "Use fallocate() when laying out files", |
| 1114 | .def = "1", |
| 1115 | }, |
| 1116 | #endif |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1117 | { |
| 1118 | .name = "fadvise_hint", |
| 1119 | .type = FIO_OPT_BOOL, |
| 1120 | .off1 = td_var_offset(fadvise_hint), |
| 1121 | .help = "Use fadvise() to advise the kernel on IO pattern", |
| 1122 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1123 | }, |
| 1124 | { |
| 1125 | .name = "fsync", |
| 1126 | .type = FIO_OPT_INT, |
| 1127 | .off1 = td_var_offset(fsync_blocks), |
| 1128 | .help = "Issue fsync for writes every given number of blocks", |
| 1129 | .def = "0", |
| 1130 | }, |
| 1131 | { |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 1132 | .name = "fdatasync", |
| 1133 | .type = FIO_OPT_INT, |
| 1134 | .off1 = td_var_offset(fdatasync_blocks), |
| 1135 | .help = "Issue fdatasync for writes every given number of blocks", |
| 1136 | .def = "0", |
| 1137 | }, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1138 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
| 1139 | { |
| 1140 | .name = "sync_file_range", |
| 1141 | .posval = { |
| 1142 | { .ival = "wait_before", |
| 1143 | .oval = SYNC_FILE_RANGE_WAIT_BEFORE, |
| 1144 | .help = "SYNC_FILE_RANGE_WAIT_BEFORE", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1145 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1146 | }, |
| 1147 | { .ival = "write", |
| 1148 | .oval = SYNC_FILE_RANGE_WRITE, |
| 1149 | .help = "SYNC_FILE_RANGE_WRITE", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1150 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1151 | }, |
| 1152 | { |
| 1153 | .ival = "wait_after", |
| 1154 | .oval = SYNC_FILE_RANGE_WAIT_AFTER, |
| 1155 | .help = "SYNC_FILE_RANGE_WAIT_AFTER", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1156 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1157 | }, |
| 1158 | }, |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1159 | .type = FIO_OPT_STR_MULTI, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1160 | .cb = str_sfr_cb, |
| 1161 | .off1 = td_var_offset(sync_file_range), |
| 1162 | .help = "Use sync_file_range()", |
| 1163 | }, |
| 1164 | #endif |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 1165 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1166 | .name = "direct", |
| 1167 | .type = FIO_OPT_BOOL, |
| 1168 | .off1 = td_var_offset(odirect), |
| 1169 | .help = "Use O_DIRECT IO (negates buffered)", |
| 1170 | .def = "0", |
| 1171 | }, |
| 1172 | { |
| 1173 | .name = "buffered", |
| 1174 | .type = FIO_OPT_BOOL, |
| 1175 | .off1 = td_var_offset(odirect), |
| 1176 | .neg = 1, |
| 1177 | .help = "Use buffered IO (negates direct)", |
| 1178 | .def = "1", |
| 1179 | }, |
| 1180 | { |
| 1181 | .name = "overwrite", |
| 1182 | .type = FIO_OPT_BOOL, |
| 1183 | .off1 = td_var_offset(overwrite), |
| 1184 | .help = "When writing, set whether to overwrite current data", |
| 1185 | .def = "0", |
| 1186 | }, |
| 1187 | { |
| 1188 | .name = "loops", |
| 1189 | .type = FIO_OPT_INT, |
| 1190 | .off1 = td_var_offset(loops), |
| 1191 | .help = "Number of times to run the job", |
| 1192 | .def = "1", |
| 1193 | }, |
| 1194 | { |
| 1195 | .name = "numjobs", |
| 1196 | .type = FIO_OPT_INT, |
| 1197 | .off1 = td_var_offset(numjobs), |
| 1198 | .help = "Duplicate this job this many times", |
| 1199 | .def = "1", |
| 1200 | }, |
| 1201 | { |
| 1202 | .name = "startdelay", |
| 1203 | .type = FIO_OPT_INT, |
| 1204 | .off1 = td_var_offset(start_delay), |
| 1205 | .help = "Only start job when this period has passed", |
| 1206 | .def = "0", |
| 1207 | }, |
| 1208 | { |
| 1209 | .name = "runtime", |
| 1210 | .alias = "timeout", |
| 1211 | .type = FIO_OPT_STR_VAL_TIME, |
| 1212 | .off1 = td_var_offset(timeout), |
| 1213 | .help = "Stop workload when this amount of time has passed", |
| 1214 | .def = "0", |
| 1215 | }, |
| 1216 | { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 1217 | .name = "time_based", |
| 1218 | .type = FIO_OPT_STR_SET, |
| 1219 | .off1 = td_var_offset(time_based), |
| 1220 | .help = "Keep running until runtime/timeout is met", |
| 1221 | }, |
| 1222 | { |
Jens Axboe | 721938a | 2008-09-10 09:46:16 +0200 | [diff] [blame] | 1223 | .name = "ramp_time", |
| 1224 | .type = FIO_OPT_STR_VAL_TIME, |
| 1225 | .off1 = td_var_offset(ramp_time), |
| 1226 | .help = "Ramp up time before measuring performance", |
| 1227 | }, |
| 1228 | { |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 1229 | .name = "clocksource", |
| 1230 | .type = FIO_OPT_STR, |
| 1231 | .cb = fio_clock_source_cb, |
| 1232 | .off1 = td_var_offset(clocksource), |
| 1233 | .help = "What type of timing source to use", |
| 1234 | .def = "gettimeofday", |
| 1235 | .posval = { |
| 1236 | { .ival = "gettimeofday", |
| 1237 | .oval = CS_GTOD, |
| 1238 | .help = "Use gettimeofday(2) for timing", |
| 1239 | }, |
| 1240 | { .ival = "clock_gettime", |
| 1241 | .oval = CS_CGETTIME, |
| 1242 | .help = "Use clock_gettime(2) for timing", |
| 1243 | }, |
| 1244 | #ifdef ARCH_HAVE_CPU_CLOCK |
| 1245 | { .ival = "cpu", |
| 1246 | .oval = CS_CPUCLOCK, |
| 1247 | .help = "Use CPU private clock", |
| 1248 | }, |
| 1249 | #endif |
| 1250 | }, |
| 1251 | }, |
| 1252 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1253 | .name = "mem", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1254 | .alias = "iomem", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1255 | .type = FIO_OPT_STR, |
| 1256 | .cb = str_mem_cb, |
| 1257 | .off1 = td_var_offset(mem_type), |
| 1258 | .help = "Backing type for IO buffers", |
| 1259 | .def = "malloc", |
| 1260 | .posval = { |
| 1261 | { .ival = "malloc", |
| 1262 | .oval = MEM_MALLOC, |
| 1263 | .help = "Use malloc(3) for IO buffers", |
| 1264 | }, |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 1265 | { .ival = "shm", |
| 1266 | .oval = MEM_SHM, |
| 1267 | .help = "Use shared memory segments for IO buffers", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1268 | }, |
| 1269 | #ifdef FIO_HAVE_HUGETLB |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 1270 | { .ival = "shmhuge", |
| 1271 | .oval = MEM_SHMHUGE, |
| 1272 | .help = "Like shm, but use huge pages", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1273 | }, |
| 1274 | #endif |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 1275 | { .ival = "mmap", |
| 1276 | .oval = MEM_MMAP, |
| 1277 | .help = "Use mmap(2) (file or anon) for IO buffers", |
| 1278 | }, |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 1279 | #ifdef FIO_HAVE_HUGETLB |
| 1280 | { .ival = "mmaphuge", |
| 1281 | .oval = MEM_MMAPHUGE, |
| 1282 | .help = "Like mmap, but use huge pages", |
| 1283 | }, |
| 1284 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1285 | }, |
| 1286 | }, |
| 1287 | { |
Jens Axboe | d529ee1 | 2009-07-01 10:33:03 +0200 | [diff] [blame] | 1288 | .name = "iomem_align", |
| 1289 | .alias = "mem_align", |
| 1290 | .type = FIO_OPT_INT, |
| 1291 | .off1 = td_var_offset(mem_align), |
| 1292 | .minval = 0, |
| 1293 | .help = "IO memory buffer offset alignment", |
| 1294 | .def = "0", |
| 1295 | .parent = "iomem", |
| 1296 | }, |
| 1297 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1298 | .name = "verify", |
| 1299 | .type = FIO_OPT_STR, |
| 1300 | .off1 = td_var_offset(verify), |
| 1301 | .help = "Verify data written", |
| 1302 | .def = "0", |
| 1303 | .posval = { |
| 1304 | { .ival = "0", |
| 1305 | .oval = VERIFY_NONE, |
| 1306 | .help = "Don't do IO verification", |
| 1307 | }, |
Jens Axboe | fcca4b5 | 2007-07-27 15:42:00 +0200 | [diff] [blame] | 1308 | { .ival = "md5", |
| 1309 | .oval = VERIFY_MD5, |
| 1310 | .help = "Use md5 checksums for verification", |
| 1311 | }, |
Jens Axboe | d77a7af | 2007-07-27 15:35:06 +0200 | [diff] [blame] | 1312 | { .ival = "crc64", |
| 1313 | .oval = VERIFY_CRC64, |
| 1314 | .help = "Use crc64 checksums for verification", |
| 1315 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1316 | { .ival = "crc32", |
| 1317 | .oval = VERIFY_CRC32, |
| 1318 | .help = "Use crc32 checksums for verification", |
| 1319 | }, |
Jens Axboe | af497e6 | 2008-08-04 15:40:35 +0200 | [diff] [blame] | 1320 | { .ival = "crc32c-intel", |
| 1321 | .oval = VERIFY_CRC32C_INTEL, |
| 1322 | .help = "Use hw crc32c checksums for verification", |
| 1323 | }, |
Jens Axboe | bac39e0 | 2008-06-11 20:46:19 +0200 | [diff] [blame] | 1324 | { .ival = "crc32c", |
| 1325 | .oval = VERIFY_CRC32C, |
| 1326 | .help = "Use crc32c checksums for verification", |
| 1327 | }, |
Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 1328 | { .ival = "crc16", |
| 1329 | .oval = VERIFY_CRC16, |
| 1330 | .help = "Use crc16 checksums for verification", |
| 1331 | }, |
Jens Axboe | 1e154bd | 2007-07-27 09:52:40 +0200 | [diff] [blame] | 1332 | { .ival = "crc7", |
| 1333 | .oval = VERIFY_CRC7, |
| 1334 | .help = "Use crc7 checksums for verification", |
| 1335 | }, |
Jens Axboe | 7c353ce | 2009-08-09 22:40:33 +0200 | [diff] [blame] | 1336 | { .ival = "sha1", |
| 1337 | .oval = VERIFY_SHA1, |
| 1338 | .help = "Use sha1 checksums for verification", |
| 1339 | }, |
Jens Axboe | cd14cc1 | 2007-07-30 10:59:33 +0200 | [diff] [blame] | 1340 | { .ival = "sha256", |
| 1341 | .oval = VERIFY_SHA256, |
| 1342 | .help = "Use sha256 checksums for verification", |
| 1343 | }, |
| 1344 | { .ival = "sha512", |
| 1345 | .oval = VERIFY_SHA512, |
| 1346 | .help = "Use sha512 checksums for verification", |
| 1347 | }, |
Shawn Lewis | 7437ee8 | 2007-08-02 21:05:58 +0200 | [diff] [blame] | 1348 | { .ival = "meta", |
| 1349 | .oval = VERIFY_META, |
| 1350 | .help = "Use io information", |
| 1351 | }, |
Jens Axboe | 36690c9 | 2007-03-26 10:23:34 +0200 | [diff] [blame] | 1352 | { |
| 1353 | .ival = "null", |
| 1354 | .oval = VERIFY_NULL, |
| 1355 | .help = "Pretend to verify", |
| 1356 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1357 | }, |
| 1358 | }, |
| 1359 | { |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 1360 | .name = "do_verify", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 1361 | .type = FIO_OPT_BOOL, |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 1362 | .off1 = td_var_offset(do_verify), |
| 1363 | .help = "Run verification stage after write", |
| 1364 | .def = "1", |
| 1365 | .parent = "verify", |
| 1366 | }, |
| 1367 | { |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 1368 | .name = "verifysort", |
| 1369 | .type = FIO_OPT_BOOL, |
| 1370 | .off1 = td_var_offset(verifysort), |
| 1371 | .help = "Sort written verify blocks for read back", |
| 1372 | .def = "1", |
Jens Axboe | c83f2df | 2007-07-31 22:51:47 +0200 | [diff] [blame] | 1373 | .parent = "verify", |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 1374 | }, |
| 1375 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1376 | .name = "verify_interval", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1377 | .type = FIO_OPT_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1378 | .off1 = td_var_offset(verify_interval), |
Jens Axboe | 819a968 | 2007-07-28 21:30:31 +0200 | [diff] [blame] | 1379 | .minval = 2 * sizeof(struct verify_header), |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1380 | .help = "Store verify buffer header every N bytes", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1381 | .parent = "verify", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 1382 | }, |
| 1383 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1384 | .name = "verify_offset", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1385 | .type = FIO_OPT_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1386 | .help = "Offset verify header location by N bytes", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 1387 | .def = "0", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 1388 | .cb = str_verify_offset_cb, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1389 | .parent = "verify", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 1390 | }, |
| 1391 | { |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 1392 | .name = "verify_pattern", |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 1393 | .type = FIO_OPT_STR, |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 1394 | .cb = str_verify_pattern_cb, |
| 1395 | .help = "Fill pattern for IO buffers", |
| 1396 | .parent = "verify", |
| 1397 | }, |
| 1398 | { |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 1399 | .name = "verify_fatal", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 1400 | .type = FIO_OPT_BOOL, |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 1401 | .off1 = td_var_offset(verify_fatal), |
| 1402 | .def = "0", |
| 1403 | .help = "Exit on a single verify failure, don't continue", |
| 1404 | .parent = "verify", |
| 1405 | }, |
| 1406 | { |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 1407 | .name = "verify_async", |
| 1408 | .type = FIO_OPT_INT, |
| 1409 | .off1 = td_var_offset(verify_async), |
| 1410 | .def = "0", |
| 1411 | .help = "Number of async verifier threads to use", |
| 1412 | .parent = "verify", |
| 1413 | }, |
| 1414 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1415 | { |
| 1416 | .name = "verify_async_cpus", |
| 1417 | .type = FIO_OPT_STR, |
| 1418 | .cb = str_verify_cpus_allowed_cb, |
| 1419 | .help = "Set CPUs allowed for async verify threads", |
| 1420 | .parent = "verify_async", |
| 1421 | }, |
| 1422 | #endif |
| 1423 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1424 | .name = "write_iolog", |
| 1425 | .type = FIO_OPT_STR_STORE, |
| 1426 | .off1 = td_var_offset(write_iolog_file), |
| 1427 | .help = "Store IO pattern to file", |
| 1428 | }, |
| 1429 | { |
| 1430 | .name = "read_iolog", |
| 1431 | .type = FIO_OPT_STR_STORE, |
| 1432 | .off1 = td_var_offset(read_iolog_file), |
| 1433 | .help = "Playback IO pattern from file", |
| 1434 | }, |
| 1435 | { |
| 1436 | .name = "exec_prerun", |
| 1437 | .type = FIO_OPT_STR_STORE, |
| 1438 | .off1 = td_var_offset(exec_prerun), |
| 1439 | .help = "Execute this file prior to running job", |
| 1440 | }, |
| 1441 | { |
| 1442 | .name = "exec_postrun", |
| 1443 | .type = FIO_OPT_STR_STORE, |
| 1444 | .off1 = td_var_offset(exec_postrun), |
| 1445 | .help = "Execute this file after running job", |
| 1446 | }, |
| 1447 | #ifdef FIO_HAVE_IOSCHED_SWITCH |
| 1448 | { |
| 1449 | .name = "ioscheduler", |
| 1450 | .type = FIO_OPT_STR_STORE, |
| 1451 | .off1 = td_var_offset(ioscheduler), |
| 1452 | .help = "Use this IO scheduler on the backing device", |
| 1453 | }, |
| 1454 | #endif |
| 1455 | { |
| 1456 | .name = "zonesize", |
| 1457 | .type = FIO_OPT_STR_VAL, |
| 1458 | .off1 = td_var_offset(zone_size), |
| 1459 | .help = "Give size of an IO zone", |
| 1460 | .def = "0", |
| 1461 | }, |
| 1462 | { |
| 1463 | .name = "zoneskip", |
| 1464 | .type = FIO_OPT_STR_VAL, |
| 1465 | .off1 = td_var_offset(zone_skip), |
| 1466 | .help = "Space between IO zones", |
| 1467 | .def = "0", |
| 1468 | }, |
| 1469 | { |
| 1470 | .name = "lockmem", |
| 1471 | .type = FIO_OPT_STR_VAL, |
| 1472 | .cb = str_lockmem_cb, |
| 1473 | .help = "Lock down this amount of memory", |
| 1474 | .def = "0", |
| 1475 | }, |
| 1476 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1477 | .name = "rwmixread", |
| 1478 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1479 | .cb = str_rwmix_read_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1480 | .maxval = 100, |
| 1481 | .help = "Percentage of mixed workload that is reads", |
| 1482 | .def = "50", |
| 1483 | }, |
| 1484 | { |
| 1485 | .name = "rwmixwrite", |
| 1486 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1487 | .cb = str_rwmix_write_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1488 | .maxval = 100, |
| 1489 | .help = "Percentage of mixed workload that is writes", |
| 1490 | .def = "50", |
| 1491 | }, |
| 1492 | { |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1493 | .name = "rwmixcycle", |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 1494 | .type = FIO_OPT_DEPRECATED, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1495 | }, |
| 1496 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1497 | .name = "nice", |
| 1498 | .type = FIO_OPT_INT, |
| 1499 | .off1 = td_var_offset(nice), |
| 1500 | .help = "Set job CPU nice value", |
| 1501 | .minval = -19, |
| 1502 | .maxval = 20, |
| 1503 | .def = "0", |
| 1504 | }, |
| 1505 | #ifdef FIO_HAVE_IOPRIO |
| 1506 | { |
| 1507 | .name = "prio", |
| 1508 | .type = FIO_OPT_INT, |
| 1509 | .cb = str_prio_cb, |
| 1510 | .help = "Set job IO priority value", |
| 1511 | .minval = 0, |
| 1512 | .maxval = 7, |
| 1513 | }, |
| 1514 | { |
| 1515 | .name = "prioclass", |
| 1516 | .type = FIO_OPT_INT, |
| 1517 | .cb = str_prioclass_cb, |
| 1518 | .help = "Set job IO priority class", |
| 1519 | .minval = 0, |
| 1520 | .maxval = 3, |
| 1521 | }, |
| 1522 | #endif |
| 1523 | { |
| 1524 | .name = "thinktime", |
| 1525 | .type = FIO_OPT_INT, |
| 1526 | .off1 = td_var_offset(thinktime), |
| 1527 | .help = "Idle time between IO buffers (usec)", |
| 1528 | .def = "0", |
| 1529 | }, |
| 1530 | { |
| 1531 | .name = "thinktime_spin", |
| 1532 | .type = FIO_OPT_INT, |
| 1533 | .off1 = td_var_offset(thinktime_spin), |
| 1534 | .help = "Start think time by spinning this amount (usec)", |
| 1535 | .def = "0", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1536 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1537 | }, |
| 1538 | { |
| 1539 | .name = "thinktime_blocks", |
| 1540 | .type = FIO_OPT_INT, |
| 1541 | .off1 = td_var_offset(thinktime_blocks), |
| 1542 | .help = "IO buffer period between 'thinktime'", |
| 1543 | .def = "1", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1544 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1545 | }, |
| 1546 | { |
| 1547 | .name = "rate", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1548 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1549 | .off1 = td_var_offset(rate[0]), |
| 1550 | .off2 = td_var_offset(rate[1]), |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1551 | .help = "Set bandwidth rate", |
| 1552 | }, |
| 1553 | { |
| 1554 | .name = "ratemin", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1555 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1556 | .off1 = td_var_offset(ratemin[0]), |
| 1557 | .off2 = td_var_offset(ratemin[1]), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1558 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1559 | .parent = "rate", |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1560 | }, |
| 1561 | { |
| 1562 | .name = "rate_iops", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1563 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1564 | .off1 = td_var_offset(rate_iops[0]), |
| 1565 | .off2 = td_var_offset(rate_iops[1]), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1566 | .help = "Limit IO used to this number of IO operations/sec", |
| 1567 | }, |
| 1568 | { |
| 1569 | .name = "rate_iops_min", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1570 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1571 | .off1 = td_var_offset(rate_iops_min[0]), |
| 1572 | .off2 = td_var_offset(rate_iops_min[1]), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1573 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1574 | .parent = "rate_iops", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1575 | }, |
| 1576 | { |
| 1577 | .name = "ratecycle", |
| 1578 | .type = FIO_OPT_INT, |
| 1579 | .off1 = td_var_offset(ratecycle), |
| 1580 | .help = "Window average for rate limits (msec)", |
| 1581 | .def = "1000", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1582 | .parent = "rate", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1583 | }, |
| 1584 | { |
| 1585 | .name = "invalidate", |
| 1586 | .type = FIO_OPT_BOOL, |
| 1587 | .off1 = td_var_offset(invalidate_cache), |
| 1588 | .help = "Invalidate buffer/page cache prior to running job", |
| 1589 | .def = "1", |
| 1590 | }, |
| 1591 | { |
| 1592 | .name = "sync", |
| 1593 | .type = FIO_OPT_BOOL, |
| 1594 | .off1 = td_var_offset(sync_io), |
| 1595 | .help = "Use O_SYNC for buffered writes", |
| 1596 | .def = "0", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1597 | .parent = "buffered", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1598 | }, |
| 1599 | { |
| 1600 | .name = "bwavgtime", |
| 1601 | .type = FIO_OPT_INT, |
| 1602 | .off1 = td_var_offset(bw_avg_time), |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 1603 | .help = "Time window over which to calculate bandwidth" |
| 1604 | " (msec)", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1605 | .def = "500", |
| 1606 | }, |
| 1607 | { |
| 1608 | .name = "create_serialize", |
| 1609 | .type = FIO_OPT_BOOL, |
| 1610 | .off1 = td_var_offset(create_serialize), |
| 1611 | .help = "Serialize creating of job files", |
| 1612 | .def = "1", |
| 1613 | }, |
| 1614 | { |
| 1615 | .name = "create_fsync", |
| 1616 | .type = FIO_OPT_BOOL, |
| 1617 | .off1 = td_var_offset(create_fsync), |
| 1618 | .help = "Fsync file after creation", |
| 1619 | .def = "1", |
| 1620 | }, |
| 1621 | { |
Jens Axboe | 814452b | 2009-03-04 12:53:13 +0100 | [diff] [blame] | 1622 | .name = "create_on_open", |
| 1623 | .type = FIO_OPT_BOOL, |
| 1624 | .off1 = td_var_offset(create_on_open), |
| 1625 | .help = "Create files when they are opened for IO", |
| 1626 | .def = "0", |
| 1627 | }, |
Jens Axboe | 0b9d69e | 2009-09-11 22:29:54 +0200 | [diff] [blame] | 1628 | { |
Zhang, Yanmin | afad68f | 2009-05-20 11:30:55 +0200 | [diff] [blame] | 1629 | .name = "pre_read", |
| 1630 | .type = FIO_OPT_BOOL, |
| 1631 | .off1 = td_var_offset(pre_read), |
| 1632 | .help = "Preread files before starting official testing", |
| 1633 | .def = "0", |
| 1634 | }, |
Jens Axboe | 814452b | 2009-03-04 12:53:13 +0100 | [diff] [blame] | 1635 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1636 | .name = "cpuload", |
| 1637 | .type = FIO_OPT_INT, |
| 1638 | .off1 = td_var_offset(cpuload), |
| 1639 | .help = "Use this percentage of CPU", |
| 1640 | }, |
| 1641 | { |
| 1642 | .name = "cpuchunks", |
| 1643 | .type = FIO_OPT_INT, |
| 1644 | .off1 = td_var_offset(cpucycle), |
| 1645 | .help = "Length of the CPU burn cycles (usecs)", |
| 1646 | .def = "50000", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1647 | .parent = "cpuload", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1648 | }, |
| 1649 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1650 | { |
| 1651 | .name = "cpumask", |
| 1652 | .type = FIO_OPT_INT, |
| 1653 | .cb = str_cpumask_cb, |
| 1654 | .help = "CPU affinity mask", |
| 1655 | }, |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 1656 | { |
| 1657 | .name = "cpus_allowed", |
| 1658 | .type = FIO_OPT_STR, |
| 1659 | .cb = str_cpus_allowed_cb, |
| 1660 | .help = "Set CPUs allowed", |
| 1661 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1662 | #endif |
| 1663 | { |
| 1664 | .name = "end_fsync", |
| 1665 | .type = FIO_OPT_BOOL, |
| 1666 | .off1 = td_var_offset(end_fsync), |
| 1667 | .help = "Include fsync at the end of job", |
| 1668 | .def = "0", |
| 1669 | }, |
| 1670 | { |
| 1671 | .name = "fsync_on_close", |
| 1672 | .type = FIO_OPT_BOOL, |
| 1673 | .off1 = td_var_offset(fsync_on_close), |
| 1674 | .help = "fsync files on close", |
| 1675 | .def = "0", |
| 1676 | }, |
| 1677 | { |
| 1678 | .name = "unlink", |
| 1679 | .type = FIO_OPT_BOOL, |
| 1680 | .off1 = td_var_offset(unlink), |
| 1681 | .help = "Unlink created files after job has completed", |
| 1682 | .def = "0", |
| 1683 | }, |
| 1684 | { |
| 1685 | .name = "exitall", |
| 1686 | .type = FIO_OPT_STR_SET, |
| 1687 | .cb = str_exitall_cb, |
| 1688 | .help = "Terminate all jobs when one exits", |
| 1689 | }, |
| 1690 | { |
| 1691 | .name = "stonewall", |
| 1692 | .type = FIO_OPT_STR_SET, |
| 1693 | .off1 = td_var_offset(stonewall), |
| 1694 | .help = "Insert a hard barrier between this job and previous", |
| 1695 | }, |
| 1696 | { |
Jens Axboe | b3d62a7 | 2007-03-20 14:23:26 +0100 | [diff] [blame] | 1697 | .name = "new_group", |
| 1698 | .type = FIO_OPT_STR_SET, |
| 1699 | .off1 = td_var_offset(new_group), |
| 1700 | .help = "Mark the start of a new group (for reporting)", |
| 1701 | }, |
| 1702 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1703 | .name = "thread", |
| 1704 | .type = FIO_OPT_STR_SET, |
| 1705 | .off1 = td_var_offset(use_thread), |
| 1706 | .help = "Use threads instead of forks", |
| 1707 | }, |
| 1708 | { |
| 1709 | .name = "write_bw_log", |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1710 | .type = FIO_OPT_STR, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1711 | .off1 = td_var_offset(write_bw_log), |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1712 | .cb = str_write_bw_log_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1713 | .help = "Write log of bandwidth during run", |
| 1714 | }, |
| 1715 | { |
| 1716 | .name = "write_lat_log", |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1717 | .type = FIO_OPT_STR, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1718 | .off1 = td_var_offset(write_lat_log), |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1719 | .cb = str_write_lat_log_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1720 | .help = "Write log of latency during run", |
| 1721 | }, |
| 1722 | { |
| 1723 | .name = "hugepage-size", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1724 | .type = FIO_OPT_INT, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1725 | .off1 = td_var_offset(hugepage_size), |
| 1726 | .help = "When using hugepages, specify size of each page", |
| 1727 | .def = __stringify(FIO_HUGE_PAGE), |
| 1728 | }, |
| 1729 | { |
| 1730 | .name = "group_reporting", |
| 1731 | .type = FIO_OPT_STR_SET, |
| 1732 | .off1 = td_var_offset(group_reporting), |
| 1733 | .help = "Do reporting on a per-group basis", |
| 1734 | }, |
| 1735 | { |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1736 | .name = "zero_buffers", |
| 1737 | .type = FIO_OPT_STR_SET, |
| 1738 | .off1 = td_var_offset(zero_buffers), |
| 1739 | .help = "Init IO buffers to all zeroes", |
| 1740 | }, |
Jens Axboe | 5973caf | 2008-05-21 19:52:35 +0200 | [diff] [blame] | 1741 | { |
| 1742 | .name = "refill_buffers", |
| 1743 | .type = FIO_OPT_STR_SET, |
| 1744 | .off1 = td_var_offset(refill_buffers), |
| 1745 | .help = "Refill IO buffers on every IO submit", |
| 1746 | }, |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 1747 | #ifdef FIO_HAVE_DISK_UTIL |
| 1748 | { |
| 1749 | .name = "disk_util", |
| 1750 | .type = FIO_OPT_BOOL, |
| 1751 | .off1 = td_var_offset(do_disk_util), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 1752 | .help = "Log disk utilization statistics", |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 1753 | .def = "1", |
| 1754 | }, |
| 1755 | #endif |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1756 | { |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 1757 | .name = "gtod_reduce", |
| 1758 | .type = FIO_OPT_BOOL, |
| 1759 | .help = "Greatly reduce number of gettimeofday() calls", |
| 1760 | .cb = str_gtod_reduce_cb, |
| 1761 | .def = "0", |
| 1762 | }, |
| 1763 | { |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 1764 | .name = "disable_clat", |
| 1765 | .type = FIO_OPT_BOOL, |
| 1766 | .off1 = td_var_offset(disable_clat), |
| 1767 | .help = "Disable completion latency numbers", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 1768 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 1769 | .def = "0", |
| 1770 | }, |
| 1771 | { |
| 1772 | .name = "disable_slat", |
| 1773 | .type = FIO_OPT_BOOL, |
| 1774 | .off1 = td_var_offset(disable_slat), |
| 1775 | .help = "Disable submissionn latency numbers", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 1776 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 1777 | .def = "0", |
| 1778 | }, |
| 1779 | { |
| 1780 | .name = "disable_bw_measurement", |
| 1781 | .type = FIO_OPT_BOOL, |
| 1782 | .off1 = td_var_offset(disable_bw), |
| 1783 | .help = "Disable bandwidth logging", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 1784 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 1785 | .def = "0", |
| 1786 | }, |
| 1787 | { |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 1788 | .name = "gtod_cpu", |
| 1789 | .type = FIO_OPT_INT, |
| 1790 | .cb = str_gtod_cpu_cb, |
| 1791 | .help = "Setup dedicated gettimeofday() thread on this CPU", |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 1792 | .verify = gtod_cpu_verify, |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 1793 | }, |
| 1794 | { |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 1795 | .name = "continue_on_error", |
| 1796 | .type = FIO_OPT_BOOL, |
| 1797 | .off1 = td_var_offset(continue_on_error), |
| 1798 | .help = "Continue on non-fatal errors during I/O", |
| 1799 | .def = "0", |
| 1800 | }, |
| 1801 | { |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 1802 | .name = "profile", |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 1803 | .type = FIO_OPT_STR_STORE, |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 1804 | .off1 = td_var_offset(profile), |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 1805 | .help = "Select a specific builtin performance test", |
| 1806 | }, |
| 1807 | { |
Jens Axboe | a696fa2 | 2009-12-04 10:05:02 +0100 | [diff] [blame] | 1808 | .name = "cgroup", |
| 1809 | .type = FIO_OPT_STR_STORE, |
| 1810 | .off1 = td_var_offset(cgroup), |
| 1811 | .help = "Add job to cgroup of this name", |
| 1812 | }, |
| 1813 | { |
| 1814 | .name = "cgroup_weight", |
| 1815 | .type = FIO_OPT_INT, |
| 1816 | .off1 = td_var_offset(cgroup_weight), |
| 1817 | .help = "Use given weight for cgroup", |
| 1818 | .minval = 100, |
| 1819 | .maxval = 1000, |
Jens Axboe | a696fa2 | 2009-12-04 10:05:02 +0100 | [diff] [blame] | 1820 | }, |
| 1821 | { |
Jens Axboe | e0b0d89 | 2009-12-08 10:10:14 +0100 | [diff] [blame] | 1822 | .name = "uid", |
| 1823 | .type = FIO_OPT_INT, |
| 1824 | .off1 = td_var_offset(uid), |
| 1825 | .help = "Run job with this user ID", |
| 1826 | }, |
| 1827 | { |
| 1828 | .name = "gid", |
| 1829 | .type = FIO_OPT_INT, |
| 1830 | .off1 = td_var_offset(gid), |
| 1831 | .help = "Run job with this group ID", |
| 1832 | }, |
| 1833 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1834 | .name = NULL, |
| 1835 | }, |
| 1836 | }; |
| 1837 | |
Jens Axboe | 9f81736 | 2010-03-04 14:38:10 +0100 | [diff] [blame] | 1838 | static void add_to_lopt(struct option *lopt, struct fio_option *o) |
| 1839 | { |
| 1840 | lopt->name = (char *) o->name; |
| 1841 | lopt->val = FIO_GETOPT_JOB; |
| 1842 | if (o->type == FIO_OPT_STR_SET) |
| 1843 | lopt->has_arg = no_argument; |
| 1844 | else |
| 1845 | lopt->has_arg = required_argument; |
| 1846 | } |
| 1847 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1848 | void fio_options_dup_and_init(struct option *long_options) |
| 1849 | { |
| 1850 | struct fio_option *o; |
| 1851 | unsigned int i; |
| 1852 | |
| 1853 | options_init(options); |
| 1854 | |
| 1855 | i = 0; |
| 1856 | while (long_options[i].name) |
| 1857 | i++; |
| 1858 | |
| 1859 | o = &options[0]; |
| 1860 | while (o->name) { |
Jens Axboe | 9f81736 | 2010-03-04 14:38:10 +0100 | [diff] [blame] | 1861 | add_to_lopt(&long_options[i], o); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1862 | |
| 1863 | i++; |
| 1864 | o++; |
| 1865 | assert(i < FIO_NR_OPTIONS); |
| 1866 | } |
| 1867 | } |
| 1868 | |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 1869 | struct fio_keyword { |
| 1870 | const char *word; |
| 1871 | const char *desc; |
| 1872 | char *replace; |
| 1873 | }; |
| 1874 | |
| 1875 | static struct fio_keyword fio_keywords[] = { |
| 1876 | { |
| 1877 | .word = "$pagesize", |
| 1878 | .desc = "Page size in the system", |
| 1879 | }, |
| 1880 | { |
| 1881 | .word = "$mb_memory", |
| 1882 | .desc = "Megabytes of memory online", |
| 1883 | }, |
| 1884 | { |
| 1885 | .word = "$ncpus", |
| 1886 | .desc = "Number of CPUs online in the system", |
| 1887 | }, |
| 1888 | { |
| 1889 | .word = NULL, |
| 1890 | }, |
| 1891 | }; |
| 1892 | |
| 1893 | void fio_keywords_init(void) |
| 1894 | { |
Jens Axboe | 3b2e146 | 2009-12-15 08:58:10 +0100 | [diff] [blame] | 1895 | unsigned long long mb_memory; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 1896 | char buf[128]; |
| 1897 | long l; |
| 1898 | |
| 1899 | sprintf(buf, "%lu", page_size); |
| 1900 | fio_keywords[0].replace = strdup(buf); |
| 1901 | |
Jens Axboe | 3b2e146 | 2009-12-15 08:58:10 +0100 | [diff] [blame] | 1902 | mb_memory = os_phys_mem() / page_size; |
| 1903 | sprintf(buf, "%llu", mb_memory); |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 1904 | fio_keywords[1].replace = strdup(buf); |
| 1905 | |
| 1906 | l = sysconf(_SC_NPROCESSORS_ONLN); |
| 1907 | sprintf(buf, "%lu", l); |
| 1908 | fio_keywords[2].replace = strdup(buf); |
| 1909 | } |
| 1910 | |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 1911 | #define BC_APP "bc" |
| 1912 | |
| 1913 | static char *bc_calc(char *str) |
| 1914 | { |
| 1915 | char *buf, *tmp, opt[80]; |
| 1916 | FILE *f; |
| 1917 | int ret; |
| 1918 | |
| 1919 | /* |
| 1920 | * No math, just return string |
| 1921 | */ |
| 1922 | if (!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && |
| 1923 | !strchr(str, '/')) |
| 1924 | return str; |
| 1925 | |
| 1926 | /* |
| 1927 | * Split option from value, we only need to calculate the value |
| 1928 | */ |
| 1929 | tmp = strchr(str, '='); |
| 1930 | if (!tmp) |
| 1931 | return str; |
| 1932 | |
| 1933 | tmp++; |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 1934 | memset(opt, 0, sizeof(opt)); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 1935 | strncpy(opt, str, tmp - str); |
| 1936 | |
| 1937 | buf = malloc(128); |
| 1938 | |
| 1939 | sprintf(buf, "which %s > /dev/null", BC_APP); |
| 1940 | if (system(buf)) { |
| 1941 | log_err("fio: bc is needed for performing math\n"); |
| 1942 | free(buf); |
| 1943 | return NULL; |
| 1944 | } |
| 1945 | |
| 1946 | sprintf(buf, "echo %s | %s", tmp, BC_APP); |
| 1947 | f = popen(buf, "r"); |
| 1948 | if (!f) { |
| 1949 | free(buf); |
| 1950 | return NULL; |
| 1951 | } |
| 1952 | |
| 1953 | ret = fread(buf, 1, 128, f); |
| 1954 | if (ret <= 0) { |
| 1955 | free(buf); |
| 1956 | return NULL; |
| 1957 | } |
| 1958 | |
| 1959 | buf[ret - 1] = '\0'; |
| 1960 | strcat(opt, buf); |
| 1961 | strcpy(buf, opt); |
| 1962 | pclose(f); |
| 1963 | free(str); |
| 1964 | return buf; |
| 1965 | } |
| 1966 | |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 1967 | /* |
| 1968 | * Look for reserved variable names and replace them with real values |
| 1969 | */ |
| 1970 | static char *fio_keyword_replace(char *opt) |
| 1971 | { |
| 1972 | char *s; |
| 1973 | int i; |
| 1974 | |
| 1975 | for (i = 0; fio_keywords[i].word != NULL; i++) { |
| 1976 | struct fio_keyword *kw = &fio_keywords[i]; |
| 1977 | |
| 1978 | while ((s = strstr(opt, kw->word)) != NULL) { |
| 1979 | char *new = malloc(strlen(opt) + 1); |
| 1980 | char *o_org = opt; |
| 1981 | int olen = s - opt; |
| 1982 | int len; |
| 1983 | |
| 1984 | /* |
| 1985 | * Copy part of the string before the keyword and |
| 1986 | * sprintf() the replacement after it. |
| 1987 | */ |
| 1988 | memcpy(new, opt, olen); |
| 1989 | len = sprintf(new + olen, "%s", kw->replace); |
| 1990 | |
| 1991 | /* |
| 1992 | * If there's more in the original string, copy that |
| 1993 | * in too |
| 1994 | */ |
| 1995 | opt += strlen(kw->word) + olen; |
| 1996 | if (strlen(opt)) |
| 1997 | memcpy(new + olen + len, opt, opt - o_org - 1); |
| 1998 | |
| 1999 | /* |
| 2000 | * replace opt and free the old opt |
| 2001 | */ |
| 2002 | opt = new; |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 2003 | //free(o_org); |
Jens Axboe | 7a958bd | 2009-11-13 12:33:54 +0100 | [diff] [blame] | 2004 | |
| 2005 | /* |
| 2006 | * Check for potential math and invoke bc, if possible |
| 2007 | */ |
| 2008 | opt = bc_calc(opt); |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2009 | } |
| 2010 | } |
| 2011 | |
Jens Axboe | 7a958bd | 2009-11-13 12:33:54 +0100 | [diff] [blame] | 2012 | return opt; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2013 | } |
| 2014 | |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2015 | 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] | 2016 | { |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2017 | int i, ret; |
| 2018 | |
| 2019 | sort_options(opts, options, num_opts); |
| 2020 | |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2021 | for (ret = 0, i = 0; i < num_opts; i++) { |
| 2022 | opts[i] = fio_keyword_replace(opts[i]); |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2023 | ret |= parse_option(opts[i], options, td); |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2024 | } |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2025 | |
| 2026 | return ret; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2027 | } |
| 2028 | |
| 2029 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) |
| 2030 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2031 | return parse_cmd_option(opt, val, options, td); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | void fio_fill_default_options(struct thread_data *td) |
| 2035 | { |
| 2036 | fill_default_options(td, options); |
| 2037 | } |
| 2038 | |
| 2039 | int fio_show_option_help(const char *opt) |
| 2040 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2041 | return show_cmd_help(options, opt); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2042 | } |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2043 | |
| 2044 | static void __options_mem(struct thread_data *td, int alloc) |
| 2045 | { |
| 2046 | struct thread_options *o = &td->o; |
| 2047 | struct fio_option *opt; |
| 2048 | char **ptr; |
| 2049 | int i; |
| 2050 | |
| 2051 | for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) { |
| 2052 | if (opt->type != FIO_OPT_STR_STORE) |
| 2053 | continue; |
| 2054 | |
| 2055 | ptr = (void *) o + opt->off1; |
| 2056 | if (*ptr) { |
| 2057 | if (alloc) |
| 2058 | *ptr = strdup(*ptr); |
| 2059 | else { |
| 2060 | free(*ptr); |
| 2061 | *ptr = NULL; |
| 2062 | } |
| 2063 | } |
| 2064 | } |
| 2065 | } |
| 2066 | |
| 2067 | /* |
| 2068 | * dupe FIO_OPT_STR_STORE options |
| 2069 | */ |
| 2070 | void options_mem_dupe(struct thread_data *td) |
| 2071 | { |
| 2072 | __options_mem(td, 1); |
| 2073 | } |
| 2074 | |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 2075 | void options_mem_free(struct thread_data fio_unused *td) |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2076 | { |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 2077 | #if 0 |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2078 | __options_mem(td, 0); |
Jens Axboe | 22d6621 | 2007-03-27 20:06:25 +0200 | [diff] [blame] | 2079 | #endif |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2080 | } |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 2081 | |
| 2082 | unsigned int fio_get_kb_base(void *data) |
| 2083 | { |
| 2084 | struct thread_data *td = data; |
| 2085 | unsigned int kb_base = 0; |
| 2086 | |
| 2087 | if (td) |
| 2088 | kb_base = td->o.kb_base; |
| 2089 | if (!kb_base) |
| 2090 | kb_base = 1024; |
| 2091 | |
| 2092 | return kb_base; |
| 2093 | } |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2094 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2095 | int add_option(struct fio_option *o) |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2096 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2097 | struct fio_option *__o; |
| 2098 | int opt_index = 0; |
| 2099 | |
| 2100 | __o = options; |
| 2101 | while (__o->name) { |
| 2102 | opt_index++; |
| 2103 | __o++; |
| 2104 | } |
| 2105 | |
| 2106 | memcpy(&options[opt_index], o, sizeof(*o)); |
| 2107 | return 0; |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2108 | } |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2109 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2110 | void invalidate_profile_options(const char *prof_name) |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2111 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2112 | struct fio_option *o; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2113 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2114 | o = options; |
| 2115 | while (o->name) { |
| 2116 | if (o->prof_name && !strcmp(o->prof_name, prof_name)) { |
| 2117 | o->type = FIO_OPT_INVALID; |
| 2118 | o->prof_name = NULL; |
| 2119 | } |
| 2120 | o++; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2121 | } |
| 2122 | } |
Jens Axboe | f5b6bb8 | 2010-03-05 10:09:59 +0100 | [diff] [blame] | 2123 | |
| 2124 | void add_opt_posval(const char *optname, const char *ival, const char *help) |
| 2125 | { |
| 2126 | struct fio_option *o; |
| 2127 | unsigned int i; |
| 2128 | |
| 2129 | o = find_option(options, optname); |
| 2130 | if (!o) |
| 2131 | return; |
| 2132 | |
| 2133 | for (i = 0; i < PARSE_MAX_VP; i++) { |
| 2134 | if (o->posval[i].ival) |
| 2135 | continue; |
| 2136 | |
| 2137 | o->posval[i].ival = ival; |
| 2138 | o->posval[i].help = help; |
| 2139 | break; |
| 2140 | } |
| 2141 | } |
| 2142 | |
| 2143 | void del_opt_posval(const char *optname, const char *ival) |
| 2144 | { |
| 2145 | struct fio_option *o; |
| 2146 | unsigned int i; |
| 2147 | |
| 2148 | o = find_option(options, optname); |
| 2149 | if (!o) |
| 2150 | return; |
| 2151 | |
| 2152 | for (i = 0; i < PARSE_MAX_VP; i++) { |
| 2153 | if (!o->posval[i].ival) |
| 2154 | continue; |
| 2155 | if (strcmp(o->posval[i].ival, ival)) |
| 2156 | continue; |
| 2157 | |
| 2158 | o->posval[i].ival = NULL; |
| 2159 | o->posval[i].help = NULL; |
| 2160 | } |
| 2161 | } |