From 9bd4f25b6b0ea8103324b685fcc21525a29849a8 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Wed, 23 Mar 2011 00:50:17 +0000 Subject: CLI : Validate options farmework. Signed-off-by: Gaurav Signed-off-by: Vijay Bellur BUG: 2064 (NFS options are removed upon glusterd restart) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2064 --- xlators/performance/quick-read/src/quick-read.c | 63 ++++++------------------- 1 file changed, 14 insertions(+), 49 deletions(-) (limited to 'xlators/performance/quick-read/src/quick-read.c') diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 044b00fd5..465881080 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; } -- cgit