Blob Blame History Raw
From f330d80bf821fee47572d7d640a4a3aa41f4875c Mon Sep 17 00:00:00 2001
From: Jeff Darcy <jdarcy@redhat.com>
Date: Tue, 26 Jul 2016 08:49:36 -0400
Subject: [PATCH 367/369] io-stats: fix translator names

We use the first name of the xlator as brick name to
find the right graph from many multiplexed graphs.

And then we search any specific xlator on the graph
Backport of >
>Change-Id: Icf5afaee8b7c704aecab7f8a8a1df9f1bc9288ce
>BUG: 1360401
>Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
>Reviewed-on: http://review.gluster.org/15016
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Vijay Bellur <vbellur@redhat.com>

Change-Id: I8ea78e497b9729a8cdbd90a26f7747365d976547
BUG: 1438378
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/102371
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 glusterfsd/src/glusterfsd-mgmt.c            |  9 +++++++++
 xlators/debug/io-stats/src/io-stats.c       | 30 +++++++++++++++++++++++++----
 xlators/mgmt/glusterd/src/glusterd-volgen.c |  9 +++++++--
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 9a7ed0d..36a658f 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -407,6 +407,15 @@ cont:
                 goto out;
         }
 
+        /*
+         * Searching by name will only get us to the decompounder translator,
+         * but we really want io-stats.  Since we know the exact relationship
+         * between these two, it's easy to get from one to the other.
+         *
+         * TBD: should this even be notify, or something else?
+         */
+        xlator = FIRST_CHILD(xlator);
+
         output = dict_new ();
         ret = xlator->notify (xlator, GF_EVENT_TRANSLATOR_INFO, dict, output);
 
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index c2375d9..5875616 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -147,6 +147,18 @@ struct ios_conf {
         ios_sample_buf_t          *ios_sample_buf;
         struct dnscache           *dnscache;
         int32_t                   ios_dnscache_ttl_sec;
+        /*
+         * What we really need here is just a unique value to keep files
+         * created by this instance distinct from those created by any other.
+         * On the client side this isn't a problem, so we just use the
+         * translator name.  On the server side conflicts can occur, so the
+         * volfile-generation code automatically sets this (via an option)
+         * to be the brick path.
+         *
+         * NB While the *field* name has changed, it didn't seem worth changing
+         * all of the cases where "xlator_name" is used as a *variable* name.
+         */
+        char                      *unique_id;
 };
 
 
@@ -716,8 +728,9 @@ _io_stats_get_key_prefix (xlator_t *this, char **key_prefix) {
         int                   bytes_written = 0;
         int                   i = 0;
         int                   ret = 0;
+        struct ios_conf       *conf = this->private;
 
-        xlator_name = strdupa (this->name);
+        xlator_name = strdupa (conf->unique_id);
         for (i = 0; i < strlen (xlator_name); i++) {
                 if (xlator_name[i] == '/')
                         xlator_name[i] = '_';
@@ -1070,7 +1083,7 @@ _io_stats_write_latency_sample (xlator_t *this, ios_sample_t *sample,
                         hostname = "Unknown";
         }
 
-        xlator_name = this->name;
+        xlator_name = conf->unique_id;
         if (!xlator_name || strlen (xlator_name) == 0)
                 xlator_name = "Unknown";
 
@@ -2959,7 +2972,7 @@ _ios_dump_thread (xlator_t *this) {
         conf = this->private;
         gf_log (this->name, GF_LOG_INFO, "IO stats dump thread started, "
                 "polling IO stats every %d seconds", conf->ios_dump_interval);
-        xlator_name = strdupa (this->name);
+        xlator_name = strdupa (conf->unique_id);
         for (i = 0; i < strlen (xlator_name); i++) {
                 if (xlator_name[i] == '/')
                         xlator_name[i] = '_';
@@ -3720,6 +3733,11 @@ init (xlator_t *this)
         if (!conf)
                 goto out;
 
+        if (dict_get_str (this->options, "unique-id", &conf->unique_id) != 0) {
+                /* This is always set on servers, so we must be a client. */
+                conf->unique_id = this->name;
+        }
+
         /*
          * Init it just after calloc, so that we are sure the lock is inited
          * in case of error paths.
@@ -3790,7 +3808,6 @@ init (xlator_t *this)
         GF_OPTION_INIT ("log-flush-timeout", log_flush_timeout, time, out);
         gf_log_set_log_flush_timeout (log_flush_timeout);
 
-
         this->private = conf;
         if (conf->ios_dump_interval > 0) {
                 pthread_create (&conf->dump_thread, NULL,
@@ -4184,6 +4201,11 @@ struct volume_options options[] = {
                          "log messages that can be buffered for a time equal to"
                          " the value of the option brick-log-flush-timeout."
         },
+        { .key = {"unique-id"},
+          .type = GF_OPTION_TYPE_STR,
+          .default_value = "/no/such/path",
+          .description = "Unique ID for our files."
+        },
         { .key  = {NULL} },
 
 };
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index d5ea166..c906306 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1543,7 +1543,8 @@ brick_graph_add_decompounder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo
         conf = this->private;
         GF_VALIDATE_OR_GOTO (this->name, conf, out);
 
-        xl = volgen_graph_add (graph, "performance/decompounder", volinfo->volname);
+        xl = volgen_graph_add_as (graph, "performance/decompounder",
+                                  brickinfo->path);
         if (xl)
                 ret = 0;
 out:
@@ -2057,10 +2058,14 @@ brick_graph_add_io_stats (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
         if (!graph || !volinfo || !set_dict || !brickinfo)
                 goto out;
 
-        xl = volgen_graph_add_as (graph, "debug/io-stats", brickinfo->path);
+        xl = volgen_graph_add (graph, "debug/io-stats", volinfo->volname);
         if (!xl)
                 goto out;
 
+        ret = xlator_set_option (xl, "unique-id", brickinfo->path);
+        if (ret)
+                goto out;
+
         ret = 0;
 out:
         return ret;
-- 
1.8.3.1