summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c25
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.c26
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c3
4 files changed, 46 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 7686fe0..6e4bfdc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -5982,8 +5982,10 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
glusterd_volinfo_t *volinfo = NULL;
xlator_t *this = NULL;
int temp = 0;
+ int32_t pid = -1;
glusterd_brickinfo_t *brickinfo_tmp = NULL;
glusterd_brick_proc_t *brick_proc = NULL;
+ char pidfile[PATH_MAX] = {0};
brickid = mydata;
if (!brickid)
@@ -6082,6 +6084,29 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
"peer=%s;volume=%s;brick=%s",
brickinfo->hostname, volinfo->volname,
brickinfo->path);
+ /* In case of an abrupt shutdown of a brick PMAP_SIGNOUT
+ * event is not received by glusterd which can lead to a
+ * stale port entry in glusterd, so forcibly clean up
+ * the same if the process is not running
+ */
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
+ brickinfo, conf);
+ if (!gf_is_service_running (pidfile, &pid)) {
+ ret = pmap_registry_remove (
+ THIS, brickinfo->port,
+ brickinfo->path,
+ GF_PMAP_PORT_BRICKSERVER,
+ NULL, _gf_true);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING,
+ GD_MSG_PMAP_REGISTRY_REMOVE_FAIL,
+ 0, "Failed to remove pmap "
+ "registry for port %d for "
+ "brick %s", brickinfo->port,
+ brickinfo->path);
+ ret = 0;
+ }
+ }
}
if (is_brick_mx_enabled()) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
index 6d8cf3f..4f045ab 100644
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
@@ -241,7 +241,8 @@ pmap_assign_port (xlator_t *this, int old_port, const char *path)
if (old_port) {
ret = pmap_registry_remove (this, 0, path,
- GF_PMAP_PORT_BRICKSERVER, NULL);
+ GF_PMAP_PORT_BRICKSERVER, NULL,
+ _gf_false);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING,
GD_MSG_PMAP_REGISTRY_REMOVE_FAIL, 0, "Failed to"
@@ -344,7 +345,8 @@ pmap_registry_extend (xlator_t *this, int port, const char *brickname)
int
pmap_registry_remove (xlator_t *this, int port, const char *brickname,
- gf_pmap_port_type_t type, void *xprt)
+ gf_pmap_port_type_t type, void *xprt,
+ gf_boolean_t brick_disconnect)
{
struct pmap_registry *pmap = NULL;
int p = 0;
@@ -391,11 +393,16 @@ remove:
* can delete the entire entry.
*/
if (!pmap->ports[p].xprt) {
- brick_str = pmap->ports[p].brickname;
- if (brick_str) {
- while (*brick_str != '\0') {
- if (*(brick_str++) != ' ') {
- goto out;
+ /* If the signout call is being triggered by brick disconnect
+ * then clean up all the bricks (in case of brick mux)
+ */
+ if (!brick_disconnect) {
+ brick_str = pmap->ports[p].brickname;
+ if (brick_str) {
+ while (*brick_str != '\0') {
+ if (*(brick_str++) != ' ') {
+ goto out;
+ }
}
}
}
@@ -550,14 +557,15 @@ __gluster_pmap_signout (rpcsvc_request_t *req)
goto fail;
}
rsp.op_ret = pmap_registry_remove (THIS, args.port, args.brick,
- GF_PMAP_PORT_BRICKSERVER, req->trans);
+ GF_PMAP_PORT_BRICKSERVER, req->trans,
+ _gf_false);
ret = glusterd_get_brickinfo (THIS, args.brick, args.port, &brickinfo);
if (args.rdma_port) {
snprintf(brick_path, PATH_MAX, "%s.rdma", args.brick);
rsp.op_ret = pmap_registry_remove (THIS, args.rdma_port,
brick_path, GF_PMAP_PORT_BRICKSERVER,
- req->trans);
+ req->trans, _gf_false);
}
/* Update portmap status on brickinfo */
if (brickinfo)
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h
index c0475db..f642d66 100644
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.h
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h
@@ -43,7 +43,8 @@ int pmap_registry_bind (xlator_t *this, int port, const char *brickname,
gf_pmap_port_type_t type, void *xprt);
int pmap_registry_extend (xlator_t *this, int port, const char *brickname);
int pmap_registry_remove (xlator_t *this, int port, const char *brickname,
- gf_pmap_port_type_t type, void *xprt);
+ gf_pmap_port_type_t type, void *xprt,
+ gf_boolean_t brick_disconnect);
int pmap_registry_search (xlator_t *this, const char *brickname,
gf_pmap_port_type_t type, gf_boolean_t destroy);
struct pmap_registry *pmap_registry_get (xlator_t *this);
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 1c26db6..96019a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -424,7 +424,8 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
pthread_mutex_lock (&priv->xprt_lock);
list_del (&xprt->list);
pthread_mutex_unlock (&priv->xprt_lock);
- pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_ANY, xprt);
+ pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_ANY, xprt,
+ _gf_false);
break;
}