summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2012-08-09 18:33:37 +0530
committerVijay Bellur <vbellur@redhat.com>2012-08-11 23:29:14 -0700
commitc79690c4cb503a6e6b52998038fd85cdfcf0f7be (patch)
treefe1ea9023ef4823b0a97c87a3f8d24a56fd446e9
parenta1d071374365a10ebef508c38c39f61da0a0f855 (diff)
protocol/server: use pthread_mutex_trylock while dumping statedumps
Change-Id: I2b04dc35a51d940915197cf8e26e638f32fa4d7b BUG: 843821 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.com/3802 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--libglusterfs/src/fd.c12
-rw-r--r--xlators/protocol/server/src/server.c40
2 files changed, 37 insertions, 15 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 3a7a592786c..b0b75a5ad3e 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -989,10 +989,8 @@ fdtable_dump (fdtable_t *fdtable, char *prefix)
ret = pthread_mutex_trylock (&fdtable->lock);
- if (ret) {
- gf_log ("fd", GF_LOG_WARNING, "Unable to acquire lock");
- return;
- }
+ if (ret)
+ goto out;
memset(key, 0, sizeof(key));
gf_proc_dump_build_key(key, prefix, "refcount");
@@ -1012,6 +1010,12 @@ fdtable_dump (fdtable_t *fdtable, char *prefix)
}
pthread_mutex_unlock(&fdtable->lock);
+
+out:
+ if (ret != 0)
+ gf_proc_dump_write ("Unable to dump the fdtable",
+ "(Lock acquistion failed) %p", fdtable);
+ return;
}
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index a99ba817e5e..f51dfb9c5ef 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -245,6 +245,7 @@ server_fd (xlator_t *this)
char key[GF_DUMP_MAX_BUF_LEN];
int i = 1;
int ret = -1;
+ gf_boolean_t section_added = _gf_false;
GF_VALIDATE_OR_GOTO ("server", this, out);
@@ -256,13 +257,11 @@ server_fd (xlator_t *this)
}
gf_proc_dump_add_section("xlator.protocol.server.conn");
+ section_added = _gf_true;
ret = pthread_mutex_trylock (&conf->mutex);
- if (ret) {
- gf_log("", GF_LOG_WARNING, "Unable to dump fdtable"
- " errno: %d", errno);
- return -1;
- }
+ if (ret)
+ goto out;
list_for_each_entry (trav, &conf->conns, list) {
if (trav->id) {
@@ -288,6 +287,13 @@ server_fd (xlator_t *this)
ret = 0;
out:
+ if (ret) {
+ if (section_added == _gf_false)
+ gf_proc_dump_add_section("xlator.protocol.server.conn");
+ gf_proc_dump_write ("Unable to dump the list of connections",
+ "(Lock acquisition failed) %s",
+ this?this->name:"server");
+ }
return ret;
}
@@ -366,7 +372,12 @@ server_priv (xlator_t *this)
if (!conf)
return 0;
- pthread_mutex_lock (&conf->mutex);
+ gf_proc_dump_build_key (key, "xlator.protocol.server", "priv");
+ gf_proc_dump_add_section (key);
+
+ ret = pthread_mutex_trylock (&conf->mutex);
+ if (ret != 0)
+ goto out;
{
list_for_each_entry (xprt, &conf->xprt_list, list) {
total_read += xprt->total_bytes_read;
@@ -383,6 +394,11 @@ server_priv (xlator_t *this)
ret = 0;
out:
+ if (ret)
+ gf_proc_dump_write ("Unable to print priv",
+ "(Lock acquisition failed) %s",
+ this?this->name:"server");
+
return ret;
}
@@ -457,11 +473,8 @@ server_inode (xlator_t *this)
}
ret = pthread_mutex_trylock (&conf->mutex);
- if (ret) {
- gf_log("", GF_LOG_WARNING, "Unable to dump itable"
- " errno: %d", errno);
- return -1;
- }
+ if (ret)
+ goto out;
list_for_each_entry (trav, &conf->conns, list) {
if (trav->bound_xl && trav->bound_xl->itable) {
@@ -487,6 +500,11 @@ server_inode (xlator_t *this)
ret = 0;
out:
+ if (ret)
+ gf_proc_dump_write ("Unable to dump the inode table",
+ "(Lock acquisition failed) %s",
+ this?this->name:"server");
+
return ret;
}