|
|
50dc83 |
From feeee9a35c1219b2077ea07b6fd80976960bd181 Mon Sep 17 00:00:00 2001
|
|
|
50dc83 |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
50dc83 |
Date: Thu, 11 Jul 2019 12:44:42 +0530
|
|
|
50dc83 |
Subject: [PATCH 234/255] Revert "glusterd/shd: Change shd logfile to a unique
|
|
|
50dc83 |
name"
|
|
|
50dc83 |
|
|
|
50dc83 |
This reverts commit 541e1400ecaec5fea0f56e8ca18f00c229906d8a.
|
|
|
50dc83 |
|
|
|
50dc83 |
BUG: 1471742
|
|
|
50dc83 |
Change-Id: I7e0371d77db6897981f7364c04d4b9b523b865ba
|
|
|
50dc83 |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
50dc83 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/175943
|
|
|
50dc83 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
50dc83 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
50dc83 |
---
|
|
|
50dc83 |
.../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 12 ++++++++
|
|
|
50dc83 |
.../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 6 ++++
|
|
|
50dc83 |
xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 14 ++++-----
|
|
|
50dc83 |
xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 34 +++++-----------------
|
|
|
50dc83 |
xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 4 +--
|
|
|
50dc83 |
xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h | 4 ---
|
|
|
50dc83 |
6 files changed, 34 insertions(+), 40 deletions(-)
|
|
|
50dc83 |
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
|
|
|
50dc83 |
index 57ceda9..9196758 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
|
|
|
50dc83 |
@@ -75,6 +75,18 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path,
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
void
|
|
|
50dc83 |
+glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len)
|
|
|
50dc83 |
+{
|
|
|
50dc83 |
+ snprintf(logdir, len, "%s/shd/%s", DEFAULT_LOG_FILE_DIRECTORY, volname);
|
|
|
50dc83 |
+}
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+void
|
|
|
50dc83 |
+glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len)
|
|
|
50dc83 |
+{
|
|
|
50dc83 |
+ snprintf(logfile, len, "%s/shd.log", logdir);
|
|
|
50dc83 |
+}
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+void
|
|
|
50dc83 |
glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd)
|
|
|
50dc83 |
{
|
|
|
50dc83 |
glusterd_svc_proc_t *svc_proc = NULL;
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
|
|
|
50dc83 |
index 59466ec..c70702c 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
|
|
|
50dc83 |
@@ -27,6 +27,12 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path,
|
|
|
50dc83 |
int path_len);
|
|
|
50dc83 |
|
|
|
50dc83 |
void
|
|
|
50dc83 |
+glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+void
|
|
|
50dc83 |
+glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+void
|
|
|
50dc83 |
glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd);
|
|
|
50dc83 |
|
|
|
50dc83 |
int
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
50dc83 |
index 8ad90a9..dbe2560 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
50dc83 |
@@ -90,8 +90,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
|
|
|
50dc83 |
GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv);
|
|
|
50dc83 |
glusterd_svc_create_rundir(rundir);
|
|
|
50dc83 |
|
|
|
50dc83 |
- glusterd_svc_build_logfile_path(shd_svc_name, DEFAULT_LOG_FILE_DIRECTORY,
|
|
|
50dc83 |
- logfile, sizeof(logfile));
|
|
|
50dc83 |
+ glusterd_svc_build_shd_logdir(logdir, volinfo->volname, sizeof(logdir));
|
|
|
50dc83 |
+ glusterd_svc_build_shd_logfile(logfile, logdir, sizeof(logfile));
|
|
|
50dc83 |
|
|
|
50dc83 |
/* Initialize the connection mgmt */
|
|
|
50dc83 |
if (mux_conn && mux_svc->rpc) {
|
|
|
50dc83 |
@@ -104,7 +104,7 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
|
|
|
50dc83 |
if (ret < 0)
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
} else {
|
|
|
50dc83 |
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY, 0755, _gf_true);
|
|
|
50dc83 |
+ ret = mkdir_p(logdir, 0755, _gf_true);
|
|
|
50dc83 |
if ((ret == -1) && (EEXIST != errno)) {
|
|
|
50dc83 |
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED,
|
|
|
50dc83 |
"Unable to create logdir %s", logdir);
|
|
|
50dc83 |
@@ -460,7 +460,6 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
|
|
|
50dc83 |
return -1;
|
|
|
50dc83 |
|
|
|
50dc83 |
glusterd_volinfo_ref(volinfo);
|
|
|
50dc83 |
-
|
|
|
50dc83 |
if (!svc->inited) {
|
|
|
50dc83 |
ret = glusterd_shd_svc_mux_init(volinfo, svc);
|
|
|
50dc83 |
if (ret)
|
|
|
50dc83 |
@@ -472,11 +471,12 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
|
|
|
50dc83 |
/* Unref will happen from glusterd_svc_attach_cbk */
|
|
|
50dc83 |
ret = glusterd_attach_svc(svc, volinfo, flags);
|
|
|
50dc83 |
if (ret) {
|
|
|
50dc83 |
+ glusterd_volinfo_unref(volinfo);
|
|
|
50dc83 |
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL,
|
|
|
50dc83 |
- "Failed to attach shd svc(volume=%s) to pid=%d",
|
|
|
50dc83 |
+ "Failed to attach shd svc(volume=%s) to pid=%d. Starting"
|
|
|
50dc83 |
+ "a new process",
|
|
|
50dc83 |
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
|
|
|
50dc83 |
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
|
|
|
50dc83 |
- glusterd_volinfo_unref(volinfo);
|
|
|
50dc83 |
+ ret = glusterd_recover_shd_attach_failure(volinfo, svc, flags);
|
|
|
50dc83 |
}
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
}
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
50dc83 |
index 400826f..a6e662f 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
50dc83 |
@@ -469,9 +469,6 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
|
|
|
50dc83 |
glusterd_conf_t *conf = NULL;
|
|
|
50dc83 |
glusterd_svc_t *parent_svc = NULL;
|
|
|
50dc83 |
int pid = -1;
|
|
|
50dc83 |
- char pidfile[PATH_MAX] = {
|
|
|
50dc83 |
- 0,
|
|
|
50dc83 |
- };
|
|
|
50dc83 |
|
|
|
50dc83 |
GF_VALIDATE_OR_GOTO("glusterd", svc, out);
|
|
|
50dc83 |
GF_VALIDATE_OR_GOTO("glusterd", volinfo, out);
|
|
|
50dc83 |
@@ -481,26 +478,8 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
|
|
|
50dc83 |
|
|
|
50dc83 |
pthread_mutex_lock(&conf->attach_lock);
|
|
|
50dc83 |
{
|
|
|
50dc83 |
- if (svc->inited && !glusterd_proc_is_running(&(svc->proc))) {
|
|
|
50dc83 |
- /* This is the case when shd process was abnormally killed */
|
|
|
50dc83 |
- pthread_mutex_unlock(&conf->attach_lock);
|
|
|
50dc83 |
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
|
|
|
50dc83 |
- pthread_mutex_lock(&conf->attach_lock);
|
|
|
50dc83 |
- }
|
|
|
50dc83 |
-
|
|
|
50dc83 |
if (!svc->inited) {
|
|
|
50dc83 |
- glusterd_svc_build_shd_pidfile(volinfo, pidfile, sizeof(pidfile));
|
|
|
50dc83 |
- ret = snprintf(svc->proc.name, sizeof(svc->proc.name), "%s",
|
|
|
50dc83 |
- "glustershd");
|
|
|
50dc83 |
- if (ret < 0)
|
|
|
50dc83 |
- goto unlock;
|
|
|
50dc83 |
-
|
|
|
50dc83 |
- ret = snprintf(svc->proc.pidfile, sizeof(svc->proc.pidfile), "%s",
|
|
|
50dc83 |
- pidfile);
|
|
|
50dc83 |
- if (ret < 0)
|
|
|
50dc83 |
- goto unlock;
|
|
|
50dc83 |
-
|
|
|
50dc83 |
- if (gf_is_service_running(pidfile, &pid)) {
|
|
|
50dc83 |
+ if (gf_is_service_running(svc->proc.pidfile, &pid)) {
|
|
|
50dc83 |
/* Just connect is required, but we don't know what happens
|
|
|
50dc83 |
* during the disconnect. So better to reattach.
|
|
|
50dc83 |
*/
|
|
|
50dc83 |
@@ -508,10 +487,10 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
if (!mux_proc) {
|
|
|
50dc83 |
- if (pid != -1 && sys_access(pidfile, R_OK) == 0) {
|
|
|
50dc83 |
+ if (pid != -1 && sys_access(svc->proc.pidfile, R_OK) == 0) {
|
|
|
50dc83 |
/* stale pid file, stop and unlink it */
|
|
|
50dc83 |
glusterd_proc_stop(&svc->proc, SIGTERM, PROC_STOP_FORCE);
|
|
|
50dc83 |
- glusterd_unlink_file(pidfile);
|
|
|
50dc83 |
+ glusterd_unlink_file(svc->proc.pidfile);
|
|
|
50dc83 |
}
|
|
|
50dc83 |
mux_proc = __gf_find_compatible_svc(GD_NODE_SHD);
|
|
|
50dc83 |
}
|
|
|
50dc83 |
@@ -705,10 +684,11 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count,
|
|
|
50dc83 |
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
|
|
|
50dc83 |
} else {
|
|
|
50dc83 |
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL,
|
|
|
50dc83 |
- "svc %s of volume %s failed to attach to pid %d", svc->name,
|
|
|
50dc83 |
- volinfo->volname, glusterd_proc_get_pid(&svc->proc));
|
|
|
50dc83 |
+ "svc %s of volume %s failed to "
|
|
|
50dc83 |
+ "attach to pid %d. Starting a new process",
|
|
|
50dc83 |
+ svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc));
|
|
|
50dc83 |
if (!strcmp(svc->name, "glustershd")) {
|
|
|
50dc83 |
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
|
|
|
50dc83 |
+ glusterd_recover_shd_attach_failure(volinfo, svc, *flag);
|
|
|
50dc83 |
}
|
|
|
50dc83 |
}
|
|
|
50dc83 |
out:
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
|
|
|
50dc83 |
index fa316a6..f32dafc 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
|
|
|
50dc83 |
@@ -33,14 +33,14 @@ glusterd_svc_create_rundir(char *rundir)
|
|
|
50dc83 |
return ret;
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
-void
|
|
|
50dc83 |
+static void
|
|
|
50dc83 |
glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile,
|
|
|
50dc83 |
size_t len)
|
|
|
50dc83 |
{
|
|
|
50dc83 |
snprintf(logfile, len, "%s/%s.log", logdir, server);
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
-void
|
|
|
50dc83 |
+static void
|
|
|
50dc83 |
glusterd_svc_build_volfileid_path(char *server, char *volfileid, size_t len)
|
|
|
50dc83 |
{
|
|
|
50dc83 |
snprintf(volfileid, len, "gluster/%s", server);
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
|
|
|
50dc83 |
index 5a5466a..fbc5225 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
|
|
|
50dc83 |
@@ -74,10 +74,6 @@ glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile,
|
|
|
50dc83 |
size_t len);
|
|
|
50dc83 |
|
|
|
50dc83 |
void
|
|
|
50dc83 |
-glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile,
|
|
|
50dc83 |
- size_t len);
|
|
|
50dc83 |
-
|
|
|
50dc83 |
-void
|
|
|
50dc83 |
glusterd_svc_build_svcdir(char *server, char *workdir, char *path, size_t len);
|
|
|
50dc83 |
|
|
|
50dc83 |
void
|
|
|
50dc83 |
--
|
|
|
50dc83 |
1.8.3.1
|
|
|
50dc83 |
|