summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorGaurav <gaurav@gluster.com>2011-03-23 00:50:17 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-23 04:55:29 -0700
commit9bd4f25b6b0ea8103324b685fcc21525a29849a8 (patch)
tree7b0e0b875934521dea0c6fdd3412ac61972a527e /xlators
parent6f6c817314a2a867be996c2ad6d9a1337617ded4 (diff)
CLI : Validate options farmework.
Signed-off-by: Gaurav <gaurav@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2064 (NFS options are removed upon glusterd restart) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2064
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr.c287
-rw-r--r--xlators/cluster/dht/src/dht.c43
-rw-r--r--xlators/cluster/stripe/src/stripe.c49
-rw-r--r--xlators/debug/io-stats/src/io-stats.c36
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c2
-rw-r--r--xlators/nfs/server/src/nfs.c54
-rw-r--r--xlators/performance/io-cache/src/io-cache.c156
-rw-r--r--xlators/performance/io-threads/src/io-threads.c42
-rw-r--r--xlators/performance/quick-read/src/quick-read.c63
-rw-r--r--xlators/performance/write-behind/src/write-behind.c78
-rw-r--r--xlators/protocol/client/src/client.c79
-rw-r--r--xlators/protocol/server/src/server.c64
12 files changed, 204 insertions, 749 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 3aa035c1712..dff55bc9584 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -59,283 +59,33 @@ mem_acct_init (xlator_t *this)
return ret;
}
+
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
-
- 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;
- gf_boolean_t optimistic_change_log;
-
- xlator_list_t * trav = NULL;
-
- char * read_subvol = NULL;
- char * self_heal = NULL;
- char * change_log = NULL;
- char * str_readdir = NULL;
- char * self_heal_algo = 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 "
- "(given-string = %s)", 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"
- " (given string = %s)",
- 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 "
- "(given-string = %s)", 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 < 1) {
- *op_errstr = gf_strdup ("Error, option should be >= 1");
- 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);
- }
-
-
- dict_ret = dict_get_str (options, "optimistic-change-log",
- &change_log);
- if (dict_ret == 0) {
- temp_ret = gf_string2boolean (change_log,
- &optimistic_change_log);
- if (temp_ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Validation faled for optimistic-change-log");
- *op_errstr = gf_strdup ("Error, option should be "
- "boolean");
- ret = -1;
- goto out;
- }
-
-
- gf_log (this->name, GF_LOG_DEBUG,
- "Validated 'option optimistic-"
- "change-log %s'.", change_log);
- }
-
- dict_ret = dict_get_str (options, "data-self-heal-algorithm",
- &self_heal_algo);
- if (dict_ret == 0) {
- /* Handling both strcmp cases - s1 > s2 and s1 < s2 */
-
- if (!strcmp (self_heal_algo, "full"))
- goto next;
- if (!strcmp (self_heal_algo, "diff"))
- goto next;
-
- gf_log (this->name, GF_LOG_ERROR,
- "Invalid self-heal algorithm %s",
- self_heal_algo);
- *op_errstr = gf_strdup ("Error, invalid self-heal "
- "algorithm");
- ret = -1;
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
goto out;
}
- 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;
+ if (list_empty (&this->volume_options))
goto out;
- }
-
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
+ }
-next:
out:
+
return ret;
}
@@ -575,8 +325,7 @@ reconfigure (xlator_t *this, dict_t *options)
trav->xlator->name);
flag = 1;
- ret = -1;
- goto out;
+ break;
}
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index 61c43a8d604..c9b77d64428 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -258,36 +258,33 @@ mem_acct_init (xlator_t *this)
out:
return ret;
}
+
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
- char *temp_str = NULL;
- gf_boolean_t search_unhashed;
- int ret = 0;
-
- GF_VALIDATE_OR_GOTO ("dht", this, out);
- GF_VALIDATE_OR_GOTO ("dht", options, out);
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
+
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
+ }
- 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;
- }
+ if (list_empty (&this->volume_options))
+ goto out;
- }
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
out:
+
return ret;
}
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index c251de13755..64a26214e76 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3720,43 +3720,32 @@ out:
return ret;
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
+ }
- 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;
- }
+ if (list_empty (&this->volume_options))
+ 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");
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
out:
- if (priv)
- GF_FREE (priv);
- return ret;
+ return ret;
}
int
@@ -3767,7 +3756,6 @@ reconfigure (xlator_t *this, dict_t *options)
data_t *data = NULL;
int ret = 0;
-
priv = this->private;
data = dict_get (options, "block-size");
@@ -3787,7 +3775,6 @@ reconfigure (xlator_t *this, dict_t *options)
else {
priv->block_size = (128 * GF_UNIT_KB);
}
-
out:
return ret;
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 13173b498a2..c96603b8295 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -2541,20 +2541,31 @@ fini (xlator_t *this)
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
- int ret = -1;
- char *log_str = NULL;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
+
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
+ }
+
+ if (list_empty (&this->volume_options))
+ goto out;
+
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
+ }
+
+out:
- ret = dict_get_str (options, "log-level", &log_str);
- if (ret)
- return 0;
- ret = glusterd_check_log_level(log_str);
- if (ret == -1)
- *op_errstr = gf_strdup ("Invalid log level. possible option are"
- " DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE");
- else
- ret = 0;
return ret;
}
int
@@ -2675,6 +2686,7 @@ struct volume_options options[] = {
},
{ .key = {"log-level"},
.type = GF_OPTION_TYPE_STR,
+ .value = { "DEBUG", "WARNING", "ERROR", "CRITICAL", "NONE", "TRACE"}
},
{ .key = {NULL} },
};
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 3ac6f2895a2..036502bdb56 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1634,7 +1634,7 @@ nfs_option_handler (glusterfs_graph_t *graph,
if (! strcmp (vme->option, "!nfs-disable")) {
- ret = gf_asprintf (&aa, "nfs3.%s.disable",
+ ret = gf_asprintf (&aa, "nfs.%s.disable",
volinfo->volname);
if (ret != -1) {
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 8df7c13321c..150fa239f39 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -603,47 +603,31 @@ free_nfs:
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
- char *str=NULL;
- gf_boolean_t nfs_ino32;
- data_t *data = NULL;
- long long lng = 0;
- int ret = 0;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
-
-
- ret = dict_get_str (options, "nfs.enable-ino32",
- &str);
- if (ret == 0) {
- ret = gf_string2boolean (str,
- &nfs_ino32);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING,
- "'nfs.enable-ino32' takes only boolean"
- " arguments");
- *op_errstr = gf_strdup ("Error, should be boolean");
- ret = -1;
- goto out;
- }
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
}
- data = dict_get (options, "nfs.mem-factor");
- if (data) {
- if (gf_string2longlong (data->data, &lng) != 0) {
- gf_log (this->name, GF_LOG_ERROR, "invalid number format"
- "\"%s\" in option "
- "\"nfs.mem-factor\" ",
- data->data );
- *op_errstr = gf_strdup ("Error, Invalid number format");
- ret = -1;
- goto out;
- }
+ if (list_empty (&this->volume_options))
+ goto out;
+
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret =0;
out:
- return ret;
+ return ret;
}
@@ -944,7 +928,7 @@ struct volume_options options[] = {
"Please consult gluster-users list before using this "
"option."
},
- { .key = {"nfs3.*.disable"},
+ { .key = {"nfs.*.disable"},
.type = GF_OPTION_TYPE_BOOL,
.description = "This option is used to start or stop NFS server"
"for individual volume."
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 738bd66a2b6..a3ebaf47c0e 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1497,144 +1497,32 @@ mem_acct_init (xlator_t *this)
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, 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 "
- "(%"PRIu64")", 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 "
- "(%"PRIu64")", 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;
- }
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
- 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 (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
}
- 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;
+ if (list_empty (&this->volume_options))
goto out;
- }
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
+ }
out:
- return ret;
+ return ret;
}
int
@@ -1664,7 +1552,6 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_WARNING,
"cache-timeout %d seconds invalid,"
" has to be >=0", cache_timeout);
- ret = -1;
goto out;
}
@@ -1673,7 +1560,6 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_WARNING,
"cache-timeout %d seconds invalid,"
" has to be <=60", cache_timeout);
- ret = -1;
goto out;
}
@@ -1698,7 +1584,6 @@ reconfigure (xlator_t *this, dict_t *options)
"invalid number format \"%s\" of "
"\"option cache-size\" Defaulting"
"to old value", cache_size_string);
- ret = -1;
goto out;
}
@@ -1709,7 +1594,6 @@ reconfigure (xlator_t *this, dict_t *options)
"Max value can be 4MiB, Defaulting to "
"old value (%"PRIu64")",
cache_size_string, table->cache_size);
- ret = -1;
goto out;
}
@@ -1720,7 +1604,6 @@ reconfigure (xlator_t *this, dict_t *options)
"Max value can be 6GiB, Defaulting to "
"old value (%"PRIu64")",
cache_size_string, table->cache_size);
- ret = -1;
goto out;
}
@@ -1794,7 +1677,6 @@ reconfigure (xlator_t *this, dict_t *options)
"greater than maximum size (%"PRIu64"). "
"Hence Defaulting to old value",
table->min_file_size, table->max_file_size);
- ret = -1;
goto out;
}
@@ -2066,13 +1948,9 @@ struct volume_options options[] = {
},
{ .key = {"min-file-size"},
.type = GF_OPTION_TYPE_SIZET,
- .min = -1,
- .max = -1
},
{ .key = {"max-file-size"},
.type = GF_OPTION_TYPE_SIZET,
- .min = -1,
- .max = -1
},
{ .key = {NULL} },
};
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 09b240e8847..bdc808319d1 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2081,35 +2081,29 @@ mem_acct_init (xlator_t *this)
int
-validate_options ( xlator_t *this, dict_t *options, char **op_errstr)
+validate_options ( xlator_t *this, char **op_errstr)
{
- int ret = 0;
- int thread_count;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
+ }
- 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 (list_empty (&this->volume_options))
+ 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;
- }
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret = 0;
-
out:
return ret;
}
@@ -2119,7 +2113,7 @@ int
reconfigure ( xlator_t *this, dict_t *options)
{
iot_conf_t *conf = NULL;
- int ret = -1;
+ int ret = 0;
int thread_count;
conf = this->private;
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 044b00fd58d..465881080a4 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -3172,64 +3172,29 @@ mem_acct_init (xlator_t *this)
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
- char *str = NULL;
- int32_t ret = -1;
- int32_t cache_timeout = 0;
- uint64_t cache_size = 0;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
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 = dict_get_str (this->options, "cache-size", &str);
- if (ret == 0) {
- ret = gf_string2bytesize (str, &cache_size);
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid cache-size value %s", str);
- ret = -1;
- goto out;
- }
- if (cache_size > 6 * GF_UNIT_GB) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid cache-size value %s", str);
- *op_errstr = "Range 4mb <= value <= 6gb";
- ret = -1;
- goto out;
- }
- if (cache_size < 4* GF_UNIT_MB) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid cache-size value %s", str);
- *op_errstr = "Range 4mb <= value <= 6gb";
- ret = -1;
- goto out;
- }
+ if (list_empty (&this->volume_options))
+ goto out;
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret =0;
out:
return ret;
}
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 61d4c316cff..cdc88969976 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2867,65 +2867,34 @@ out:
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, char **op_errstr)
{
- char *str = NULL;
- uint64_t window_size = 0;;
- gf_boolean_t flush_behind = 0;
- int ret = 0;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
- 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 < (512 * GF_UNIT_KB)) {
- 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 > (1 * GF_UNIT_GB)) {
- 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_WARNING,
- "validated 'option cache-size %s '", str);
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
}
- 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;
- }
+ if (list_empty (&this->volume_options))
+ goto out;
+
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret =0;
out:
+
return ret;
}
-
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -2944,8 +2913,7 @@ reconfigure (xlator_t *this, dict_t *options)
"'option cache-size %s failed , Invalid"
" number format, Defaulting to old value "
"(%"PRIu64")", str, conf->window_size);
- ret = -1;
- goto out;
+ goto out;
}
if (window_size < (512 * GF_UNIT_KB)) {
@@ -2953,8 +2921,7 @@ reconfigure (xlator_t *this, dict_t *options)
"'option cache-size %s' failed , Max value"
"can be 512KiB, Defaulting to old value "
"(%"PRIu64")", str, conf->window_size);
- ret = -1;
- goto out;
+ goto out;
}
if (window_size > (2 * GF_UNIT_GB)) {
@@ -2962,8 +2929,7 @@ reconfigure (xlator_t *this, dict_t *options)
"'option cache-size %s' failed , Max value"
"can be 1 GiB, Defaulting to old value "
"(%"PRIu64")", str, conf->window_size);
- ret = -1;
- goto out;
+ goto out;
}
conf->window_size = window_size;
@@ -2981,7 +2947,7 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_ERROR,
"'flush-behind' takes only boolean arguments");
conf->flush_behind = 1;
- return -1;
+ goto out;
}
if (conf->flush_behind) {
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 3082656f4d5..22394f59fcd 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -2076,72 +2076,31 @@ out:
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options (xlator_t *this, 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 of "
- "'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 of"
- " '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);
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
+ goto out;
}
- 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);
+ if (list_empty (&this->volume_options))
+ goto out;
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret = 0;
-
out:
+
return ret;
}
@@ -2169,7 +2128,6 @@ reconfigure (xlator_t *this, dict_t *options)
"'option frame-timeout %d failed , Min value"
" can be 5, Defaulting to old value (%d)"
, frame_timeout, conf->rpc_conf.rpc_timeout);
- ret = -1;
goto out;
}
@@ -2178,7 +2136,6 @@ reconfigure (xlator_t *this, dict_t *options)
"'option frame-timeout %d failed , Max value"
"can be 3600, Defaulting to old value (%d)"
, frame_timeout, conf->rpc_conf.rpc_timeout);
- ret = -1;
goto out;
}
@@ -2201,7 +2158,6 @@ reconfigure (xlator_t *this, dict_t *options)
"'option ping-timeout %d failed , Min value"
" can be 5, Defaulting to old value (%d)"
, ping_timeout, conf->opt.ping_timeout);
- ret = -1;
goto out;
}
@@ -2210,7 +2166,6 @@ reconfigure (xlator_t *this, dict_t *options)
"'option ping-timeout %d failed , Max value"
"can be 1013, Defaulting to old value (%d)"
, ping_timeout, conf->opt.ping_timeout);
- ret = -1;
goto out;
}
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index c1bcf61e431..73612719e45 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -472,66 +472,34 @@ out:
}
int
-validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+validate_options ( xlator_t *this, 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;
+ int ret = 0;
+ volume_opt_list_t *vol_opt = NULL;
+ volume_opt_list_t *tmp;
- 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_INFO, "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;
- }
- }
-
- auth_modules = dict_new ();
- if (!auth_modules) {
- ret = -1;
+ if (!this) {
+ gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr");
+ ret =-1;
goto out;
}
- 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);
+ if (list_empty (&this->volume_options))
goto out;
+
+ vol_opt = list_entry (this->volume_options.next,
+ volume_opt_list_t, list);
+ list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) {
+ ret = validate_xlator_volume_options_attacherr (this,
+ vol_opt->given_opt,
+ op_errstr);
}
- ret = gf_auth_init (this, auth_modules);
out:
- if (auth_modules)
- dict_unref (auth_modules);
return ret;
}
+
static void
_delete_auth_opt (dict_t *this,
char *key,