*.d
*.o
+*.so
*.exe
/.depend
/FIO-VERSION-FILE
endif
ifdef CONFIG_LIBISCSI
- CFLAGS := $(LIBISCSI_CFLAGS) $(CFLAGS)
- LIBS += $(LIBISCSI_LIBS)
- SOURCE += engines/libiscsi.c
+ iscsi_SRCS = engines/libiscsi.c
+ iscsi_LIBS = $(LIBISCSI_LIBS)
+ iscsi_CFLAGS = $(LIBISCSI_LIBS)
+ ENGINES += iscsi
endif
ifdef CONFIG_LIBNBD
- CFLAGS := $(LIBNBD_CFLAGS) $(CFLAGS)
- LIBS += $(LIBNBD_LIBS)
- SOURCE += engines/nbd.c
+ nbd_SRCS = engines/nbd.c
+ nbd_LIBS = $(LIBNBD_LIBS)
+ nbd_CFLAGS = $(LIBNBD_CFLAGS)
+ ENGINES += nbd
endif
ifdef CONFIG_64BIT
CFLAGS := -DBITS_PER_LONG=32 $(CFLAGS)
endif
ifdef CONFIG_LIBAIO
- SOURCE += engines/libaio.c
+ aio_SRCS = engines/libaio.c
+ aio_LIBS = -laio
ifdef CONFIG_LIBAIO_URING
- LIBS += -luring
+ aio_LIBS = -luring
else
- LIBS += -laio
+ aio_LIBS = -laio
endif
+ ENGINES += aio
endif
ifdef CONFIG_RDMA
- SOURCE += engines/rdma.c
- LIBS += -libverbs -lrdmacm
+ rdma_SRCS = engines/rdma.c
+ rdma_LIBS = -libverbs -lrdmacm
+ ENGINES += rdma
endif
ifdef CONFIG_POSIXAIO
SOURCE += engines/posixaio.c
SOURCE += engines/splice.c
endif
ifdef CONFIG_GUASI
- SOURCE += engines/guasi.c
+ guasi_SRCS = engines/guasi.c
+ ENGINES += guasi
endif
ifdef CONFIG_SOLARISAIO
SOURCE += engines/solarisaio.c
SOURCE += engines/windowsaio.c
endif
ifdef CONFIG_RADOS
- SOURCE += engines/rados.c
- LIBS += -lrados
+ rados_SRCS = engines/rados.c
+ rados_LIBS = -lrados
+ ENGINES += rados
endif
ifdef CONFIG_RBD
- SOURCE += engines/rbd.c
- LIBS += -lrbd -lrados
+ rbd_SRCS = engines/rbd.c
+ rbd_LIBS = -lrbd -lrados
+ ENGINES += rbd
endif
ifdef CONFIG_HTTP
- SOURCE += engines/http.c
- LIBS += -lcurl -lssl -lcrypto
+ http_SRCS = engines/http.c
+ http_LIBS = -lcurl -lssl -lcrypto
+ ENGINES += http
endif
SOURCE += oslib/asprintf.c
ifndef CONFIG_STRSEP
SOURCE += oslib/libmtd_legacy.c
endif
ifdef CONFIG_PMEMBLK
- SOURCE += engines/pmemblk.c
- LIBS += -lpmemblk
+ pmemblk_SRCS = engines/pmemblk.c
+ pmemblk_LIBS = -lpmemblk
+ ENGINES += pmemblk
endif
ifdef CONFIG_LINUX_DEVDAX
- SOURCE += engines/dev-dax.c
- LIBS += -lpmem
+ devdax_SRCS = engines/dev-dax.c
+ devdax_LIBS = -lpmem
+ ENGINES += dev-dax
endif
ifdef CONFIG_LIBPMEM
- SOURCE += engines/libpmem.c
- LIBS += -lpmem
+ pmem_SRCS = engines/libpmem.c
+ pmem_LIBS = -lpmem
+ ENGINES += pmem
endif
ifdef CONFIG_IME
SOURCE += engines/ime.c
endif
ifdef CONFIG_LIBZBC
- SOURCE += engines/libzbc.c
- LIBS += -lzbc
+ zbc_SRCS = engines/libzbc.c
+ zbc_LIBS = -lzbc
+ ENGINES += zbc
endif
ifeq ($(CONFIG_TARGET_OS), Linux)
CFLAGS := -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format $(CFLAGS)
endif
+ifdef CONFIG_DYNAMIC_ENGINES
+ DYNAMIC_ENGS := $(ENGINES)
+define engine_template =
+$(1)_OBJS := $$($(1)_SRCS:.c=.o)
+$$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
+engines/lib$(1).so: $$($(1)_OBJS)
+ $$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,lib$(1).so.1 $$($(1)_LIBS) -o $$@ $$<
+ENGS_OBJS += engines/lib$(1).so
+all install: $(ENGS_OBJS)
+endef
+else # !CONFIG_DYNAMIC_ENGINES
+define engine_template =
+SOURCE += $$($(1)_SRCS)
+LIBS += $$($(1)_LIBS)
+CFLAGS := $$($(1)_CFLAGS) $(CFLAGS)
+endef
+endif
+
+$(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
+
OBJS := $(SOURCE:.c=.o)
FIO_OBJS = $(OBJS) fio.o
endif
prefix = $(INSTALL_PREFIX)
bindir = $(prefix)/bin
+libdir = $(prefix)/lib/fio
ifeq ($(CONFIG_TARGET_OS), Darwin)
mandir = /usr/share/man
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] 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 .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
@rm -rf doc/output
install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
+ifdef CONFIG_DYNAMIC_ENGINES
+ $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
+ $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
+endif
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
libiscsi="no"
libnbd="no"
libaio_uring="no"
+dynamic_engines="no"
prefix=/usr/local
# parse options
;;
--enable-libaio-uring) libaio_uring="yes"
;;
+ --dynamic-libengines) dynamic_engines="yes"
+ ;;
--help)
show_help="yes"
;;
echo "--enable-libnbd Enable libnbd (NBD engine) support"
echo "--disable-tcmalloc Disable tcmalloc support"
echo "--enable-libaio-uring Enable libaio emulated over io_uring"
+ echo "--dynamic-libengines Lib-based ioengines as dynamic libraries"
exit $exit_val
fi
echo "LIBNBD_CFLAGS=$libnbd_cflags" >> $config_host_mak
echo "LIBNBD_LIBS=$libnbd_libs" >> $config_host_mak
fi
+if test "$dynamic_engines" = "yes" ; then
+ output_sym "CONFIG_DYNAMIC_ENGINES"
+fi
+print_config "Lib-based ioengines dynamic" "$dynamic_engines"
cat > $TMPC << EOF
int main(int argc, char **argv)
{
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "dev-dax",
.version = FIO_IOOPS_VERSION,
.init = fio_devdax_init,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "guasi",
.version = FIO_IOOPS_VERSION,
.init = fio_guasi_init,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "http",
.version = FIO_IOOPS_VERSION,
.flags = FIO_DISKLESSIO | FIO_SYNCIO,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "libaio",
.version = FIO_IOOPS_VERSION,
.flags = FIO_ASYNCIO_SYNC_TRIM,
}
}
-static struct ioengine_ops ioengine_hdfs = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "libhdfs",
.version = FIO_IOOPS_VERSION,
.flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NODISKUTIL,
static void fio_init fio_hdfsio_register(void)
{
- register_ioengine(&ioengine_hdfs);
+ register_ioengine(&ioengine);
}
static void fio_exit fio_hdfsio_unregister(void)
{
- unregister_ioengine(&ioengine_hdfs);
+ unregister_ioengine(&ioengine);
}
return io_u;
}
-static struct ioengine_ops ioengine_iscsi = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "libiscsi",
.version = FIO_IOOPS_VERSION,
.flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NODISKUTIL,
static void fio_init fio_iscsi_register(void)
{
- register_ioengine(&ioengine_iscsi);
+ register_ioengine(&ioengine);
}
static void fio_exit fio_iscsi_unregister(void)
{
- unregister_ioengine(&ioengine_iscsi);
+ unregister_ioengine(&ioengine);
}
return generic_close_file(td, f);
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "libpmem",
.version = FIO_IOOPS_VERSION,
.init = fio_libpmem_init,
return FIO_Q_COMPLETED;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "libzbc",
.version = FIO_IOOPS_VERSION,
.open_file = libzbc_open_file,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "nbd",
.version = FIO_IOOPS_VERSION,
.options = options,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "pmemblk",
.version = FIO_IOOPS_VERSION,
.queue = fio_pmemblk_queue,
}
/* ioengine_ops for get_ioengine() */
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "rados",
.version = FIO_IOOPS_VERSION,
.flags = FIO_DISKLESSIO,
return 0;
}
-static struct ioengine_ops ioengine = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "rbd",
.version = FIO_IOOPS_VERSION,
.setup = fio_rbd_setup,
rd->rmt_nr = ntohl(rd->recv_buf.nr);
for (i = 0; i < rd->rmt_nr; i++) {
- rd->rmt_us[i].buf = be64_to_cpu(rd->recv_buf.rmt_us[i].buf);
+ rd->rmt_us[i].buf = __be64_to_cpu(
+ rd->recv_buf.rmt_us[i].buf);
rd->rmt_us[i].rkey = ntohl(rd->recv_buf.rmt_us[i].rkey);
rd->rmt_us[i].size = ntohl(rd->recv_buf.rmt_us[i].size);
return 0;
}
-static struct ioengine_ops ioengine_rw = {
+FIO_STATIC struct ioengine_ops ioengine = {
.name = "rdma",
.version = FIO_IOOPS_VERSION,
.setup = fio_rdmaio_setup,
static void fio_init fio_rdmaio_register(void)
{
- register_ioengine(&ioengine_rw);
+ register_ioengine(&ioengine);
}
static void fio_exit fio_rdmaio_unregister(void)
{
- unregister_ioengine(&ioengine_rw);
+ unregister_ioengine(&ioengine);
}
return NULL;
}
+#ifdef CONFIG_DYNAMIC_ENGINES
+static void *dlopen_external(struct thread_data *td, const char *engine)
+{
+ char engine_path[PATH_MAX];
+
+ sprintf(engine_path, "%s/lib%s.so", FIO_EXT_ENG_DIR, engine);
+
+ return dlopen(engine_path, RTLD_LAZY);
+}
+#else
+#define dlopen_external(td, engine) (NULL)
+#endif
+
static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
const char *engine_lib)
{
dlerror();
dlhandle = dlopen(engine_lib, RTLD_LAZY);
if (!dlhandle) {
- td_vmsg(td, -1, dlerror(), "dlopen");
- return NULL;
+ dlhandle = dlopen_external(td, engine_lib);
+ if (!dlhandle) {
+ td_vmsg(td, -1, dlerror(), "dlopen");
+ return NULL;
+ }
}
/*
#define FIO_IOOPS_VERSION 26
+#ifndef CONFIG_DYNAMIC_ENGINES
+#define FIO_STATIC static
+#else
+#define FIO_STATIC
+#endif
+
/*
* io_ops->queue() return values
*/
#define OS_MAP_ANON MAP_ANONYMOUS
+#define FIO_EXT_ENG_DIR "/usr/lib/fio"
+
typedef cpu_set_t os_cpu_mask_t;
#ifdef CONFIG_3ARG_AFFINITY