summaryrefslogtreecommitdiffstats
path: root/scheduler/switch
diff options
context:
space:
mode:
authorBasavanagowda Kanur <gowda@gluster.com>2009-04-13 11:21:20 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-04-13 12:28:16 +0530
commit5dd850ae840ddb402ca4aaae19c668094947507e (patch)
tree76841f526239600e1a2303690432c6738bc3ac40 /scheduler/switch
parentec06475f22db2a3683167c5ffbe236c8e4aaf0ab (diff)
switch scheduler to validate the subvolume specified for a pattern, against the given subvolumes of cluster/unify.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'scheduler/switch')
-rw-r--r--scheduler/switch/src/switch.c35
1 files changed, 33 insertions, 2 deletions
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);