From 09692a4c1645b0783ddaf83d264c3b148476f937 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Thu, 3 Jul 2014 16:47:14 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/8229 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Niels de Vos --- heal/src/glfs-heal.c | 42 +++++++++++++++++++++++++++--------------- 1 file 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; -- cgit