-/*
- * Map of job/command line options
- */
-static struct fio_option options[] = {
- {
- .name = "description",
- .type = FIO_OPT_STR_STORE,
- .off1 = td_var_offset(description),
- .help = "Text job description",
- },
- {
- .name = "name",
- .type = FIO_OPT_STR_STORE,
- .off1 = td_var_offset(name),
- .help = "Name of this job",
- },
- {
- .name = "directory",
- .type = FIO_OPT_STR_STORE,
- .off1 = td_var_offset(directory),
- .cb = str_directory_cb,
- .help = "Directory to store files in",
- },
- {
- .name = "filename",
- .type = FIO_OPT_STR_STORE,
- .off1 = td_var_offset(filename),
- .cb = str_filename_cb,
- .help = "File(s) to use for the workload",
- },
- {
- .name = "opendir",
- .type = FIO_OPT_STR_STORE,
- .off1 = td_var_offset(opendir),
- .cb = str_opendir_cb,
- .help = "Recursively add files from this directory and down",
- },
- {
- .name = "rw",
- .alias = "readwrite",
- .type = FIO_OPT_STR,
- .cb = str_rw_cb,
- .off1 = td_var_offset(td_ddir),
- .help = "IO direction",
- .def = "read",
- .posval = {
- { .ival = "read",
- .oval = TD_DDIR_READ,
- .help = "Sequential read",
- },
- { .ival = "write",
- .oval = TD_DDIR_WRITE,
- .help = "Sequential write",
- },
- { .ival = "randread",
+ td->o.verify_offset = *off;
+ return 0;
+}
+
+static int str_verify_pattern_cb(void *data, const char *input)
+{
+ struct thread_data *td = data;
+ long off;
+ int i = 0, j = 0, len, k, base = 10;
+ char* loc1, * loc2;
+
+ loc1 = strstr(input, "0x");
+ loc2 = strstr(input, "0X");
+ if (loc1 || loc2)
+ base = 16;
+ off = strtol(input, NULL, base);
+ if (off != LONG_MAX || errno != ERANGE) {
+ while (off) {
+ td->o.verify_pattern[i] = off & 0xff;
+ off >>= 8;
+ i++;
+ }
+ } else {
+ len = strlen(input);
+ k = len - 1;
+ if (base == 16) {
+ if (loc1)
+ j = loc1 - input + 2;
+ else
+ j = loc2 - input + 2;
+ } else
+ return 1;
+ if (len - j < MAX_PATTERN_SIZE * 2) {
+ while (k >= j) {
+ off = converthexchartoint(input[k--]);
+ if (k >= j)
+ off += (converthexchartoint(input[k--])
+ * 16);
+ td->o.verify_pattern[i++] = (char) off;
+ }
+ }
+ }
+ td->o.verify_pattern_bytes = i;
+ /*
+ * VERIFY_META could already be set
+ */
+ if (td->o.verify == VERIFY_NONE)
+ td->o.verify = VERIFY_PATTERN;
+ return 0;
+}
+
+static int str_lockfile_cb(void *data, const char *str)
+{
+ struct thread_data *td = data;
+ char *nr = get_opt_postfix(str);
+
+ td->o.lockfile_batch = 1;
+ if (nr) {
+ td->o.lockfile_batch = atoi(nr);
+ free(nr);
+ }
+
+ return 0;
+}
+
+static int str_write_bw_log_cb(void *data, const char *str)
+{
+ struct thread_data *td = data;
+
+ if (str)
+ td->o.bw_log_file = strdup(str);
+
+ td->o.write_bw_log = 1;
+ return 0;
+}
+
+static int str_write_lat_log_cb(void *data, const char *str)
+{
+ struct thread_data *td = data;
+
+ if (str)
+ td->o.lat_log_file = strdup(str);
+
+ td->o.write_lat_log = 1;
+ return 0;
+}
+
+static int str_write_iops_log_cb(void *data, const char *str)
+{
+ struct thread_data *td = data;
+
+ if (str)
+ td->o.iops_log_file = strdup(str);
+
+ td->o.write_iops_log = 1;
+ return 0;
+}
+
+static int str_gtod_reduce_cb(void *data, int *il)
+{
+ struct thread_data *td = data;
+ int val = *il;
+
+ td->o.disable_lat = !!val;
+ td->o.disable_clat = !!val;
+ td->o.disable_slat = !!val;
+ td->o.disable_bw = !!val;
+ td->o.clat_percentiles = !val;
+ if (val)
+ td->tv_cache_mask = 63;
+
+ return 0;
+}
+
+static int str_gtod_cpu_cb(void *data, long long *il)
+{
+ struct thread_data *td = data;
+ int val = *il;
+
+ td->o.gtod_cpu = val;
+ td->o.gtod_offload = 1;
+ return 0;
+}
+
+static int str_size_cb(void *data, unsigned long long *__val)
+{
+ struct thread_data *td = data;
+ unsigned long long v = *__val;
+
+ if (parse_is_percent(v)) {
+ td->o.size = 0;
+ td->o.size_percent = -1ULL - v;
+ } else
+ td->o.size = v;
+
+ return 0;
+}
+
+static int rw_verify(struct fio_option *o, void *data)
+{
+ struct thread_data *td = data;
+
+ if (read_only && td_write(td)) {
+ log_err("fio: job <%s> has write bit set, but fio is in"
+ " read-only mode\n", td->o.name);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int gtod_cpu_verify(struct fio_option *o, void *data)
+{
+#ifndef FIO_HAVE_CPU_AFFINITY
+ struct thread_data *td = data;
+
+ if (td->o.gtod_cpu) {
+ log_err("fio: platform must support CPU affinity for"
+ "gettimeofday() offloading\n");
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+static int kb_base_verify(struct fio_option *o, void *data)
+{
+ struct thread_data *td = data;
+
+ if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
+ log_err("fio: kb_base set to nonsensical value: %u\n",
+ td->o.kb_base);
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Map of job/command line options
+ */
+static struct fio_option options[FIO_MAX_OPTS] = {
+ {
+ .name = "description",
+ .type = FIO_OPT_STR_STORE,
+ .off1 = td_var_offset(description),
+ .help = "Text job description",
+ },
+ {
+ .name = "name",
+ .type = FIO_OPT_STR_STORE,
+ .off1 = td_var_offset(name),
+ .help = "Name of this job",
+ },
+ {
+ .name = "directory",
+ .type = FIO_OPT_STR_STORE,
+ .off1 = td_var_offset(directory),
+ .cb = str_directory_cb,
+ .help = "Directory to store files in",
+ },
+ {
+ .name = "filename",
+ .type = FIO_OPT_STR_STORE,
+ .off1 = td_var_offset(filename),
+ .cb = str_filename_cb,
+ .prio = -1, /* must come after "directory" */
+ .help = "File(s) to use for the workload",
+ },
+ {
+ .name = "kb_base",
+ .type = FIO_OPT_INT,
+ .off1 = td_var_offset(kb_base),
+ .verify = kb_base_verify,
+ .prio = 1,
+ .def = "1024",
+ .help = "How many bytes per KB for reporting (1000 or 1024)",
+ },
+ {
+ .name = "lockfile",
+ .type = FIO_OPT_STR,
+ .cb = str_lockfile_cb,
+ .off1 = td_var_offset(file_lock_mode),
+ .help = "Lock file when doing IO to it",
+ .parent = "filename",
+ .def = "none",
+ .posval = {
+ { .ival = "none",
+ .oval = FILE_LOCK_NONE,
+ .help = "No file locking",
+ },
+ { .ival = "exclusive",
+ .oval = FILE_LOCK_EXCLUSIVE,
+ .help = "Exclusive file lock",
+ },
+ {
+ .ival = "readwrite",
+ .oval = FILE_LOCK_READWRITE,
+ .help = "Read vs write lock",
+ },
+ },
+ },
+ {
+ .name = "opendir",
+ .type = FIO_OPT_STR_STORE,
+ .off1 = td_var_offset(opendir),
+ .cb = str_opendir_cb,
+ .help = "Recursively add files from this directory and down",
+ },
+ {
+ .name = "rw",
+ .alias = "readwrite",
+ .type = FIO_OPT_STR,
+ .cb = str_rw_cb,
+ .off1 = td_var_offset(td_ddir),
+ .help = "IO direction",
+ .def = "read",
+ .verify = rw_verify,
+ .posval = {
+ { .ival = "read",
+ .oval = TD_DDIR_READ,
+ .help = "Sequential read",
+ },
+ { .ival = "write",
+ .oval = TD_DDIR_WRITE,
+ .help = "Sequential write",
+ },
+ { .ival = "randread",