summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2014-12-19 16:36:25 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-12-28 22:59:36 -0800
commit41e0e325aa7733285733fb00230fdaafdc80c25a (patch)
tree38196c3a5cb83b1db9df1a9b311db990aabfb2bb /xlators/mgmt/glusterd
parentf7a8bd08c80a33a9e2459b47e203a8bc841abc54 (diff)
glusterd: Move statedump utils into a new file.
Change-Id: I1bf26c9d294e95f7b82cfc7a96f9d5575f5e0362 BUG: 1176770 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/9313 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/Makefile.am5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-statedump.c245
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-statedump.h23
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c223
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h9
5 files changed, 272 insertions, 233 deletions
diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am
index 913a2a70729..950fc17e712 100644
--- a/xlators/mgmt/glusterd/src/Makefile.am
+++ b/xlators/mgmt/glusterd/src/Makefile.am
@@ -10,7 +10,7 @@ glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \
glusterd-volume-ops.c glusterd-brick-ops.c glusterd-mountbroker.c \
glusterd-syncop.c glusterd-hooks.c glusterd-volume-set.c \
glusterd-locks.c glusterd-snapshot.c glusterd-mgmt-handler.c \
- glusterd-mgmt.c glusterd-peer-utils.c
+ glusterd-mgmt.c glusterd-peer-utils.c glusterd-statedump.c
glusterd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la \
@@ -24,7 +24,8 @@ noinst_HEADERS = glusterd.h glusterd-utils.h glusterd-op-sm.h \
glusterd-sm.h glusterd-store.h glusterd-mem-types.h \
glusterd-pmap.h glusterd-volgen.h glusterd-mountbroker.h \
glusterd-syncop.h glusterd-hooks.h glusterd-locks.h \
- glusterd-mgmt.h glusterd-messages.h glusterd-peer-utils.h
+ glusterd-mgmt.h glusterd-messages.h glusterd-peer-utils.h \
+ glusterd-statedump.h
AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
-I$(rpclibdir) -I$(CONTRIBDIR)/rbtree \
diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c
new file mode 100644
index 00000000000..e28624c6955
--- /dev/null
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c
@@ -0,0 +1,245 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ 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 _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "statedump.h"
+#include "glusterd.h"
+#include "glusterd-locks.h"
+
+
+
+static void
+glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *input_key, int index,
+ gf_boolean_t xpeers)
+{
+ char subkey[50] = {0,};
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+
+ strncpy (key, input_key, (GF_DUMP_MAX_BUF_LEN - 1));
+
+ snprintf (subkey, sizeof (subkey), "%s%d", key, index);
+
+ gf_proc_dump_build_key (key, subkey, "uuid");
+ gf_proc_dump_write (key, "%s",
+ uuid_utoa (peerinfo->uuid));
+
+ gf_proc_dump_build_key (key, subkey, "hostname");
+ gf_proc_dump_write (key, "%d", peerinfo->hostname);
+
+ gf_proc_dump_build_key (key, subkey, "port");
+ gf_proc_dump_write (key, "%d", peerinfo->port);
+
+ gf_proc_dump_build_key (key, subkey, "state");
+ gf_proc_dump_write (key, "%d", peerinfo->state.state);
+
+ gf_proc_dump_build_key (key, subkey, "quorum-action");
+ gf_proc_dump_write (key, "%d", peerinfo->quorum_action);
+
+ gf_proc_dump_build_key (key, subkey, "quorum-contrib");
+ gf_proc_dump_write (key, "%d",
+ peerinfo->quorum_contrib);
+
+ gf_proc_dump_build_key (key, subkey, "detaching");
+ gf_proc_dump_write (key, "%d", peerinfo->detaching);
+
+ gf_proc_dump_build_key (key, subkey, "locked");
+ gf_proc_dump_write (key, "%d", peerinfo->locked);
+
+}
+
+
+static void
+glusterd_dump_peer_rpcstat (glusterd_peerinfo_t *peerinfo, char *input_key,
+ int index)
+{
+ rpc_clnt_connection_t *conn = NULL;
+ int ret = -1;
+ rpc_clnt_t *rpc = NULL;
+ char rpcsvc_peername[RPCSVC_PEER_STRLEN] = {0,};
+ char subkey[50] = {0,};
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+
+ strncpy (key, input_key, (GF_DUMP_MAX_BUF_LEN - 1));
+
+ /* Dump the rpc connection statistics */
+ rpc = peerinfo->rpc;
+ if (rpc) {
+ conn = &rpc->conn;
+ snprintf (subkey, sizeof (subkey), "%s%d", key, index);
+ ret = rpcsvc_transport_peername (conn->trans,
+ (char *)&rpcsvc_peername,
+ sizeof (rpcsvc_peername));
+ if (!ret) {
+ gf_proc_dump_build_key (key, subkey, "rpc.peername");
+ gf_proc_dump_write (key, "%s", rpcsvc_peername);
+ }
+ gf_proc_dump_build_key (key, subkey, "rpc.connected");
+ gf_proc_dump_write (key, "%d", conn->connected);
+
+ gf_proc_dump_build_key (key, subkey, "rpc.total-bytes-read");
+ gf_proc_dump_write (key, "%"PRIu64,
+ conn->trans->total_bytes_read);
+
+ gf_proc_dump_build_key (key, subkey, "rpc.total-bytes-written");
+ gf_proc_dump_write (key, "%"PRIu64,
+ conn->trans->total_bytes_write);
+
+ gf_proc_dump_build_key (key, subkey, "rpc.ping_msgs_sent");
+ gf_proc_dump_write (key, "%"PRIu64, conn->pingcnt);
+
+ gf_proc_dump_build_key (key, subkey, "rpc.msgs_sent");
+ gf_proc_dump_write (key, "%"PRIu64, conn->msgcnt);
+ }
+
+}
+
+
+static void
+glusterd_dump_client_details (glusterd_conf_t *conf)
+{
+ rpc_transport_t *xprt = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char subkey[50] = {0,};
+ int index = 1;
+
+ pthread_mutex_lock (&conf->xprt_lock);
+ {
+ list_for_each_entry (xprt, &conf->xprt_list, list) {
+ snprintf (subkey, sizeof (subkey), "glusterd.client%d",
+ index);
+
+ gf_proc_dump_build_key (key, subkey, "identifier");
+ gf_proc_dump_write (key, "%s",
+ xprt->peerinfo.identifier);
+
+ gf_proc_dump_build_key (key, subkey, "volname");
+ gf_proc_dump_write (key, "%s",
+ xprt->peerinfo.volname);
+
+ gf_proc_dump_build_key (key, subkey, "max-op-version");
+ gf_proc_dump_write (key, "%u",
+ xprt->peerinfo.max_op_version);
+
+ gf_proc_dump_build_key (key, subkey, "min-op-version");
+ gf_proc_dump_write (key, "%u",
+ xprt->peerinfo.min_op_version);
+ index++;
+ }
+ }
+ pthread_mutex_unlock (&conf->xprt_lock);
+}
+
+
+/* The following function is just for dumping mgmt_v3_lock dictionary, any other
+ * dict passed to this API will not work */
+
+static void
+glusterd_dict_mgmt_v3_lock_statedump (dict_t *dict)
+{
+ int ret = 0;
+ int dumplen = 0;
+ data_pair_t *trav = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char dump[64*1024] = {0,};
+
+ if (!dict) {
+ gf_log_callingfn ("glusterd", GF_LOG_WARNING, "dict NULL");
+ goto out;
+ }
+ for (trav = dict->members_list; trav; trav = trav->next) {
+ if (strstr (trav->key, "debug.last-success-bt") != NULL) {
+ ret = snprintf (&dump[dumplen], sizeof(dump) - dumplen,
+ "\n\t%s:%s", trav->key,
+ trav->value->data);
+ } else {
+ ret = snprintf (&dump[dumplen], sizeof(dump) - dumplen,
+ "\n\t%s:%s", trav->key,
+ uuid_utoa (((glusterd_mgmt_v3_lock_obj *)
+ (trav->value->data))->lock_owner));
+ }
+ if ((ret == -1) || !ret)
+ return;
+ dumplen += ret;
+ }
+
+ if (dumplen) {
+ gf_proc_dump_build_key (key, "glusterd", "mgmt_v3_lock");
+ gf_proc_dump_write (key, "%s", dump);
+ }
+
+out:
+ return;
+}
+
+
+int
+glusterd_dump_priv (xlator_t *this)
+{
+ int index = 1;
+ glusterd_conf_t *priv = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char subkey[50] = {0,};
+ glusterd_peerinfo_t *peerinfo = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+
+ priv = this->private;
+ if (!priv)
+ return 0;
+
+ gf_proc_dump_build_key (key, "xlator.glusterd", "priv");
+ gf_proc_dump_add_section (key);
+
+ pthread_mutex_lock (&priv->mutex);
+ {
+ gf_proc_dump_build_key (key, "glusterd", "my-uuid");
+ gf_proc_dump_write (key, "%s", uuid_utoa (priv->uuid));
+
+ gf_proc_dump_build_key (key, "glusterd", "working-directory");
+ gf_proc_dump_write (key, "%s", priv->workdir);
+
+ gf_proc_dump_build_key (key, "glusterd", "max-op-version");
+ gf_proc_dump_write (key, "%d", GD_OP_VERSION_MAX);
+
+ gf_proc_dump_build_key (key, "glusterd", "min-op-version");
+ gf_proc_dump_write (key, "%d", GD_OP_VERSION_MIN);
+
+ gf_proc_dump_build_key (key, "glusterd", "current-op-version");
+ gf_proc_dump_write (key, "%d", priv->op_version);
+
+ gf_proc_dump_build_key (key, "glusterd", "ping-timeout");
+ gf_proc_dump_write (key, "%d", priv->ping_timeout);
+
+ gf_proc_dump_build_key (key, "glusterd", "shd.online");
+ gf_proc_dump_write (key, "%d", priv->shd->online);
+
+ gf_proc_dump_build_key (key, "glusterd", "nfs.online");
+ gf_proc_dump_write (key, "%d", priv->nfs->online);
+
+ gf_proc_dump_build_key (key, "glusterd", "quotad.online");
+ gf_proc_dump_write (key, "%d", priv->quotad->online);
+
+ GLUSTERD_DUMP_PEERS (&priv->peers, uuid_list, _gf_false);
+ GLUSTERD_DUMP_PEERS (&priv->xaction_peers, op_peers_list,
+ _gf_true);
+ glusterd_dump_client_details (priv);
+ glusterd_dict_mgmt_v3_lock_statedump(priv->mgmt_v3_lock);
+ dict_dump_to_statedump (priv->opts, "options", "glusterd");
+ }
+ pthread_mutex_unlock (&priv->mutex);
+
+out:
+ return 0;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.h b/xlators/mgmt/glusterd/src/glusterd-statedump.h
new file mode 100644
index 00000000000..9917560b542
--- /dev/null
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.h
@@ -0,0 +1,23 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ 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 _GLUSTERD_STATEDUMP_H_
+#define _GLUSTERD_STATEDUMP_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+
+int
+glusterd_dump_priv (xlator_t *this);
+#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 4f99a736dcf..98ac403a4c1 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -31,7 +31,7 @@
#include "compat.h"
#include "compat-errno.h"
#include "syscall.h"
-#include "statedump.h"
+#include "glusterd-statedump.h"
#include "glusterd-sm.h"
#include "glusterd-op-sm.h"
#include "glusterd-store.h"
@@ -277,227 +277,6 @@ glusterd_fetchsnap_notify (xlator_t *this)
return ret;
}
-void
-glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *input_key, int index,
- gf_boolean_t xpeers)
-{
- char subkey[50] = {0,};
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
-
- strncpy (key, input_key, (GF_DUMP_MAX_BUF_LEN - 1));
-
- snprintf (subkey, sizeof (subkey), "%s%d", key, index);
-
- gf_proc_dump_build_key (key, subkey, "uuid");
- gf_proc_dump_write (key, "%s",
- uuid_utoa (peerinfo->uuid));
-
- gf_proc_dump_build_key (key, subkey, "hostname");
- gf_proc_dump_write (key, "%d", peerinfo->hostname);
-
- gf_proc_dump_build_key (key, subkey, "port");
- gf_proc_dump_write (key, "%d", peerinfo->port);
-
- gf_proc_dump_build_key (key, subkey, "state");
- gf_proc_dump_write (key, "%d", peerinfo->state.state);
-
- gf_proc_dump_build_key (key, subkey, "quorum-action");
- gf_proc_dump_write (key, "%d", peerinfo->quorum_action);
-
- gf_proc_dump_build_key (key, subkey, "quorum-contrib");
- gf_proc_dump_write (key, "%d",
- peerinfo->quorum_contrib);
-
- gf_proc_dump_build_key (key, subkey, "detaching");
- gf_proc_dump_write (key, "%d", peerinfo->detaching);
-
- gf_proc_dump_build_key (key, subkey, "locked");
- gf_proc_dump_write (key, "%d", peerinfo->locked);
-
-}
-
-void
-glusterd_dump_peer_rpcstat (glusterd_peerinfo_t *peerinfo, char *input_key,
- int index)
-{
- rpc_clnt_connection_t *conn = NULL;
- int ret = -1;
- rpc_clnt_t *rpc = NULL;
- char rpcsvc_peername[RPCSVC_PEER_STRLEN] = {0,};
- char subkey[50] = {0,};
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
-
- strncpy (key, input_key, (GF_DUMP_MAX_BUF_LEN - 1));
-
- /* Dump the rpc connection statistics */
- rpc = peerinfo->rpc;
- if (rpc) {
- conn = &rpc->conn;
- snprintf (subkey, sizeof (subkey), "%s%d", key, index);
- ret = rpcsvc_transport_peername (conn->trans,
- (char *)&rpcsvc_peername,
- sizeof (rpcsvc_peername));
- if (!ret) {
- gf_proc_dump_build_key (key, subkey, "rpc.peername");
- gf_proc_dump_write (key, "%s", rpcsvc_peername);
- }
- gf_proc_dump_build_key (key, subkey, "rpc.connected");
- gf_proc_dump_write (key, "%d", conn->connected);
-
- gf_proc_dump_build_key (key, subkey, "rpc.total-bytes-read");
- gf_proc_dump_write (key, "%"PRIu64,
- conn->trans->total_bytes_read);
-
- gf_proc_dump_build_key (key, subkey, "rpc.total-bytes-written");
- gf_proc_dump_write (key, "%"PRIu64,
- conn->trans->total_bytes_write);
-
- gf_proc_dump_build_key (key, subkey, "rpc.ping_msgs_sent");
- gf_proc_dump_write (key, "%"PRIu64, conn->pingcnt);
-
- gf_proc_dump_build_key (key, subkey, "rpc.msgs_sent");
- gf_proc_dump_write (key, "%"PRIu64, conn->msgcnt);
- }
-
-}
-
-static void
-glusterd_dump_client_details (glusterd_conf_t *conf)
-{
- rpc_transport_t *xprt = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
- char subkey[50] = {0,};
- int index = 1;
-
- pthread_mutex_lock (&conf->xprt_lock);
- {
- list_for_each_entry (xprt, &conf->xprt_list, list) {
- snprintf (subkey, sizeof (subkey), "glusterd.client%d",
- index);
-
- gf_proc_dump_build_key (key, subkey, "identifier");
- gf_proc_dump_write (key, "%s",
- xprt->peerinfo.identifier);
-
- gf_proc_dump_build_key (key, subkey, "volname");
- gf_proc_dump_write (key, "%s",
- xprt->peerinfo.volname);
-
- gf_proc_dump_build_key (key, subkey, "max-op-version");
- gf_proc_dump_write (key, "%u",
- xprt->peerinfo.max_op_version);
-
- gf_proc_dump_build_key (key, subkey, "min-op-version");
- gf_proc_dump_write (key, "%u",
- xprt->peerinfo.min_op_version);
- index++;
- }
- }
- pthread_mutex_unlock (&conf->xprt_lock);
-}
-
-
-/* The following function is just for dumping mgmt_v3_lock dictionary, any other
- * dict passed to this API will not work */
-
-static void
-glusterd_dict_mgmt_v3_lock_statedump (dict_t *dict)
-{
- int ret = 0;
- int dumplen = 0;
- data_pair_t *trav = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
- char dump[64*1024] = {0,};
-
- if (!dict) {
- gf_log_callingfn ("glusterd", GF_LOG_WARNING, "dict NULL");
- goto out;
- }
- for (trav = dict->members_list; trav; trav = trav->next) {
- if (strstr (trav->key, "debug.last-success-bt") != NULL) {
- ret = snprintf (&dump[dumplen], sizeof(dump) - dumplen,
- "\n\t%s:%s", trav->key,
- trav->value->data);
- } else {
- ret = snprintf (&dump[dumplen], sizeof(dump) - dumplen,
- "\n\t%s:%s", trav->key,
- uuid_utoa (((glusterd_mgmt_v3_lock_obj *)
- (trav->value->data))->lock_owner));
- }
- if ((ret == -1) || !ret)
- return;
- dumplen += ret;
- }
-
- if (dumplen) {
- gf_proc_dump_build_key (key, "glusterd", "mgmt_v3_lock");
- gf_proc_dump_write (key, "%s", dump);
- }
-
-out:
- return;
-}
-
-int
-glusterd_dump_priv (xlator_t *this)
-{
- int index = 1;
- glusterd_conf_t *priv = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
- char subkey[50] = {0,};
- glusterd_peerinfo_t *peerinfo = NULL;
- glusterd_volinfo_t *volinfo = NULL;
-
- GF_VALIDATE_OR_GOTO ("glusterd", this, out);
-
- priv = this->private;
- if (!priv)
- return 0;
-
- gf_proc_dump_build_key (key, "xlator.glusterd", "priv");
- gf_proc_dump_add_section (key);
-
- pthread_mutex_lock (&priv->mutex);
- {
- gf_proc_dump_build_key (key, "glusterd", "my-uuid");
- gf_proc_dump_write (key, "%s", uuid_utoa (priv->uuid));
-
- gf_proc_dump_build_key (key, "glusterd", "working-directory");
- gf_proc_dump_write (key, "%s", priv->workdir);
-
- gf_proc_dump_build_key (key, "glusterd", "max-op-version");
- gf_proc_dump_write (key, "%d", GD_OP_VERSION_MAX);
-
- gf_proc_dump_build_key (key, "glusterd", "min-op-version");
- gf_proc_dump_write (key, "%d", GD_OP_VERSION_MIN);
-
- gf_proc_dump_build_key (key, "glusterd", "current-op-version");
- gf_proc_dump_write (key, "%d", priv->op_version);
-
- gf_proc_dump_build_key (key, "glusterd", "ping-timeout");
- gf_proc_dump_write (key, "%d", priv->ping_timeout);
-
- gf_proc_dump_build_key (key, "glusterd", "shd.online");
- gf_proc_dump_write (key, "%d", priv->shd->online);
-
- gf_proc_dump_build_key (key, "glusterd", "nfs.online");
- gf_proc_dump_write (key, "%d", priv->nfs->online);
-
- gf_proc_dump_build_key (key, "glusterd", "quotad.online");
- gf_proc_dump_write (key, "%d", priv->quotad->online);
-
- GLUSTERD_DUMP_PEERS (&priv->peers, uuid_list, _gf_false);
- GLUSTERD_DUMP_PEERS (&priv->xaction_peers, op_peers_list,
- _gf_true);
- glusterd_dump_client_details (priv);
- glusterd_dict_mgmt_v3_lock_statedump(priv->mgmt_v3_lock);
- dict_dump_to_statedump (priv->opts, "options", "glusterd");
- }
- pthread_mutex_unlock (&priv->mutex);
-
-out:
- return 0;
-}
int32_t
mem_acct_init (xlator_t *this)
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 208e5fc918c..23a41d925ce 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -1076,13 +1076,4 @@ glusterd_add_brick_status_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
int32_t
glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict);
-
-void
-glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *key, int index,
- gf_boolean_t xpeers);
-
-void
-glusterd_dump_peer_rpcstat (glusterd_peerinfo_t *peerinfo, char *key,
- int index);
-
#endif