From 0bbe6f776e68a77225ef64a19d5f043c052b570a Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Tue, 7 Jul 2015 16:27:45 +0530 Subject: rebalance/glusterd: Refactor rebalance volfile 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 >Reviewed-on: http://review.gluster.org/11565 >Tested-by: NetBSD Build System >Tested-by: Gluster Build System >Reviewed-by: Dan Lambright >Reviewed-by: Atin Mukherjee (cherry picked from commit 16bd894480b34e20950af795dc1ebb66d942541a) Change-Id: I967754fd69629e983ff355e1f60eb91bbaa96b9a BUG: 1252727 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/11889 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: N Balachandran Reviewed-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 98 ++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 24 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 8f3e912fdab..a08d8845c8b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3527,7 +3527,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); @@ -3745,19 +3744,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); @@ -4204,6 +4196,73 @@ out: return clusters; } +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, @@ -4864,19 +4923,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, -- cgit