diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 29 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-peer-utils.h | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 6 |
3 files changed, 38 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c index 607ad3d38be..4131296ef12 100644 --- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c @@ -394,6 +394,35 @@ gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo) } gf_boolean_t +glusterd_are_all_peers_up () +{ + glusterd_peerinfo_t *peerinfo = NULL; + xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; + gf_boolean_t peers_up = _gf_false; + + this = THIS; + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + + conf = this->private; + GF_VALIDATE_OR_GOTO (this->name, conf, out); + + rcu_read_lock (); + cds_list_for_each_entry_rcu (peerinfo, &conf->peers, uuid_list) { + if (!peerinfo->connected) { + rcu_read_unlock (); + goto out; + } + } + rcu_read_unlock (); + + peers_up = _gf_true; + +out: + return peers_up; +} + +gf_boolean_t glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo, struct cds_list_head *peers, char **down_peerstr) diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h index bd30e335f69..9332cf2ea02 100644 --- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h @@ -43,6 +43,9 @@ char* gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo); gf_boolean_t +glusterd_are_all_peers_up (); + +gf_boolean_t glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo, struct cds_list_head *peers, char **down_peerstr); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 7b833a9a737..60577505cfc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -1781,6 +1781,12 @@ glusterd_op_stage_delete_volume (dict_t *dict, char **op_errstr) goto out; } + if (!glusterd_are_all_peers_up ()) { + ret = -1; + snprintf (msg, sizeof(msg), "Some of the peers are down"); + goto out; + } + ret = 0; out: |