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.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 02b2ba923e..c358e9f6d0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3421,7 +3421,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)
+ int *quorum_count,
+ gf_boolean_t _xaction_peers)
{
glusterd_peerinfo_t *peerinfo = NULL;
glusterd_conf_t *conf = NULL;
@@ -3431,21 +3432,26 @@ 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;
- list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
- if (peerinfo->quorum_contrib == QUORUM_WAITING)
- goto out;
- if (_is_contributing_to_quorum (peerinfo->quorum_contrib))
- inquorum_count = inquorum_count + 1;
+ peer_list = (_xaction_peers) ? &conf->xaction_peers : &conf->peers;
- if (active_count && (peerinfo->quorum_contrib == QUORUM_UP))
- *active_count = *active_count + 1;
+ if (_xaction_peers) {
+ list_for_each_entry (peerinfo, peer_list, op_peers_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);
+ }
}
ret = dict_get_str (conf->opts, GLUSTERD_QUORUM_RATIO_KEY, &val);
@@ -3501,7 +3507,7 @@ glusterd_is_any_volume_in_server_quorum (xlator_t *this)
}
gf_boolean_t
-does_gd_meet_server_quorum (xlator_t *this)
+does_gd_meet_server_quorum (xlator_t *this, gf_boolean_t _xaction_peers)
{
int quorum_count = 0;
int active_count = 0;
@@ -3511,7 +3517,8 @@ does_gd_meet_server_quorum (xlator_t *this)
conf = this->private;
ret = glusterd_get_quorum_cluster_counts (this, &active_count,
- &quorum_count);
+ &quorum_count,
+ _xaction_peers);
if (ret)
goto out;
@@ -3627,7 +3634,8 @@ glusterd_do_quorum_action ()
{
ret = glusterd_get_quorum_cluster_counts (this, &active_count,
- &quorum_count);
+ &quorum_count,
+ _gf_false);
if (ret)
goto unlock;
@@ -12971,7 +12979,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)) {
+ if (!does_gd_meet_server_quorum (this,_gf_true)) {
snprintf (err_str, sizeof (err_str),
"glusterds are not in quorum");
gf_log (this->name, GF_LOG_WARNING, "%s",
@@ -13130,7 +13138,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)) {
+ if (!does_gd_meet_server_quorum (this, _gf_true)) {
ret = -1;
snprintf (err_str, sizeof (err_str),
"glusterds are not in quorum");