summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src/entrylk.c
diff options
context:
space:
mode:
authorkrad <krad@fb.com>2017-06-22 10:53:41 -0700
committerJeff Darcy <jeff@pl.atyp.us>2017-09-13 14:13:58 +0000
commit5c30bda609f99e3360e11dc3e6ac2c727a11171a (patch)
tree9652eb11159de680b376fa7a199794a8a84ebee7 /xlators/features/locks/src/entrylk.c
parentcf8a4d17fe9133f050560c4d655255a003185fe5 (diff)
inodelk-count: Add stats to count the number of lock objects
Summary: We want to track the number of locks held by the locks xlator. One of the ways to do it would be to track the total number of pl_lock objects in the system. This patch tracks the total number of pl_lock object and exposes the stat via io-stats JSON dump. Test Plan: WIP, haven't got a pass. Putting the diff to get a sense of this approach would yield what you guys are looking for? Reviewers: kvigor, sshreyas, jdarcy Reviewed By: jdarcy Differential Revision: https://phabricator.intern.facebook.com/D5303071 Change-Id: I946debcbff61699ec28b4d6f243042440107a224 Signed-off-by: Jeff Darcy <jdarcy@fb.com> Reviewed-on: https://review.gluster.org/18273 Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> Tested-by: Jeff Darcy <jeff@pl.atyp.us> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/features/locks/src/entrylk.c')
-rw-r--r--xlators/features/locks/src/entrylk.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index 626541237b3..fa1b33045dc 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -19,11 +19,40 @@
#include "clear.h"
#include "common.h"
+static inline void
+pl_private_inc_entrylk (posix_locks_private_t *private)
+{
+#ifdef HAVE_ATOMIC_BUILTINS
+ __sync_fetch_and_add (&private->entrylk_count, 1);
+#else
+ pthread_mutex_lock (&private->lock);
+ {
+ private->entrylk_count += 1;
+ }
+ pthread_mutex_unlock (&private->lock);
+#endif
+}
+
+static inline void
+pl_private_dec_entrylk (posix_locks_private_t *private)
+{
+#ifdef HAVE_ATOMIC_BUILTINS
+ __sync_fetch_and_sub (&private->entrylk_count, 1);
+#else
+ pthread_mutex_lock (&private->lock);
+ {
+ private->entrylk_count -= 1;
+ }
+ pthread_mutex_unlock (&private->lock);
+#endif
+}
+
void
__pl_entrylk_unref (pl_entry_lock_t *lock)
{
lock->ref--;
if (!lock->ref) {
+ pl_private_dec_entrylk (lock->this->private);
GF_FREE ((char *)lock->basename);
GF_FREE (lock->connection_id);
GF_FREE (lock);
@@ -68,6 +97,8 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
INIT_LIST_HEAD (&newlock->client_list);
__pl_entrylk_ref (newlock);
+
+ pl_private_inc_entrylk (newlock->this->private);
out:
return newlock;
}