diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-entry.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 9e714b0263c..dc1546c7403 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -430,24 +430,21 @@ afr_selfheal_entry_do (call_frame_t *frame, xlator_t *this, fd_t *fd, static int __afr_selfheal_entry_finalize_source (xlator_t *this, unsigned char *sources, - unsigned char *sinks, + 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; } @@ -471,7 +468,6 @@ __afr_selfheal_entry_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; @@ -486,7 +482,18 @@ __afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, fd_t *fd, if (ret) return ret; - source = __afr_selfheal_entry_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_entry_finalize_source (this, sources, + healed_sinks, locked_on, replies); if (source < 0) { /* If source is < 0 (typically split-brain), we perform a @@ -494,17 +501,6 @@ __afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, fd_t *fd, } *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; } |