diff options
| author | Avra Sengupta <asengupt@redhat.com> | 2013-02-18 14:22:07 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-02-19 00:09:34 -0800 | 
| commit | eac54f6f76e6fca4f94028b47d963108f63c8f02 (patch) | |
| tree | 0992b0443f4df9e622bee77aef050d0cbe46b07e /xlators | |
| parent | 81dceec250c9b2f5b87650e28e736e04c4b8597e (diff) | |
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 <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/4535
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 34 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.h | 6 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 36 | 
3 files changed, 47 insertions, 29 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index d650111f04b..d154c4fd242 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 b495b4408bf..342183ccafc 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 41719ec8993..62e7b4259cb 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 <op-version>.   * + * 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 <option> does _not_ start with @@ -463,50 +469,52 @@ struct volopt_map_entry glusterd_volopt_map[] = {            .voltype     = "performance/write-behind",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable write-behind translator in the volume."          },          { .key         = "performance.read-ahead",            .voltype     = "performance/read-ahead",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable read-ahead translator in the volume."          },          { .key         = "performance.io-cache",            .voltype     = "performance/io-cache",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable io-cache translator in the volume."          },          { .key         = "performance.quick-read",            .voltype     = "performance/quick-read",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable quick-read translator in the volume."          },          { .key         = "performance.open-behind",            .voltype     = "performance/open-behind",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 2 +          .op_version  = 2, +          .description = "enable/disable open-behind translator in the volume."          },          { .key         = "performance.stat-prefetch",            .voltype     = "performance/md-cache",            .option      = "!perf",            .value       = "on", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable meta-data caching translator in the " +                         "volume."          },          { .key         = "performance.client-io-threads",            .voltype     = "performance/io-threads",            .option      = "!perf",            .value       = "off", -          .type        = NO_DOC, -          .op_version  = 1 +          .op_version  = 1, +          .description = "enable/disable io-threads translator in the client " +                         "graph of volume."          },          { .key         = "performance.nfs.write-behind",            .voltype     = "performance/write-behind",  | 
