summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-08-15 12:58:08 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-08-19 17:57:53 -0700
commitb4d6c3d1bb461d2c8a396c9ed3881a4da40fc6ab (patch)
tree7a5a15665d46a91b9d4d744b0da599c4628d7f6c /xlators
parenta31b0016347b3bc9b341fa0f4541ed137224f593 (diff)
TAKE2[PATCH BUG:213 1/1] Support for Process State Dump
Support for process state dump. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 213 (Support for process state dump) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=213
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr.c59
-rw-r--r--xlators/features/locks/src/posix.c55
-rw-r--r--xlators/protocol/server/src/server-protocol.c81
-rw-r--r--xlators/storage/posix/src/posix.c45
4 files changed, 240 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 6b3b05c6b3c..6b7b007aeb8 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -43,6 +43,7 @@
#include "compat-errno.h"
#include "compat.h"
#include "byte-order.h"
+#include "statedump.h"
#include "fd.h"
@@ -2158,6 +2159,60 @@ out:
return 0;
}
+int
+afr_priv_dump (xlator_t *this)
+{
+ afr_private_t *priv = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+
+
+ assert(this);
+ priv = this->private;
+
+ assert(priv);
+ snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
+ gf_proc_dump_add_section(key_prefix);
+ gf_proc_dump_build_key(key, key_prefix, "child_count");
+ gf_proc_dump_write(key, "%u", priv->child_count);
+ gf_proc_dump_build_key(key, key_prefix, "read_child_rr");
+ gf_proc_dump_write(key, "%u", priv->read_child_rr);
+ for (i = 0; i < priv->child_count; i++) {
+ gf_proc_dump_build_key(key, key_prefix, "child_up[%d]", i);
+ gf_proc_dump_write(key, "%d", priv->child_up[i]);
+ gf_proc_dump_build_key(key, key_prefix,
+ "pending_key[%d]", i);
+ gf_proc_dump_write(key, "%s", priv->pending_key[i]);
+ }
+ gf_proc_dump_build_key(key, key_prefix, "data_self_heal");
+ gf_proc_dump_write(key, "%d", priv->data_self_heal);
+ gf_proc_dump_build_key(key, key_prefix, "metadata_self_heal");
+ gf_proc_dump_write(key, "%d", priv->metadata_self_heal);
+ gf_proc_dump_build_key(key, key_prefix, "entry_self_heal");
+ gf_proc_dump_write(key, "%d", priv->entry_self_heal);
+ gf_proc_dump_build_key(key, key_prefix, "data_change_log");
+ gf_proc_dump_write(key, "%d", priv->data_change_log);
+ gf_proc_dump_build_key(key, key_prefix, "metadata_change_log");
+ gf_proc_dump_write(key, "%d", priv->metadata_change_log);
+ gf_proc_dump_build_key(key, key_prefix, "entry_change_log");
+ gf_proc_dump_write(key, "%d", priv->entry_change_log);
+ gf_proc_dump_build_key(key, key_prefix, "read_child");
+ gf_proc_dump_write(key, "%d", priv->read_child);
+ gf_proc_dump_build_key(key, key_prefix, "favorite_child");
+ gf_proc_dump_write(key, "%u", priv->favorite_child);
+ gf_proc_dump_build_key(key, key_prefix, "data_lock_server_count");
+ gf_proc_dump_write(key, "%u", priv->data_lock_server_count);
+ gf_proc_dump_build_key(key, key_prefix, "metadata_lock_server_count");
+ gf_proc_dump_write(key, "%u", priv->metadata_lock_server_count);
+ gf_proc_dump_build_key(key, key_prefix, "entry_lock_server_count");
+ gf_proc_dump_write(key, "%u", priv->entry_lock_server_count);
+ gf_proc_dump_build_key(key, key_prefix, "wait_count");
+ gf_proc_dump_write(key, "%u", priv->wait_count);
+
+ return 0;
+}
+
/**
* find_child_index - find the child's index in the array of subvolumes
@@ -2587,6 +2642,10 @@ struct xlator_fops fops = {
struct xlator_mops mops = {
};
+struct xlator_dumpops dumpops = {
+ .priv = afr_priv_dump,
+};
+
struct xlator_cbks cbks = {
.release = afr_release,
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index d672beaebc3..7389e1e6afd 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -36,6 +36,7 @@
#include "locks.h"
#include "common.h"
+#include "statedump.h"
#ifndef LLONG_MAX
#define LLONG_MAX LONG_LONG_MAX /* compat with old gcc */
@@ -768,6 +769,57 @@ pl_forget (xlator_t *this,
}
+void
+pl_dump_inode_priv (inode_t *inode)
+{
+
+ int ret = -1;
+ uint64_t tmp_pl_inode = 0;
+ pl_inode_t *pl_inode = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN];
+
+ if (!inode)
+ return;
+
+ ret = inode_ctx_get (inode, inode->table->xl, &tmp_pl_inode);
+
+ if (ret != 0)
+ return;
+
+ pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
+
+ if (!pl_inode)
+ return;
+
+ gf_proc_dump_build_key(key,
+ "xlator.feature.locks.inode",
+ "%ld.%s",inode->ino, "mandatory");
+ gf_proc_dump_write(key, "%d", pl_inode->mandatory);
+}
+
+
+
+/*
+ * pl_dump_inode - inode dump function for posix locks
+ *
+ */
+int
+pl_dump_inode (xlator_t *this)
+{
+
+ assert(this);
+
+ if (this->itable) {
+ inode_table_dump(this->itable,
+ "xlator.features.locks.inode_table",
+ pl_dump_inode_priv);
+ }
+
+ return 0;
+}
+
+
+
int
init (xlator_t *this)
{
@@ -864,6 +916,9 @@ struct xlator_fops fops = {
struct xlator_mops mops = {
};
+struct xlator_dumpops dumpops = {
+ .inode = pl_dump_inode,
+};
struct xlator_cbks cbks = {
.forget = pl_forget,
diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c
index 220f5b3b466..47a6f027736 100644
--- a/xlators/protocol/server/src/server-protocol.c
+++ b/xlators/protocol/server/src/server-protocol.c
@@ -40,6 +40,7 @@
#include "dict.h"
#include "compat.h"
#include "compat-errno.h"
+#include "statedump.h"
static void
@@ -7512,7 +7513,80 @@ server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
return 0;
}
+/*
+ * server_fd - fdtable dump function for server protocol
+ * @this:
+ *
+ */
+int
+server_fd (xlator_t *this)
+{
+ server_conf_t *conf = NULL;
+ server_connection_t *trav = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 1;
+ int ret = -1;
+
+ if (!this)
+ return -1;
+
+ conf = this->private;
+ if (!conf) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "conf null in xlator");
+ return -1;
+ }
+
+ gf_proc_dump_add_section("xlator.protocol.server.conn");
+
+ ret = pthread_mutex_trylock (&conf->mutex);
+ if (ret) {
+ gf_log("", GF_LOG_WARNING, "Unable to dump fdtable"
+ " errno: %d", errno);
+ return -1;
+ }
+
+ list_for_each_entry (trav, &conf->conns, list) {
+ if (trav->id) {
+ gf_proc_dump_build_key(key,
+ "xlator.protocol.server.conn",
+ "%d.id", i);
+ gf_proc_dump_write(key, "%s", trav->id);
+ }
+
+ gf_proc_dump_build_key(key,"xlator.protocol.server.conn",
+ "%d.ref",i)
+ gf_proc_dump_write(key, "%d", trav->ref);
+ if (trav->bound_xl) {
+ gf_proc_dump_build_key(key,
+ "xlator.protocol.server.conn",
+ "%d.bound_xl", i);
+ gf_proc_dump_write(key, "%s", trav->bound_xl->name);
+ }
+
+ gf_proc_dump_build_key(key,
+ "xlator.protocol.server.conn",
+ "%d.id", i);
+ fdtable_dump(trav->fdtable,key);
+ i++;
+ }
+ pthread_mutex_unlock (&conf->mutex);
+
+
+ return 0;
+ }
+
+int
+server_priv (xlator_t *this)
+{
+ return 0;
+}
+int
+server_inode (xlator_t *this)
+{
+ return 0;
+}
static void
get_auth_types (dict_t *this, char *key, data_t *value, void *data)
{
@@ -7841,6 +7915,13 @@ struct xlator_fops fops = {
struct xlator_cbks cbks = {
};
+struct xlator_dumpops dumpops = {
+ .inode = server_inode,
+ .priv = server_priv,
+ .fd = server_fd,
+};
+
+
struct volume_options options[] = {
{ .key = {"transport-type"},
.value = {"tcp", "socket", "ib-verbs", "unix", "ib-sdp",
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 4bcea07f9c6..b124d136201 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -45,6 +45,7 @@
#include "compat.h"
#include "byte-order.h"
#include "syscall.h"
+#include "statedump.h"
#undef HAVE_SET_FSID
#ifdef HAVE_SET_FSID
@@ -3808,6 +3809,45 @@ posix_checksum (call_frame_t *frame, xlator_t *this,
return 0;
}
+int32_t
+posix_priv (xlator_t *this)
+{
+ struct posix_private *priv = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ char key[GF_DUMP_MAX_BUF_LEN];
+
+ snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type,
+ this->name);
+ gf_proc_dump_add_section(key_prefix);
+
+ if (!this)
+ return 0;
+
+ priv = this->private;
+
+ if (!priv)
+ return 0;
+
+ gf_proc_dump_build_key(key, key_prefix, "base_path");
+ gf_proc_dump_write(key,"%s", priv->base_path);
+ gf_proc_dump_build_key(key, key_prefix, "base_path_length");
+ gf_proc_dump_write(key,"%d", priv->base_path_length);
+ gf_proc_dump_build_key(key, key_prefix, "max_read");
+ gf_proc_dump_write(key,"%d", priv->max_read);
+ gf_proc_dump_build_key(key, key_prefix, "max_write");
+ gf_proc_dump_write(key,"%d", priv->max_write);
+ gf_proc_dump_build_key(key, key_prefix, "stats.nr_files");
+ gf_proc_dump_write(key,"%ld", priv->stats.nr_files);
+
+ return 0;
+}
+
+int32_t
+posix_inode (xlator_t *this)
+{
+ return 0;
+}
+
/**
* notify - when parent sends PARENT_UP, send CHILD_UP event from here
*/
@@ -4056,6 +4096,11 @@ fini (xlator_t *this)
return;
}
+struct xlator_dumpops dumpops = {
+ .priv = posix_priv,
+ .inode = posix_inode,
+};
+
struct xlator_mops mops = {
.stats = posix_stats,
};