summaryrefslogtreecommitdiffstats
path: root/xlators/performance/quick-read/src/quick-read.c
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-10-05 07:02:07 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-05 05:47:38 -0700
commit6b74f3ec7b6e0fed2e253df456b067fc27049117 (patch)
treea4f51f043b8d169bf1be46e7b482fca9f3d29d77 /xlators/performance/quick-read/src/quick-read.c
parent7aec50bdad06665243a16f1ce83a03037bcd5d56 (diff)
Reply back to CLI on error, by validating each xlator's opts
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'xlators/performance/quick-read/src/quick-read.c')
-rw-r--r--xlators/performance/quick-read/src/quick-read.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 6751089b3..91243561e 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)
{