fio: create over-arching data placement option
authorVincent Fu <vincent.fu@samsung.com>
Wed, 3 Jan 2024 20:16:19 +0000 (20:16 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 24 Apr 2024 17:44:09 +0000 (13:44 -0400)
Since FDP and streams are similar, we should have an over-arching data
placement option that encompasses both of these frameworks instead of
having separate sets of similar options for FDP and streams.

With a common set of options, users will be able to select the data
placement strategy (fdp or streams), the placement identifiers to use,
and the algorithm for selecting from the list of placement identifiers.

The original set of FDP options is retained for backward compatibility.

No functional change.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
cconv.c
dataplacement.c
dataplacement.h
filesetup.c
init.c
io_u.c
options.c
server.h
thread_options.h

diff --git a/cconv.c b/cconv.c
index ead472480b9a2aa24793802d80542e241e462b92..16112248a6b71016c2542a5097ca35750f9a470b 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -354,10 +354,11 @@ int convert_thread_options_to_cpu(struct thread_options *o,
                o->merge_blktrace_iters[i].u.f = fio_uint64_to_double(le64_to_cpu(top->merge_blktrace_iters[i].u.i));
 
        o->fdp = le32_to_cpu(top->fdp);
-       o->fdp_pli_select = le32_to_cpu(top->fdp_pli_select);
-       o->fdp_nrpli = le32_to_cpu(top->fdp_nrpli);
-       for (i = 0; i < o->fdp_nrpli; i++)
-               o->fdp_plis[i] = le32_to_cpu(top->fdp_plis[i]);
+       o->dp_type = le32_to_cpu(top->dp_type);
+       o->dp_id_select = le32_to_cpu(top->dp_id_select);
+       o->dp_nr_ids = le32_to_cpu(top->dp_nr_ids);
+       for (i = 0; i < o->dp_nr_ids; i++)
+               o->dp_ids[i] = le32_to_cpu(top->dp_ids[i]);
 #if 0
        uint8_t cpumask[FIO_TOP_STR_MAX];
        uint8_t verify_cpumask[FIO_TOP_STR_MAX];
@@ -652,10 +653,11 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
                top->merge_blktrace_iters[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->merge_blktrace_iters[i].u.f));
 
        top->fdp = cpu_to_le32(o->fdp);
-       top->fdp_pli_select = cpu_to_le32(o->fdp_pli_select);
-       top->fdp_nrpli = cpu_to_le32(o->fdp_nrpli);
-       for (i = 0; i < o->fdp_nrpli; i++)
-               top->fdp_plis[i] = cpu_to_le32(o->fdp_plis[i]);
+       top->dp_type = cpu_to_le32(o->dp_type);
+       top->dp_id_select = cpu_to_le32(o->dp_id_select);
+       top->dp_nr_ids = cpu_to_le32(o->dp_nr_ids);
+       for (i = 0; i < o->dp_nr_ids; i++)
+               top->dp_ids[i] = cpu_to_le32(o->dp_ids[i]);
 #if 0
        uint8_t cpumask[FIO_TOP_STR_MAX];
        uint8_t verify_cpumask[FIO_TOP_STR_MAX];
index 7518d193073ae7ad47f9e003caa738f2f76b4aeb..a7170863937c7a914c90af23dc6fff3668bff592 100644 (file)
@@ -59,13 +59,13 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)
        if (ruhs->nr_ruhs > FDP_MAX_RUHS)
                ruhs->nr_ruhs = FDP_MAX_RUHS;
 
-       if (td->o.fdp_nrpli == 0) {
+       if (td->o.dp_nr_ids == 0) {
                f->ruhs_info = ruhs;
                return 0;
        }
 
-       for (i = 0; i < td->o.fdp_nrpli; i++) {
-               if (td->o.fdp_plis[i] >= ruhs->nr_ruhs) {
+       for (i = 0; i < td->o.dp_nr_ids; i++) {
+               if (td->o.dp_ids[i] >= ruhs->nr_ruhs) {
                        ret = -EINVAL;
                        goto out;
                }
@@ -77,9 +77,9 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)
                goto out;
        }
 
-       tmp->nr_ruhs = td->o.fdp_nrpli;
-       for (i = 0; i < td->o.fdp_nrpli; i++)
-               tmp->plis[i] = ruhs->plis[td->o.fdp_plis[i]];
+       tmp->nr_ruhs = td->o.dp_nr_ids;
+       for (i = 0; i < td->o.dp_nr_ids; i++)
+               tmp->plis[i] = ruhs->plis[td->o.dp_ids[i]];
        f->ruhs_info = tmp;
 out:
        sfree(ruhs);
@@ -119,7 +119,7 @@ void dp_fill_dspec_data(struct thread_data *td, struct io_u *io_u)
                return;
        }
 
-       if (td->o.fdp_pli_select == FIO_FDP_RR) {
+       if (td->o.dp_id_select == FIO_DP_RR) {
                if (ruhs->pli_loc >= ruhs->nr_ruhs)
                        ruhs->pli_loc = 0;
 
index 72bd4c08920db1e0a6d675727e888ad2d5ac3e23..b6ceb5bcefb6cef92f39890b5bbdc998c4ee165e 100644 (file)
@@ -5,15 +5,22 @@
 
 #define FDP_DIR_DTYPE  2
 #define FDP_MAX_RUHS   128
+#define FIO_MAX_DP_IDS         16
 
 /*
  * How fio chooses what placement identifier to use next. Choice of
  * uniformly random, or roundrobin.
  */
+enum {
+       FIO_DP_RANDOM   = 0x1,
+       FIO_DP_RR       = 0x2,
+};
+
 
 enum {
-       FIO_FDP_RANDOM  = 0x1,
-       FIO_FDP_RR      = 0x2,
+       FIO_DP_NONE     = 0x0,
+       FIO_DP_FDP      = 0x1,
+       FIO_DP_STREAMS  = 0x2,
 };
 
 struct fio_ruhs_info {
index 8923f2b3eaf53c39771fe8a901dd63839b66b1fa..6fbfced57455bc3e8856c23d57bcd18effc909fb 100644 (file)
@@ -1411,7 +1411,7 @@ done:
 
        td_restore_runstate(td, old_state);
 
-       if (td->o.fdp) {
+       if (td->o.dp_type == FIO_DP_FDP) {
                err = dp_init(td);
                if (err)
                        goto err_out;
diff --git a/init.c b/init.c
index 7a0b14a3d2f5031516db14ab583952de77439a13..ff3e9a90d551500b3880df95c2505e3a7df9e684 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1015,7 +1015,15 @@ static int fixup_options(struct thread_data *td)
                ret |= 1;
        }
 
-
+       if (td->o.fdp) {
+               if (fio_option_is_set(&td->o, dp_type) &&
+                       (td->o.dp_type == FIO_DP_STREAMS || td->o.dp_type == FIO_DP_NONE)) {
+                       log_err("fio: fdp=1 is not compatible with dataplacement={streams, none}\n");
+                       ret |= 1;
+               } else {
+                       td->o.dp_type = FIO_DP_FDP;
+               }
+       }
        return ret;
 }
 
diff --git a/io_u.c b/io_u.c
index 89f3d7892eb4c7ebfbfc5f17d371496b3b34928a..86ad74245a5e72a333e3c330c06ecdf42d314c64 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1065,7 +1065,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
                }
        }
 
-       if (td->o.fdp)
+       if (td->o.dp_type == FIO_DP_FDP)
                dp_fill_dspec_data(td, io_u);
 
        if (io_u->offset + io_u->buflen > io_u->file->real_file_size) {
index de935efcb671fe3cd25b4002bed64532783d1b00..7e589299d34a990ba0c8b510f5f4b5ee25d5ac3a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -270,12 +270,12 @@ static int str_fdp_pli_cb(void *data, const char *input)
        strip_blank_front(&str);
        strip_blank_end(str);
 
-       while ((v = strsep(&str, ",")) != NULL && i < FIO_MAX_PLIS)
-               td->o.fdp_plis[i++] = strtoll(v, NULL, 0);
+       while ((v = strsep(&str, ",")) != NULL && i < FIO_MAX_DP_IDS)
+               td->o.dp_ids[i++] = strtoll(v, NULL, 0);
        free(p);
 
-       qsort(td->o.fdp_plis, i, sizeof(*td->o.fdp_plis), fio_fdp_cmp);
-       td->o.fdp_nrpli = i;
+       qsort(td->o.dp_ids, i, sizeof(*td->o.dp_ids), fio_fdp_cmp);
+       td->o.dp_nr_ids = i;
 
        return 0;
 }
@@ -3710,32 +3710,59 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .group  = FIO_OPT_G_INVALID,
        },
        {
-               .name   = "fdp_pli_select",
-               .lname  = "FDP Placement ID select",
+               .name   = "dataplacement",
+               .alias  = "data_placement",
+               .lname  = "Data Placement interface",
                .type   = FIO_OPT_STR,
-               .off1   = offsetof(struct thread_options, fdp_pli_select),
-               .help   = "Select which FDP placement ID to use next",
+               .off1   = offsetof(struct thread_options, dp_type),
+               .help   = "Data Placement interface to use",
+               .def    = "none",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_INVALID,
+               .posval = {
+                         { .ival = "none",
+                           .oval = FIO_DP_NONE,
+                           .help = "Do not specify a data placement interface",
+                         },
+                         { .ival = "fdp",
+                           .oval = FIO_DP_FDP,
+                           .help = "Use Flexible Data Placement interface",
+                         },
+                         { .ival = "streams",
+                           .oval = FIO_DP_STREAMS,
+                           .help = "Use Streams interface",
+                         },
+               },
+       },
+       {
+               .name   = "plid_select",
+               .alias  = "fdp_pli_select",
+               .lname  = "Data Placement ID selection strategy",
+               .type   = FIO_OPT_STR,
+               .off1   = offsetof(struct thread_options, dp_id_select),
+               .help   = "Strategy for selecting next Data Placement ID",
                .def    = "roundrobin",
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_INVALID,
                .posval = {
                          { .ival = "random",
-                           .oval = FIO_FDP_RANDOM,
+                           .oval = FIO_DP_RANDOM,
                            .help = "Choose a Placement ID at random (uniform)",
                          },
                          { .ival = "roundrobin",
-                           .oval = FIO_FDP_RR,
+                           .oval = FIO_DP_RR,
                            .help = "Round robin select Placement IDs",
                          },
                },
        },
        {
-               .name   = "fdp_pli",
-               .lname  = "FDP Placement ID indicies",
+               .name   = "plids",
+               .alias  = "fdp_pli",
+               .lname  = "Stream IDs/Data Placement ID indices",
                .type   = FIO_OPT_STR,
                .cb     = str_fdp_pli_cb,
-               .off1   = offsetof(struct thread_options, fdp_plis),
-               .help   = "Sets which placement ids to use (defaults to all)",
+               .off1   = offsetof(struct thread_options, dp_ids),
+               .help   = "Sets which Data Placement ids to use (defaults to all for FDP)",
                .hide   = 1,
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_INVALID,
index 6d2659b05a25c144522606feac9b40e925731c04..83ce449ba0e77034de3bf2f0ef9897ec81ff5f86 100644 (file)
--- a/server.h
+++ b/server.h
@@ -51,7 +51,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
-       FIO_SERVER_VER                  = 103,
+       FIO_SERVER_VER                  = 104,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
        FIO_SERVER_MAX_CMD_MB           = 2048,
index c2e71518b37471b2533ce8678580fcc02a016e5c..a36b79094f26a77afdfe327b85182f601cd09c31 100644 (file)
@@ -391,11 +391,11 @@ struct thread_options {
        fio_fp64_t zrt;
        fio_fp64_t zrf;
 
-#define FIO_MAX_PLIS 16
        unsigned int fdp;
-       unsigned int fdp_pli_select;
-       unsigned int fdp_plis[FIO_MAX_PLIS];
-       unsigned int fdp_nrpli;
+       unsigned int dp_type;
+       unsigned int dp_id_select;
+       unsigned int dp_ids[FIO_MAX_DP_IDS];
+       unsigned int dp_nr_ids;
 
        unsigned int log_entries;
        unsigned int log_prio;
@@ -709,9 +709,10 @@ struct thread_options_pack {
        uint32_t log_prio;
 
        uint32_t fdp;
-       uint32_t fdp_pli_select;
-       uint32_t fdp_plis[FIO_MAX_PLIS];
-       uint32_t fdp_nrpli;
+       uint32_t dp_type;
+       uint32_t dp_id_select;
+       uint32_t dp_ids[FIO_MAX_DP_IDS];
+       uint32_t dp_nr_ids;
 
        uint32_t num_range;
        /*