From 63281d7eeb5b8ac44e3630ccfbc61774eedf2ae2 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Wed, 7 Mar 2012 00:19:29 +0530 Subject: protocol/client: Added lk_ctx info in fdctx dump - Added a brief explanation as to why we can't use gf_log when in statedump. - Removed gf_log messages from client_priv_dump since it can cause a 'deadlock' - See statedump.c for explanation - Added try-lock based accessors for fd_lk_list for dump purposes. Change-Id: I1d755a4ef2c568acf22fb8c4ab0a33a4f5fd07b4 BUG: 789858 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/2882 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Vijay Bellur --- libglusterfs/src/fd-lk.c | 21 +++++++++++++++++++++ libglusterfs/src/fd-lk.h | 3 +++ libglusterfs/src/statedump.c | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/fd-lk.c b/libglusterfs/src/fd-lk.c index 8df43bb602f..4e10d649ee9 100644 --- a/libglusterfs/src/fd-lk.c +++ b/libglusterfs/src/fd-lk.c @@ -128,6 +128,27 @@ fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx) return new_lk_ctx; } +fd_lk_ctx_t * +fd_lk_ctx_try_ref (fd_lk_ctx_t *lk_ctx) +{ + int ret = -1; + fd_lk_ctx_t *new_lk_ctx = NULL; + + if (!lk_ctx) { + goto out; + } + + ret = TRY_LOCK (&lk_ctx->lock); + if (ret) + goto out; + + new_lk_ctx = _fd_lk_ctx_ref (lk_ctx); + UNLOCK (&lk_ctx->lock); + +out: + return new_lk_ctx; +} + fd_lk_ctx_t * fd_lk_ctx_create () { diff --git a/libglusterfs/src/fd-lk.h b/libglusterfs/src/fd-lk.h index 3e419e14377..7adbb5131b7 100644 --- a/libglusterfs/src/fd-lk.h +++ b/libglusterfs/src/fd-lk.h @@ -59,6 +59,9 @@ _fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx); fd_lk_ctx_t * fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx); +fd_lk_ctx_t * +fd_lk_ctx_try_ref (fd_lk_ctx_t *lk_ctx); + fd_lk_ctx_t * fd_lk_ctx_create (); diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 9b15c5ba50d..f438c5a61ea 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -30,7 +30,8 @@ #endif /* MALLOC_H */ /* We don't want gf_log in this function because it may cause - 'deadlock' with statedump */ + 'deadlock' with statedump. This is because statedump happens + inside a signal handler and cannot afford to block on a lock.*/ #ifdef gf_log # undef gf_log #endif -- cgit