From 5dd850ae840ddb402ca4aaae19c668094947507e Mon Sep 17 00:00:00 2001 From: Basavanagowda Kanur Date: Mon, 13 Apr 2009 11:21:20 +0530 Subject: switch scheduler to validate the subvolume specified for a pattern, against the given subvolumes of cluster/unify. Signed-off-by: Anand V. Avati --- scheduler/switch/src/switch.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'scheduler') diff --git a/scheduler/switch/src/switch.c b/scheduler/switch/src/switch.c index 0e3469213..791b06550 100644 --- a/scheduler/switch/src/switch.c +++ b/scheduler/switch/src/switch.c @@ -75,6 +75,26 @@ switch_get_matching_xl (const char *path, struct switch_sched_struct *cond) return NULL; } +static int32_t +gf_unify_valid_child (const char *child, + xlator_t *xl) +{ + xlator_list_t *children = NULL, *prev = NULL; + int32_t ret = 0; + + children = xl->children; + do { + if (!strcmp (child, children->xlator->name)) { + ret = 1; + break; + } + + prev = children; + children = prev->next; + } while (children); + + return ret; +} static int32_t switch_init (xlator_t *xl) @@ -195,8 +215,19 @@ switch_init (xlator_t *xl) dup_childs = strdup (childs); child = strtok_r (dup_childs, ",", &tmp); while (child) { - idx++; - child = strtok_r (NULL, ",", &tmp); + if (gf_unify_valid_child (child, xl)) { + idx++; + child = strtok_r (NULL, ",", &tmp); + } else { + gf_log ("switch", GF_LOG_ERROR, + "%s is not a subvolume " + "of %s. pattern can " + "only be scheduled only" + " to a subvolume of %s", + child, xl->name, + xl->name); + return -1; + } } free (dup_childs); child = strtok_r (childs, ",", &tmp1); -- cgit