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 --- .../performance/write-behind/src/write-behind.c | 72 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'xlators/performance/write-behind/src/write-behind.c') diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index db3ca28be..ef596dfbe 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -2727,6 +2727,71 @@ mem_acct_init (xlator_t *this) return ret; } +int +validate_options (xlator_t *this, dict_t *options, char **op_errstr) +{ + char *str=NULL; + uint64_t window_size; + gf_boolean_t flush_behind; + + int ret = 0; + + + + 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 < (524288)) { + 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 > (1073741824)) { + 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_DEBUG, "Validated " + "'option cache-size %s '", str); + } + 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; + } + } + ret =0; +out: + return ret; + +} + int reconfigure (xlator_t *this, dict_t *options) { @@ -2750,7 +2815,7 @@ reconfigure (xlator_t *this, dict_t *options) goto out; } - if (window_size < (2^19)) { + if (window_size < (512 * GF_UNIT_KB)) { gf_log(this->name, GF_LOG_ERROR, "Reconfiguration" "'option cache-size %s' failed , Max value" "can be 512KiB, Defaulting to old value (%d)" @@ -2759,7 +2824,7 @@ reconfigure (xlator_t *this, dict_t *options) goto out; } - if (window_size > (2^30)) { + if (window_size > (2 * GF_UNIT_GB)) { gf_log(this->name, GF_LOG_ERROR, "Reconfiguration" "'option cache-size %s' failed , Max value" "can be 1 GiB, Defaulting to old value (%d)" @@ -2773,6 +2838,9 @@ reconfigure (xlator_t *this, dict_t *options) "'option cache-size %s ' to %d" , str, conf->window_size); } + else + conf->window_size = WB_WINDOW_SIZE; + out: return 0; -- cgit