static int stress_set_stream_L3_size(const char *opt) { uint64_t stream_L3_size; stream_L3_size = get_uint64_byte(opt); check_range_bytes("stream-L3-size", stream_L3_size, MIN_STREAM_L3_SIZE, MAX_STREAM_L3_SIZE); return set_setting("stream-L3-size", TYPE_ID_UINT64, &stream_L3_size); }
static int stress_set_fallocate_bytes(const char *opt) { off_t fallocate_bytes; fallocate_bytes = (off_t)get_uint64_byte_filesystem(opt, 1); check_range_bytes("fallocate-bytes", fallocate_bytes, MIN_FALLOCATE_BYTES, MAX_FALLOCATE_BYTES); return set_setting("fallocate-bytes", TYPE_ID_OFF_T, &fallocate_bytes); }
static int stress_set_sync_file_bytes(const char *opt) { off_t sync_file_bytes; sync_file_bytes = (off_t)get_uint64_byte_filesystem(opt, 1); check_range_bytes("sync_file-bytes", sync_file_bytes, MIN_SYNC_FILE_BYTES, MAX_SYNC_FILE_BYTES); return set_setting("sync_file-bytes", TYPE_ID_OFF_T, &sync_file_bytes); }
static int stress_set_userfaultfd_bytes(const char *opt) { size_t userfaultfd_bytes; userfaultfd_bytes = (size_t)get_uint64_byte_memory(opt, 1); check_range_bytes("userfaultfd-bytes", userfaultfd_bytes, MIN_MMAP_BYTES, MAX_MEM_LIMIT); return set_setting("userfaultfd-bytes", TYPE_ID_SIZE_T, &userfaultfd_bytes); }
static int stress_set_sendfile_size(const char *opt) { int64_t sendfile_size; sendfile_size = get_uint64_byte(opt); check_range_bytes("sendfile-size", sendfile_size, MIN_SENDFILE_SIZE, MAX_SENDFILE_SIZE); return set_setting("sendfile-size", TYPE_ID_UINT64, &sendfile_size); }
static int stress_set_mremap_bytes(const char *opt) { size_t mremap_bytes; mremap_bytes = (size_t)get_uint64_byte_memory(opt, 1); check_range_bytes("mremap-bytes", mremap_bytes, MIN_MREMAP_BYTES, MAX_MEM_LIMIT); return set_setting("mremap-bytes", TYPE_ID_SIZE_T, &mremap_bytes); }
static int stress_set_splice_bytes(const char *opt) { size_t splice_bytes; splice_bytes = (size_t)get_uint64_byte_memory(opt, 1); check_range_bytes("splice-bytes", splice_bytes, MIN_SPLICE_BYTES, MAX_MEM_LIMIT); return set_setting("splice-bytes", TYPE_ID_SIZE_T, &splice_bytes); }
static int __handle_option(struct fio_option *o, const char *ptr, void *data, int first, int more) { int il, *ilp; long long ull, *ullp; long ul1, ul2; char **cp; int ret = 0, is_time = 0; dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name, o->type, ptr); if (!ptr && o->type != FIO_OPT_STR_SET && o->type != FIO_OPT_STR) { fprintf(stderr, "Option %s requires an argument\n", o->name); return 1; } switch (o->type) { case FIO_OPT_STR: { fio_opt_str_fn *fn = o->cb; const struct value_pair *vp; struct value_pair posval[PARSE_MAX_VP]; int i; posval_sort(o, posval); for (i = 0; i < PARSE_MAX_VP; i++) { vp = &posval[i]; if (!vp->ival || vp->ival[0] == '\0') break; ret = 1; if (!strncmp(vp->ival, ptr, strlen(vp->ival))) { ret = 0; if (!o->off1) break; val_store(ilp, vp->oval, o->off1, data); break; } } if (ret) show_option_values(o); else if (fn) ret = fn(data, ptr); break; } case FIO_OPT_STR_VAL_TIME: is_time = 1; case FIO_OPT_INT: case FIO_OPT_STR_VAL: { fio_opt_str_val_fn *fn = o->cb; if (is_time) ret = check_str_time(ptr, &ull); else ret = check_str_bytes(ptr, &ull, data); if (ret) break; if (o->maxval && ull > o->maxval) { fprintf(stderr, "max value out of range: %lld" " (%d max)\n", ull, o->maxval); return 1; } if (o->minval && ull < o->minval) { fprintf(stderr, "min value out of range: %lld" " (%d min)\n", ull, o->minval); return 1; } if (fn) ret = fn(data, &ull); else { if (o->type == FIO_OPT_INT) { if (first) val_store(ilp, ull, o->off1, data); if (!more && o->off2) val_store(ilp, ull, o->off2, data); } else { if (first) val_store(ullp, ull, o->off1, data); if (!more && o->off2) val_store(ullp, ull, o->off2, data); } } break; } case FIO_OPT_STR_STORE: { fio_opt_str_fn *fn = o->cb; cp = td_var(data, o->off1); *cp = strdup(ptr); if (fn) { ret = fn(data, ptr); if (ret) { free(*cp); *cp = NULL; } } break; } case FIO_OPT_RANGE: { char tmp[128]; char *p1, *p2; strncpy(tmp, ptr, sizeof(tmp) - 1); p1 = strchr(tmp, '-'); if (!p1) { p1 = strchr(tmp, ':'); if (!p1) { ret = 1; break; } } p2 = p1 + 1; *p1 = '\0'; p1 = tmp; ret = 1; if (!check_range_bytes(p1, &ul1, data) && !check_range_bytes(p2, &ul2, data)) { ret = 0; if (ul1 > ul2) { unsigned long foo = ul1; ul1 = ul2; ul2 = foo; } if (first) { val_store(ilp, ul1, o->off1, data); val_store(ilp, ul2, o->off2, data); } if (o->off3 && o->off4) { val_store(ilp, ul1, o->off3, data); val_store(ilp, ul2, o->off4, data); } } break; } case FIO_OPT_BOOL: { fio_opt_int_fn *fn = o->cb; ret = check_int(ptr, &il); if (ret) break; if (o->maxval && il > (int) o->maxval) { fprintf(stderr, "max value out of range: %d (%d max)\n", il, o->maxval); return 1; } if (o->minval && il < o->minval) { fprintf(stderr, "min value out of range: %d (%d min)\n", il, o->minval); return 1; } if (o->neg) il = !il; if (fn) ret = fn(data, &il); else { if (first) val_store(ilp, il, o->off1, data); if (!more && o->off2) val_store(ilp, il, o->off2, data); } break; } case FIO_OPT_STR_SET: { fio_opt_str_set_fn *fn = o->cb; if (fn) ret = fn(data); else { if (first) val_store(ilp, 1, o->off1, data); if (!more && o->off2) val_store(ilp, 1, o->off2, data); } break; } case FIO_OPT_DEPRECATED: fprintf(stdout, "Option %s is deprecated\n", o->name); break; default: fprintf(stderr, "Bad option type %u\n", o->type); ret = 1; } if (ret) return ret; if (o->verify) { ret = o->verify(o, data); if (ret) { fprintf(stderr,"Correct format for offending option\n"); fprintf(stderr, "%20s: %s\n", o->name, o->help); show_option_help(o, stderr); } } return ret; }