summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-09-15 04:43:48 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-16 07:11:23 -0700
commitdb3d9ff328a9ce65db452d628f33c3151e131d5e (patch)
tree77ced8f99e2def4b74ae1d9a439b3189f61f9352 /xlators/cluster/dht/src
parentfd9c608193b3318a543f25f75af7b888d85c4405 (diff)
cluster/dht: Support for dumpop priv.
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/cluster/dht/src')
-rw-r--r--xlators/cluster/dht/src/dht.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index e004dee0d5c..24782471e1d 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -25,6 +25,7 @@
/* TODO: add NS locking */
+#include "statedump.h"
#include "dht-common.c"
/* TODO:
@@ -35,6 +36,135 @@
*/
+void
+dht_layout_dump (dht_layout_t *layout, const char *prefix)
+{
+
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+
+ if (!layout)
+ return;
+
+ gf_proc_dump_build_key(key, prefix, "cnt");
+ gf_proc_dump_write(key, "%d", layout->cnt);
+ gf_proc_dump_build_key(key, prefix, "preset");
+ gf_proc_dump_write(key, "%d", layout->preset);
+ gf_proc_dump_build_key(key, prefix, "gen");
+ gf_proc_dump_write(key, "%d", layout->gen);
+ gf_proc_dump_build_key(key, prefix, "type");
+ gf_proc_dump_write(key, "%d", layout->type);
+
+ for (i = 0; i < layout->cnt; i++) {
+ gf_proc_dump_build_key(key, prefix,"list[%d].err", i);
+ gf_proc_dump_write(key, "%d", layout->list[i].err);
+ gf_proc_dump_build_key(key, prefix,"list[%d].start", i);
+ gf_proc_dump_write(key, "%u", layout->list[i].start);
+ gf_proc_dump_build_key(key, prefix,"list[%d].stop", i);
+ gf_proc_dump_write(key, "%u", layout->list[i].stop);
+ if (layout->list[i].xlator) {
+ gf_proc_dump_build_key(key, prefix,
+ "list[%d].xlator.type", i);
+ gf_proc_dump_write(key, "%s",
+ layout->list[i].xlator->type);
+ gf_proc_dump_build_key(key, prefix,
+ "list[%d].xlator.name", i);
+ gf_proc_dump_write(key, "%s",
+ layout->list[i].xlator->name);
+ }
+ }
+}
+
+
+int32_t
+dht_priv_dump (xlator_t *this)
+{
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+ dht_conf_t *conf = NULL;
+ int ret = 0;
+
+ if (!this)
+ return -1;
+
+ conf = this->private;
+
+ if (!conf)
+ return -1;
+
+ ret = TRY_LOCK(&conf->subvolume_lock);
+
+ if (ret != 0) {
+ gf_log("", GF_LOG_WARNING, "Unable to lock dht subvolume %s",
+ this->name);
+ return ret;
+ }
+
+ gf_proc_dump_add_section("xlator.cluster.dht.%s.priv", this->name);
+ gf_proc_dump_build_key(key_prefix,"xlator.cluster.dht","%s.priv",
+ this->name);
+ gf_proc_dump_build_key(key, key_prefix, "subvolume_cnt");
+ gf_proc_dump_write(key,"%d", conf->subvolume_cnt);
+ for (i = 0; i < conf->subvolume_cnt; i++) {
+ gf_proc_dump_build_key(key, key_prefix, "subvolumes[%d]", i);
+ gf_proc_dump_write(key, "%s.%s", conf->subvolumes[i]->type,
+ conf->subvolumes[i]->name);
+ if (conf->file_layouts && conf->file_layouts[i]){
+ gf_proc_dump_build_key(key, key_prefix,
+ "file_layouts[%d]",i);
+ dht_layout_dump(conf->file_layouts[i], key);
+ }
+ if (conf->dir_layouts && conf->dir_layouts[i]) {
+ gf_proc_dump_build_key(key, key_prefix,
+ "dir_layouts[%d]",i);
+ dht_layout_dump(conf->dir_layouts[i], key);
+ }
+ if (conf->subvolume_status) {
+ gf_proc_dump_build_key(key, key_prefix,
+ "subvolume_status[%d]", i);
+ gf_proc_dump_write(key, "%d",
+ (int)conf->subvolume_status[i]);
+ }
+
+ }
+
+ gf_proc_dump_build_key(key, key_prefix,"default_dir_layout");
+ dht_layout_dump(conf->default_dir_layout, key);
+
+ gf_proc_dump_build_key(key, key_prefix, "local_volume");
+ gf_proc_dump_write(key,"%s",
+ conf->local_volume?(conf->local_volume->name):"None");
+ gf_proc_dump_build_key(key, key_prefix, "search_unhashed");
+ gf_proc_dump_write(key, "%d", conf->search_unhashed);
+ gf_proc_dump_build_key(key, key_prefix, "gen");
+ gf_proc_dump_write(key, "%d", conf->gen);
+ gf_proc_dump_build_key(key, key_prefix, "min_free_disk");
+ gf_proc_dump_write(key, "%lu", conf->min_free_disk);
+ gf_proc_dump_build_key(key, key_prefix, "disk_unit");
+ gf_proc_dump_write(key, "%c", conf->disk_unit);
+ gf_proc_dump_build_key(key, key_prefix, "refresh_interval");
+ gf_proc_dump_write(key, "%d", conf->refresh_interval);
+ gf_proc_dump_build_key(key, key_prefix, "unhashed_sticky_bit");
+ gf_proc_dump_write(key, "%d", conf->unhashed_sticky_bit);
+ if (conf ->du_stats) {
+ gf_proc_dump_build_key(key, key_prefix,
+ "du_stats.avail_percent");
+ gf_proc_dump_write(key, "%lf", conf->du_stats->avail_percent);
+ gf_proc_dump_build_key(key, key_prefix,
+ "du_stats.avail_space");
+ gf_proc_dump_write(key, "%lu", conf->du_stats->avail_space);
+ gf_proc_dump_build_key(key, key_prefix,
+ "du_stats.log");
+ gf_proc_dump_write(key, "%lu", conf->du_stats->log);
+ }
+ gf_proc_dump_build_key(key, key_prefix, "last_stat_fetch");
+ gf_proc_dump_write(key, "%s", ctime(&conf->last_stat_fetch.tv_sec));
+
+ UNLOCK(&conf->subvolume_lock);
+
+ return 0;
+}
int
notify (xlator_t *this, int event, void *data, ...)
@@ -241,6 +371,10 @@ struct xlator_fops fops = {
struct xlator_mops mops = {
};
+struct xlator_dumpops dumpops = {
+ .priv = dht_priv_dump,
+};
+
struct xlator_cbks cbks = {
// .release = dht_release,