diff options
author | Avra Sengupta <asengupt@redhat.com> | 2014-11-24 08:24:24 +0000 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2014-11-30 23:09:44 -0800 |
commit | a93164cd2a7f7ec37cf30d52b1a73fdc211981c3 (patch) | |
tree | 637079704020927ecd961aaa951f3af17eb6d344 /xlators/mgmt/glusterd/src | |
parent | 92242ecd1047fe23ca494555edd6033685522c82 (diff) |
glusterd/uss: Create rebalance volfile.
Create a new rebalance volfile, which will not contain
snap-view client translators, irrespective of the status
of USS.
This volfile, will be created and regenerated everytime
the fuse-volfile is generated, and will be consumed
by the rebalance process.
Change-Id: I514a8e88d06c0b8fb6949c3a3e6dc4dbe55e38af
BUG: 1164711
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/9190
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 20 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 40 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 61 |
5 files changed, 117 insertions, 21 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 8c9194e1961..8414fa8e9bb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -230,6 +230,26 @@ build_volfile_path (char *volume_id, char *path, } + volid_ptr = strstr (volume_id, "rebalance/"); + if (volid_ptr) { + volid_ptr = strchr (volid_ptr, '/'); + if (!volid_ptr) { + ret = -1; + goto out; + } + volid_ptr++; + + ret = glusterd_volinfo_find (volid_ptr, &volinfo); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, + "Couldn't find volinfo"); + goto out; + } + glusterd_get_rebalance_volfile (volinfo, path, path_len); + ret = 0; + goto out; + } + if (volume_id[0] == '/') { /* Normal behavior */ volid_ptr = volume_id; diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index fd63a9bafc6..c986fc12e7b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -207,6 +207,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, char sockfile[PATH_MAX] = {0,}; char pidfile[PATH_MAX] = {0,}; char logfile[PATH_MAX] = {0,}; + char volname[PATH_MAX] = {0,}; char valgrind_logfile[PATH_MAX] = {0,}; priv = THIS->private; @@ -264,8 +265,9 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, runner_argprintf (&runner, "--log-file=%s", valgrind_logfile); } + snprintf (volname, sizeof(volname), "rebalance/%s", volinfo->volname); runner_add_args (&runner, SBIN_DIR"/glusterfs", - "-s", "localhost", "--volfile-id", volinfo->volname, + "-s", "localhost", "--volfile-id", volname, "--xlator-option", "*dht.use-readdirp=yes", "--xlator-option", "*dht.lookup-unhashed=yes", "--xlator-option", "*dht.assert-no-child-down=yes", @@ -804,19 +806,41 @@ out: int32_t glusterd_defrag_event_notify_handle (dict_t *dict) { - glusterd_volinfo_t *volinfo = NULL; - char *volname = NULL; - int32_t ret = -1; + glusterd_volinfo_t *volinfo = NULL; + char *volname = NULL; + char *volname_ptr = NULL; + int32_t ret = -1; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (dict); ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("", GF_LOG_ERROR, "Failed to get volname"); + gf_log (this->name, GF_LOG_ERROR, "Failed to get volname"); return ret; } + volname_ptr = strstr (volname, "rebalance/"); + if (volname_ptr) { + volname_ptr = strchr (volname_ptr, '/'); + if (!volname_ptr) { + ret = -1; + goto out; + } + volname = volname_ptr + 1; + } else { + gf_log (this->name, GF_LOG_ERROR, + "volname recieved (%s) is not prefixed with rebalance.", + volname); + ret = -1; + goto out; + } + ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log ("", GF_LOG_ERROR, "Failed to get volinfo for %s" + gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo for %s" , volname); return ret; } @@ -824,6 +848,8 @@ glusterd_defrag_event_notify_handle (dict_t *dict) ret = glusterd_defrag_volume_status_update (volinfo, dict); if (ret) - gf_log ("", GF_LOG_ERROR, "Failed to update status"); + gf_log (this->name, GF_LOG_ERROR, "Failed to update status"); + +out: return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 39323897045..d8b7e78a340 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -13136,6 +13136,19 @@ out: return ret; } +void +glusterd_get_rebalance_volfile (glusterd_volinfo_t *volinfo, + char *path, int path_len) +{ + char workdir[PATH_MAX] = {0,}; + glusterd_conf_t *priv = THIS->private; + + GLUSTERD_GET_VOLUME_DIR (workdir, volinfo, priv); + + snprintf (path, path_len, "%s/%s-rebalance.vol", workdir, + volinfo->volname); +} + /* Snapd functions */ int glusterd_is_snapd_enabled (glusterd_volinfo_t *volinfo) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 6cc34b5c2a7..511d36d5294 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -921,4 +921,8 @@ glusterd_op_clear_xaction_peers (); gf_boolean_t mntopts_exists (const char *str, const char *opts); + +void +glusterd_get_rebalance_volfile (glusterd_volinfo_t *volinfo, + char *path, int path_len); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 247f369274f..b0c82632c45 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -2690,14 +2690,16 @@ static int client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, void *param) { - int ret = 0; - xlator_t *xl = NULL; - char *volname = NULL; - glusterd_conf_t *conf = THIS->private; - char *tmp = NULL; - gf_boolean_t var = _gf_false; - gf_boolean_t ob = _gf_false; - xlator_t *this = THIS; + int ret = 0; + xlator_t *xl = NULL; + char *volname = NULL; + glusterd_conf_t *conf = THIS->private; + char *tmp = NULL; + 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); GF_ASSERT (conf); @@ -2881,14 +2883,24 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (ret) goto out; - ret = dict_get_str_boolean (set_dict, "features.uss", _gf_false); - if (ret == -1) + uss_enabled = dict_get_str_boolean (set_dict, "features.uss", + _gf_false); + if (uss_enabled == -1) goto out; - if (ret && !volinfo->is_snap_volume) { - ret = volgen_graph_build_snapview_client - (graph, volinfo, volname, set_dict); - if (ret == -1) + 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; + } } /* add debug translators depending on the options */ @@ -3895,6 +3907,27 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo, if (ret) goto out; } + + /* Generate volfile for rebalance process */ + ret = dict_set_int32 (dict, "rebalance-volfile-creation", _gf_true); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to set rebalance-volfile-creation"); + goto out; + } + + glusterd_get_rebalance_volfile (volinfo, filepath, PATH_MAX); + + ret = generate_single_transport_client_volfile (volinfo, + filepath, + dict); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to create rebalance volfile for %s", + volinfo->volname); + goto out; + } + out: if (dict) dict_unref (dict); |