From cc95b58e835a7c30bebef2cf930913ac8152997e Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 9 Oct 2017 10:37:14 -0400 Subject: [PATCH] LU-9897 utils: remove libcfsutils.a and libptlctl.a 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 Reviewed-on: https://review.whamcloud.com/28752 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- libcfs/libcfs/autoMakefile.am | 15 ++++++-------- lnet/utils/Makefile.am | 17 ++++++---------- lnet/utils/lnetconfig/Makefile.am | 10 ++++----- lnet/utils/{cyaml => lnetconfig}/cyaml.c | 0 lnet/utils/lnetconfig/liblnd.h | 2 +- lnet/utils/lnetconfig/liblnetconfig.c | 1 - lnet/utils/lnetconfig/liblnetconfig_lnd.c | 2 +- lnet/utils/lst.c | 16 ++++++++++----- lustre.spec.in | 2 -- lustre/utils/Makefile.am | 34 +++++++++++++++---------------- {lnet => lustre}/utils/debug.c | 0 lustre/utils/lustre_rsync.c | 9 ++++---- {lnet => lustre}/utils/portals.c | 0 13 files changed, 50 insertions(+), 58 deletions(-) rename lnet/utils/{cyaml => lnetconfig}/cyaml.c (100%) rename {lnet => lustre}/utils/debug.c (100%) rename {lnet => lustre}/utils/portals.c (100%) diff --git a/libcfs/libcfs/autoMakefile.am b/libcfs/libcfs/autoMakefile.am index 4165f54..dbb7cdb 100644 --- a/libcfs/libcfs/autoMakefile.am +++ b/libcfs/libcfs/autoMakefile.am @@ -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 diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am index 16047da..091f9da 100644 --- a/lnet/utils/Makefile.am +++ b/lnet/utils/Makefile.am @@ -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 diff --git a/lnet/utils/lnetconfig/Makefile.am b/lnet/utils/lnetconfig/Makefile.am index 7da6071..e50b13a 100644 --- a/lnet/utils/lnetconfig/Makefile.am +++ b/lnet/utils/lnetconfig/Makefile.am @@ -28,12 +28,12 @@ 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 = diff --git a/lnet/utils/cyaml/cyaml.c b/lnet/utils/lnetconfig/cyaml.c similarity index 100% rename from lnet/utils/cyaml/cyaml.c rename to lnet/utils/lnetconfig/cyaml.c diff --git a/lnet/utils/lnetconfig/liblnd.h b/lnet/utils/lnetconfig/liblnd.h index 1896d48..3dd6741 100644 --- a/lnet/utils/lnetconfig/liblnd.h +++ b/lnet/utils/lnetconfig/liblnd.h @@ -28,7 +28,7 @@ #include #include -#include "cyaml.h" +#include int lustre_net_show_tunables(struct cYAML *tunables, diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index b55576b..b372837 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -51,7 +51,6 @@ #include #include #include "liblnetconfig.h" -#include "cyaml.h" #define CONFIG_CMD "configure" #define UNCONFIG_CMD "unconfigure" diff --git a/lnet/utils/lnetconfig/liblnetconfig_lnd.c b/lnet/utils/lnetconfig/liblnetconfig_lnd.c index 5aa8787..c5f023c 100644 --- a/lnet/utils/lnetconfig/liblnetconfig_lnd.c +++ b/lnet/utils/lnetconfig/liblnetconfig_lnd.c @@ -31,8 +31,8 @@ #include #include #include +#include "liblnd.h" #include "liblnetconfig.h" -#include "cyaml.h" static int lustre_o2iblnd_show_tun(struct cYAML *lndparams, diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index ff8db84..e5e8abb 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -51,7 +51,9 @@ #include #include #include -#include +#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); diff --git a/lustre.spec.in b/lustre.spec.in index 855d435..65e9ad4 100644 --- a/lustre.spec.in +++ b/lustre.spec.in @@ -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} diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 82e7381..e4e64a3 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -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)\"" diff --git a/lnet/utils/debug.c b/lustre/utils/debug.c similarity index 100% rename from lnet/utils/debug.c rename to lustre/utils/debug.c diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index c949ae8..fc971dc 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -120,7 +120,9 @@ #include #include #include +#include +#include #include #include #include @@ -144,7 +146,6 @@ /* 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) { diff --git a/lnet/utils/portals.c b/lustre/utils/portals.c similarity index 100% rename from lnet/utils/portals.c rename to lustre/utils/portals.c -- 1.8.3.1