cifs: add ability to build as an external IO engine
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/Makefile b/Makefile
index 8df6597..1a4e015 100644
--- a/Makefile
+++ b/Makefile
@@ -108,9 +108,14 @@
endif
endif
ifdef CONFIG_CIFS
+ifdef CONFIG_CIFS_EXTERNAL
+ EXT_SOURCE += engines/cifs.c
+ EXT_SOURCE += engines/cifs_sync.c
+else
SOURCE += engines/cifs.c
SOURCE += engines/cifs_sync.c
endif
+endif
ifeq ($(CONFIG_TARGET_OS), Linux)
SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
@@ -253,7 +258,11 @@
sharedir = $(prefix)/share/fio
endif
-all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE
+ifdef CONFIG_CIFS_EXTERNAL
+EXT_ENGINES = cifs.so
+endif
+
+all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE $(EXT_ENGINES)
.PHONY: all install clean
.PHONY: FORCE cscope
@@ -298,6 +307,9 @@
parse.o: lex.yy.o y.tab.o
endif
+cifs.so: engines/cifs.c engines/cifs_sync.c
+ $(QUIET_CC)$(CC) -o cifs.so -shared -rdynamic -fPIC $(CFLAGS) $(CPPFLAGS) engines/cifs.c engines/cifs_sync.c
+
init.o: FIO-VERSION-FILE init.c
$(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
@@ -358,7 +370,7 @@
$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
clean: FORCE
- @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d 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) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h *.so
distclean: clean FORCE
@rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
diff --git a/configure b/configure
index 67373b2..e8c4dde 100755
--- a/configure
+++ b/configure
@@ -135,6 +135,7 @@
exit_val=0
gfio_check="no"
libhdfs="no"
+cifs_external="no"
# parse options
for opt do
@@ -167,6 +168,8 @@
;;
--disable-cifs) disable_cifs="yes"
;;
+ --cifs-external) external_cifs="yes"
+ ;;
--help)
show_help="yes"
;;
@@ -187,6 +190,8 @@
echo "--enable-gfio Enable building of gtk gfio"
echo "--disable-numa Disable libnuma even if found"
echo "--enable-libhdfs Enable hdfs support"
+ echo "--disable-cifs Disable CIFS support"
+ echo "--cifs-external Build CIFS as an external engine"
exit $exit_val
fi
@@ -1610,6 +1615,9 @@
fi
if test "$cifs" = "yes"; then
output_sym "CONFIG_CIFS"
+ if test "$external_cifs" = "yes" ; then
+ output_sym "CONFIG_CIFS_EXTERNAL"
+ fi
fi
if test "$zlib" = "no" ; then
diff --git a/engines/cifs_sync.c b/engines/cifs_sync.c
index 49b66ff..ff5b696 100644
--- a/engines/cifs_sync.c
+++ b/engines/cifs_sync.c
@@ -61,7 +61,10 @@
return fio_io_end(td, io_u, ret);
}
-static struct ioengine_ops ioengine = {
+#ifndef CONFIG_CIFS_EXTERNAL
+static
+#endif
+struct ioengine_ops ioengine = {
.name = "cifs_sync",
.version = FIO_IOOPS_VERSION,
.init = fio_cifs_init,
@@ -76,6 +79,7 @@
.flags = FIO_SYNCIO | FIO_DISKLESSIO,
};
+#ifndef CONFIG_CIFS_EXTERNAL
static void fio_init fio_cifs_register(void)
{
register_ioengine(&ioengine);
@@ -85,3 +89,4 @@
{
unregister_ioengine(&ioengine);
}
+#endif
diff --git a/options.c b/options.c
index 765559c..bace303 100644
--- a/options.c
+++ b/options.c
@@ -1549,7 +1549,7 @@
},
#endif
#ifdef CONFIG_CIFS
- { .ival = "cifs",
+ { .ival = "cifs_sync",
.help = "CIFS Samba client"
},
#endif