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