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