From 29cfe643cbcf7826375a3d52ff1865706a35bc38 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 28 Jun 2019 22:51:37 +0530 Subject: libglusterfs: remove dependency of rpc Goal: 'libglusterfs' files shouldn't have any dependency outside of the tree, specially the header files, shouldn't have '#include' from outside the tree. Fixes: * Had to introduce libglusterd so, methods and structures required for only mgmt/glusterd, and cli/ are separated from 'libglusterfs/' * Remove rpc/xdr/gen from build, which was used mainly so dependency for libglusterfs could be properly satisfied. * Move rpcsvc_auth_data to client_t.h, so all dependencies could be handled. Updates: bz#1636297 Change-Id: I0e80243a5a3f4615e6fac6e1b947ad08a9363fce Signed-off-by: Amar Tumballi --- .gitignore | 1 - Makefile.am | 5 +- cli/src/Makefile.am | 10 ++-- cli/src/cli.h | 1 + configure.ac | 3 +- libglusterd/Makefile.am | 3 ++ libglusterd/src/Makefile.am | 31 ++++++++++++ libglusterd/src/gd-common-utils.c | 78 +++++++++++++++++++++++++++++++ libglusterd/src/gd-common-utils.h | 28 +++++++++++ libglusterd/src/libglusterd.sym | 2 + libglusterfs/src/Makefile.am | 10 ++-- libglusterfs/src/client_t.c | 14 +++--- libglusterfs/src/common-utils.c | 68 --------------------------- libglusterfs/src/glusterfs/client_t.h | 21 ++++++--- libglusterfs/src/glusterfs/common-utils.h | 5 -- libglusterfs/src/libglusterfs.sym | 2 - rpc/rpc-lib/src/rpcsvc.h | 11 ++--- rpc/xdr/gen/Makefile.am | 54 --------------------- rpc/xdr/src/Makefile.am | 45 ++++++++++++++++-- xlators/debug/io-stats/src/io-stats.c | 32 ++++++++----- xlators/mgmt/glusterd/src/Makefile.am | 11 ++++- xlators/mgmt/glusterd/src/glusterd.h | 2 + xlators/protocol/server/src/server.c | 1 - xlators/storage/posix/src/posix-helpers.c | 1 - 24 files changed, 255 insertions(+), 184 deletions(-) create mode 100644 libglusterd/Makefile.am create mode 100644 libglusterd/src/Makefile.am create mode 100644 libglusterd/src/gd-common-utils.c create mode 100644 libglusterd/src/gd-common-utils.h create mode 100644 libglusterd/src/libglusterd.sym delete mode 100644 rpc/xdr/gen/Makefile.am diff --git a/.gitignore b/.gitignore index e9e35b6809e..0f79471d64c 100644 --- a/.gitignore +++ b/.gitignore @@ -95,7 +95,6 @@ libglusterfs/src/cli1-xdr.h libglusterfs/src/protocol-common.h libtool # copied XDR for cyclic libglusterfs <-> rpc-header dependency -rpc/xdr/gen/*.x run-tests.sh !tests/basic/fuse/Makefile !tests/basic/gfapi/Makefile diff --git a/Makefile.am b/Makefile.am index e0c795f418f..aa0ca5c2a04 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,8 +9,9 @@ EXTRA_DIST = autogen.sh \ contrib/umountd \ $(shell find $(top_srcdir)/tests -type f -print) -SUBDIRS = $(ARGP_STANDALONE_DIR) rpc/xdr/gen libglusterfs rpc api xlators \ - glusterfsd $(FUSERMOUNT_SUBDIR) doc extras cli heal \ + +SUBDIRS = $(ARGP_STANDALONE_DIR) libglusterfs rpc libglusterd api \ + glusterfsd xlators $(FUSERMOUNT_SUBDIR) doc extras cli heal \ @SYNCDAEMON_SUBDIR@ @UMOUNTD_SUBDIR@ tools events pkgconfigdir = @pkgconfigdir@ diff --git a/cli/src/Makefile.am b/cli/src/Makefile.am index 3e7511fe1b7..cfbfca450c5 100644 --- a/cli/src/Makefile.am +++ b/cli/src/Makefile.am @@ -5,6 +5,7 @@ gluster_SOURCES = cli.c registry.c input.c cli-cmd.c cli-rl.c cli-cmd-global.c \ cli-cmd-system.c cli-cmd-misc.c cli-xml-output.c cli-quotad-client.c cli-cmd-snapshot.c gluster_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD) \ + $(top_builddir)/libglusterd/src/libglusterd.la \ $(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(XML_LIBS) @@ -13,9 +14,9 @@ gluster_LDFLAGS = $(GF_LDFLAGS) noinst_HEADERS = cli.h cli-mem-types.h cli-cmd.h cli-quotad-client.h AM_CPPFLAGS = $(GF_CPPFLAGS) \ - -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src\ - -I$(top_srcdir)/rpc/xdr/src\ - -I$(top_builddir)/rpc/xdr/src\ + -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src \ + -I$(top_srcdir)/rpc/xdr/src -I$(top_srcdir)/libglusterd/src \ + -I$(top_builddir)/rpc/xdr/src \ -DDATADIR=\"$(localstatedir)\" \ -DCONFDIR=\"$(sysconfdir)/glusterfs\" \ -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\"\ @@ -28,5 +29,8 @@ CLEANFILES = $(top_builddir)/libglusterfs/src/libglusterfs.la: $(MAKE) -C $(top_builddir)/libglusterfs/src/ all +$(top_builddir)/libglusterfs/src/libglusterd.la: + $(MAKE) -C $(top_builddir)/libglusterd/src/ all + install-data-hook: $(mkdir_p) $(DESTDIR)$(localstatedir)/run/gluster diff --git a/cli/src/cli.h b/cli/src/cli.h index 7166991a7ff..4e008ffe878 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -17,6 +17,7 @@ #include #include "cli1-xdr.h" +#include "gd-common-utils.h" #if (HAVE_LIB_XML) #include diff --git a/configure.ac b/configure.ac index 3e0b78d9455..7bfe018bfd7 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,8 @@ AC_CONFIG_HEADERS([config.h site.h]) AC_CONFIG_FILES([Makefile libglusterfs/Makefile libglusterfs/src/Makefile + libglusterd/Makefile + libglusterd/src/Makefile geo-replication/src/peer_gsec_create geo-replication/src/peer_mountbroker geo-replication/src/peer_mountbroker.py @@ -44,7 +46,6 @@ AC_CONFIG_FILES([Makefile rpc/rpc-transport/socket/src/Makefile rpc/xdr/Makefile rpc/xdr/src/Makefile - rpc/xdr/gen/Makefile xlators/Makefile xlators/meta/Makefile xlators/meta/src/Makefile diff --git a/libglusterd/Makefile.am b/libglusterd/Makefile.am new file mode 100644 index 00000000000..a985f42a877 --- /dev/null +++ b/libglusterd/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = src + +CLEANFILES = diff --git a/libglusterd/src/Makefile.am b/libglusterd/src/Makefile.am new file mode 100644 index 00000000000..684d2bac96b --- /dev/null +++ b/libglusterd/src/Makefile.am @@ -0,0 +1,31 @@ +libglusterd_la_CFLAGS = $(GF_CFLAGS) $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \ + -DDATADIR=\"$(localstatedir)\" + +libglusterd_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \ + -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \ + -DXLATORPARENTDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)\" \ + -DXXH_NAMESPACE=GF_ -D__USE_LARGEFILE64 \ + -I$(CONTRIBDIR)/rbtree \ + -I$(CONTRIBDIR)/libexecinfo ${ARGP_STANDALONE_CPPFLAGS} \ + -DSBIN_DIR=\"$(sbindir)\" -I$(CONTRIBDIR)/timer-wheel \ + -I$(CONTRIBDIR)/xxhash \ + -I$(top_srcdir)/rpc/xdr/src -I$(top_builddir)/rpc/xdr/src \ + -I$(top_srcdir)/rpc/rpc-lib/src/ + +libglusterd_la_LIBADD = $(ZLIB_LIBS) $(MATH_LIB) $(UUID_LIBS) +libglusterd_la_LDFLAGS = -version-info $(LIBGLUSTERFS_LT_VERSION) $(GF_LDFLAGS) \ + -export-symbols $(top_srcdir)/libglusterd/src/libglusterd.sym + +lib_LTLIBRARIES = libglusterd.la + +libglusterd_la_SOURCES = gd-common-utils.c + +libglusterd_la_HEADERS = gd-common-utils.h + +libglusterd_ladir = $(includedir)/glusterfs + +noinst_HEADERS = gd-common-utils.h + +EXTRA_DIST = libglusterd.sym + +CLEANFILES = diff --git a/libglusterd/src/gd-common-utils.c b/libglusterd/src/gd-common-utils.c new file mode 100644 index 00000000000..243fab215e6 --- /dev/null +++ b/libglusterd/src/gd-common-utils.c @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#include "gd-common-utils.h" +#include "cli1-xdr.h" + +int +get_vol_type(int type, int dist_count, int brick_count) +{ + if ((type != GF_CLUSTER_TYPE_TIER) && (type > 0) && + (dist_count < brick_count)) + type = type + GF_CLUSTER_TYPE_MAX - 1; + + return type; +} + +char * +get_struct_variable(int mem_num, gf_gsync_status_t *sts_val) +{ + switch (mem_num) { + case 0: + return (sts_val->node); + case 1: + return (sts_val->master); + case 2: + return (sts_val->brick); + case 3: + return (sts_val->slave_user); + case 4: + return (sts_val->slave); + case 5: + return (sts_val->slave_node); + case 6: + return (sts_val->worker_status); + case 7: + return (sts_val->crawl_status); + case 8: + return (sts_val->last_synced); + case 9: + return (sts_val->entry); + case 10: + return (sts_val->data); + case 11: + return (sts_val->meta); + case 12: + return (sts_val->failures); + case 13: + return (sts_val->checkpoint_time); + case 14: + return (sts_val->checkpoint_completed); + case 15: + return (sts_val->checkpoint_completion_time); + case 16: + return (sts_val->brick_host_uuid); + case 17: + return (sts_val->last_synced_utc); + case 18: + return (sts_val->checkpoint_time_utc); + case 19: + return (sts_val->checkpoint_completion_time_utc); + case 20: + return (sts_val->slavekey); + case 21: + return (sts_val->session_slave); + default: + goto out; + } + +out: + return NULL; +} diff --git a/libglusterd/src/gd-common-utils.h b/libglusterd/src/gd-common-utils.h new file mode 100644 index 00000000000..b9bb4f956fe --- /dev/null +++ b/libglusterd/src/gd-common-utils.h @@ -0,0 +1,28 @@ +/* + Copyright (c) 2019 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#ifndef _GD_COMMON_UTILS_H +#define _GD_COMMON_UTILS_H + +#include +#include +#include +#include + +#include "protocol-common.h" +#include "rpcsvc.h" + +int +get_vol_type(int type, int dist_count, int brick_count); + +char * +get_struct_variable(int mem_num, gf_gsync_status_t *sts_val); + +#endif /* _GD_COMMON_UTILS_H */ diff --git a/libglusterd/src/libglusterd.sym b/libglusterd/src/libglusterd.sym new file mode 100644 index 00000000000..45969a87c12 --- /dev/null +++ b/libglusterd/src/libglusterd.sym @@ -0,0 +1,2 @@ +get_vol_type +get_struct_variable diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index 12fdc8e64b0..df4c4678a6e 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -7,8 +7,7 @@ libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \ -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \ -DXLATORPARENTDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)\" \ -DXXH_NAMESPACE=GF_ -D__USE_LARGEFILE64 \ - -I$(top_srcdir)/rpc/xdr/src/ -I$(top_builddir)/rpc/xdr/src/ \ - -I$(top_srcdir)/rpc/rpc-lib/src/ -I$(CONTRIBDIR)/rbtree \ + -I$(CONTRIBDIR)/rbtree \ -I$(CONTRIBDIR)/libexecinfo ${ARGP_STANDALONE_CPPFLAGS} \ -DSBIN_DIR=\"$(sbindir)\" -I$(CONTRIBDIR)/timer-wheel \ -I$(CONTRIBDIR)/xxhash @@ -40,12 +39,9 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \ throttle-tbf.c monitoring.c async.c nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c defaults.c -nodist_libglusterfs_la_HEADERS = y.tab.h protocol-common.h +nodist_libglusterfs_la_HEADERS = y.tab.h -BUILT_SOURCES = graph.lex.c defaults.c eventtypes.h protocol-common.h - -protocol-common.h: $(top_srcdir)/rpc/rpc-lib/src/protocol-common.h - cp $(top_srcdir)/rpc/rpc-lib/src/protocol-common.h . +BUILT_SOURCES = graph.lex.c defaults.c eventtypes.h libglusterfs_la_HEADERS = glusterfs/common-utils.h glusterfs/defaults.h \ glusterfs/default-args.h glusterfs/dict.h glusterfs/glusterfs.h \ diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index e875c8b6b69..871fea6413c 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -13,7 +13,6 @@ #include "glusterfs/statedump.h" #include "glusterfs/client_t.h" #include "glusterfs/list.h" -#include "rpcsvc.h" #include "glusterfs/libglusterfs-messages.h" static int @@ -153,7 +152,7 @@ gf_client_clienttable_destroy(clienttable_t *clienttable) * as long as ref.bind is > 0 client should be alive. */ client_t * -gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, +gf_client_get(xlator_t *this, client_auth_data_t *cred, char *client_uid, char *subdir_mount) { client_t *client = NULL; @@ -181,11 +180,10 @@ gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, * if auth was used, matching auth flavour and data */ if (strcmp(client_uid, client->client_uid) == 0 && - (cred->flavour != AUTH_NONE && - (cred->flavour == client->auth.flavour && - (size_t)cred->datalen == client->auth.len && - memcmp(cred->authdata, client->auth.data, client->auth.len) == - 0))) { + (cred->flavour && (cred->flavour == client->auth.flavour && + (size_t)cred->datalen == client->auth.len && + memcmp(cred->authdata, client->auth.data, + client->auth.len) == 0))) { GF_ATOMIC_INC(client->bind); goto unlock; } @@ -227,7 +225,7 @@ gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, GF_ATOMIC_INIT(client->fd_cnt, 0); client->auth.flavour = cred->flavour; - if (cred->flavour != AUTH_NONE) { + if (cred->flavour) { client->auth.data = GF_MALLOC(cred->datalen, gf_common_mt_client_t); if (client->auth.data == NULL) { GF_FREE(client->scratch_ctx.ctx); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index df30507e3ae..360bc222c7e 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -45,13 +45,11 @@ #include "glusterfs/stack.h" #include "glusterfs/lkowner.h" #include "glusterfs/syscall.h" -#include "cli1-xdr.h" #include "glusterfs/globals.h" #define XXH_INLINE_ALL #include "xxhash.h" #include #include "glusterfs/libglusterfs-messages.h" -#include "protocol-common.h" #ifdef __FreeBSD__ #include #undef BIT_SET @@ -2984,16 +2982,6 @@ out: return result; } -int -get_vol_type(int type, int dist_count, int brick_count) -{ - if ((type != GF_CLUSTER_TYPE_TIER) && (type > 0) && - (dist_count < brick_count)) - type = type + GF_CLUSTER_TYPE_MAX - 1; - - return type; -} - int validate_brick_name(char *brick) { @@ -5253,62 +5241,6 @@ glusterfs_compute_sha256(const unsigned char *content, size_t size, return 0; } -char * -get_struct_variable(int mem_num, gf_gsync_status_t *sts_val) -{ - switch (mem_num) { - case 0: - return (sts_val->node); - case 1: - return (sts_val->master); - case 2: - return (sts_val->brick); - case 3: - return (sts_val->slave_user); - case 4: - return (sts_val->slave); - case 5: - return (sts_val->slave_node); - case 6: - return (sts_val->worker_status); - case 7: - return (sts_val->crawl_status); - case 8: - return (sts_val->last_synced); - case 9: - return (sts_val->entry); - case 10: - return (sts_val->data); - case 11: - return (sts_val->meta); - case 12: - return (sts_val->failures); - case 13: - return (sts_val->checkpoint_time); - case 14: - return (sts_val->checkpoint_completed); - case 15: - return (sts_val->checkpoint_completion_time); - case 16: - return (sts_val->brick_host_uuid); - case 17: - return (sts_val->last_synced_utc); - case 18: - return (sts_val->checkpoint_time_utc); - case 19: - return (sts_val->checkpoint_completion_time_utc); - case 20: - return (sts_val->slavekey); - case 21: - return (sts_val->session_slave); - default: - goto out; - } - -out: - return NULL; -} - /* * Safe wrapper function for strncpy. * This wrapper makes sure that when there is no null byte among the first n in * source srting for strncpy function call, the string placed in dest will be diff --git a/libglusterfs/src/glusterfs/client_t.h b/libglusterfs/src/glusterfs/client_t.h index 8ef3665a9c2..6bc03271eed 100644 --- a/libglusterfs/src/glusterfs/client_t.h +++ b/libglusterfs/src/glusterfs/client_t.h @@ -15,6 +15,17 @@ #include "glusterfs/locking.h" /* for gf_lock_t, not included by glusterfs.h */ #include "glusterfs/atomic.h" /* for gf_atomic_t */ +/* auth_data structure is required by RPC layer. But as it is also used in + * client_t structure validation, comparision, it is critical that it is defined + * in the larger scope of libglusterfs, instead of libgfrpc. With this change, + * even RPC will use this structure */ +#define GF_CLIENTT_AUTH_BYTES 400 +typedef struct client_auth_data { + int flavour; + int datalen; + char authdata[GF_CLIENTT_AUTH_BYTES]; +} client_auth_data_t; + struct client_ctx { void *ctx_key; void *ctx_value; @@ -78,12 +89,6 @@ typedef struct clienttable clienttable_t; */ #define GF_CLIENTENTRY_ALLOCATED -2 -struct rpcsvc_auth_data; - -client_t * -gf_client_get(xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, - char *subdir_mount); - void gf_client_put(client_t *client, gf_boolean_t *detached); @@ -138,4 +143,8 @@ gf_client_dump_inodes(xlator_t *this); int gf_client_disconnect(client_t *client); +client_t * +gf_client_get(xlator_t *this, client_auth_data_t *cred, char *client_uid, + char *subdir_mount); + #endif /* _CLIENT_T_H */ diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h index b184031e565..a11c3a5f458 100644 --- a/libglusterfs/src/glusterfs/common-utils.h +++ b/libglusterfs/src/glusterfs/common-utils.h @@ -42,7 +42,6 @@ trap(void); #include "glusterfs/compat-uuid.h" #include "glusterfs/iatt.h" #include "glusterfs/libglusterfs-messages.h" -#include "protocol-common.h" #define STRINGIFY(val) #val #define TOSTRING(val) STRINGIFY(val) @@ -994,8 +993,6 @@ gf_is_str_int(const char *value); char *gf_uint64_2human_readable(uint64_t); int -get_vol_type(int type, int dist_count, int brick_count); -int validate_brick_name(char *brick); char * get_host_name(char *word, char **host); @@ -1147,8 +1144,6 @@ gf_getgrouplist(const char *user, gid_t group, gid_t **groups); int glusterfs_compute_sha256(const unsigned char *content, size_t size, char *sha256_hash); -char * -get_struct_variable(int mem_num, gf_gsync_status_t *sts_val); char * gf_strncpy(char *dest, const char *src, const size_t dest_size); diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym index 48548c4ce50..5d96a4c6386 100644 --- a/libglusterfs/src/libglusterfs.sym +++ b/libglusterfs/src/libglusterfs.sym @@ -547,8 +547,6 @@ get_file_mtime get_host_name get_mem_size get_path_name -get_struct_variable -get_vol_type get_xlator_by_name get_xlator_by_type gf_array_insertionsort diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index d9052392d47..f6a02d6759f 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -22,6 +22,7 @@ #include #include #include +#include #ifndef MAX_IOVEC #define MAX_IOVEC 16 @@ -142,12 +143,6 @@ struct rpcsvc_config { int max_block_size; }; -typedef struct rpcsvc_auth_data { - int flavour; - int datalen; - char authdata[GF_MAX_AUTH_BYTES]; -} rpcsvc_auth_data_t; - #define rpcsvc_auth_flavour(au) ((au).flavour) typedef struct drc_client drc_client_t; @@ -228,14 +223,14 @@ struct rpcsvc_request { size_t payloadsize; /* The credentials extracted from the rpc request */ - rpcsvc_auth_data_t cred; + client_auth_data_t cred; /* The verified extracted from the rpc request. In request side * processing this contains the verifier sent by the client, on reply * side processing, it is filled with the verified that will be * sent to the client. */ - rpcsvc_auth_data_t verf; + client_auth_data_t verf; /* Container for a RPC program wanting to store a temp * request-specific item. */ diff --git a/rpc/xdr/gen/Makefile.am b/rpc/xdr/gen/Makefile.am deleted file mode 100644 index 3e799b4c644..00000000000 --- a/rpc/xdr/gen/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -if BUILD_GNFS - NFS_XDRS = nlm4-xdr.x nsm-xdr.x acl3-xdr.x mount3udp.x -endif - -XDRGENFILES = glusterfs3-xdr.x glusterfs4-xdr.x cli1-xdr.x \ - rpc-common-xdr.x glusterd1-xdr.x portmap-xdr.x \ - changelog-xdr.x ${NFS_XDRS} - -XDRHEADERS = $(XDRGENFILES:.x=.h) -XDRSOURCES = $(XDRGENFILES:.x=.c) - -CLEANFILES = $(XDRSOURCES) $(XDRHEADERS) $(XDRGENFILES) - -# trick automake into doing BUILT_SOURCES magic -BUILT_SOURCES = $(XDRHEADERS) $(XDRSOURCES) - -xdrsrc=$(top_srcdir)/rpc/xdr/src -xdrdst=$(top_builddir)/rpc/xdr/src - -# make's dependency resolution may mean that it decides to run -# rpcgen again (unnecessarily), but as the .c file already exists, -# rpcgen will exit with an error, resulting in a build error. We -# could use a '-' (i.e. -@rpcgen ...) and suffer with noisy warnings -# in the build. Or we do this crufty thing instead. -$(XDRSOURCES): $(XDRGENFILES) - @if [ ! -e $(xdrdst)/$@ -o $(@:.c=.x) -nt $(xdrdst)/$@ ]; then \ - rpcgen -c -o $(xdrdst)/$@ $(@:.c=.x) ;\ - fi - -# d*mn sed in netbsd6 doesn't do -i (inline) -# (why are we still running smoke on netbsd6 and not netbsd7?) -$(XDRHEADERS): $(XDRGENFILES) - @if [ ! -e $(xdrdst)/$@ -o $(@:.h=.x) -nt $(xdrdst)/$@ ]; then \ - rpcgen -h -o $(@:.h=.tmp) $(@:.h=.x) && \ - sed -e '/#ifndef/ s/-/_/g' -e '/#define/ s/-/_/g' \ - -e '/#endif/ s/-/_/' -e 's/TMP_/H_/g' \ - $(@:.h=.tmp) > $(xdrdst)/$@ && \ - rm -f $(@:.h=.tmp) ; \ - fi - - -# link .x files when doing out-of-tree builds -# have to use .PHONY here to force it; all versions of make -# will think the file already exists "here" by virtue of the -# VPATH. And we have to have the .x file in $cwd in order to -# have rpcgen generate "nice" #include directives -# i.e. (nice): -# #include "acl3-xdr.h" -# versus (not nice): -# #include "../../../../foo/src/rpc/xdr/src/acl3-xdr.h" -.PHONY : $(XDRGENFILES) -$(XDRGENFILES): - @if [ ! -e $@ ]; then ln -s $(xdrsrc)/$@ . ; fi; - diff --git a/rpc/xdr/src/Makefile.am b/rpc/xdr/src/Makefile.am index 44a72cac53b..05f4167076f 100644 --- a/rpc/xdr/src/Makefile.am +++ b/rpc/xdr/src/Makefile.am @@ -36,8 +36,45 @@ nodist_libgfxdr_la_HEADERS = $(XDRHEADERS) libgfxdr_ladir = $(includedir)/glusterfs/rpc -CLEANFILES = $(XDRSOURCES) $(XDRHEADERS) +CLEANFILES = $(XDRSOURCES) $(XDRHEADERS) $(XDRGENFILES) -# Generate the .c and .h symlinks from the ../gen/*.x files -$(XDRSOURCES) $(XDRHEADERS): - $(MAKE) -C ../gen $^ +# trick automake into doing BUILT_SOURCES magic +BUILT_SOURCES = $(XDRHEADERS) $(XDRSOURCES) + +xdrsrc=$(top_srcdir)/rpc/xdr/src +xdrdst=$(top_builddir)/rpc/xdr/src + +# make's dependency resolution may mean that it decides to run +# rpcgen again (unnecessarily), but as the .c file already exists, +# rpcgen will exit with an error, resulting in a build error. We +# could use a '-' (i.e. -@rpcgen ...) and suffer with noisy warnings +# in the build. Or we do this crufty thing instead. +$(XDRSOURCES): $(XDRGENFILES) + @if [ ! -e $(xdrdst)/$@ -o $(@:.c=.x) -nt $(xdrdst)/$@ ]; then \ + rpcgen -c -o $(xdrdst)/$@ $(@:.c=.x) ;\ + fi + +# d*mn sed in netbsd6 doesn't do -i (inline) +# (why are we still running smoke on netbsd6 and not netbsd7?) +$(XDRHEADERS): $(XDRGENFILES) + @if [ ! -e $(xdrdst)/$@ -o $(@:.h=.x) -nt $(xdrdst)/$@ ]; then \ + rpcgen -h -o $(@:.h=.tmp) $(@:.h=.x) && \ + sed -e '/#ifndef/ s/-/_/g' -e '/#define/ s/-/_/g' \ + -e '/#endif/ s/-/_/' -e 's/TMP_/H_/g' \ + $(@:.h=.tmp) > $(xdrdst)/$@ && \ + rm -f $(@:.h=.tmp) ; \ + fi + + +# link .x files when doing out-of-tree builds +# have to use .PHONY here to force it; all versions of make +# will think the file already exists "here" by virtue of the +# VPATH. And we have to have the .x file in $cwd in order to +# have rpcgen generate "nice" #include directives +# i.e. (nice): +# #include "acl3-xdr.h" +# versus (not nice): +# #include "../../../../foo/src/rpc/xdr/src/acl3-xdr.h" +.PHONY : $(XDRGENFILES) +$(XDRGENFILES): + @if [ ! -e $@ ]; then ln -s $(xdrsrc)/$@ . ; fi; diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index b9422c0f335..71bd03c0123 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -34,7 +34,6 @@ #include #include #include -#include "cli1-xdr.h" #include #include #include @@ -67,6 +66,17 @@ typedef enum { IOS_STATS_THRU_MAX, } ios_stats_thru_t; +/* This is same as gf1_cli_info_op */ +/* had to be defined here again, so we have modularity between + xdr, xlator, and library functions */ +typedef enum ios_info_op { + GF_IOS_INFO_NONE = 0, + GF_IOS_INFO_ALL = 1, + GF_IOS_INFO_INCREMENTAL = 2, + GF_IOS_INFO_CUMULATIVE = 3, + GF_IOS_INFO_CLEAR = 4, +} ios_info_op_t; + struct ios_stat_lat { struct timeval time; double throughput; @@ -1590,7 +1600,7 @@ ios_global_stats_clear(struct ios_global_stats *stats, struct timeval *now) } int -io_stats_dump(xlator_t *this, struct ios_dump_args *args, gf1_cli_info_op op, +io_stats_dump(xlator_t *this, struct ios_dump_args *args, ios_info_op_t op, gf_boolean_t is_peek) { struct ios_conf *conf = NULL; @@ -1609,10 +1619,10 @@ io_stats_dump(xlator_t *this, struct ios_dump_args *args, gf1_cli_info_op op, gettimeofday(&now, NULL); LOCK(&conf->lock); { - if (op == GF_CLI_INFO_ALL || op == GF_CLI_INFO_CUMULATIVE) + if (op == GF_IOS_INFO_ALL || op == GF_IOS_INFO_CUMULATIVE) cumulative = conf->cumulative; - if (op == GF_CLI_INFO_ALL || op == GF_CLI_INFO_INCREMENTAL) { + if (op == GF_IOS_INFO_ALL || op == GF_IOS_INFO_INCREMENTAL) { incremental = conf->incremental; increment = conf->increment; @@ -1625,10 +1635,10 @@ io_stats_dump(xlator_t *this, struct ios_dump_args *args, gf1_cli_info_op op, } UNLOCK(&conf->lock); - if (op == GF_CLI_INFO_ALL || op == GF_CLI_INFO_CUMULATIVE) + if (op == GF_IOS_INFO_ALL || op == GF_IOS_INFO_CUMULATIVE) io_stats_dump_global(this, &cumulative, &now, -1, args); - if (op == GF_CLI_INFO_ALL || op == GF_CLI_INFO_INCREMENTAL) + if (op == GF_IOS_INFO_ALL || op == GF_IOS_INFO_INCREMENTAL) io_stats_dump_global(this, &incremental, &now, increment, args); return 0; @@ -3031,7 +3041,7 @@ conditional_dump(dict_t *dict, char *key, data_t *value, void *data) } else { (void)ios_dump_args_init(&args, IOS_DUMP_TYPE_FILE, logfp); } - io_stats_dump(this, &args, GF_CLI_INFO_ALL, _gf_false); + io_stats_dump(this, &args, GF_IOS_INFO_ALL, _gf_false); fclose(logfp); return 0; } @@ -3134,7 +3144,7 @@ _ios_dump_thread(xlator_t *this) stats_logfp = fopen(stats_filename, "w+"); if (stats_logfp) { (void)ios_dump_args_init(&args, conf->dump_format, stats_logfp); - io_stats_dump(this, &args, GF_CLI_INFO_ALL, _gf_false); + io_stats_dump(this, &args, GF_IOS_INFO_ALL, _gf_false); fclose(stats_logfp); log_stats_fopen_failure = _gf_true; } else if (log_stats_fopen_failure) { @@ -4105,8 +4115,8 @@ notify(xlator_t *this, int32_t event, void *data, ...) } } else { ret = dict_get_int32(dict, "info-op", &op); - if (ret || op < GF_CLI_INFO_ALL || GF_CLI_INFO_CLEAR < op) - op = GF_CLI_INFO_ALL; + if (ret || op < GF_IOS_INFO_ALL || GF_IOS_INFO_CLEAR < op) + op = GF_IOS_INFO_ALL; ret = dict_set_int32(output, "info-op", op); if (ret) { @@ -4115,7 +4125,7 @@ notify(xlator_t *this, int32_t event, void *data, ...) goto out; } - if (GF_CLI_INFO_CLEAR == op) { + if (GF_IOS_INFO_CLEAR == op) { ret = io_stats_clear(this->private); if (ret) gf_log(this->name, GF_LOG_ERROR, diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am index 10f389faf59..3b051a0fec9 100644 --- a/xlators/mgmt/glusterd/src/Makefile.am +++ b/xlators/mgmt/glusterd/src/Makefile.am @@ -5,7 +5,9 @@ endif xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mgmt glusterd_la_CPPFLAGS = $(AM_CPPFLAGS) \ -DFILTERDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/filter\" \ - -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" + -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \ + -I$(top_srcdir)/libglusterd/src/ + glusterd_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \ glusterd-op-sm.c glusterd-utils.c glusterd-rpc-ops.c \ @@ -27,6 +29,7 @@ glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \ glusterd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ + $(top_builddir)/libglusterd/src/libglusterd.la \ $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(XML_LIBS) -lcrypto $(URCU_LIBS) $(URCU_CDS_LIBS) $(LIB_DL) @@ -52,7 +55,8 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ -I$(CONTRIBDIR)/mount -I$(CONTRIBDIR)/userspace-rcu \ -DSBIN_DIR=\"$(sbindir)\" -DDATADIR=\"$(localstatedir)\" \ -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\" \ - -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) + -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) \ + -I$(top_srcdir)/libglusterd/src/ AM_CFLAGS = -Wall $(GF_CFLAGS) $(URCU_CFLAGS) $(URCU_CDS_CFLAGS) $(XML_CFLAGS) @@ -70,3 +74,6 @@ if GF_INSTALL_GLUSTERD_WORKDIR (ln -sf $(DESTDIR)$(GLUSTERD_WORKDIR) $(sysconfdir)/glusterd) || true; endif endif + +$(top_builddir)/libglusterfs/src/libglusterd.la: + $(MAKE) -C $(top_builddir)/libglusterd/src/ all diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 00211da3b63..899bd0e357b 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -39,6 +39,8 @@ #include #include "glusterd-gfproxyd-svc.h" +#include "gd-common-utils.h" + #define GLUSTERD_TR_LOG_SIZE 50 #define GLUSTERD_QUORUM_TYPE_KEY "cluster.server-quorum-type" #define GLUSTERD_QUORUM_RATIO_KEY "cluster.server-quorum-ratio" diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index f79fe26641d..1e91ede0d58 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -22,7 +22,6 @@ #include #include "server-messages.h" #include "rpc-clnt.h" -#include "glusterfsd.h" rpcsvc_cbk_program_t server_cbk_prog = { .progname = "Gluster Callback", diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 688a60b4b28..828aa289a2f 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -48,7 +48,6 @@ #include #include "posix-gfid-path.h" #include -#include "glusterfsd.h" #include "glusterfs/syncop.h" #include "timer-wheel.h" #include -- cgit