summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-peer-utils.c38
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-peer-utils.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.h1
5 files changed, 53 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 524ce35d841..fcdfa608607 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -3152,6 +3152,10 @@ glusterd_friend_rpc_create (xlator_t *this, glusterd_peerinfo_t *peerinfo,
gf_uuid_copy (peerctx->peerid, peerinfo->uuid);
peerctx->peername = gf_strdup (peerinfo->hostname);
+ peerctx->peerinfo_gen = peerinfo->generation; /* A peerinfos generation
+ number can be used to
+ uniquely identify a
+ peerinfo */
ret = glusterd_transport_inet_options_build (&options,
peerinfo->hostname,
@@ -4613,7 +4617,7 @@ glusterd_friend_remove_notify (glusterd_peerctx_t *peerctx)
GF_ASSERT (peerctx);
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
gf_log (THIS->name, GF_LOG_DEBUG, "Could not find peer %s(%s). "
"Peer could have been deleted.", peerctx->peername,
@@ -4684,7 +4688,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
/* Peerinfo should be available at this point. Not finding it
* means that something terrible has happened
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index bc00e99b62f..f1712685dcb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -1527,7 +1527,7 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
ret = -1;
gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
@@ -1621,7 +1621,7 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
peerctx = frame->local;
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
@@ -1725,7 +1725,7 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
ret = -1;
gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
@@ -1859,7 +1859,7 @@ glusterd_mgmt_handshake (xlator_t *this, glusterd_peerctx_t *peerctx)
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
gf_log (THIS->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
@@ -1988,7 +1988,7 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
@@ -2109,7 +2109,7 @@ glusterd_peer_dump_version (xlator_t *this, struct rpc_clnt *rpc,
rcu_read_lock ();
- peerinfo = glusterd_peerinfo_find (peerctx->peerid, peerctx->peername);
+ peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
index f3241e918f7..9a05941a3f3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
@@ -949,3 +949,41 @@ gd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *friends,
out:
return ret;
}
+
+/* glusterd_peerinfo_find_by_generation searches for a peer which has the
+ * generation number @generation and if found returns the pointer to peerinfo
+ * object. Returns NULL otherwise.
+ */
+glusterd_peerinfo_t *
+glusterd_peerinfo_find_by_generation (uint32_t generation) {
+ glusterd_conf_t *priv = NULL;
+ glusterd_peerinfo_t *entry = NULL;
+ glusterd_peerinfo_t *found = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ priv = this->private;
+
+ GF_ASSERT (priv);
+
+ rcu_read_lock ();
+ cds_list_for_each_entry_rcu (entry, &priv->peers, uuid_list) {
+ if (entry->generation == generation) {
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Friend found... state: %s",
+ glusterd_friend_sm_state_name_get (entry->state.state));
+ found = entry; /* Probably should be rcu_dereferenced */
+ break;
+ }
+ }
+ rcu_read_unlock ();
+
+ if (!found)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Friend with generation: %"PRIu32", not found",
+ generation);
+ return found;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
index 3a1aee7cd15..bd30e335f69 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
@@ -82,4 +82,6 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
int
gd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *friends,
int count);
+glusterd_peerinfo_t *
+glusterd_peerinfo_find_by_generation (uint32_t generation);
#endif /* _GLUSTERD_PEER_UTILS_H */
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.h b/xlators/mgmt/glusterd/src/glusterd-sm.h
index d75baa8d128..60e7514fdae 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.h
@@ -130,6 +130,7 @@ typedef struct glusterd_peer_ctx_ {
glusterd_peerctx_args_t args;
uuid_t peerid;
char *peername;
+ uint32_t peerinfo_gen;
char *errstr;
} glusterd_peerctx_t;