diff options
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 60 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 29 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 27 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 15 |
6 files changed, 97 insertions, 39 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index a069e0ec5..102cc01c9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -103,6 +103,9 @@ glusterd_friend_find_by_uuid (uuid_t uuid, GF_ASSERT (priv); + if (uuid_is_null (uuid)) + return -1; + list_for_each_entry (entry, &priv->peers, uuid_list) { if (!uuid_compare (entry->uuid, uuid)) { @@ -285,6 +288,11 @@ glusterd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, if (ret) goto out; + snprintf (key, 256, "friend%d.connected", count); + ret = dict_set_int32 (friends, key, (int32_t)peerinfo->connected); + if (ret) + goto out; + out: return ret; } @@ -2349,6 +2357,8 @@ glusterd_handle_probe_query (rpcsvc_request_t *req) gd1_mgmt_probe_req probe_req = {{0},}; gd1_mgmt_probe_rsp rsp = {{0},}; glusterd_peer_hostname_t *name = NULL; + glusterd_peerinfo_t *peerinfo = NULL; + char remote_hostname[UNIX_PATH_MAX + 1] = {0,}; GF_ASSERT (req); @@ -2367,23 +2377,35 @@ glusterd_handle_probe_query (rpcsvc_request_t *req) gf_log ("glusterd", GF_LOG_NORMAL, "Received probe from uuid: %s", str); - ret = glusterd_peer_hostname_new (probe_req.hostname, &name); - + ret = glusterd_remote_hostname_get (req, remote_hostname, + sizeof (remote_hostname)); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to get new peer_hostname"); - } else { - list_add_tail (&name->hostname_list, &conf->hostnames); + GF_ASSERT (0); + goto out; } + ret = glusterd_friend_find (NULL, remote_hostname, &peerinfo); + if ((ret == 0 ) || list_empty (&conf->peers)) { + ret = glusterd_peer_hostname_new (probe_req.hostname, &name); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to get new peer_hostname"); + } else { + list_add_tail (&name->hostname_list, &conf->hostnames); + } + uuid_copy (rsp.uuid, conf->uuid); + } else { + rsp.op_ret = -1; + rsp.op_errno = GF_PROBE_ANOTHER_CLUSTER; + } - uuid_copy (rsp.uuid, conf->uuid); rsp.hostname = probe_req.hostname; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gd_xdr_serialize_mgmt_probe_rsp); - gf_log ("glusterd", GF_LOG_NORMAL, - "Responded to %s, ret: %d", probe_req.hostname, ret); + gf_log ("glusterd", GF_LOG_NORMAL, "Responded to %s, op_ret: %d, " + "op_errno: %d, ret: %d", probe_req.hostname, + rsp.op_ret, rsp.op_errno, ret); out: if (probe_req.hostname) @@ -2392,6 +2414,22 @@ out: } int +glusterd_friend_remove (uuid_t uuid, char *hostname) +{ + int ret = 0; + glusterd_peerinfo_t *peerinfo = NULL; + + ret = glusterd_friend_find (uuid, hostname, &peerinfo); + if (ret) + goto out; + + ret = glusterd_friend_cleanup (peerinfo); +out: + gf_log ("", GF_LOG_DEBUG, "returning %d"); + return ret; +} + +int glusterd_friend_add (const char *hoststr, int port, glusterd_friend_sm_state_t state, uuid_t *uuid, @@ -2665,6 +2703,8 @@ glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname, int port, gf_log ("glusterd", GF_LOG_NORMAL, "Responded to %s (%d), ret: %d", hostname, port, ret); + if (rsp.hostname) + GF_FREE (rsp.hostname) return ret; } @@ -3169,7 +3209,7 @@ glusterd_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, case RPC_CLNT_CONNECT: { - gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); + gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); peerinfo->connected = 1; glusterd_friend_sm (); glusterd_op_sm (); @@ -3188,7 +3228,7 @@ glusterd_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, //Inject friend disconnected here - gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); + gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_DISCONNECT"); peerinfo->connected = 0; //default_notify (this, GF_EVENT_CHILD_DOWN, NULL); diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index b1dc1ddac..602494b14 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -296,7 +296,7 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event, ret = glusterd_xfer_friend_remove_resp (ev_ctx->req, ev_ctx->hostname, ev_ctx->port); - rpc_clnt_destroy (peerinfo->rpc); + peerinfo->rpc = rpc_clnt_unref (peerinfo->rpc); peerinfo->rpc = NULL; ret = glusterd_friend_sm_new_event (GD_FRIEND_EVENT_REMOVE_FRIEND, @@ -340,31 +340,6 @@ glusterd_ac_none (void *ctx) return ret; }*/ -int -glusterd_remote_hostname_get (rpcsvc_request_t *req, char *remote_host, int len) -{ - GF_ASSERT (req); - GF_ASSERT (remote_host); - GF_ASSERT (req->trans); - - char *name = NULL; - char *delimiter = NULL; - - name = req->trans->peerinfo.identifier; - strncpy (remote_host, name, len); - delimiter = strchr (remote_host, ':'); - - GF_ASSERT (delimiter); - if (!delimiter) { - memset (remote_host, 0, len); - return -1; - } - - *delimiter = '\0'; - - return 0; -} - static int glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) { @@ -377,7 +352,7 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE; int status = 0; int32_t op_ret = -1; - char remote_hostname[UNIX_PATH_MAX + 1] = {0,}; + char remote_hostname[UNIX_PATH_MAX + 1] = {0,}; GF_ASSERT (ctx); ev_ctx = ctx; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 4ef0bd17b..845fcbbe9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -729,7 +729,7 @@ glusterd_friend_cleanup (glusterd_peerinfo_t *peerinfo) { GF_ASSERT (peerinfo); if (peerinfo->rpc) { - rpc_clnt_destroy (peerinfo->rpc); + peerinfo->rpc = rpc_clnt_unref (peerinfo->rpc); peerinfo->rpc = NULL; } glusterd_peer_destroy (peerinfo); @@ -1696,3 +1696,28 @@ glusterd_are_all_volumes_stopped () } +int +glusterd_remote_hostname_get (rpcsvc_request_t *req, char *remote_host, int len) +{ + GF_ASSERT (req); + GF_ASSERT (remote_host); + GF_ASSERT (req->trans); + + char *name = NULL; + char *delimiter = NULL; + + name = req->trans->peerinfo.identifier; + strncpy (remote_host, name, len); + delimiter = strchr (remote_host, ':'); + + GF_ASSERT (delimiter); + if (!delimiter) { + memset (remote_host, 0, len); + return -1; + } + + *delimiter = '\0'; + + return 0; +} + diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 183642811..19ca43fa1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -142,4 +142,7 @@ glusterd_file_copy (int out, int in); gf_boolean_t glusterd_are_all_volumes_stopped (); +int +glusterd_remote_hostname_get (rpcsvc_request_t *req, + char *remote_host, int len); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 708080a13..e888b7c9d 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -238,6 +238,8 @@ glusterd_friend_add (const char *hoststr, int port, glusterd_peerinfo_t **friend, gf_boolean_t restore); +int +glusterd_friend_remove (uuid_t uuid, char *hostname); int glusterd_op_lock_send_resp (rpcsvc_request_t *req, int32_t status); diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index a9dfa6d41..943509990 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -60,6 +60,7 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, glusterd_peerinfo_t *dup_peerinfo = NULL; glusterd_friend_sm_event_t *event = NULL; glusterd_peer_hostname_t *name = NULL; + glusterd_probe_ctx_t *ctx = NULL; conf = THIS->private; @@ -79,9 +80,20 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("glusterd", GF_LOG_NORMAL, "Received probe resp from uuid: %s, host: %s", str, rsp.hostname); + if (rsp.op_ret != 0) { + ctx = ((call_frame_t *)myframe)->local; + ((call_frame_t *)myframe)->local = NULL; - ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); + GF_ASSERT (ctx); + glusterd_xfer_cli_probe_resp (ctx->req, rsp.op_ret, + rsp.op_errno, + ctx->hostname, ctx->port); + ret = rsp.op_ret; + (void) glusterd_friend_remove (rsp.uuid, rsp.hostname); + goto out; + } + ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); if (ret) { GF_ASSERT (0); } @@ -93,6 +105,7 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, glusterd_peer_hostname_new (rsp.hostname, &name); list_add_tail (&name->hostname_list, &peerinfo->hostnames); peerinfo->rpc = dup_peerinfo->rpc; + peerinfo->connected = dup_peerinfo->connected; glusterd_peer_destroy (dup_peerinfo); } if (!peerinfo->hostname) |