From 5c30bda609f99e3360e11dc3e6ac2c727a11171a Mon Sep 17 00:00:00 2001 From: krad Date: Thu, 22 Jun 2017 10:53:41 -0700 Subject: 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 Reviewed-on: https://review.gluster.org/18273 Reviewed-by: Jeff Darcy Tested-by: Jeff Darcy CentOS-regression: Gluster Build System Smoke: Gluster Build System --- xlators/debug/io-stats/src/io-stats.c | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'xlators/debug/io-stats/src') diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 408908cbd9b..f1970a41c3b 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -302,6 +302,7 @@ struct ios_conf { int32_t ios_dnscache_ttl_sec; gf_boolean_t iamshd; gf_boolean_t iamnfsd; + gf_boolean_t iambrickd; gf_boolean_t iamgfproxyd; gf_boolean_t audit_creates_and_unlinks; gf_boolean_t sample_hard_errors; @@ -1022,6 +1023,9 @@ io_stats_dump_global_to_json_logfp (xlator_t *this, { int i = 0; int j = 0; + int32_t inodelk_count = -1; + int32_t entrylk_count = -1; + dict_t *xattr = NULL; struct ios_conf *conf = NULL; char *key_prefix = NULL; char *str_prefix = NULL; @@ -1064,6 +1068,46 @@ io_stats_dump_global_to_json_logfp (xlator_t *this, ios_log (this, logfp, "\"%s.%s.outstanding_req\": \"%u\",", key_prefix, str_prefix, conf->outstanding_req); + if (conf->iambrickd) { + ret = syncop_getxattr (FIRST_CHILD (this), &unused_loc, + &xattr, GLUSTERFS_INODELK_COUNT, + NULL, NULL); + if (ret == 0 && xattr) { + if (dict_get_int32 (xattr, GLUSTERFS_INODELK_COUNT, + &inodelk_count) != 0) { + gf_log (this->name, GF_LOG_DEBUG, + "Error fetching %s", + GLUSTERFS_INODELK_COUNT); + } + } else { + gf_log (this->name, GF_LOG_DEBUG, + "Unable to get inode lock count counts " + "from the posix-locks translator!"); + } + + ios_log (this, logfp, "\"%s.%s.inodelk_count\": \"%u\",", + key_prefix, str_prefix, inodelk_count); + + ret = syncop_getxattr (FIRST_CHILD (this), &unused_loc, &xattr, + GLUSTERFS_ENTRYLK_COUNT, NULL, NULL); + if (ret == 0 && xattr) { + if (dict_get_int32 (xattr, GLUSTERFS_ENTRYLK_COUNT, + &entrylk_count) != 0) { + gf_log (this->name, GF_LOG_DEBUG, + "Error fetching %s", + GLUSTERFS_ENTRYLK_COUNT); + } + dict_unref (xattr); + } else { + gf_log (this->name, GF_LOG_DEBUG, + "Unable to get entry lock count counts " + "from the posix-locks translator!"); + } + + ios_log (this, logfp, "\"%s.%s.entrylk_count\": \"%u\",", + key_prefix, str_prefix, entrylk_count); + } + for (i = 0; i < 31; i++) { rw_size = (1 << i); if (rw_size >= 1024 * 1024) { @@ -4363,6 +4407,8 @@ init (xlator_t *this) GF_OPTION_INIT ("iam-nfs-daemon", conf->iamnfsd, bool, out); + GF_OPTION_INIT ("iam-brick-daemon", conf->iambrickd, bool, out); + GF_OPTION_INIT ("iam-gfproxy-daemon", conf->iamgfproxyd, bool, out); GF_OPTION_INIT ("fop-sample-hard-errors", conf->sample_hard_errors, @@ -4807,6 +4853,13 @@ struct volume_options options[] = { "translator is running as part of an NFS daemon " "or not." }, + { .key = {"iam-brick-daemon"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "This option differentiates if the io-stats " + "translator is running as part of brick daemon " + "or not." + }, { .key = {"iam-gfproxy-daemon"}, .type = GF_OPTION_TYPE_BOOL, .default_value = "off", -- cgit