From cb7647f67390920fa2aa25fd0af7c84787c08ed0 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Mon, 13 Aug 2012 19:16:43 +0530 Subject: performance/write-behind: use pthread_mutex_trylock to hold mutex in statedumps Change-Id: I24c83b1b5e83ef3e38a019043c7fbca13b19ff43 BUG: 841543 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3815 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/performance/write-behind/src/write-behind.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index a743039d9ab..f392d6fe2e0 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -2784,6 +2784,7 @@ wb_file_dump (xlator_t *this, fd_t *fd) int32_t ret = -1; char *path = NULL; char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }; + gf_boolean_t section_added = _gf_true; if ((fd == NULL) || (this == NULL)) { ret = 0; @@ -2806,6 +2807,7 @@ wb_file_dump (xlator_t *this, fd_t *fd) "file"); gf_proc_dump_add_section (key_prefix); + section_added = _gf_true; __inode_path (fd->inode, NULL, &path); if (path != NULL) { @@ -2834,7 +2836,10 @@ wb_file_dump (xlator_t *this, fd_t *fd) gf_proc_dump_write ("op_errno", "%d", file->op_errno); - LOCK (&file->lock); + ret = TRY_LOCK (&file->lock); + if (ret) + goto out; + else { if (!list_empty (&file->request)) { __wb_dump_requests (&file->request, key_prefix, 0); @@ -2844,11 +2849,18 @@ wb_file_dump (xlator_t *this, fd_t *fd) __wb_dump_requests (&file->passive_requests, key_prefix, 1); } - } + UNLOCK (&file->lock); + } - ret = 0; out: + if (ret && file) { + if (section_added == _gf_false) + gf_proc_dump_add_section (key_prefix); + gf_proc_dump_write ("Unable to dump the fd context", + "(Lock acquisition failed) fd:%p, gfid:%s", + fd, uuid_utoa (fd->inode->gfid)); + } return ret; } -- cgit