Patchwork [BUG:2064] CLI : Validate options farmework.

login
register
Submitter Gaurav
Date 2011-03-23 06:20:17
Message ID <1300861217-7926-1-git-send-email-gaurav@gluster.com>
Download mbox | patch
Permalink /patch/6561/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Gaurav - 2011-03-23 06:20:17
From: Gaurav <gaurav@gluster.com>


Signed-off-by: Gaurav <gaurav@gluster.com>
---
 libglusterfs/src/xlator.c                          |  612 +++++++++++++++++++-
 libglusterfs/src/xlator.h                          |   20 +-
 rpc/rpc-lib/src/rpc-transport.h                    |    1 -
 rpc/rpc-transport/socket/src/socket.c              |   33 +-
 xlators/cluster/afr/src/afr.c                      |  287 +---------
 xlators/cluster/dht/src/dht.c                      |   43 +-
 xlators/cluster/stripe/src/stripe.c                |   49 +-
 xlators/debug/io-stats/src/io-stats.c              |   36 +-
 xlators/mgmt/glusterd/src/glusterd-volgen.c        |    2 +-
 xlators/nfs/server/src/nfs.c                       |   54 +--
 xlators/performance/io-cache/src/io-cache.c        |  156 +-----
 xlators/performance/io-threads/src/io-threads.c    |   42 +-
 xlators/performance/quick-read/src/quick-read.c    |   63 +--
 .../performance/write-behind/src/write-behind.c    |   78 +--
 xlators/protocol/client/src/client.c               |   79 +--
 xlators/protocol/server/src/server.c               |   64 +--
 16 files changed, 834 insertions(+), 785 deletions(-)

Patch

diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index fd10eb0..b995212 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -105,6 +105,548 @@  fill_defaults (xlator_t *xl)
 	return;
 }
 
+int 
+_volume_option_value_validate_attacherr (xlator_t *xl,
+                               data_pair_t *pair,
+                               volume_option_t *opt,
+                               char **op_errstr)
+{
+        int       i = 0;
+        int       ret = -1;
+        uint64_t  input_size = 0;
+        long long inputll = 0;
+        char      errstr[256] = {0, };
+
+        /* Key is valid, validate the option */
+        switch (opt->type) {
+        case GF_OPTION_TYPE_PATH:
+        {
+                if (strstr (pair->value->data, "../")) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "invalid path given '%s'",
+                                pair->value->data);
+                        snprintf (errstr, 256,
+                                  "invalid path given '%s'",
+                                  pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        ret = -1;
+                        goto out;
+                }
+
+                /* Make sure the given path is valid */
+                if (pair->value->data[0] != '/') {
+                        gf_log (xl->name, GF_LOG_WARNING,
+                                "option %s %s: '%s' is not an "
+                                "absolute path name",
+                                pair->key, pair->value->data,
+                                pair->value->data);
+                        snprintf (errstr, 256,
+                                  "option %s %s: '%s' is not an "
+                                  "absolute path name",
+                                  pair->key, pair->value->data,
+                                  pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_INT:
+        {
+                /* Check the range */
+                if (gf_string2longlong (pair->value->data,
+                                        &inputll) != 0) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "invalid number format \"%s\" in "
+                                "\"option %s\"",
+                                pair->value->data, pair->key);
+                        snprintf (errstr, 256,
+                                  "invalid number format \"%s\" in "
+                                "\"option %s\"",
+                                pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if ((opt->min == 0) && (opt->max == 0)) {
+                        gf_log (xl->name, GF_LOG_DEBUG,
+                                "no range check required for "
+                                "'option %s %s'",
+                                pair->key, pair->value->data);
+                        ret = 0;
+                        break;
+                }
+                if ((inputll < opt->min) ||
+                    (inputll > opt->max)) {
+                        gf_log (xl->name, GF_LOG_WARNING,
+                                "'%lld' in 'option %s %s' is out of "
+                                "range [%"PRId64" - %"PRId64"]",
+                                inputll, pair->key,
+                                pair->value->data,
+                                opt->min, opt->max);
+                        snprintf (errstr, 256,
+                                  "'%lld' in 'option %s %s' is out of "
+                                "range [%"PRId64" - %"PRId64"]",
+                                inputll, pair->key,
+                                pair->value->data,
+                                opt->min, opt->max);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_SIZET:
+        {
+                /* Check the range */
+                if (gf_string2bytesize (pair->value->data,
+                                        &input_size) != 0) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "invalid size format \"%s\" in "
+                                "\"option %s\"",
+                                pair->value->data, pair->key);
+                        snprintf (errstr, 256,
+                                  "invalid size format \"%s\" in "
+                                  "\"option %s\"",
+                                  pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if ((opt->min == 0) && (opt->max == 0)) {
+                        gf_log (xl->name, GF_LOG_DEBUG,
+                                "no range check required for "
+                                "'option %s %s'",
+                                pair->key, pair->value->data);
+                        ret = 0;
+                        break;
+                }
+                if ((input_size < opt->min) ||
+                    (input_size > opt->max)) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "'%"PRId64"' in 'option %s %s' is "
+                                "out of range [%"PRId64" - %"PRId64"]",
+                                input_size, pair->key,
+                                pair->value->data,
+                                opt->min, opt->max);
+                        snprintf (errstr, 256,
+                                  "'%"PRId64"' in 'option %s %s' is "
+                                "out of range [%"PRId64" - %"PRId64"]",
+                                input_size, pair->key,
+                                pair->value->data,
+                                opt->min, opt->max);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_BOOL:
+        {
+                /* Check if the value is one of
+                   '0|1|on|off|no|yes|true|false|enable|disable' */
+                gf_boolean_t bool_value;
+                if (gf_string2boolean (pair->value->data,
+                                       &bool_value) != 0) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "option %s %s: '%s' is not a valid "
+                                "boolean value",
+                                pair->key, pair->value->data,
+                                pair->value->data);
+                        snprintf (errstr, 256,
+                                   "option %s %s: '%s' is not a valid "
+                                   "boolean value",
+                                   pair->key, pair->value->data,
+                                   pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_XLATOR:
+        {
+                /* Check if the value is one of the xlators */
+                xlator_t *xlopt = xl;
+                while (xlopt->prev)
+                        xlopt = xlopt->prev;
+
+                while (xlopt) {
+                        if (strcmp (pair->value->data,
+                                    xlopt->name) == 0) {
+                                ret = 0;
+                                break;
+                        }
+                        xlopt = xlopt->next;
+                }
+                if (!xlopt) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "option %s %s: '%s' is not a "
+                                "valid volume name",
+                                pair->key, pair->value->data,
+                                pair->value->data);
+                        snprintf (errstr, 256,
+                                  "option %s %s: '%s' is not a "
+                                  "valid volume name",
+                                  pair->key, pair->value->data,
+                                  pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_STR:
+        {
+                /* Check if the '*str' is valid */
+                if (GF_OPTION_LIST_EMPTY(opt)) {
+                        ret = 0;
+                        goto out;
+                }
+
+                for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE) &&
+                             opt->value[i]; i++) {
+                        if (fnmatch (opt->value[i], pair->value->data,
+                                     FNM_EXTMATCH) == 0) {
+                                ret = 0;
+                                break;
+                        }
+                }
+
+                if ((i == ZR_OPTION_MAX_ARRAY_SIZE)
+                    || ((i < ZR_OPTION_MAX_ARRAY_SIZE)
+                        && (!opt->value[i]))) {
+                        /* enter here only if
+                         * 1. reached end of opt->value array and haven't
+                         *    validated input
+                         *                      OR
+                         * 2. valid input list is less than
+                         *    ZR_OPTION_MAX_ARRAY_SIZE and input has not
+                         *    matched all possible input values.
+                         */
+                        char given_array[4096] = {0,};
+                        for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE) &&
+                                     opt->value[i]; i++) {
+                                strcat (given_array, opt->value[i]);
+                                strcat (given_array, ", ");
+                        }
+
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "option %s %s: '%s' is not valid "
+                                "(possible options are %s)",
+                                pair->key, pair->value->data,
+                                pair->value->data, given_array);
+                        snprintf (errstr, 256,
+                                  "option %s %s: '%s' is not valid "
+                                  "(possible options are %s)",
+                                  pair->key, pair->value->data,
+                                  pair->value->data, given_array);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+        }
+        break;
+        case GF_OPTION_TYPE_PERCENT:
+        {
+                uint32_t percent = 0;
+
+
+                /* Check if the value is valid percentage */
+                if (gf_string2percent (pair->value->data,
+                                       &percent) != 0) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "invalid percent format \"%s\" "
+                                "in \"option %s\"",
+                                pair->value->data, pair->key);
+                        snprintf (errstr, 256,
+                                  "invalid percent format \"%s\" "
+                                  "in \"option %s\"",
+                                  pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if ((percent < 0) || (percent > 100)) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "'%d' in 'option %s %s' is out of "
+                                "range [0 - 100]",
+                                percent, pair->key,
+                                pair->value->data);
+                        snprintf (errstr, 256,
+                                   "'%d' in 'option %s %s' is out of "
+                                "range [0 - 100]",
+                                percent, pair->key,
+                                pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_PERCENT_OR_SIZET:
+        {
+                uint32_t percent = 0;
+                uint64_t input_size = 0;
+
+                /* Check if the value is valid percentage */
+                if (gf_string2percent (pair->value->data,
+                                       &percent) == 0) {
+                        if (percent > 100) {
+                                gf_log (xl->name, GF_LOG_DEBUG,
+                                        "value given was greater than 100, "
+                                        "assuming this is actually a size");
+                                if (gf_string2bytesize (pair->value->data,
+                                                        &input_size) == 0) {
+                                        /* Check the range */
+                                        if ((opt->min == 0) &&
+                                            (opt->max == 0)) {
+                                                gf_log (xl->name, GF_LOG_DEBUG,
+                                                        "no range check "
+                                                        "required for "
+                                                        "'option %s %s'",
+                                                        pair->key,
+                                                        pair->value->data);
+                                                // It is a size
+                                                ret = 0;
+                                                goto out;
+                                        }
+                                        if ((input_size < opt->min) ||
+                                            (input_size > opt->max)) {
+                                                gf_log (xl->name, GF_LOG_ERROR,
+                                                        "'%"PRId64"' in "
+                                                        "'option %s %s' is out"
+                                                        " of range [%"PRId64""
+                                                        "- %"PRId64"]",
+                                                        input_size, pair->key,
+                                                        pair->value->data,
+                                                        opt->min, opt->max);
+                                                 snprintf (errstr, 256,
+                                                          "'%"PRId64"' in "
+                                                          "'option %s %s' is "
+                                                          " out of range ["
+                                                          "%"PRId64"- %"PRId64"]",
+                                                          input_size, pair->key,
+                                                          pair->value->data,
+                                                          opt->min, opt->max);
+
+                                                *op_errstr = gf_strdup (errstr);
+                                                goto out;
+                                        }
+                                        // It is a size
+                                        ret = 0;
+                                        goto out;
+                                } else {
+                                        // It's not a percent or size
+                                        gf_log (xl->name, GF_LOG_ERROR,
+                                        "invalid number format \"%s\" "
+                                        "in \"option %s\"",
+                                        pair->value->data, pair->key);
+
+                                        snprintf (errstr, 256,
+                                        "invalid number format \"%s\" "
+                                        "in \"option %s\"",
+                                        pair->value->data, pair->key);
+
+
+                                        *op_errstr = gf_strdup (errstr);
+                                        goto out;
+                                }
+
+                        }
+                        // It is a percent
+                        ret = 0;
+                        goto out;
+                } else {
+                        if (gf_string2bytesize (pair->value->data,
+                                                &input_size) == 0) {
+                                /* Check the range */
+                                if ((opt->min == 0) && (opt->max == 0)) {
+                                        gf_log (xl->name, GF_LOG_DEBUG,
+                                                "no range check required for "
+                                                "'option %s %s'",
+                                                pair->key, pair->value->data);
+                                        // It is a size
+                                        ret = 0;
+                                        goto out;
+                                }
+                                if ((input_size < opt->min) ||
+                                    (input_size > opt->max)) {
+                                        gf_log (xl->name, GF_LOG_ERROR,
+                                                "'%"PRId64"' in 'option %s %s'"
+                                                " is out of range [%"PRId64" -"
+                                                " %"PRId64"]",
+                                                input_size, pair->key,
+                                                pair->value->data,
+                                                opt->min, opt->max);
+                                        snprintf (errstr, 256,
+                                                  "'%"PRId64"' in 'option %s %s'"
+                                                  " is out of range [%"PRId64" -"
+                                                  " %"PRId64"]",
+                                                  input_size, pair->key,
+                                                  pair->value->data,
+                                                  opt->min, opt->max);
+
+                                        *op_errstr = gf_strdup (errstr);
+                                        goto out;
+                                }
+                        } else {
+                                // It's not a percent or size
+                                gf_log (xl->name, GF_LOG_ERROR,
+                                        "invalid number format \"%s\" "
+                                        "in \"option %s\"",
+                                        pair->value->data, pair->key);
+                                snprintf (errstr, 256,
+                                          "invalid number format \"%s\" "
+                                          "in \"option %s\"",
+                                          pair->value->data, pair->key);
+
+                                *op_errstr = gf_strdup (errstr);
+                                goto out;
+                        }
+                        //It is a size
+                        ret = 0;
+                        goto out;
+                }
+
+        }
+        break;
+        case GF_OPTION_TYPE_TIME:
+        {
+                uint32_t input_time = 0;
+
+                /* Check if the value is valid percentage */
+                if (gf_string2time (pair->value->data,
+                                    &input_time) != 0) {
+                        gf_log (xl->name,
+                                GF_LOG_ERROR,
+                                "invalid time format \"%s\" in "
+                                "\"option %s\"",
+                                pair->value->data, pair->key);
+
+                        snprintf (errstr, 256,
+                                  "invalid time format \"%s\" in "
+                                  "\"option %s\"",
+                                  pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if ((opt->min == 0) && (opt->max == 0)) {
+                        gf_log (xl->name, GF_LOG_DEBUG,
+                                "no range check required for "
+                                "'option %s %s'",
+                                pair->key, pair->value->data);
+                        ret = 0;
+                        goto out;
+                }
+                if ((input_time < opt->min) ||
+                    (input_time > opt->max)) {
+                        gf_log (xl->name, GF_LOG_ERROR,
+                                "'%"PRIu32"' in 'option %s %s' is "
+                                "out of range [%"PRId64" - %"PRId64"]",
+                                input_time, pair->key,
+                                pair->value->data,
+                                opt->min, opt->max);
+
+                        snprintf (errstr, 256,
+                                  "'%"PRIu32"' in 'option %s %s' is "
+                                  "out of range [%"PRId64" - %"PRId64"]",
+                                  input_time, pair->key,
+                                  pair->value->data,
+                                  opt->min, opt->max);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_DOUBLE:
+        {
+                double input_time = 0.0;
+
+                /* Check if the value is valid double */
+                if (gf_string2double (pair->value->data,
+                                      &input_time) != 0) {
+                        gf_log (xl->name,
+                                GF_LOG_ERROR,
+                                "invalid double \"%s\" in \"option %s\"",
+                                pair->value->data, pair->key);
+
+                        snprintf (errstr, 256,
+                                  "invalid double \"%s\" in \"option %s\"",
+                                  pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if (input_time < 0.0) {
+                        gf_log (xl->name,
+                                GF_LOG_ERROR,
+                                "invalid time format \"%s\" in \"option %s\"",
+                                pair->value->data, pair->key);
+
+                        snprintf (errstr, 256,
+                                  "invalid double \"%s\" in \"option %s\"",
+                                  pair->value->data, pair->key);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+
+                if ((opt->min == 0) && (opt->max == 0)) {
+                        gf_log (xl->name, GF_LOG_DEBUG,
+                                "no range check required for 'option %s %s'",
+                                pair->key, pair->value->data);
+                        ret = 0;
+                        goto out;
+                }
+                ret = 0;
+        }
+        break;
+        case GF_OPTION_TYPE_INTERNET_ADDRESS:
+        {
+                if (valid_internet_address (pair->value->data)) {
+                        ret = 0;
+                } else {
+                        gf_log (xl->name, GF_LOG_ERROR, "internet address '%s'"
+                                " does not conform to standards.",
+                                pair->value->data);
+
+                        snprintf (errstr, 256,
+                                  "internet address '%s'"
+                                  " does not conform to standards.",
+                                  pair->value->data);
+
+                        *op_errstr = gf_strdup (errstr);
+                        goto out;
+                }
+        }
+        break;
+        case GF_OPTION_TYPE_ANY:
+                /* NO CHECK */
+                ret = 0;
+                break;
+        }
+
+out:
+        return ret;
+}
+
+
 int
 _volume_option_value_validate (xlator_t *xl,
 			       data_pair_t *pair,
@@ -498,6 +1040,71 @@  out:
 }
 
 int
+validate_xlator_volume_options_attacherr (xlator_t *xl,
+                                          volume_option_t *opt,
+                                          char **op_errstr)
+{
+        int i = 0;
+        int ret = -1;
+        int index = 0;
+        volume_option_t *trav  = NULL;
+        data_pair_t     *pairs = NULL;
+
+        if (!opt) {
+                ret = 0;
+                goto out;
+        }
+
+        /* First search for not supported options, if any report error */
+        pairs = xl->options->members_list;
+        while (pairs) {
+                ret = -1;
+                for (index = 0;
+                     opt[index].key && opt[index].key[0] ; index++) {
+                        trav = &(opt[index]);
+                        for (i = 0 ;
+                             (i < ZR_VOLUME_MAX_NUM_KEY) &&
+                                     trav->key[i]; i++) {
+                                /* Check if the key is valid */
+                                if (fnmatch (trav->key[i],
+                                             pairs->key, FNM_NOESCAPE) == 0) {
+                                        ret = 0;
+                                        break;
+                                }
+                        }
+                        if (!ret) {
+                                if (i) {
+                                        gf_log (xl->name, GF_LOG_WARNING,
+                                                "option '%s' is deprecated, "
+                                                "preferred is '%s', continuing"
+                                                " with correction",
+                                                trav->key[i], trav->key[0]);
+                                        /* TODO: some bytes lost */
+                                        pairs->key = gf_strdup (trav->key[0]);
+                                }
+                                break;
+                        }
+                }
+                if (!ret) {
+                        ret = _volume_option_value_validate_attacherr (xl,
+                                                                       pairs,
+                                                                       trav,
+                                                                       op_errstr);
+                        if (-1 == ret) {
+                                goto out;
+                        }
+                }
+
+                pairs = pairs->next;
+        }
+
+        ret = 0;
+ out:
+        return ret;
+}
+
+
+int
 validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
 {
 	int i = 0;
@@ -888,9 +1495,8 @@  xlator_validate_rec (xlator_t *xlator, char **op_errstr)
                 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_INFO, "%s", *op_errstr);
+                if (xlator->validate_options (xlator, op_errstr)) {
+                        gf_log ("", GF_LOG_DEBUG, "%s", *op_errstr);
                         return -1;
                 }
                 gf_log (xlator->name, GF_LOG_DEBUG, "Validated option");
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 604c8c0..e587ae5 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -771,8 +771,8 @@  typedef struct volume_options {
         char                *key[ZR_VOLUME_MAX_NUM_KEY];
         /* different key, same meaning */
         volume_option_type_t type;
-        int64_t              min;  /* -1 means no range */
-        int64_t              max;  /* -1 means no range */
+        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 */
@@ -806,10 +806,9 @@  struct _xlator {
         void              (*fini) (xlator_t *this);
         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;
+	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 */
 
@@ -865,5 +864,14 @@  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);
+
+
 
 #endif /* _XLATOR_H */
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h
index b42df31..e688388 100644
--- a/rpc/rpc-lib/src/rpc-transport.h
+++ b/rpc/rpc-lib/src/rpc-transport.h
@@ -200,7 +200,6 @@  struct rpc_transport {
  	int32_t                  (*init)   (rpc_transport_t *this);
 	void                     (*fini)   (rpc_transport_t *this);
         int32_t                  (*validate_options) (rpc_transport_t *this, 
-                                                      dict_t *options, 
                                                       char **op_errstr);
         int                      (*reconfigure) (rpc_transport_t *this, dict_t *options);
         rpc_transport_notify_t     notify;
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 395bf73..62f22e2 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2457,41 +2457,21 @@  struct rpc_transport_ops tops = {
 };
 
 int
-validate_options (rpc_transport_t *this, dict_t *options, char **op_errstr)
-{
-        char             *optstr = NULL;
-        int               ret = -1;
-        gf_boolean_t      tmp_bool = _gf_false;
-
-        if (dict_get_str (options, "transport.socket.keepalive",
-                          &optstr) == 0) {
-                if (gf_string2boolean (optstr, &tmp_bool) == -1) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "'transport.socket.keepalive' takes only "
-                                "boolean options, not taking any action");
-                        *op_errstr = "Value should be only boolean!!";
-                        ret =-1;
-                        goto out;
-                }
-        }
-
-        ret =0;
-out:
-        return ret;
-
-}
-
-int
 reconfigure (rpc_transport_t *this, dict_t *options)
 {
         socket_private_t *priv = NULL;
         gf_boolean_t      tmp_bool = _gf_false;
         char             *optstr = NULL;
-        int               ret = -1;
+        int               ret = 0;
 
         GF_VALIDATE_OR_GOTO ("socket", this, out);
         GF_VALIDATE_OR_GOTO ("socket", this->private, out);
 
+        if (!this || !this->private) {
+                ret =-1;
+                goto out;
+        }
+
         priv = this->private;
 
         if (dict_get_str (this->options, "transport.socket.keepalive",
@@ -2501,6 +2481,7 @@  reconfigure (rpc_transport_t *this, dict_t *options)
                                 "'transport.socket.keepalive' takes only "
                                 "boolean options, not taking any action");
                         priv->keepalive = 1;
+                        ret = -1;
                         goto out;
                 }
                 gf_log (this->name, GF_LOG_DEBUG, "Reconfigured transport.socket.keepalive");
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 3aa035c..dff55bc 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -59,283 +59,33 @@  mem_acct_init (xlator_t *this)
 
         return ret;
 }
+
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
-
-        gf_boolean_t metadata_self_heal;
-        gf_boolean_t entry_self_heal;
-        gf_boolean_t data_self_heal;
-        gf_boolean_t data_change_log;
-        gf_boolean_t metadata_change_log;
-        gf_boolean_t entry_change_log;
-        gf_boolean_t strict_readdir;
-        gf_boolean_t optimistic_change_log;
-
-        xlator_list_t * trav        = NULL;
-
-        char * read_subvol     = NULL;
-        char * self_heal       = NULL;
-        char * change_log      = NULL;
-        char * str_readdir     = NULL;
-        char * self_heal_algo  = NULL;
-
-        int32_t background_count  = 0;
-        int32_t window_size       = 0;
-
-        int    read_ret      = -1;
-        int    dict_ret      = -1;
-        int    flag          = 1;
-        int    ret           = 0;
-        int    temp_ret      = -1;
-
-
-
-        dict_ret = dict_get_int32 (options, "background-self-heal-count",
-                                   &background_count);
-        if (dict_ret == 0) {
-                if (background_count < 0) {
-                        *op_errstr = gf_strdup ("Error, option should be >= 0");
-                        ret = -1;
-                        goto out;
-                }
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "validated background self-heal count to %d",
-                        background_count);
-        }
-
-        dict_ret = dict_get_str (options, "metadata-self-heal",
-                                 &self_heal);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (self_heal, &metadata_self_heal);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "validation failed 'option metadata"
-                                                "-self-heal %s'.not correct.",
-                                                self_heal);
-                        *op_errstr = gf_strdup ("Error, option should be boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-        }
-
-        dict_ret = dict_get_str (options, "data-self-heal",
-                                 &self_heal);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (self_heal, &data_self_heal);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation failed for data self heal "
-                                "(given-string = %s)", self_heal);
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Reconfiguring 'option data"
-                        "-self-heal %s'.", self_heal);
-        }
-
-        dict_ret = dict_get_str (options, "entry-self-heal",
-                                 &self_heal);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (self_heal, &entry_self_heal);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faled for entry-self-heal"
-                                " (given string = %s)",
-                                self_heal);
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option entry"
-                        "-self-heal %s'.", self_heal);
-        }
-
-
-        dict_ret = dict_get_str (options, "strict-readdir",
-                                 &str_readdir);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (str_readdir, &strict_readdir);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faled for strict_readdir "
-                                "(given-string = %s)", str_readdir);
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option strict"
-                        "-readdir %s'.", str_readdir);
-        }
-
-        dict_ret = dict_get_int32 (options, "data-self-heal-window-size",
-                                   &window_size);
-        if (dict_ret == 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "validated data self-heal window size to %d",
-                        window_size);
-
-                if (window_size < 1) {
-                        *op_errstr = gf_strdup ("Error, option should be >= 1");
-                        ret = -1;
-                        goto out;
-                }
-
-                if (window_size > 1024) {
-                        *op_errstr = gf_strdup ("Error, option should be <= 1024");
-                        ret = -1;
-                        goto out;
-                }
-
-
-        }
-
-        dict_ret = dict_get_str (options, "data-change-log",
-                                 &change_log);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (change_log, &data_change_log);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faled for data-change-log");
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option data-"
-                        "change-log %s'.", change_log);
-        }
-
-        dict_ret = dict_get_str (options, "metadata-change-log",
-                                 &change_log);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (change_log,
-                                              &metadata_change_log);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faild for metadata-change-log");
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option metadata-"
-                        "change-log %s'.", change_log);
-        }
-
-        dict_ret = dict_get_str (options, "entry-change-log",
-                                 &change_log);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (change_log, &entry_change_log);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faild for entr-change-log");
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option entry-"
-                                        "change-log %s'.", change_log);
-        }
-
-
-        dict_ret = dict_get_str (options, "optimistic-change-log",
-                                 &change_log);
-        if (dict_ret == 0) {
-                temp_ret = gf_string2boolean (change_log,
-                                              &optimistic_change_log);
-                if (temp_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Validation faled for optimistic-change-log");
-                        *op_errstr = gf_strdup ("Error, option should be "
-                                                "boolean");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated 'option optimistic-"
-                        "change-log %s'.", change_log);
-        }
-
-        dict_ret = dict_get_str (options, "data-self-heal-algorithm",
-                                 &self_heal_algo);
-        if (dict_ret == 0) {
-                /* Handling both strcmp cases - s1 > s2 and s1 < s2 */
-
-                if (!strcmp (self_heal_algo, "full"))
-                        goto next;
-                if (!strcmp (self_heal_algo, "diff"))
-                        goto next;
-
-                gf_log (this->name, GF_LOG_ERROR,
-                        "Invalid self-heal algorithm %s",
-                        self_heal_algo);
-                *op_errstr = gf_strdup ("Error, invalid self-heal "
-                                        "algorithm");
-                ret = -1;
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
                 goto out;
         }
 
-        read_ret = dict_get_str (options, "read-subvolume", &read_subvol);
-
-        if (read_ret)
-                goto next;// No need to traverse, hence set the next option
-
-        trav = this->children;
-        flag = 0;
-        while (trav) {
-                if (!read_ret && !strcmp (read_subvol, trav->xlator->name)) {
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "Validated Subvolume '%s'  as read child.",
-                                trav->xlator->name);
-                        flag = 1;
-                        ret = 0;
-                        goto out;
-                }
-                trav = trav->next;
-        }
-
-        if (flag == 0 ) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "Invalid 'option read-subvolume %s', no such subvolume"
-                        , read_subvol);
-                *op_errstr = gf_strdup ("Error, the sub-volume is not right");
-                ret = -1;
+        if (list_empty (&this->volume_options))
                 goto out;
-        }
-
 
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
+        }
 
-next:
 out:
+
         return ret;
 }
 
@@ -575,8 +325,7 @@  reconfigure (xlator_t *this, dict_t *options)
 				trav->xlator->name);
 
 			flag = 1;
-			ret = -1;
-			goto out;
+                        break;
 		}
 
 
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index 61c43a8..c9b77d6 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -258,36 +258,33 @@  mem_acct_init (xlator_t *this)
 out:
         return ret;
 }
+
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        char            *temp_str = NULL;
-        gf_boolean_t     search_unhashed;
-        int              ret = 0;
-
-        GF_VALIDATE_OR_GOTO ("dht", this, out);
-        GF_VALIDATE_OR_GOTO ("dht", options, out);
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
+
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
+        }
 
-        if (dict_get_str (options, "lookup-unhashed", &temp_str) == 0) {
-                if (strcasecmp (temp_str, "auto")) {
-                        if (!gf_string2boolean (temp_str, &search_unhashed)) {
-                                gf_log(this->name, GF_LOG_DEBUG, "Validated"
-                                       " lookup-unahashed (%s)",
-                                       temp_str);
-                        } else {
-                                gf_log(this->name, GF_LOG_ERROR, "Validation:"
-                                       " lookup-unahashed should be boolean,"
-                                       " not (%s)", temp_str);
-                                *op_errstr = gf_strdup ("Error, lookup-"
-                                                        "unhashed be boolean");
-                                ret = -1;
-                                goto out;
-                        }
+        if (list_empty (&this->volume_options))
+                goto out;
 
-                }
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
 out:
+
         return ret;
 }
 
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index c251de1..64a2621 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3720,43 +3720,32 @@  out:
         return ret;
 }
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
+        }
 
-        data_t           *data = NULL;
-        int               ret = 0;
-        stripe_private_t *priv = NULL;
-
-        data = dict_get (options, "block-size");
-        if (data) {
-                gf_log (this->name, GF_LOG_TRACE,"Reconfiguring Stripe"
-                                " Block-size");
-                priv = GF_CALLOC (1, sizeof (stripe_private_t),
-                                  gf_stripe_mt_stripe_private_t);
-                if (!priv) {
-                        gf_log ("",GF_LOG_ERROR, "Unable to allocate memory");
-                        ret = -1;
-                        goto out;
-                }
+        if (list_empty (&this->volume_options))
+                goto out;
 
-                ret = set_stripe_block_size (this, priv, data->data);
-                if (ret) {
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "Reconfigue: Block-Size reconfiguration failed");
-                        *op_errstr = gf_strdup ("Error, could not parse list");
-                        ret = -1;
-                        goto out;
-                }
-                gf_log (this->name, GF_LOG_TRACE,
-                        "Reconfigue: Block-Size reconfigured Successfully");
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
 out:
-                if (priv)
-                GF_FREE (priv);
-        return ret;
 
+        return ret;
 }
 
 int
@@ -3767,7 +3756,6 @@  reconfigure (xlator_t *this, dict_t *options)
 	data_t           *data = NULL;
 	int 		  ret = 0;
 
-
 	priv = this->private;
 
 	data = dict_get (options, "block-size");
@@ -3787,7 +3775,6 @@  reconfigure (xlator_t *this, dict_t *options)
         else {
                 priv->block_size = (128 * GF_UNIT_KB);
         }
-                        
 
 out:
 	return ret;
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 13173b4..c96603b 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -2541,20 +2541,31 @@  fini (xlator_t *this)
 }
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        int             ret = -1;
-        char            *log_str = NULL;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
+
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
+        }
+
+        if (list_empty (&this->volume_options))
+                goto out;
+
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
+        }
+
+out:
 
-        ret = dict_get_str (options, "log-level", &log_str);
-        if (ret)
-                return 0;
-        ret = glusterd_check_log_level(log_str);
-        if (ret == -1)
-                *op_errstr = gf_strdup ("Invalid log level. possible option are"
-                                    " DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE");
-        else
-                ret = 0;
         return ret;
 }
 int
@@ -2675,6 +2686,7 @@  struct volume_options options[] = {
         },
         { .key = {"log-level"},
           .type = GF_OPTION_TYPE_STR,
+          .value = { "DEBUG", "WARNING", "ERROR", "CRITICAL", "NONE", "TRACE"}
         },
                 { .key  = {NULL} },
 };
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 3ac6f28..036502b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1634,7 +1634,7 @@  nfs_option_handler (glusterfs_graph_t *graph,
 
 
         if (! strcmp (vme->option, "!nfs-disable")) {
-                ret = gf_asprintf (&aa, "nfs3.%s.disable",
+                ret = gf_asprintf (&aa, "nfs.%s.disable",
                                         volinfo->volname);
 
                 if (ret != -1) {
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 8df7c13..150fa23 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -603,47 +603,31 @@  free_nfs:
 }
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        char         *str=NULL;
-        gf_boolean_t  nfs_ino32;
-        data_t       *data = NULL;
-        long long     lng = 0;
-        int           ret = 0;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
-
-
-        ret = dict_get_str (options, "nfs.enable-ino32", 
-                            &str);
-        if (ret == 0) {
-                ret = gf_string2boolean (str, 
-                                         &nfs_ino32);
-                if (ret == -1) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "'nfs.enable-ino32' takes only boolean"
-                                " arguments");
-                        *op_errstr = gf_strdup ("Error, should be boolean");
-                        ret = -1;
-                        goto out;
-                }
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
         }
 
-        data = dict_get (options, "nfs.mem-factor");
-        if (data) {
-                if (gf_string2longlong (data->data, &lng) != 0) {
-                        gf_log (this->name, GF_LOG_ERROR, "invalid number format"
-                                                        "\"%s\" in option "
-                                                        "\"nfs.mem-factor\" ",
-                                data->data );
-                        *op_errstr = gf_strdup ("Error, Invalid number format");
-                        ret = -1;
-                        goto out;
-                }
+        if (list_empty (&this->volume_options))
+                goto out;
+
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+        list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret =0;
 out:
-                return ret;
+        return ret;
 
 }
 
@@ -944,7 +928,7 @@  struct volume_options options[] = {
                          "Please consult gluster-users list before using this "
                          "option."
         },
-        { .key  = {"nfs3.*.disable"},
+        { .key  = {"nfs.*.disable"},
           .type = GF_OPTION_TYPE_BOOL,
           .description = "This option is used to start or stop NFS server"
                          "for individual volume."
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 738bd66..a3ebaf4 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1497,144 +1497,32 @@  mem_acct_init (xlator_t *this)
 }
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        int32_t          cache_timeout;
-        int64_t          min_file_size = 0;
-        int64_t          max_file_size = 0;
-        char            *tmp = NULL;
-        uint64_t         cache_size;
-        char            *cache_size_string = NULL;
-        int              ret = 0;
-
-
-        if (dict_get (options, "cache-timeout")) {
-                cache_timeout = data_to_uint32 (dict_get (options,
-                                "cache-timeout"));
-                if (cache_timeout < 0){
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "cache-timeout %d seconds invalid,"
-                                                " has to be  >=0", cache_timeout);
-                        *op_errstr = gf_strdup ("Error, should be >= 0");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                if (cache_timeout > 60){
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "cache-timeout %d seconds invalid,"
-                                                " has to be  <=60", cache_timeout);
-                        *op_errstr = gf_strdup ("Error, should be <= 60");
-                        ret = -1;
-                        goto out;
-                }
-
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Validated cache-timeout revalidate cache");
-        }
-
-
-        if (dict_get (options, "cache-size"))
-                cache_size_string = data_to_str (dict_get (options,
-                                "cache-size"));
-        if (cache_size_string) {
-                if (gf_string2bytesize (cache_size_string,
-                    &cache_size) != 0) {
-                            gf_log ("io-cache", GF_LOG_ERROR,
-                                    "invalid number format \"%s\" of "
-                                    "\"option cache-size\" Defaulting"
-                                    "to old value", cache_size_string);
-                            *op_errstr = gf_strdup ("Error, Invalid Format");
-                            ret = -1;
-                            goto out;
-                    }
-
-                    if (cache_size < ( 4 * GF_UNIT_MB)) {
-                            gf_log(this->name, GF_LOG_WARNING, "Reconfiguration"
-                                   "'option cache-size %s' failed , Max value"
-                                   "can be 4MiB, Defaulting to old value "
-                                   "(%"PRIu64")", cache_size_string,
-                                   cache_size);
-                            *op_errstr = gf_strdup ("Error, "
-                                                    "Cannot be less than 4MB");
-                            ret = -1;
-                            goto out;
-                    }
-
-                    if (cache_size > ( 6 * GF_UNIT_GB)) {
-                            gf_log(this->name, GF_LOG_WARNING, "Validation"
-                                   "'option cache-size %s' failed , Max value"
-                                   "can be 6GiB, Defaulting to old value "
-                                   "(%"PRIu64")", cache_size_string,
-                                   cache_size);
-                            *op_errstr = gf_strdup ("Error, Cannot be more "
-                                                    "than 6GB");
-                            ret = -1;
-                            goto out;
-                    }
-
-
-                    gf_log (this->name, GF_LOG_DEBUG, "Validated "
-                            " cache-size %"PRIu64"", cache_size);
-        }
-
-
-        tmp = data_to_str (dict_get (options, "min-file-size"));
-        if (tmp != NULL) {
-                if (gf_string2bytesize (tmp,
-                    (uint64_t *)&min_file_size)
-                    != 0) {
-                        gf_log ("io-cache", GF_LOG_WARNING,
-                                "invalid number format \"%s\" of "
-                                                "\"option min-file-size\"", tmp);
-                        *op_errstr = gf_strdup ("Error, Invalid Format");
-                        ret = -1;
-                        goto out;
-                    }
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
-                    gf_log (this->name, GF_LOG_DEBUG,
-                            "Validated min-file-size %"PRIu64"",
-                            min_file_size);
-        }
-
-
-        tmp = data_to_str (dict_get (options, "max-file-size"));
-        if (tmp != NULL) {
-                if (gf_string2bytesize (tmp,
-                    (uint64_t *)&max_file_size)
-                    != 0) {
-                        gf_log ("io-cache", GF_LOG_WARNING,
-                                "invalid number format \"%s\" of "
-                                                "\"option max-file-size\"", tmp);
-                        *op_errstr = gf_strdup ("Error, Invalid Format");
-                        ret = -1;
-                        goto out;
-                    }
-
-
-                    gf_log (this->name, GF_LOG_WARNING,
-                            "Validated max-file-size %"PRIu64"",
-                            max_file_size);
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
         }
 
-        if ((max_file_size >= 0) & (min_file_size > max_file_size)) {
-                gf_log ("io-cache", GF_LOG_WARNING, "minimum size (%"
-                                PRIu64") of a file that can be cached is "
-                                                "greater than maximum size (%"PRIu64"). ",
-                                                min_file_size, max_file_size);
-                *op_errstr = gf_strdup ("Error, min-file-size greater"
-                                "than max-file-size");
-                ret = -1;
+        if (list_empty (&this->volume_options))
                 goto out;
-        }
 
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
+        }
 
 out:
-                return ret;
 
+        return ret;
 }
 
 int
@@ -1664,7 +1552,6 @@  reconfigure (xlator_t *this, dict_t *options)
 				gf_log (this->name, GF_LOG_WARNING,
 					"cache-timeout %d seconds invalid,"
 					" has to be  >=0", cache_timeout);
-				ret = -1;
 				goto out;
 			}
 
@@ -1673,7 +1560,6 @@  reconfigure (xlator_t *this, dict_t *options)
 				gf_log (this->name, GF_LOG_WARNING,
 				"cache-timeout %d seconds invalid,"
 				" has to be  <=60", cache_timeout);
-				ret = -1;
 				goto out;
 			}
 
@@ -1698,7 +1584,6 @@  reconfigure (xlator_t *this, dict_t *options)
 					"invalid number format \"%s\" of "
 					"\"option cache-size\" Defaulting"
 					"to old value", cache_size_string);
-                        	ret = -1;
 				goto out;
 			}
 
@@ -1709,7 +1594,6 @@  reconfigure (xlator_t *this, dict_t *options)
                                        "Max value can be 4MiB, Defaulting to "
                                        "old value (%"PRIu64")",
                                        cache_size_string, table->cache_size);
-				ret = -1;
 				goto out;
        		        }
 
@@ -1720,7 +1604,6 @@  reconfigure (xlator_t *this, dict_t *options)
                                         "Max value can be 6GiB, Defaulting to "
                                         "old value (%"PRIu64")",
                                         cache_size_string, table->cache_size);
-				ret = -1;
 				goto out;
                 	}
 
@@ -1794,7 +1677,6 @@  reconfigure (xlator_t *this, dict_t *options)
                                 "greater than maximum size (%"PRIu64"). "
 				"Hence Defaulting to old value",
                                 table->min_file_size, table->max_file_size);
-                        ret = -1;
 			goto out;
 		}
 
@@ -2066,13 +1948,9 @@  struct volume_options options[] = {
 	},
         { .key  = {"min-file-size"},
           .type = GF_OPTION_TYPE_SIZET,
-          .min  = -1,
-          .max  = -1
         },
         { .key  = {"max-file-size"},
           .type = GF_OPTION_TYPE_SIZET,
-          .min  = -1,
-          .max  = -1
         },
 	{ .key = {NULL} },
 };
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 09b240e..bdc8083 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2081,35 +2081,29 @@  mem_acct_init (xlator_t *this)
 
 
 int
-validate_options ( xlator_t *this, dict_t *options, char **op_errstr)
+validate_options ( xlator_t *this, char **op_errstr)
 {
-        int              ret = 0;
-        int              thread_count;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
+        }
 
-        if (dict_get (options, "thread-count")) {
-                thread_count = data_to_int32 (dict_get (options,
-                                              "thread-count"));
-
-                if (thread_count < IOT_MIN_THREADS) {
-                        gf_log ("io-threads", GF_LOG_DEBUG,
-                                "volume set thread_count WRONG,it is lesser");
-                        ret = -1;
-                        *op_errstr = gf_strdup ("LESSER Than min. threads");
-                        goto out;
-                }
+        if (list_empty (&this->volume_options))
+                goto out;
 
-                if (thread_count > IOT_MAX_THREADS) {
-                        gf_log ("io-threads", GF_LOG_DEBUG,
-                                "volume set thread_count WRONG,it is greater");
-                        *op_errstr = gf_strdup ("GREATER than max. threads");
-                        ret = -1;
-                        goto out;
-                }
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret = 0;
-
 out:
         return ret;
 }
@@ -2119,7 +2113,7 @@  int
 reconfigure ( xlator_t *this, dict_t *options)
 {
 	iot_conf_t      *conf = NULL;
-	int		 ret = -1;
+	int		 ret = 0;
 	int		 thread_count;
 
         conf = this->private;
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 044b00f..4658810 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -3172,64 +3172,29 @@  mem_acct_init (xlator_t *this)
 
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        char         *str           = NULL;
-        int32_t       ret           = -1;
-        int32_t       cache_timeout = 0;
-        uint64_t      cache_size    = 0;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
         if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
                 goto out;
         }
 
-        ret = dict_get_str (this->options, "cache-timeout", &str);
-        if (ret == 0) {
-                ret = gf_string2uint_base10 (str,
-                                             (unsigned int *)&cache_timeout);
-                if (ret != 0) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "invalid cache-timeout value %s", str);
-                        *op_errstr = "Invalid Format!!";
-                        ret = -1;
-                        goto out;
-                }
-                if (ret < 1  || ret > 60) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "invalid cache-timeout value %s", str);
-                        *op_errstr = "Range 1 <= value <= 60";
-                        ret = -1;
-                        goto out;
-                }
-        }
-
-        ret = dict_get_str (this->options, "cache-size", &str);
-        if (ret == 0) {
-                ret = gf_string2bytesize (str, &cache_size);
-                if (ret != 0) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "invalid cache-size value %s", str);
-                        ret = -1;
-                        goto out;
-                }
-                if (cache_size > 6 * GF_UNIT_GB) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "invalid cache-size value %s", str);
-                        *op_errstr = "Range 4mb <= value <= 6gb";
-                        ret = -1;
-                        goto out;
-                }
-                if (cache_size < 4* GF_UNIT_MB) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "invalid cache-size value %s", str);
-                        *op_errstr = "Range 4mb <= value <= 6gb";
-                        ret = -1;
-                        goto out;
-                }
+        if (list_empty (&this->volume_options))
+                goto out;
 
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret =0;
 out:
         return ret;
 }
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 61d4c31..cdc8896 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2867,65 +2867,34 @@  out:
 
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        char         *str          = NULL;
-        uint64_t      window_size  = 0;;
-        gf_boolean_t  flush_behind = 0;
-        int           ret          = 0;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
-        ret = dict_get_str (options, "cache-size", &str);
-        if (ret == 0) {
-                ret = gf_string2bytesize (str, &window_size);
-                if (ret != 0) {
-                        gf_log(this->name, GF_LOG_WARNING, "Validation"
-                               "'option cache-size %s failed , Invalid"
-                               " number format, ", str);
-                        *op_errstr = gf_strdup ("Error, Invalid num format");
-                        ret = -1;
-                        goto out;
-                }
-
-                if (window_size < (512 * GF_UNIT_KB)) {
-                        gf_log(this->name, GF_LOG_WARNING, "Validation"
-                               "'option cache-size %s' failed , Min value"
-                               "should be 512KiB ", str);
-                        *op_errstr = gf_strdup ("Error, Should be min 512KB");
-                        ret = -1;
-                        goto out;
-                }
-
-                if (window_size > (1 * GF_UNIT_GB)) {
-                        gf_log(this->name, GF_LOG_WARNING, "Reconfiguration"
-                               "'option cache-size %s' failed , Max value"
-                               "can be 1 GiB", str);
-                        *op_errstr = gf_strdup ("Error, Max Value is 1GB");
-                        ret = -1;
-                        goto out;
-                }
-
-                gf_log(this->name, GF_LOG_WARNING,
-                       "validated 'option cache-size %s '", str);
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
         }
 
-        ret = dict_get_str (options, "flush-behind", &str);
-        if (ret == 0) {
-                ret = gf_string2boolean (str, &flush_behind);
-                if (ret == -1) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "'flush-behind' takes only boolean arguments");
-                        *op_errstr = gf_strdup ("Error, should be boolean");
-                        ret = -1;
-                        goto out;
-                }
+        if (list_empty (&this->volume_options))
+                goto out;
+
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+        list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret =0;
 out:
+
         return ret;
 }
 
-
 int
 reconfigure (xlator_t *this, dict_t *options)
 {
@@ -2944,8 +2913,7 @@  reconfigure (xlator_t *this, dict_t *options)
                                "'option cache-size %s failed , Invalid"
                                " number format, Defaulting to old value "
                                "(%"PRIu64")", str, conf->window_size);
-                        ret = -1;
-                        goto out;
+			goto out;
                 }
 
                 if (window_size < (512 * GF_UNIT_KB)) {
@@ -2953,8 +2921,7 @@  reconfigure (xlator_t *this, dict_t *options)
                                "'option cache-size %s' failed , Max value"
                                "can be 512KiB, Defaulting to old value "
                                "(%"PRIu64")", str, conf->window_size);
-                        ret = -1;
-                        goto out;
+			goto out;
                 }
 
                 if (window_size > (2 * GF_UNIT_GB)) {
@@ -2962,8 +2929,7 @@  reconfigure (xlator_t *this, dict_t *options)
                                "'option cache-size %s' failed , Max value"
                                "can be 1 GiB, Defaulting to old value "
                                "(%"PRIu64")", str, conf->window_size);
-                        ret = -1;
-                        goto out;
+			goto out;
                 }
 
                 conf->window_size = window_size;
@@ -2981,7 +2947,7 @@  reconfigure (xlator_t *this, dict_t *options)
                         gf_log (this->name, GF_LOG_ERROR,
                                 "'flush-behind' takes only boolean arguments");
                         conf->flush_behind = 1;
-                        return -1;
+                        goto out;
                 }
 
                 if (conf->flush_behind) {
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 3082656..22394f5 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -2076,72 +2076,31 @@  out:
 }
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
 {
-        int     ret = 0;
-        int     timeout_ret=0;
-        int     ping_timeout;
-        int     frame_timeout;
-
-
-        timeout_ret = dict_get_int32 (options, "frame-timeout",
-                                      &frame_timeout);
-        if (timeout_ret == 0) {
-                if (frame_timeout < 5 ) {
-                        gf_log (this->name, GF_LOG_WARNING, "validation of "
-                                "'option frame-timeout %d failed, min value"
-                                " can be 5", frame_timeout);
-                        *op_errstr = gf_strdup ("Error, Min Value 5");
-                        ret = -1;
-                        goto out;
-                }
-
-                if (frame_timeout > 86400 ) {
-                        gf_log (this->name, GF_LOG_WARNING, "reconfiguration of"
-                                " 'option frame-timeout %d failed , max value "
-                                "can be 86400", frame_timeout );
-                        *op_errstr = gf_strdup ("Error, Max Value 86400");
-                        ret = -1;
-                        goto out;
-                }
-
-
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "validation otion frame-timeout to %d",
-                        frame_timeout);
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
+                goto out;
         }
 
-        timeout_ret = dict_get_int32 (options, "ping-timeout",
-                                      &ping_timeout);
-        if (timeout_ret == 0) {
-
-                if (ping_timeout < 5 ) {
-                        gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
-                                " 'option ping-timeout %d failed , Min value"
-                                " can be 5", ping_timeout);
-                        *op_errstr = gf_strdup ("Error, Min Value 5");
-                        ret = -1;
-                        goto out;
-                }
-
-                if (ping_timeout > 1013 ) {
-                        gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
-                                " 'option frame-timeout %d failed , Max value"
-                                " can be 1013,", frame_timeout);
-                        *op_errstr =  gf_strdup ("Error, Max Value 1013");
-                        ret = -1;
-                        goto out;
-                }
-
-                gf_log (this->name, GF_LOG_DEBUG, "Validated "
-                        "'option ping-timeout' to %d", ping_timeout);
+        if (list_empty (&this->volume_options))
+                goto out;
 
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+        list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret = 0;
-
 out:
+
         return ret;
 }
 
@@ -2169,7 +2128,6 @@  reconfigure (xlator_t *this, dict_t *options)
 			      "'option frame-timeout %d failed , Min value"
 			      " can be 5, Defaulting to old value (%d)"
 			      , frame_timeout, conf->rpc_conf.rpc_timeout);
-			ret = -1;
 			goto out;
 		}
 
@@ -2178,7 +2136,6 @@  reconfigure (xlator_t *this, dict_t *options)
 			      "'option frame-timeout %d failed , Max value"
 			      "can be 3600, Defaulting to old value (%d)"
 			      , frame_timeout, conf->rpc_conf.rpc_timeout);
-			ret = -1;
 			goto out;
 		}
 
@@ -2201,7 +2158,6 @@  reconfigure (xlator_t *this, dict_t *options)
 			      "'option ping-timeout %d failed , Min value"
 			      " can be 5, Defaulting to old value (%d)"
 			      , ping_timeout, conf->opt.ping_timeout);
-			ret = -1;
 			goto out;
 		}
 
@@ -2210,7 +2166,6 @@  reconfigure (xlator_t *this, dict_t *options)
 			      "'option ping-timeout %d failed , Max value"
 			      "can be 1013, Defaulting to old value (%d)"
 			      , ping_timeout, conf->opt.ping_timeout);
-			ret = -1;
 			goto out;
 		}
 
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index c1bcf61..7361271 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -472,66 +472,34 @@  out:
 }
 
 int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options ( xlator_t *this, char **op_errstr)
 {
-        int               inode_lru_limit = 0;
-        char              errstr[1024] = {0, };
-        dict_t           *auth_modules =  NULL;
-        int               ret = 0;
-        data_t           *data;
-        gf_boolean_t      trace;
+        int                 ret = 0;
+        volume_opt_list_t  *vol_opt = NULL;
+        volume_opt_list_t  *tmp;
 
-        if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){
-                if (!(inode_lru_limit < (1 * GF_UNIT_MB)  &&
-                      inode_lru_limit >1 )) {
-                        gf_log (this->name, GF_LOG_INFO, "Validate inode-lru"
-                                "-limit %d, was WRONG", inode_lru_limit);
-                        snprintf (errstr,1024, "Error, Greater than max value %d "
-                                  ,inode_lru_limit);
-
-                        *op_errstr = gf_strdup (errstr);
-                        ret = -1;
-                        goto out;
-                }
-        }
-
-        data = dict_get (options, "trace");
-        if (data) {
-                ret = gf_string2boolean (data->data, &trace);
-                if (ret != 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "'trace' takes on only boolean values. "
-                                "Neglecting option");
-                        snprintf (errstr,1024, "Error, trace takes only boolean"
-                                  "values");
-                        *op_errstr = gf_strdup (errstr);
-                        ret = -1;
-                        goto out;
-                }
-        }
-
-        auth_modules = dict_new ();
-        if (!auth_modules) {
-                ret = -1;
+        if (!this) {
+                gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+                ret =-1;
                 goto out;
         }
 
-        dict_foreach (options, get_auth_types, auth_modules);
-        ret = validate_auth_options (this, options);
-        if (ret == -1) {
-                /* logging already done in validate_auth_options function. */
-                snprintf (errstr,1024, "authentication values are incorrect");
-                *op_errstr = gf_strdup (errstr);
+        if (list_empty (&this->volume_options))
                 goto out;
+
+        vol_opt = list_entry (this->volume_options.next,
+                                      volume_opt_list_t, list);
+         list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+                ret = validate_xlator_volume_options_attacherr (this,
+                                                                vol_opt->given_opt,
+                                                                op_errstr);
         }
 
-        ret = gf_auth_init (this, auth_modules);
 out:
-        if (auth_modules)
-                dict_unref (auth_modules);
 
         return ret;
 }
+
 static void
 _delete_auth_opt (dict_t *this,
                 char *key,