summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c40
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c61
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 f2e7338a80e..1631290ad69 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",
@@ -774,19 +776,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;
}
@@ -794,6 +818,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 d4521679d86..0589704bc48 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -13114,6 +13114,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 77e51f6b61d..368b6627159 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -906,4 +906,8 @@ glusterd_have_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 f38616ffbc7..90e22bec5c3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -2817,14 +2817,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);
@@ -3007,14 +3009,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 */
@@ -4021,6 +4033,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);