summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-09-15 04:43:29 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-16 07:11:19 -0700
commitfd9c608193b3318a543f25f75af7b888d85c4405 (patch)
treec4ce442d7d4bd066adefe4735cb17376e791f8c8 /libglusterfs/src/fd.c
parent58e6643e036bda21f686955d779bb95ac513ab62 (diff)
libglusterfs:Acquire lock before accessing fdtable contents during statedump.
Hold lock while dumping fdtable. Dump only inode ino instead of the complete inode. 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.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 62536fc55..5b2d32bff 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -692,7 +692,6 @@ void
fd_dump (fd_t *fd, char *prefix)
{
char key[GF_DUMP_MAX_BUF_LEN];
- inode_t *inode = NULL;
if (!fd)
return;
@@ -704,9 +703,10 @@ fd_dump (fd_t *fd, char *prefix)
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);
+ if (fd->inode) {
+ gf_proc_dump_build_key(key, prefix, "inode");
+ gf_proc_dump_write(key, "%ld", fd->inode->ino);
+ }
}
@@ -726,12 +726,20 @@ fdentry_dump (fdentry_t *fdentry, char *prefix)
void
fdtable_dump (fdtable_t *fdtable, char *prefix)
{
- char key[GF_DUMP_MAX_BUF_LEN];
- int i = 0;
+ char key[GF_DUMP_MAX_BUF_LEN];
+ int i = 0;
+ int ret = -1;
if (!fdtable)
return;
+ ret = pthread_mutex_trylock (&fdtable->lock);
+
+ if (ret) {
+ gf_log ("fd", GF_LOG_WARNING, "Unable to acquire lock");
+ return;
+ }
+
memset(key, 0, sizeof(key));
gf_proc_dump_build_key(key, prefix, "refcount");
gf_proc_dump_write(key, "%d", fdtable->refcount);
@@ -739,8 +747,6 @@ fdtable_dump (fdtable_t *fdtable, char *prefix)
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 ==
@@ -750,5 +756,7 @@ fdtable_dump (fdtable_t *fdtable, char *prefix)
fdentry_dump(&fdtable->fdentries[i], key);
}
}
+
+ pthread_mutex_unlock(&fdtable->lock);
}