1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
From feeee9a35c1219b2077ea07b6fd80976960bd181 Mon Sep 17 00:00:00 2001
From: Mohammed Rafi KC <rkavunga@redhat.com>
Date: Thu, 11 Jul 2019 12:44:42 +0530
Subject: [PATCH 234/255] Revert "glusterd/shd: Change shd logfile to a unique
name"
This reverts commit 541e1400ecaec5fea0f56e8ca18f00c229906d8a.
BUG: 1471742
Change-Id: I7e0371d77db6897981f7364c04d4b9b523b865ba
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/175943
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
.../mgmt/glusterd/src/glusterd-shd-svc-helper.c | 12 ++++++++
.../mgmt/glusterd/src/glusterd-shd-svc-helper.h | 6 ++++
xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 14 ++++-----
xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 34 +++++-----------------
xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 4 +--
xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h | 4 ---
6 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
index 57ceda9..9196758 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
@@ -75,6 +75,18 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path,
}
void
+glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len)
+{
+ snprintf(logdir, len, "%s/shd/%s", DEFAULT_LOG_FILE_DIRECTORY, volname);
+}
+
+void
+glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len)
+{
+ snprintf(logfile, len, "%s/shd.log", logdir);
+}
+
+void
glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd)
{
glusterd_svc_proc_t *svc_proc = NULL;
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
index 59466ec..c70702c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
@@ -27,6 +27,12 @@ glusterd_svc_build_shd_volfile_path(glusterd_volinfo_t *volinfo, char *path,
int path_len);
void
+glusterd_svc_build_shd_logdir(char *logdir, char *volname, size_t len);
+
+void
+glusterd_svc_build_shd_logfile(char *logfile, char *logdir, size_t len);
+
+void
glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd);
int
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
index 8ad90a9..dbe2560 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_shd_logdir(logdir, volinfo->volname, sizeof(logdir));
+ glusterd_svc_build_shd_logfile(logfile, logdir, 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(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);
@@ -460,7 +460,6 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
return -1;
glusterd_volinfo_ref(volinfo);
-
if (!svc->inited) {
ret = glusterd_shd_svc_mux_init(volinfo, svc);
if (ret)
@@ -472,11 +471,12 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
/* Unref will happen from glusterd_svc_attach_cbk */
ret = glusterd_attach_svc(svc, volinfo, flags);
if (ret) {
+ glusterd_volinfo_unref(volinfo);
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL,
- "Failed to attach shd svc(volume=%s) to pid=%d",
+ "Failed to attach shd svc(volume=%s) to pid=%d. Starting"
+ "a new process",
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
- glusterd_volinfo_unref(volinfo);
+ ret = glusterd_recover_shd_attach_failure(volinfo, svc, flags);
}
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
index 400826f..a6e662f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
@@ -469,9 +469,6 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
glusterd_conf_t *conf = NULL;
glusterd_svc_t *parent_svc = NULL;
int pid = -1;
- char pidfile[PATH_MAX] = {
- 0,
- };
GF_VALIDATE_OR_GOTO("glusterd", svc, out);
GF_VALIDATE_OR_GOTO("glusterd", volinfo, out);
@@ -481,26 +478,8 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
pthread_mutex_lock(&conf->attach_lock);
{
- if (svc->inited && !glusterd_proc_is_running(&(svc->proc))) {
- /* This is the case when shd process was abnormally killed */
- pthread_mutex_unlock(&conf->attach_lock);
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
- pthread_mutex_lock(&conf->attach_lock);
- }
-
if (!svc->inited) {
- glusterd_svc_build_shd_pidfile(volinfo, pidfile, sizeof(pidfile));
- ret = snprintf(svc->proc.name, sizeof(svc->proc.name), "%s",
- "glustershd");
- if (ret < 0)
- goto unlock;
-
- ret = snprintf(svc->proc.pidfile, sizeof(svc->proc.pidfile), "%s",
- pidfile);
- if (ret < 0)
- goto unlock;
-
- if (gf_is_service_running(pidfile, &pid)) {
+ if (gf_is_service_running(svc->proc.pidfile, &pid)) {
/* Just connect is required, but we don't know what happens
* during the disconnect. So better to reattach.
*/
@@ -508,10 +487,10 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
}
if (!mux_proc) {
- if (pid != -1 && sys_access(pidfile, R_OK) == 0) {
+ if (pid != -1 && sys_access(svc->proc.pidfile, R_OK) == 0) {
/* stale pid file, stop and unlink it */
glusterd_proc_stop(&svc->proc, SIGTERM, PROC_STOP_FORCE);
- glusterd_unlink_file(pidfile);
+ glusterd_unlink_file(svc->proc.pidfile);
}
mux_proc = __gf_find_compatible_svc(GD_NODE_SHD);
}
@@ -705,10 +684,11 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count,
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
} else {
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_ATTACH_FAIL,
- "svc %s of volume %s failed to attach to pid %d", svc->name,
- volinfo->volname, glusterd_proc_get_pid(&svc->proc));
+ "svc %s of volume %s failed to "
+ "attach to pid %d. Starting a new process",
+ svc->name, volinfo->volname, glusterd_proc_get_pid(&svc->proc));
if (!strcmp(svc->name, "glustershd")) {
- glusterd_shd_svcproc_cleanup(&volinfo->shd);
+ glusterd_recover_shd_attach_failure(volinfo, svc, *flag);
}
}
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
index fa316a6..f32dafc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
@@ -33,14 +33,14 @@ glusterd_svc_create_rundir(char *rundir)
return ret;
}
-void
+static void
glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile,
size_t len)
{
snprintf(logfile, len, "%s/%s.log", logdir, server);
}
-void
+static void
glusterd_svc_build_volfileid_path(char *server, char *volfileid, size_t len)
{
snprintf(volfileid, len, "gluster/%s", server);
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
index 5a5466a..fbc5225 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
@@ -74,10 +74,6 @@ glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile,
size_t len);
void
-glusterd_svc_build_logfile_path(char *server, char *logdir, char *logfile,
- size_t len);
-
-void
glusterd_svc_build_svcdir(char *server, char *workdir, char *path, size_t len);
void
--
1.8.3.1
|