diff options
author | Anand Avati <avati@gluster.com> | 2011-08-11 16:08:36 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-08-18 23:49:03 -0700 |
commit | d2849bd349081b332540713cfeaa561f57356b2a (patch) | |
tree | 85ca2a53d39ced5cf7fd8dfb0df8cf292e9d29af /libglusterfs/src/xlator.h | |
parent | 6073fc29bf79fad0b0a3ae423d637ded39a00a3a (diff) |
xlator options: revamp xlator option validation/reconfigure code
- move option handling to options.c (new file)
- remove duplication of option validation code
- remove duplication of gf_log / sprintf
- get rid of xlator_t->validate_options
- get rid of option validation in rpc-transport
- get rid of validate_options() in every xlator
- use xlator_volume_option_get to clean up many functions
- introduce primitives to init/reconfigure option types
Change-Id: I51798af72c8dc0a2b9e017424036eb3667dfc7ff
BUG: 3415
Reviewed-on: http://review.gluster.com/235
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'libglusterfs/src/xlator.h')
-rw-r--r-- | libglusterfs/src/xlator.h | 61 |
1 files changed, 4 insertions, 57 deletions
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 1ecde5d5f79..725a9a2d039 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -74,6 +74,8 @@ typedef int32_t (*event_notify_fn_t) (xlator_t *this, int32_t event, void *data, #include "fd.h" #include "globals.h" #include "iatt.h" +#include "options.h" + struct _loc { const char *path; @@ -756,46 +758,6 @@ typedef struct xlator_list { struct xlator_list *next; } xlator_list_t; -/* Add possible new type of option you may need */ -typedef enum { - GF_OPTION_TYPE_ANY = 0, - GF_OPTION_TYPE_STR, - GF_OPTION_TYPE_INT, - GF_OPTION_TYPE_SIZET, - GF_OPTION_TYPE_PERCENT, - GF_OPTION_TYPE_PERCENT_OR_SIZET, - GF_OPTION_TYPE_BOOL, - GF_OPTION_TYPE_XLATOR, - GF_OPTION_TYPE_PATH, - GF_OPTION_TYPE_TIME, - GF_OPTION_TYPE_DOUBLE, - GF_OPTION_TYPE_INTERNET_ADDRESS, -} volume_option_type_t; - - -#define ZR_VOLUME_MAX_NUM_KEY 4 -#define ZR_OPTION_MAX_ARRAY_SIZE 64 - -/* Each translator should define this structure */ -typedef struct volume_options { - char *key[ZR_VOLUME_MAX_NUM_KEY]; - /* different key, same meaning */ - volume_option_type_t type; - int64_t min; /* 0 means no range */ - int64_t max; /* 0 means no range */ - char *value[ZR_OPTION_MAX_ARRAY_SIZE]; - /* If specified, will check for one of - the value from this array */ - char *default_value; - char *description; /* about the key */ -} volume_option_t; - - -typedef struct vol_opt_list { - struct list_head list; - volume_option_t *given_opt; -} volume_opt_list_t; - struct _xlator { /* Built during parsing */ @@ -818,7 +780,6 @@ 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, char **op_errstr); event_notify_fn_t notify; gf_loglevel_t loglevel; /* Log level for translator */ @@ -837,8 +798,6 @@ struct _xlator { #define xlator_has_parent(xl) (xl->parents != NULL) -int validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt); - int32_t xlator_set_type_virtual (xlator_t *xl, const char *type); int32_t xlator_set_type (xlator_t *xl, const char *type); @@ -870,20 +829,8 @@ int loc_copy (loc_t *dst, loc_t *src); #define loc_dup(src, dst) loc_copy(dst, src) 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); int glusterd_check_log_level (const char *value); -int validate_xlator_volume_options_attacherr (xlator_t *xl, - volume_option_t *opt, - char **op_errstr); -int _volume_option_value_validate_attacherr (xlator_t *xl, - data_pair_t *pair, - volume_option_t *opt, - char **op_errstr); -int32_t xlator_volopt_dynload (char *xlator_type, void **dl_handle, - volume_opt_list_t *vol_opt_handle); -int xlator_get_volopt_info (struct list_head *opt_list, char *key, - char **def_val, char **descr); +int xlator_volopt_dynload (char *xlator_type, void **dl_handle, + volume_opt_list_t *vol_opt_handle); #endif /* _XLATOR_H */ |