From eac54f6f76e6fca4f94028b47d963108f63c8f02 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Mon, 18 Feb 2013 14:22:07 +0530 Subject: glusterd: Added option description, and validation function fields. In volopt_map_entry table, added option description field, and option validation function pointer. Change-Id: I21c6bccd175970592b470ce3ef3f418cb99a5a43 BUG: 903478 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/4535 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 34 ++++++++++++----------- xlators/mgmt/glusterd/src/glusterd-volgen.h | 6 +++++ xlators/mgmt/glusterd/src/glusterd-volume-set.c | 36 +++++++++++++++---------- 3 files changed, 47 insertions(+), 29 deletions(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index d650111f..d154c4fd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1916,33 +1916,37 @@ glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out) if (get_key_from_volopt (vme, &key)) goto out; /*Some error while getin key*/ - if (!xlator_type || strcmp (vme->voltype, xlator_type)){ - ret = xlator_volopt_dynload (vme->voltype, - &dl_handle, - &vol_opt_handle); - if (ret) { - dl_handle = NULL; - continue; + if (vme->description) { + descr = vme->description; + def_val = vme->value; + } else { + if (!xlator_type || strcmp (vme->voltype, xlator_type)){ + ret = xlator_volopt_dynload (vme->voltype, + &dl_handle, + &vol_opt_handle); + if (ret) { + dl_handle = NULL; + continue; + } } + ret = xlator_option_info_list (&vol_opt_handle, key, + &def_val, &descr); + if (ret) /*Swallow Error i.e if option not found*/ + continue; } - ret = xlator_option_info_list (&vol_opt_handle, key, - &def_val, &descr); - if (ret) /*Swallow Error i.e if option not found*/ - continue; - if (xml_out) { #if (HAVE_LIB_XML) if (xml_add_volset_element (writer,vme->key, - def_val, descr)) + def_val, descr)) goto out; #else gf_log ("glusterd", GF_LOG_ERROR, "Libxml not present"); #endif } else { snprintf (tmp_str, 2048, "Option: %s\nDefault " - "Value: %s\nDescription: %s\n\n", - vme->key, def_val, descr); + "Value: %s\nDescription: %s\n\n", + vme->key, def_val, descr); strcat (output_string, tmp_str); } diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index b495b440..342183cc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -86,6 +86,9 @@ typedef enum { typedef enum { DOC, NO_DOC, GLOBAL_DOC, GLOBAL_NO_DOC } option_type_t; +typedef int (*vme_option_validation) (char *key, dict_t *dict, + char **op_errstr); + struct volopt_map_entry { char *key; char *voltype; @@ -94,7 +97,10 @@ struct volopt_map_entry { option_type_t type; uint32_t flags; uint32_t op_version; + char *description; + vme_option_validation validate_fn; }; + int glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 41719ec8..62e7b425 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -41,6 +41,12 @@ * * Seventh field is . * + * Eight field is description of option: If NULL, tried to fetch from + * translator code's xlator_options table. + * + * Nineth field is validation function: If NULL, xlator's option specific + * validation will be tried, otherwise tried at glusterd code itself. + * * There are two type of entries: basic and special. * * - Basic entries are the ones where the