summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2013-09-03 13:30:13 +0530
committerAnand Avati <avati@redhat.com>2013-09-03 21:37:44 -0700
commit2c15621d26fda5ba21e375d803baa5d8e09e6260 (patch)
tree3a90a671e8409bd23585a30c82b11e44b77abe28
parent6f85f6ce64c99e70d3b674e2e01657803ee3c082 (diff)
cluster/afr: Set size based source only when sizes are unequal
Change-Id: I18583f14edf1011401be15744371e2a6b79d75cc BUG: 1003842 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/5763 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index f82ce23..ef92b42 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -574,6 +574,8 @@ afr_find_largest_file_size (struct iatt *bufs, int32_t *success_children,
int i = -1;
int child = -1;
uint64_t max_size = 0;
+ uint64_t min_size = 0;
+ int num_children = 0;
for (i = 0; i < child_count; i++) {
if (success_children[i] == -1)
@@ -584,8 +586,19 @@ afr_find_largest_file_size (struct iatt *bufs, int32_t *success_children,
max_size = bufs[child].ia_size;
idx = child;
}
+
+ if ((num_children == 0) || (bufs[child].ia_size < min_size)) {
+ min_size = bufs[child].ia_size;
+ }
+
+ num_children++;
}
+ /* If sizes are same for all of them, finding sources will have to
+ * happen with pending changelog. So return -1
+ */
+ if ((num_children > 1) && (min_size == max_size))
+ return -1;
return idx;
}