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