summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kp@gluster.com>2012-02-06 15:12:51 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-07 09:45:08 -0800
commita4818cef9838ed3b1a270f395b4cce9551532927 (patch)
treec782edb6d43d8061b4dd36dc6c6a31c538fdb9d6 /xlators
parent0272f7de41fa529f51bc69fdaf694c77b47250f2 (diff)
glusterd: Initialised op_sm/friend_sm before cluster restore.
Cleaned up peerinfo/rpc association. Change-Id: I11bcaa3ea1f2b86c6b4e235873a60bb5bf76a892 BUG: 786006 Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Reviewed-on: http://review.gluster.com/2725 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c84
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h6
4 files changed, 38 insertions, 62 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 93900acc3b3..f2980e7efda 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1622,7 +1622,7 @@ glusterd_handle_friend_update (rpcsvc_request_t *req)
ret = glusterd_friend_add (hostname, friend_req.port,
GD_FRIEND_STATE_BEFRIENDED,
- &uuid, NULL, &peerinfo, 0, &args);
+ &uuid, &peerinfo, 0, &args);
i++;
}
@@ -1694,7 +1694,7 @@ glusterd_handle_probe_query (rpcsvc_request_t *req)
args.mode = GD_MODE_ON;
ret = glusterd_friend_add (remote_hostname, port,
GD_FRIEND_STATE_PROBE_RCVD,
- NULL, NULL, &peerinfo, 0, &args);
+ NULL, &peerinfo, 0, &args);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Failed to add peer %s",
remote_hostname);
@@ -2059,17 +2059,15 @@ int
glusterd_friend_add (const char *hoststr, int port,
glusterd_friend_sm_state_t state,
uuid_t *uuid,
- struct rpc_clnt *rpc,
glusterd_peerinfo_t **friend,
gf_boolean_t restore,
glusterd_peerctx_args_t *args)
{
- int ret = 0;
+ int ret = 0;
glusterd_conf_t *conf = NULL;
- glusterd_peerinfo_t *peerinfo = NULL;
glusterd_peerctx_t *peerctx = NULL;
- gf_boolean_t is_allocated = _gf_false;
dict_t *options = NULL;
+ gf_boolean_t handover = _gf_false;
conf = THIS->private;
GF_ASSERT (conf)
@@ -2084,55 +2082,31 @@ glusterd_friend_add (const char *hoststr, int port,
if (args)
peerctx->args = *args;
- ret = glusterd_peerinfo_new (&peerinfo, state, uuid, hoststr);
+ ret = glusterd_peerinfo_new (friend, state, uuid, hoststr);
if (ret)
goto out;
- peerctx->peerinfo = peerinfo;
- if (friend)
- *friend = peerinfo;
- if (!rpc) {
- ret = glusterd_transport_inet_keepalive_options_build (&options,
- hoststr, port);
- if (ret)
- goto out;
- ret = glusterd_rpc_create (&rpc, options,
- glusterd_peer_rpc_notify,
- peerctx);
- if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "failed to create rpc for"
- " peer %s", (char*)hoststr);
- goto out;
- }
- is_allocated = _gf_true;
- }
+ peerctx->peerinfo = *friend;
- /* If peer is unreachable when in DEFAULT state, we cleanup peerinfo
- * via the friend state machine. ie, peerinfo could have been freed.
- * peer_rpc_notify sets peerctx->peerinfo to NULL to indicate the
- * same*/
- peerinfo = peerctx->peerinfo;
-
- if (peerinfo) {
- peerinfo->rpc = rpc;
-
- if (!restore)
- ret = glusterd_store_peerinfo (peerinfo);
+ ret = glusterd_transport_inet_keepalive_options_build (&options,
+ hoststr, port);
+ if (ret)
+ goto out;
- list_add_tail (&peerinfo->uuid_list, &conf->peers);
+ ret = glusterd_rpc_create (&(*friend)->rpc, options,
+ glusterd_peer_rpc_notify,
+ peerctx);
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "failed to create rpc for"
+ " peer %s", (char*)hoststr);
+ goto out;
}
+ handover = _gf_true;
out:
- if (ret) {
- if (peerctx)
- GF_FREE (peerctx);
- if (is_allocated && rpc) {
- (void) rpc_clnt_unref (rpc);
- }
- if (peerinfo) {
- peerinfo->rpc = NULL;
- (void) glusterd_friend_cleanup (peerinfo);
- }
+ if (ret && !handover) {
+ (void) glusterd_friend_cleanup (*friend);
+ *friend = NULL;
}
gf_log ("glusterd", GF_LOG_INFO, "connect returned %d", ret);
@@ -2158,7 +2132,7 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port)
args.req = req;
ret = glusterd_friend_add ((char *)hoststr, port,
GD_FRIEND_STATE_DEFAULT,
- NULL, NULL, &peerinfo, 0, &args);
+ NULL, &peerinfo, 0, &args);
if ((!ret) && (!peerinfo->connected)) {
ret = GLUSTERD_CONNECTION_AWAITED;
}
@@ -2725,6 +2699,15 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
{
gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT");
peerinfo->connected = 1;
+ ret = glusterd_store_peerinfo (peerinfo);
+ if (ret) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+ "peerinfo");
+ break;
+ }
+
+ list_add_tail (&peerinfo->uuid_list, &conf->peers);
ret = glusterd_peer_handshake (this, rpc, peerctx);
if (ret)
@@ -2769,11 +2752,6 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
//Inject friend disconnected here
if (peerinfo->state.state == GD_FRIEND_STATE_DEFAULT) {
- /* Remove the friend as it was the newly requested
- 'peer' and connection with this peer didn't
- succeed. we have opportunity to notify user
- */
- peerctx->peerinfo = NULL;
glusterd_friend_remove_notify (peerinfo,
peerctx->args.req);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 823fb37cd71..4fe8f71cb5b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2339,7 +2339,7 @@ glusterd_store_retrieve_peers (xlator_t *this)
args.mode = GD_MODE_SWITCH_ON;
ret = glusterd_friend_add (hostname, 0, state, &uuid,
- NULL, &peerinfo, 1, &args);
+ &peerinfo, 1, &args);
GF_FREE (hostname);
if (ret)
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index af6381bbfb2..e9f3bd05577 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -936,6 +936,10 @@ init (xlator_t *this)
strncpy (conf->workdir, dirname, PATH_MAX);
INIT_LIST_HEAD (&conf->xprt_list);
+
+ glusterd_friend_sm_init ();
+ glusterd_op_sm_init ();
+ glusterd_opinfo_init ();
ret = glusterd_sm_tr_log_init (&conf->op_sm_log,
glusterd_op_sm_state_name_get,
glusterd_op_sm_event_name_get,
@@ -987,10 +991,6 @@ init (xlator_t *this)
if (ret < 0)
goto out;
- glusterd_friend_sm_init ();
- glusterd_op_sm_init ();
- glusterd_opinfo_init ();
-
ret = glusterd_handle_upgrade_downgrade (this->options, conf);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index fe2402ec26b..3c671da641c 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -330,10 +330,8 @@ glusterd_friend_find (uuid_t uuid, char *hostname,
int
glusterd_friend_add (const char *hoststr, int port,
glusterd_friend_sm_state_t state,
- uuid_t *uuid, struct rpc_clnt *rpc,
- glusterd_peerinfo_t **friend,
- gf_boolean_t restore,
- glusterd_peerctx_args_t *args);
+ uuid_t *uuid, glusterd_peerinfo_t **friend,
+ gf_boolean_t restore, glusterd_peerctx_args_t *args);
int
glusterd_friend_remove (uuid_t uuid, char *hostname);