summaryrefslogtreecommitdiffstats
path: root/xlators/performance/write-behind/src
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/write-behind/src
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/write-behind/src')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c72
1 files changed, 70 insertions, 2 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index db3ca28be35..ef596dfbeaa 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2728,6 +2728,71 @@ mem_acct_init (xlator_t *this)
}
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)
{
char *str=NULL;
@@ -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;