diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2011-09-20 09:49:57 -0400 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-11-20 07:34:31 -0800 |
commit | 76d5e5d5b51eb2ffe5a0608bf8869650bb76585f (patch) | |
tree | d349474b5f4eebe00973c05df29b9ebf5715d889 /xlators/cluster/afr/src/afr.h | |
parent | e6a3902410aaa8756e9c07302d88399fb99641c7 (diff) |
Add quorum checks to avoid split-brain.
Change-Id: I2f123ef93989862aa796903a45682981d5d7fc3c
BUG: 3533
Reviewed-on: http://review.gluster.com/473
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr.h')
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index e1f13b37655..0677b96e9fe 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__ */ |