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