fio: fix interaction between offset/size limited threads and "max_open_zones"
[fio.git] / options.c
index 98187def98fbe842e90ae6d4a85a9fb3f358fd10..4714a3a1e57f7fe0767fe2caf1437457573c88b9 100644 (file)
--- a/options.c
+++ b/options.c
@@ -493,6 +493,9 @@ int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
        const long max_cpu = cpus_online();
 
        cpus_in_mask = fio_cpu_count(mask);
+       if (!cpus_in_mask)
+               return 0;
+
        cpu_index = cpu_index % cpus_in_mask;
 
        index = 0;
@@ -1232,7 +1235,8 @@ int set_name_idx(char *target, size_t tlen, char *input, int index,
                len = snprintf(target, tlen, "%s/%s.", fname,
                                client_sockaddr_str);
        } else
-               len = snprintf(target, tlen, "%s/", fname);
+               len = snprintf(target, tlen, "%s%c", fname,
+                               FIO_OS_PATH_SEPARATOR);
 
        target[tlen - 1] = '\0';
        free(p);
@@ -1404,13 +1408,20 @@ static int str_gtod_reduce_cb(void *data, int *il)
        struct thread_data *td = cb_data_to_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)
+       /*
+        * Only modfiy options if gtod_reduce==1
+        * Otherwise leave settings alone.
+        */
+       if (val) {
+               td->o.disable_lat = 1;
+               td->o.disable_clat = 1;
+               td->o.disable_slat = 1;
+               td->o.disable_bw = 1;
+               td->o.clat_percentiles = 0;
+               td->o.lat_percentiles = 0;
+               td->o.slat_percentiles = 0;
                td->ts_cache_mask = 63;
+       }
 
        return 0;
 }
@@ -1431,6 +1442,22 @@ static int str_offset_cb(void *data, unsigned long long *__val)
        return 0;
 }
 
+static int str_offset_increment_cb(void *data, unsigned long long *__val)
+{
+       struct thread_data *td = cb_data_to_td(data);
+       unsigned long long v = *__val;
+
+       if (parse_is_percent(v)) {
+               td->o.offset_increment = 0;
+               td->o.offset_increment_percent = -1ULL - v;
+               dprint(FD_PARSE, "SET offset_increment_percent %d\n",
+                                       td->o.offset_increment_percent);
+       } else
+               td->o.offset_increment = v;
+
+       return 0;
+}
+
 static int str_size_cb(void *data, unsigned long long *__val)
 {
        struct thread_data *td = cb_data_to_td(data);
@@ -1773,6 +1800,11 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .help = "Linux native asynchronous IO",
                          },
 #endif
+#ifdef ARCH_HAVE_IOURING
+                         { .ival = "io_uring",
+                           .help = "Fast Linux native aio",
+                         },
+#endif
 #ifdef CONFIG_POSIXAIO
                          { .ival = "posixaio",
                            .help = "POSIX asynchronous IO",
@@ -1891,6 +1923,9 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .help = "HTTP (WebDAV/S3) IO engine",
                          },
 #endif
+                         { .ival = "nbd",
+                           .help = "Network Block Device (NBD) IO engine"
+                         },
                },
        },
        {
@@ -2073,6 +2108,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .name   = "offset_increment",
                .lname  = "IO offset increment",
                .type   = FIO_OPT_STR_VAL,
+               .cb     = str_offset_increment_cb,
                .off1   = offsetof(struct thread_options, offset_increment),
                .help   = "What is the increment from one offset to the next",
                .parent = "offset",
@@ -2384,14 +2420,17 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .parent = "nrfiles",
                .hide   = 1,
        },
-#ifdef FIO_HAVE_ANY_FALLOCATE
        {
                .name   = "fallocate",
                .lname  = "Fallocate",
                .type   = FIO_OPT_STR,
                .off1   = offsetof(struct thread_options, fallocate_mode),
                .help   = "Whether pre-allocation is performed when laying out files",
+#ifdef FIO_HAVE_DEFAULT_FALLOCATE
                .def    = "native",
+#else
+               .def    = "none",
+#endif
                .category = FIO_OPT_C_FILE,
                .group  = FIO_OPT_G_INVALID,
                .posval = {
@@ -2415,6 +2454,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
                          },
 #endif
+                         { .ival = "truncate",
+                           .oval = FIO_FALLOCATE_TRUNCATE,
+                           .help = "Truncate file to final size instead of allocating"
+                         },
                          /* Compatibility with former boolean values */
                          { .ival = "0",
                            .oval = FIO_FALLOCATE_NONE,
@@ -2428,14 +2471,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
 #endif
                },
        },
-#else  /* FIO_HAVE_ANY_FALLOCATE */
-       {
-               .name   = "fallocate",
-               .lname  = "Fallocate",
-               .type   = FIO_OPT_UNSUPPORTED,
-               .help   = "Your platform does not support fallocate",
-       },
-#endif /* FIO_HAVE_ANY_FALLOCATE */
        {
                .name   = "fadvise_hint",
                .lname  = "Fadvise hint",
@@ -3913,6 +3948,30 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_GENERAL,
                .group  = FIO_OPT_G_PROCESS,
        },
+       {
+               .name   = "exit_what",
+               .lname  = "What jobs to quit on terminate",
+               .type   = FIO_OPT_STR,
+               .off1   = offsetof(struct thread_options, exit_what),
+               .help   = "Fine-grained control for exitall",
+               .def    = "group",
+               .category = FIO_OPT_C_GENERAL,
+               .group  = FIO_OPT_G_PROCESS,
+               .posval = {
+                         { .ival = "group",
+                           .oval = TERMINATE_GROUP,
+                           .help = "exit_all=1 default behaviour",
+                         },
+                         { .ival = "stonewall",
+                           .oval = TERMINATE_STONEWALL,
+                           .help = "quit all currently running jobs; continue with next stonewall",
+                         },
+                         { .ival = "all",
+                           .oval = TERMINATE_ALL,
+                           .help = "Quit everything",
+                         },
+               },
+       },
        {
                .name   = "exitall_on_error",
                .lname  = "Exit-all on terminate in error",
@@ -4260,7 +4319,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .off1   = offsetof(struct thread_options, clat_percentiles),
                .help   = "Enable the reporting of completion latency percentiles",
                .def    = "1",
-               .inverse = "lat_percentiles",
                .category = FIO_OPT_C_STAT,
                .group  = FIO_OPT_G_INVALID,
        },
@@ -4271,7 +4329,16 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .off1   = offsetof(struct thread_options, lat_percentiles),
                .help   = "Enable the reporting of IO latency percentiles",
                .def    = "0",
-               .inverse = "clat_percentiles",
+               .category = FIO_OPT_C_STAT,
+               .group  = FIO_OPT_G_INVALID,
+       },
+       {
+               .name   = "slat_percentiles",
+               .lname  = "Submission latency percentiles",
+               .type   = FIO_OPT_BOOL,
+               .off1   = offsetof(struct thread_options, slat_percentiles),
+               .help   = "Enable the reporting of submission latency percentiles",
+               .def    = "0",
                .category = FIO_OPT_C_STAT,
                .group  = FIO_OPT_G_INVALID,
        },
@@ -4530,7 +4597,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
        {
                .name   = "kb_base",
                .lname  = "KB Base",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_STR,
                .off1   = offsetof(struct thread_options, kb_base),
                .prio   = 1,
                .def    = "1024",
@@ -4551,7 +4618,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
        {
                .name   = "unit_base",
                .lname  = "Unit for quantities of data (Bits or Bytes)",
-               .type   = FIO_OPT_INT,
+               .type   = FIO_OPT_STR,
                .off1   = offsetof(struct thread_options, unit_base),
                .prio   = 1,
                .posval = {
@@ -4891,8 +4958,7 @@ char *fio_option_dup_subs(const char *opt)
                return NULL;
        }
 
-       in[OPT_LEN_MAX] = '\0';
-       strncpy(in, opt, OPT_LEN_MAX);
+       snprintf(in, sizeof(in), "%s", opt);
 
        while (*inptr && nchr > 0) {
                if (inptr[0] == '$' && inptr[1] == '{') {