summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-data.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-08-08 11:52:17 +0530
committerVijay Bellur <vbellur@redhat.com>2014-09-12 02:55:36 -0700
commit43d49fab8cce7d06fc63f23757abc7f2c70a6d48 (patch)
tree9fd43fa87d183b07e84a5cc000402f7b3087b7ac /xlators/cluster/afr/src/afr-self-heal-data.c
parenta82cfba2795bb15c74b4a8d28bd53ad73a7997c1 (diff)
cluster/afr: Fix all locked_on bricks are sinks check in self-heals
Backport of http://review.gluster.org/8456 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. BUG: 1136829 Change-Id: I56a8f9ff261bdeec8c441237c485036141b6f00d Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/8593 Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index c0548d9958f..402474e787b 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -388,7 +388,6 @@ __afr_selfheal_truncate_sinks (call_frame_t *frame, xlator_t *this,
*/
static int
__afr_selfheal_data_finalize_source (xlator_t *this, unsigned char *sources,
- unsigned char *sinks,
unsigned char *healed_sinks,
unsigned char *locked_on,
struct afr_reply *replies)
@@ -397,17 +396,14 @@ __afr_selfheal_data_finalize_source (xlator_t *this, unsigned char *sources,
afr_private_t *priv = NULL;
uint64_t size = 0;
int source = -1;
- int locked_count = 0;
int sources_count = 0;
- int healed_sinks_count = 0;
priv = this->private;
- locked_count = AFR_COUNT (locked_on, priv->child_count);
sources_count = AFR_COUNT (sources, priv->child_count);
- healed_sinks_count = AFR_COUNT (healed_sinks, priv->child_count);
- if (locked_count == healed_sinks_count || !sources_count) {
+ if ((AFR_CMP (locked_on, healed_sinks, priv->child_count) == 0)
+ || !sources_count) {
/* split brain */
return -EIO;
}
@@ -426,7 +422,7 @@ __afr_selfheal_data_finalize_source (xlator_t *this, unsigned char *sources,
continue;
if (replies[i].poststat.ia_size < size) {
sources[i] = 0;
- sinks[i] = 1;
+ healed_sinks[i] = 1;
}
}
@@ -451,7 +447,6 @@ __afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = -1;
int source = -1;
afr_private_t *priv = NULL;
- int i = 0;
priv = this->private;
@@ -466,22 +461,21 @@ __afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (ret)
return ret;
- source = __afr_selfheal_data_finalize_source (this, sources, sinks,
- healed_sinks, locked_on,
- replies);
- if (source < 0)
- return -EIO;
+ /* 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[]).
- 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.
+ */
+ AFR_INTERSECT (healed_sinks, sinks, locked_on, priv->child_count);
- 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];
+ source = __afr_selfheal_data_finalize_source (this, sources,
+ healed_sinks, locked_on,
+ replies);
+ if (source < 0)
+ return -EIO;
return source;
}