From a5341ef545b1568cbe33db80f62950e428ede98a Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Wed, 1 Aug 2012 16:38:34 +0530 Subject: performance/read-ahead: use pthread_mutex_trylock to hold mutex in statedumps Change-Id: I4491c96fc7d9879ba9040dcda3700c81d99ba184 BUG: 843796 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3766 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Anand Avati --- xlators/performance/read-ahead/src/read-ahead.c | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'xlators/performance/read-ahead/src/read-ahead.c') diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index 7b23049d3..549496755 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -949,6 +949,7 @@ ra_priv_dump (xlator_t *this) ra_conf_t *conf = NULL; int ret = -1; char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }; + gf_boolean_t add_section = _gf_false; if (!this) { goto out; @@ -960,26 +961,32 @@ ra_priv_dump (xlator_t *this) goto out; } - ret = pthread_mutex_trylock (&conf->conf_lock); - if (ret) { - gf_log (this->name, GF_LOG_WARNING, "Unable to lock client %s " - "(%s)", this->name, strerror (ret)); - ret = -1; - goto out; - } - gf_proc_dump_build_key (key_prefix, "xlator.performance.read-ahead", "priv"); gf_proc_dump_add_section (key_prefix); - gf_proc_dump_write ("page_size", "%d", conf->page_size); - gf_proc_dump_write ("page_count", "%d", conf->page_count); - gf_proc_dump_write ("force_atime_update", "%d", conf->force_atime_update); + add_section = _gf_true; + ret = pthread_mutex_trylock (&conf->conf_lock); + if (ret) + goto out; + { + gf_proc_dump_write ("page_size", "%d", conf->page_size); + gf_proc_dump_write ("page_count", "%d", conf->page_count); + gf_proc_dump_write ("force_atime_update", "%d", + conf->force_atime_update); + } pthread_mutex_unlock (&conf->conf_lock); ret = 0; out: + if (ret && conf) { + if (add_section == _gf_false) + gf_proc_dump_add_section (key_prefix); + + gf_proc_dump_write ("Unable to dump priv", + "(Lock acquisition failed) %s", this->name); + } return ret; } -- cgit