diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/xlator.c | 59 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 4 |
2 files changed, 63 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index b9819584eee..ff1dc5efa26 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 7c71f8e40b5..b4200976e4c 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" |