Blob Blame History Raw
From 374e94cd9670ee9f0ef997edfde6f9198d5494b5 Mon Sep 17 00:00:00 2001
From: Mohammed Rafi KC <rkavunga@redhat.com>
Date: Tue, 7 Jul 2015 16:27:45 +0530
Subject: [PATCH 271/279] rebalance/glusterd: Refactor rebalance volfile

        Back port of http://review.gluster.org/11889

performance xlator loaded in rebalance xlators are dummy
translators, since all fops are starting with dht level.

Removing the performance xlators from rebalance volfile
will help to minimize the chance for a graph switch.

The new rebalance xlators will look like->>>

                        (io-stats)
                            ||
                            ||
                            ||
                       (----DHT----)
                      //          \\
                     //            \\
                    //              \\
              (replica-1)  ...   (replica-n)
              //      \\          //      \\
             //        \\        //        \\
            //          \\      //          \\
         client       client  client       client

Back port of :
>Change-Id: I3808e3b48fd0cb3e60ef386b8ac9fd994e2831e3
>BUG: 1240621
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
>Reviewed-on: http://review.gluster.org/11565
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: Dan Lambright <dlambrig@redhat.com>
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>

>(cherry picked from commit 16bd894480b34e20950af795dc1ebb66d942541a)

>Change-Id: I967754fd69629e983ff355e1f60eb91bbaa96b9a
>BUG: 1252727
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
>Reviewed-on: http://review.gluster.org/11889
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: N Balachandran <nbalacha@redhat.com>
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>

Change-Id: I7a05bcb734273ab6fcac6296c0e15cdb9d31e7b3
BUG: 1253549
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/55292
Reviewed-by: Nithya Balachandran <nbalacha@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-volgen.c |   98 ++++++++++++++++++++-------
 1 files changed, 74 insertions(+), 24 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 836ec3e..3d04e9f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -3534,7 +3534,6 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
         gf_boolean_t     var           = _gf_false;
         gf_boolean_t     ob            = _gf_false;
         gf_boolean_t     uss_enabled   = _gf_false;
-        gf_boolean_t     rebal_volfile = _gf_false;
         xlator_t        *this          = THIS;
 
         GF_ASSERT (this);
@@ -3752,19 +3751,12 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
         if (uss_enabled == -1)
                 goto out;
         if (uss_enabled && !volinfo->is_snap_volume) {
-                rebal_volfile = dict_get_str_boolean (set_dict,
-                                                   "rebalance-volfile-creation",
-                                                   _gf_false);
-                if (rebal_volfile == -1)
-                        goto out;
 
-                if (!rebal_volfile) {
-                        ret = volgen_graph_build_snapview_client
-                                                   (graph, volinfo,
-                                                    volname, set_dict);
-                        if (ret == -1)
-                                goto out;
-                }
+                ret = volgen_graph_build_snapview_client
+                                           (graph, volinfo,
+                                            volname, set_dict);
+                if (ret == -1)
+                        goto out;
         }
 
         ret = dict_get_str_boolean (set_dict, "ganesha.enable", _gf_false);
@@ -4212,6 +4204,73 @@ out:
 }
 
 static int
+build_rebalance_volfile (glusterd_volinfo_t *volinfo, char *filepath,
+                         dict_t *mod_dict)
+{
+        volgen_graph_t          graph           = {0,};
+        xlator_t                *xl             = NULL;
+        int                     ret             = -1;
+        xlator_t                *this           = NULL;
+        dict_t                  *set_dict       = NULL;
+
+        this = THIS;
+
+        if (volinfo->brick_count <= volinfo->dist_leaf_count) {
+                /*
+                 * Volume is not a distribute volume or
+                 * contains only 1 brick, no need to create
+                 * the volfiles.
+                 */
+                return 0;
+        }
+
+        if (mod_dict) {
+                set_dict = dict_copy (volinfo->dict, NULL);
+                if (!set_dict)
+                        return -1;
+                 dict_copy (mod_dict, set_dict);
+                 /* XXX dict_copy swallows errors */
+        } else {
+                set_dict = volinfo->dict;
+        }
+
+
+        ret = volgen_graph_build_clients (&graph, volinfo, set_dict, NULL);
+        if (volinfo->type == GF_CLUSTER_TYPE_TIER)
+                ret = volume_volgen_graph_build_clusters_tier
+                                        (&graph, volinfo, _gf_false);
+        else
+                ret = volume_volgen_graph_build_clusters
+                                        (&graph, volinfo, _gf_false);
+
+        xl = volgen_graph_add_as (&graph, "debug/io-stats", volinfo->volname);
+        if (!xl) {
+                ret = -1;
+                goto out;
+        }
+
+        ret = graph_set_generic_options (this, &graph, set_dict,
+                                         "rebalance-daemon");
+        if (ret)
+                goto out;
+
+        ret = volgen_graph_set_options_generic (&graph, set_dict, volinfo,
+                                                basic_option_handler);
+
+        if (!ret)
+                ret = volgen_write_volfile (&graph, filepath);
+
+out:
+        volgen_graph_free (&graph);
+
+        if (mod_dict)
+                dict_destroy (set_dict);
+
+
+        return ret;
+
+}
+static int
 build_shd_volume_graph (xlator_t *this, volgen_graph_t *graph,
                         glusterd_volinfo_t *volinfo,
                         dict_t *mod_dict, dict_t *set_dict,
@@ -4871,19 +4930,10 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
         }
 
         /* Generate volfile for rebalance process */
-        ret = dict_set_int32 (dict, "rebalance-volfile-creation", _gf_true);
-        if (ret) {
-                gf_msg (this->name, GF_LOG_ERROR, errno,
-                        GD_MSG_DICT_SET_FAILED,
-                        "Failed to set rebalance-volfile-creation");
-                goto out;
-        }
-
         glusterd_get_rebalance_volfile (volinfo, filepath, PATH_MAX);
+        ret = build_rebalance_volfile (volinfo, filepath, dict);
+
 
-        ret = generate_single_transport_client_volfile (volinfo,
-                                                        filepath,
-                                                        dict);
         if (ret) {
                 gf_msg (this->name, GF_LOG_ERROR, 0,
                         GD_MSG_VOLFILE_CREATE_FAIL,
-- 
1.7.1