From 12689595abd50d13711f855dddfb5cfe51f40455 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Wed, 30 Jan 2013 15:46:49 -0800 Subject: fd-lk: implement new method to check for empty fd_lk_ctx_t to use this in fuse-bridge, to conditionally attempt lock migration to new graph. Change-Id: I9b10d5839c4ac6051c75e4c020371391cd886ac8 BUG: 808400 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/4455 Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat --- libglusterfs/src/fd-lk.c | 18 ++++++++++++++++++ libglusterfs/src/fd-lk.h | 4 ++++ 2 files changed, 22 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/fd-lk.c b/libglusterfs/src/fd-lk.c index 0c439fe6e..fff4aa996 100644 --- a/libglusterfs/src/fd-lk.c +++ b/libglusterfs/src/fd-lk.c @@ -468,3 +468,21 @@ fd_lk_insert_and_merge (fd_t *fd, int32_t cmd, out: return ret; } + + +gf_boolean_t +fd_lk_ctx_empty (fd_lk_ctx_t *lk_ctx) +{ + gf_boolean_t verdict = _gf_true; + + if (!lk_ctx) + return _gf_true; + + LOCK (&lk_ctx->lock); + { + verdict = list_empty (&lk_ctx->lk_list); + } + UNLOCK (&lk_ctx->lock); + + return verdict; +} diff --git a/libglusterfs/src/fd-lk.h b/libglusterfs/src/fd-lk.h index bdea8c2a0..1d2ff794c 100644 --- a/libglusterfs/src/fd-lk.h +++ b/libglusterfs/src/fd-lk.h @@ -18,6 +18,7 @@ #include "mem-pool.h" #include "mem-types.h" #include "glusterfs.h" +#include "common-utils.h" #define get_lk_type(type) \ type == F_UNLCK ? "F_UNLCK" : (type == F_RDLCK ? "F_RDLCK" : "F_WRLCK") @@ -63,4 +64,7 @@ fd_lk_insert_and_merge (struct _fd *lk_ctx, int32_t cmd, int fd_lk_ctx_unref (fd_lk_ctx_t *lk_ctx); +gf_boolean_t +fd_lk_ctx_empty (fd_lk_ctx_t *lk_ctx); + #endif /* _FD_LK_H */ -- cgit