Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH 0/3] dynamic engines: fix several issues
@ 2020-11-09 16:46 Eric Sandeen
  2020-11-09 16:46 ` [PATCH 1/3] fix dynamic engine buil Eric Sandeen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eric Sandeen @ 2020-11-09 16:46 UTC (permalink / raw)
  To: fio; +Cc: sitsofe, ykorman, rjones

1) Fix the build
2) Fix engine loading
3) Fix engine listing

Thanks,
-Eric



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] fix dynamic engine buil
  2020-11-09 16:46 [PATCH 0/3] dynamic engines: fix several issues Eric Sandeen
@ 2020-11-09 16:46 ` Eric Sandeen
  2020-11-09 16:46 ` [PATCH 2/3] fix dynamic engine loading for libaio engine etc Eric Sandeen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2020-11-09 16:46 UTC (permalink / raw)
  To: fio; +Cc: sitsofe, ykorman, rjones

Builds with --dynamic-libengines are currently broken, because the rule
to build the libraries was moved out of the template that creates them:

make: *** No rule to make target 'engines/libpmem.so', needed by 'all'.  Stop.
make: *** Waiting for unfinished jobs....

Fix this by moving the rule back into the template, calling the template
to create rules only after FIO_CFLAGS has been incorporated into CFLAGS,
and using CFLAGS + -fPIC in that rule rather than FIO_CFLAGS.

Fixes: 8a2cf08d29ac ("Makefile: introduce FIO_CFLAGS")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 Makefile | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 8c8a8fc..b0b9f86 100644
--- a/Makefile
+++ b/Makefile
@@ -255,7 +255,9 @@ ifdef CONFIG_DYNAMIC_ENGINES
  DYNAMIC_ENGS := $(ENGINES)
 define engine_template =
 $(1)_OBJS := $$($(1)_SRCS:.c=.o)
-$$($(1)_OBJS): FIO_CFLAGS += -fPIC $$($(1)_CFLAGS)
+$$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
+engines/lib$(1).so: $$($(1)_OBJS)
+	$$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 $$($(1)_LIBS) -o $$@ $$<
 ENGS_OBJS += engines/lib$(1).so
 endef
 else # !CONFIG_DYNAMIC_ENGINES
@@ -266,6 +268,8 @@ CFLAGS += $$($(1)_CFLAGS)
 endef
 endif
 
+override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
+
 $(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
 
 OBJS := $(SOURCE:.c=.o)
@@ -438,8 +442,6 @@ FIO-VERSION-FILE: FORCE
 	@$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
 -include FIO-VERSION-FILE
 
-override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
-
 %.o : %.c
 	@mkdir -p $(dir $@)
 	$(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
@@ -567,11 +569,6 @@ unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
 	$(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
 endif
 
-ifdef CONFIG_DYNAMIC_ENGINES
-engines/lib$(1).so: $$($(1)_OBJS)
-	$$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 $$($(1)_LIBS) -o $$@ $$<
-endif
-
 clean: FORCE
 	@rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(UT_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio unittests/unittest FIO-VERSION-FILE *.[do] lib/*.d oslib/*.[do] crc/*.d engines/*.[do] engines/*.so profiles/*.[do] t/*.[do] unittests/*.[do] unittests/*/*.[do] config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
 	@rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] fix dynamic engine loading for libaio engine etc
  2020-11-09 16:46 [PATCH 0/3] dynamic engines: fix several issues Eric Sandeen
  2020-11-09 16:46 ` [PATCH 1/3] fix dynamic engine buil Eric Sandeen
@ 2020-11-09 16:46 ` Eric Sandeen
  2020-11-09 16:46 ` [PATCH 3/3] list all available dynamic ioengines with --enghelp Eric Sandeen
  2020-11-09 17:08 ` [PATCH 0/3] dynamic engines: fix several issues Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2020-11-09 16:46 UTC (permalink / raw)
  To: fio; +Cc: sitsofe, ykorman, rjones

The dynamic engine loading for libaio (and some others) currently
fails because the dlopen routine is looking for ("lib%s", enginename)
which translates into "liblibiscsi.so":

openat(AT_FDCWD, "/usr/lib64/fio/liblibiscsi.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
Engine libiscsi not found; Either name is invalid, was not built, or fio-engine-libiscsi package is missing.
fio: engine libiscsi not loadable
IO engine libiscsi not found

The Makefile decide to name this engine "iscsi" instead of "libiscsi",
which leads to "libiscsi.so" not "liblibiscsi.so" hence the mismatch.

OTOH, "liblibiscsi.so" seems a bit bonkers.

Try to resolve all this by:

1) make all of the engine names match the documented engine names
   in the Makefile, i.e. "iscsi" -> "libiscsi"
2) change the created library filenames to "fio-$(ENGINENAME)"
   from "lib$(ENGINENAME)" to avoid the "liblib" prefix.

So now we consistently have the libraries named "fio-$(ENGINENAME).so"

fio-http.so
fio-libaio.so

etc.

Fixes: 5a8a6a03 ("configure: new --dynamic-libengines build option")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 Makefile    | 34 +++++++++++++++++-----------------
 ioengines.c |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index b0b9f86..ac3a590 100644
--- a/Makefile
+++ b/Makefile
@@ -66,10 +66,10 @@ ifdef CONFIG_LIBHDFS
 endif
 
 ifdef CONFIG_LIBISCSI
-  iscsi_SRCS = engines/libiscsi.c
-  iscsi_LIBS = $(LIBISCSI_LIBS)
-  iscsi_CFLAGS = $(LIBISCSI_CFLAGS)
-  ENGINES += iscsi
+  libiscsi_SRCS = engines/libiscsi.c
+  libiscsi_LIBS = $(LIBISCSI_LIBS)
+  libiscsi_CFLAGS = $(LIBISCSI_CFLAGS)
+  ENGINES += libiscsi
 endif
 
 ifdef CONFIG_LIBNBD
@@ -85,14 +85,14 @@ else ifdef CONFIG_32BIT
   CPPFLAGS += -DBITS_PER_LONG=32
 endif
 ifdef CONFIG_LIBAIO
-  aio_SRCS = engines/libaio.c
-  aio_LIBS = -laio
+  libaio_SRCS = engines/libaio.c
+  libaio_LIBS = -laio
   ifdef CONFIG_LIBAIO_URING
-    aio_LIBS = -luring
+    libaio_LIBS = -luring
   else
-    aio_LIBS = -laio
+    libaio_LIBS = -laio
   endif
-  ENGINES += aio
+  ENGINES += libaio
 endif
 ifdef CONFIG_RDMA
   rdma_SRCS = engines/rdma.c
@@ -179,17 +179,17 @@ ifdef CONFIG_LINUX_DEVDAX
   ENGINES += dev-dax
 endif
 ifdef CONFIG_LIBPMEM
-  pmem_SRCS = engines/libpmem.c
-  pmem_LIBS = -lpmem
-  ENGINES += pmem
+  libpmem_SRCS = engines/libpmem.c
+  libpmem_LIBS = -lpmem
+  ENGINES += libpmem
 endif
 ifdef CONFIG_IME
   SOURCE += engines/ime.c
 endif
 ifdef CONFIG_LIBZBC
-  zbc_SRCS = engines/libzbc.c
-  zbc_LIBS = -lzbc
-  ENGINES += zbc
+  libzbc_SRCS = engines/libzbc.c
+  libzbc_LIBS = -lzbc
+  ENGINES += libzbc
 endif
 
 ifeq ($(CONFIG_TARGET_OS), Linux)
@@ -256,9 +256,9 @@ ifdef CONFIG_DYNAMIC_ENGINES
 define engine_template =
 $(1)_OBJS := $$($(1)_SRCS:.c=.o)
 $$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
-engines/lib$(1).so: $$($(1)_OBJS)
+engines/fio-$(1).so: $$($(1)_OBJS)
 	$$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 $$($(1)_LIBS) -o $$@ $$<
-ENGS_OBJS += engines/lib$(1).so
+ENGS_OBJS += engines/fio-$(1).so
 endef
 else # !CONFIG_DYNAMIC_ENGINES
 define engine_template =
diff --git a/ioengines.c b/ioengines.c
index 3e43ef2..fb59349 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -91,7 +91,7 @@ static void *dlopen_external(struct thread_data *td, const char *engine)
 	char engine_path[PATH_MAX];
 	void *dlhandle;
 
-	sprintf(engine_path, "%s/lib%s.so", FIO_EXT_ENG_DIR, engine);
+	sprintf(engine_path, "%s/fio-%s.so", FIO_EXT_ENG_DIR, engine);
 
 	dlhandle = dlopen(engine_path, RTLD_LAZY);
 	if (!dlhandle)
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] list all available dynamic ioengines with --enghelp
  2020-11-09 16:46 [PATCH 0/3] dynamic engines: fix several issues Eric Sandeen
  2020-11-09 16:46 ` [PATCH 1/3] fix dynamic engine buil Eric Sandeen
  2020-11-09 16:46 ` [PATCH 2/3] fix dynamic engine loading for libaio engine etc Eric Sandeen
@ 2020-11-09 16:46 ` Eric Sandeen
  2020-11-09 17:08 ` [PATCH 0/3] dynamic engines: fix several issues Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2020-11-09 16:46 UTC (permalink / raw)
  To: fio; +Cc: sitsofe, ykorman, rjones

When dynamic engines are enabled, "fio --enghelp" does not list all
available engines as the man page says it will:

	If no ioengine is given, list all available ioengines.

Fix this by opening FIO_EXT_ENG_DIR and attempting dlopen_ioengine
everything that's found there.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 ioengines.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/ioengines.c b/ioengines.c
index fb59349..c688dd1 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -15,6 +15,8 @@
 #include <dlfcn.h>
 #include <fcntl.h>
 #include <assert.h>
+#include <sys/types.h>
+#include <dirent.h>
 
 #include "fio.h"
 #include "diskutil.h"
@@ -630,6 +632,34 @@ int td_io_get_file_size(struct thread_data *td, struct fio_file *f)
 	return td->io_ops->get_file_size(td, f);
 }
 
+#ifdef CONFIG_DYNAMIC_ENGINES
+/* Load all dynamic engines in FIO_EXT_ENG_DIR for enghelp command */
+static void
+fio_load_dynamic_engines(struct thread_data *td)
+{
+	DIR *dirhandle = NULL;
+	struct dirent *dirent = NULL;
+	char engine_path[PATH_MAX];
+
+	dirhandle = opendir(FIO_EXT_ENG_DIR);
+	if (!dirhandle)
+		return;
+
+	while ((dirent = readdir(dirhandle)) != NULL) {
+		if (!strcmp(dirent->d_name, ".") ||
+		    !strcmp(dirent->d_name, ".."))
+			continue;
+
+		sprintf(engine_path, "%s/%s", FIO_EXT_ENG_DIR, dirent->d_name);
+		dlopen_ioengine(td, engine_path);
+	}
+
+	closedir(dirhandle);
+}
+#else
+#define fio_load_dynamic_engines(td) do { } while (0)
+#endif
+
 int fio_show_ioengine_help(const char *engine)
 {
 	struct flist_head *entry;
@@ -638,8 +668,11 @@ int fio_show_ioengine_help(const char *engine)
 	char *sep;
 	int ret = 1;
 
+	memset(&td, 0, sizeof(struct thread_data));
+
 	if (!engine || !*engine) {
 		log_info("Available IO engines:\n");
+		fio_load_dynamic_engines(&td);
 		flist_for_each(entry, &engine_list) {
 			io_ops = flist_entry(entry, struct ioengine_ops, list);
 			log_info("\t%s\n", io_ops->name);
@@ -652,7 +685,6 @@ int fio_show_ioengine_help(const char *engine)
 		sep++;
 	}
 
-	memset(&td, 0, sizeof(struct thread_data));
 	td.o.ioengine = (char *)engine;
 	io_ops = load_ioengine(&td);
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] dynamic engines: fix several issues
  2020-11-09 16:46 [PATCH 0/3] dynamic engines: fix several issues Eric Sandeen
                   ` (2 preceding siblings ...)
  2020-11-09 16:46 ` [PATCH 3/3] list all available dynamic ioengines with --enghelp Eric Sandeen
@ 2020-11-09 17:08 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2020-11-09 17:08 UTC (permalink / raw)
  To: Eric Sandeen, fio; +Cc: sitsofe, ykorman, rjones

On 11/9/20 9:46 AM, Eric Sandeen wrote:
> 1) Fix the build
> 2) Fix engine loading
> 3) Fix engine listing

Applied this, and a change for the default lookup path so that it at
least matches the default install path. On second thought, that should
probably just match prefix, but even that won't be correct. More work
needed there, but it's no more broken that before at least.

And a fix for the linking order, so that dynamic engines actually work
now.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-09 17:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-09 16:46 [PATCH 0/3] dynamic engines: fix several issues Eric Sandeen
2020-11-09 16:46 ` [PATCH 1/3] fix dynamic engine buil Eric Sandeen
2020-11-09 16:46 ` [PATCH 2/3] fix dynamic engine loading for libaio engine etc Eric Sandeen
2020-11-09 16:46 ` [PATCH 3/3] list all available dynamic ioengines with --enghelp Eric Sandeen
2020-11-09 17:08 ` [PATCH 0/3] dynamic engines: fix several issues Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox