From 25e8e74eb7b81ccd114a9833371a3f72d284c48d Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Wed, 15 Apr 2015 22:22:08 +0530 Subject: afr: add arbitration support Add logic in afr to work in conjunction with the arbiter xlator when a replica 3 arbiter volume is created. More specifically, this patch: * Enables full locks for afr data transaction for such volumes. * Removes the upfront marking of pending xattrs at the time of pre-op and defer it to post-op. (This is an arbiter independent change and is made for all afr transactions.) * After pre-op stage, check if we can proceed with the fop stage without ending up in split-brain by examining the changelog xattrs. * Unwinds the fop with failure if only one source was available at the time of pre-op and the fop happened to fail on particular source brick. * Skips data self-heal if arbiter brick is the only source available. * Adds the arbiter-count option to the shd graph. This patch is a part of the arbiter logic implementation for 3 way AFR details of which can be found at http://review.gluster.org/#/c/9656/ Change-Id: I9603db9d04de5626eb2f4d8d959ef5b46113561d BUG: 1199985 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/10258 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-inode-write.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/afr/src/afr-inode-write.c') diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c index f712166e44d..f9fde44e9e4 100644 --- a/xlators/cluster/afr/src/afr-inode-write.c +++ b/xlators/cluster/afr/src/afr-inode-write.c @@ -37,7 +37,7 @@ #include "protocol-common.h" #include "afr-transaction.h" - +#include "afr-self-heal.h" static void __afr_inode_write_finalize (call_frame_t *frame, xlator_t *this) @@ -97,6 +97,8 @@ __afr_inode_write_finalize (call_frame_t *frame, xlator_t *this) } } } + + afr_txn_arbitrate_fop_cbk (frame, this); } @@ -342,6 +344,7 @@ afr_do_writev (call_frame_t *frame, xlator_t *this) { call_frame_t *transaction_frame = NULL; afr_local_t *local = NULL; + afr_private_t *priv = NULL; int ret = -1; int op_errno = ENOMEM; @@ -350,6 +353,7 @@ afr_do_writev (call_frame_t *frame, xlator_t *this) goto out; local = frame->local; + priv = this->private; transaction_frame->local = local; frame->local = NULL; @@ -379,6 +383,12 @@ afr_do_writev (call_frame_t *frame, xlator_t *this) local->transaction.start = local->cont.writev.offset; local->transaction.len = iov_length (local->cont.writev.vector, local->cont.writev.count); + + /*Lock entire file to avoid network split brains.*/ + if (priv->arbiter_count == 1) { + local->transaction.start = 0; + local->transaction.len = 0; + } } ret = afr_transaction (transaction_frame, this, AFR_DATA_TRANSACTION); -- cgit