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