From 36827add0f55d674768ff9c90c5fbb636ae99054 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Wed, 1 Aug 2012 16:28:13 +0530 Subject: performance/quick-read: use pthread_mutex_trylock to hold mutex in statedumps Do not use pthread_mutex_lock and gf_log functions while dumping information to statedump, to avoid deadlocks. Change-Id: I0d30b04ae322f131b7a42d277ebd4385e83769e6 BUG: 843789 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3764 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/performance/quick-read/src/quick-read.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'xlators/performance/quick-read/src') diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 349ea778902..867900b902c 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -3431,6 +3431,7 @@ qr_inodectx_dump (xlator_t *this, inode_t *inode) int32_t ret = -1; char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }; char buf[256] = {0, }; + ret = inode_ctx_get (inode, this, &value); if (ret != 0) { goto out; @@ -3470,6 +3471,7 @@ qr_fdctx_dump (xlator_t *this, fd_t *fd) char key[GF_DUMP_MAX_BUF_LEN] = {0, }; char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }; call_stub_t *stub = NULL; + gf_boolean_t add_section = _gf_false; ret = fd_ctx_get (fd, this, &value); if (ret != 0) { @@ -3484,13 +3486,16 @@ qr_fdctx_dump (xlator_t *this, fd_t *fd) gf_proc_dump_build_key (key_prefix, "xlator.performance.quick-read", "fdctx"); gf_proc_dump_add_section (key_prefix); + add_section = _gf_true; gf_proc_dump_write ("fd", "%p", fd); - gf_proc_dump_write ("path", "%s", fdctx->path); - - LOCK (&fdctx->lock); + ret = TRY_LOCK (&fdctx->lock); + if (ret) + goto out; { + gf_proc_dump_write ("path", "%s", fdctx->path); + gf_proc_dump_write ("opened", "%s", fdctx->opened ? "yes" : "no"); gf_proc_dump_write ("open-in-progress", "%s", fdctx->open_in_transit ? @@ -3518,6 +3523,14 @@ qr_fdctx_dump (xlator_t *this, fd_t *fd) ret = 0; out: + if (ret && fdctx) { + if (add_section == _gf_false) + gf_proc_dump_add_section (key_prefix); + + gf_proc_dump_write ("Unable to dump the state of fdctx", + "(Lock acquistion failed) fd: %p, gfid: %s", + fd, uuid_utoa (fd->inode->gfid)); + } return ret; } -- cgit