summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c154
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c92
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h1
4 files changed, 183 insertions, 67 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index f4c5f1cb685..74d28a71898 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -3735,18 +3735,22 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave,
char *conf_path, gf_boolean_t is_force)
{
- int ret = 0;
- glusterd_conf_t *priv = NULL;
- char *status_msg = NULL;
- gf_boolean_t is_running = _gf_false;
- char *op_errstr = NULL;
+ int ret = 0;
+ glusterd_conf_t *priv = NULL;
+ char *status_msg = NULL;
+ gf_boolean_t is_running = _gf_false;
+ char *op_errstr = NULL;
+ char *key = NULL;
+ xlator_t *this = NULL;
GF_ASSERT (volinfo);
GF_ASSERT (slave);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
- priv = THIS->private;
+ key = slave;
ret = glusterd_check_gsync_running_local (volinfo->volname,
slave, conf_path,
@@ -3761,13 +3765,28 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave,
if (ret == 0 && status_msg)
ret = dict_set_str (resp_dict, "gsync-status",
status_msg);
- if (ret == 0)
+ if (ret == 0) {
+ dict_del (volinfo->gsync_active_slaves, key);
ret = glusterd_start_gsync (volinfo, slave, path_list,
conf_path, uuid_utoa(MY_UUID),
NULL, _gf_false);
+ if (!ret) {
+ /* Add slave to the dict indicating geo-rep session is
+ * running.*/
+ ret = dict_set_dynstr_with_alloc (
+ volinfo->gsync_active_slaves,
+ key, "running");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to set "
+ "key:%s value:running in dict. But the "
+ "config succeeded.", key);
+ goto out;
+ }
+ }
+ }
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -4422,31 +4441,33 @@ out:
int
glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
{
- int32_t ret = -1;
- int32_t type = -1;
- char *host_uuid = NULL;
- char *slave = NULL;
- char *slave_url = NULL;
- char *slave_vol = NULL;
- char *slave_host = NULL;
- char *volname = NULL;
- char *path_list = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- glusterd_conf_t *priv = NULL;
- gf_boolean_t is_force = _gf_false;
- char *status_msg = NULL;
- gf_boolean_t is_running = _gf_false;
- char *conf_path = NULL;
- char errmsg[PATH_MAX] = "";
+ int32_t ret = -1;
+ int32_t type = -1;
+ char *host_uuid = NULL;
+ char *slave = NULL;
+ char *slave_url = NULL;
+ char *slave_vol = NULL;
+ char *slave_host = NULL;
+ char *volname = NULL;
+ char *path_list = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ glusterd_conf_t *priv = NULL;
+ gf_boolean_t is_force = _gf_false;
+ char *status_msg = NULL;
+ gf_boolean_t is_running = _gf_false;
+ char *conf_path = NULL;
+ char errmsg[PATH_MAX] = "";
+ char *key = NULL;
+ xlator_t *this = NULL;
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
GF_ASSERT (dict);
GF_ASSERT (op_errstr);
GF_ASSERT (rsp_dict);
- priv = THIS->private;
-
ret = dict_get_int32 (dict, "type", &type);
if (ret < 0)
goto out;
@@ -4464,27 +4485,31 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret < 0)
goto out;
+ key = slave;
+
ret = dict_get_str (dict, "slave_url", &slave_url);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch slave url.");
+ gf_log (this->name, GF_LOG_ERROR, "Unable to fetch slave url.");
goto out;
}
ret = dict_get_str (dict, "slave_host", &slave_host);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch slave hostname.");
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to fetch slave hostname.");
goto out;
}
ret = dict_get_str (dict, "slave_vol", &slave_vol);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch slave volume name.");
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to fetch slave volume name.");
goto out;
}
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"Unable to fetch conf file path.");
goto out;
}
@@ -4492,8 +4517,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (dict_get_str (dict, "master", &volname) == 0) {
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log ("", GF_LOG_WARNING, "Volinfo for %s (master)"
- " not found", volname);
+ gf_log (this->name, GF_LOG_WARNING, "Volinfo for"
+ " %s (master) not found", volname);
goto out;
}
@@ -4506,7 +4531,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (!ret) {
ret = dict_set_str (rsp_dict, "conf_path", conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"Unable to store conf_file_path.");
goto out;
}
@@ -4536,17 +4561,30 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_set_gsync_confs (volinfo);
if (ret != 0) {
- gf_log ("", GF_LOG_WARNING, "marker/changelog"
+ gf_log (this->name, GF_LOG_WARNING, "marker/changelog"
" start failed");
*op_errstr = gf_strdup ("Index initialization failed");
ret = -1;
goto out;
}
+ /* Add slave to the dict indicating geo-rep session is running*/
+ ret = dict_set_dynstr_with_alloc (volinfo->gsync_active_slaves,
+ key, "running");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to set key:%s"
+ " value:running in the dict", key);
+ goto out;
+ }
+
ret = glusterd_start_gsync (volinfo, slave, path_list,
conf_path, host_uuid, op_errstr,
_gf_false);
- }
+
+ /* Delete added slave in the dict if start fails*/
+ if (ret)
+ dict_del (volinfo->gsync_active_slaves, key);
+ }
if (type == GF_GSYNC_OPTION_TYPE_STOP ||
type == GF_GSYNC_OPTION_TYPE_PAUSE ||
@@ -4556,8 +4594,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
&is_running);
if (!ret && !is_force && path_list &&
(_gf_true != is_running)) {
- gf_log ("", GF_LOG_WARNING, GEOREP" is not set up for"
- "%s(master) and %s(slave)", volname, slave);
+ gf_log (this->name, GF_LOG_WARNING, GEOREP" is not set "
+ "up for %s(master) and %s(slave)",
+ volname, slave);
*op_errstr = strdup (GEOREP" is not set up");
goto out;
}
@@ -4568,17 +4607,35 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
conf_path, op_errstr,
_gf_true);
if (ret)
- gf_log("", GF_LOG_ERROR, GEOREP
+ gf_log(this->name, GF_LOG_ERROR, GEOREP
" Pause Failed");
+ else
+ dict_del (volinfo->gsync_active_slaves, key);
+
} else if (type == GF_GSYNC_OPTION_TYPE_RESUME) {
+
+ /* Add slave to the dict indicating geo-rep session is
+ * running*/
+ ret = dict_set_dynstr_with_alloc (
+ volinfo->gsync_active_slaves,
+ key, "running");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to set "
+ "key:%s value:running in dict", key);
+ goto out;
+ }
+
ret = gd_pause_or_resume_gsync (dict, volname, slave,
slave_host, slave_vol,
conf_path, op_errstr,
_gf_false);
- if (ret)
- gf_log("", GF_LOG_ERROR, GEOREP
+ if (ret) {
+ gf_log(this->name, GF_LOG_ERROR, GEOREP
" Resume Failed");
+ dict_del (volinfo->gsync_active_slaves, key);
+ }
} else {
+
ret = stop_gsync (volname, slave, &status_msg,
conf_path, op_errstr, is_force);
@@ -4591,10 +4648,11 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
slave, slave_host,
slave_vol,"Stopped");
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to "
- "update state_file. Error : %s",
- strerror (errno));
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to update state_file. "
+ "Error : %s", strerror (errno));
}
+ dict_del (volinfo->gsync_active_slaves, key);
}
}
}
@@ -4605,7 +4663,7 @@ out:
path_list = NULL;
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 46ec9eb2e5b..cfebadc3e1d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -485,8 +485,16 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
new_volinfo->gsync_slaves = dict_new ();
if (!new_volinfo->gsync_slaves) {
+ dict_unref (new_volinfo->dict);
GF_FREE (new_volinfo);
+ goto out;
+ }
+ new_volinfo->gsync_active_slaves = dict_new ();
+ if (!new_volinfo->gsync_active_slaves) {
+ dict_unref (new_volinfo->dict);
+ dict_unref (new_volinfo->gsync_slaves);
+ GF_FREE (new_volinfo);
goto out;
}
@@ -550,6 +558,8 @@ glusterd_volinfo_dup (glusterd_volinfo_t *volinfo,
dict_copy (volinfo->dict, new_volinfo->dict);
dict_copy (volinfo->gsync_slaves, new_volinfo->gsync_slaves);
+ dict_copy (volinfo->gsync_active_slaves,
+ new_volinfo->gsync_active_slaves);
gd_update_volume_op_versions (new_volinfo);
if (set_userauth) {
@@ -616,6 +626,29 @@ glusterd_brickinfo_dup (glusterd_brickinfo_t *brickinfo,
out:
return ret;
}
+/*
+ * gd_vol_is_geo_rep_active:
+ * This function checks for any running geo-rep session for
+ * the volume given.
+ *
+ * Return Value:
+ * _gf_true : If any running geo-rep session.
+ * _gf_false: If no running geo-rep session.
+ */
+
+gf_boolean_t
+gd_vol_is_geo_rep_active (glusterd_volinfo_t *volinfo)
+{
+ gf_boolean_t active = _gf_false;
+
+ GF_ASSERT (volinfo);
+
+ if (volinfo->gsync_active_slaves &&
+ volinfo->gsync_active_slaves->count > 0)
+ active = _gf_true;
+
+ return active;
+}
/*
* glusterd_snap_geo_rep_restore:
@@ -936,6 +969,8 @@ glusterd_volinfo_delete (glusterd_volinfo_t *volinfo)
dict_unref (volinfo->dict);
if (volinfo->gsync_slaves)
dict_unref (volinfo->gsync_slaves);
+ if (volinfo->gsync_active_slaves)
+ dict_unref (volinfo->gsync_active_slaves);
GF_FREE (volinfo->logdir);
if (volinfo->rebal.dict)
dict_unref (volinfo->rebal.dict);
@@ -6808,21 +6843,24 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
char *slave_vol = NULL;
char *slave_host = NULL;
char *statefile = NULL;
- char buf[1024] = "faulty";
+ char buf[1024] = "faulty";
int uuid_len = 0;
int ret = 0;
int op_ret = 0;
int ret_status = 0;
- char uuid_str[64] = {0};
+ char uuid_str[64] = {0};
glusterd_volinfo_t *volinfo = NULL;
- char confpath[PATH_MAX] = "";
+ char confpath[PATH_MAX] = "";
char *op_errstr = NULL;
glusterd_conf_t *priv = NULL;
gf_boolean_t is_template_in_use = _gf_false;
- gf_boolean_t is_paused = _gf_false;
+ gf_boolean_t is_paused = _gf_false;
+ char *key1 = NULL;
+ xlator_t *this1 = NULL;
- GF_ASSERT (THIS);
- priv = THIS->private;
+ this1 = THIS;
+ GF_ASSERT (this1);
+ priv = this1->private;
GF_ASSERT (priv);
GF_ASSERT (data);
@@ -6843,7 +6881,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
ret = glusterd_get_slave_info (slave, &slave_url, &slave_host,
&slave_vol, &op_errstr);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_log (this1->name, GF_LOG_ERROR,
"Unable to fetch slave details.");
ret = -1;
goto out;
@@ -6861,10 +6899,10 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
&is_template_in_use);
if (ret) {
if (!strstr(slave, "::"))
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
"%s is not a valid slave url.", slave);
else
- gf_log ("", GF_LOG_INFO, "Unable to get"
+ gf_log (this1->name, GF_LOG_INFO, "Unable to get"
" statefile's name");
goto out;
}
@@ -6872,7 +6910,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
/* If state-file entry is missing from the config file,
* do not start gsyncd on restart */
if (is_template_in_use) {
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
"state-file entry is missing in config file."
"Not Restarting");
goto out;
@@ -6883,14 +6921,14 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
ret = gsync_status (volinfo->volname, slave, confpath,
&ret_status, &is_template_in_use);
if (ret == -1) {
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
GEOREP" start option validation failed ");
ret = 0;
goto out;
}
if (is_template_in_use == _gf_true) {
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
"pid-file entry is missing in config file."
"Not Restarting");
ret = 0;
@@ -6899,16 +6937,20 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
ret = glusterd_gsync_read_frm_status (statefile, buf, sizeof (buf));
if (ret < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to read the status");
+ gf_log (this1->name, GF_LOG_ERROR, "Unable to read the status");
goto out;
}
+ /* Move the pointer two characters ahead to surpass '//' */
+ if ((key1 = strchr (slave, '/')))
+ key1 = key1 + 2;
+
/* Looks for the last status, to find if the sessiom was running
* when the node went down. If the session was not started or
* not started, do not restart the geo-rep session */
if ((!strcmp (buf, "Not Started")) ||
(!strcmp (buf, "Stopped"))) {
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
"Geo-Rep Session was not started between "
"%s and %s::%s. Not Restarting", volinfo->volname,
slave_url, slave_vol);
@@ -6916,7 +6958,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
} else if (strstr(buf, "Paused")) {
is_paused = _gf_true;
} else if ((!strcmp (buf, "Config Corrupted"))) {
- gf_log ("", GF_LOG_INFO,
+ gf_log (this1->name, GF_LOG_INFO,
"Recovering from a corrupted config. "
"Not Restarting. Use start (force) to "
"start the session between %s and %s::%s.",
@@ -6925,12 +6967,24 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
goto out;
}
- if (is_paused)
+ if (is_paused) {
glusterd_start_gsync (volinfo, slave, path_list, confpath,
uuid_str, NULL, _gf_true);
- else
- glusterd_start_gsync (volinfo, slave, path_list, confpath,
+ }
+ else {
+ /* Add slave to the dict indicating geo-rep session is running*/
+ ret = dict_set_dynstr_with_alloc (volinfo->gsync_active_slaves,
+ key1, "running");
+ if (ret) {
+ gf_log (this1->name, GF_LOG_ERROR, "Unable to set key:%s"
+ " value:running in the dict", key1);
+ goto out;
+ }
+ ret = glusterd_start_gsync (volinfo, slave, path_list, confpath,
uuid_str, NULL, _gf_false);
+ if (ret)
+ dict_del (volinfo->gsync_active_slaves, key1);
+ }
out:
if (statefile)
@@ -6941,7 +6995,7 @@ out:
slave_host, slave_vol,
"Config Corrupted");
if (op_ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_log (this1->name, GF_LOG_ERROR,
"Unable to create status file"
". Error : %s", strerror (errno));
ret = op_ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index f8dfce7ca82..c277445ce61 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -763,6 +763,9 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname,
int32_t
glusterd_restore_geo_rep_files (glusterd_volinfo_t *snap_vol);
+gf_boolean_t
+gd_vol_is_geo_rep_active (glusterd_volinfo_t *volinfo);
+
int32_t
glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
glusterd_volinfo_t *dest_vol);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 16745688868..f2f7a0a277c 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -368,6 +368,7 @@ struct glusterd_volinfo_ {
char *logdir;
dict_t *gsync_slaves;
+ dict_t *gsync_active_slaves;
int decommission_in_progress;
xlator_t *xl;