summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/iobuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/iobuf.c')
-rw-r--r--libglusterfs/src/iobuf.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index 6d6fca13388..e9408f86bac 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;
+}