summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-name.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-08-08 11:52:17 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2014-08-26 01:17:23 -0700
commitdc450ab5e3798b47e89e90b64c49cb8e1f20efce (patch)
treeed57707d0b7e5194bc828e16d95c020e294fba90 /xlators/cluster/afr/src/afr-self-heal-name.c
parent71095db8f40888f6afc604c896c296dbe988d292 (diff)
cluster/afr: Fix all locked_on bricks are sinks check in self-heals
Problem: Counts may give wrong results when the number of bricks is > 2. If the locks are acquired on one source and sink, but the source accuses even the down sink then there will be 2 sinks and lock is acquired on 2 bricks so even when there is a clear source and sink **_finalize_source functions think the file/directory is in split-brain. Fix: Check that all the bricks which are locked are sinks. Change-Id: Ia43790e8e1bfb5e72a3d0b56bcad94abd0dc58ab BUG: 1128721 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/8456 Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-name.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
index 151c401e3b1..f09eb0be6ba 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -263,23 +263,21 @@ __afr_selfheal_name_do (call_frame_t *frame, xlator_t *this, inode_t *parent,
int
__afr_selfheal_name_finalize_source (xlator_t *this, unsigned char *sources,
- unsigned char *sinks, unsigned char *locked_on,
+ unsigned char *healed_sinks,
+ unsigned char *locked_on,
struct afr_reply *replies)
{
int i = 0;
afr_private_t *priv = NULL;
int source = -1;
- int locked_count = 0;
int sources_count = 0;
- int sinks_count = 0;
priv = this->private;
- locked_count = AFR_COUNT (locked_on, priv->child_count);
sources_count = AFR_COUNT (sources, priv->child_count);
- sinks_count = AFR_COUNT (sinks, priv->child_count);
- if (locked_count == sinks_count || !sources_count) {
+ if ((AFR_CMP (locked_on, healed_sinks, priv->child_count) == 0)
+ || !sources_count) {
return -1;
}
@@ -304,7 +302,6 @@ __afr_selfheal_name_prepare (call_frame_t *frame, xlator_t *this, inode_t *paren
int ret = -1;
int source = -1;
afr_private_t *priv = NULL;
- int i = 0;
priv = this->private;
@@ -318,7 +315,18 @@ __afr_selfheal_name_prepare (call_frame_t *frame, xlator_t *this, inode_t *paren
if (ret)
return ret;
- source = __afr_selfheal_name_finalize_source (this, sources, sinks,
+ /* Initialize the healed_sinks[] array optimistically to
+ the intersection of to-be-healed (i.e sinks[]) and
+ the list of servers which are up (i.e locked_on[]).
+
+ As we encounter failures in the healing process, we
+ will unmark the respective servers in the healed_sinks[]
+ array.
+ */
+ AFR_INTERSECT (healed_sinks, sinks, locked_on, priv->child_count);
+
+ source = __afr_selfheal_name_finalize_source (this, sources,
+ healed_sinks,
locked_on, replies);
if (source < 0) {
/* If source is < 0 (typically split-brain), we perform a
@@ -326,17 +334,6 @@ __afr_selfheal_name_prepare (call_frame_t *frame, xlator_t *this, inode_t *paren
}
*source_p = source;
- for (i = 0; i < priv->child_count; i++)
- /* Initialize the healed_sinks[] array optimistically to
- the intersection of to-be-healed (i.e sinks[]) and
- the list of servers which are up (i.e locked_on[]).
-
- As we encounter failures in the healing process, we
- will unmark the respective servers in the healed_sinks[]
- array.
- */
- healed_sinks[i] = sinks[i] && locked_on[i];
-
return ret;
}