summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-metadata.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-08-20 21:50:06 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2014-10-01 03:29:12 -0700
commit443e48abf9b373bb1a8c56d016aad3b974554b80 (patch)
tree4a7124ff1c959d11c275dec9a0906519694e37ed /xlators/cluster/afr/src/afr-self-heal-metadata.c
parentf95a25c35e1ced6a3c05030d34555b757b14e1c9 (diff)
cluster/afr: Add afr-v1 xattr compatibility
All the special cases v1 handles and also self-accusing pending changelog from v1 pre-op also is handled in this patch. Change-Id: Ie10f71633fb20276f01ecafbd728f20483e7029c BUG: 1128721 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/8536 Reviewed-by: Ravishankar N <ravishankar@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-metadata.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index b4714fe9e05..96b3262e471 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -169,7 +169,6 @@ __afr_selfheal_metadata_finalize_source (call_frame_t *frame, xlator_t *this,
return source;
}
-
static int
__afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode,
unsigned char *locked_on, unsigned char *sources,
@@ -179,6 +178,8 @@ __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *i
int ret = -1;
int source = -1;
afr_private_t *priv = NULL;
+ int i = 0;
+ uint64_t *witness = NULL;
priv = this->private;
@@ -187,9 +188,10 @@ __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *i
if (ret)
return ret;
- ret = afr_selfheal_find_direction (this, replies,
- AFR_METADATA_TRANSACTION,
- locked_on, sources, sinks);
+ witness = alloca0 (sizeof (*witness) * priv->child_count);
+ ret = afr_selfheal_find_direction (frame, this, replies,
+ AFR_METADATA_TRANSACTION,
+ locked_on, sources, sinks, witness);
if (ret)
return ret;
@@ -203,9 +205,28 @@ __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *i
*/
AFR_INTERSECT (healed_sinks, sinks, locked_on, priv->child_count);
+ /* If any source has witness, pick first
+ * witness source and make everybody else sinks */
+ for (i = 0; i < priv->child_count; i++) {
+ if (sources[i] && witness[i]) {
+ source = i;
+ break;
+ }
+ }
+
+ if (source != -1) {
+ for (i = 0; i < priv->child_count; i++) {
+ if (i != source && sources[i]) {
+ sources[i] = 0;
+ healed_sinks[i] = 1;
+ }
+ }
+ }
+
source = __afr_selfheal_metadata_finalize_source (frame, this, sources,
healed_sinks,
- locked_on, replies);
+ locked_on, replies);
+
if (source < 0)
return -EIO;