|
|
a3470f |
From aed804b0f10c93ade88e109dd89a5b593ff1b1e5 Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Ravishankar N <ravishankar@redhat.com>
|
|
|
a3470f |
Date: Fri, 18 May 2018 15:38:29 +0530
|
|
|
a3470f |
Subject: [PATCH 275/282] afr: fix bug-1363721.t failure
|
|
|
a3470f |
|
|
|
a3470f |
Backport of https://review.gluster.org/#/c/20036/
|
|
|
a3470f |
|
|
|
a3470f |
Problem:
|
|
|
a3470f |
In the .t, when the only good brick was brought down, writes on the fd were
|
|
|
a3470f |
still succeeding on the bad bricks. The inflight split-brain check was
|
|
|
a3470f |
marking the write as failure but since the write succeeded on all the
|
|
|
a3470f |
bad bricks, afr_txn_nothing_failed() was set to true and we were
|
|
|
a3470f |
unwinding writev with success to DHT and then catching the failure in
|
|
|
a3470f |
post-op in the background.
|
|
|
a3470f |
|
|
|
a3470f |
Fix:
|
|
|
a3470f |
Don't wind the FOP phase if the write_subvol (which is populated with readable
|
|
|
a3470f |
subvols obtained in pre-op cbk) does not have at least 1 good brick which was up
|
|
|
a3470f |
when the transaction started.
|
|
|
a3470f |
|
|
|
a3470f |
Note: This fix is not related to brick muliplexing. I ran the .t
|
|
|
a3470f |
10 times with this fix and brick-mux enabled without any failures.
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: I915c9c366aa32cd342b1565827ca2d83cb02ae85
|
|
|
a3470f |
BUG: 1581057
|
|
|
a3470f |
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/139440
|
|
|
a3470f |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
a3470f |
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
tests/bugs/replicate/bug-1363721.t | 12 +++++++---
|
|
|
a3470f |
xlators/cluster/afr/src/afr-common.c | 14 ++++++++++++
|
|
|
a3470f |
xlators/cluster/afr/src/afr-transaction.c | 38 +++++++++++++++++++++++++++++++
|
|
|
a3470f |
xlators/cluster/afr/src/afr.h | 3 +++
|
|
|
a3470f |
4 files changed, 64 insertions(+), 3 deletions(-)
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/tests/bugs/replicate/bug-1363721.t b/tests/bugs/replicate/bug-1363721.t
|
|
|
a3470f |
index ec39889..0ed34d8 100644
|
|
|
a3470f |
--- a/tests/bugs/replicate/bug-1363721.t
|
|
|
a3470f |
+++ b/tests/bugs/replicate/bug-1363721.t
|
|
|
a3470f |
@@ -18,6 +18,10 @@ function size_increased {
|
|
|
a3470f |
fi
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+function has_write_failed {
|
|
|
a3470f |
+ local pid=$1
|
|
|
a3470f |
+ if [ -d /proc/$pid ]; then echo "N"; else echo "Y"; fi
|
|
|
a3470f |
+}
|
|
|
a3470f |
TEST glusterd
|
|
|
a3470f |
TEST pidof glusterd
|
|
|
a3470f |
TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
|
|
|
a3470f |
@@ -27,7 +31,7 @@ TEST $CLI volume set $V0 cluster.data-self-heal off
|
|
|
a3470f |
TEST $CLI volume set $V0 cluster.metadata-self-heal off
|
|
|
a3470f |
TEST $CLI volume set $V0 cluster.entry-self-heal off
|
|
|
a3470f |
TEST $CLI volume start $V0
|
|
|
a3470f |
-TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0 --direct-io-mode=enable
|
|
|
a3470f |
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 --direct-io-mode=enable $M0
|
|
|
a3470f |
|
|
|
a3470f |
cd $M0
|
|
|
a3470f |
|
|
|
a3470f |
@@ -67,8 +71,10 @@ sleep 3
|
|
|
a3470f |
# Now kill the second brick
|
|
|
a3470f |
kill_brick $V0 $H0 $B0/${V0}2
|
|
|
a3470f |
|
|
|
a3470f |
-# At this point the write should have been failed. But make sure that the second
|
|
|
a3470f |
-# brick is never an accused.
|
|
|
a3470f |
+# At this point the write should have been failed.
|
|
|
a3470f |
+EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT "Y" has_write_failed $dd_pid
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Also make sure that the second brick is never an accused.
|
|
|
a3470f |
|
|
|
a3470f |
md5sum_2=$(md5sum $B0/${V0}2/file1 | awk '{print $1}')
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
|
|
|
a3470f |
index 6025a60..a85549b 100644
|
|
|
a3470f |
--- a/xlators/cluster/afr/src/afr-common.c
|
|
|
a3470f |
+++ b/xlators/cluster/afr/src/afr-common.c
|
|
|
a3470f |
@@ -6270,6 +6270,20 @@ out:
|
|
|
a3470f |
return ret;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+uint64_t
|
|
|
a3470f |
+afr_write_subvol_get (call_frame_t *frame, xlator_t *this)
|
|
|
a3470f |
+{
|
|
|
a3470f |
+ afr_local_t *local = NULL;
|
|
|
a3470f |
+ uint64_t write_subvol = 0;
|
|
|
a3470f |
+
|
|
|
a3470f |
+ local = frame->local;
|
|
|
a3470f |
+ LOCK(&local->inode->lock);
|
|
|
a3470f |
+ write_subvol = local->inode_ctx->write_subvol;
|
|
|
a3470f |
+ UNLOCK (&local->inode->lock);
|
|
|
a3470f |
+
|
|
|
a3470f |
+ return write_subvol;
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
int
|
|
|
a3470f |
afr_write_subvol_set (call_frame_t *frame, xlator_t *this)
|
|
|
a3470f |
{
|
|
|
a3470f |
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
a3470f |
index 0506a78..ff07319 100644
|
|
|
a3470f |
--- a/xlators/cluster/afr/src/afr-transaction.c
|
|
|
a3470f |
+++ b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
a3470f |
@@ -167,6 +167,34 @@ afr_changelog_has_quorum (afr_local_t *local, xlator_t *this)
|
|
|
a3470f |
return _gf_false;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+
|
|
|
a3470f |
+gf_boolean_t
|
|
|
a3470f |
+afr_is_write_subvol_valid (call_frame_t *frame, xlator_t *this)
|
|
|
a3470f |
+{
|
|
|
a3470f |
+ int i = 0;
|
|
|
a3470f |
+ afr_local_t *local = NULL;
|
|
|
a3470f |
+ afr_private_t *priv = NULL;
|
|
|
a3470f |
+ uint64_t write_subvol = 0;
|
|
|
a3470f |
+ unsigned char *writable = NULL;
|
|
|
a3470f |
+ uint16_t datamap = 0;
|
|
|
a3470f |
+
|
|
|
a3470f |
+ local = frame->local;
|
|
|
a3470f |
+ priv = this->private;
|
|
|
a3470f |
+ writable = alloca0 (priv->child_count);
|
|
|
a3470f |
+
|
|
|
a3470f |
+ write_subvol = afr_write_subvol_get (frame, this);
|
|
|
a3470f |
+ datamap = (write_subvol & 0x00000000ffff0000) >> 16;
|
|
|
a3470f |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
a3470f |
+ if (datamap & (1 << i))
|
|
|
a3470f |
+ writable[i] = 1;
|
|
|
a3470f |
+
|
|
|
a3470f |
+ if (writable[i] && !local->transaction.failed_subvols[i])
|
|
|
a3470f |
+ return _gf_true;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
+ return _gf_false;
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
int
|
|
|
a3470f |
afr_transaction_fop (call_frame_t *frame, xlator_t *this)
|
|
|
a3470f |
{
|
|
|
a3470f |
@@ -189,6 +217,16 @@ afr_transaction_fop (call_frame_t *frame, xlator_t *this)
|
|
|
a3470f |
afr_transaction_resume (frame, this);
|
|
|
a3470f |
return 0;
|
|
|
a3470f |
}
|
|
|
a3470f |
+
|
|
|
a3470f |
+ /* Fail if at least one writeable brick isn't up.*/
|
|
|
a3470f |
+ if (local->transaction.type == AFR_DATA_TRANSACTION &&
|
|
|
a3470f |
+ !afr_is_write_subvol_valid (frame, this)) {
|
|
|
a3470f |
+ local->op_ret = -1;
|
|
|
a3470f |
+ local->op_errno = EIO;
|
|
|
a3470f |
+ afr_transaction_resume (frame, this);
|
|
|
a3470f |
+ return 0;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
local->call_count = call_count;
|
|
|
a3470f |
for (i = 0; i < priv->child_count; i++) {
|
|
|
a3470f |
if (local->transaction.pre_op[i] && !failed_subvols[i]) {
|
|
|
a3470f |
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
|
|
|
a3470f |
index 6be59dc..35928a9 100644
|
|
|
a3470f |
--- a/xlators/cluster/afr/src/afr.h
|
|
|
a3470f |
+++ b/xlators/cluster/afr/src/afr.h
|
|
|
a3470f |
@@ -1199,6 +1199,9 @@ afr_serialize_xattrs_with_delimiter (call_frame_t *frame, xlator_t *this,
|
|
|
a3470f |
int
|
|
|
a3470f |
__afr_inode_ctx_get (xlator_t *this, inode_t *inode, afr_inode_ctx_t **ctx);
|
|
|
a3470f |
|
|
|
a3470f |
+uint64_t
|
|
|
a3470f |
+afr_write_subvol_get (call_frame_t *frame, xlator_t *this);
|
|
|
a3470f |
+
|
|
|
a3470f |
int
|
|
|
a3470f |
afr_write_subvol_set (call_frame_t *frame, xlator_t *this);
|
|
|
a3470f |
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|