14f8ab
From baa566be8832a56fdea7068d84844ec1ec84d8d9 Mon Sep 17 00:00:00 2001
14f8ab
From: mohit84 <moagrawa@redhat.com>
14f8ab
Date: Thu, 15 Oct 2020 16:28:58 +0530
14f8ab
Subject: [PATCH 504/511] io-stats: Configure ios_sample_buf_size based on
14f8ab
 sample_interval value (#1574)
14f8ab
14f8ab
io-stats xlator declares a ios_sample_buf_size 64k object(10M) per xlator
14f8ab
but in case of sample_interval is 0 this big buffer is not required so
14f8ab
declare the default value only while sample_interval is not 0.The new
14f8ab
change would be helpful to reduce RSS size for a brick and shd process
14f8ab
while the number of volumes are huge.
14f8ab
14f8ab
> Change-Id: I3e82cca92e40549355edfac32580169f3ce51af8
14f8ab
> Fixes: #1542
14f8ab
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
14f8ab
> (Cherry picked from commit f71660eb879a9cd5761e5adbf10c783e959a990a)
14f8ab
> (Reviewed on upstream link https://github.com/gluster/glusterfs/issues/1542)
14f8ab
14f8ab
Change-Id: I3e82cca92e40549355edfac32580169f3ce51af8
14f8ab
BUG: 1898778
14f8ab
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/221183
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 tests/bugs/glusterd/daemon-log-level-option.t |  8 ++++----
14f8ab
 xlators/debug/io-stats/src/io-stats.c         | 26 ++++++++++++++++++++++----
14f8ab
 2 files changed, 26 insertions(+), 8 deletions(-)
14f8ab
14f8ab
diff --git a/tests/bugs/glusterd/daemon-log-level-option.t b/tests/bugs/glusterd/daemon-log-level-option.t
14f8ab
index 66e55e3..5352a63 100644
14f8ab
--- a/tests/bugs/glusterd/daemon-log-level-option.t
14f8ab
+++ b/tests/bugs/glusterd/daemon-log-level-option.t
14f8ab
@@ -61,8 +61,8 @@ rm -f /var/log/glusterfs/glustershd.log
14f8ab
 TEST $CLI volume set all cluster.daemon-log-level WARNING
14f8ab
 TEST $CLI volume start $V0
14f8ab
 
14f8ab
-# log should not have any info messages
14f8ab
-EXPECT 0 Info_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
+# log does have 1 info message specific to configure ios_sample_buf_size in io-stats xlator
14f8ab
+EXPECT 1 Info_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
 
14f8ab
 # log should not have any debug messages
14f8ab
 EXPECT 0 Debug_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
@@ -78,8 +78,8 @@ rm -f /var/log/glusterfs/glustershd.log
14f8ab
 TEST $CLI volume set all cluster.daemon-log-level ERROR
14f8ab
 TEST $CLI volume start $V0
14f8ab
 
14f8ab
-# log should not have any info messages
14f8ab
-EXPECT 0 Info_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
+# log does have 1 info message specific to configure ios_sample_buf_size in io-stats xlator
14f8ab
+EXPECT 1 Info_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
 
14f8ab
 # log should not have any warning messages
14f8ab
 EXPECT 0 Warning_messages_count "/var/log/glusterfs/glustershd.log"
14f8ab
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
14f8ab
index aa91a0a..9b34895 100644
14f8ab
--- a/xlators/debug/io-stats/src/io-stats.c
14f8ab
+++ b/xlators/debug/io-stats/src/io-stats.c
14f8ab
@@ -3724,6 +3724,15 @@ xlator_set_loglevel(xlator_t *this, int log_level)
14f8ab
     }
14f8ab
 }
14f8ab
 
14f8ab
+void
14f8ab
+ios_sample_buf_size_configure(char *name, struct ios_conf *conf)
14f8ab
+{
14f8ab
+    conf->ios_sample_buf_size = 1024;
14f8ab
+    gf_log(name, GF_LOG_INFO,
14f8ab
+           "Configure ios_sample_buf "
14f8ab
+           " size is 1024 because ios_sample_interval is 0");
14f8ab
+}
14f8ab
+
14f8ab
 int
14f8ab
 reconfigure(xlator_t *this, dict_t *options)
14f8ab
 {
14f8ab
@@ -3779,8 +3788,13 @@ reconfigure(xlator_t *this, dict_t *options)
14f8ab
                      int32, out);
14f8ab
     GF_OPTION_RECONF("ios-dump-format", dump_format_str, options, str, out);
14f8ab
     ios_set_log_format_code(conf, dump_format_str);
14f8ab
-    GF_OPTION_RECONF("ios-sample-buf-size", conf->ios_sample_buf_size, options,
14f8ab
-                     int32, out);
14f8ab
+    if (conf->ios_sample_interval) {
14f8ab
+        GF_OPTION_RECONF("ios-sample-buf-size", conf->ios_sample_buf_size,
14f8ab
+                         options, int32, out);
14f8ab
+    } else {
14f8ab
+        ios_sample_buf_size_configure(this->name, conf);
14f8ab
+    }
14f8ab
+
14f8ab
     GF_OPTION_RECONF("sys-log-level", sys_log_str, options, str, out);
14f8ab
     if (sys_log_str) {
14f8ab
         sys_log_level = glusterd_check_log_level(sys_log_str);
14f8ab
@@ -3947,8 +3961,12 @@ init(xlator_t *this)
14f8ab
     GF_OPTION_INIT("ios-dump-format", dump_format_str, str, out);
14f8ab
     ios_set_log_format_code(conf, dump_format_str);
14f8ab
 
14f8ab
-    GF_OPTION_INIT("ios-sample-buf-size", conf->ios_sample_buf_size, int32,
14f8ab
-                   out);
14f8ab
+    if (conf->ios_sample_interval) {
14f8ab
+        GF_OPTION_INIT("ios-sample-buf-size", conf->ios_sample_buf_size, int32,
14f8ab
+                       out);
14f8ab
+    } else {
14f8ab
+        ios_sample_buf_size_configure(this->name, conf);
14f8ab
+    }
14f8ab
 
14f8ab
     ret = ios_init_sample_buf(conf);
14f8ab
     if (ret) {
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab