fio: rename fdp.[c,h] to dataplacement.[c,h]
authorVincent Fu <vincent.fu@samsung.com>
Thu, 18 Apr 2024 17:55:27 +0000 (17:55 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 24 Apr 2024 17:44:09 +0000 (13:44 -0400)
We can use code in the files to support NVMe streams.  Streams also
falls under the umbrella of data placement, so it seems reasonable to
put streams and FDP code in the same source files.

Also change the prefix of some functions from fdp_ to dp_ to indicate
that they are not specific to FDP but apply more generally to the two
data placement features.

No functional change.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
Makefile
dataplacement.c [new file with mode: 0644]
dataplacement.h [new file with mode: 0644]
engines/xnvme.c
fdp.c [deleted file]
fdp.h [deleted file]
filesetup.c
io_u.c
ioengines.h

index cc8164b27d56766d48de8c22c8860df10dba2f62..be57e296516d096c1e7a389d1a7d5f1362ddd953 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ SOURCE :=     $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
                gettime-thread.c helpers.c json.c idletime.c td_error.c \
                profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
                workqueue.c rate-submit.c optgroup.c helper_thread.c \
-               steadystate.c zone-dist.c zbd.c dedupe.c fdp.c
+               steadystate.c zone-dist.c zbd.c dedupe.c dataplacement.c
 
 ifdef CONFIG_LIBHDFS
   HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
diff --git a/dataplacement.c b/dataplacement.c
new file mode 100644 (file)
index 0000000..7518d19
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Note: This is similar to a very basic setup
+ * of ZBD devices
+ *
+ * Specify fdp=1 (With char devices /dev/ng0n1)
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "fio.h"
+#include "file.h"
+
+#include "pshared.h"
+#include "dataplacement.h"
+
+static int fdp_ruh_info(struct thread_data *td, struct fio_file *f,
+                       struct fio_ruhs_info *ruhs)
+{
+       int ret = -EINVAL;
+
+       if (!td->io_ops) {
+               log_err("fio: no ops set in fdp init?!\n");
+               return ret;
+       }
+
+       if (td->io_ops->fdp_fetch_ruhs) {
+               ret = td->io_ops->fdp_fetch_ruhs(td, f, ruhs);
+               if (ret < 0) {
+                       td_verror(td, errno, "fdp fetch ruhs failed");
+                       log_err("%s: fdp fetch ruhs failed (%d)\n",
+                               f->file_name, errno);
+               }
+       } else {
+               log_err("%s: engine (%s) lacks fetch ruhs\n",
+                       f->file_name, td->io_ops->name);
+       }
+
+       return ret;
+}
+
+static int init_ruh_info(struct thread_data *td, struct fio_file *f)
+{
+       struct fio_ruhs_info *ruhs, *tmp;
+       int i, ret;
+
+       ruhs = scalloc(1, sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(*ruhs->plis));
+       if (!ruhs)
+               return -ENOMEM;
+
+       ret = fdp_ruh_info(td, f, ruhs);
+       if (ret) {
+               log_info("fio: ruh info failed for %s (%d)\n",
+                        f->file_name, -ret);
+               goto out;
+       }
+
+       if (ruhs->nr_ruhs > FDP_MAX_RUHS)
+               ruhs->nr_ruhs = FDP_MAX_RUHS;
+
+       if (td->o.fdp_nrpli == 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) {
+                       ret = -EINVAL;
+                       goto out;
+               }
+       }
+
+       tmp = scalloc(1, sizeof(*tmp) + ruhs->nr_ruhs * sizeof(*tmp->plis));
+       if (!tmp) {
+               ret = -ENOMEM;
+               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]];
+       f->ruhs_info = tmp;
+out:
+       sfree(ruhs);
+       return ret;
+}
+
+int dp_init(struct thread_data *td)
+{
+       struct fio_file *f;
+       int i, ret = 0;
+
+       for_each_file(td, f, i) {
+               ret = init_ruh_info(td, f);
+               if (ret)
+                       break;
+       }
+       return ret;
+}
+
+void fdp_free_ruhs_info(struct fio_file *f)
+{
+       if (!f->ruhs_info)
+               return;
+       sfree(f->ruhs_info);
+       f->ruhs_info = NULL;
+}
+
+void dp_fill_dspec_data(struct thread_data *td, struct io_u *io_u)
+{
+       struct fio_file *f = io_u->file;
+       struct fio_ruhs_info *ruhs = f->ruhs_info;
+       int dspec;
+
+       if (!ruhs || io_u->ddir != DDIR_WRITE) {
+               io_u->dtype = 0;
+               io_u->dspec = 0;
+               return;
+       }
+
+       if (td->o.fdp_pli_select == FIO_FDP_RR) {
+               if (ruhs->pli_loc >= ruhs->nr_ruhs)
+                       ruhs->pli_loc = 0;
+
+               dspec = ruhs->plis[ruhs->pli_loc++];
+       } else {
+               ruhs->pli_loc = rand_between(&td->fdp_state, 0, ruhs->nr_ruhs - 1);
+               dspec = ruhs->plis[ruhs->pli_loc];
+       }
+
+       io_u->dtype = FDP_DIR_DTYPE;
+       io_u->dspec = dspec;
+}
diff --git a/dataplacement.h b/dataplacement.h
new file mode 100644 (file)
index 0000000..72bd4c0
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef FIO_DATAPLACEMENT_H
+#define FIO_DATAPLACEMENT_H
+
+#include "io_u.h"
+
+#define FDP_DIR_DTYPE  2
+#define FDP_MAX_RUHS   128
+
+/*
+ * How fio chooses what placement identifier to use next. Choice of
+ * uniformly random, or roundrobin.
+ */
+
+enum {
+       FIO_FDP_RANDOM  = 0x1,
+       FIO_FDP_RR      = 0x2,
+};
+
+struct fio_ruhs_info {
+       uint32_t nr_ruhs;
+       uint32_t pli_loc;
+       uint16_t plis[];
+};
+
+int dp_init(struct thread_data *td);
+void fdp_free_ruhs_info(struct fio_file *f);
+void dp_fill_dspec_data(struct thread_data *td, struct io_u *io_u);
+
+#endif /* FIO_DATAPLACEMENT_H */
index a8137286841cdbcb0a0e02a6741d5d3712c8f081..6ba4aa467d5501408c52604ddf7daa55e6d3fc10 100644 (file)
@@ -13,7 +13,7 @@
 #include "fio.h"
 #include "verify.h"
 #include "zbd_types.h"
-#include "fdp.h"
+#include "dataplacement.h"
 #include "optgroup.h"
 
 static pthread_mutex_t g_serialize = PTHREAD_MUTEX_INITIALIZER;
diff --git a/fdp.c b/fdp.c
deleted file mode 100644 (file)
index 49c80d2..0000000
--- a/fdp.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Note: This is similar to a very basic setup
- * of ZBD devices
- *
- * Specify fdp=1 (With char devices /dev/ng0n1)
- */
-
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "fio.h"
-#include "file.h"
-
-#include "pshared.h"
-#include "fdp.h"
-
-static int fdp_ruh_info(struct thread_data *td, struct fio_file *f,
-                       struct fio_ruhs_info *ruhs)
-{
-       int ret = -EINVAL;
-
-       if (!td->io_ops) {
-               log_err("fio: no ops set in fdp init?!\n");
-               return ret;
-       }
-
-       if (td->io_ops->fdp_fetch_ruhs) {
-               ret = td->io_ops->fdp_fetch_ruhs(td, f, ruhs);
-               if (ret < 0) {
-                       td_verror(td, errno, "fdp fetch ruhs failed");
-                       log_err("%s: fdp fetch ruhs failed (%d)\n",
-                               f->file_name, errno);
-               }
-       } else {
-               log_err("%s: engine (%s) lacks fetch ruhs\n",
-                       f->file_name, td->io_ops->name);
-       }
-
-       return ret;
-}
-
-static int init_ruh_info(struct thread_data *td, struct fio_file *f)
-{
-       struct fio_ruhs_info *ruhs, *tmp;
-       int i, ret;
-
-       ruhs = scalloc(1, sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(*ruhs->plis));
-       if (!ruhs)
-               return -ENOMEM;
-
-       ret = fdp_ruh_info(td, f, ruhs);
-       if (ret) {
-               log_info("fio: ruh info failed for %s (%d)\n",
-                        f->file_name, -ret);
-               goto out;
-       }
-
-       if (ruhs->nr_ruhs > FDP_MAX_RUHS)
-               ruhs->nr_ruhs = FDP_MAX_RUHS;
-
-       if (td->o.fdp_nrpli == 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) {
-                       ret = -EINVAL;
-                       goto out;
-               }
-       }
-
-       tmp = scalloc(1, sizeof(*tmp) + ruhs->nr_ruhs * sizeof(*tmp->plis));
-       if (!tmp) {
-               ret = -ENOMEM;
-               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]];
-       f->ruhs_info = tmp;
-out:
-       sfree(ruhs);
-       return ret;
-}
-
-int fdp_init(struct thread_data *td)
-{
-       struct fio_file *f;
-       int i, ret = 0;
-
-       for_each_file(td, f, i) {
-               ret = init_ruh_info(td, f);
-               if (ret)
-                       break;
-       }
-       return ret;
-}
-
-void fdp_free_ruhs_info(struct fio_file *f)
-{
-       if (!f->ruhs_info)
-               return;
-       sfree(f->ruhs_info);
-       f->ruhs_info = NULL;
-}
-
-void fdp_fill_dspec_data(struct thread_data *td, struct io_u *io_u)
-{
-       struct fio_file *f = io_u->file;
-       struct fio_ruhs_info *ruhs = f->ruhs_info;
-       int dspec;
-
-       if (!ruhs || io_u->ddir != DDIR_WRITE) {
-               io_u->dtype = 0;
-               io_u->dspec = 0;
-               return;
-       }
-
-       if (td->o.fdp_pli_select == FIO_FDP_RR) {
-               if (ruhs->pli_loc >= ruhs->nr_ruhs)
-                       ruhs->pli_loc = 0;
-
-               dspec = ruhs->plis[ruhs->pli_loc++];
-       } else {
-               ruhs->pli_loc = rand_between(&td->fdp_state, 0, ruhs->nr_ruhs - 1);
-               dspec = ruhs->plis[ruhs->pli_loc];
-       }
-
-       io_u->dtype = FDP_DIR_DTYPE;
-       io_u->dspec = dspec;
-}
diff --git a/fdp.h b/fdp.h
deleted file mode 100644 (file)
index accbac3..0000000
--- a/fdp.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef FIO_FDP_H
-#define FIO_FDP_H
-
-#include "io_u.h"
-
-#define FDP_DIR_DTYPE  2
-#define FDP_MAX_RUHS   128
-
-/*
- * How fio chooses what placement identifier to use next. Choice of
- * uniformly random, or roundrobin.
- */
-
-enum {
-       FIO_FDP_RANDOM  = 0x1,
-       FIO_FDP_RR      = 0x2,
-};
-
-struct fio_ruhs_info {
-       uint32_t nr_ruhs;
-       uint32_t pli_loc;
-       uint16_t plis[];
-};
-
-int fdp_init(struct thread_data *td);
-void fdp_free_ruhs_info(struct fio_file *f);
-void fdp_fill_dspec_data(struct thread_data *td, struct io_u *io_u);
-
-#endif /* FIO_FDP_H */
index 2d277a6428a3b19dee365262405b30850d90a669..8923f2b3eaf53c39771fe8a901dd63839b66b1fa 100644 (file)
@@ -1412,7 +1412,7 @@ done:
        td_restore_runstate(td, old_state);
 
        if (td->o.fdp) {
-               err = fdp_init(td);
+               err = dp_init(td);
                if (err)
                        goto err_out;
        }
diff --git a/io_u.c b/io_u.c
index a499ff076b188c5cf6530892a4c1c7e1ce73d43b..89f3d7892eb4c7ebfbfc5f17d371496b3b34928a 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1066,7 +1066,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
        }
 
        if (td->o.fdp)
-               fdp_fill_dspec_data(td, io_u);
+               dp_fill_dspec_data(td, io_u);
 
        if (io_u->offset + io_u->buflen > io_u->file->real_file_size) {
                dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n",
index 4fe9bb98b608f02b6f4ea07b7245c9c4287053bf..d5b0cafe33773cfebe931ea3ff57e9a34efbc472 100644 (file)
@@ -7,7 +7,7 @@
 #include "flist.h"
 #include "io_u.h"
 #include "zbd_types.h"
-#include "fdp.h"
+#include "dataplacement.h"
 
 #define FIO_IOOPS_VERSION      34