options: use fio_option_is_set() to detect verify setting
[fio.git] / options.c
index e0b7ff23a93dfb3149c7466a5eb7235882ac6a2b..e3b93383cfb529cea6eb4d5ad9b439e0d8821938 100644 (file)
--- a/options.c
+++ b/options.c
@@ -8,6 +8,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <netinet/in.h>
 
 #include "fio.h"
 #include "verify.h"
@@ -17,6 +18,8 @@
 
 #include "crc/crc32c.h"
 
+char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
+
 /*
  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
  */
@@ -443,9 +446,9 @@ static int str_cpumask_cb(void *data, unsigned long long *val)
 
        for (i = 0; i < sizeof(int) * 8; i++) {
                if ((1 << i) & *val) {
-                       if (i > max_cpu) {
+                       if (i >= max_cpu) {
                                log_err("fio: CPU %d too large (max=%ld)\n", i,
-                                                               max_cpu);
+                                                               max_cpu - 1);
                                return 1;
                        }
                        dprint(FD_PARSE, "set cpu allowed %d\n", i);
@@ -503,9 +506,9 @@ static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
                                ret = 1;
                                break;
                        }
-                       if (icpu > max_cpu) {
+                       if (icpu >= max_cpu) {
                                log_err("fio: CPU %d too large (max=%ld)\n",
-                                                       icpu, max_cpu);
+                                                       icpu, max_cpu - 1);
                                ret = 1;
                                break;
                        }
@@ -820,7 +823,7 @@ static int get_max_name_idx(char *input)
  * Returns the directory at the index, indexes > entires will be
  * assigned via modulo division of the index
  */
-int set_name_idx(char *target, char *input, int index)
+int set_name_idx(char *target, size_t tlen, char *input, int index)
 {
        unsigned int cur_idx;
        int len;
@@ -832,7 +835,13 @@ int set_name_idx(char *target, char *input, int index)
        for (cur_idx = 0; cur_idx <= index; cur_idx++)
                fname = get_next_name(&str);
 
-       len = sprintf(target, "%s/", fname);
+       if (client_sockaddr_str[0]) {
+               len = snprintf(target, tlen, "%s/%s.", fname,
+                               client_sockaddr_str);
+       } else
+               len = snprintf(target, tlen, "%s/", fname);
+
+       target[tlen - 1] = '\0';
        free(p);
 
        return len;
@@ -974,6 +983,8 @@ static int pattern_cb(char *pattern, unsigned int max_size,
         */
 fill:
        pattern_length = i;
+       if (!i && !off)
+               i = 1;
        while (i > 1 && i * 2 <= max_size) {
                memcpy(&pattern[i], &pattern[0], i);
                i *= 2;
@@ -1053,7 +1064,7 @@ static int str_verify_pattern_cb(void *data, const char *input)
        /*
         * VERIFY_META could already be set
         */
-       if (!ret && td->o.verify == VERIFY_NONE)
+       if (!ret && !fio_option_is_set(&td->o, verify))
                td->o.verify = VERIFY_PATTERN;
 
        return ret;
@@ -1265,6 +1276,10 @@ static struct opt_group fio_opt_cat_groups[] = {
                .name   = "Tiobench profile",
                .mask   = FIO_OPT_G_TIOBENCH,
        },
+       {
+               .name   = "MTD",
+               .mask   = FIO_OPT_G_MTD,
+       },
 
        {
                .name   = NULL,
@@ -1416,9 +1431,9 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = TD_DDIR_RANDRW,
                            .help = "Random read and write mix"
                          },
-                         { .ival = "writetrim",
-                           .oval = TD_DDIR_WRITETRIM,
-                           .help = "Write and trim mix, trims preceding writes"
+                         { .ival = "trimwrite",
+                           .oval = TD_DDIR_TRIMWRITE,
+                           .help = "Trim and write mix, trims preceding writes"
                          },
                },
        },
@@ -1618,6 +1633,26 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_IO_BASIC,
        },
+       {
+               .name   = "io_submit_mode",
+               .lname  = "IO submit mode",
+               .type   = FIO_OPT_STR,
+               .off1   = td_var_offset(io_submit_mode),
+               .help   = "How IO submissions and completions are done",
+               .def    = "inline",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_IO_BASIC,
+               .posval = {
+                         { .ival = "inline",
+                           .oval = IO_MODE_INLINE,
+                           .help = "Submit and complete IO inline",
+                         },
+                         { .ival = "offload",
+                           .oval = IO_MODE_OFFLOAD,
+                           .help = "Offload submit and complete to threads",
+                         },
+               },
+       },
        {
                .name   = "size",
                .lname  = "Size",
@@ -1812,6 +1847,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .type   = FIO_OPT_STR_VAL,
                .off1   = td_var_offset(rand_seed),
                .help   = "Set the random generator seed value",
+               .def    = "0x89",
                .parent = "rw",
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_RANDOM,
@@ -1863,6 +1899,11 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = FIO_RAND_GEN_LFSR,
                            .help = "Variable length LFSR",
                          },
+                         {
+                           .ival = "tausworthe64",
+                           .oval = FIO_RAND_GEN_TAUSWORTHE64,
+                           .help = "64-bit Tausworthe variant",
+                         },
                },
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_RANDOM,
@@ -2361,6 +2402,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = VERIFY_META,
                            .help = "Use io information",
                          },
+                         { .ival = "pattern",
+                           .oval = VERIFY_PATTERN_NO_HDR,
+                           .help = "Verify strict pattern",
+                         },
                          {
                            .ival = "null",
                            .oval = VERIFY_NULL,
@@ -2637,6 +2682,28 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_IOLOG,
        },
+       {
+               .name   = "replay_scale",
+               .lname  = "Replace offset scale factor",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(replay_scale),
+               .parent = "read_iolog",
+               .def    = "1",
+               .help   = "Align offsets to this blocksize",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_IOLOG,
+       },
+       {
+               .name   = "replay_align",
+               .lname  = "Replace alignment",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(replay_align),
+               .parent = "read_iolog",
+               .help   = "Scale offset down by this factor",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_IOLOG,
+               .pow2   = 1,
+       },
        {
                .name   = "exec_prerun",
                .lname  = "Pre-execute runnable",
@@ -2983,6 +3050,26 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_FILE,
                .def    = "0",
        },
+       {
+               .name   = "allow_file_create",
+               .lname  = "Allow file create",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(allow_create),
+               .help   = "Permit fio to create files, if they don't exist",
+               .def    = "1",
+               .category = FIO_OPT_C_FILE,
+               .group  = FIO_OPT_G_FILENAME,
+       },
+       {
+               .name   = "allow_mounted_write",
+               .lname  = "Allow mounted write",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(allow_mounted_write),
+               .help   = "Allow writes to a mounted partition",
+               .def    = "0",
+               .category = FIO_OPT_C_FILE,
+               .group  = FIO_OPT_G_FILENAME,
+       },
        {
                .name   = "pre_read",
                .lname  = "Pre-read files",
@@ -3127,6 +3214,15 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_GENERAL,
                .group  = FIO_OPT_G_PROCESS,
        },
+       {
+               .name   = "per_job_logs",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(per_job_logs),
+               .help   = "Include job number in generated log files or not",
+               .def    = "1",
+               .category = FIO_OPT_C_LOG,
+               .group  = FIO_OPT_G_INVALID,
+       },
        {
                .name   = "write_bw_log",
                .lname  = "Write bandwidth log",
@@ -3661,6 +3757,17 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_IO_FLOW,
        },
+       {
+               .name   = "skip_bad",
+               .lname  = "Skip operations against bad blocks",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(skip_bad),
+               .help   = "Skip operations against known bad blocks.",
+               .hide   = 1,
+               .def    = "0",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_MTD,
+       },
        {
                .name = NULL,
        },
@@ -3756,6 +3863,18 @@ static struct fio_keyword fio_keywords[] = {
        },
 };
 
+void fio_keywords_exit(void)
+{
+       struct fio_keyword *kw;
+
+       kw = &fio_keywords[0];
+       while (kw->word) {
+               free(kw->replace);
+               kw->replace = NULL;
+               kw++;
+       }
+}
+
 void fio_keywords_init(void)
 {
        unsigned long long mb_memory;