summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2015-01-06 18:23:41 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-03-03 23:50:22 -0800
commit673ba2659cebe22ee30c43f9fb080f330150f55e (patch)
treef91e83be5cfae7a08febfda420b33e05ed0b964f /xlators/mgmt/glusterd/src/glusterd-peer-utils.c
parentef061b67f1b80c147c1959b896f7c9bdff01af96 (diff)
glusterd: Replace libglusterfs lists with liburcu lists
This patch replaces usage of the libglusterfs lists data structures and API in glusterd with the lists data structures and API from liburcu. The liburcu data structes and APIs are a drop-in replacement for libglusterfs lists. All usages have been changed to keep the code consistent, and free from confusion. NOTE: glusterd_conf_t->xprt_list still uses the libglusterfs data structures and API, as it holds rpc_transport_t objects, which is not a part of glusterd and is not being changed in this patch. This change was developed on the git branch at [1]. This commit is a combination of the following commits on the development branch. 6dac576 Replace libglusterfs lists with liburcu lists a51b5ab Fix compilation issues d98a06f Fix merge issues a5d918e Remove merge remnant 1cca113 More style cleanup 1917be3 Address review comments on 9624/1 8d10f13 Use cds_lists for glusterd_svc_t 524ad5d Add rculist header in glusterd-conn-helper.c 646f294 glusterd: add list_add_order API honouring rcu [1]: https://github.com/kshlm/glusterfs/tree/urcu Change-Id: Ic613c5b6e496a677b9d3de15fc042a0492109fb0 BUG: 1191030 Signed-off-by: Kaushal M <kaushal@redhat.com> Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/9624 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-peer-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-peer-utils.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
index be8ae76c77a..3a145264b79 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
@@ -49,7 +49,7 @@ glusterd_peerinfo_destroy (glusterd_peerinfo_t *peerinfo)
if (!peerinfo)
goto out;
- list_del_init (&peerinfo->uuid_list);
+ cds_list_del_init (&peerinfo->uuid_list);
ret = glusterd_store_delete_peerinfo (peerinfo);
if (ret) {
@@ -59,8 +59,8 @@ glusterd_peerinfo_destroy (glusterd_peerinfo_t *peerinfo)
GF_FREE (peerinfo->hostname);
peerinfo->hostname = NULL;
- list_for_each_entry_safe (hostname, tmp, &peerinfo->hostnames,
- hostname_list) {
+ cds_list_for_each_entry_safe (hostname, tmp, &peerinfo->hostnames,
+ hostname_list) {
glusterd_peer_hostname_free (hostname);
}
@@ -178,7 +178,7 @@ glusterd_peerinfo_find_by_uuid (uuid_t uuid)
if (uuid_is_null (uuid))
return NULL;
- list_for_each_entry (entry, &priv->peers, uuid_list) {
+ cds_list_for_each_entry (entry, &priv->peers, uuid_list) {
if (!uuid_compare (entry->uuid, uuid)) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -252,11 +252,11 @@ glusterd_peerinfo_new (glusterd_friend_sm_state_t state, uuid_t *uuid,
if (!new_peer)
goto out;
- INIT_LIST_HEAD (&new_peer->uuid_list);
+ CDS_INIT_LIST_HEAD (&new_peer->uuid_list);
new_peer->state.state = state;
- INIT_LIST_HEAD (&new_peer->hostnames);
+ CDS_INIT_LIST_HEAD (&new_peer->hostnames);
if (hostname) {
ret = gd_add_address_to_peer (new_peer, hostname);
if (ret)
@@ -303,7 +303,7 @@ glusterd_chk_peers_connected_befriended (uuid_t skip_uuid)
priv= THIS->private;
GF_ASSERT (priv);
- list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
+ cds_list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
if (!uuid_is_null (skip_uuid) && !uuid_compare (skip_uuid,
peerinfo->uuid))
@@ -336,8 +336,8 @@ glusterd_uuid_to_hostname (uuid_t uuid)
if (!uuid_compare (MY_UUID, uuid)) {
hostname = gf_strdup ("localhost");
}
- if (!list_empty (&priv->peers)) {
- list_for_each_entry (entry, &priv->peers, uuid_list) {
+ if (!cds_list_empty (&priv->peers)) {
+ cds_list_for_each_entry (entry, &priv->peers, uuid_list) {
if (!uuid_compare (entry->uuid, uuid)) {
hostname = gf_strdup (entry->hostname);
break;
@@ -362,18 +362,18 @@ gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo)
gf_boolean_t
glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo,
- struct list_head *peers,
+ struct cds_list_head *peers,
char **down_peerstr)
{
glusterd_peerinfo_t *peerinfo = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
gf_boolean_t ret = _gf_false;
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (!uuid_compare (brickinfo->uuid, MY_UUID))
continue;
- list_for_each_entry (peerinfo, peers, uuid_list) {
+ cds_list_for_each_entry (peerinfo, peers, uuid_list) {
if (uuid_compare (peerinfo->uuid, brickinfo->uuid))
continue;
@@ -413,7 +413,7 @@ glusterd_peer_hostname_new (const char *hostname,
goto out;
peer_hostname->hostname = gf_strdup (hostname);
- INIT_LIST_HEAD (&peer_hostname->hostname_list);
+ CDS_INIT_LIST_HEAD (&peer_hostname->hostname_list);
*name = peer_hostname;
ret = 0;
@@ -429,7 +429,7 @@ glusterd_peer_hostname_free (glusterd_peer_hostname_t *name)
if (!name)
return;
- list_del_init (&name->hostname_list);
+ cds_list_del_init (&name->hostname_list);
GF_FREE (name->hostname);
name->hostname = NULL;
@@ -448,7 +448,8 @@ gd_peer_has_address (glusterd_peerinfo_t *peerinfo, const char *address)
GF_VALIDATE_OR_GOTO ("glusterd", (peerinfo != NULL), out);
GF_VALIDATE_OR_GOTO ("glusterd", (address != NULL), out);
- list_for_each_entry (hostname, &peerinfo->hostnames, hostname_list) {
+ cds_list_for_each_entry (hostname, &peerinfo->hostnames,
+ hostname_list) {
if (strcmp (hostname->hostname, address) == 0) {
ret = _gf_true;
break;
@@ -478,7 +479,7 @@ gd_add_address_to_peer (glusterd_peerinfo_t *peerinfo, const char *address)
if (ret)
goto out;
- list_add_tail (&hostname->hostname_list, &peerinfo->hostnames);
+ cds_list_add_tail (&hostname->hostname_list, &peerinfo->hostnames);
ret = 0;
out:
@@ -525,8 +526,8 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict,
*/
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.hostname", prefix);
- address = list_entry (&friend->hostnames, glusterd_peer_hostname_t,
- hostname_list);
+ address = cds_list_entry (&friend->hostnames, glusterd_peer_hostname_t,
+ hostname_list);
if (!address) {
ret = -1;
gf_log (this->name, GF_LOG_ERROR, "Could not retrieve first "
@@ -547,7 +548,7 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict,
address = NULL;
count = 0;
- list_for_each_entry (address, &friend->hostnames, hostname_list) {
+ cds_list_for_each_entry (address, &friend->hostnames, hostname_list) {
GF_VALIDATE_OR_GOTO (this->name, (address != NULL), out);
memset (key, 0, sizeof (key));
@@ -592,8 +593,9 @@ gd_peerinfo_find_from_hostname (const char *hoststr)
GF_VALIDATE_OR_GOTO (this->name, (hoststr != NULL), out);
- list_for_each_entry (peer, &priv->peers, uuid_list) {
- list_for_each_entry (tmphost, &peer->hostnames,hostname_list) {
+ cds_list_for_each_entry (peer, &priv->peers, uuid_list) {
+ cds_list_for_each_entry (tmphost, &peer->hostnames,
+ hostname_list) {
if (!strncasecmp (tmphost->hostname, hoststr, 1024)) {
gf_log (this->name, GF_LOG_DEBUG,
"Friend %s found.. state: %d",
@@ -634,8 +636,9 @@ gd_peerinfo_find_from_addrinfo (const struct addrinfo *addr)
GF_VALIDATE_OR_GOTO (this->name, (addr != NULL), out);
- list_for_each_entry (peer, &conf->peers, uuid_list) {
- list_for_each_entry (address, &peer->hostnames, hostname_list) {
+ cds_list_for_each_entry (peer, &conf->peers, uuid_list) {
+ cds_list_for_each_entry (address, &peer->hostnames,
+ hostname_list) {
/* TODO: Cache the resolved addrinfos to improve
* performance
*/
@@ -827,7 +830,7 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict,
GF_VALIDATE_OR_GOTO (this->name, (dict != NULL), out);
GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out);
- list_for_each_entry (addr, &peerinfo->hostnames, hostname_list) {
+ cds_list_for_each_entry (addr, &peerinfo->hostnames, hostname_list) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.hostname%d", prefix, count);
ret = dict_set_dynstr_with_alloc (dict, key, addr->hostname);