|
|
21ab4e |
From 953bdf315ffcca73e4aad3eafb5f25a0457947ca Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
Date: Wed, 3 May 2017 12:17:30 +0530
|
|
|
21ab4e |
Subject: [PATCH 421/426] glusterd: cleanup pidfile on pmap signout
|
|
|
21ab4e |
|
|
|
21ab4e |
This patch ensures
|
|
|
21ab4e |
1. brick pidfile is cleaned up on pmap signout
|
|
|
21ab4e |
2. pmap signout evemt is sent for all the bricks when a brick process
|
|
|
21ab4e |
shuts down.
|
|
|
21ab4e |
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/17168
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: I7606a60775b484651d4b9743b6037b40323931a2
|
|
|
21ab4e |
BUG: 1443972
|
|
|
21ab4e |
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/105595
|
|
|
21ab4e |
Reviewed-by: Prashanth Pai <ppai@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
glusterfsd/src/glusterfsd.c | 18 ++++++++-
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-pmap.c | 31 ++++++++++++---
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-utils.c | 62 ++++++++++++++++++++++++++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-utils.h | 4 ++
|
|
|
21ab4e |
4 files changed, 109 insertions(+), 6 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
|
|
|
21ab4e |
index cbc1b93..7957f38 100644
|
|
|
21ab4e |
--- a/glusterfsd/src/glusterfsd.c
|
|
|
21ab4e |
+++ b/glusterfsd/src/glusterfsd.c
|
|
|
21ab4e |
@@ -1262,6 +1262,9 @@ cleanup_and_exit (int signum)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
glusterfs_ctx_t *ctx = NULL;
|
|
|
21ab4e |
xlator_t *trav = NULL;
|
|
|
21ab4e |
+ xlator_t *top;
|
|
|
21ab4e |
+ xlator_t *victim;
|
|
|
21ab4e |
+ xlator_list_t **trav_p;
|
|
|
21ab4e |
|
|
|
21ab4e |
ctx = glusterfsd_ctx;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -1291,7 +1294,20 @@ cleanup_and_exit (int signum)
|
|
|
21ab4e |
return;
|
|
|
21ab4e |
|
|
|
21ab4e |
ctx->cleanup_started = 1;
|
|
|
21ab4e |
- glusterfs_mgmt_pmap_signout (ctx, NULL);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* signout should be sent to all the bricks in case brick mux is enabled
|
|
|
21ab4e |
+ * and multiple brick instances are attached to this process
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ if (ctx->active) {
|
|
|
21ab4e |
+ top = ctx->active->first;
|
|
|
21ab4e |
+ for (trav_p = &top->children; *trav_p;
|
|
|
21ab4e |
+ trav_p = &(*trav_p)->next) {
|
|
|
21ab4e |
+ victim = (*trav_p)->xlator;
|
|
|
21ab4e |
+ glusterfs_mgmt_pmap_signout (ctx, victim->name);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
+ glusterfs_mgmt_pmap_signout (ctx, NULL);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
/* below part is a racy code where the rpcsvc object is freed.
|
|
|
21ab4e |
* But in another thread (epoll thread), upon poll error in the
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
21ab4e |
index d87c31e..d67117f 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
21ab4e |
@@ -551,11 +551,20 @@ gluster_pmap_signin (rpcsvc_request_t *req)
|
|
|
21ab4e |
int
|
|
|
21ab4e |
__gluster_pmap_signout (rpcsvc_request_t *req)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
- pmap_signout_req args = {0,};
|
|
|
21ab4e |
- pmap_signout_rsp rsp = {0,};
|
|
|
21ab4e |
- int ret = -1;
|
|
|
21ab4e |
- char brick_path[PATH_MAX] = {0,};
|
|
|
21ab4e |
- glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
21ab4e |
+ pmap_signout_req args = {0,};
|
|
|
21ab4e |
+ pmap_signout_rsp rsp = {0,};
|
|
|
21ab4e |
+ int ret = -1;
|
|
|
21ab4e |
+ xlator_t *this = NULL;
|
|
|
21ab4e |
+ glusterd_conf_t *conf = NULL;
|
|
|
21ab4e |
+ glusterd_volinfo_t *volinfo = NULL;
|
|
|
21ab4e |
+ glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
21ab4e |
+ char pidfile[PATH_MAX] = {0};
|
|
|
21ab4e |
+ char brick_path[PATH_MAX] = {0,};
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ this = THIS;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO ("glusterd", this, fail);
|
|
|
21ab4e |
+ conf = this->private;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (this->name, conf, fail);
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = xdr_to_generic (req->msg[0], &args,
|
|
|
21ab4e |
(xdrproc_t)xdr_pmap_signout_req);
|
|
|
21ab4e |
@@ -574,6 +583,18 @@ __gluster_pmap_signout (rpcsvc_request_t *req)
|
|
|
21ab4e |
brick_path, GF_PMAP_PORT_BRICKSERVER,
|
|
|
21ab4e |
req->trans);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
+ /* Clean up the pidfile for this brick given glusterfsd doesn't clean it
|
|
|
21ab4e |
+ * any more. This is required to ensure we don't end up with having
|
|
|
21ab4e |
+ * stale pid files in case a brick is killed from the backend
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ ret = glusterd_get_volinfo_from_brick (args.brick, &volinfo);
|
|
|
21ab4e |
+ if (!ret) {
|
|
|
21ab4e |
+ if (volinfo && brickinfo) {
|
|
|
21ab4e |
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo,
|
|
|
21ab4e |
+ conf);
|
|
|
21ab4e |
+ sys_unlink (pidfile);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
fail:
|
|
|
21ab4e |
glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
index 9eb6502..36eb1d1 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
@@ -5742,6 +5742,7 @@ glusterd_get_brickinfo (xlator_t *this, const char *brickname, int port,
|
|
|
21ab4e |
glusterd_conf_t *priv = NULL;
|
|
|
21ab4e |
glusterd_volinfo_t *volinfo = NULL;
|
|
|
21ab4e |
glusterd_brickinfo_t *tmpbrkinfo = NULL;
|
|
|
21ab4e |
+ glusterd_snap_t *snap = NULL;
|
|
|
21ab4e |
int ret = -1;
|
|
|
21ab4e |
|
|
|
21ab4e |
GF_ASSERT (brickname);
|
|
|
21ab4e |
@@ -5760,6 +5761,21 @@ glusterd_get_brickinfo (xlator_t *this, const char *brickname, int port,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
+ /* In case normal volume is not found, check for snapshot volumes */
|
|
|
21ab4e |
+ cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
|
|
|
21ab4e |
+ cds_list_for_each_entry (volinfo, &snap->volumes, vol_list) {
|
|
|
21ab4e |
+ cds_list_for_each_entry (tmpbrkinfo, &volinfo->bricks,
|
|
|
21ab4e |
+ brick_list) {
|
|
|
21ab4e |
+ if (gf_uuid_compare (tmpbrkinfo->uuid, MY_UUID))
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ if (!strcmp(tmpbrkinfo->path, brickname)) {
|
|
|
21ab4e |
+ *brickinfo = tmpbrkinfo;
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -12757,6 +12773,52 @@ out:
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+glusterd_get_volinfo_from_brick (char *brick, glusterd_volinfo_t **volinfo)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ int ret = -1;
|
|
|
21ab4e |
+ xlator_t *this = NULL;
|
|
|
21ab4e |
+ glusterd_conf_t *conf = NULL;
|
|
|
21ab4e |
+ glusterd_volinfo_t *voliter = NULL;
|
|
|
21ab4e |
+ glusterd_brickinfo_t *brickiter = NULL;
|
|
|
21ab4e |
+ glusterd_snap_t *snap = NULL;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ this = THIS;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
|
|
|
21ab4e |
+ conf = this->private;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* First check for normal volumes */
|
|
|
21ab4e |
+ cds_list_for_each_entry (voliter, &conf->volumes, vol_list) {
|
|
|
21ab4e |
+ cds_list_for_each_entry (brickiter, &voliter->bricks,
|
|
|
21ab4e |
+ brick_list) {
|
|
|
21ab4e |
+ if (gf_uuid_compare (brickiter->uuid, MY_UUID))
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ if (!strcmp(brickiter->path, brick)) {
|
|
|
21ab4e |
+ *volinfo = voliter;
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ /* In case normal volume is not found, check for snapshot volumes */
|
|
|
21ab4e |
+ cds_list_for_each_entry (snap, &conf->snapshots, snap_list) {
|
|
|
21ab4e |
+ cds_list_for_each_entry (voliter, &snap->volumes, vol_list) {
|
|
|
21ab4e |
+ cds_list_for_each_entry (brickiter, &voliter->bricks,
|
|
|
21ab4e |
+ brick_list) {
|
|
|
21ab4e |
+ if (gf_uuid_compare (brickiter->uuid, MY_UUID))
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ if (!strcmp(brickiter->path, brick)) {
|
|
|
21ab4e |
+ *volinfo = voliter;
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ return ret;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
glusterd_op_t
|
|
|
21ab4e |
gd_cli_to_gd_op (char *cli_op)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
index d3ff44f..aab6a29 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
@@ -820,4 +820,8 @@ glusterd_brick_op_prerequisites (dict_t *dict,
|
|
|
21ab4e |
char **src_brick, glusterd_brickinfo_t
|
|
|
21ab4e |
**src_brickinfo, char *pidfile,
|
|
|
21ab4e |
char **op_errstr, dict_t *rsp_dict);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+glusterd_get_volinfo_from_brick (char *brick, glusterd_volinfo_t **volinfo);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
#endif
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|