diff options
author | Vijay Bellur <vijay@gluster.com> | 2009-08-15 12:58:08 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-08-19 17:57:53 -0700 |
commit | b4d6c3d1bb461d2c8a396c9ed3881a4da40fc6ab (patch) | |
tree | 7a5a15665d46a91b9d4d744b0da599c4628d7f6c /libglusterfs/src/iobuf.c | |
parent | a31b0016347b3bc9b341fa0f4541ed137224f593 (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 'libglusterfs/src/iobuf.c')
-rw-r--r-- | libglusterfs/src/iobuf.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index 6d6fca133..e9408f86b 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -19,6 +19,7 @@ #include "iobuf.h" +#include "statedump.h" #include <stdio.h> @@ -636,3 +637,106 @@ iobref_size (struct iobref *iobref) out: return size; } + +void +iobuf_info_dump (struct iobuf *iobuf, const char *key_prefix) +{ + char key[GF_DUMP_MAX_BUF_LEN]; + struct iobuf my_iobuf; + int ret = 0; + + if (!iobuf) + return; + + memset(&my_iobuf, 0, sizeof(my_iobuf)); + + ret = TRY_LOCK(&iobuf->lock); + if (ret) { + gf_log("", GF_LOG_WARNING, "Unable to dump iobuf" + " errno: %d", errno); + return; + } + memcpy(&my_iobuf, iobuf, sizeof(my_iobuf)); + UNLOCK(&iobuf->lock); + + gf_proc_dump_build_key(key, key_prefix,"ref"); + gf_proc_dump_write(key, "%d", my_iobuf.ref); + gf_proc_dump_build_key(key, key_prefix,"ptr"); + gf_proc_dump_write(key, "%p", my_iobuf.ptr); + +} + +void +iobuf_arena_info_dump (struct iobuf_arena *iobuf_arena, const char *key_prefix) +{ + char key[GF_DUMP_MAX_BUF_LEN]; + int i = 1; + struct iobuf *trav; + + if (!iobuf_arena) + return; + + gf_proc_dump_build_key(key, key_prefix,"mem_base"); + gf_proc_dump_write(key, "%p", iobuf_arena->mem_base); + gf_proc_dump_build_key(key, key_prefix, "active_cnt"); + gf_proc_dump_write(key, "%d", iobuf_arena->active_cnt); + gf_proc_dump_build_key(key, key_prefix, "passive_cnt"); + gf_proc_dump_write(key, "%d", iobuf_arena->passive_cnt); + list_for_each_entry (trav, &iobuf_arena->active.list, list) { + gf_proc_dump_build_key(key, key_prefix,"active_iobuf.%d", i++); + gf_proc_dump_add_section(key); + iobuf_info_dump(trav, key); + } + + i = 1; + list_for_each_entry (trav, &iobuf_arena->passive.list, list) { + gf_proc_dump_build_key(key, key_prefix, + "passive_iobuf.%d",i++); + gf_proc_dump_add_section(key); + iobuf_info_dump(trav, key); + } + +} + +void +iobuf_stats_dump (struct iobuf_pool *iobuf_pool) +{ + + char msg[1024]; + struct iobuf_arena *trav; + int i = 1; + int ret = -1; + + if (!iobuf_pool) + return; + + memset(msg, 0, sizeof(msg)); + + ret = pthread_mutex_trylock(&iobuf_pool->mutex); + + if (ret) { + gf_log("", GF_LOG_WARNING, "Unable to dump iobuf pool" + " errno: %d", errno); + return; + } + gf_proc_dump_add_section("iobuf.global"); + gf_proc_dump_write("iobuf.global.iobuf_pool","%p", iobuf_pool); + gf_proc_dump_write("iobuf.global.iobuf_pool.page_size", "%d", + iobuf_pool->page_size); + gf_proc_dump_write("iobuf.global.iobuf_pool.arena_size", "%d", + iobuf_pool->arena_size); + gf_proc_dump_write("iobuf.global.iobuf_pool.arena_cnt", "%d", + iobuf_pool->arena_cnt); + + list_for_each_entry (trav, &iobuf_pool->arenas.list, list) { + snprintf(msg, sizeof(msg), "iobuf.global.iobuf_pool.arena.%d", + i); + gf_proc_dump_add_section(msg); + iobuf_arena_info_dump(trav,msg); + i++; + } + + pthread_mutex_unlock(&iobuf_pool->mutex); + + return; +} |