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