diff options
| author | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-01-27 16:44:20 +0530 | 
|---|---|---|
| committer | Kaushal M <kaushal@redhat.com> | 2015-04-02 10:58:13 -0700 | 
| commit | f66a85a484d41e68611f68d70e458c67f484d2e1 (patch) | |
| tree | 6c0f9d051c987814b1c5e034f094a97a8c9c2e13 /xlators/mgmt/glusterd/src/glusterd-server-quorum.c | |
| parent | 08d35497e30714058002b4b0095171f1dad73ddc (diff) | |
glusterd: compute quorum on peers in cluster
... and not on peers participating in an ongoing
transaction.
Change-Id: I6bdb80fd3bf3e7593fdf37e45a441d4a490469b8
BUG: 1205592
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/9493
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-server-quorum.c')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-server-quorum.c | 55 | 
1 files changed, 19 insertions, 36 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c index 6178f273629..8d8acb17513 100644 --- a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c +++ b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c @@ -79,8 +79,6 @@ out:          return required;  } -/* This function should not be used when the quorum validation needs to happen - * on non-global peer list */  int  glusterd_validate_quorum (xlator_t *this, glusterd_op_t op,                               dict_t *dict, char **op_errstr) @@ -106,9 +104,7 @@ glusterd_validate_quorum (xlator_t *this, glusterd_op_t op,                  goto out;          } -        /* Passing NULL implies quorum calculation will happen on global peer -         * list */ -        if (does_gd_meet_server_quorum (this, NULL, _gf_false)) { +        if (does_gd_meet_server_quorum (this)) {                  ret = 0;                  goto out;          } @@ -128,8 +124,9 @@ glusterd_is_quorum_option (char *option)  {          gf_boolean_t    res     = _gf_false;          int             i       = 0; -        char            *keys[] = {GLUSTERD_QUORUM_TYPE_KEY, -                                   GLUSTERD_QUORUM_RATIO_KEY, NULL}; +        static const char * const keys[] = {GLUSTERD_QUORUM_TYPE_KEY, +                                            GLUSTERD_QUORUM_RATIO_KEY, +                                            NULL};          for (i = 0; keys[i]; i++) {                  if (strcmp (option, keys[i]) == 0) { @@ -200,9 +197,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 cds_list_head *peer_list, -                                    gf_boolean_t _local_xaction_peers) +                                    int *quorum_count)  {          glusterd_peerinfo_t *peerinfo      = NULL;          glusterd_conf_t     *conf          = NULL; @@ -221,26 +216,19 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count,                  *active_count = 1;          rcu_read_lock (); -        if (!peer_list) { -                cds_list_for_each_entry (peerinfo, &conf->peers, uuid_list) { -                        GLUSTERD_QUORUM_COUNT (peerinfo, inquorum_count, -                                               active_count, out); -                } -        } else { -                if (_local_xaction_peers) { -                        list_for_each_local_xaction_peers (peerinfo, -                                                           peer_list) { -                                GLUSTERD_QUORUM_COUNT (peerinfo, inquorum_count, -                                                       active_count, out); -                        } -                } else { -                        cds_list_for_each_entry (peerinfo, peer_list, -                                                 op_peers_list) { -                                GLUSTERD_QUORUM_COUNT (peerinfo, inquorum_count, -                                                       active_count, out); -                        } +        cds_list_for_each_entry_rcu (peerinfo, &conf->peers, uuid_list) { +                if (peerinfo->quorum_contrib == QUORUM_WAITING) { +                        rcu_read_unlock (); +                        goto out;                  } + +                if (_is_contributing_to_quorum (peerinfo->quorum_contrib)) +                        inquorum_count = inquorum_count + 1; +                if (active_count && (peerinfo->quorum_contrib == QUORUM_UP)) +                        *active_count = *active_count + 1;          } +        rcu_read_unlock (); +          ret = dict_get_str (conf->opts, GLUSTERD_QUORUM_RATIO_KEY, &val);          if (ret == 0) {                  ratio = _gf_true; @@ -257,7 +245,6 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count,          *quorum_count = count;          ret = 0;  out: -        rcu_read_unlock ();          return ret;  } @@ -295,8 +282,7 @@ glusterd_is_any_volume_in_server_quorum (xlator_t *this)  }  gf_boolean_t -does_gd_meet_server_quorum (xlator_t *this, struct cds_list_head *peers_list, -                            gf_boolean_t _local_xaction_peers) +does_gd_meet_server_quorum (xlator_t *this)  {          int                     quorum_count    = 0;          int                     active_count    = 0; @@ -306,9 +292,7 @@ does_gd_meet_server_quorum (xlator_t *this, struct cds_list_head *peers_list,          conf = this->private;          ret = glusterd_get_quorum_cluster_counts (this, &active_count, -                                                  &quorum_count, -                                                  peers_list, -                                                  _local_xaction_peers); +                                                  &quorum_count);          if (ret)                  goto out; @@ -406,8 +390,7 @@ glusterd_do_quorum_action ()          {                  ret = glusterd_get_quorum_cluster_counts (this, &active_count, -                                                          &quorum_count, NULL, -                                                          _gf_false); +                                                          &quorum_count);                  if (ret)                          goto unlock;  | 
