diff options
author | Kaushal M <kaushal@redhat.com> | 2015-01-06 18:23:41 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-03-03 23:50:22 -0800 |
commit | 673ba2659cebe22ee30c43f9fb080f330150f55e (patch) | |
tree | f91e83be5cfae7a08febfda420b33e05ed0b964f /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | ef061b67f1b80c147c1959b896f7c9bdff01af96 (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-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 70e3536af85..047ff942cec 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -622,7 +622,7 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path) GF_ASSERT (volinfo); - list_for_each_entry (tmp, &volinfo->bricks, brick_list) { + cds_list_for_each_entry (tmp, &volinfo->bricks, brick_list) { ret = glusterd_store_delete_brick (tmp, delete_path); if (ret) goto out; @@ -1238,7 +1238,7 @@ glusterd_store_brickinfos (glusterd_volinfo_t *volinfo, int vol_fd) GF_ASSERT (volinfo); - list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { ret = glusterd_store_brickinfo (volinfo, brickinfo, brick_count, vol_fd); if (ret) @@ -1476,7 +1476,7 @@ glusterd_store_bricks_cleanup_tmp (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) { gf_store_unlink_tmppath (brickinfo->shandle); } } @@ -1505,7 +1505,7 @@ glusterd_store_brickinfos_atomic_update (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) { ret = gf_store_rename_tmppath (brickinfo->shandle); if (ret) goto out; @@ -2373,7 +2373,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) brickid++); } - list_add_tail (&brickinfo->brick_list, &volinfo->bricks); + cds_list_add_tail (&brickinfo->brick_list, &volinfo->bricks); brick_count++; } @@ -2901,8 +2901,9 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) if (!snap) { - list_add_order (&volinfo->vol_list, &priv->volumes, - glusterd_compare_volume_name); + glusterd_list_add_order (&volinfo->vol_list, &priv->volumes, + glusterd_compare_volume_name); + } else { ret = glusterd_volinfo_find (volinfo->parent_volname, &origin_volinfo); @@ -3231,7 +3232,7 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, GF_ASSERT (volinfo); brick_count = 0; - list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { brick_count++; /* If the brick is not of this node, or its * snapshot is pending, or the brick is not @@ -3309,8 +3310,9 @@ glusterd_resolve_snap_bricks (xlator_t *this, glusterd_snap_t *snap) GF_ASSERT (this); GF_VALIDATE_OR_GOTO (this->name, snap, out); - list_for_each_entry (volinfo, &snap->volumes, vol_list) { - list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + cds_list_for_each_entry (volinfo, &snap->volumes, vol_list) { + cds_list_for_each_entry (brickinfo, &volinfo->bricks, + brick_list) { ret = glusterd_resolve_brick (brickinfo); if (ret) { gf_log (this->name, GF_LOG_ERROR, @@ -3453,8 +3455,8 @@ glusterd_store_retrieve_snap (char *snapname) /* TODO: list_add_order can do 'N-square' comparisions and is not efficient. Find a better solution to store the snap in order */ - list_add_order (&snap->snap_list, &priv->snapshots, - glusterd_compare_snap_time); + glusterd_list_add_order (&snap->snap_list, &priv->snapshots, + glusterd_compare_snap_time); out: gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret); @@ -3635,11 +3637,11 @@ glusterd_store_write_missed_snapinfo (int32_t fd) GF_ASSERT (priv); /* Write the missed_snap_entry */ - list_for_each_entry (missed_snapinfo, &priv->missed_snaps_list, - missed_snaps) { - list_for_each_entry (snap_opinfo, - &missed_snapinfo->snap_ops, - snap_ops_list) { + cds_list_for_each_entry (missed_snapinfo, &priv->missed_snaps_list, + missed_snaps) { + cds_list_for_each_entry (snap_opinfo, + &missed_snapinfo->snap_ops, + snap_ops_list) { snprintf (key, sizeof(key), "%s:%s", missed_snapinfo->node_uuid, missed_snapinfo->snap_uuid); @@ -3911,7 +3913,8 @@ glusterd_store_peer_write (int fd, glusterd_peerinfo_t *peerinfo) if (ret) goto out; - list_for_each_entry (hostname, &peerinfo->hostnames, hostname_list) { + cds_list_for_each_entry (hostname, &peerinfo->hostnames, + hostname_list) { ret = gf_asprintf (&key, GLUSTERD_STORE_KEY_PEER_HOSTNAME"%d", i); if (ret < 0) @@ -4074,8 +4077,9 @@ glusterd_store_retrieve_peers (xlator_t *this) /* Set first hostname from peerinfo->hostnames to * peerinfo->hostname */ - address = list_entry (peerinfo->hostnames.next, - glusterd_peer_hostname_t, hostname_list); + address = cds_list_entry (peerinfo->hostnames.next, + glusterd_peer_hostname_t, + hostname_list); if (!address) { ret = -1; goto out; @@ -4092,7 +4096,7 @@ glusterd_store_retrieve_peers (xlator_t *this) } args.mode = GD_MODE_ON; - list_for_each_entry (peerinfo, &priv->peers, uuid_list) { + cds_list_for_each_entry (peerinfo, &priv->peers, uuid_list) { ret = glusterd_friend_rpc_create (this, peerinfo, &args); if (ret) goto out; @@ -4128,7 +4132,7 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this) GF_ASSERT (priv); /* Recreate bricks of volumes restored from snaps */ - list_for_each_entry (volinfo, &priv->volumes, vol_list) { + cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) { /* If the volume is not a restored volume then continue */ if (uuid_is_null (volinfo->restored_from_snap)) continue; @@ -4143,8 +4147,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this) } /* Recreate bricks of snapshot volumes */ - list_for_each_entry (snap, &priv->snapshots, snap_list) { - list_for_each_entry (volinfo, &snap->volumes, vol_list) { + cds_list_for_each_entry (snap, &priv->snapshots, snap_list) { + cds_list_for_each_entry (volinfo, &snap->volumes, vol_list) { ret = glusterd_recreate_vol_brick_mounts (this, volinfo); if (ret) { @@ -4195,7 +4199,8 @@ glusterd_snap_cleanup (xlator_t *this) goto out; } - list_for_each_entry_safe (snap, tmp_snap, &priv->snapshots, snap_list) { + cds_list_for_each_entry_safe (snap, tmp_snap, &priv->snapshots, + snap_list) { if (snap->snap_status == GD_SNAP_STATUS_RESTORED) { ret = glusterd_snapshot_revert_restore_from_snap (snap); if (ret) { @@ -4238,8 +4243,9 @@ glusterd_resolve_all_bricks (xlator_t *this) GF_ASSERT (priv); /* Resolve bricks of volumes */ - 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 = glusterd_resolve_brick (brickinfo); if (ret) { gf_log ("glusterd", GF_LOG_ERROR, @@ -4250,7 +4256,7 @@ glusterd_resolve_all_bricks (xlator_t *this) } /* Resolve bricks of snapshot volumes */ - list_for_each_entry (snap, &priv->snapshots, snap_list) { + cds_list_for_each_entry (snap, &priv->snapshots, snap_list) { ret = glusterd_resolve_snap_bricks (this, snap); if (ret) { gf_log (this->name, GF_LOG_ERROR, |