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
committerVijay Bellur <vbellur@redhat.com>2014-10-22 03:03:51 -0700
commitd7e56dde3c19a11647eae9cf6a868c191c641489 (patch)
tree978d388b34c1e773b753936bfe71ec8f432e49e1 /xlators/cluster/afr/src/afr-self-heal-metadata.c
parent4522acc20bdd1ca17c053969ef7edce1bb6ede76 (diff)
cluster/afr: Add afr-v1 xattr compatibility
Backport of http://review.gluster.org/8536 All the special cases v1 handles and also self-accusing pending changelog from v1 pre-op also is handled in this patch. BUG: 1155017 Change-Id: I86cf6b80492be5c1f240c74f91a0e1b0dd9b58b2 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/8956 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.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;