summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd.c
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 /libglusterfs/src/fd.c
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 'libglusterfs/src/fd.c')
-rw-r--r--libglusterfs/src/fd.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 8f7616929c2..62536fc5524 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -21,6 +21,7 @@
#include "glusterfs.h"
#include "inode.h"
#include "dict.h"
+#include "statedump.h"
#ifndef _CONFIG_H
@@ -685,3 +686,69 @@ fd_ctx_del (fd_t *fd, xlator_t *xlator, uint64_t *value)
return ret;
}
+
+
+void
+fd_dump (fd_t *fd, char *prefix)
+{
+ char key[GF_DUMP_MAX_BUF_LEN];
+ inode_t *inode = NULL;
+
+ if (!fd)
+ return;
+
+ memset(key, 0, sizeof(key));
+ gf_proc_dump_build_key(key, prefix, "pid");
+ gf_proc_dump_write(key, "%d", fd->pid);
+ gf_proc_dump_build_key(key, prefix, "refcount");
+ gf_proc_dump_write(key, "%d", fd->refcount);
+ gf_proc_dump_build_key(key, prefix, "flags");
+ gf_proc_dump_write(key, "%d", fd->flags);
+ gf_proc_dump_build_key(key, prefix, "inode");
+ gf_proc_dump_add_section(key);
+ inode_dump(inode, key, NULL);
+}
+
+
+void
+fdentry_dump (fdentry_t *fdentry, char *prefix)
+{
+ if (!fdentry)
+ return;
+
+ if (GF_FDENTRY_ALLOCATED != fdentry->next_free)
+ return;
+
+ if (fdentry->fd)
+ fd_dump(fdentry->fd, prefix);
+}
+
+void
+fdtable_dump (fdtable_t *fdtable, char *prefix)
+{
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+
+ if (!fdtable)
+ return;
+
+ memset(key, 0, sizeof(key));
+ gf_proc_dump_build_key(key, prefix, "refcount");
+ gf_proc_dump_write(key, "%d", fdtable->refcount);
+ gf_proc_dump_build_key(key, prefix, "maxfds");
+ gf_proc_dump_write(key, "%d", fdtable->max_fds);
+ gf_proc_dump_build_key(key, prefix, "first_free");
+ gf_proc_dump_write(key, "%d", fdtable->first_free);
+ gf_proc_dump_build_key(key, prefix, "lock");
+ gf_proc_dump_write(key, "%d", fdtable->lock);
+
+ for ( i = 0 ; i < fdtable->max_fds; i++) {
+ if (GF_FDENTRY_ALLOCATED ==
+ fdtable->fdentries[i].next_free) {
+ gf_proc_dump_build_key(key, prefix, "fdentry[%d]", i);
+ gf_proc_dump_add_section(key);
+ fdentry_dump(&fdtable->fdentries[i], key);
+ }
+ }
+}
+