Blob Blame History Raw
From 56fb13d05cb4465c14cc231bab1296a48c33c57d Mon Sep 17 00:00:00 2001
From: Mohit Agrawal <moagrawa@redhat.com>
Date: Tue, 6 Nov 2018 09:06:34 +0530
Subject: [PATCH 419/444] glusterfs: During reconfigure set log-level per
 xlator level

Problem: In brick_mux environment, while a user has enabled brick-log-level
         for anyone volume, it automatically enables for other volumes
         also those are attached with same brick.

Solution: A log-level option is automatically enabled for other volumes
          because log-level saved in glusterfsd_ctx and ctx is common for
          volumes those are attached with same brick. To resolve it
          set log level for all children xlator's at the time of the graph
          reconfigure at io-stat xlator.

> Change-Id: Id9a6efa05d286e0bea2d47f49292d084e7bb2fcf
> fixes: bz#1640495
> (Reviwed on upstream link https://review.gluster.org/#/c/glusterfs/+/20488/)
> (Cherry pick from commit c34e4161f3cb6539ec83a9020f3d27eb4759a975)

Change-Id: I1dd57c52997f16e8a05f982c6c05bb4f758e8bd3
BUG: 1598407
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/155021
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 xlators/debug/io-stats/src/io-stats.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 0f71334..aade097 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -3812,6 +3812,35 @@ ios_set_log_format_code (struct ios_conf *conf)
                 conf->dump_format = IOS_DUMP_TYPE_SAMPLES;
 }
 
+void
+xlator_set_loglevel(xlator_t *this, int log_level)
+{
+    glusterfs_ctx_t *ctx = NULL;
+    glusterfs_graph_t *active = NULL;
+    xlator_t *top = NULL;
+    xlator_t *trav = this;
+
+    ctx = this->ctx;
+    GF_ASSERT(ctx);
+    active = ctx->active;
+    top = active->first;
+
+    if (strcmp(top->type, "protocol/server") || (log_level == -1))
+        return;
+
+    /* Set log-level for server xlator */
+    top->loglevel = log_level;
+
+    /* Set log-level for parent xlator */
+    if (this->parents)
+        this->parents->xlator->loglevel = log_level;
+
+    while (trav) {
+        trav->loglevel = log_level;
+        trav = trav->next;
+    }
+}
+
 int
 reconfigure (xlator_t *this, dict_t *options)
 {
@@ -3867,7 +3896,8 @@ reconfigure (xlator_t *this, dict_t *options)
         GF_OPTION_RECONF ("log-level", log_str, options, str, out);
         if (log_str) {
                 log_level = glusterd_check_log_level (log_str);
-                gf_log_set_loglevel (log_level);
+                /* Set loglevel for all children and server xlators */
+                xlator_set_loglevel(this, log_level);
         }
 
         GF_OPTION_RECONF ("logger", logger_str, options, str, out);
-- 
1.8.3.1