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