From 6e2318f0821d7c58eddc837b2d218247243a5c8d Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Fri, 26 Dec 2014 12:18:31 +0530 Subject: glusterd: cluster quorum count check correction Due to the recent change introduced by commit da9deb54df91dedc51ebe165f3a0be646455cb5b cluster quorum count calucation now depends on whether the peer list is either all peers or global transaction peer list or the local transaction peer list. Change-Id: I9f63af9a0cb3cfd6369b050247d0ef3ac93d760f BUG: 1173414 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/9350 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Raghavendra Bhat Reviewed-by: Avra Sengupta Reviewed-by: Kaushal M --- xlators/mgmt/glusterd/src/glusterd-utils.c | 48 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 787352e93f6..06ac43aaf4b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -3487,7 +3487,8 @@ _does_quorum_meet (int active_count, int quorum_count) int glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, int *quorum_count, - gf_boolean_t _xaction_peers) + struct list_head *peer_list, + gf_boolean_t _local_xaction_peers) { glusterd_peerinfo_t *peerinfo = NULL; glusterd_conf_t *conf = NULL; @@ -3497,28 +3498,34 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, double quorum_percentage = 0.0; gf_boolean_t ratio = _gf_false; int count = 0; - struct list_head *peer_list = NULL; conf = this->private; + //Start with counting self inquorum_count = 1; if (active_count) *active_count = 1; - peer_list = (_xaction_peers) ? &conf->xaction_peers : &conf->peers; - - if (_xaction_peers) { - list_for_each_entry (peerinfo, peer_list, op_peers_list) { + if (!peer_list) { + list_for_each_entry (peerinfo, &conf->peers, uuid_list) { glusterd_quorum_count(peerinfo, inquorum_count, active_count, out); } } else { - list_for_each_entry (peerinfo, peer_list, uuid_list) { - glusterd_quorum_count(peerinfo, inquorum_count, - active_count, out); + if (_local_xaction_peers) { + list_for_each_local_xaction_peers (peerinfo, + peer_list) { + glusterd_quorum_count(peerinfo, inquorum_count, + active_count, out); + } + } else { + list_for_each_entry (peerinfo, peer_list, + op_peers_list) { + glusterd_quorum_count(peerinfo, inquorum_count, + active_count, out); + } } } - ret = dict_get_str (conf->opts, GLUSTERD_QUORUM_RATIO_KEY, &val); if (ret == 0) { ratio = _gf_true; @@ -3572,7 +3579,8 @@ glusterd_is_any_volume_in_server_quorum (xlator_t *this) } gf_boolean_t -does_gd_meet_server_quorum (xlator_t *this, gf_boolean_t _xaction_peers) +does_gd_meet_server_quorum (xlator_t *this, struct list_head *peers_list, + gf_boolean_t _local_xaction_peers) { int quorum_count = 0; int active_count = 0; @@ -3583,7 +3591,8 @@ does_gd_meet_server_quorum (xlator_t *this, gf_boolean_t _xaction_peers) conf = this->private; ret = glusterd_get_quorum_cluster_counts (this, &active_count, &quorum_count, - _xaction_peers); + peers_list, + _local_xaction_peers); if (ret) goto out; @@ -3699,7 +3708,7 @@ glusterd_do_quorum_action () { ret = glusterd_get_quorum_cluster_counts (this, &active_count, - &quorum_count, + &quorum_count, NULL, _gf_false); if (ret) goto unlock; @@ -12808,7 +12817,8 @@ out: int32_t glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, - char **op_errstr) + char **op_errstr, + struct list_head *peers_list) { int8_t snap_force = 0; int32_t force = 0; @@ -12861,7 +12871,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume, by glusterd and if glusterds are not in quorum, then better fail the snapshot */ - if (!does_gd_meet_server_quorum (this,_gf_true)) { + if (!does_gd_meet_server_quorum (this, peers_list, _gf_true)) { snprintf (err_str, sizeof (err_str), "glusterds are not in quorum"); gf_log (this->name, GF_LOG_WARNING, "%s", @@ -13002,7 +13012,8 @@ out: int32_t glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, - char **op_errstr) + char **op_errstr, + struct list_head *peers_list) { int32_t ret = -1; xlator_t *this = NULL; @@ -13028,7 +13039,8 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, switch (snap_command) { case GF_SNAP_OPTION_TYPE_CREATE: ret = glusterd_snap_quorum_check_for_create (dict, snap_volume, - op_errstr); + op_errstr, + peers_list); if (ret) { gf_log (this->name, GF_LOG_WARNING, "Quorum check" "failed during snapshot create command"); @@ -13037,7 +13049,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, break; case GF_SNAP_OPTION_TYPE_DELETE: case GF_SNAP_OPTION_TYPE_RESTORE: - if (!does_gd_meet_server_quorum (this, _gf_true)) { + if (!does_gd_meet_server_quorum (this, peers_list, _gf_true)) { ret = -1; snprintf (err_str, sizeof (err_str), "glusterds are not in quorum"); -- cgit