Whamcloud - gitweb
LU-9897 utils: remove libcfsutils.a and libptlctl.a 52/28752/7
authorJames Simmons <uja.ornl@yahoo.com>
Mon, 9 Oct 2017 14:37:14 +0000 (10:37 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Oct 2017 07:18:39 +0000 (07:18 +0000)
Currently lustre creates many libraries and combines them in
redudant ways. Broke up libptlctl.a and merged debug.c and
portals.c into lctl. The application lustre_rsync pulled in
way too much extra code that is not needed just for the function
obd_initialize(). Instead just call register_ioc_dev() directly
for lustre_rsync. This removes the libptlctl.a/portals.c
dependency. In time the portals.c code can be replaced by the
work from liblnetconfig. Integrated cyaml into liblnetconfig
instead of directly linking cyaml.c into lnetctl. This way
we can take advantage of YAML in the future for lnet selftest
and lustre utilities. Only a small change was needed for lnet
selftest to be dependent on liblnetconfig instead of libptlctl.a.

Change-Id: Ic1caaa01b3faedf90dc7ae8bc26ee40396a52a07
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/28752
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
13 files changed:
libcfs/libcfs/autoMakefile.am
lnet/utils/Makefile.am
lnet/utils/lnetconfig/Makefile.am
lnet/utils/lnetconfig/cyaml.c [moved from lnet/utils/cyaml/cyaml.c with 100% similarity]
lnet/utils/lnetconfig/liblnd.h
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetconfig/liblnetconfig_lnd.c
lnet/utils/lst.c
lustre.spec.in
lustre/utils/Makefile.am
lustre/utils/debug.c [moved from lnet/utils/debug.c with 100% similarity]
lustre/utils/lustre_rsync.c
lustre/utils/portals.c [moved from lnet/utils/portals.c with 100% similarity]

index 4165f54..dbb7cdb 100644 (file)
@@ -37,18 +37,15 @@ DIST_SUBDIRS = linux util
 
 noinst_LIBRARIES  = libcfs.a
 libcfs_a_SOURCES  := util/string.c util/nidstrings.c util/param.c
+if UTILS
+libcfs_a_SOURCES  += util/parser.c util/l_ioctl.c
+endif # UTILS
 libcfs_a_CPPFLAGS := -D_GNU_SOURCE
 libcfs_a_CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64
-libcfs_a_CFLAGS   := -fPIC
-
 if UTILS
-lib_LIBRARIES = libcfsutil.a
-libcfsutil_a_SOURCES  := util/parser.c util/l_ioctl.c
-libcfsutil_a_CPPFLAGS := -D_GNU_SOURCE
-libcfsutil_a_CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64
-libcfsutil_a_CPPFLAGS += -DLUSTRE_UTILS=1
-libcfsutil_a_CFLAGS   := -fPIC
-endif # UTILS
+libcfs_a_CPPFLAGS += -DLUSTRE_UTILS=1
+endif
+libcfs_a_CFLAGS   := -fPIC
 
 if MODULES
 
index 16047da..091f9da 100644 (file)
@@ -40,7 +40,6 @@ SUBDIRS = lnetconfig
 endif # BUILD_DLC
 
 LIBCFS= $(top_builddir)/libcfs/libcfs/libcfs.a
-LIBCFSUTIL= $(top_builddir)/libcfs/libcfs/libcfsutil.a
 
 if UTILS
 sbin_PROGRAMS = routerstat lst
@@ -53,9 +52,10 @@ routerstat_SOURCES = routerstat.c
 routerstat_LDADD = $(LIBCFS)
 
 lst_SOURCES = lst.c
-lst_CPPFLAGS = -I$(top_builddir)/lustre
-lst_LDADD = -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE)
-lst_DEPENDENCIES = libptlctl.a
+lst_LDADD = $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE)
+if BUILD_DLC
+lst_LDADD += $(top_builddir)/lnet/utils/lnetconfig/liblnetconfig.la
+endif
 
 if TESTS
 sbin_PROGRAMS += wirecheck
@@ -63,12 +63,7 @@ sbin_PROGRAMS += wirecheck
 wirecheck_SOURCES = wirecheck.c
 endif # TESTS
 
-lib_LIBRARIES = libptlctl.a
-libptlctl_a_SOURCES = portals.c debug.c
-
-CYAML := $(top_builddir)/lnet/utils/cyaml/cyaml.c
-lnetctl_SOURCES = lnetctl.c $(CYAML)
+lnetctl_SOURCES = lnetctl.c
 lnetctl_LDADD = $(top_builddir)/lnet/utils/lnetconfig/liblnetconfig.la \
-               $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE) -lyaml -lm
-lnetctl_DEPENDENCIES = $(top_builddir)/lnet/utils/lnetconfig/liblnetconfig.la
+               $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE)
 endif # UTILS
index 7da6071..e50b13a 100644 (file)
 
 lib_LTLIBRARIES = liblnetconfig.la
 
-CYAML := $(top_builddir)/lnet/utils/cyaml/cyaml.c \
-        $(top_builddir)/lnet/include/cyaml.h
 liblnetconfig_la_SOURCES  = liblnetconfig.c liblnetconfig.h \
-                           liblnetconfig_lnd.c liblnd.h $(CYAML)
+                           liblnetconfig_lnd.c liblnd.h cyaml.c \
+                           $(top_builddir)/lnet/include/cyaml.h
 liblnetconfig_la_CPPFLAGS = -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
-                           -DLUSTRE_UTILS=1 -I$(top_builddir)/lnet/utils/cyaml
-liblnetconfig_la_LDFLAGS = -L$(top_builddir)/libcfs/libcfs -version-info 2:0:0
+                           -DLUSTRE_UTILS=1 -I$(top_builddir)/lnet/include
+liblnetconfig_la_LDFLAGS = -L$(top_builddir)/libcfs/libcfs -lyaml -lm \
+                          -version-info 2:0:0
 
 EXTRA_DIST =
index 1896d48..3dd6741 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <linux/lnet/socklnd.h>
 #include <linux/lnet/lnet-dlc.h>
-#include "cyaml.h"
+#include <cyaml.h>
 
 int
 lustre_net_show_tunables(struct cYAML *tunables,
index b55576b..b372837 100644 (file)
@@ -51,7 +51,6 @@
 #include <fcntl.h>
 #include <ifaddrs.h>
 #include "liblnetconfig.h"
-#include "cyaml.h"
 
 #define CONFIG_CMD             "configure"
 #define UNCONFIG_CMD           "unconfigure"
index 5aa8787..c5f023c 100644 (file)
@@ -31,8 +31,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <libcfs/util/ioctl.h>
+#include "liblnd.h"
 #include "liblnetconfig.h"
-#include "cyaml.h"
 
 static int
 lustre_o2iblnd_show_tun(struct cYAML *lndparams,
index ff8db84..e5e8abb 100644 (file)
@@ -51,7 +51,9 @@
 #include <linux/lnet/lnetctl.h>
 #include <linux/lnet/lnetst.h>
 #include <linux/lnet/nidstr.h>
-#include <utils/obdctl.h>
+#ifdef USE_DLC
+#include "lnetconfig/liblnetconfig.h"
+#endif
 
 struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
 static struct lst_sid session_id;
@@ -3331,10 +3333,14 @@ main(int argc, char **argv)
         rc = lst_initialize();
         if (rc < 0)
                 goto errorout;
-
-        rc = ptl_initialize(argc, argv);
-        if (rc < 0)
-                goto errorout;
+#ifdef USE_DLC
+       rc = lustre_lnet_config_lib_init();
+#else
+       rc = register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
+                             LNET_DEV_MAJOR, LNET_DEV_MINOR);
+#endif
+       if (rc < 0)
+               goto errorout;
 
         Parser_init("lst > ", lst_cmdlist);
 
index 855d435..65e9ad4 100644 (file)
@@ -451,8 +451,6 @@ echo '%{_sbindir}/wiretest' >>lustre-tests.files
 %{_bindir}/lfs
 %{_bindir}/lfs_migrate
 /sbin/mount.lustre
-%{_libdir}/libptlctl.a
-%{_libdir}/libcfsutil.a
 %{_libdir}/liblustreapi.a
 %{_libdir}/liblustreapi.so
 %if %{with manpages}
index 82e7381..e4e64a3 100644 (file)
@@ -4,9 +4,7 @@ AM_CFLAGS  := -fPIC -D_GNU_SOURCE \
              -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS=1
 AM_LDFLAGS := -L$(top_builddir)/lnet/utils
 
-LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a \
-            $(top_builddir)/libcfs/libcfs/libcfsutil.a \
-            $(top_builddir)/libcfs/libcfs/libcfs.a
+LIBCFS := $(top_builddir)/libcfs/libcfs/libcfs.a
 
 if TESTS
 EXTRA_PROGRAMS = wirecheck
@@ -53,17 +51,17 @@ endif
 noinst_LIBRARIES = liblustreapitmp.a
 endif # UTILS
 
-lctl_SOURCES = lustre_lfsck.c obd.c lustre_cfg.c lctl.c obdctl.h lsnapshot.c
-lctl_LDADD :=  liblustreapi.a $(LIBPTLCTL) $(LIBREADLINE) $(PTHREAD_LIBS)
-lctl_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
+lctl_SOURCES = lustre_lfsck.c portals.c debug.c obd.c lustre_cfg.c lctl.c obdctl.h lsnapshot.c
+lctl_LDADD :=  liblustreapi.a $(LIBCFS) $(LIBREADLINE) $(PTHREAD_LIBS)
+lctl_DEPENDENCIES := $(LIBCFS) liblustreapi.a
 
 lfs_SOURCES = lfs.c
-lfs_LDADD := liblustreapi.a $(LIBPTLCTL) $(LIBREADLINE)
-lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
+lfs_LDADD := liblustreapi.a $(LIBCFS) $(LIBREADLINE)
+lfs_DEPENDENCIES := $(LIBCFS) liblustreapi.a
 
-lustre_rsync_SOURCES = lustre_rsync.c obd.c lustre_cfg.c lustre_rsync.h
-lustre_rsync_LDADD :=  liblustreapi.a $(LIBPTLCTL) $(LIBREADLINE) $(PTHREAD_LIBS)
-lustre_rsync_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
+lustre_rsync_SOURCES = lustre_rsync.c lustre_rsync.h
+lustre_rsync_LDADD :=  liblustreapi.a $(LIBCFS) $(LIBREADLINE) $(PTHREAD_LIBS)
+lustre_rsync_DEPENDENCIES := $(LIBCFS) liblustreapi.a
 
 lshowmount_SOURCES = lshowmount.c nidlist.c nidlist.h
 lshowmount_LDADD :=  liblustreapi.a
@@ -134,8 +132,8 @@ libiam_a_SOURCES = libiam.c
 endif
 
 llog_reader_SOURCES = llog_reader.c
-llog_reader_LDADD := $(LIBPTLCTL) liblustreapi.a
-llog_reader_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
+llog_reader_LDADD := $(LIBCFS) liblustreapi.a
+llog_reader_DEPENDENCIES := $(LIBCFS) liblustreapi.a
 
 lr_reader_SOURCES = lr_reader.c
 
@@ -187,7 +185,7 @@ endif # LDISKFS_ENABLED
 mount_lustre_SOURCES = mount_lustre.c mount_utils.c mount_utils.h $(GSSSRC)
 mount_lustre_CPPFLAGS := ${MNTMODCFLAGS}
 mount_lustre_LDFLAGS  := ${MNTMODLDFLAGS}
-mount_lustre_LDADD    := $(LIBPTLCTL) $(SELINUX) $(LDLIBMOUNT) $(PLUGIN_LIB) $(GSSLIB)
+mount_lustre_LDADD    := $(LIBCFS) $(SELINUX) $(LDLIBMOUNT) $(PLUGIN_LIB) $(GSSLIB)
 
 mkfs_lustre_SOURCES = mkfs_lustre.c mount_utils.c mount_utils.h $(GSSSRC)
 mkfs_lustre_CPPFLAGS := -UTUNEFS ${MNTMODCFLAGS}
@@ -200,12 +198,12 @@ tunefs_lustre_LDFLAGS  := ${MNTMODLDFLAGS}
 tunefs_lustre_LDADD    := $(mkfs_lustre_LDADD)
 
 l_getidentity_SOURCES = l_getidentity.c
-l_getidentity_LDADD := $(LIBPTLCTL)
-l_getidentity_DEPENDENCIES := $(LIBPTLCTL)
+l_getidentity_LDADD := $(LIBCFS)
+l_getidentity_DEPENDENCIES := $(LIBCFS)
 
 lhsmtool_posix_SOURCES = lhsmtool_posix.c
-lhsmtool_posix_LDADD := liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS)
-lhsmtool_posix_DEPENDENCIES := liblustreapi.a $(LIBPTLCTL)
+lhsmtool_posix_LDADD := liblustreapi.a $(LIBCFS) $(PTHREAD_LIBS)
+lhsmtool_posix_DEPENDENCIES := liblustreapi.a $(LIBCFS)
 
 wirecheck_SOURCES = wirecheck.c
 wirecheck_CPPFLAGS := -DCC="\"$(CC)\""
similarity index 100%
rename from lnet/utils/debug.c
rename to lustre/utils/debug.c
index c949ae8..fc971dc 100644 (file)
 #include <time.h>
 #include <sys/xattr.h>
 #include <linux/types.h>
+#include <linux/lustre/lustre_ioctl.h>
 
+#include <libcfs/util/ioctl.h>
 #include <libcfs/util/string.h>
 #include <libcfs/util/parser.h>
 #include <linux/lnet/libcfs_debug.h>
 
 /* Not used; declared for fulfilling obd.c's dependency. */
 command_t cmdlist[0];
-extern int obd_initialize(int argc, char **argv);
 
 /* Information for processing a changelog record. This structure is
    allocated on the heap instead of allocating large variables on the
@@ -1792,10 +1793,8 @@ int main(int argc, char *argv[])
 
         /* This plumbing is needed for some of the ioctls behind
            llapi calls to work. */
-        if (obd_initialize(argc, argv) < 0) {
-                fprintf(stderr, "obd_initialize failed.\n");
-                exit(-1);
-        }
+       register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH,
+                        OBD_DEV_MAJOR, OBD_DEV_MINOR);
 
         rc = lr_locate_rsync();
         if (use_rsync && rc != 0) {
similarity index 100%
rename from lnet/utils/portals.c
rename to lustre/utils/portals.c