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