summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c202
1 files changed, 116 insertions, 86 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 04fa67c6df1..84cdfca3049 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -477,10 +477,10 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
goto out;
LOCK_INIT (&new_volinfo->lock);
- INIT_LIST_HEAD (&new_volinfo->vol_list);
- INIT_LIST_HEAD (&new_volinfo->snapvol_list);
- INIT_LIST_HEAD (&new_volinfo->bricks);
- INIT_LIST_HEAD (&new_volinfo->snap_volumes);
+ CDS_INIT_LIST_HEAD (&new_volinfo->vol_list);
+ CDS_INIT_LIST_HEAD (&new_volinfo->snapvol_list);
+ CDS_INIT_LIST_HEAD (&new_volinfo->bricks);
+ CDS_INIT_LIST_HEAD (&new_volinfo->snap_volumes);
new_volinfo->dict = dict_new ();
if (!new_volinfo->dict) {
@@ -709,7 +709,7 @@ glusterd_brickinfo_delete (glusterd_brickinfo_t *brickinfo)
GF_ASSERT (brickinfo);
- list_del_init (&brickinfo->brick_list);
+ cds_list_del_init (&brickinfo->brick_list);
GF_FREE (brickinfo->logfile);
GF_FREE (brickinfo);
@@ -728,8 +728,8 @@ glusterd_volume_brickinfos_delete (glusterd_volinfo_t *volinfo)
GF_ASSERT (volinfo);
- list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks,
- brick_list) {
+ cds_list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks,
+ brick_list) {
ret = glusterd_brickinfo_delete (brickinfo);
if (ret)
goto out;
@@ -743,7 +743,7 @@ out:
int
glusterd_volinfo_remove (glusterd_volinfo_t *volinfo)
{
- list_del_init (&volinfo->vol_list);
+ cds_list_del_init (&volinfo->vol_list);
glusterd_volinfo_unref (volinfo);
return 0;
}
@@ -755,8 +755,8 @@ glusterd_volinfo_delete (glusterd_volinfo_t *volinfo)
GF_ASSERT (volinfo);
- list_del_init (&volinfo->vol_list);
- list_del_init (&volinfo->snapvol_list);
+ cds_list_del_init (&volinfo->vol_list);
+ cds_list_del_init (&volinfo->snapvol_list);
ret = glusterd_volume_brickinfos_delete (volinfo);
if (ret)
@@ -798,7 +798,7 @@ glusterd_brickinfo_new (glusterd_brickinfo_t **brickinfo)
if (!new_brickinfo)
goto out;
- INIT_LIST_HEAD (&new_brickinfo->brick_list);
+ CDS_INIT_LIST_HEAD (&new_brickinfo->brick_list);
*brickinfo = new_brickinfo;
@@ -818,7 +818,7 @@ glusterd_get_next_available_brickid (glusterd_volinfo_t *volinfo)
int max_brickid = -1;
int ret = -1;
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
token = strrchr (brickinfo->brick_id, '-');
ret = gf_string2int32 (++token, &brickid);
if (ret < 0) {
@@ -1025,8 +1025,9 @@ glusterd_is_brickpath_available (uuid_t uuid, char *path)
strncpy(tmp_path,path,PATH_MAX);
}
- list_for_each_entry (volinfo, &priv->volumes, vol_list) {
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks,
+ brick_list) {
if (uuid_compare (uuid, brickinfo->uuid))
continue;
@@ -1331,7 +1332,7 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,
goto out;
}
ret = -1;
- list_for_each_entry (brickiter, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickiter, &volinfo->bricks, brick_list) {
if ((uuid_is_null (brickiter->uuid)) &&
(glusterd_resolve_brick (brickiter) != 0))
@@ -1410,7 +1411,7 @@ glusterd_volinfo_find_by_volume_id (uuid_t volume_id, glusterd_volinfo_t **volin
this = THIS;
priv = this->private;
- list_for_each_entry (voliter, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (voliter, &priv->volumes, vol_list) {
if (uuid_compare (volume_id, voliter->volume_id))
continue;
*volinfo = voliter;
@@ -1437,7 +1438,7 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo)
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) {
if (!strcmp (tmp_volinfo->volname, volname)) {
gf_log (this->name, GF_LOG_DEBUG, "Volume %s found",
volname);
@@ -1845,7 +1846,7 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
priv = this->private;
if (del_brick)
- list_del_init (&brickinfo->brick_list);
+ cds_list_del_init (&brickinfo->brick_list);
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
(void) glusterd_brick_disconnect (brickinfo);
@@ -2145,7 +2146,7 @@ glusterd_add_bricks_hname_path_to_dict (dict_t *dict,
int index = 0;
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
snprintf (key, sizeof (key), "%d-hostname", index);
ret = dict_set_str (dict, key, brickinfo->hostname);
if (ret)
@@ -2420,7 +2421,7 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s%d.brick%d.hostname",
prefix, count, i);
@@ -2598,7 +2599,7 @@ glusterd_add_volumes_to_export_dict (dict_t **peer_data)
if (!dict)
goto out;
- list_for_each_entry (volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
count++;
ret = glusterd_add_volume_to_dict (volinfo, dict, count,
"volume");
@@ -2898,7 +2899,7 @@ _does_quorum_meet (int active_count, int quorum_count)
int
glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count,
int *quorum_count,
- struct list_head *peer_list,
+ struct cds_list_head *peer_list,
gf_boolean_t _local_xaction_peers)
{
glusterd_peerinfo_t *peerinfo = NULL;
@@ -2918,7 +2919,7 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count,
*active_count = 1;
if (!peer_list) {
- list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
+ cds_list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
glusterd_quorum_count(peerinfo, inquorum_count,
active_count, out);
}
@@ -2930,8 +2931,8 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count,
active_count, out);
}
} else {
- list_for_each_entry (peerinfo, peer_list,
- op_peers_list) {
+ cds_list_for_each_entry (peerinfo, peer_list,
+ op_peers_list) {
glusterd_quorum_count(peerinfo, inquorum_count,
active_count, out);
}
@@ -2981,7 +2982,7 @@ glusterd_is_any_volume_in_server_quorum (xlator_t *this)
glusterd_volinfo_t *volinfo = NULL;
conf = this->private;
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
if (glusterd_is_volume_in_server_quorum (volinfo)) {
return _gf_true;
}
@@ -2990,7 +2991,7 @@ glusterd_is_any_volume_in_server_quorum (xlator_t *this)
}
gf_boolean_t
-does_gd_meet_server_quorum (xlator_t *this, struct list_head *peers_list,
+does_gd_meet_server_quorum (xlator_t *this, struct cds_list_head *peers_list,
gf_boolean_t _local_xaction_peers)
{
int quorum_count = 0;
@@ -3085,7 +3086,7 @@ glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo,
"bricks.", volinfo->volname);
}
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (!glusterd_is_local_brick (this, volinfo, brickinfo))
continue;
if (quorum_status == DOESNT_MEET_QUORUM)
@@ -3126,7 +3127,7 @@ glusterd_do_quorum_action ()
if (_does_quorum_meet (active_count, quorum_count))
meets = _gf_true;
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
glusterd_do_volume_quorum_action (this, volinfo, meets);
}
}
@@ -3309,7 +3310,8 @@ glusterd_import_bricks (dict_t *peer_data, int32_t vol_count,
GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (new_brickinfo,
new_volinfo,
brickid++);
- list_add_tail (&new_brickinfo->brick_list, &new_volinfo->bricks);
+ cds_list_add_tail (&new_brickinfo->brick_list,
+ &new_volinfo->bricks);
brick_count++;
}
ret = 0;
@@ -3821,7 +3823,7 @@ glusterd_volume_disconnect_all_bricks (glusterd_volinfo_t *volinfo)
glusterd_brickinfo_t *brickinfo = NULL;
GF_ASSERT (volinfo);
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (glusterd_is_brick_started (brickinfo)) {
ret = glusterd_brick_disconnect (brickinfo);
if (ret) {
@@ -3857,11 +3859,13 @@ glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *new_volinfo,
if (_gf_false == glusterd_is_volume_started (new_volinfo))
goto out;
- list_for_each_entry (new_brickinfo, &new_volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (new_brickinfo, &new_volinfo->bricks,
+ brick_list) {
ret = glusterd_volume_brickinfo_get (new_brickinfo->uuid,
new_brickinfo->hostname,
new_brickinfo->path,
- old_volinfo, &old_brickinfo);
+ old_volinfo,
+ &old_brickinfo);
if (ret == 0) {
GLUSTERD_GET_BRICK_PIDFILE (pidfile, old_volinfo,
old_brickinfo, priv);
@@ -3887,11 +3891,13 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo,
GF_ASSERT (old_volinfo);
if (_gf_false == glusterd_is_volume_started (old_volinfo))
goto out;
- list_for_each_entry (old_brickinfo, &old_volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (old_brickinfo, &old_volinfo->bricks,
+ brick_list) {
ret = glusterd_volume_brickinfo_get (old_brickinfo->uuid,
old_brickinfo->hostname,
old_brickinfo->path,
- new_volinfo, &new_brickinfo);
+ new_volinfo,
+ &new_brickinfo);
/* If the brick is stale, i.e it's not a part of the new volume
* or if it's part of the new volume and is pending a snap,
* then stop the brick process
@@ -3932,10 +3938,11 @@ glusterd_delete_stale_volume (glusterd_volinfo_t *stale_volinfo,
/* Copy snap_volumes list from stale_volinfo to valid_volinfo */
valid_volinfo->snap_count = 0;
- list_for_each_entry_safe (voliter, temp_volinfo,
- &stale_volinfo->snap_volumes, snapvol_list) {
- list_add_tail (&voliter->snapvol_list,
- &valid_volinfo->snap_volumes);
+ cds_list_for_each_entry_safe (voliter, temp_volinfo,
+ &stale_volinfo->snap_volumes,
+ snapvol_list) {
+ cds_list_add_tail (&voliter->snapvol_list,
+ &valid_volinfo->snap_volumes);
valid_volinfo->snap_count++;
}
@@ -4110,8 +4117,9 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
if (ret)
goto out;
- list_add_order (&new_volinfo->vol_list, &priv->volumes,
- glusterd_compare_volume_name);
+ glusterd_list_add_order (&new_volinfo->vol_list, &priv->volumes,
+ glusterd_compare_volume_name);
+
out:
gf_log ("", GF_LOG_DEBUG, "Returning with ret: %d", ret);
return ret;
@@ -4534,7 +4542,7 @@ glusterd_are_all_volumes_stopped ()
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (voliter, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (voliter, &priv->volumes, vol_list) {
if (voliter->status == GLUSTERD_STATUS_STARTED)
return _gf_false;
}
@@ -4555,7 +4563,7 @@ glusterd_all_shd_compatible_volumes_stopped ()
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (voliter, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (voliter, &priv->volumes, vol_list) {
if (!glusterd_is_shd_compatible_volume (voliter))
continue;
if (voliter->status == GLUSTERD_STATUS_STARTED)
@@ -4577,7 +4585,7 @@ glusterd_all_volumes_with_quota_stopped ()
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (voliter, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (voliter, &priv->volumes, vol_list) {
if (!glusterd_is_volume_quota_enabled (voliter))
continue;
if (voliter->status == GLUSTERD_STATUS_STARTED)
@@ -4600,7 +4608,7 @@ glusterd_volume_count_get (void)
priv = this->private;
- list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) {
ret++;
}
@@ -4626,7 +4634,7 @@ glusterd_brickinfo_get (uuid_t uuid, char *hostname, char *path,
priv = this->private;
- list_for_each_entry (volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
ret = glusterd_volume_brickinfo_get (uuid, hostname, path,
volinfo, brickinfo);
@@ -4690,26 +4698,27 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
this = THIS;
GF_ASSERT (this);
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
if (volinfo->status != GLUSTERD_STATUS_STARTED)
continue;
start_svcs = _gf_true;
gf_log (this->name, GF_LOG_DEBUG, "starting the volume %s",
volinfo->volname);
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks,
+ brick_list) {
glusterd_brick_start (volinfo, brickinfo, _gf_false);
}
}
- list_for_each_entry (snap, &conf->snapshots, snap_list) {
- list_for_each_entry (volinfo, &snap->volumes, vol_list) {
+ cds_list_for_each_entry (snap, &conf->snapshots, snap_list) {
+ cds_list_for_each_entry (volinfo, &snap->volumes, vol_list) {
if (volinfo->status != GLUSTERD_STATUS_STARTED)
continue;
start_svcs = _gf_true;
gf_log (this->name, GF_LOG_DEBUG, "starting the snap "
"volume %s", volinfo->volname);
- list_for_each_entry (brickinfo, &volinfo->bricks,
- brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks,
+ brick_list) {
glusterd_brick_start (volinfo, brickinfo,
_gf_false);
}
@@ -4911,7 +4920,7 @@ glusterd_restart_gsyncds (glusterd_conf_t *conf)
glusterd_volinfo_t *volinfo = NULL;
int ret = 0;
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
glusterd_volume_restart_gsyncds (volinfo);
}
return ret;
@@ -4942,9 +4951,9 @@ glusterd_get_brickinfo (xlator_t *this, const char *brickname, int port,
GF_ASSERT (this);
priv = this->private;
- list_for_each_entry (volinfo, &priv->volumes, vol_list) {
- list_for_each_entry (tmpbrkinfo, &volinfo->bricks,
- brick_list) {
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (tmpbrkinfo, &volinfo->bricks,
+ brick_list) {
if (localhost && !gf_is_local_addr (tmpbrkinfo->hostname))
continue;
if (!strcmp(tmpbrkinfo->path, brickname) &&
@@ -4962,8 +4971,7 @@ glusterd_get_brickinfo_by_position (glusterd_volinfo_t *volinfo, uint32_t pos)
{
glusterd_brickinfo_t *tmpbrkinfo = NULL;
- list_for_each_entry (tmpbrkinfo, &volinfo->bricks,
- brick_list) {
+ cds_list_for_each_entry (tmpbrkinfo, &volinfo->bricks, brick_list) {
if (pos == 0)
return tmpbrkinfo;
pos--;
@@ -5540,7 +5548,7 @@ glusterd_get_all_volnames (dict_t *dict)
priv = THIS->private;
GF_ASSERT (priv);
- list_for_each_entry (entry, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (entry, &priv->volumes, vol_list) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "vol%d", vol_count);
ret = dict_set_str (dict, key, entry->volname);
@@ -5572,9 +5580,9 @@ glusterd_all_volume_cond_check (glusterd_condition_func func, int status,
this = THIS;
priv = this->private;
- list_for_each_entry (volinfo, &priv->volumes, vol_list) {
- list_for_each_entry (brickinfo, &volinfo->bricks,
- brick_list) {
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks,
+ brick_list) {
ret = func (volinfo, brickinfo, ctx);
if (ret != status) {
ret = -1;
@@ -6135,15 +6143,15 @@ out:
}
int
-glusterd_remove_pending_entry (struct list_head *list, void *elem)
+glusterd_remove_pending_entry (struct cds_list_head *list, void *elem)
{
glusterd_pending_node_t *pending_node = NULL;
glusterd_pending_node_t *tmp = NULL;
int ret = 0;
- list_for_each_entry_safe (pending_node, tmp, list, list) {
+ cds_list_for_each_entry_safe (pending_node, tmp, list, list) {
if (elem == pending_node->node) {
- list_del_init (&pending_node->list);
+ cds_list_del_init (&pending_node->list);
GF_FREE (pending_node);
ret = 0;
goto out;
@@ -6156,13 +6164,13 @@ out:
}
int
-glusterd_clear_pending_nodes (struct list_head *list)
+glusterd_clear_pending_nodes (struct cds_list_head *list)
{
glusterd_pending_node_t *pending_node = NULL;
glusterd_pending_node_t *tmp = NULL;
- list_for_each_entry_safe (pending_node, tmp, list, list) {
- list_del_init (&pending_node->list);
+ cds_list_for_each_entry_safe (pending_node, tmp, list, list) {
+ cds_list_del_init (&pending_node->list);
GF_FREE (pending_node);
}
@@ -6214,7 +6222,8 @@ glusterd_delete_all_bricks (glusterd_volinfo_t* volinfo)
GF_ASSERT (volinfo);
- list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks,
+ brick_list) {
ret = glusterd_delete_brick (volinfo, brickinfo);
}
return ret;
@@ -6244,7 +6253,7 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist)
goto out;
}
- 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;
@@ -6400,7 +6409,7 @@ glusterd_recreate_volfiles (glusterd_conf_t *conf)
int op_ret = 0;
GF_ASSERT (conf);
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
ret = generate_brick_volfiles (volinfo);
if (ret) {
gf_log ("glusterd", GF_LOG_ERROR, "Failed to "
@@ -6800,7 +6809,7 @@ glusterd_friend_contains_vol_bricks (glusterd_volinfo_t *volinfo,
GF_ASSERT (volinfo);
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (!uuid_compare (brickinfo->uuid, friend_uuid)) {
count++;
}
@@ -6831,8 +6840,8 @@ glusterd_friend_remove_cleanup_vols (uuid_t uuid)
priv = THIS->private;
GF_ASSERT (priv);
- list_for_each_entry_safe (volinfo, tmp_volinfo,
- &priv->volumes, vol_list) {
+ cds_list_for_each_entry_safe (volinfo, tmp_volinfo, &priv->volumes,
+ vol_list) {
if (glusterd_friend_contains_vol_bricks (volinfo, uuid) == 2) {
gf_log (THIS->name, GF_LOG_INFO,
"Deleting stale volume %s", volinfo->volname);
@@ -6965,7 +6974,7 @@ glusterd_restart_rebalance (glusterd_conf_t *conf)
int ret = 0;
char op_errstr[256];
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
if (!volinfo->rebal.defrag_cmd)
continue;
if (!gd_should_i_start_rebalance (volinfo))
@@ -8067,7 +8076,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
node_uuid_str = gf_strdup (node_uuid);
/* Finding the index of the node-uuid in the peer-list */
- list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
+ cds_list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
peer_uuid_str = gd_peer_uuid_str (peerinfo);
if (strcmp (peer_uuid_str, node_uuid_str) == 0)
break;
@@ -9093,7 +9102,7 @@ gd_should_i_start_rebalance (glusterd_volinfo_t *volinfo) {
switch (volinfo->rebal.op) {
case GD_OP_REBALANCE:
- list_for_each_entry (brick, &volinfo->bricks, brick_list) {
+ cds_list_for_each_entry (brick, &volinfo->bricks, brick_list) {
if (uuid_compare (MY_UUID, brick->uuid) == 0) {
retval = _gf_true;
break;
@@ -9393,13 +9402,14 @@ glusterd_rpc_clnt_unref (glusterd_conf_t *conf, rpc_clnt_t *rpc)
}
int32_t
-glusterd_compare_volume_name(struct list_head *list1, struct list_head *list2)
+glusterd_compare_volume_name(struct cds_list_head *list1,
+ struct cds_list_head *list2)
{
glusterd_volinfo_t *volinfo1 = NULL;
glusterd_volinfo_t *volinfo2 = NULL;
- volinfo1 = list_entry(list1, glusterd_volinfo_t, vol_list);
- volinfo2 = list_entry(list2, glusterd_volinfo_t, vol_list);
+ volinfo1 = cds_list_entry (list1, glusterd_volinfo_t, vol_list);
+ volinfo2 = cds_list_entry (list2, glusterd_volinfo_t, vol_list);
return strcmp(volinfo1->volname, volinfo2->volname);
}
@@ -9557,7 +9567,7 @@ glusterd_get_value_for_vme_entry (struct volopt_map_entry *vme, char **def_val)
this = THIS;
GF_ASSERT (this);
- INIT_LIST_HEAD (&vol_opt_handle.list);
+ CDS_INIT_LIST_HEAD (&vol_opt_handle.list);
if (_get_xlator_opt_key_from_vme (vme, &key)) {
gf_log (this->name, GF_LOG_ERROR, "Failed to get %s key from "
@@ -9715,7 +9725,7 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out)
}
#endif
- INIT_LIST_HEAD (&vol_opt_handle.list);
+ CDS_INIT_LIST_HEAD (&vol_opt_handle.list);
for (vme = &glusterd_volopt_map[0]; vme->key; vme++) {
@@ -9863,7 +9873,7 @@ glusterd_have_peers ()
conf = this->private;
GF_ASSERT (conf);
- return !list_empty (&conf->peers);
+ return !cds_list_empty (&conf->peers);
}
void
@@ -9880,10 +9890,10 @@ glusterd_op_clear_xaction_peers ()
GF_ASSERT (this);
GF_ASSERT (priv);
- list_for_each_entry_safe (peerinfo, tmp, &priv->xaction_peers,
- op_peers_list) {
+ cds_list_for_each_entry_safe (peerinfo, tmp, &priv->xaction_peers,
+ op_peers_list) {
GF_ASSERT (peerinfo);
- list_del_init (&peerinfo->op_peers_list);
+ cds_list_del_init (&peerinfo->op_peers_list);
}
}
@@ -9895,3 +9905,23 @@ glusterd_is_volume_started (glusterd_volinfo_t *volinfo)
return (volinfo->status == GLUSTERD_STATUS_STARTED);
}
+/* This function will insert the element to the list in a order.
+ Order will be based on the compare function provided as a input.
+ If element to be inserted in ascending order compare should return:
+ 0: if both the arguments are equal
+ >0: if first argument is greater than second argument
+ <0: if first argument is less than second argument */
+void
+glusterd_list_add_order (struct cds_list_head *new, struct cds_list_head *head,
+ int (*compare)(struct cds_list_head *,
+ struct cds_list_head *))
+{
+ struct cds_list_head *pos = NULL;
+
+ cds_list_for_each_rcu (pos, head) {
+ if (compare (new, pos) >= 0)
+ break;
+ }
+
+ cds_list_add_rcu (new, pos);
+}