summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/fd-lk.c21
-rw-r--r--libglusterfs/src/fd-lk.h3
-rw-r--r--libglusterfs/src/statedump.c3
3 files changed, 26 insertions, 1 deletions
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
@@ -129,6 +129,27 @@ 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)
+{
+ 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 ()
{
fd_lk_ctx_t *fd_lk_ctx = NULL;
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
@@ -60,6 +60,9 @@ 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 ();
int
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