summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2015-06-10 18:34:52 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2015-06-15 09:28:59 -0700
commit83778a592f75ef18ce5e22e14adc9bf118705a17 (patch)
tree7f0961fe22446f20b78514f08814d8c9cd239133
parentfecebde3fbae17ace970a4d9c440f6455161dc62 (diff)
afr: allow readdir to proceed for directories in split-brainv3.6.4beta2
Problem: afr_read_txn() bails out if read_subvol==-1. This meant that for directories that were in entry split-brain, FOPS like readdir, access, stat etc were not allowed. Fix: Except for getxattr, all other FOPS are wound on the first up child of afr. Change-Id: Iacec8fbb1e75c4d2094baa304f62331c81a6f670 BUG: 1230242 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/10776 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Reviewed-by: Anuradha Talur <atalur@redhat.com> (cherry picked from commit 49b428433a03fcf709fdc8c08603b4cf02198e0a) Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/11162 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--tests/bugs/replicate/bug-1221481-allow-fops-on-dir-split-brain.t37
-rw-r--r--xlators/cluster/afr/src/afr-read-txn.c40
2 files changed, 59 insertions, 18 deletions
diff --git a/tests/bugs/replicate/bug-1221481-allow-fops-on-dir-split-brain.t b/tests/bugs/replicate/bug-1221481-allow-fops-on-dir-split-brain.t
new file mode 100644
index 00000000000..cd4a9bad87b
--- /dev/null
+++ b/tests/bugs/replicate/bug-1221481-allow-fops-on-dir-split-brain.t
@@ -0,0 +1,37 @@
+#!/bin/bash
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../afr.rc
+cleanup;
+
+#Allow readdirs to proceed on directories that are in split-brain
+
+TEST glusterd;
+TEST pidof glusterd;
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1};
+TEST $CLI volume set $V0 cluster.self-heal-daemon off
+TEST $CLI volume start $V0;
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0
+TEST mkdir $M0/dir
+TEST touch $M0/dir/file{1..5}
+
+#Create metadata and entry split-brain
+TEST kill_brick $V0 $H0 $B0/$V0"1"
+TEST setfattr -n user.attribute -v value1 $M0/dir
+TEST touch $M0/dir/FILE
+TEST $CLI volume start $V0 force
+EXPECT_WITHIN $CHILD_UP_TIMEOUT '1' afr_child_up_status_meta $M0 $V0-replicate-0 1
+TEST kill_brick $V0 $H0 $B0/$V0"0"
+TEST setfattr -n user.attribute -v value2 $M0/dir
+TEST touch $M0/dir/FILE
+TEST $CLI volume start $V0 force
+EXPECT_WITHIN $CHILD_UP_TIMEOUT '1' afr_child_up_status_meta $M0 $V0-replicate-0 0
+
+TEST ! getfattr $M0/dir
+cd $M0/dir
+EXPECT "6" echo $(ls | wc -l)
+TEST ! cat FILE
+TEST `echo hello>hello.txt`
+cd -
+TEST umount $M0
+cleanup
diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c
index 29a926dbd97..f19c91230e7 100644
--- a/xlators/cluster/afr/src/afr-read-txn.c
+++ b/xlators/cluster/afr/src/afr-read-txn.c
@@ -47,11 +47,19 @@ afr_read_txn_next_subvol (call_frame_t *frame, xlator_t *this)
return 0;
}
+#define AFR_READ_TXN_SET_ERROR_AND_GOTO(ret, errnum, index, label) \
+ do { \
+ local->op_ret = ret; \
+ local->op_errno = errnum; \
+ read_subvol = index; \
+ goto label; \
+ } while (0)
int
afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err)
{
afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
int read_subvol = 0;
int event_generation = 0;
inode_t *inode = NULL;
@@ -59,35 +67,31 @@ afr_read_txn_refresh_done (call_frame_t *frame, xlator_t *this, int err)
local = frame->local;
inode = local->inode;
+ priv = frame->this->private;
- if (err) {
- local->op_errno = -err;
- local->op_ret = -1;
- read_subvol = -1;
- goto readfn;
- }
+ if (err)
+ AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, -err, -1, readfn);
ret = afr_inode_read_subvol_type_get (inode, this, local->readable,
&event_generation,
local->transaction.type);
- if (ret == -1 || !event_generation) {
+ if (ret == -1 || !event_generation)
/* Even after refresh, we don't have a good
read subvolume. Time to bail */
- local->op_ret = -1;
- local->op_errno = EIO;
- read_subvol = -1;
- goto readfn;
- }
+ AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, EIO, -1, readfn);
+
+ /* For directories in split-brain, we need to allow all fops
+ * except (f)getxattr and access. */
+ if (!AFR_COUNT(local->readable, priv->child_count) &&
+ local->transaction.type == AFR_DATA_TRANSACTION &&
+ inode->ia_type == IA_IFDIR)
+ memcpy (local->readable, local->child_up, priv->child_count);
read_subvol = afr_read_subvol_select_by_policy (inode, this,
local->readable);
-
- if (read_subvol == -1) {
- local->op_ret = -1;
- local->op_errno = EIO;
- goto readfn;
- }
+ if (read_subvol == -1)
+ AFR_READ_TXN_SET_ERROR_AND_GOTO (-1, EIO, -1, readfn);
if (local->read_attempted[read_subvol]) {
afr_read_txn_next_subvol (frame, this);