Patchwork [BUG:1789,1/1] io-stats, volgen: make the distinction between client and brick loglevel in volgen's scope

login
register
Submitter Csaba Henk
Date 2010-10-08 15:22:52
Message ID <1286551372-16866-1-git-send-email-csaba@gluster.com>
Download mbox | patch
Permalink /patch/5370/
State Accepted
Headers show

Comments

Csaba Henk - 2010-10-08 15:22:52
Signed-off-by: Csaba Henk <csaba@gluster.com>
---
 xlators/debug/io-stats/src/io-stats.c       |    9 +-----
 xlators/mgmt/glusterd/src/glusterd-volgen.c |   41 ++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 12 deletions(-)

Patch

diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 2061d9b..c72545b 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -1586,11 +1586,7 @@  reconfigure (xlator_t *this, dict_t *options)
         if (!ctx)
                 return -1;
 
-        if (ctx->cmd_args.brick_name)
-                ret = dict_get_str (options, "log-level", &log_str);
-        else
-                ret = dict_get_str (options, "client-log-level", &log_str);
-
+        ret = dict_get_str (options, "log-level", &log_str);
         if (!ret) {
                 if (!is_gf_log_command(this, "trusted.glusterfs*set-log-level", log_str)) {
                         gf_log (this->name, GF_LOG_DEBUG,
@@ -1762,8 +1758,5 @@  struct volume_options options[] = {
         { .key = {"log-level"},
           .type = GF_OPTION_TYPE_STR,
         },
-        { .key = {"client-log-level"},
-          .type = GF_OPTION_TYPE_STR,
-        },
         { .key  = {NULL} },
 };
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 639504f..f46cc2a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -102,8 +102,8 @@  static struct volopt_map_entry glusterd_volopt_map[] = {
 
         {"diagnostics.latency-measurement",      "debug/io-stats",            },
         {"diagnostics.dump-fd-stats",            "debug/io-stats",            },
-        {"diagnostics.brick-log-level",          "debug/io-stats",            "log-level",},
-        {"diagnostics.client-log-level",         "debug/io-stats",            },
+        {"diagnostics.brick-log-level",          "debug/io-stats",            "!log-level",},
+        {"diagnostics.client-log-level",         "debug/io-stats",            "!log-level",},
 
         {"performance.cache-max-file-size",      "performance/io-cache",      "max-file-size",},
         {"performance.cache-min-file-size",      "performance/io-cache",      "min-file-size",},
@@ -942,6 +942,36 @@  server_auth_option_handler (glusterfs_graph_t *graph,
 }
 
 static int
+loglevel_option_handler (glusterfs_graph_t *graph,
+                         struct volopt_map_entry *vme, void *param)
+{
+        char *role = param;
+        struct volopt_map_entry vme2 = {0,};
+
+        if (strcmp (vme->option, "!log-level") != 0 ||
+            !strstr (vme->key, role))
+                return 0;
+
+        memcpy (&vme2, vme, sizeof (vme2));
+        vme2.option = "log-level";
+
+        return basic_option_handler (graph, &vme2, NULL);
+}
+
+static int
+server_spec_option_handler (glusterfs_graph_t *graph,
+                            struct volopt_map_entry *vme, void *param)
+{
+        int ret = 0;
+
+        ret = server_auth_option_handler (graph, vme, NULL);
+        if (!ret)
+                ret = loglevel_option_handler (graph, vme, "brick");
+
+        return ret;
+}
+
+static int
 server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
                       dict_t *set_dict, void *param)
 {
@@ -1024,7 +1054,7 @@  server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
                 return -1;
 
         ret = volgen_graph_set_options_generic (graph, set_dict, NULL,
-                                                &server_auth_option_handler);
+                                                &server_spec_option_handler);
 
         return ret;
 }
@@ -1199,7 +1229,10 @@  client_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
         if (!xl)
                 return -1;
 
-        return 0;
+        ret = volgen_graph_set_options_generic (graph, set_dict, "client",
+                                                &loglevel_option_handler);
+
+        return ret;
 }