summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli3_1-cops.c2
-rw-r--r--xlators/cluster/afr/src/afr.c239
-rw-r--r--xlators/cluster/dht/src/dht.c39
-rw-r--r--xlators/cluster/stripe/src/stripe.c43
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c2
-rw-r--r--xlators/performance/io-cache/src/io-cache.c146
-rw-r--r--xlators/performance/io-threads/src/io-threads.c42
-rw-r--r--xlators/performance/quick-read/src/quick-read.c85
-rw-r--r--xlators/performance/write-behind/src/write-behind.c72
-rw-r--r--xlators/protocol/client/src/client.c71
-rw-r--r--xlators/protocol/server/src/server.c79
12 files changed, 818 insertions, 7 deletions
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index bc98d2c942e..69c19e75a53 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -1697,7 +1697,7 @@ gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t *this,
&req.dict.dict_val,
(size_t *)&req.dict.dict_len);
if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_ERROR,
"failed to get serialized length of dict");
goto out;
}
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 813fbb24904..b026db594ca 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -59,7 +59,242 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+
+
+ gf_boolean_t metadata_self_heal;
+ gf_boolean_t entry_self_heal;
+ gf_boolean_t data_self_heal;
+ gf_boolean_t data_change_log;
+ gf_boolean_t metadata_change_log;
+ gf_boolean_t entry_change_log;
+ gf_boolean_t strict_readdir;
+
+ xlator_list_t * trav = NULL;
+
+ char * read_subvol = NULL;
+ char * self_heal = NULL;
+ char * change_log = NULL;
+ char * str_readdir = NULL;
+ int32_t background_count = 0;
+ int32_t window_size = 0;
+
+ int read_ret = -1;
+ int dict_ret = -1;
+ int flag = 1;
+ int ret = 0;
+ int temp_ret = -1;
+
+
+
+ dict_ret = dict_get_int32 (options, "background-self-heal-count",
+ &background_count);
+ if (dict_ret == 0) {
+ if (background_count < 0) {
+ *op_errstr = gf_strdup ("Error, option should be >= 0");
+ ret = -1;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validated background self-heal count to %d",
+ background_count);
+ }
+
+ dict_ret = dict_get_str (options, "metadata-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &metadata_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "validation failed 'option metadata"
+ "-self-heal %s'.not correct.",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+
+ }
+
+ dict_ret = dict_get_str (options, "data-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &data_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation failed for data self heal",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring 'option data"
+ "-self-heal %s'.", self_heal);
+ }
+
+ dict_ret = dict_get_str (options, "entry-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &entry_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for entry-self-heal",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option entry"
+ "-self-heal %s'.", self_heal);
+ }
+
+
+ dict_ret = dict_get_str (options, "strict-readdir",
+ &str_readdir);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (str_readdir, &strict_readdir);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for strict_readdir",
+ str_readdir);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option strict"
+ "-readdir %s'.", str_readdir);
+ }
+
+ dict_ret = dict_get_int32 (options, "data-self-heal-window-size",
+ &window_size);
+ if (dict_ret == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validated data self-heal window size to %d",
+ window_size);
+
+ if (window_size < 0) {
+ *op_errstr = gf_strdup ("Error, option should be >= 0");
+ ret = -1;
+ goto out;
+ }
+
+ if (window_size > 1024) {
+ *op_errstr = gf_strdup ("Error, option should be <= 1024");
+ ret = -1;
+ goto out;
+ }
+
+
+ }
+
+ dict_ret = dict_get_str (options, "data-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log, &data_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for data-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option data-"
+ "change-log %s'.", change_log);
+ }
+
+ dict_ret = dict_get_str (options, "metadata-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log,
+ &metadata_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faild for metadata-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option metadata-"
+ "change-log %s'.", change_log);
+ }
+
+ dict_ret = dict_get_str (options, "entry-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log, &entry_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faild for entr-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option entry-"
+ "change-log %s'.", change_log);
+ }
+
+ read_ret = dict_get_str (options, "read-subvolume", &read_subvol);
+
+ if (read_ret)
+ goto next;// No need to traverse, hence set the next option
+
+ trav = this->children;
+ flag = 0;
+ while (trav) {
+ if (!read_ret && !strcmp (read_subvol, trav->xlator->name)) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated Subvolume '%s' as read child.",
+ trav->xlator->name);
+
+ flag = 1;
+ ret = 0;
+ goto out;
+ }
+
+
+ trav = trav->next;
+ }
+
+ if (flag == 0 ) {
+
+ gf_log (this->name, GF_LOG_WARNING,
+ "Invalid 'option read-subvolume %s', no such subvolume"
+ , read_subvol);
+ *op_errstr = gf_strdup ("Error, the sub-volume is not right");
+ ret = -1;
+ goto out;
+ }
+
+next:
+out:
+ return ret;
+
+
+}
int
@@ -190,6 +425,10 @@ reconfigure (xlator_t *this, dict_t *options)
priv->data_self_heal_window_size = window_size;
}
+ else {
+ priv->data_self_heal_window_size = 16;
+ }
+
dict_ret = dict_get_str (options, "data-change-log",
&change_log);
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index 2c2f1750755..2c8f2e9a224 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -250,6 +250,45 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ char *temp_str = NULL;
+ gf_boolean_t search_unhashed;
+ int ret = 0;
+
+
+
+
+
+ if (dict_get_str (options, "lookup-unhashed", &temp_str) == 0) {
+ if (strcasecmp (temp_str, "auto")) {
+ if (!gf_string2boolean (temp_str, &search_unhashed)) {
+ gf_log(this->name, GF_LOG_DEBUG, "Validated"
+ " lookup-unahashed (%s)",
+ temp_str);
+ }
+ else {
+ gf_log(this->name, GF_LOG_ERROR, "Validation:"
+ " lookup-unahashed should be boolean,"
+ " not (%s)",
+ temp_str);
+ *op_errstr = gf_strdup ("Error, lookup-"
+ "unhashed be boolean");
+ ret = -1;
+ goto out;
+ }
+
+ }
+ }
+
+
+
+
+
+out:
+ return ret;
+}
int
reconfigure (xlator_t *this, dict_t *options)
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index 4eb6aebea6e..a8ac55aa4a2 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3735,6 +3735,45 @@ mem_acct_init (xlator_t *this)
out:
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+
+
+ data_t *data = NULL;
+ int ret = 0;
+ stripe_private_t *priv = NULL;
+
+ data = dict_get (options, "block-size");
+ if (data) {
+ gf_log (this->name, GF_LOG_TRACE,"Reconfiguring Stripe"
+ " Block-size");
+ priv = GF_CALLOC (1, sizeof (stripe_private_t),
+ gf_stripe_mt_stripe_private_t);
+ if (!priv) {
+ gf_log ("",GF_LOG_ERROR, "Unable to allocate memory");
+ ret = -1;
+ goto out;
+ }
+
+ ret = set_stripe_block_size (this, priv, data->data);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfigue: Block-Size reconfiguration failed");
+ *op_errstr = gf_strdup ("Error, could not parse list");
+ ret = -1;
+ goto out;
+ }
+ gf_log (this->name, GF_LOG_TRACE,
+ "Reconfigue: Block-Size reconfigured Successfully");
+ }
+
+out:
+ if (priv)
+ GF_FREE (priv);
+ return ret;
+
+}
int
reconfigure (xlator_t *this, dict_t *options)
@@ -3761,6 +3800,10 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_TRACE,
"Reconfigue: Block-Size reconfigured Successfully");
}
+ else {
+ priv->block_size = (128 * GF_UNIT_KB);
+ }
+
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index c337655857f..448dd65348d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1259,9 +1259,8 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
- "failed to "
- "unserialize req-buffer to dictionary");
+ gf_log ("glusterd", GF_LOG_ERROR, "failed to "
+ "unserialize req-buffer to dictionary");
goto out;
} else {
dict->extra_stdfree = cli_req.dict.dict_val;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 30f0514a9d5..b7513d87a24 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1054,7 +1054,7 @@ glusterd_store_retrieve_volume (char *volname)
key, value);
}
else
- gf_log ("", GF_LOG_DEBUG, "Unknown key: %s",
+ gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
key);
}
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index e95b5cfd21b..b094f97c4ef 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1476,6 +1476,143 @@ mem_acct_init (xlator_t *this)
}
int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int32_t cache_timeout;
+ int64_t min_file_size = 0;
+ int64_t max_file_size = 0;
+ char *tmp = NULL;
+ uint64_t cache_size;
+ char *cache_size_string = NULL;
+ int ret = 0;
+
+
+ if (dict_get (options, "cache-timeout")) {
+ cache_timeout = data_to_uint32 (dict_get (options,
+ "cache-timeout"));
+ if (cache_timeout < 0){
+ gf_log (this->name, GF_LOG_WARNING,
+ "cache-timeout %d seconds invalid,"
+ " has to be >=0", cache_timeout);
+ *op_errstr = gf_strdup ("Error, should be >= 0");
+ ret = -1;
+ goto out;
+ }
+
+
+ if (cache_timeout > 60){
+ gf_log (this->name, GF_LOG_WARNING,
+ "cache-timeout %d seconds invalid,"
+ " has to be <=60", cache_timeout);
+ *op_errstr = gf_strdup ("Error, should be <= 60");
+ ret = -1;
+ goto out;
+ }
+
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated cache-timeout revalidate cache");
+ }
+
+
+ if (dict_get (options, "cache-size"))
+ cache_size_string = data_to_str (dict_get (options,
+ "cache-size"));
+ if (cache_size_string) {
+ if (gf_string2bytesize (cache_size_string,
+ &cache_size) != 0) {
+ gf_log ("io-cache", GF_LOG_ERROR,
+ "invalid number format \"%s\" of "
+ "\"option cache-size\" Defaulting"
+ "to old value", cache_size_string);
+ *op_errstr = gf_strdup ("Error, Invalid Format");
+ ret = -1;
+ goto out;
+ }
+
+ if (cache_size < ( 4 * GF_UNIT_MB)) {
+ gf_log(this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option cache-size %s' failed , Max value"
+ "can be 4MiB, Defaulting to old value (%d)"
+ , cache_size_string, cache_size);
+ *op_errstr = gf_strdup ("Error, Cannot be less than 4MB");
+ ret = -1;
+ goto out;
+ }
+
+ if (cache_size > ( 6 * GF_UNIT_GB)) {
+ gf_log(this->name, GF_LOG_WARNING, "Validation"
+ "'option cache-size %s' failed , Max value"
+ "can be 6GiB, Defaulting to old value (%d)"
+ , cache_size_string, cache_size);
+ *op_errstr = gf_strdup ("Error, Cannot be more than 6GB");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG, "Validated "
+ " cache-size %"PRIu64"", cache_size);
+ }
+
+
+ tmp = data_to_str (dict_get (options, "min-file-size"));
+ if (tmp != NULL) {
+ if (gf_string2bytesize (tmp,
+ (uint64_t *)&min_file_size)
+ != 0) {
+ gf_log ("io-cache", GF_LOG_WARNING,
+ "invalid number format \"%s\" of "
+ "\"option min-file-size\"", tmp);
+ *op_errstr = gf_strdup ("Error, Invalid Format");
+ ret = -1;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated min-file-size %"PRIu64"",
+ min_file_size);
+ }
+
+
+ tmp = data_to_str (dict_get (options, "max-file-size"));
+ if (tmp != NULL) {
+ if (gf_string2bytesize (tmp,
+ (uint64_t *)&max_file_size)
+ != 0) {
+ gf_log ("io-cache", GF_LOG_WARNING,
+ "invalid number format \"%s\" of "
+ "\"option max-file-size\"", tmp);
+ *op_errstr = gf_strdup ("Error, Invalid Format");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validated max-file-size %"PRIu64"",
+ max_file_size);
+ }
+
+ if ((max_file_size >= 0) & (min_file_size > max_file_size)) {
+ gf_log ("io-cache", GF_LOG_WARNING, "minimum size (%"
+ PRIu64") of a file that can be cached is "
+ "greater than maximum size (%"PRIu64"). ",
+ min_file_size, max_file_size);
+ *op_errstr = gf_strdup ("Error, min-file-size greater"
+ "than max-file-size");
+ ret = -1;
+ goto out;
+ }
+
+
+out:
+ return ret;
+
+}
+
+int
reconfigure (xlator_t *this, dict_t *options)
{
ioc_table_t *table = NULL;
@@ -1518,6 +1655,9 @@ reconfigure (xlator_t *this, dict_t *options)
"Reconfiguring %d seconds to"
" revalidate cache", table->cache_timeout);
}
+ else
+ table->cache_timeout = 1;
+
if (dict_get (options, "cache-size"))
@@ -1557,6 +1697,8 @@ reconfigure (xlator_t *this, dict_t *options)
" cache-size %"PRIu64"", table->cache_size);
table->cache_size = cache_size;
}
+ else
+ table->cache_size = IOC_CACHE_SIZE;
if (dict_get (options, "priority")) {
@@ -1626,6 +1768,10 @@ reconfigure (xlator_t *this, dict_t *options)
table->min_file_size = min_file_size;
table->max_file_size = max_file_size;
+ if (!data_to_str (dict_get (options, "min-file-size")))
+ table->min_file_size = 0;
+ if (data_to_str (dict_get (options, "max-file-size")))
+ table->max_file_size = 0;
}
ioc_table_unlock (table);
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index b593e90e449..fe3274fc0fa 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2084,6 +2084,44 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options ( xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int ret = 0;
+ int thread_count;
+
+
+ if (dict_get (options, "thread-count")) {
+ thread_count = data_to_int32 (dict_get (options,
+ "thread-count"));
+
+ if (thread_count < IOT_MIN_THREADS) {
+ gf_log ("io-threads", GF_LOG_DEBUG,
+ "volume set thread_count WRONG,it is lesser");
+ ret = -1;
+ *op_errstr = gf_strdup ("LESSER Than min. threads");
+ goto out;
+ }
+
+ if (thread_count > IOT_MAX_THREADS) {
+ gf_log ("io-threads", GF_LOG_DEBUG,
+ "volume set thread_count WRONG,it is greater");
+ *op_errstr = gf_strdup ("GREATER than max. threads");
+ ret = -1;
+ goto out;
+ }
+
+
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+
+
+}
+
int
reconfigure ( xlator_t *this, dict_t *options)
@@ -2095,6 +2133,8 @@ reconfigure ( xlator_t *this, dict_t *options)
conf = this->private;
if (!conf)
goto out;
+
+ thread_count = conf->max_count;
if (dict_get (options, "thread-count")) {
thread_count = data_to_int32 (dict_get (options,
@@ -2116,6 +2156,8 @@ reconfigure ( xlator_t *this, dict_t *options)
conf->max_count = thread_count;
}
+ else
+ conf->max_count = thread_count;
ret = 0;
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)
{
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;
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 5cf3b1ea19f..50cb917aacc 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -1782,6 +1782,77 @@ out:
}
int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int ret = 0;
+ int timeout_ret=0;
+ int ping_timeout;
+ int frame_timeout;
+
+
+ timeout_ret = dict_get_int32 (options, "frame-timeout",
+ &frame_timeout);
+ if (timeout_ret == 0) {
+ if (frame_timeout < 5 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Validation"
+ "'option frame-timeout %d failed , Min value"
+ " can be 5", frame_timeout);
+ *op_errstr = gf_strdup ("Error, Min Value 5");
+ ret = -1;
+ goto out;
+ }
+
+ if (frame_timeout > 86400 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option frame-timeout %d failed , Max value"
+ "can be 86400", frame_timeout );
+ *op_errstr = gf_strdup ("Error, Max Value 86400");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validation otion frame-timeout to %d",
+ frame_timeout);
+
+ }
+
+ timeout_ret = dict_get_int32 (options, "ping-timeout",
+ &ping_timeout);
+ if (timeout_ret == 0) {
+
+ if (ping_timeout < 5 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option ping-timeout %d failed , Min value"
+ " can be 5", ping_timeout);
+ *op_errstr = gf_strdup ("Error, Min Value 5");
+ ret = -1;
+ goto out;
+ }
+
+ if (ping_timeout > 1013 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option frame-timeout %d failed , Max value"
+ "can be 1013,", frame_timeout);
+ *op_errstr = gf_strdup ("Error, Max Value 1013");
+ ret = -1;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_DEBUG, "Validated "
+ "'option ping-timeout' to %d", ping_timeout);
+
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+
+}
+
+int
reconfigure (xlator_t *this, dict_t *options)
{
int ret = 0;
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 1594b8d0a01..2851f8cea86 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -456,6 +456,84 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int inode_lru_limit = 0;
+ char errstr[1024] = {0, };
+ dict_t *auth_modules = NULL;
+ int ret = 0;
+ data_t *data;
+ gf_boolean_t trace;
+
+
+
+ if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){
+ if (!(inode_lru_limit < (1 * GF_UNIT_MB) &&
+ inode_lru_limit >1 )) {
+ gf_log (this->name, GF_LOG_DEBUG, "Validate inode-lru"
+ "-limit %d, was WRONG", inode_lru_limit);
+ snprintf (errstr,1024, "Error, Greater than max value %d "
+ ,inode_lru_limit);
+
+ *op_errstr = gf_strdup (errstr);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ data = dict_get (options, "trace");
+ if (data) {
+ ret = gf_string2boolean (data->data, &trace);
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "'trace' takes on only boolean values. "
+ "Neglecting option");
+ snprintf (errstr,1024, "Error, trace takes only boolean"
+ "values");
+ *op_errstr = gf_strdup (errstr);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ if (!auth_modules)
+ auth_modules = dict_new ();
+
+ dict_foreach (options, get_auth_types, auth_modules);
+ ret = validate_auth_options (this, options);
+ if (ret == -1) {
+ /* logging already done in validate_auth_options function. */
+ snprintf (errstr,1024, "authentication values are incorrect");
+ *op_errstr = gf_strdup (errstr);
+ goto out;
+ }
+
+ ret = gf_auth_init (this, auth_modules);
+ if (ret) {
+ dict_unref (auth_modules);
+ goto out;
+ }
+out:
+
+ return ret;
+}
+
+static void
+_copy_auth_opt (dict_t *unused,
+ char *key,
+ data_t *value,
+ void *xl_dict)
+{
+ char *auth_option_pattern[] = { "auth.addr.*.allow",
+ "auth.addr.*.reject"};
+ if (fnmatch ( auth_option_pattern[0], key, 0) != 0)
+ dict_set ((dict_t *)xl_dict, key, (value));
+
+ if (fnmatch ( auth_option_pattern[1], key, 0) != 0)
+ dict_set ((dict_t *)xl_dict, key, (value));
+}
+
int
reconfigure (xlator_t *this, dict_t *options)
@@ -499,6 +577,7 @@ reconfigure (xlator_t *this, dict_t *options)
/* logging already done in validate_auth_options function. */
goto out;
}
+ dict_foreach (options, _copy_auth_opt, this->options);
ret = gf_auth_init (this, conf->auth_modules);
if (ret) {