summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-04-05 14:26:22 +0530
committerVijay Bellur <vijay@gluster.com>2012-05-22 04:28:37 -0700
commitf5c87c7bedfda7ed80d03918bfc3ce90069378e8 (patch)
tree7f8f050ddb7415acff9c112c9be1d9659a9733c1
parentbdec439fe59c5e3fa9701d9cf4b5b92bd7e8a98f (diff)
cluster/afr: Mark zero size file as sink in absense of xattrs.
BUG: 765587 Change-Id: I225dbf79ec2d4669333cbb28b3c5319a08fe0600 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3394 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c53
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c2
2 files changed, 53 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 0f6b00b4fb4..f45d9c76fa9 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -541,6 +541,46 @@ out:
return nsources;
}
+int
+afr_sh_mark_zero_size_file_as_sink (struct iatt *bufs, int32_t *success_children,
+ int child_count, int32_t *sources)
+{
+ int nsources = 0;
+ int i = 0;
+ int child = 0;
+ gf_boolean_t sink_exists = _gf_false;
+ gf_boolean_t source_exists = _gf_false;
+
+ for (i = 0; i < child_count; i++) {
+ child = success_children[i];
+ if (child < 0)
+ break;
+ if (bufs[child].ia_size)
+ source_exists = _gf_true;
+ if (!bufs[child].ia_size)
+ sink_exists = _gf_true;
+ }
+ if (!source_exists && !sink_exists) {
+ nsources = -1;
+ goto out;
+ }
+
+ if (!source_exists || !sink_exists)
+ goto out;
+
+ for (i = 0; i < child_count; i++) {
+ child = success_children[i];
+ if (child < 0)
+ break;
+ if (bufs[child].ia_size) {
+ sources[child] = 1;
+ nsources++;
+ }
+ }
+out:
+ return nsources;
+}
+
char *
afr_get_character_str (afr_node_type type)
{
@@ -706,11 +746,22 @@ afr_mark_sources (xlator_t *this, int32_t *sources, int32_t **pending_matrix,
afr_find_character_types (characters, pending_matrix, success_children,
child_count);
if (afr_sh_all_nodes_innocent (characters, child_count)) {
- if (type == AFR_SELF_HEAL_METADATA)
+ switch (type) {
+ case AFR_SELF_HEAL_METADATA:
nsources = afr_sh_mark_lowest_uid_as_source (bufs,
success_children,
child_count,
sources);
+ break;
+ case AFR_SELF_HEAL_DATA:
+ nsources = afr_sh_mark_zero_size_file_as_sink (bufs,
+ success_children,
+ child_count,
+ sources);
+ break;
+ default:
+ break;
+ }
goto out;
}
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index df8e2ca7af7..044d412d822 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -736,7 +736,7 @@ afr_sh_data_fxattrop_fstat_done (call_frame_t *frame, xlator_t *this)
nsources = afr_build_sources (this, sh->xattr, sh->buf, sh->pending_matrix,
sh->sources, sh->success_children,
- AFR_DATA_TRANSACTION, NULL, _gf_false);
+ AFR_DATA_TRANSACTION, NULL, _gf_true);
if ((nsources == 0) && !sh->sync_done) {
gf_log (this->name, GF_LOG_DEBUG,
"No self-heal needed for %s",