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