From 76d5e5d5b51eb2ffe5a0608bf8869650bb76585f Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Tue, 20 Sep 2011 09:49:57 -0400 Subject: Add quorum checks to avoid split-brain. Change-Id: I2f123ef93989862aa796903a45682981d5d7fc3c BUG: 3533 Reviewed-on: http://review.gluster.com/473 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/afr/src/afr.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xlators/cluster/afr/src/afr.h') diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index e1f13b376..0677b96e9 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -146,6 +146,7 @@ typedef struct _afr_private { struct list_head saved_fds; /* list of fds on which locks have succeeded */ gf_boolean_t optimistic_change_log; gf_boolean_t eager_lock; + gf_boolean_t enforce_quorum; char vol_uuid[UUID_SIZE + 1]; int32_t *last_event; @@ -998,4 +999,21 @@ afr_set_low_priority (call_frame_t *frame); int afr_child_fd_ctx_set (xlator_t *this, fd_t *fd, int32_t child, int flags, int32_t wb_flags); + +gf_boolean_t +afr_have_quorum (char *logname, afr_private_t *priv); + +/* + * Having this as a macro will make debugging a bit weirder, but does reduce + * the probability of functions handling this check inconsistently. + */ +#define QUORUM_CHECK(_func,_label) do { \ + if (priv->enforce_quorum && !afr_have_quorum(this->name,priv)) { \ + gf_log(this->name,GF_LOG_WARNING, \ + "failing "#_func" due to lack of quorum"); \ + op_errno = EROFS; \ + goto _label; \ + } \ +} while (0); + #endif /* __AFR_H__ */ -- cgit