From e304d218602f3099dc4ba9bb86fd953cee8a8e59 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 4 Sep 2017 16:57:25 +0530 Subject: cluster/afr: Fail open on split-brain Problem: Append on a file with split-brain succeeds. Open is intercepted by open-behind, when write comes on the file, open-behind does open+write. Open succeeds because afr doesn't fail it. Then write succeeds because write-behind intercepts it. Flush is also intercepted by write-behind, so the application never gets to know that the write failed. Fix: Fail open on split-brain, so that when open-behind does open+write open fails which leads to write failure. Application will know about this failure. Change-Id: I4bff1c747c97bb2925d6987f4ced5f1ce75dbc15 BUG: 1544635 Signed-off-by: Pranith Kumar K (cherry picked from commit 786343abca3474ff01aa1017210112d97cbc4843) --- xlators/cluster/afr/src/afr-self-heal-common.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'xlators/cluster/afr/src/afr-self-heal-common.c') diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 20e81dd43e0..26d3860b234 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -66,9 +66,9 @@ afr_lookup_and_heal_gfid (xlator_t *this, inode_t *parent, const char *name, goto out; } - frame = afr_frame_create (this); + frame = afr_frame_create (this, &ret); if (!frame) { - ret = -ENOMEM; + ret = -ret; goto out; } @@ -2349,18 +2349,17 @@ afr_inode_find (xlator_t *this, uuid_t gfid) call_frame_t * -afr_frame_create (xlator_t *this) +afr_frame_create (xlator_t *this, int32_t *op_errno) { call_frame_t *frame = NULL; afr_local_t *local = NULL; - int op_errno = 0; pid_t pid = GF_CLIENT_PID_SELF_HEALD; frame = create_frame (this, this->ctx->pool); if (!frame) return NULL; - local = AFR_FRAME_INIT (frame, op_errno); + local = AFR_FRAME_INIT (frame, (*op_errno)); if (!local) { STACK_DESTROY (frame->root); return NULL; @@ -2490,7 +2489,7 @@ afr_selfheal (xlator_t *this, uuid_t gfid) call_frame_t *frame = NULL; afr_local_t *local = NULL; - frame = afr_frame_create (this); + frame = afr_frame_create (this, NULL); if (!frame) return ret; -- cgit