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> |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 6 | #include <assert.h> |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 7 | #include <libgen.h> |
Jens Axboe | 5921e80 | 2008-05-30 15:02:38 +0200 | [diff] [blame] | 8 | #include <fcntl.h> |
| 9 | #include <sys/types.h> |
| 10 | #include <sys/stat.h> |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 11 | |
| 12 | #include "fio.h" |
Jens Axboe | 4f5af7b | 2009-06-03 08:45:40 +0200 | [diff] [blame] | 13 | #include "verify.h" |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 14 | #include "parse.h" |
Jens Axboe | eef3235 | 2008-06-02 13:31:26 +0200 | [diff] [blame] | 15 | #include "lib/fls.h" |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 16 | #include "options.h" |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 17 | |
Jens Axboe | 5d7c5d3 | 2010-06-21 15:08:17 +0200 | [diff] [blame] | 18 | #include "crc/crc32c.h" |
| 19 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 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 | |
Jens Axboe | 6925dd3 | 2011-09-07 22:10:11 +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 | 5736c10 | 2010-07-20 12:03:25 -0600 | [diff] [blame] | 205 | td->o.ddir_seq_nr = 1; |
Jens Axboe | 059b080 | 2011-08-25 09:09:37 +0200 | [diff] [blame] | 206 | td->o.ddir_seq_add = 0; |
| 207 | |
| 208 | if (!nr) |
| 209 | return 0; |
| 210 | |
| 211 | if (td_random(td)) |
Jens Axboe | 5736c10 | 2010-07-20 12:03:25 -0600 | [diff] [blame] | 212 | td->o.ddir_seq_nr = atoi(nr); |
Jens Axboe | 059b080 | 2011-08-25 09:09:37 +0200 | [diff] [blame] | 213 | else { |
| 214 | long long val; |
| 215 | |
Jens Axboe | 6925dd3 | 2011-09-07 22:10:11 +0200 | [diff] [blame] | 216 | if (str_to_decimal(nr, &val, 1, td)) { |
Jens Axboe | 059b080 | 2011-08-25 09:09:37 +0200 | [diff] [blame] | 217 | log_err("fio: rw postfix parsing failed\n"); |
| 218 | free(nr); |
| 219 | return 1; |
| 220 | } |
| 221 | |
| 222 | td->o.ddir_seq_add = val; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 223 | } |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 224 | |
Jens Axboe | 059b080 | 2011-08-25 09:09:37 +0200 | [diff] [blame] | 225 | free(nr); |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 226 | return 0; |
| 227 | } |
| 228 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 229 | static int str_mem_cb(void *data, const char *mem) |
| 230 | { |
| 231 | struct thread_data *td = data; |
| 232 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 233 | 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] | 234 | td->mmapfile = get_opt_postfix(mem); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 235 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 236 | log_err("fio: mmaphuge:/path/to/file\n"); |
| 237 | return 1; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
Jens Axboe | 5d7c5d3 | 2010-06-21 15:08:17 +0200 | [diff] [blame] | 244 | static int str_verify_cb(void *data, const char *mem) |
| 245 | { |
| 246 | struct thread_data *td = data; |
| 247 | |
| 248 | if (td->o.verify != VERIFY_CRC32C_INTEL) |
| 249 | return 0; |
| 250 | |
| 251 | if (!crc32c_intel_works()) { |
| 252 | log_info("fio: System does not support hw accelerated crc32c. Falling back to sw crc32c.\n"); |
| 253 | td->o.verify = VERIFY_CRC32C; |
| 254 | } |
| 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 259 | static int fio_clock_source_cb(void *data, const char *str) |
| 260 | { |
| 261 | struct thread_data *td = data; |
| 262 | |
| 263 | fio_clock_source = td->o.clocksource; |
| 264 | fio_time_init(); |
| 265 | return 0; |
| 266 | } |
| 267 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 268 | static int str_lockmem_cb(void fio_unused *data, unsigned long long *val) |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 269 | { |
| 270 | mlock_size = *val; |
| 271 | return 0; |
| 272 | } |
| 273 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 274 | static int str_rwmix_read_cb(void *data, unsigned long long *val) |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 275 | { |
| 276 | struct thread_data *td = data; |
| 277 | |
| 278 | td->o.rwmix[DDIR_READ] = *val; |
| 279 | td->o.rwmix[DDIR_WRITE] = 100 - *val; |
| 280 | return 0; |
| 281 | } |
| 282 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 283 | static int str_rwmix_write_cb(void *data, unsigned long long *val) |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 284 | { |
| 285 | struct thread_data *td = data; |
| 286 | |
| 287 | td->o.rwmix[DDIR_WRITE] = *val; |
| 288 | td->o.rwmix[DDIR_READ] = 100 - *val; |
| 289 | return 0; |
| 290 | } |
| 291 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 292 | #ifdef FIO_HAVE_IOPRIO |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 293 | static int str_prioclass_cb(void *data, unsigned long long *val) |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 294 | { |
| 295 | struct thread_data *td = data; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 296 | unsigned short mask; |
| 297 | |
| 298 | /* |
| 299 | * mask off old class bits, str_prio_cb() may have set a default class |
| 300 | */ |
| 301 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; |
| 302 | td->ioprio &= mask; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 303 | |
| 304 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 305 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 309 | static int str_prio_cb(void *data, unsigned long long *val) |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 310 | { |
| 311 | struct thread_data *td = data; |
| 312 | |
| 313 | td->ioprio |= *val; |
Jens Axboe | 6cefbe3 | 2007-04-18 12:46:56 +0200 | [diff] [blame] | 314 | |
| 315 | /* |
| 316 | * If no class is set, assume BE |
| 317 | */ |
| 318 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) |
| 319 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; |
| 320 | |
Jens Axboe | ac68478 | 2007-11-08 08:29:07 +0100 | [diff] [blame] | 321 | td->ioprio_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 322 | return 0; |
| 323 | } |
| 324 | #endif |
| 325 | |
| 326 | static int str_exitall_cb(void) |
| 327 | { |
| 328 | exitall_on_terminate = 1; |
| 329 | return 0; |
| 330 | } |
| 331 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 332 | #ifdef FIO_HAVE_CPU_AFFINITY |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 333 | static int str_cpumask_cb(void *data, unsigned long long *val) |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 334 | { |
| 335 | struct thread_data *td = data; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 336 | unsigned int i; |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 337 | long max_cpu; |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 338 | int ret; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 339 | |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 340 | ret = fio_cpuset_init(&td->o.cpumask); |
| 341 | if (ret < 0) { |
| 342 | log_err("fio: cpuset_init failed\n"); |
| 343 | td_verror(td, ret, "fio_cpuset_init"); |
| 344 | return 1; |
| 345 | } |
| 346 | |
Jens Axboe | c00a228 | 2011-07-08 20:56:06 +0200 | [diff] [blame] | 347 | max_cpu = cpus_online(); |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 348 | |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 349 | for (i = 0; i < sizeof(int) * 8; i++) { |
| 350 | if ((1 << i) & *val) { |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 351 | if (i > max_cpu) { |
| 352 | log_err("fio: CPU %d too large (max=%ld)\n", i, |
| 353 | max_cpu); |
| 354 | return 1; |
| 355 | } |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 356 | dprint(FD_PARSE, "set cpu allowed %d\n", i); |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 357 | fio_cpu_set(&td->o.cpumask, i); |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 358 | } |
| 359 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 360 | |
Jens Axboe | 375b269 | 2007-05-22 09:13:02 +0200 | [diff] [blame] | 361 | td->o.cpumask_set = 1; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 362 | return 0; |
| 363 | } |
| 364 | |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 365 | static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask, |
| 366 | const char *input) |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 367 | { |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 368 | char *cpu, *str, *p; |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 369 | long max_cpu; |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 370 | int ret = 0; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 371 | |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 372 | ret = fio_cpuset_init(mask); |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 373 | if (ret < 0) { |
| 374 | log_err("fio: cpuset_init failed\n"); |
| 375 | td_verror(td, ret, "fio_cpuset_init"); |
| 376 | return 1; |
| 377 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 378 | |
| 379 | p = str = strdup(input); |
| 380 | |
| 381 | strip_blank_front(&str); |
| 382 | strip_blank_end(str); |
| 383 | |
Jens Axboe | c00a228 | 2011-07-08 20:56:06 +0200 | [diff] [blame] | 384 | max_cpu = cpus_online(); |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 385 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 386 | while ((cpu = strsep(&str, ",")) != NULL) { |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 387 | char *str2, *cpu2; |
| 388 | int icpu, icpu2; |
| 389 | |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 390 | if (!strlen(cpu)) |
| 391 | break; |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 392 | |
| 393 | str2 = cpu; |
| 394 | icpu2 = -1; |
| 395 | while ((cpu2 = strsep(&str2, "-")) != NULL) { |
| 396 | if (!strlen(cpu2)) |
| 397 | break; |
| 398 | |
| 399 | icpu2 = atoi(cpu2); |
| 400 | } |
| 401 | |
| 402 | icpu = atoi(cpu); |
| 403 | if (icpu2 == -1) |
| 404 | icpu2 = icpu; |
| 405 | while (icpu <= icpu2) { |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 406 | if (icpu >= FIO_MAX_CPUS) { |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 407 | log_err("fio: your OS only supports up to" |
Jens Axboe | 6d459ee | 2008-12-12 20:02:58 +0100 | [diff] [blame] | 408 | " %d CPUs\n", (int) FIO_MAX_CPUS); |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 409 | ret = 1; |
| 410 | break; |
| 411 | } |
Jens Axboe | b03daaf | 2008-12-08 20:31:43 +0100 | [diff] [blame] | 412 | if (icpu > max_cpu) { |
| 413 | log_err("fio: CPU %d too large (max=%ld)\n", |
| 414 | icpu, max_cpu); |
| 415 | ret = 1; |
| 416 | break; |
| 417 | } |
Jens Axboe | 0b9d69e | 2009-09-11 22:29:54 +0200 | [diff] [blame] | 418 | |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 419 | dprint(FD_PARSE, "set cpu allowed %d\n", icpu); |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 420 | fio_cpu_set(mask, icpu); |
Jens Axboe | 62a7273 | 2008-12-08 11:37:01 +0100 | [diff] [blame] | 421 | icpu++; |
| 422 | } |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 423 | if (ret) |
| 424 | break; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | free(p); |
Jens Axboe | 19608d6 | 2008-12-08 15:03:12 +0100 | [diff] [blame] | 428 | if (!ret) |
| 429 | td->o.cpumask_set = 1; |
| 430 | return ret; |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 431 | } |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 432 | |
| 433 | static int str_cpus_allowed_cb(void *data, const char *input) |
| 434 | { |
| 435 | struct thread_data *td = data; |
| 436 | int ret; |
| 437 | |
| 438 | ret = set_cpus_allowed(td, &td->o.cpumask, input); |
| 439 | if (!ret) |
| 440 | td->o.cpumask_set = 1; |
| 441 | |
| 442 | return ret; |
| 443 | } |
| 444 | |
| 445 | static int str_verify_cpus_allowed_cb(void *data, const char *input) |
| 446 | { |
| 447 | struct thread_data *td = data; |
| 448 | int ret; |
| 449 | |
| 450 | ret = set_cpus_allowed(td, &td->o.verify_cpumask, input); |
| 451 | if (!ret) |
| 452 | td->o.verify_cpumask_set = 1; |
| 453 | |
| 454 | return ret; |
| 455 | } |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 456 | #endif |
| 457 | |
Jens Axboe | 0d29de8 | 2010-09-01 13:54:15 +0200 | [diff] [blame] | 458 | #ifdef FIO_HAVE_TRIM |
| 459 | static int str_verify_trim_cb(void *data, unsigned long long *val) |
| 460 | { |
| 461 | struct thread_data *td = data; |
| 462 | |
| 463 | td->o.trim_percentage = *val; |
| 464 | return 0; |
| 465 | } |
| 466 | #endif |
| 467 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 468 | static int str_fst_cb(void *data, const char *str) |
| 469 | { |
| 470 | struct thread_data *td = data; |
| 471 | char *nr = get_opt_postfix(str); |
| 472 | |
| 473 | td->file_service_nr = 1; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 474 | if (nr) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 475 | td->file_service_nr = atoi(nr); |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 476 | free(nr); |
| 477 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
Jens Axboe | 3ae0637 | 2010-03-19 19:17:15 +0100 | [diff] [blame] | 482 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 483 | static int str_sfr_cb(void *data, const char *str) |
| 484 | { |
| 485 | struct thread_data *td = data; |
| 486 | char *nr = get_opt_postfix(str); |
| 487 | |
| 488 | td->sync_file_range_nr = 1; |
| 489 | if (nr) { |
| 490 | td->sync_file_range_nr = atoi(nr); |
| 491 | free(nr); |
| 492 | } |
| 493 | |
| 494 | return 0; |
| 495 | } |
Jens Axboe | 3ae0637 | 2010-03-19 19:17:15 +0100 | [diff] [blame] | 496 | #endif |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 497 | |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 498 | static int check_dir(struct thread_data *td, char *fname) |
| 499 | { |
Jens Axboe | 3f0ca9b | 2011-05-24 21:36:24 +0200 | [diff] [blame] | 500 | #if 0 |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 501 | char file[PATH_MAX], *dir; |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 502 | int elen = 0; |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 503 | |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 504 | if (td->o.directory) { |
| 505 | strcpy(file, td->o.directory); |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 506 | strcat(file, "/"); |
Jens Axboe | bc83891 | 2008-04-07 09:00:54 +0200 | [diff] [blame] | 507 | elen = strlen(file); |
| 508 | } |
| 509 | |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 510 | sprintf(file + elen, "%s", fname); |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 511 | dir = dirname(file); |
| 512 | |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 513 | { |
| 514 | struct stat sb; |
| 515 | /* |
| 516 | * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded |
| 517 | * yet, so we can't do this check right here... |
| 518 | */ |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 519 | if (lstat(dir, &sb) < 0) { |
| 520 | int ret = errno; |
| 521 | |
| 522 | log_err("fio: %s is not a directory\n", dir); |
| 523 | td_verror(td, ret, "lstat"); |
| 524 | return 1; |
| 525 | } |
| 526 | |
| 527 | if (!S_ISDIR(sb.st_mode)) { |
| 528 | log_err("fio: %s is not a directory\n", dir); |
| 529 | return 1; |
| 530 | } |
Jens Axboe | fcef0b3 | 2008-05-26 14:53:24 +0200 | [diff] [blame] | 531 | } |
| 532 | #endif |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 533 | |
| 534 | return 0; |
| 535 | } |
| 536 | |
Jens Axboe | 8e827d3 | 2009-08-04 09:51:48 +0200 | [diff] [blame] | 537 | /* |
| 538 | * Return next file in the string. Files are separated with ':'. If the ':' |
| 539 | * is escaped with a '\', then that ':' is part of the filename and does not |
| 540 | * indicate a new file. |
| 541 | */ |
| 542 | static char *get_next_file_name(char **ptr) |
| 543 | { |
| 544 | char *str = *ptr; |
| 545 | char *p, *start; |
| 546 | |
| 547 | if (!str || !strlen(str)) |
| 548 | return NULL; |
| 549 | |
| 550 | start = str; |
| 551 | do { |
| 552 | /* |
| 553 | * No colon, we are done |
| 554 | */ |
| 555 | p = strchr(str, ':'); |
| 556 | if (!p) { |
| 557 | *ptr = NULL; |
| 558 | break; |
| 559 | } |
| 560 | |
| 561 | /* |
| 562 | * We got a colon, but it's the first character. Skip and |
| 563 | * continue |
| 564 | */ |
| 565 | if (p == start) { |
| 566 | str = ++start; |
| 567 | continue; |
| 568 | } |
| 569 | |
| 570 | if (*(p - 1) != '\\') { |
| 571 | *p = '\0'; |
| 572 | *ptr = p + 1; |
| 573 | break; |
| 574 | } |
| 575 | |
| 576 | memmove(p - 1, p, strlen(p) + 1); |
| 577 | str = p; |
| 578 | } while (1); |
| 579 | |
| 580 | return start; |
| 581 | } |
| 582 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 583 | static int str_filename_cb(void *data, const char *input) |
| 584 | { |
| 585 | struct thread_data *td = data; |
| 586 | char *fname, *str, *p; |
| 587 | |
| 588 | p = str = strdup(input); |
| 589 | |
| 590 | strip_blank_front(&str); |
| 591 | strip_blank_end(str); |
| 592 | |
| 593 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 594 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 595 | |
Jens Axboe | 8e827d3 | 2009-08-04 09:51:48 +0200 | [diff] [blame] | 596 | while ((fname = get_next_file_name(&str)) != NULL) { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 597 | if (!strlen(fname)) |
| 598 | break; |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 599 | if (check_dir(td, fname)) { |
| 600 | free(p); |
| 601 | return 1; |
| 602 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 603 | add_file(td, fname); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 604 | td->o.nr_files++; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | free(p); |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | static int str_directory_cb(void *data, const char fio_unused *str) |
| 612 | { |
| 613 | struct thread_data *td = data; |
| 614 | struct stat sb; |
| 615 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 616 | if (lstat(td->o.directory, &sb) < 0) { |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 617 | int ret = errno; |
| 618 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 619 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 921c766 | 2008-03-26 09:17:55 +0100 | [diff] [blame] | 620 | td_verror(td, ret, "lstat"); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 621 | return 1; |
| 622 | } |
| 623 | if (!S_ISDIR(sb.st_mode)) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 624 | log_err("fio: %s is not a directory\n", td->o.directory); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 625 | return 1; |
| 626 | } |
| 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | static int str_opendir_cb(void *data, const char fio_unused *str) |
| 632 | { |
| 633 | struct thread_data *td = data; |
| 634 | |
| 635 | if (!td->files_index) |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 636 | td->o.nr_files = 0; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 637 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 638 | return add_dir_files(td, td->o.opendir); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 639 | } |
| 640 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 641 | static int str_verify_offset_cb(void *data, unsigned long long *off) |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 642 | { |
| 643 | struct thread_data *td = data; |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 644 | |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 645 | if (*off && *off < sizeof(struct verify_header)) { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 646 | log_err("fio: verify_offset too small\n"); |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 647 | return 1; |
| 648 | } |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 649 | |
| 650 | td->o.verify_offset = *off; |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 651 | return 0; |
| 652 | } |
| 653 | |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 654 | static int str_verify_pattern_cb(void *data, const char *input) |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 655 | { |
| 656 | struct thread_data *td = data; |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 657 | long off; |
| 658 | int i = 0, j = 0, len, k, base = 10; |
| 659 | char* loc1, * loc2; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 660 | |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 661 | loc1 = strstr(input, "0x"); |
| 662 | loc2 = strstr(input, "0X"); |
| 663 | if (loc1 || loc2) |
| 664 | base = 16; |
| 665 | off = strtol(input, NULL, base); |
| 666 | if (off != LONG_MAX || errno != ERANGE) { |
| 667 | while (off) { |
| 668 | td->o.verify_pattern[i] = off & 0xff; |
| 669 | off >>= 8; |
| 670 | i++; |
| 671 | } |
| 672 | } else { |
| 673 | len = strlen(input); |
| 674 | k = len - 1; |
| 675 | if (base == 16) { |
| 676 | if (loc1) |
| 677 | j = loc1 - input + 2; |
| 678 | else |
| 679 | j = loc2 - input + 2; |
| 680 | } else |
| 681 | return 1; |
| 682 | if (len - j < MAX_PATTERN_SIZE * 2) { |
| 683 | while (k >= j) { |
| 684 | off = converthexchartoint(input[k--]); |
| 685 | if (k >= j) |
| 686 | off += (converthexchartoint(input[k--]) |
| 687 | * 16); |
| 688 | td->o.verify_pattern[i++] = (char) off; |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | td->o.verify_pattern_bytes = i; |
Jens Axboe | 92bf48d | 2011-01-14 21:20:42 +0100 | [diff] [blame] | 693 | /* |
| 694 | * VERIFY_META could already be set |
| 695 | */ |
| 696 | if (td->o.verify == VERIFY_NONE) |
| 697 | td->o.verify = VERIFY_PATTERN; |
Jens Axboe | 90059d6 | 2007-07-30 09:33:12 +0200 | [diff] [blame] | 698 | return 0; |
| 699 | } |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 700 | |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 701 | static int str_lockfile_cb(void *data, const char *str) |
| 702 | { |
| 703 | struct thread_data *td = data; |
| 704 | char *nr = get_opt_postfix(str); |
| 705 | |
| 706 | td->o.lockfile_batch = 1; |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 707 | if (nr) { |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 708 | td->o.lockfile_batch = atoi(nr); |
Jens Axboe | 182ec6e | 2008-11-14 13:06:06 +0100 | [diff] [blame] | 709 | free(nr); |
| 710 | } |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 711 | |
| 712 | return 0; |
| 713 | } |
| 714 | |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 715 | static int str_write_bw_log_cb(void *data, const char *str) |
| 716 | { |
| 717 | struct thread_data *td = data; |
| 718 | |
| 719 | if (str) |
| 720 | td->o.bw_log_file = strdup(str); |
| 721 | |
| 722 | td->o.write_bw_log = 1; |
| 723 | return 0; |
| 724 | } |
| 725 | |
| 726 | static int str_write_lat_log_cb(void *data, const char *str) |
| 727 | { |
| 728 | struct thread_data *td = data; |
| 729 | |
| 730 | if (str) |
| 731 | td->o.lat_log_file = strdup(str); |
| 732 | |
| 733 | td->o.write_lat_log = 1; |
| 734 | return 0; |
| 735 | } |
| 736 | |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 737 | static int str_write_iops_log_cb(void *data, const char *str) |
| 738 | { |
| 739 | struct thread_data *td = data; |
| 740 | |
| 741 | if (str) |
| 742 | td->o.iops_log_file = strdup(str); |
| 743 | |
| 744 | td->o.write_iops_log = 1; |
| 745 | return 0; |
| 746 | } |
| 747 | |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 748 | static int str_gtod_reduce_cb(void *data, int *il) |
| 749 | { |
| 750 | struct thread_data *td = data; |
| 751 | int val = *il; |
| 752 | |
Jens Axboe | 02af098 | 2010-06-24 09:59:34 +0200 | [diff] [blame] | 753 | td->o.disable_lat = !!val; |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 754 | td->o.disable_clat = !!val; |
| 755 | td->o.disable_slat = !!val; |
| 756 | td->o.disable_bw = !!val; |
Jens Axboe | 0dc1bc0 | 2011-10-13 08:55:29 +0200 | [diff] [blame] | 757 | td->o.clat_percentiles = !val; |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 758 | if (val) |
| 759 | td->tv_cache_mask = 63; |
| 760 | |
| 761 | return 0; |
| 762 | } |
| 763 | |
Cigy Cyriac | 85bc833 | 2010-08-10 19:21:09 -0400 | [diff] [blame] | 764 | static int str_gtod_cpu_cb(void *data, long long *il) |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 765 | { |
| 766 | struct thread_data *td = data; |
| 767 | int val = *il; |
| 768 | |
| 769 | td->o.gtod_cpu = val; |
| 770 | td->o.gtod_offload = 1; |
| 771 | return 0; |
| 772 | } |
| 773 | |
Jens Axboe | 7bb5910 | 2011-07-12 19:47:03 +0200 | [diff] [blame] | 774 | static int str_size_cb(void *data, unsigned long long *__val) |
| 775 | { |
| 776 | struct thread_data *td = data; |
| 777 | unsigned long long v = *__val; |
| 778 | |
| 779 | if (parse_is_percent(v)) { |
| 780 | td->o.size = 0; |
| 781 | td->o.size_percent = -1ULL - v; |
| 782 | } else |
| 783 | td->o.size = v; |
| 784 | |
| 785 | return 0; |
| 786 | } |
| 787 | |
Jens Axboe | 896cac2 | 2009-07-01 10:38:35 +0200 | [diff] [blame] | 788 | static int rw_verify(struct fio_option *o, void *data) |
| 789 | { |
| 790 | struct thread_data *td = data; |
| 791 | |
| 792 | if (read_only && td_write(td)) { |
| 793 | log_err("fio: job <%s> has write bit set, but fio is in" |
| 794 | " read-only mode\n", td->o.name); |
| 795 | return 1; |
| 796 | } |
| 797 | |
| 798 | return 0; |
| 799 | } |
| 800 | |
Jens Axboe | 276ca4f | 2009-07-01 10:43:05 +0200 | [diff] [blame] | 801 | static int gtod_cpu_verify(struct fio_option *o, void *data) |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 802 | { |
Jens Axboe | 276ca4f | 2009-07-01 10:43:05 +0200 | [diff] [blame] | 803 | #ifndef FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 804 | struct thread_data *td = data; |
| 805 | |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 806 | if (td->o.gtod_cpu) { |
| 807 | log_err("fio: platform must support CPU affinity for" |
| 808 | "gettimeofday() offloading\n"); |
| 809 | return 1; |
| 810 | } |
| 811 | #endif |
| 812 | |
| 813 | return 0; |
| 814 | } |
| 815 | |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 816 | static int kb_base_verify(struct fio_option *o, void *data) |
| 817 | { |
| 818 | struct thread_data *td = data; |
| 819 | |
| 820 | if (td->o.kb_base != 1024 && td->o.kb_base != 1000) { |
| 821 | log_err("fio: kb_base set to nonsensical value: %u\n", |
| 822 | td->o.kb_base); |
| 823 | return 1; |
| 824 | } |
| 825 | |
| 826 | return 0; |
| 827 | } |
| 828 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 829 | /* |
| 830 | * Map of job/command line options |
| 831 | */ |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 832 | static struct fio_option options[FIO_MAX_OPTS] = { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 833 | { |
| 834 | .name = "description", |
| 835 | .type = FIO_OPT_STR_STORE, |
| 836 | .off1 = td_var_offset(description), |
| 837 | .help = "Text job description", |
| 838 | }, |
| 839 | { |
| 840 | .name = "name", |
| 841 | .type = FIO_OPT_STR_STORE, |
| 842 | .off1 = td_var_offset(name), |
| 843 | .help = "Name of this job", |
| 844 | }, |
| 845 | { |
| 846 | .name = "directory", |
| 847 | .type = FIO_OPT_STR_STORE, |
| 848 | .off1 = td_var_offset(directory), |
| 849 | .cb = str_directory_cb, |
| 850 | .help = "Directory to store files in", |
| 851 | }, |
| 852 | { |
| 853 | .name = "filename", |
| 854 | .type = FIO_OPT_STR_STORE, |
| 855 | .off1 = td_var_offset(filename), |
| 856 | .cb = str_filename_cb, |
Jens Axboe | f0d524b | 2009-04-27 08:00:48 +0200 | [diff] [blame] | 857 | .prio = -1, /* must come after "directory" */ |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 858 | .help = "File(s) to use for the workload", |
| 859 | }, |
| 860 | { |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 861 | .name = "kb_base", |
| 862 | .type = FIO_OPT_INT, |
| 863 | .off1 = td_var_offset(kb_base), |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 864 | .verify = kb_base_verify, |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 865 | .prio = 1, |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 866 | .def = "1024", |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 867 | .help = "How many bytes per KB for reporting (1000 or 1024)", |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 868 | }, |
| 869 | { |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 870 | .name = "lockfile", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 871 | .type = FIO_OPT_STR, |
| 872 | .cb = str_lockfile_cb, |
| 873 | .off1 = td_var_offset(file_lock_mode), |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 874 | .help = "Lock file when doing IO to it", |
| 875 | .parent = "filename", |
Jens Axboe | 4d4e80f | 2008-03-04 10:18:56 +0100 | [diff] [blame] | 876 | .def = "none", |
| 877 | .posval = { |
| 878 | { .ival = "none", |
| 879 | .oval = FILE_LOCK_NONE, |
| 880 | .help = "No file locking", |
| 881 | }, |
| 882 | { .ival = "exclusive", |
| 883 | .oval = FILE_LOCK_EXCLUSIVE, |
| 884 | .help = "Exclusive file lock", |
| 885 | }, |
| 886 | { |
| 887 | .ival = "readwrite", |
| 888 | .oval = FILE_LOCK_READWRITE, |
| 889 | .help = "Read vs write lock", |
| 890 | }, |
| 891 | }, |
Jens Axboe | 29c1349 | 2008-03-01 19:25:20 +0100 | [diff] [blame] | 892 | }, |
| 893 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 894 | .name = "opendir", |
| 895 | .type = FIO_OPT_STR_STORE, |
| 896 | .off1 = td_var_offset(opendir), |
| 897 | .cb = str_opendir_cb, |
| 898 | .help = "Recursively add files from this directory and down", |
| 899 | }, |
| 900 | { |
| 901 | .name = "rw", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 902 | .alias = "readwrite", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 903 | .type = FIO_OPT_STR, |
Jens Axboe | 211097b | 2007-03-22 18:56:45 +0100 | [diff] [blame] | 904 | .cb = str_rw_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 905 | .off1 = td_var_offset(td_ddir), |
| 906 | .help = "IO direction", |
| 907 | .def = "read", |
Jens Axboe | 896cac2 | 2009-07-01 10:38:35 +0200 | [diff] [blame] | 908 | .verify = rw_verify, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 909 | .posval = { |
| 910 | { .ival = "read", |
| 911 | .oval = TD_DDIR_READ, |
| 912 | .help = "Sequential read", |
| 913 | }, |
| 914 | { .ival = "write", |
| 915 | .oval = TD_DDIR_WRITE, |
| 916 | .help = "Sequential write", |
| 917 | }, |
| 918 | { .ival = "randread", |
| 919 | .oval = TD_DDIR_RANDREAD, |
| 920 | .help = "Random read", |
| 921 | }, |
| 922 | { .ival = "randwrite", |
| 923 | .oval = TD_DDIR_RANDWRITE, |
| 924 | .help = "Random write", |
| 925 | }, |
| 926 | { .ival = "rw", |
| 927 | .oval = TD_DDIR_RW, |
| 928 | .help = "Sequential read and write mix", |
| 929 | }, |
| 930 | { .ival = "randrw", |
| 931 | .oval = TD_DDIR_RANDRW, |
| 932 | .help = "Random read and write mix" |
| 933 | }, |
| 934 | }, |
| 935 | }, |
| 936 | { |
Jens Axboe | 38dad62 | 2010-07-20 14:46:00 -0600 | [diff] [blame] | 937 | .name = "rw_sequencer", |
| 938 | .type = FIO_OPT_STR, |
| 939 | .off1 = td_var_offset(rw_seq), |
| 940 | .help = "IO offset generator modifier", |
| 941 | .def = "sequential", |
| 942 | .posval = { |
| 943 | { .ival = "sequential", |
| 944 | .oval = RW_SEQ_SEQ, |
| 945 | .help = "Generate sequential offsets", |
| 946 | }, |
| 947 | { .ival = "identical", |
| 948 | .oval = RW_SEQ_IDENT, |
| 949 | .help = "Generate identical offsets", |
| 950 | }, |
| 951 | }, |
| 952 | }, |
| 953 | |
| 954 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 955 | .name = "ioengine", |
| 956 | .type = FIO_OPT_STR_STORE, |
| 957 | .off1 = td_var_offset(ioengine), |
| 958 | .help = "IO engine to use", |
Jens Axboe | 58483fa | 2011-01-19 11:09:58 -0700 | [diff] [blame] | 959 | .def = FIO_PREFERRED_ENGINE, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 960 | .posval = { |
| 961 | { .ival = "sync", |
| 962 | .help = "Use read/write", |
| 963 | }, |
gurudas pai | a31041e | 2007-10-23 15:12:30 +0200 | [diff] [blame] | 964 | { .ival = "psync", |
| 965 | .help = "Use pread/pwrite", |
| 966 | }, |
Jens Axboe | 1d2af02 | 2008-02-04 10:59:07 +0100 | [diff] [blame] | 967 | { .ival = "vsync", |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 968 | .help = "Use readv/writev", |
Jens Axboe | 1d2af02 | 2008-02-04 10:59:07 +0100 | [diff] [blame] | 969 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 970 | #ifdef FIO_HAVE_LIBAIO |
| 971 | { .ival = "libaio", |
| 972 | .help = "Linux native asynchronous IO", |
| 973 | }, |
| 974 | #endif |
| 975 | #ifdef FIO_HAVE_POSIXAIO |
| 976 | { .ival = "posixaio", |
| 977 | .help = "POSIX asynchronous IO", |
| 978 | }, |
| 979 | #endif |
Jens Axboe | 417f006 | 2008-06-02 11:59:30 +0200 | [diff] [blame] | 980 | #ifdef FIO_HAVE_SOLARISAIO |
| 981 | { .ival = "solarisaio", |
| 982 | .help = "Solaris native asynchronous IO", |
| 983 | }, |
| 984 | #endif |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 985 | #ifdef FIO_HAVE_WINDOWSAIO |
| 986 | { .ival = "windowsaio", |
Jens Axboe | 3be8007 | 2011-01-19 11:07:28 -0700 | [diff] [blame] | 987 | .help = "Windows native asynchronous IO" |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 988 | }, |
Jens Axboe | 3be8007 | 2011-01-19 11:07:28 -0700 | [diff] [blame] | 989 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 990 | { .ival = "mmap", |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 991 | .help = "Memory mapped IO" |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 992 | }, |
| 993 | #ifdef FIO_HAVE_SPLICE |
| 994 | { .ival = "splice", |
| 995 | .help = "splice/vmsplice based IO", |
| 996 | }, |
Jens Axboe | 9cce02e | 2007-06-22 15:42:21 +0200 | [diff] [blame] | 997 | { .ival = "netsplice", |
| 998 | .help = "splice/vmsplice to/from the network", |
| 999 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1000 | #endif |
| 1001 | #ifdef FIO_HAVE_SGIO |
| 1002 | { .ival = "sg", |
| 1003 | .help = "SCSI generic v3 IO", |
| 1004 | }, |
| 1005 | #endif |
| 1006 | { .ival = "null", |
| 1007 | .help = "Testing engine (no data transfer)", |
| 1008 | }, |
| 1009 | { .ival = "net", |
| 1010 | .help = "Network IO", |
| 1011 | }, |
| 1012 | #ifdef FIO_HAVE_SYSLET |
| 1013 | { .ival = "syslet-rw", |
| 1014 | .help = "syslet enabled async pread/pwrite IO", |
| 1015 | }, |
| 1016 | #endif |
| 1017 | { .ival = "cpuio", |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 1018 | .help = "CPU cycle burner engine", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1019 | }, |
Jens Axboe | b8c82a4 | 2007-03-21 08:48:26 +0100 | [diff] [blame] | 1020 | #ifdef FIO_HAVE_GUASI |
| 1021 | { .ival = "guasi", |
| 1022 | .help = "GUASI IO engine", |
| 1023 | }, |
| 1024 | #endif |
Jens Axboe | 79a4318 | 2010-09-07 13:28:58 +0200 | [diff] [blame] | 1025 | #ifdef FIO_HAVE_BINJECT |
| 1026 | { .ival = "binject", |
| 1027 | .help = "binject direct inject block engine", |
| 1028 | }, |
| 1029 | #endif |
ren yufei | 21b8aee | 2011-08-01 10:01:57 +0200 | [diff] [blame] | 1030 | #ifdef FIO_HAVE_RDMA |
| 1031 | { .ival = "rdma", |
| 1032 | .help = "RDMA IO engine", |
| 1033 | }, |
| 1034 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1035 | { .ival = "external", |
| 1036 | .help = "Load external engine (append name)", |
| 1037 | }, |
| 1038 | }, |
| 1039 | }, |
| 1040 | { |
| 1041 | .name = "iodepth", |
| 1042 | .type = FIO_OPT_INT, |
| 1043 | .off1 = td_var_offset(iodepth), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 1044 | .help = "Number of IO buffers to keep in flight", |
Jens Axboe | 757aff4 | 2007-12-12 19:42:13 +0100 | [diff] [blame] | 1045 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1046 | .def = "1", |
| 1047 | }, |
| 1048 | { |
| 1049 | .name = "iodepth_batch", |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 1050 | .alias = "iodepth_batch_submit", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1051 | .type = FIO_OPT_INT, |
| 1052 | .off1 = td_var_offset(iodepth_batch), |
Jens Axboe | d65db44 | 2009-01-16 19:15:33 +0100 | [diff] [blame] | 1053 | .help = "Number of IO buffers to submit in one go", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1054 | .parent = "iodepth", |
Jens Axboe | a2e6f8a | 2008-01-18 10:28:11 +0100 | [diff] [blame] | 1055 | .minval = 1, |
| 1056 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1057 | }, |
| 1058 | { |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 1059 | .name = "iodepth_batch_complete", |
| 1060 | .type = FIO_OPT_INT, |
| 1061 | .off1 = td_var_offset(iodepth_batch_complete), |
Jens Axboe | d65db44 | 2009-01-16 19:15:33 +0100 | [diff] [blame] | 1062 | .help = "Number of IO buffers to retrieve in one go", |
Jens Axboe | 4950421 | 2008-06-05 09:03:30 +0200 | [diff] [blame] | 1063 | .parent = "iodepth", |
| 1064 | .minval = 0, |
| 1065 | .def = "1", |
| 1066 | }, |
| 1067 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1068 | .name = "iodepth_low", |
| 1069 | .type = FIO_OPT_INT, |
| 1070 | .off1 = td_var_offset(iodepth_low), |
| 1071 | .help = "Low water mark for queuing depth", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1072 | .parent = "iodepth", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1073 | }, |
| 1074 | { |
| 1075 | .name = "size", |
| 1076 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | 7bb5910 | 2011-07-12 19:47:03 +0200 | [diff] [blame] | 1077 | .cb = str_size_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1078 | .help = "Total size of device or files", |
| 1079 | }, |
| 1080 | { |
Shawn Lewis | aa31f1f | 2008-01-11 09:45:11 +0100 | [diff] [blame] | 1081 | .name = "fill_device", |
Jens Axboe | 74586c1 | 2011-01-20 10:16:03 -0700 | [diff] [blame] | 1082 | .alias = "fill_fs", |
Shawn Lewis | aa31f1f | 2008-01-11 09:45:11 +0100 | [diff] [blame] | 1083 | .type = FIO_OPT_BOOL, |
| 1084 | .off1 = td_var_offset(fill_device), |
| 1085 | .help = "Write until an ENOSPC error occurs", |
| 1086 | .def = "0", |
| 1087 | }, |
| 1088 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1089 | .name = "filesize", |
| 1090 | .type = FIO_OPT_STR_VAL, |
| 1091 | .off1 = td_var_offset(file_size_low), |
| 1092 | .off2 = td_var_offset(file_size_high), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 1093 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1094 | .help = "Size of individual files", |
| 1095 | }, |
| 1096 | { |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1097 | .name = "offset", |
| 1098 | .alias = "fileoffset", |
| 1099 | .type = FIO_OPT_STR_VAL, |
| 1100 | .off1 = td_var_offset(start_offset), |
| 1101 | .help = "Start IO from this offset", |
| 1102 | .def = "0", |
| 1103 | }, |
| 1104 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1105 | .name = "bs", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1106 | .alias = "blocksize", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1107 | .type = FIO_OPT_INT, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1108 | .off1 = td_var_offset(bs[DDIR_READ]), |
| 1109 | .off2 = td_var_offset(bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 1110 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1111 | .help = "Block size unit", |
| 1112 | .def = "4k", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1113 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1114 | }, |
| 1115 | { |
Jens Axboe | 2b7a01d | 2009-03-11 11:00:13 +0100 | [diff] [blame] | 1116 | .name = "ba", |
| 1117 | .alias = "blockalign", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1118 | .type = FIO_OPT_INT, |
Jens Axboe | 2b7a01d | 2009-03-11 11:00:13 +0100 | [diff] [blame] | 1119 | .off1 = td_var_offset(ba[DDIR_READ]), |
| 1120 | .off2 = td_var_offset(ba[DDIR_WRITE]), |
| 1121 | .minval = 1, |
| 1122 | .help = "IO block offset alignment", |
| 1123 | .parent = "rw", |
| 1124 | }, |
| 1125 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1126 | .name = "bsrange", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1127 | .alias = "blocksize_range", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1128 | .type = FIO_OPT_RANGE, |
| 1129 | .off1 = td_var_offset(min_bs[DDIR_READ]), |
| 1130 | .off2 = td_var_offset(max_bs[DDIR_READ]), |
| 1131 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), |
| 1132 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), |
Jens Axboe | c3edbdb | 2007-07-20 14:25:31 +0200 | [diff] [blame] | 1133 | .minval = 1, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1134 | .help = "Set block size range (in more detail than bs)", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1135 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1136 | }, |
| 1137 | { |
Jens Axboe | 564ca97 | 2007-12-14 12:21:19 +0100 | [diff] [blame] | 1138 | .name = "bssplit", |
| 1139 | .type = FIO_OPT_STR, |
| 1140 | .cb = str_bssplit_cb, |
| 1141 | .help = "Set a specific mix of block sizes", |
| 1142 | .parent = "rw", |
| 1143 | }, |
| 1144 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1145 | .name = "bs_unaligned", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1146 | .alias = "blocksize_unaligned", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1147 | .type = FIO_OPT_STR_SET, |
| 1148 | .off1 = td_var_offset(bs_unaligned), |
| 1149 | .help = "Don't sector align IO buffer sizes", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1150 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1151 | }, |
| 1152 | { |
| 1153 | .name = "randrepeat", |
| 1154 | .type = FIO_OPT_BOOL, |
| 1155 | .off1 = td_var_offset(rand_repeatable), |
| 1156 | .help = "Use repeatable random IO pattern", |
| 1157 | .def = "1", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1158 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1159 | }, |
| 1160 | { |
Jens Axboe | 2615cc4 | 2011-03-28 09:35:09 +0200 | [diff] [blame] | 1161 | .name = "use_os_rand", |
| 1162 | .type = FIO_OPT_BOOL, |
| 1163 | .off1 = td_var_offset(use_os_rand), |
| 1164 | .help = "Set to use OS random generator", |
| 1165 | .def = "0", |
| 1166 | .parent = "rw", |
| 1167 | }, |
| 1168 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1169 | .name = "norandommap", |
| 1170 | .type = FIO_OPT_STR_SET, |
| 1171 | .off1 = td_var_offset(norandommap), |
| 1172 | .help = "Accept potential duplicate random blocks", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1173 | .parent = "rw", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1174 | }, |
| 1175 | { |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 1176 | .name = "softrandommap", |
| 1177 | .type = FIO_OPT_BOOL, |
| 1178 | .off1 = td_var_offset(softrandommap), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 1179 | .help = "Set norandommap if randommap allocation fails", |
Jens Axboe | 2b386d2 | 2008-03-26 10:32:57 +0100 | [diff] [blame] | 1180 | .parent = "norandommap", |
| 1181 | .def = "0", |
| 1182 | }, |
| 1183 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1184 | .name = "nrfiles", |
Jens Axboe | d7c8be0 | 2010-11-25 08:21:39 +0100 | [diff] [blame] | 1185 | .alias = "nr_files", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1186 | .type = FIO_OPT_INT, |
| 1187 | .off1 = td_var_offset(nr_files), |
| 1188 | .help = "Split job workload between this number of files", |
| 1189 | .def = "1", |
| 1190 | }, |
| 1191 | { |
| 1192 | .name = "openfiles", |
| 1193 | .type = FIO_OPT_INT, |
| 1194 | .off1 = td_var_offset(open_files), |
| 1195 | .help = "Number of files to keep open at the same time", |
| 1196 | }, |
| 1197 | { |
| 1198 | .name = "file_service_type", |
| 1199 | .type = FIO_OPT_STR, |
| 1200 | .cb = str_fst_cb, |
| 1201 | .off1 = td_var_offset(file_service_type), |
| 1202 | .help = "How to select which file to service next", |
| 1203 | .def = "roundrobin", |
| 1204 | .posval = { |
| 1205 | { .ival = "random", |
| 1206 | .oval = FIO_FSERVICE_RANDOM, |
| 1207 | .help = "Choose a file at random", |
| 1208 | }, |
| 1209 | { .ival = "roundrobin", |
| 1210 | .oval = FIO_FSERVICE_RR, |
| 1211 | .help = "Round robin select files", |
| 1212 | }, |
Jens Axboe | a086c25 | 2009-03-04 08:27:37 +0100 | [diff] [blame] | 1213 | { .ival = "sequential", |
| 1214 | .oval = FIO_FSERVICE_SEQ, |
| 1215 | .help = "Finish one file before moving to the next", |
| 1216 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1217 | }, |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1218 | .parent = "nrfiles", |
| 1219 | }, |
Jens Axboe | 7bc8c2c | 2010-01-28 11:31:31 +0100 | [diff] [blame] | 1220 | #ifdef FIO_HAVE_FALLOCATE |
| 1221 | { |
| 1222 | .name = "fallocate", |
Eric Gouriou | a596f04 | 2011-06-17 09:11:45 +0200 | [diff] [blame] | 1223 | .type = FIO_OPT_STR, |
| 1224 | .off1 = td_var_offset(fallocate_mode), |
| 1225 | .help = "Whether pre-allocation is performed when laying out files", |
| 1226 | .def = "posix", |
| 1227 | .posval = { |
| 1228 | { .ival = "none", |
| 1229 | .oval = FIO_FALLOCATE_NONE, |
| 1230 | .help = "Do not pre-allocate space", |
| 1231 | }, |
| 1232 | { .ival = "posix", |
| 1233 | .oval = FIO_FALLOCATE_POSIX, |
| 1234 | .help = "Use posix_fallocate()", |
| 1235 | }, |
| 1236 | #ifdef FIO_HAVE_LINUX_FALLOCATE |
| 1237 | { .ival = "keep", |
| 1238 | .oval = FIO_FALLOCATE_KEEP_SIZE, |
| 1239 | .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", |
| 1240 | }, |
Jens Axboe | 7bc8c2c | 2010-01-28 11:31:31 +0100 | [diff] [blame] | 1241 | #endif |
Eric Gouriou | a596f04 | 2011-06-17 09:11:45 +0200 | [diff] [blame] | 1242 | /* Compatibility with former boolean values */ |
| 1243 | { .ival = "0", |
| 1244 | .oval = FIO_FALLOCATE_NONE, |
| 1245 | .help = "Alias for 'none'", |
| 1246 | }, |
| 1247 | { .ival = "1", |
| 1248 | .oval = FIO_FALLOCATE_POSIX, |
| 1249 | .help = "Alias for 'posix'", |
| 1250 | }, |
| 1251 | }, |
| 1252 | }, |
| 1253 | #endif /* FIO_HAVE_FALLOCATE */ |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1254 | { |
| 1255 | .name = "fadvise_hint", |
| 1256 | .type = FIO_OPT_BOOL, |
| 1257 | .off1 = td_var_offset(fadvise_hint), |
| 1258 | .help = "Use fadvise() to advise the kernel on IO pattern", |
| 1259 | .def = "1", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1260 | }, |
| 1261 | { |
| 1262 | .name = "fsync", |
| 1263 | .type = FIO_OPT_INT, |
| 1264 | .off1 = td_var_offset(fsync_blocks), |
| 1265 | .help = "Issue fsync for writes every given number of blocks", |
| 1266 | .def = "0", |
| 1267 | }, |
| 1268 | { |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 1269 | .name = "fdatasync", |
| 1270 | .type = FIO_OPT_INT, |
| 1271 | .off1 = td_var_offset(fdatasync_blocks), |
| 1272 | .help = "Issue fdatasync for writes every given number of blocks", |
| 1273 | .def = "0", |
| 1274 | }, |
Jens Axboe | 1ef2b6b | 2010-10-08 15:07:01 +0200 | [diff] [blame] | 1275 | { |
| 1276 | .name = "write_barrier", |
| 1277 | .type = FIO_OPT_INT, |
| 1278 | .off1 = td_var_offset(barrier_blocks), |
| 1279 | .help = "Make every Nth write a barrier write", |
| 1280 | .def = "0", |
| 1281 | }, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1282 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
| 1283 | { |
| 1284 | .name = "sync_file_range", |
| 1285 | .posval = { |
| 1286 | { .ival = "wait_before", |
| 1287 | .oval = SYNC_FILE_RANGE_WAIT_BEFORE, |
| 1288 | .help = "SYNC_FILE_RANGE_WAIT_BEFORE", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1289 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1290 | }, |
| 1291 | { .ival = "write", |
| 1292 | .oval = SYNC_FILE_RANGE_WRITE, |
| 1293 | .help = "SYNC_FILE_RANGE_WRITE", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1294 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1295 | }, |
| 1296 | { |
| 1297 | .ival = "wait_after", |
| 1298 | .oval = SYNC_FILE_RANGE_WAIT_AFTER, |
| 1299 | .help = "SYNC_FILE_RANGE_WAIT_AFTER", |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1300 | .or = 1, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1301 | }, |
| 1302 | }, |
Jens Axboe | 3843deb | 2010-03-09 20:41:15 +0100 | [diff] [blame] | 1303 | .type = FIO_OPT_STR_MULTI, |
Jens Axboe | 44f2969 | 2010-03-09 20:09:44 +0100 | [diff] [blame] | 1304 | .cb = str_sfr_cb, |
| 1305 | .off1 = td_var_offset(sync_file_range), |
| 1306 | .help = "Use sync_file_range()", |
| 1307 | }, |
| 1308 | #endif |
Jens Axboe | 5f9099e | 2009-06-16 22:40:26 +0200 | [diff] [blame] | 1309 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1310 | .name = "direct", |
| 1311 | .type = FIO_OPT_BOOL, |
| 1312 | .off1 = td_var_offset(odirect), |
| 1313 | .help = "Use O_DIRECT IO (negates buffered)", |
| 1314 | .def = "0", |
| 1315 | }, |
| 1316 | { |
| 1317 | .name = "buffered", |
| 1318 | .type = FIO_OPT_BOOL, |
| 1319 | .off1 = td_var_offset(odirect), |
| 1320 | .neg = 1, |
| 1321 | .help = "Use buffered IO (negates direct)", |
| 1322 | .def = "1", |
| 1323 | }, |
| 1324 | { |
| 1325 | .name = "overwrite", |
| 1326 | .type = FIO_OPT_BOOL, |
| 1327 | .off1 = td_var_offset(overwrite), |
| 1328 | .help = "When writing, set whether to overwrite current data", |
| 1329 | .def = "0", |
| 1330 | }, |
| 1331 | { |
| 1332 | .name = "loops", |
| 1333 | .type = FIO_OPT_INT, |
| 1334 | .off1 = td_var_offset(loops), |
| 1335 | .help = "Number of times to run the job", |
| 1336 | .def = "1", |
| 1337 | }, |
| 1338 | { |
| 1339 | .name = "numjobs", |
| 1340 | .type = FIO_OPT_INT, |
| 1341 | .off1 = td_var_offset(numjobs), |
| 1342 | .help = "Duplicate this job this many times", |
| 1343 | .def = "1", |
| 1344 | }, |
| 1345 | { |
| 1346 | .name = "startdelay", |
Jens Axboe | a5737c9 | 2010-06-29 10:40:30 +0200 | [diff] [blame] | 1347 | .type = FIO_OPT_STR_VAL_TIME, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1348 | .off1 = td_var_offset(start_delay), |
| 1349 | .help = "Only start job when this period has passed", |
| 1350 | .def = "0", |
| 1351 | }, |
| 1352 | { |
| 1353 | .name = "runtime", |
| 1354 | .alias = "timeout", |
| 1355 | .type = FIO_OPT_STR_VAL_TIME, |
| 1356 | .off1 = td_var_offset(timeout), |
| 1357 | .help = "Stop workload when this amount of time has passed", |
| 1358 | .def = "0", |
| 1359 | }, |
| 1360 | { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 1361 | .name = "time_based", |
| 1362 | .type = FIO_OPT_STR_SET, |
| 1363 | .off1 = td_var_offset(time_based), |
| 1364 | .help = "Keep running until runtime/timeout is met", |
| 1365 | }, |
| 1366 | { |
Jens Axboe | 721938a | 2008-09-10 09:46:16 +0200 | [diff] [blame] | 1367 | .name = "ramp_time", |
| 1368 | .type = FIO_OPT_STR_VAL_TIME, |
| 1369 | .off1 = td_var_offset(ramp_time), |
| 1370 | .help = "Ramp up time before measuring performance", |
| 1371 | }, |
| 1372 | { |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 1373 | .name = "clocksource", |
| 1374 | .type = FIO_OPT_STR, |
| 1375 | .cb = fio_clock_source_cb, |
| 1376 | .off1 = td_var_offset(clocksource), |
| 1377 | .help = "What type of timing source to use", |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 1378 | .posval = { |
| 1379 | { .ival = "gettimeofday", |
| 1380 | .oval = CS_GTOD, |
| 1381 | .help = "Use gettimeofday(2) for timing", |
| 1382 | }, |
| 1383 | { .ival = "clock_gettime", |
| 1384 | .oval = CS_CGETTIME, |
| 1385 | .help = "Use clock_gettime(2) for timing", |
| 1386 | }, |
| 1387 | #ifdef ARCH_HAVE_CPU_CLOCK |
| 1388 | { .ival = "cpu", |
| 1389 | .oval = CS_CPUCLOCK, |
| 1390 | .help = "Use CPU private clock", |
| 1391 | }, |
| 1392 | #endif |
| 1393 | }, |
| 1394 | }, |
| 1395 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1396 | .name = "mem", |
Jens Axboe | d3aad8f | 2007-03-15 14:12:05 +0100 | [diff] [blame] | 1397 | .alias = "iomem", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1398 | .type = FIO_OPT_STR, |
| 1399 | .cb = str_mem_cb, |
| 1400 | .off1 = td_var_offset(mem_type), |
| 1401 | .help = "Backing type for IO buffers", |
| 1402 | .def = "malloc", |
| 1403 | .posval = { |
| 1404 | { .ival = "malloc", |
| 1405 | .oval = MEM_MALLOC, |
| 1406 | .help = "Use malloc(3) for IO buffers", |
| 1407 | }, |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 1408 | { .ival = "shm", |
| 1409 | .oval = MEM_SHM, |
| 1410 | .help = "Use shared memory segments for IO buffers", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1411 | }, |
| 1412 | #ifdef FIO_HAVE_HUGETLB |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 1413 | { .ival = "shmhuge", |
| 1414 | .oval = MEM_SHMHUGE, |
| 1415 | .help = "Like shm, but use huge pages", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1416 | }, |
| 1417 | #endif |
Jens Axboe | b370e46 | 2007-03-19 10:51:49 +0100 | [diff] [blame] | 1418 | { .ival = "mmap", |
| 1419 | .oval = MEM_MMAP, |
| 1420 | .help = "Use mmap(2) (file or anon) for IO buffers", |
| 1421 | }, |
Jens Axboe | 37c8cdf | 2007-03-19 13:14:03 +0100 | [diff] [blame] | 1422 | #ifdef FIO_HAVE_HUGETLB |
| 1423 | { .ival = "mmaphuge", |
| 1424 | .oval = MEM_MMAPHUGE, |
| 1425 | .help = "Like mmap, but use huge pages", |
| 1426 | }, |
| 1427 | #endif |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1428 | }, |
| 1429 | }, |
| 1430 | { |
Jens Axboe | d529ee1 | 2009-07-01 10:33:03 +0200 | [diff] [blame] | 1431 | .name = "iomem_align", |
| 1432 | .alias = "mem_align", |
| 1433 | .type = FIO_OPT_INT, |
| 1434 | .off1 = td_var_offset(mem_align), |
| 1435 | .minval = 0, |
| 1436 | .help = "IO memory buffer offset alignment", |
| 1437 | .def = "0", |
| 1438 | .parent = "iomem", |
| 1439 | }, |
| 1440 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1441 | .name = "verify", |
| 1442 | .type = FIO_OPT_STR, |
| 1443 | .off1 = td_var_offset(verify), |
| 1444 | .help = "Verify data written", |
Jens Axboe | 5d7c5d3 | 2010-06-21 15:08:17 +0200 | [diff] [blame] | 1445 | .cb = str_verify_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1446 | .def = "0", |
| 1447 | .posval = { |
| 1448 | { .ival = "0", |
| 1449 | .oval = VERIFY_NONE, |
| 1450 | .help = "Don't do IO verification", |
| 1451 | }, |
Jens Axboe | fcca4b5 | 2007-07-27 15:42:00 +0200 | [diff] [blame] | 1452 | { .ival = "md5", |
| 1453 | .oval = VERIFY_MD5, |
| 1454 | .help = "Use md5 checksums for verification", |
| 1455 | }, |
Jens Axboe | d77a7af | 2007-07-27 15:35:06 +0200 | [diff] [blame] | 1456 | { .ival = "crc64", |
| 1457 | .oval = VERIFY_CRC64, |
| 1458 | .help = "Use crc64 checksums for verification", |
| 1459 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1460 | { .ival = "crc32", |
| 1461 | .oval = VERIFY_CRC32, |
| 1462 | .help = "Use crc32 checksums for verification", |
| 1463 | }, |
Jens Axboe | af497e6 | 2008-08-04 15:40:35 +0200 | [diff] [blame] | 1464 | { .ival = "crc32c-intel", |
| 1465 | .oval = VERIFY_CRC32C_INTEL, |
| 1466 | .help = "Use hw crc32c checksums for verification", |
| 1467 | }, |
Jens Axboe | bac39e0 | 2008-06-11 20:46:19 +0200 | [diff] [blame] | 1468 | { .ival = "crc32c", |
| 1469 | .oval = VERIFY_CRC32C, |
| 1470 | .help = "Use crc32c checksums for verification", |
| 1471 | }, |
Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 1472 | { .ival = "crc16", |
| 1473 | .oval = VERIFY_CRC16, |
| 1474 | .help = "Use crc16 checksums for verification", |
| 1475 | }, |
Jens Axboe | 1e154bd | 2007-07-27 09:52:40 +0200 | [diff] [blame] | 1476 | { .ival = "crc7", |
| 1477 | .oval = VERIFY_CRC7, |
| 1478 | .help = "Use crc7 checksums for verification", |
| 1479 | }, |
Jens Axboe | 7c353ce | 2009-08-09 22:40:33 +0200 | [diff] [blame] | 1480 | { .ival = "sha1", |
| 1481 | .oval = VERIFY_SHA1, |
| 1482 | .help = "Use sha1 checksums for verification", |
| 1483 | }, |
Jens Axboe | cd14cc1 | 2007-07-30 10:59:33 +0200 | [diff] [blame] | 1484 | { .ival = "sha256", |
| 1485 | .oval = VERIFY_SHA256, |
| 1486 | .help = "Use sha256 checksums for verification", |
| 1487 | }, |
| 1488 | { .ival = "sha512", |
| 1489 | .oval = VERIFY_SHA512, |
| 1490 | .help = "Use sha512 checksums for verification", |
| 1491 | }, |
Shawn Lewis | 7437ee8 | 2007-08-02 21:05:58 +0200 | [diff] [blame] | 1492 | { .ival = "meta", |
| 1493 | .oval = VERIFY_META, |
| 1494 | .help = "Use io information", |
| 1495 | }, |
Jens Axboe | 36690c9 | 2007-03-26 10:23:34 +0200 | [diff] [blame] | 1496 | { |
| 1497 | .ival = "null", |
| 1498 | .oval = VERIFY_NULL, |
| 1499 | .help = "Pretend to verify", |
| 1500 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1501 | }, |
| 1502 | }, |
| 1503 | { |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 1504 | .name = "do_verify", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 1505 | .type = FIO_OPT_BOOL, |
Jens Axboe | 005c565 | 2007-08-02 22:21:36 +0200 | [diff] [blame] | 1506 | .off1 = td_var_offset(do_verify), |
| 1507 | .help = "Run verification stage after write", |
| 1508 | .def = "1", |
| 1509 | .parent = "verify", |
| 1510 | }, |
| 1511 | { |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 1512 | .name = "verifysort", |
| 1513 | .type = FIO_OPT_BOOL, |
| 1514 | .off1 = td_var_offset(verifysort), |
| 1515 | .help = "Sort written verify blocks for read back", |
| 1516 | .def = "1", |
Jens Axboe | c83f2df | 2007-07-31 22:51:47 +0200 | [diff] [blame] | 1517 | .parent = "verify", |
Jens Axboe | 160b966 | 2007-03-27 10:59:49 +0200 | [diff] [blame] | 1518 | }, |
| 1519 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1520 | .name = "verify_interval", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1521 | .type = FIO_OPT_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1522 | .off1 = td_var_offset(verify_interval), |
Jens Axboe | 819a968 | 2007-07-28 21:30:31 +0200 | [diff] [blame] | 1523 | .minval = 2 * sizeof(struct verify_header), |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1524 | .help = "Store verify buffer header every N bytes", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1525 | .parent = "verify", |
Shawn Lewis | 3f9f4e2 | 2007-07-28 21:10:37 +0200 | [diff] [blame] | 1526 | }, |
| 1527 | { |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1528 | .name = "verify_offset", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1529 | .type = FIO_OPT_INT, |
Jens Axboe | a59e170 | 2007-07-30 08:53:27 +0200 | [diff] [blame] | 1530 | .help = "Offset verify header location by N bytes", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 1531 | .def = "0", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 1532 | .cb = str_verify_offset_cb, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1533 | .parent = "verify", |
Shawn Lewis | 546a914 | 2007-07-28 21:11:37 +0200 | [diff] [blame] | 1534 | }, |
| 1535 | { |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 1536 | .name = "verify_pattern", |
Radha Ramachandran | 0e92f87 | 2009-10-27 20:14:27 +0100 | [diff] [blame] | 1537 | .type = FIO_OPT_STR, |
Shawn Lewis | e28218f | 2008-01-16 11:01:33 +0100 | [diff] [blame] | 1538 | .cb = str_verify_pattern_cb, |
| 1539 | .help = "Fill pattern for IO buffers", |
| 1540 | .parent = "verify", |
| 1541 | }, |
| 1542 | { |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 1543 | .name = "verify_fatal", |
Jens Axboe | 68e1f29 | 2007-08-10 10:32:14 +0200 | [diff] [blame] | 1544 | .type = FIO_OPT_BOOL, |
Jens Axboe | a12a3b4 | 2007-08-09 10:20:54 +0200 | [diff] [blame] | 1545 | .off1 = td_var_offset(verify_fatal), |
| 1546 | .def = "0", |
| 1547 | .help = "Exit on a single verify failure, don't continue", |
| 1548 | .parent = "verify", |
| 1549 | }, |
| 1550 | { |
Jens Axboe | b463e93 | 2011-01-12 09:03:23 +0100 | [diff] [blame] | 1551 | .name = "verify_dump", |
| 1552 | .type = FIO_OPT_BOOL, |
| 1553 | .off1 = td_var_offset(verify_dump), |
Jens Axboe | ef71e31 | 2011-10-25 22:43:36 +0200 | [diff] [blame] | 1554 | .def = "0", |
Jens Axboe | b463e93 | 2011-01-12 09:03:23 +0100 | [diff] [blame] | 1555 | .help = "Dump contents of good and bad blocks on failure", |
| 1556 | .parent = "verify", |
| 1557 | }, |
| 1558 | { |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 1559 | .name = "verify_async", |
| 1560 | .type = FIO_OPT_INT, |
| 1561 | .off1 = td_var_offset(verify_async), |
| 1562 | .def = "0", |
| 1563 | .help = "Number of async verifier threads to use", |
| 1564 | .parent = "verify", |
| 1565 | }, |
Jens Axboe | 9e14418 | 2010-06-15 14:25:36 +0200 | [diff] [blame] | 1566 | { |
| 1567 | .name = "verify_backlog", |
| 1568 | .type = FIO_OPT_STR_VAL, |
| 1569 | .off1 = td_var_offset(verify_backlog), |
| 1570 | .help = "Verify after this number of blocks are written", |
| 1571 | .parent = "verify", |
| 1572 | }, |
| 1573 | { |
| 1574 | .name = "verify_backlog_batch", |
| 1575 | .type = FIO_OPT_INT, |
| 1576 | .off1 = td_var_offset(verify_batch), |
| 1577 | .help = "Verify this number of IO blocks", |
Jens Axboe | 0d29de8 | 2010-09-01 13:54:15 +0200 | [diff] [blame] | 1578 | .parent = "verify", |
Jens Axboe | 9e14418 | 2010-06-15 14:25:36 +0200 | [diff] [blame] | 1579 | }, |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 1580 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1581 | { |
| 1582 | .name = "verify_async_cpus", |
| 1583 | .type = FIO_OPT_STR, |
| 1584 | .cb = str_verify_cpus_allowed_cb, |
| 1585 | .help = "Set CPUs allowed for async verify threads", |
| 1586 | .parent = "verify_async", |
| 1587 | }, |
| 1588 | #endif |
Jens Axboe | 0d29de8 | 2010-09-01 13:54:15 +0200 | [diff] [blame] | 1589 | #ifdef FIO_HAVE_TRIM |
| 1590 | { |
| 1591 | .name = "trim_percentage", |
| 1592 | .type = FIO_OPT_INT, |
| 1593 | .cb = str_verify_trim_cb, |
| 1594 | .maxval = 100, |
| 1595 | .help = "Number of verify blocks to discard/trim", |
| 1596 | .parent = "verify", |
| 1597 | .def = "0", |
| 1598 | }, |
| 1599 | { |
| 1600 | .name = "trim_verify_zero", |
| 1601 | .type = FIO_OPT_INT, |
| 1602 | .help = "Verify that trim/discarded blocks are returned as zeroes", |
| 1603 | .off1 = td_var_offset(trim_zero), |
| 1604 | .parent = "trim_percentage", |
| 1605 | .def = "1", |
| 1606 | }, |
| 1607 | { |
| 1608 | .name = "trim_backlog", |
| 1609 | .type = FIO_OPT_STR_VAL, |
| 1610 | .off1 = td_var_offset(trim_backlog), |
| 1611 | .help = "Trim after this number of blocks are written", |
| 1612 | .parent = "trim_percentage", |
| 1613 | }, |
| 1614 | { |
| 1615 | .name = "trim_backlog_batch", |
| 1616 | .type = FIO_OPT_INT, |
| 1617 | .off1 = td_var_offset(trim_batch), |
| 1618 | .help = "Trim this number of IO blocks", |
| 1619 | .parent = "trim_percentage", |
| 1620 | }, |
| 1621 | #endif |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame] | 1622 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1623 | .name = "write_iolog", |
| 1624 | .type = FIO_OPT_STR_STORE, |
| 1625 | .off1 = td_var_offset(write_iolog_file), |
| 1626 | .help = "Store IO pattern to file", |
| 1627 | }, |
| 1628 | { |
| 1629 | .name = "read_iolog", |
| 1630 | .type = FIO_OPT_STR_STORE, |
| 1631 | .off1 = td_var_offset(read_iolog_file), |
| 1632 | .help = "Playback IO pattern from file", |
| 1633 | }, |
| 1634 | { |
David Nellans | 64bbb86 | 2010-08-24 22:13:30 +0200 | [diff] [blame] | 1635 | .name = "replay_no_stall", |
| 1636 | .type = FIO_OPT_INT, |
| 1637 | .off1 = td_var_offset(no_stall), |
| 1638 | .def = "0", |
Jens Axboe | 87e7a97 | 2010-08-25 09:01:25 +0200 | [diff] [blame] | 1639 | .parent = "read_iolog", |
David Nellans | 64bbb86 | 2010-08-24 22:13:30 +0200 | [diff] [blame] | 1640 | .help = "Playback IO pattern file as fast as possible without stalls", |
| 1641 | }, |
| 1642 | { |
David Nellans | d1c46c0 | 2010-08-31 21:20:47 +0200 | [diff] [blame] | 1643 | .name = "replay_redirect", |
| 1644 | .type = FIO_OPT_STR_STORE, |
| 1645 | .off1 = td_var_offset(replay_redirect), |
| 1646 | .parent = "read_iolog", |
| 1647 | .help = "Replay all I/O onto this device, regardless of trace device", |
| 1648 | }, |
| 1649 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1650 | .name = "exec_prerun", |
| 1651 | .type = FIO_OPT_STR_STORE, |
| 1652 | .off1 = td_var_offset(exec_prerun), |
| 1653 | .help = "Execute this file prior to running job", |
| 1654 | }, |
| 1655 | { |
| 1656 | .name = "exec_postrun", |
| 1657 | .type = FIO_OPT_STR_STORE, |
| 1658 | .off1 = td_var_offset(exec_postrun), |
| 1659 | .help = "Execute this file after running job", |
| 1660 | }, |
| 1661 | #ifdef FIO_HAVE_IOSCHED_SWITCH |
| 1662 | { |
| 1663 | .name = "ioscheduler", |
| 1664 | .type = FIO_OPT_STR_STORE, |
| 1665 | .off1 = td_var_offset(ioscheduler), |
| 1666 | .help = "Use this IO scheduler on the backing device", |
| 1667 | }, |
| 1668 | #endif |
| 1669 | { |
| 1670 | .name = "zonesize", |
| 1671 | .type = FIO_OPT_STR_VAL, |
| 1672 | .off1 = td_var_offset(zone_size), |
| 1673 | .help = "Give size of an IO zone", |
| 1674 | .def = "0", |
| 1675 | }, |
| 1676 | { |
| 1677 | .name = "zoneskip", |
| 1678 | .type = FIO_OPT_STR_VAL, |
| 1679 | .off1 = td_var_offset(zone_skip), |
| 1680 | .help = "Space between IO zones", |
| 1681 | .def = "0", |
| 1682 | }, |
| 1683 | { |
| 1684 | .name = "lockmem", |
| 1685 | .type = FIO_OPT_STR_VAL, |
| 1686 | .cb = str_lockmem_cb, |
| 1687 | .help = "Lock down this amount of memory", |
| 1688 | .def = "0", |
| 1689 | }, |
| 1690 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1691 | .name = "rwmixread", |
| 1692 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1693 | .cb = str_rwmix_read_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1694 | .maxval = 100, |
| 1695 | .help = "Percentage of mixed workload that is reads", |
| 1696 | .def = "50", |
| 1697 | }, |
| 1698 | { |
| 1699 | .name = "rwmixwrite", |
| 1700 | .type = FIO_OPT_INT, |
Jens Axboe | cb499fc | 2008-05-28 10:33:32 +0200 | [diff] [blame] | 1701 | .cb = str_rwmix_write_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1702 | .maxval = 100, |
| 1703 | .help = "Percentage of mixed workload that is writes", |
| 1704 | .def = "50", |
| 1705 | }, |
| 1706 | { |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1707 | .name = "rwmixcycle", |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 1708 | .type = FIO_OPT_DEPRECATED, |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1709 | }, |
| 1710 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1711 | .name = "nice", |
| 1712 | .type = FIO_OPT_INT, |
| 1713 | .off1 = td_var_offset(nice), |
| 1714 | .help = "Set job CPU nice value", |
| 1715 | .minval = -19, |
| 1716 | .maxval = 20, |
| 1717 | .def = "0", |
| 1718 | }, |
| 1719 | #ifdef FIO_HAVE_IOPRIO |
| 1720 | { |
| 1721 | .name = "prio", |
| 1722 | .type = FIO_OPT_INT, |
| 1723 | .cb = str_prio_cb, |
| 1724 | .help = "Set job IO priority value", |
| 1725 | .minval = 0, |
| 1726 | .maxval = 7, |
| 1727 | }, |
| 1728 | { |
| 1729 | .name = "prioclass", |
| 1730 | .type = FIO_OPT_INT, |
| 1731 | .cb = str_prioclass_cb, |
| 1732 | .help = "Set job IO priority class", |
| 1733 | .minval = 0, |
| 1734 | .maxval = 3, |
| 1735 | }, |
| 1736 | #endif |
| 1737 | { |
| 1738 | .name = "thinktime", |
| 1739 | .type = FIO_OPT_INT, |
| 1740 | .off1 = td_var_offset(thinktime), |
| 1741 | .help = "Idle time between IO buffers (usec)", |
| 1742 | .def = "0", |
| 1743 | }, |
| 1744 | { |
| 1745 | .name = "thinktime_spin", |
| 1746 | .type = FIO_OPT_INT, |
| 1747 | .off1 = td_var_offset(thinktime_spin), |
| 1748 | .help = "Start think time by spinning this amount (usec)", |
| 1749 | .def = "0", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1750 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1751 | }, |
| 1752 | { |
| 1753 | .name = "thinktime_blocks", |
| 1754 | .type = FIO_OPT_INT, |
| 1755 | .off1 = td_var_offset(thinktime_blocks), |
| 1756 | .help = "IO buffer period between 'thinktime'", |
| 1757 | .def = "1", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1758 | .parent = "thinktime", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1759 | }, |
| 1760 | { |
| 1761 | .name = "rate", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1762 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1763 | .off1 = td_var_offset(rate[0]), |
| 1764 | .off2 = td_var_offset(rate[1]), |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1765 | .help = "Set bandwidth rate", |
| 1766 | }, |
| 1767 | { |
| 1768 | .name = "ratemin", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1769 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1770 | .off1 = td_var_offset(ratemin[0]), |
| 1771 | .off2 = td_var_offset(ratemin[1]), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1772 | .help = "Job must meet this rate or it will be shutdown", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1773 | .parent = "rate", |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1774 | }, |
| 1775 | { |
| 1776 | .name = "rate_iops", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1777 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1778 | .off1 = td_var_offset(rate_iops[0]), |
| 1779 | .off2 = td_var_offset(rate_iops[1]), |
Jens Axboe | 4e991c2 | 2007-03-15 11:41:11 +0100 | [diff] [blame] | 1780 | .help = "Limit IO used to this number of IO operations/sec", |
| 1781 | }, |
| 1782 | { |
| 1783 | .name = "rate_iops_min", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1784 | .type = FIO_OPT_INT, |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 1785 | .off1 = td_var_offset(rate_iops_min[0]), |
| 1786 | .off2 = td_var_offset(rate_iops_min[1]), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 1787 | .help = "Job must meet this rate or it will be shut down", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1788 | .parent = "rate_iops", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1789 | }, |
| 1790 | { |
| 1791 | .name = "ratecycle", |
| 1792 | .type = FIO_OPT_INT, |
| 1793 | .off1 = td_var_offset(ratecycle), |
| 1794 | .help = "Window average for rate limits (msec)", |
| 1795 | .def = "1000", |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 1796 | .parent = "rate", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1797 | }, |
| 1798 | { |
| 1799 | .name = "invalidate", |
| 1800 | .type = FIO_OPT_BOOL, |
| 1801 | .off1 = td_var_offset(invalidate_cache), |
| 1802 | .help = "Invalidate buffer/page cache prior to running job", |
| 1803 | .def = "1", |
| 1804 | }, |
| 1805 | { |
| 1806 | .name = "sync", |
| 1807 | .type = FIO_OPT_BOOL, |
| 1808 | .off1 = td_var_offset(sync_io), |
| 1809 | .help = "Use O_SYNC for buffered writes", |
| 1810 | .def = "0", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1811 | .parent = "buffered", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1812 | }, |
| 1813 | { |
| 1814 | .name = "bwavgtime", |
| 1815 | .type = FIO_OPT_INT, |
| 1816 | .off1 = td_var_offset(bw_avg_time), |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 1817 | .help = "Time window over which to calculate bandwidth" |
| 1818 | " (msec)", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1819 | .def = "500", |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1820 | .parent = "write_bw_log", |
| 1821 | }, |
| 1822 | { |
| 1823 | .name = "iopsavgtime", |
| 1824 | .type = FIO_OPT_INT, |
| 1825 | .off1 = td_var_offset(iops_avg_time), |
| 1826 | .help = "Time window over which to calculate IOPS (msec)", |
| 1827 | .def = "500", |
| 1828 | .parent = "write_iops_log", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1829 | }, |
| 1830 | { |
| 1831 | .name = "create_serialize", |
| 1832 | .type = FIO_OPT_BOOL, |
| 1833 | .off1 = td_var_offset(create_serialize), |
| 1834 | .help = "Serialize creating of job files", |
| 1835 | .def = "1", |
| 1836 | }, |
| 1837 | { |
| 1838 | .name = "create_fsync", |
| 1839 | .type = FIO_OPT_BOOL, |
| 1840 | .off1 = td_var_offset(create_fsync), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 1841 | .help = "fsync file after creation", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1842 | .def = "1", |
| 1843 | }, |
| 1844 | { |
Jens Axboe | 814452b | 2009-03-04 12:53:13 +0100 | [diff] [blame] | 1845 | .name = "create_on_open", |
| 1846 | .type = FIO_OPT_BOOL, |
| 1847 | .off1 = td_var_offset(create_on_open), |
| 1848 | .help = "Create files when they are opened for IO", |
| 1849 | .def = "0", |
| 1850 | }, |
Jens Axboe | 0b9d69e | 2009-09-11 22:29:54 +0200 | [diff] [blame] | 1851 | { |
Zhang, Yanmin | afad68f | 2009-05-20 11:30:55 +0200 | [diff] [blame] | 1852 | .name = "pre_read", |
| 1853 | .type = FIO_OPT_BOOL, |
| 1854 | .off1 = td_var_offset(pre_read), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 1855 | .help = "Pre-read files before starting official testing", |
Zhang, Yanmin | afad68f | 2009-05-20 11:30:55 +0200 | [diff] [blame] | 1856 | .def = "0", |
| 1857 | }, |
Jens Axboe | 814452b | 2009-03-04 12:53:13 +0100 | [diff] [blame] | 1858 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1859 | .name = "cpuload", |
| 1860 | .type = FIO_OPT_INT, |
| 1861 | .off1 = td_var_offset(cpuload), |
| 1862 | .help = "Use this percentage of CPU", |
| 1863 | }, |
| 1864 | { |
| 1865 | .name = "cpuchunks", |
| 1866 | .type = FIO_OPT_INT, |
| 1867 | .off1 = td_var_offset(cpucycle), |
| 1868 | .help = "Length of the CPU burn cycles (usecs)", |
| 1869 | .def = "50000", |
Jens Axboe | 67a1000 | 2007-07-31 23:12:16 +0200 | [diff] [blame] | 1870 | .parent = "cpuload", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1871 | }, |
| 1872 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 1873 | { |
| 1874 | .name = "cpumask", |
| 1875 | .type = FIO_OPT_INT, |
| 1876 | .cb = str_cpumask_cb, |
| 1877 | .help = "CPU affinity mask", |
| 1878 | }, |
Jens Axboe | d2e268b | 2007-06-15 10:33:49 +0200 | [diff] [blame] | 1879 | { |
| 1880 | .name = "cpus_allowed", |
| 1881 | .type = FIO_OPT_STR, |
| 1882 | .cb = str_cpus_allowed_cb, |
| 1883 | .help = "Set CPUs allowed", |
| 1884 | }, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1885 | #endif |
| 1886 | { |
| 1887 | .name = "end_fsync", |
| 1888 | .type = FIO_OPT_BOOL, |
| 1889 | .off1 = td_var_offset(end_fsync), |
| 1890 | .help = "Include fsync at the end of job", |
| 1891 | .def = "0", |
| 1892 | }, |
| 1893 | { |
| 1894 | .name = "fsync_on_close", |
| 1895 | .type = FIO_OPT_BOOL, |
| 1896 | .off1 = td_var_offset(fsync_on_close), |
| 1897 | .help = "fsync files on close", |
| 1898 | .def = "0", |
| 1899 | }, |
| 1900 | { |
| 1901 | .name = "unlink", |
| 1902 | .type = FIO_OPT_BOOL, |
| 1903 | .off1 = td_var_offset(unlink), |
| 1904 | .help = "Unlink created files after job has completed", |
| 1905 | .def = "0", |
| 1906 | }, |
| 1907 | { |
| 1908 | .name = "exitall", |
| 1909 | .type = FIO_OPT_STR_SET, |
| 1910 | .cb = str_exitall_cb, |
| 1911 | .help = "Terminate all jobs when one exits", |
| 1912 | }, |
| 1913 | { |
| 1914 | .name = "stonewall", |
Jens Axboe | d392365 | 2011-08-03 12:38:39 +0200 | [diff] [blame] | 1915 | .alias = "wait_for_previous", |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1916 | .type = FIO_OPT_STR_SET, |
| 1917 | .off1 = td_var_offset(stonewall), |
| 1918 | .help = "Insert a hard barrier between this job and previous", |
| 1919 | }, |
| 1920 | { |
Jens Axboe | b3d62a7 | 2007-03-20 14:23:26 +0100 | [diff] [blame] | 1921 | .name = "new_group", |
| 1922 | .type = FIO_OPT_STR_SET, |
| 1923 | .off1 = td_var_offset(new_group), |
| 1924 | .help = "Mark the start of a new group (for reporting)", |
| 1925 | }, |
| 1926 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1927 | .name = "thread", |
| 1928 | .type = FIO_OPT_STR_SET, |
| 1929 | .off1 = td_var_offset(use_thread), |
| 1930 | .help = "Use threads instead of forks", |
| 1931 | }, |
| 1932 | { |
| 1933 | .name = "write_bw_log", |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1934 | .type = FIO_OPT_STR, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1935 | .off1 = td_var_offset(write_bw_log), |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1936 | .cb = str_write_bw_log_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1937 | .help = "Write log of bandwidth during run", |
| 1938 | }, |
| 1939 | { |
| 1940 | .name = "write_lat_log", |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1941 | .type = FIO_OPT_STR, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1942 | .off1 = td_var_offset(write_lat_log), |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 1943 | .cb = str_write_lat_log_cb, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1944 | .help = "Write log of latency during run", |
| 1945 | }, |
| 1946 | { |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1947 | .name = "write_iops_log", |
| 1948 | .type = FIO_OPT_STR, |
| 1949 | .off1 = td_var_offset(write_iops_log), |
| 1950 | .cb = str_write_iops_log_cb, |
| 1951 | .help = "Write log of IOPS during run", |
| 1952 | }, |
| 1953 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1954 | .name = "hugepage-size", |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 1955 | .type = FIO_OPT_INT, |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1956 | .off1 = td_var_offset(hugepage_size), |
| 1957 | .help = "When using hugepages, specify size of each page", |
Jens Axboe | 81179ee | 2011-10-04 12:42:06 +0200 | [diff] [blame] | 1958 | .def = __fio_stringify(FIO_HUGE_PAGE), |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 1959 | }, |
| 1960 | { |
| 1961 | .name = "group_reporting", |
| 1962 | .type = FIO_OPT_STR_SET, |
| 1963 | .off1 = td_var_offset(group_reporting), |
| 1964 | .help = "Do reporting on a per-group basis", |
| 1965 | }, |
| 1966 | { |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 1967 | .name = "zero_buffers", |
| 1968 | .type = FIO_OPT_STR_SET, |
| 1969 | .off1 = td_var_offset(zero_buffers), |
| 1970 | .help = "Init IO buffers to all zeroes", |
| 1971 | }, |
Jens Axboe | 5973caf | 2008-05-21 19:52:35 +0200 | [diff] [blame] | 1972 | { |
| 1973 | .name = "refill_buffers", |
| 1974 | .type = FIO_OPT_STR_SET, |
| 1975 | .off1 = td_var_offset(refill_buffers), |
| 1976 | .help = "Refill IO buffers on every IO submit", |
| 1977 | }, |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1978 | { |
Jens Axboe | fd68418 | 2011-09-19 09:24:44 +0200 | [diff] [blame] | 1979 | .name = "scramble_buffers", |
| 1980 | .type = FIO_OPT_BOOL, |
| 1981 | .off1 = td_var_offset(scramble_buffers), |
| 1982 | .help = "Slightly scramble buffers on every IO submit", |
| 1983 | .def = "1", |
| 1984 | }, |
| 1985 | { |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1986 | .name = "clat_percentiles", |
| 1987 | .type = FIO_OPT_BOOL, |
| 1988 | .off1 = td_var_offset(clat_percentiles), |
| 1989 | .help = "Enable the reporting of completion latency percentiles", |
Jens Axboe | 467b35e | 2011-10-13 08:53:24 +0200 | [diff] [blame] | 1990 | .def = "1", |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1991 | }, |
| 1992 | { |
| 1993 | .name = "percentile_list", |
| 1994 | .type = FIO_OPT_FLOAT_LIST, |
| 1995 | .off1 = td_var_offset(percentile_list), |
| 1996 | .off2 = td_var_offset(overwrite_plist), |
| 1997 | .help = "Specify a custom list of percentiles to report", |
| 1998 | .maxlen = FIO_IO_U_LIST_MAX_LEN, |
| 1999 | .minfp = 0.0, |
| 2000 | .maxfp = 100.0, |
| 2001 | }, |
| 2002 | |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 2003 | #ifdef FIO_HAVE_DISK_UTIL |
| 2004 | { |
| 2005 | .name = "disk_util", |
| 2006 | .type = FIO_OPT_BOOL, |
| 2007 | .off1 = td_var_offset(do_disk_util), |
Jens Axboe | f66ab3c | 2008-06-05 11:48:22 +0200 | [diff] [blame] | 2008 | .help = "Log disk utilization statistics", |
Jens Axboe | 0a839f3 | 2007-04-26 09:02:34 +0200 | [diff] [blame] | 2009 | .def = "1", |
| 2010 | }, |
| 2011 | #endif |
Jens Axboe | e9459e5 | 2007-04-17 15:46:32 +0200 | [diff] [blame] | 2012 | { |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 2013 | .name = "gtod_reduce", |
| 2014 | .type = FIO_OPT_BOOL, |
| 2015 | .help = "Greatly reduce number of gettimeofday() calls", |
| 2016 | .cb = str_gtod_reduce_cb, |
| 2017 | .def = "0", |
| 2018 | }, |
| 2019 | { |
Jens Axboe | 02af098 | 2010-06-24 09:59:34 +0200 | [diff] [blame] | 2020 | .name = "disable_lat", |
| 2021 | .type = FIO_OPT_BOOL, |
| 2022 | .off1 = td_var_offset(disable_lat), |
| 2023 | .help = "Disable latency numbers", |
| 2024 | .parent = "gtod_reduce", |
| 2025 | .def = "0", |
| 2026 | }, |
| 2027 | { |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 2028 | .name = "disable_clat", |
| 2029 | .type = FIO_OPT_BOOL, |
| 2030 | .off1 = td_var_offset(disable_clat), |
| 2031 | .help = "Disable completion latency numbers", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 2032 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 2033 | .def = "0", |
| 2034 | }, |
| 2035 | { |
| 2036 | .name = "disable_slat", |
| 2037 | .type = FIO_OPT_BOOL, |
| 2038 | .off1 = td_var_offset(disable_slat), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 2039 | .help = "Disable submission latency numbers", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 2040 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 2041 | .def = "0", |
| 2042 | }, |
| 2043 | { |
| 2044 | .name = "disable_bw_measurement", |
| 2045 | .type = FIO_OPT_BOOL, |
| 2046 | .off1 = td_var_offset(disable_bw), |
| 2047 | .help = "Disable bandwidth logging", |
Jens Axboe | 993bf48 | 2008-11-14 13:04:53 +0100 | [diff] [blame] | 2048 | .parent = "gtod_reduce", |
Jens Axboe | 9520ebb | 2008-10-16 21:03:27 +0200 | [diff] [blame] | 2049 | .def = "0", |
| 2050 | }, |
| 2051 | { |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 2052 | .name = "gtod_cpu", |
| 2053 | .type = FIO_OPT_INT, |
| 2054 | .cb = str_gtod_cpu_cb, |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 2055 | .help = "Set up dedicated gettimeofday() thread on this CPU", |
Jens Axboe | 29d43ff | 2009-07-01 10:42:18 +0200 | [diff] [blame] | 2056 | .verify = gtod_cpu_verify, |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 2057 | }, |
| 2058 | { |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 2059 | .name = "continue_on_error", |
| 2060 | .type = FIO_OPT_BOOL, |
| 2061 | .off1 = td_var_offset(continue_on_error), |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 2062 | .help = "Continue on non-fatal errors during IO", |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 2063 | .def = "0", |
| 2064 | }, |
| 2065 | { |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 2066 | .name = "profile", |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 2067 | .type = FIO_OPT_STR_STORE, |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 2068 | .off1 = td_var_offset(profile), |
Jens Axboe | 9ac8a79 | 2009-11-13 21:23:07 +0100 | [diff] [blame] | 2069 | .help = "Select a specific builtin performance test", |
| 2070 | }, |
| 2071 | { |
Jens Axboe | a696fa2 | 2009-12-04 10:05:02 +0100 | [diff] [blame] | 2072 | .name = "cgroup", |
| 2073 | .type = FIO_OPT_STR_STORE, |
| 2074 | .off1 = td_var_offset(cgroup), |
| 2075 | .help = "Add job to cgroup of this name", |
| 2076 | }, |
| 2077 | { |
| 2078 | .name = "cgroup_weight", |
| 2079 | .type = FIO_OPT_INT, |
| 2080 | .off1 = td_var_offset(cgroup_weight), |
| 2081 | .help = "Use given weight for cgroup", |
| 2082 | .minval = 100, |
| 2083 | .maxval = 1000, |
Jens Axboe | a696fa2 | 2009-12-04 10:05:02 +0100 | [diff] [blame] | 2084 | }, |
| 2085 | { |
Vivek Goyal | 7de8709 | 2010-03-31 22:55:15 +0200 | [diff] [blame] | 2086 | .name = "cgroup_nodelete", |
| 2087 | .type = FIO_OPT_BOOL, |
| 2088 | .off1 = td_var_offset(cgroup_nodelete), |
| 2089 | .help = "Do not delete cgroups after job completion", |
| 2090 | .def = "0", |
| 2091 | }, |
| 2092 | { |
Jens Axboe | e0b0d89 | 2009-12-08 10:10:14 +0100 | [diff] [blame] | 2093 | .name = "uid", |
| 2094 | .type = FIO_OPT_INT, |
| 2095 | .off1 = td_var_offset(uid), |
| 2096 | .help = "Run job with this user ID", |
| 2097 | }, |
| 2098 | { |
| 2099 | .name = "gid", |
| 2100 | .type = FIO_OPT_INT, |
| 2101 | .off1 = td_var_offset(gid), |
| 2102 | .help = "Run job with this group ID", |
| 2103 | }, |
| 2104 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2105 | .name = NULL, |
| 2106 | }, |
| 2107 | }; |
| 2108 | |
Jens Axboe | 17af15d | 2010-04-13 10:38:16 +0200 | [diff] [blame] | 2109 | static void add_to_lopt(struct option *lopt, struct fio_option *o, |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2110 | const char *name, int val) |
Jens Axboe | 9f81736 | 2010-03-04 14:38:10 +0100 | [diff] [blame] | 2111 | { |
Jens Axboe | 17af15d | 2010-04-13 10:38:16 +0200 | [diff] [blame] | 2112 | lopt->name = (char *) name; |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2113 | lopt->val = val; |
Jens Axboe | 9f81736 | 2010-03-04 14:38:10 +0100 | [diff] [blame] | 2114 | if (o->type == FIO_OPT_STR_SET) |
| 2115 | lopt->has_arg = no_argument; |
| 2116 | else |
| 2117 | lopt->has_arg = required_argument; |
| 2118 | } |
| 2119 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2120 | static void options_to_lopts(struct fio_option *opts, |
| 2121 | struct option *long_options, |
| 2122 | int i, int option_type) |
| 2123 | { |
| 2124 | struct fio_option *o = &opts[0]; |
| 2125 | while (o->name) { |
| 2126 | add_to_lopt(&long_options[i], o, o->name, option_type); |
| 2127 | if (o->alias) { |
| 2128 | i++; |
| 2129 | add_to_lopt(&long_options[i], o, o->alias, option_type); |
| 2130 | } |
| 2131 | |
| 2132 | i++; |
| 2133 | o++; |
| 2134 | assert(i < FIO_NR_OPTIONS); |
| 2135 | } |
| 2136 | } |
| 2137 | |
| 2138 | void fio_options_set_ioengine_opts(struct option *long_options, |
| 2139 | struct thread_data *td) |
| 2140 | { |
| 2141 | unsigned int i; |
| 2142 | |
| 2143 | i = 0; |
| 2144 | while (long_options[i].name) { |
| 2145 | if (long_options[i].val == FIO_GETOPT_IOENGINE) { |
| 2146 | memset(&long_options[i], 0, sizeof(*long_options)); |
| 2147 | break; |
| 2148 | } |
| 2149 | i++; |
| 2150 | } |
| 2151 | |
| 2152 | /* |
| 2153 | * Just clear out the prior ioengine options. |
| 2154 | */ |
| 2155 | if (!td || !td->eo) |
| 2156 | return; |
| 2157 | |
| 2158 | options_to_lopts(td->io_ops->options, long_options, i, |
| 2159 | FIO_GETOPT_IOENGINE); |
| 2160 | } |
| 2161 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2162 | void fio_options_dup_and_init(struct option *long_options) |
| 2163 | { |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2164 | unsigned int i; |
| 2165 | |
| 2166 | options_init(options); |
| 2167 | |
| 2168 | i = 0; |
| 2169 | while (long_options[i].name) |
| 2170 | i++; |
| 2171 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2172 | options_to_lopts(options, long_options, i, FIO_GETOPT_JOB); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2173 | } |
| 2174 | |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2175 | struct fio_keyword { |
| 2176 | const char *word; |
| 2177 | const char *desc; |
| 2178 | char *replace; |
| 2179 | }; |
| 2180 | |
| 2181 | static struct fio_keyword fio_keywords[] = { |
| 2182 | { |
| 2183 | .word = "$pagesize", |
| 2184 | .desc = "Page size in the system", |
| 2185 | }, |
| 2186 | { |
| 2187 | .word = "$mb_memory", |
| 2188 | .desc = "Megabytes of memory online", |
| 2189 | }, |
| 2190 | { |
| 2191 | .word = "$ncpus", |
| 2192 | .desc = "Number of CPUs online in the system", |
| 2193 | }, |
| 2194 | { |
| 2195 | .word = NULL, |
| 2196 | }, |
| 2197 | }; |
| 2198 | |
| 2199 | void fio_keywords_init(void) |
| 2200 | { |
Jens Axboe | 3b2e146 | 2009-12-15 08:58:10 +0100 | [diff] [blame] | 2201 | unsigned long long mb_memory; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2202 | char buf[128]; |
| 2203 | long l; |
| 2204 | |
| 2205 | sprintf(buf, "%lu", page_size); |
| 2206 | fio_keywords[0].replace = strdup(buf); |
| 2207 | |
Jens Axboe | 8eb016d | 2011-07-11 10:24:20 +0200 | [diff] [blame] | 2208 | mb_memory = os_phys_mem() / (1024 * 1024); |
Jens Axboe | 3b2e146 | 2009-12-15 08:58:10 +0100 | [diff] [blame] | 2209 | sprintf(buf, "%llu", mb_memory); |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2210 | fio_keywords[1].replace = strdup(buf); |
| 2211 | |
Jens Axboe | c00a228 | 2011-07-08 20:56:06 +0200 | [diff] [blame] | 2212 | l = cpus_online(); |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2213 | sprintf(buf, "%lu", l); |
| 2214 | fio_keywords[2].replace = strdup(buf); |
| 2215 | } |
| 2216 | |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2217 | #define BC_APP "bc" |
| 2218 | |
| 2219 | static char *bc_calc(char *str) |
| 2220 | { |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2221 | char buf[128], *tmp; |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2222 | FILE *f; |
| 2223 | int ret; |
| 2224 | |
| 2225 | /* |
| 2226 | * No math, just return string |
| 2227 | */ |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2228 | if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && |
| 2229 | !strchr(str, '/')) || strchr(str, '\'')) |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2230 | return str; |
| 2231 | |
| 2232 | /* |
| 2233 | * Split option from value, we only need to calculate the value |
| 2234 | */ |
| 2235 | tmp = strchr(str, '='); |
| 2236 | if (!tmp) |
| 2237 | return str; |
| 2238 | |
| 2239 | tmp++; |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2240 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2241 | /* |
| 2242 | * Prevent buffer overflows; such a case isn't reasonable anyway |
| 2243 | */ |
| 2244 | if (strlen(str) >= 128 || strlen(tmp) > 100) |
| 2245 | return str; |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2246 | |
| 2247 | sprintf(buf, "which %s > /dev/null", BC_APP); |
| 2248 | if (system(buf)) { |
| 2249 | log_err("fio: bc is needed for performing math\n"); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2250 | return NULL; |
| 2251 | } |
| 2252 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2253 | sprintf(buf, "echo '%s' | %s", tmp, BC_APP); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2254 | f = popen(buf, "r"); |
| 2255 | if (!f) { |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2256 | return NULL; |
| 2257 | } |
| 2258 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2259 | ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2260 | if (ret <= 0) { |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2261 | return NULL; |
| 2262 | } |
| 2263 | |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2264 | pclose(f); |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2265 | buf[(tmp - str) + ret - 1] = '\0'; |
| 2266 | memcpy(buf, str, tmp - str); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2267 | free(str); |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2268 | return strdup(buf); |
| 2269 | } |
| 2270 | |
| 2271 | /* |
| 2272 | * Return a copy of the input string with substrings of the form ${VARNAME} |
| 2273 | * substituted with the value of the environment variable VARNAME. The |
| 2274 | * substitution always occurs, even if VARNAME is empty or the corresponding |
| 2275 | * environment variable undefined. |
| 2276 | */ |
| 2277 | static char *option_dup_subs(const char *opt) |
| 2278 | { |
| 2279 | char out[OPT_LEN_MAX+1]; |
| 2280 | char in[OPT_LEN_MAX+1]; |
| 2281 | char *outptr = out; |
| 2282 | char *inptr = in; |
| 2283 | char *ch1, *ch2, *env; |
| 2284 | ssize_t nchr = OPT_LEN_MAX; |
| 2285 | size_t envlen; |
| 2286 | |
| 2287 | if (strlen(opt) + 1 > OPT_LEN_MAX) { |
| 2288 | log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); |
| 2289 | return NULL; |
| 2290 | } |
| 2291 | |
| 2292 | in[OPT_LEN_MAX] = '\0'; |
| 2293 | strncpy(in, opt, OPT_LEN_MAX); |
| 2294 | |
| 2295 | while (*inptr && nchr > 0) { |
| 2296 | if (inptr[0] == '$' && inptr[1] == '{') { |
| 2297 | ch2 = strchr(inptr, '}'); |
| 2298 | if (ch2 && inptr+1 < ch2) { |
| 2299 | ch1 = inptr+2; |
| 2300 | inptr = ch2+1; |
| 2301 | *ch2 = '\0'; |
| 2302 | |
| 2303 | env = getenv(ch1); |
| 2304 | if (env) { |
| 2305 | envlen = strlen(env); |
| 2306 | if (envlen <= nchr) { |
| 2307 | memcpy(outptr, env, envlen); |
| 2308 | outptr += envlen; |
| 2309 | nchr -= envlen; |
| 2310 | } |
| 2311 | } |
| 2312 | |
| 2313 | continue; |
| 2314 | } |
| 2315 | } |
| 2316 | |
| 2317 | *outptr++ = *inptr++; |
| 2318 | --nchr; |
| 2319 | } |
| 2320 | |
| 2321 | *outptr = '\0'; |
| 2322 | return strdup(out); |
Jens Axboe | 892a6ff | 2009-11-13 12:19:49 +0100 | [diff] [blame] | 2323 | } |
| 2324 | |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2325 | /* |
| 2326 | * Look for reserved variable names and replace them with real values |
| 2327 | */ |
| 2328 | static char *fio_keyword_replace(char *opt) |
| 2329 | { |
| 2330 | char *s; |
| 2331 | int i; |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2332 | int docalc = 0; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2333 | |
| 2334 | for (i = 0; fio_keywords[i].word != NULL; i++) { |
| 2335 | struct fio_keyword *kw = &fio_keywords[i]; |
| 2336 | |
| 2337 | while ((s = strstr(opt, kw->word)) != NULL) { |
| 2338 | char *new = malloc(strlen(opt) + 1); |
| 2339 | char *o_org = opt; |
| 2340 | int olen = s - opt; |
| 2341 | int len; |
| 2342 | |
| 2343 | /* |
| 2344 | * Copy part of the string before the keyword and |
| 2345 | * sprintf() the replacement after it. |
| 2346 | */ |
| 2347 | memcpy(new, opt, olen); |
| 2348 | len = sprintf(new + olen, "%s", kw->replace); |
| 2349 | |
| 2350 | /* |
| 2351 | * If there's more in the original string, copy that |
| 2352 | * in too |
| 2353 | */ |
| 2354 | opt += strlen(kw->word) + olen; |
| 2355 | if (strlen(opt)) |
| 2356 | memcpy(new + olen + len, opt, opt - o_org - 1); |
| 2357 | |
| 2358 | /* |
| 2359 | * replace opt and free the old opt |
| 2360 | */ |
| 2361 | opt = new; |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2362 | free(o_org); |
Jens Axboe | 7a958bd | 2009-11-13 12:33:54 +0100 | [diff] [blame] | 2363 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2364 | docalc = 1; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2365 | } |
| 2366 | } |
| 2367 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2368 | /* |
| 2369 | * Check for potential math and invoke bc, if possible |
| 2370 | */ |
| 2371 | if (docalc) |
| 2372 | opt = bc_calc(opt); |
| 2373 | |
Jens Axboe | 7a958bd | 2009-11-13 12:33:54 +0100 | [diff] [blame] | 2374 | return opt; |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2375 | } |
| 2376 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2377 | static char **dup_and_sub_options(char **opts, int num_opts) |
| 2378 | { |
| 2379 | int i; |
| 2380 | char **opts_copy = malloc(num_opts * sizeof(*opts)); |
| 2381 | for (i = 0; i < num_opts; i++) { |
| 2382 | opts_copy[i] = option_dup_subs(opts[i]); |
| 2383 | if (!opts_copy[i]) |
| 2384 | continue; |
| 2385 | opts_copy[i] = fio_keyword_replace(opts_copy[i]); |
| 2386 | } |
| 2387 | return opts_copy; |
| 2388 | } |
| 2389 | |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2390 | 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] | 2391 | { |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2392 | int i, ret, unknown; |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2393 | char **opts_copy; |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2394 | |
| 2395 | sort_options(opts, options, num_opts); |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2396 | opts_copy = dup_and_sub_options(opts, num_opts); |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2397 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2398 | for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) { |
| 2399 | struct fio_option *o; |
| 2400 | int newret = parse_option(opts_copy[i], opts[i], options, &o, |
| 2401 | td); |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2402 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2403 | if (opts_copy[i]) { |
| 2404 | if (newret && !o) { |
| 2405 | unknown++; |
| 2406 | continue; |
| 2407 | } |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2408 | free(opts_copy[i]); |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2409 | opts_copy[i] = NULL; |
| 2410 | } |
| 2411 | |
| 2412 | ret |= newret; |
| 2413 | } |
| 2414 | |
| 2415 | if (unknown) { |
| 2416 | ret |= ioengine_load(td); |
| 2417 | if (td->eo) { |
| 2418 | sort_options(opts_copy, td->io_ops->options, num_opts); |
| 2419 | opts = opts_copy; |
| 2420 | } |
| 2421 | for (i = 0; i < num_opts; i++) { |
| 2422 | struct fio_option *o = NULL; |
| 2423 | int newret = 1; |
| 2424 | if (!opts_copy[i]) |
| 2425 | continue; |
| 2426 | |
| 2427 | if (td->eo) |
| 2428 | newret = parse_option(opts_copy[i], opts[i], |
| 2429 | td->io_ops->options, &o, |
| 2430 | td->eo); |
| 2431 | |
| 2432 | ret |= newret; |
| 2433 | if (!o) |
| 2434 | log_err("Bad option <%s>\n", opts[i]); |
| 2435 | |
| 2436 | free(opts_copy[i]); |
| 2437 | opts_copy[i] = NULL; |
| 2438 | } |
Jens Axboe | 74929ac | 2009-08-05 11:42:37 +0200 | [diff] [blame] | 2439 | } |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2440 | |
Steven Lang | d0c814e | 2011-10-28 08:37:13 +0200 | [diff] [blame] | 2441 | free(opts_copy); |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 2442 | return ret; |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2443 | } |
| 2444 | |
| 2445 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) |
| 2446 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2447 | return parse_cmd_option(opt, val, options, td); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2448 | } |
| 2449 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2450 | int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt, |
| 2451 | char *val) |
| 2452 | { |
| 2453 | return parse_cmd_option(opt, val, td->io_ops->options, td); |
| 2454 | } |
| 2455 | |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2456 | void fio_fill_default_options(struct thread_data *td) |
| 2457 | { |
| 2458 | fill_default_options(td, options); |
| 2459 | } |
| 2460 | |
| 2461 | int fio_show_option_help(const char *opt) |
| 2462 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2463 | return show_cmd_help(options, opt); |
Jens Axboe | 214e1ec | 2007-03-15 10:48:13 +0100 | [diff] [blame] | 2464 | } |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2465 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2466 | void options_mem_dupe(void *data, struct fio_option *options) |
| 2467 | { |
| 2468 | struct fio_option *o; |
| 2469 | char **ptr; |
| 2470 | |
| 2471 | for (o = &options[0]; o->name; o++) { |
| 2472 | if (o->type != FIO_OPT_STR_STORE) |
| 2473 | continue; |
| 2474 | |
| 2475 | ptr = td_var(data, o->off1); |
| 2476 | if (*ptr) |
| 2477 | *ptr = strdup(*ptr); |
| 2478 | } |
| 2479 | } |
| 2480 | |
Jens Axboe | 7e356b2 | 2011-10-14 10:55:16 +0200 | [diff] [blame] | 2481 | /* |
| 2482 | * dupe FIO_OPT_STR_STORE options |
| 2483 | */ |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2484 | void fio_options_mem_dupe(struct thread_data *td) |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2485 | { |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2486 | options_mem_dupe(&td->o, options); |
Jens Axboe | 1647f59 | 2011-11-09 20:25:21 +0100 | [diff] [blame^] | 2487 | |
| 2488 | if (td->eo && td->io_ops) { |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2489 | void *oldeo = td->eo; |
Jens Axboe | 1647f59 | 2011-11-09 20:25:21 +0100 | [diff] [blame^] | 2490 | |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2491 | td->eo = malloc(td->io_ops->option_struct_size); |
| 2492 | memcpy(td->eo, oldeo, td->io_ops->option_struct_size); |
| 2493 | options_mem_dupe(td->eo, td->io_ops->options); |
Jens Axboe | d23bb32 | 2007-03-23 15:57:56 +0100 | [diff] [blame] | 2494 | } |
| 2495 | } |
| 2496 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 2497 | unsigned int fio_get_kb_base(void *data) |
| 2498 | { |
| 2499 | struct thread_data *td = data; |
| 2500 | unsigned int kb_base = 0; |
| 2501 | |
| 2502 | if (td) |
| 2503 | kb_base = td->o.kb_base; |
| 2504 | if (!kb_base) |
| 2505 | kb_base = 1024; |
| 2506 | |
| 2507 | return kb_base; |
| 2508 | } |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2509 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2510 | int add_option(struct fio_option *o) |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2511 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2512 | struct fio_option *__o; |
| 2513 | int opt_index = 0; |
| 2514 | |
| 2515 | __o = options; |
| 2516 | while (__o->name) { |
| 2517 | opt_index++; |
| 2518 | __o++; |
| 2519 | } |
| 2520 | |
| 2521 | memcpy(&options[opt_index], o, sizeof(*o)); |
| 2522 | return 0; |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 2523 | } |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2524 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2525 | void invalidate_profile_options(const char *prof_name) |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2526 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2527 | struct fio_option *o; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2528 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 2529 | o = options; |
| 2530 | while (o->name) { |
| 2531 | if (o->prof_name && !strcmp(o->prof_name, prof_name)) { |
| 2532 | o->type = FIO_OPT_INVALID; |
| 2533 | o->prof_name = NULL; |
| 2534 | } |
| 2535 | o++; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 2536 | } |
| 2537 | } |
Jens Axboe | f5b6bb8 | 2010-03-05 10:09:59 +0100 | [diff] [blame] | 2538 | |
| 2539 | void add_opt_posval(const char *optname, const char *ival, const char *help) |
| 2540 | { |
| 2541 | struct fio_option *o; |
| 2542 | unsigned int i; |
| 2543 | |
| 2544 | o = find_option(options, optname); |
| 2545 | if (!o) |
| 2546 | return; |
| 2547 | |
| 2548 | for (i = 0; i < PARSE_MAX_VP; i++) { |
| 2549 | if (o->posval[i].ival) |
| 2550 | continue; |
| 2551 | |
| 2552 | o->posval[i].ival = ival; |
| 2553 | o->posval[i].help = help; |
| 2554 | break; |
| 2555 | } |
| 2556 | } |
| 2557 | |
| 2558 | void del_opt_posval(const char *optname, const char *ival) |
| 2559 | { |
| 2560 | struct fio_option *o; |
| 2561 | unsigned int i; |
| 2562 | |
| 2563 | o = find_option(options, optname); |
| 2564 | if (!o) |
| 2565 | return; |
| 2566 | |
| 2567 | for (i = 0; i < PARSE_MAX_VP; i++) { |
| 2568 | if (!o->posval[i].ival) |
| 2569 | continue; |
| 2570 | if (strcmp(o->posval[i].ival, ival)) |
| 2571 | continue; |
| 2572 | |
| 2573 | o->posval[i].ival = NULL; |
| 2574 | o->posval[i].help = NULL; |
| 2575 | } |
| 2576 | } |
Jens Axboe | 7e356b2 | 2011-10-14 10:55:16 +0200 | [diff] [blame] | 2577 | |
| 2578 | void fio_options_free(struct thread_data *td) |
| 2579 | { |
| 2580 | options_free(options, td); |
Steven Lang | de890a1 | 2011-11-09 14:03:34 +0100 | [diff] [blame] | 2581 | if (td->eo && td->io_ops && td->io_ops->options) { |
| 2582 | options_free(td->io_ops->options, td->eo); |
| 2583 | free(td->eo); |
| 2584 | td->eo = NULL; |
| 2585 | } |
Jens Axboe | 7e356b2 | 2011-10-14 10:55:16 +0200 | [diff] [blame] | 2586 | } |