diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2014-12-26 12:18:31 +0530 |
---|---|---|
committer | Kaushal M <kaushal@redhat.com> | 2015-01-06 05:44:38 -0800 |
commit | 6e2318f0821d7c58eddc837b2d218247243a5c8d (patch) | |
tree | edb45148107c26164aaa55a04e98fdd18a783845 /xlators/mgmt/glusterd/src | |
parent | 64954eb3c58f4ef077e54e8a3726fd2d27419b12 (diff) |
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 <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/9350
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 48 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 13 |
5 files changed, 50 insertions, 27 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 463de91440d..0f2c2751883 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -1005,7 +1005,7 @@ __glusterd_handle_cli_probe (rpcsvc_request_t *req) } if (glusterd_is_any_volume_in_server_quorum (this) && - !does_gd_meet_server_quorum (this, _gf_false)) { + !does_gd_meet_server_quorum (this, NULL, _gf_false)) { glusterd_xfer_cli_probe_resp (req, -1, GF_PROBE_QUORUM_NOT_MET, NULL, hostname, port, dict); gf_msg (this->name, GF_LOG_CRITICAL, 0, @@ -1171,7 +1171,7 @@ __glusterd_handle_cli_deprobe (rpcsvc_request_t *req) if (!(flags & GF_CLI_FLAG_OP_FORCE)) { if (glusterd_is_any_volume_in_server_quorum (this) && - !does_gd_meet_server_quorum (this, _gf_false)) { + !does_gd_meet_server_quorum (this, NULL, _gf_false)) { gf_msg (this->name, GF_LOG_CRITICAL, 0, GD_MSG_SERVER_QUORUM_NOT_MET, "Server quorum not met. Rejecting operation."); diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 0cdaaaeda9a..0853bd9b4bb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -1856,7 +1856,8 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, } /* quorum check of the volume is done here */ - ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr); + ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr, + &xaction_peers); if (ret) { gf_log (this->name, GF_LOG_WARNING, "Volume quorum check failed"); @@ -1941,7 +1942,8 @@ unbarrier: /*Do a quorum check if the commit phase is successful*/ if (success) { //quorum check of the snapshot volume - ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr); + ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr, + &xaction_peers); if (ret) { gf_log (this->name, GF_LOG_WARNING, "Snapshot Volume quorum check failed"); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 3f8de08a577..a0cf87598fa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3462,8 +3462,11 @@ glusterd_op_validate_quorum (xlator_t *this, glusterd_op_t op, int ret = 0; char *volname = NULL; glusterd_volinfo_t *volinfo = NULL; + glusterd_conf_t *conf = NULL; char *errstr = NULL; + conf = this->private; + GF_ASSERT (conf); errstr = "Quorum not met. Volume operation not allowed."; if (!glusterd_is_op_quorum_validation_required (this, op, dict)) @@ -3481,7 +3484,8 @@ glusterd_op_validate_quorum (xlator_t *this, glusterd_op_t op, goto out; } - if (does_gd_meet_server_quorum (this, _gf_false)) { + if (does_gd_meet_server_quorum (this, &conf->xaction_peers, + _gf_false)) { ret = 0; goto out; } 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"); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 511d36d5294..78a44fda6c7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -566,7 +566,8 @@ glusterd_do_quorum_action (); 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); int glusterd_get_next_global_opt_version_str (dict_t *opts, char **version_str); @@ -577,7 +578,9 @@ glusterd_is_volume_in_server_quorum (glusterd_volinfo_t *volinfo); gf_boolean_t 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 glusterd_generate_and_set_task_id (dict_t *dict, char *key); @@ -785,11 +788,13 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo, 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 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); int32_t glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index, |