summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-10-05 07:01:52 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-05 05:47:33 -0700
commit7aec50bdad06665243a16f1ce83a03037bcd5d56 (patch)
tree7b034228b529e7bd8abe318e2f3d6609f4679ccb /libglusterfs
parent79db3aced2ffca84a696192343d5b811833eb671 (diff)
mgmt/Glusterd : Reply to CLI error: graph construction
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/xlator.c59
-rw-r--r--libglusterfs/src/xlator.h4
2 files changed, 63 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index b981958..ff1dc5e 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -763,6 +763,13 @@ xlator_dynload (xlator_t *xl)
"dlsym(reconfigure) on %s -- neglecting",
dlerror());
}
+
+ if (!(xl->validate_options = dlsym (handle, "validate_options"))) {
+ gf_log ("xlator", GF_LOG_DEBUG,
+ "dlsym(validate_options) on %s -- neglecting",
+ dlerror());
+ }
+
INIT_LIST_HEAD (&xl->volume_options);
@@ -978,6 +985,58 @@ out:
}
int
+xlator_validate_rec (xlator_t *xlator, char **op_errstr)
+{
+ xlator_list_t *trav = NULL;
+
+ if (xlator == NULL ) {
+ gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ return -1;
+ }
+
+ trav = xlator->children;
+
+ while (trav) {
+ if (xlator_validate_rec (trav->xlator, op_errstr) )
+ return -1;
+
+ trav = trav->next;
+ }
+
+ if (xlator_dynload (xlator))
+ gf_log ("", GF_LOG_DEBUG, "Did not load the symbols");
+
+ if (xlator->validate_options) {
+ if (xlator->validate_options (xlator, xlator->options,
+ op_errstr)) {
+ gf_log ("", GF_LOG_DEBUG, *op_errstr);
+ return -1;
+ }
+ gf_log (xlator->name, GF_LOG_DEBUG, "Validated option");
+
+ }
+
+ gf_log (xlator->name, GF_LOG_DEBUG, "No validate_options() found");
+
+ return 0;
+}
+
+int
+graph_reconf_validateopt (glusterfs_graph_t *graph,
+ char **op_errstr)
+{
+ xlator_t *xlator = NULL;
+ int ret = -1;
+
+ GF_ASSERT (graph);
+
+ xlator = graph->first;
+
+ ret = xlator_validate_rec (xlator, op_errstr);
+
+ return ret;
+}
+int
xlator_notify (xlator_t *xl, int event, void *data, ...)
{
xlator_t *old_THIS = NULL;
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 7c71f8e..b420097 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -807,6 +807,8 @@ struct _xlator {
int32_t (*init) (xlator_t *this);
int32_t (*reconfigure) (xlator_t *this, dict_t *options);
int32_t (*mem_acct_init) (xlator_t *this);
+ int32_t (*validate_options) (xlator_t *this, dict_t *options,
+ char **op_errstr);
event_notify_fn_t notify;
gf_loglevel_t loglevel; /* Log level for translator */
@@ -860,6 +862,8 @@ void loc_wipe (loc_t *loc);
int xlator_mem_acct_init (xlator_t *xl, int num_types);
int xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl);
int is_gf_log_command (xlator_t *trans, const char *name, char *value);
+int xlator_validate_rec (xlator_t *xlator, char **op_errstr);
+int graph_reconf_validateopt (glusterfs_graph_t *graph, char **op_errstr);
#define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"