summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2014-07-03 16:47:14 +0530
committerNiels de Vos <ndevos@redhat.com>2014-07-18 09:18:14 -0700
commit09692a4c1645b0783ddaf83d264c3b148476f937 (patch)
tree32155cbef01310daa3e4b8c0b31ef23f77463b74
parentc7fbb78ec198968069821cb0769071d17df1c58b (diff)
heal: fix the way we check the presence of AFR in glfsheal
Problem: glfsh_validate_replicate_volume() used to check if AFR was the parent of all client xlators present in the graph. This need not always be true, for example, for user-serviceable-snapshots where the parent of snapd-client is snapview-client. Fix: glfsh_validate_replicate_volume() returns true if atleast one client xlator has AFR as its parent. Also, AFR need not be its immediate parent, but be present somewhere in its parent ancestry. Change-Id: Id37ac88c3202bb2fdcae56e108adc461dc8a9a37 BUG: 1115950 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/8229 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--heal/src/glfs-heal.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
index dacdb5bc99b..8240e7b7569 100644
--- a/heal/src/glfs-heal.c
+++ b/heal/src/glfs-heal.c
@@ -393,30 +393,40 @@ out:
return;
}
+static gf_boolean_t
+_is_afr_an_ancestor (xlator_t *xl)
+{
+ xlator_t *parent = NULL;
+
+ if (!xl->parents)
+ return _gf_false;
+
+ for (parent = xl->parents->xlator; parent->parents;
+ parent = parent->parents->xlator) {
+ if (!strcmp (parent->type, "cluster/replicate"))
+ return _gf_true;
+ }
+
+ return _gf_false;
+}
+
static int
glfsh_validate_replicate_volume (xlator_t *xl)
{
- gf_boolean_t valid_replicate = _gf_false;
- gf_boolean_t has_client = _gf_false;
while (xl->next)
xl = xl->next;
while (xl) {
- if (strcmp (xl->type, "protocol/client") == 0) {
- has_client = _gf_true;
- if (strcmp (xl->parents->xlator->type,
- "cluster/replicate") != 0) {
- valid_replicate = _gf_false;
- goto out;
+ /* Check if atleast one client xlator has AFR in its parent
+ * ancestry */
+ if (!strcmp (xl->type, "protocol/client")) {
+ if (_is_afr_an_ancestor(xl)) {
+ return 1;
}
}
-
xl = xl->prev;
}
- valid_replicate = _gf_true;
-out:
- if (has_client && valid_replicate)
- return 0;
+
return -1;
}
@@ -497,8 +507,10 @@ main (int argc, char **argv)
while (xl) {
if (strcmp (xl->type, "protocol/client") == 0) {
- glfsh_print_pending_heals (xl, &rootloc);
- printf("\n");
+ if (_is_afr_an_ancestor (xl)) {
+ glfsh_print_pending_heals (xl, &rootloc);
+ printf("\n");
+ }
}
xl = xl->prev;