summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-shd-svc.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-shd-svc.c121
1 files changed, 89 insertions, 32 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
index aad47203d5f..1c56384a14b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
@@ -90,8 +90,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv);
glusterd_svc_create_rundir(rundir);
- glusterd_svc_build_logfile_path(shd_svc_name, DEFAULT_LOG_FILE_DIRECTORY,
- logfile, sizeof(logfile));
+ glusterd_svc_build_logfile_path(shd_svc_name, priv->logdir, logfile,
+ sizeof(logfile));
/* Initialize the connection mgmt */
if (mux_conn && mux_svc->rpc) {
@@ -104,7 +104,7 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
if (ret < 0)
goto out;
} else {
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY, 0755, _gf_true);
+ ret = mkdir_p(priv->logdir, 0755, _gf_true);
if ((ret == -1) && (EEXIST != errno)) {
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED,
"Unable to create logdir %s", logdir);
@@ -155,6 +155,8 @@ glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo)
int ret = -1;
dict_t *mod_dict = NULL;
+ xlator_t *this = THIS;
+ GF_ASSERT(this);
glusterd_svc_build_shd_volfile_path(volinfo, filepath, PATH_MAX);
if (!glusterd_is_shd_compatible_volume(volinfo)) {
@@ -166,28 +168,42 @@ glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo)
goto out;
}
mod_dict = dict_new();
- if (!mod_dict)
+ if (!mod_dict) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
goto out;
+ }
ret = dict_set_uint32(mod_dict, "cluster.background-self-heal-count", 0);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.background-self-heal-count", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.data-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.data-self-heal", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.metadata-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.metadata-self-heal", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.entry-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.entry-self-heal", NULL);
goto out;
+ }
ret = glusterd_shdsvc_generate_volfile(volinfo, filepath, mod_dict);
if (ret) {
- gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL,
+ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL,
"Failed to create volfile");
goto out;
}
@@ -195,7 +211,7 @@ glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo)
out:
if (mod_dict)
dict_unref(mod_dict);
- gf_msg_debug(THIS->name, 0, "Returning %d", ret);
+ gf_msg_debug(this->name, 0, "Returning %d", ret);
return ret;
}
@@ -263,9 +279,6 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
volinfo = data;
GF_VALIDATE_OR_GOTO("glusterd", volinfo, out);
- if (volinfo)
- glusterd_volinfo_ref(volinfo);
-
if (volinfo->is_snap_volume) {
/* healing of a snap volume is not supported yet*/
ret = 0;
@@ -273,16 +286,13 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
}
while (conf->restart_shd) {
- synclock_unlock(&conf->big_lock);
- sleep(2);
- synclock_lock(&conf->big_lock);
+ synccond_wait(&conf->cond_restart_shd, &conf->big_lock);
}
conf->restart_shd = _gf_true;
shd_restart = _gf_true;
- ret = glusterd_shdsvc_create_volfile(volinfo);
- if (ret)
- goto out;
+ if (volinfo)
+ glusterd_volinfo_ref(volinfo);
if (!glusterd_is_shd_compatible_volume(volinfo)) {
ret = 0;
@@ -294,6 +304,9 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
}
goto out;
}
+ ret = glusterd_shdsvc_create_volfile(volinfo);
+ if (ret)
+ goto out;
ret = glusterd_shd_svc_mux_init(volinfo, svc);
if (ret) {
@@ -329,8 +342,10 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
}
}
out:
- if (shd_restart)
+ if (shd_restart) {
conf->restart_shd = _gf_false;
+ synccond_broadcast(&conf->cond_restart_shd);
+ }
if (volinfo)
glusterd_volinfo_unref(volinfo);
if (ret)
@@ -347,6 +362,8 @@ glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags)
char glusterd_uuid_option[PATH_MAX] = {0};
char client_pid[32] = {0};
dict_t *cmdline = NULL;
+ xlator_t *this = THIS;
+ GF_ASSERT(this);
cmdline = dict_new();
if (!cmdline)
@@ -363,31 +380,49 @@ glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags)
goto out;
ret = dict_set_str(cmdline, "arg", client_pid);
- if (ret < 0)
+ if (ret < 0) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=arg", NULL);
goto out;
+ }
/* Pass cmdline arguments as key-value pair. The key is merely
* a carrier and is not used. Since dictionary follows LIFO the value
* should be put in reverse order*/
ret = dict_set_str(cmdline, "arg4", svc->name);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=arg4", NULL);
goto out;
+ }
ret = dict_set_str(cmdline, "arg3", GD_SHD_PROCESS_NAME);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=arg3", NULL);
goto out;
+ }
ret = dict_set_str(cmdline, "arg2", glusterd_uuid_option);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=arg2", NULL);
goto out;
+ }
ret = dict_set_str(cmdline, "arg1", "--xlator-option");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=arg1", NULL);
goto out;
+ }
ret = glusterd_svc_start(svc, flags, cmdline);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno,
+ GD_MSG_GLUSTER_SERVICE_START_FAIL, NULL);
goto out;
+ }
ret = glusterd_conn_connect(&(svc->conn));
out:
@@ -483,6 +518,7 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
glusterd_shd_svcproc_cleanup(&volinfo->shd);
glusterd_volinfo_unref(volinfo);
+ goto out1;
}
goto out;
}
@@ -491,8 +527,11 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
shd->attached = _gf_true;
}
out:
+ if (ret && volinfo)
+ glusterd_shd_svcproc_cleanup(&volinfo->shd);
if (volinfo)
glusterd_volinfo_unref(volinfo);
+out1:
gf_msg_debug(THIS->name, 0, "Returning %d", ret);
return ret;
@@ -536,28 +575,45 @@ glusterd_shdsvc_reconfigure(glusterd_volinfo_t *volinfo)
goto out;
}
mod_dict = dict_new();
- if (!mod_dict)
+ if (!mod_dict) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
goto out;
+ }
ret = dict_set_uint32(mod_dict, "cluster.background-self-heal-count", 0);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.background-self-heal-count", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.data-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.data-self-heal", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.metadata-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.metadata-self-heal", NULL);
goto out;
+ }
ret = dict_set_int32(mod_dict, "graph-check", 1);
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=graph-check", NULL);
goto out;
+ }
ret = dict_set_str(mod_dict, "cluster.entry-self-heal", "on");
- if (ret)
+ if (ret) {
+ gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED,
+ "Key=cluster.entry-self-heal", NULL);
goto out;
+ }
ret = glusterd_volume_svc_check_volfile_identical(
"glustershd", mod_dict, volinfo, glusterd_shdsvc_generate_volfile,
@@ -703,6 +759,7 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
cds_list_del_init(&svc->mux_svc);
empty = cds_list_empty(&svc_proc->svcs);
if (empty) {
+ svc_proc->status = GF_SVC_STOPPING;
cds_list_del_init(&svc_proc->svc_proc_list);
}
}