From 6b74f3ec7b6e0fed2e253df456b067fc27049117 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Tue, 5 Oct 2010 07:02:07 +0000 Subject: Reply back to CLI on error, by validating each xlator's opts Signed-off-by: Kaushik BV Signed-off-by: Vijay Bellur BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159 --- xlators/performance/quick-read/src/quick-read.c | 85 +++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'xlators/performance/quick-read/src') diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 6751089b331..91243561e3c 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -2411,6 +2411,91 @@ mem_acct_init (xlator_t *this) } +int +validate_options (xlator_t *this, dict_t *options, char **op_errstr) +{ + char *str = NULL; + int32_t ret = -1; + int32_t cache_timeout; + + if (!this) + 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 =0; +out: + return ret; + +} + +int +reconfigure (xlator_t *this, dict_t *options) +{ + + + + char *str = NULL; + int32_t ret = -1; + qr_private_t *priv = NULL; + qr_conf_t *conf = NULL; + int32_t cache_timeout; + + if (!this) + goto out; + + priv = this->private; + if (!priv) + goto out; + + conf = &priv->conf; + if (!conf) + goto out; + + cache_timeout = conf->cache_timeout; + ret = dict_get_str (this->options, "cache-timeout", &str); + if (ret == 0) { + ret = gf_string2uint_base10 (str, + (unsigned int *)&conf->cache_timeout); + if (ret != 0) { + gf_log (this->name, GF_LOG_ERROR, + "invalid cache-timeout value %s", str); + ret = -1; + goto out; + } + conf->cache_timeout = cache_timeout; + } + else + conf->cache_timeout = 1; + + ret = 0; +out: + return ret; + +} + + int32_t qr_get_priority_list (const char *opt_str, struct list_head *first) { -- cgit