summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src/posix.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/posix.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/posix.c')
-rw-r--r--xlators/features/locks/src/posix.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 616be0f7cff..59d05e81bec 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -1005,6 +1005,7 @@ int32_t
pl_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
+ posix_locks_private_t *priv = this->private;
int32_t op_errno = EINVAL;
int op_ret = -1;
int32_t bcount = 0;
@@ -1015,10 +1016,49 @@ pl_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
dict_t *dict = NULL;
clrlk_args args = {0,};
char *brickname = NULL;
+ int ret = 0;
if (!name)
goto usual;
+ if (strncmp (name, GLUSTERFS_INODELK_COUNT,
+ strlen (GLUSTERFS_INODELK_COUNT)) == 0) {
+ dict = dict_new ();
+ if (!dict) {
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, GLUSTERFS_INODELK_COUNT,
+ priv->inodelk_count);
+ if (ret) {
+ op_errno = EIO;
+ goto out;
+ }
+
+ op_ret = 0;
+ goto out;
+ }
+
+ if (strncmp (name, GLUSTERFS_ENTRYLK_COUNT,
+ strlen (GLUSTERFS_ENTRYLK_COUNT)) == 0) {
+ dict = dict_new ();
+ if (!dict) {
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, GLUSTERFS_ENTRYLK_COUNT,
+ priv->entrylk_count);
+ if (ret) {
+ op_errno = EIO;
+ goto out;
+ }
+
+ op_ret = 0;
+ goto out;
+ }
+
if (strncmp (name, GF_XATTR_CLRLK_CMD, strlen (GF_XATTR_CLRLK_CMD)))
goto usual;
@@ -3679,6 +3719,10 @@ init (xlator_t *this)
priv = GF_CALLOC (1, sizeof (*priv),
gf_locks_mt_posix_locks_private_t);
+#ifndef HAVE_ATOMIC_BUILTINS
+ pthread_mutex_init (&priv->lock, NULL);
+#endif
+
GF_OPTION_INIT ("mandatory-locking", tmp_str, str, out);
if (!strcmp (tmp_str, "forced"))
priv->mandatory_mode = MLK_FORCED;
@@ -3735,6 +3779,10 @@ fini (xlator_t *this)
GF_FREE (priv->brickname);
GF_FREE (priv);
+#ifndef HAVE_ATOMIC_BUILTINS
+ pthread_mutex_destroy (&priv->lock);
+#endif
+
return 0;
}