summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2012-11-15 23:07:24 +0530
committerAnand Avati <avati@redhat.com>2013-01-18 13:20:52 -0800
commita2b85d13e50327da721e32071aecad21b10ffb1a (patch)
tree81a1f9caf54e550dbb80b13a6e2aae5d28204b77 /xlators/cluster/afr/src
parentba16dc622a4ffc24baf7c2cde1210be7bf9fa019 (diff)
cluster/afr: Fail readv on data-split-brain
Problem: Afr prevents opens on a file in split-brian but the fd that is already open still has the capability to perform both reads and writes to the file. Fix: Fail readvs on a file with EIO. Change-Id: I8e07f24c36fab800499b36ab374f984b743332cd BUG: 873962 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/4199 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src')
-rw-r--r--xlators/cluster/afr/src/afr-common.c15
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c5
-rw-r--r--xlators/cluster/afr/src/afr.h3
3 files changed, 23 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 97303d1065b..dbd64cb246b 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -325,6 +325,21 @@ out:
}
gf_boolean_t
+afr_is_data_split_brain (xlator_t *this, inode_t *inode)
+{
+ afr_inode_ctx_t *ctx = NULL;
+ gf_boolean_t spb = _gf_false;
+
+ ctx = afr_inode_ctx_get (inode, this);
+ if (!ctx)
+ goto out;
+ if (ctx->data_spb == SPB)
+ spb = _gf_true;
+out:
+ return spb;
+}
+
+gf_boolean_t
afr_is_opendir_done (xlator_t *this, inode_t *inode)
{
afr_inode_params_t params = {0};
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 1b3f7405115..40d57b6f9da 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1813,6 +1813,11 @@ afr_readv (call_frame_t *frame, xlator_t *this,
priv = this->private;
children = priv->children;
+ if (afr_is_data_split_brain (this, fd->inode)) {
+ op_errno = EIO;
+ goto out;
+ }
+
AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out);
local = frame->local;
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 85b4b6831b8..a9c06370445 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -836,6 +836,9 @@ afr_frame_return (call_frame_t *frame);
gf_boolean_t
afr_is_split_brain (xlator_t *this, inode_t *inode);
+gf_boolean_t
+afr_is_data_split_brain (xlator_t *this, inode_t *inode);
+
void
afr_set_split_brain (xlator_t *this, inode_t *inode, afr_spb_state_t mdata_spb,
afr_spb_state_t data_spb);