summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2011-08-11 16:08:36 +0530
committerAnand Avati <avati@gluster.com>2011-08-18 23:49:03 -0700
commitd2849bd349081b332540713cfeaa561f57356b2a (patch)
tree85ca2a53d39ced5cf7fd8dfb0df8cf292e9d29af /xlators
parent6073fc29bf79fad0b0a3ae423d637ded39a00a3a (diff)
xlator options: revamp xlator option validation/reconfigure code
- move option handling to options.c (new file) - remove duplication of option validation code - remove duplication of gf_log / sprintf - get rid of xlator_t->validate_options - get rid of option validation in rpc-transport - get rid of validate_options() in every xlator - use xlator_volume_option_get to clean up many functions - introduce primitives to init/reconfigure option types Change-Id: I51798af72c8dc0a2b9e017424036eb3667dfc7ff BUG: 3415 Reviewed-on: http://review.gluster.com/235 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr.c649
-rw-r--r--xlators/cluster/dht/src/dht.c165
-rw-r--r--xlators/cluster/stripe/src/stripe.c103
-rw-r--r--xlators/debug/io-stats/src/io-stats.c186
-rw-r--r--xlators/features/quota/src/quota.c76
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c6
-rw-r--r--xlators/nfs/server/src/nfs.c29
-rw-r--r--xlators/performance/io-cache/src/io-cache.c299
-rw-r--r--xlators/performance/io-cache/src/io-cache.h4
-rw-r--r--xlators/performance/io-threads/src/io-threads.c107
-rw-r--r--xlators/performance/quick-read/src/quick-read.c127
-rw-r--r--xlators/performance/write-behind/src/write-behind.c202
-rw-r--r--xlators/protocol/client/src/client.c166
-rw-r--r--xlators/protocol/server/src/authenticate.c5
-rw-r--r--xlators/protocol/server/src/server.c28
15 files changed, 270 insertions, 1882 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 851c57fb01e..289a27d6079 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -62,284 +62,85 @@ mem_acct_init (xlator_t *this)
return ret;
}
+
int
-validate_options (xlator_t *this, char **op_errstr)
+xlator_subvolume_index (xlator_t *this, xlator_t *subvol)
{
- int ret = 0;
- volume_opt_list_t *vol_opt = NULL;
- volume_opt_list_t *tmp;
+ int index = -1;
+ int i = 0;
+ xlator_list_t *list = NULL;
- 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;
+ list = this->children;
- 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);
+ while (list) {
+ if (subvol == list->xlator ||
+ strcmp (subvol->name, list->xlator->name) == 0) {
+ index = i;
+ break;
+ }
+ list = list->next;
+ i++;
}
-out:
-
- return ret;
+ return index;
}
int
reconfigure (xlator_t *this, dict_t *options)
{
-
- gf_boolean_t metadata_self_heal; /* on/off */
- gf_boolean_t entry_self_heal;
- gf_boolean_t data_self_heal;
- gf_boolean_t data_change_log; /* on/off */
- gf_boolean_t metadata_change_log; /* on/off */
- gf_boolean_t entry_change_log; /* on/off */
- gf_boolean_t strict_readdir;
-
afr_private_t * priv = NULL;
- 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;
+ xlator_t * read_subvol = NULL;
+ int ret = -1;
+ int index = -1;
priv = this->private;
- dict_ret = dict_get_int32 (options, "background-self-heal-count",
- &background_count);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring background self-heal count to %d",
- background_count);
-
- priv->background_self_heal_count = background_count;
- }
+ GF_OPTION_RECONF ("background-self-heal-count",
+ priv->background_self_heal_count, options, uint32,
+ out);
- 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,
- "Reconfiguration Invalid 'option metadata"
- "-self-heal %s'. Defaulting to old value.",
- self_heal);
- ret = -1;
- goto out;
- }
-
- priv->metadata_self_heal = metadata_self_heal;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option metadata"
- "-self-heal %s'.",
- self_heal);
- }
+ GF_OPTION_RECONF ("metadata-self-heal",
+ priv->metadata_self_heal, options, bool, 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,
- "Reconfiguration Invalid 'option data"
- "-self-heal %s'. Defaulting to old value.",
- self_heal);
- ret = -1;
- goto out;
- }
-
- priv->data_self_heal = data_self_heal;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option data"
- "-self-heal %s'.", self_heal);
- }
+ GF_OPTION_RECONF ("data-self-heal", priv->data_self_heal, options, bool,
+ out);
- 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,
- "Reconfiguration Invalid 'option data"
- "-self-heal %s'. Defaulting to old value.",
- self_heal);
- ret = -1;
- goto out;
- }
+ GF_OPTION_RECONF ("entry-self-heal", priv->entry_self_heal, options,
+ bool, out);
- priv->entry_self_heal = entry_self_heal;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option entry"
- "-self-heal %s'.", self_heal);
- }
+ GF_OPTION_RECONF ("strict-readdir", priv->strict_readdir, options, bool,
+ out);
+ GF_OPTION_RECONF ("data-self-heal-window-size",
+ priv->data_self_heal_window_size, options,
+ uint32, out);
- 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,
- "Invalid 'option strict-readdir %s'. "
- "Defaulting to old value.",
- str_readdir);
- ret = -1;
- goto out;
- }
+ GF_OPTION_RECONF ("data-change-log", priv->data_change_log, options,
+ bool, out);
- priv->strict_readdir = strict_readdir;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option strict"
- "-readdir %s'.", str_readdir);
- }
+ GF_OPTION_RECONF ("metadata-change-log",
+ priv->metadata_change_log, options, bool, out);
- dict_ret = dict_get_int32 (options, "data-self-heal-window-size",
- &window_size);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring, Setting data self-heal window size to %d",
- window_size);
+ GF_OPTION_RECONF ("entry-change-log", priv->entry_change_log, options,
+ bool, out);
- priv->data_self_heal_window_size = window_size;
- }
- else {
- priv->data_self_heal_window_size = 16;
- }
+ GF_OPTION_RECONF ("data-self-heal-algorithm",
+ priv->data_self_heal_algorithm, options, str, out);
+ GF_OPTION_RECONF ("read-subvolume", read_subvol, options, xlator, 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,
- "Reconfiguration Invalid 'option data-"
- "change-log %s'. Defaulting to old value.",
- change_log);
- ret = -1;
+ if (read_subvol) {
+ index = xlator_subvolume_index (this, read_subvol);
+ if (index == -1) {
+ gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume",
+ read_subvol->name);
goto out;
}
-
- priv->data_change_log = data_change_log;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option data-"
- "change-log %s'.", change_log);
+ priv->read_child = index;
}
- 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,
- "Invalid 'option metadata-change-log %s'. "
- "Defaulting to metadata-change-log as 'off'.",
- change_log);
- ret = -1;
- goto out;
- }
-
- priv->metadata_change_log = metadata_change_log;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring '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,
- "Invalid 'option entry-change-log %s'. "
- "Defaulting to entry-change-log as 'on'.",
- change_log);
- ret = -1;
- goto out;
- }
-
- priv->entry_change_log = entry_change_log;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option entry-"
- "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")) {
- priv->data_self_heal_algorithm = self_heal_algo;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option data-self"
- "heal-algorithm %s'.", self_heal_algo);
- goto next;
- }
-
- if (!strcmp (self_heal_algo, "diff")) {
- priv->data_self_heal_algorithm = self_heal_algo;
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring 'option data-self"
- "heal-algorithm %s'.", self_heal_algo);
- goto next;
- }
-
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid self-heal algorithm %s,"
- "defaulting back to old value",
- self_heal_algo);
- ret = -1;
- goto out;
- }
-
- read_ret = dict_get_str (options, "read-subvolume", &read_subvol);
-
- if (read_ret < 0)
- 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,
- "Subvolume '%s' specified as read child.",
- trav->xlator->name);
-
- flag = 1;
- break;
- }
-
- trav = trav->next;
- }
-
- if (flag == 0 ) {
- gf_log (this->name, GF_LOG_ERROR,
- "Invalid 'option read-subvolume %s', no such subvolume"
- , read_subvol);
- ret = -1;
- goto out;
- }
-
-next:
+ ret = 0;
out:
return ret;
@@ -354,13 +155,6 @@ static const char *favorite_child_warning_str = "You have specified subvolume '%
"subvolumes. All versions of the file except that on '%s' "
"WILL BE LOST.";
-static const char *no_lock_servers_warning_str = "You have set lock-server-count = 0. "
- "This means correctness is NO LONGER GUARANTEED in all cases. If two or more "
- "applications write to the same region of a file, there is a possibility that "
- "its copies will be INCONSISTENT. Set it to a value greater than 0 unless you "
- "are ABSOLUTELY SURE of what you are doing and WILL NOT HOLD GlusterFS "
- "RESPONSIBLE for inconsistent data. If you are in doubt, set it to a value "
- "greater than 0.";
int32_t
init (xlator_t *this)
@@ -371,21 +165,8 @@ init (xlator_t *this)
int i = 0;
int ret = -1;
int op_errno = 0;
- char * read_subvol = NULL;
- char * fav_child = NULL;
- char * self_heal = NULL;
- char * algo = NULL;
- char * change_log = NULL;
- char * strict_readdir = NULL;
- char * inodelk_trace = NULL;
- char * entrylk_trace = NULL;
- char * def_val = NULL;
- int32_t background_count = 0;
- int32_t lock_server_count = 1;
- int32_t window_size = 0;
- int fav_ret = -1;
- int read_ret = -1;
- int dict_ret = -1;
+ xlator_t * read_subvol = NULL;
+ xlator_t * fav_child = NULL;
if (!this->children) {
@@ -404,276 +185,63 @@ init (xlator_t *this)
priv = this->private;
- read_ret = dict_get_str (this->options, "read-subvolume", &read_subvol);
priv->read_child = -1;
-
- fav_ret = dict_get_str (this->options, "favorite-child", &fav_child);
- priv->favorite_child = -1;
-
- priv->background_self_heal_count = 16;
-
- dict_ret = dict_get_int32 (this->options, "background-self-heal-count",
- &background_count);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Setting background self-heal count to %d",
- background_count);
-
- priv->background_self_heal_count = background_count;
- }
-
- /* Default values */
-
- priv->data_self_heal = 1;
- priv->metadata_self_heal = 1;
- priv->entry_self_heal = 1;
-
- dict_ret = dict_get_str (this->options, "data-self-heal", &self_heal);
- if (dict_ret == 0) {
- ret = gf_string2boolean (self_heal, &priv->data_self_heal);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option data-self-heal %s'. "
- "Defaulting to data-self-heal as 'on'",
- self_heal);
- priv->data_self_heal = 1;
- }
- }
-
- if (xlator_get_volopt_info (&this->volume_options,
- "data-self-heal-algorithm", &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- " data-self-heal-algorithm not found");
- ret = -1;
- goto out;
- } else {
- priv->data_self_heal_algorithm = def_val;
- }
- dict_ret = dict_get_str (this->options, "data-self-heal-algorithm",
- &algo);
- if (dict_ret == 0) {
- priv->data_self_heal_algorithm = gf_strdup (algo);
- }
-
- if (xlator_get_volopt_info (&this->volume_options,
- "data-self-heal-window-size",&def_val,
- NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "data-self-heal-window-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2int32 (def_val,
- (int *)&priv->data_self_heal_window_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "data-self-heal-window-size corrupt");
- ret = -1;
+ GF_OPTION_INIT ("read-subvolume", read_subvol, xlator, out);
+ if (read_subvol) {
+ priv->read_child = xlator_subvolume_index (this, read_subvol);
+ if (priv->read_child == -1) {
+ gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume",
+ read_subvol->name);
goto out;
}
}
- dict_ret = dict_get_int32 (this->options, "data-self-heal-window-size",
- &window_size);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Setting data self-heal window size to %d",
- window_size);
-
- priv->data_self_heal_window_size = window_size;
- }
-
- dict_ret = dict_get_str (this->options, "metadata-self-heal",
- &self_heal);
- if (dict_ret == 0) {
- ret = gf_string2boolean (self_heal, &priv->metadata_self_heal);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option metadata-self-heal %s'. "
- "Defaulting to metadata-self-heal as 'on'.",
- self_heal);
- priv->metadata_self_heal = 1;
- }
- }
-
- dict_ret = dict_get_str (this->options, "entry-self-heal", &self_heal);
- if (dict_ret == 0) {
- ret = gf_string2boolean (self_heal, &priv->entry_self_heal);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option entry-self-heal %s'. "
- "Defaulting to entry-self-heal as 'on'.",
- self_heal);
- priv->entry_self_heal = 1;
- }
- }
-
- /* Change log options */
-
- priv->data_change_log = 1;
- priv->metadata_change_log = 1;
- priv->entry_change_log = 1;
- priv->optimistic_change_log = 1;
-
- dict_ret = dict_get_str (this->options, "data-change-log",
- &change_log);
- if (dict_ret == 0) {
- ret = gf_string2boolean (change_log, &priv->data_change_log);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option data-change-log %s'. "
- "Defaulting to data-change-log as 'on'.",
- change_log);
- priv->data_change_log = 1;
- }
- }
-
- dict_ret = dict_get_str (this->options, "metadata-change-log",
- &change_log);
- if (dict_ret == 0) {
- ret = gf_string2boolean (change_log,
- &priv->metadata_change_log);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option metadata-change-log %s'. "
- "Defaulting to metadata-change-log as 'off'.",
- change_log);
- priv->metadata_change_log = 0;
- }
- }
-
- dict_ret = dict_get_str (this->options, "entry-change-log",
- &change_log);
- if (dict_ret == 0) {
- ret = gf_string2boolean (change_log, &priv->entry_change_log);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option entry-change-log %s'. "
- "Defaulting to entry-change-log as 'on'.",
- change_log);
- priv->entry_change_log = 1;
- }
- }
-
- dict_ret = dict_get_str (this->options, "optimistic-change-log",
- &change_log);
- if (dict_ret == 0) {
- ret = gf_string2boolean (change_log, &priv->optimistic_change_log);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option optimistic-change-log %s'. "
- "Defaulting to optimistic-change-log as 'on'.",
- change_log);
- priv->optimistic_change_log = 1;
- }
- }
-
- /* Locking options */
-
- priv->inodelk_trace = 0;
- priv->entrylk_trace = 0;
-
- dict_ret = dict_get_str (this->options, "inodelk-trace",
- &inodelk_trace);
- if (dict_ret == 0) {
- ret = gf_string2boolean (inodelk_trace, &priv->inodelk_trace);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option inodelk-trace %s' ",
- inodelk_trace);
-
- priv->inodelk_trace = 0;
- }
- }
-
-
- dict_ret = dict_get_str (this->options, "entrylk-trace",
- &entrylk_trace);
- if (dict_ret == 0) {
- ret = gf_string2boolean (entrylk_trace, &priv->entrylk_trace);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option entrylk-trace %s' ",
- inodelk_trace);
-
- priv->entrylk_trace = 0;
+ priv->favorite_child = -1;
+ GF_OPTION_INIT ("favorite-child", fav_child, xlator, out);
+ if (fav_child) {
+ priv->favorite_child = xlator_subvolume_index (this, fav_child);
+ if (priv->favorite_child == -1) {
+ gf_log (this->name, GF_LOG_ERROR, "%s not a subvolume",
+ fav_child->name);
+ goto out;
}
+ gf_log (this->name, GF_LOG_WARNING,
+ favorite_child_warning_str, fav_child->name,
+ fav_child->name, fav_child->name);
}
- priv->data_lock_server_count = 1;
- priv->metadata_lock_server_count = 0;
- priv->entry_lock_server_count = 1;
+ GF_OPTION_INIT ("background-self-heal-count",
+ priv->background_self_heal_count, uint32, out);
- dict_ret = dict_get_int32 (this->options, "data-lock-server-count",
- &lock_server_count);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Setting data lock server count to %d.",
- lock_server_count);
+ GF_OPTION_INIT ("data-self-heal", priv->data_self_heal, bool, out);
- if (lock_server_count == 0)
- gf_log (this->name, GF_LOG_WARNING, "%s",
- no_lock_servers_warning_str);
+ GF_OPTION_INIT ("data-self-heal-algorithm",
+ priv->data_self_heal_algorithm, str, out);
- priv->data_lock_server_count = lock_server_count;
- }
+ GF_OPTION_INIT ("data-self-heal-window-size",
+ priv->data_self_heal_window_size, uint32, out);
+ GF_OPTION_INIT ("metadata-self-heal", priv->metadata_self_heal, bool,
+ out);
- dict_ret = dict_get_int32 (this->options,
- "metadata-lock-server-count",
- &lock_server_count);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Setting metadata lock server count to %d.",
- lock_server_count);
- priv->metadata_lock_server_count = lock_server_count;
- }
+ GF_OPTION_INIT ("entry-self-heal", priv->entry_self_heal, bool, out);
+ GF_OPTION_INIT ("data-change-log", priv->data_change_log, bool, out);
- dict_ret = dict_get_int32 (this->options, "entry-lock-server-count",
- &lock_server_count);
- if (dict_ret == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Setting entry lock server count to %d.",
- lock_server_count);
+ GF_OPTION_INIT ("metadata-change-log", priv->metadata_change_log, bool,
+ out);
- priv->entry_lock_server_count = lock_server_count;
- }
+ GF_OPTION_INIT ("entry-change-log", priv->entry_change_log, bool, out);
- priv->strict_readdir = _gf_false;
-
- dict_ret = dict_get_str (this->options, "strict-readdir",
- &strict_readdir);
- if (dict_ret == 0) {
- ret = gf_string2boolean (strict_readdir, &priv->strict_readdir);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "Invalid 'option strict-readdir %s'. "
- "Defaulting to strict-readdir as 'off'.",
- strict_readdir);
- }
- }
+ GF_OPTION_INIT ("optimistic-change-log", priv->optimistic_change_log,
+ bool, out);
- trav = this->children;
- while (trav) {
- if (!read_ret && !strcmp (read_subvol, trav->xlator->name)) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Subvolume '%s' specified as read child.",
- trav->xlator->name);
+ GF_OPTION_INIT ("inodelk-trace", priv->inodelk_trace, bool, out);
- priv->read_child = child_count;
- }
+ GF_OPTION_INIT ("entrylk-trace", priv->entrylk_trace, bool, out);
- if (fav_ret == 0 && !strcmp (fav_child, trav->xlator->name)) {
- gf_log (this->name, GF_LOG_WARNING,
- favorite_child_warning_str, trav->xlator->name,
- trav->xlator->name, trav->xlator->name);
- priv->favorite_child = child_count;
- }
-
- child_count++;
- trav = trav->next;
- }
+ GF_OPTION_INIT ("strict-readdir", priv->strict_readdir, bool, out);
priv->wait_count = 1;
@@ -827,10 +395,12 @@ struct volume_options options[] = {
},
{ .key = {"background-self-heal-count"},
.type = GF_OPTION_TYPE_INT,
- .min = 0
+ .min = 0,
+ .default_value = "16",
},
{ .key = {"data-self-heal"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"data-self-heal-algorithm"},
.type = GF_OPTION_TYPE_STR,
@@ -840,7 +410,7 @@ struct volume_options options[] = {
"source to sink. The \"diff\" algorithm copies to "
"sink only those blocks whose checksums don't match "
"with those of source.",
- .value = { "diff", "full" }
+ .value = { "diff", "full", "" }
},
{ .key = {"data-self-heal-window-size"},
.type = GF_OPTION_TYPE_INT,
@@ -851,37 +421,40 @@ struct volume_options options[] = {
"process would be applied simultaneously."
},
{ .key = {"metadata-self-heal"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"entry-self-heal"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"data-change-log"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"metadata-change-log"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"entry-change-log"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"optimistic-change-log"},
- .type = GF_OPTION_TYPE_BOOL
- },
- { .key = {"data-lock-server-count"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
- { .key = {"metadata-lock-server-count"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0
+ { .key = {"strict-readdir"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
},
- { .key = {"entry-lock-server-count"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0
+ { .key = {"inodelk-trace"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
},
- { .key = {"strict-readdir"},
+ { .key = {"entrylk-trace"},
.type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
},
{ .key = {NULL} },
};
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index c281bb15216..6c4c1ffcdcd 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -253,34 +253,6 @@ out:
return ret;
}
-int
-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;
- }
-
- 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;
-}
int
reconfigure (xlator_t *this, dict_t *options)
@@ -288,9 +260,7 @@ reconfigure (xlator_t *this, dict_t *options)
dht_conf_t *conf = NULL;
char *temp_str = NULL;
gf_boolean_t search_unhashed;
- uint32_t temp_free_disk = 0;
int ret = -1;
- uint32_t dir_spread = 0;
GF_VALIDATE_OR_GOTO ("dht", this, out);
GF_VALIDATE_OR_GOTO ("dht", options, out);
@@ -323,45 +293,18 @@ reconfigure (xlator_t *this, dict_t *options)
}
}
- if (dict_get_str (options, "min-free-disk", &temp_str) == 0) {
- if (gf_string2percent (temp_str, &temp_free_disk) == 0) {
- if (temp_free_disk > 100) {
- gf_string2bytesize (temp_str,
- &conf->min_free_disk);
- conf->disk_unit = 'b';
- } else {
- conf->min_free_disk = (uint64_t)temp_free_disk;
- }
- } else {
- gf_string2bytesize (temp_str, &conf->min_free_disk);
- conf->disk_unit = 'b';
- }
-
- gf_log(this->name, GF_LOG_DEBUG, "Reconfigure:"
- " min-free-disk reconfigured to %s",
- temp_str);
- }
+ GF_OPTION_RECONF ("min-free-disk", conf->min_free_disk, options,
+ percent_or_size, out);
- if (dict_get_str (options, "directory-layout-spread", &temp_str) == 0) {
- ret = gf_string2uint32 (temp_str, &dir_spread);
- if (ret ||
- (dir_spread > conf->subvolume_cnt) ||
- (dir_spread < 1)) {
- gf_log (this->name, GF_LOG_ERROR,
- "wrong 'directory-layout-spread' option given "
- "(%s). setting to earlier value (%d)",
- temp_str, conf->dir_spread_cnt);
- ret = -1;
- goto out;
- }
- conf->dir_spread_cnt = dir_spread;
- }
+ GF_OPTION_RECONF ("directory-layout-spread", conf->dir_spread_cnt,
+ options, uint32, out);
ret = 0;
out:
return ret;
}
+
int
init (xlator_t *this)
{
@@ -369,8 +312,6 @@ init (xlator_t *this)
char *temp_str = NULL;
int ret = -1;
int i = 0;
- uint32_t temp_free_disk = 0;
- char *def_val = NULL;
GF_VALIDATE_OR_GOTO ("dht", this, err);
@@ -399,86 +340,20 @@ init (xlator_t *this)
conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_AUTO;
}
- conf->unhashed_sticky_bit = 0;
-
- if (dict_get_str (this->options, "unhashed-sticky-bit",
- &temp_str) == 0) {
- gf_string2boolean (temp_str, &conf->unhashed_sticky_bit);
- }
-
- conf->use_readdirp = 1;
+ GF_OPTION_INIT ("unhashed-sticky-bit", conf->unhashed_sticky_bit, bool,
+ err);
- if (dict_get_str (this->options, "use-readdirp",
- &temp_str) == 0) {
- gf_string2boolean (temp_str, &conf->use_readdirp);
- }
+ GF_OPTION_INIT ("use-readdirp", conf->use_readdirp, bool, err);
- if (xlator_get_volopt_info (&this->volume_options, "min-free-disk",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- " min-free-disk not found");
- ret = -1;
- goto err;
- } else {
- if (gf_string2percent (def_val, &temp_free_disk) == 0) {
- if (temp_free_disk > 100) {
- gf_string2bytesize (temp_str,
- &conf->min_free_disk);
- conf->disk_unit = 'b';
- } else {
- conf->min_free_disk = (uint64_t)temp_free_disk;
- conf->disk_unit = 'p';
- }
- } else {
- gf_string2bytesize (temp_str, &conf->min_free_disk);
- conf->disk_unit = 'b';
- }
- }
-
- if (dict_get_str (this->options, "min-free-disk", &temp_str) == 0) {
- if (gf_string2percent (temp_str, &temp_free_disk) == 0) {
- if (temp_free_disk > 100) {
- gf_string2bytesize (temp_str,
- &conf->min_free_disk);
- conf->disk_unit = 'b';
- } else {
- conf->min_free_disk = (uint64_t)temp_free_disk;
- }
- } else {
- gf_string2bytesize (temp_str, &conf->min_free_disk);
- conf->disk_unit = 'b';
- }
- }
+ GF_OPTION_INIT ("min-free-disk", conf->min_free_disk, percent_or_size,
+ err);
conf->dir_spread_cnt = conf->subvolume_cnt;
- if (dict_get_str (this->options, "directory-layout-spread",
- &temp_str) == 0) {
- ret = gf_string2uint32 (temp_str, &conf->dir_spread_cnt);
- if (ret ||
- (conf->dir_spread_cnt > conf->subvolume_cnt) ||
- (conf->dir_spread_cnt < 1)) {
- gf_log (this->name, GF_LOG_WARNING,
- "wrong 'directory-layout-spread' option given "
- "(%s). setting it to subvolume count",
- temp_str);
- conf->dir_spread_cnt = conf->subvolume_cnt;
- }
- }
-
- conf->assert_no_child_down = 0;
+ GF_OPTION_INIT ("directory-layout-spread", conf->dir_spread_cnt,
+ uint32, err);
- ret = dict_get_str_boolean (this->options, "assert-no-child-down", 0);
- if (ret != -1) {
- if (conf->assert_no_child_down != ret) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Changing assert-no-child-down from %d to %d",
- conf->assert_no_child_down, ret);
- }
- conf->assert_no_child_down = ret;
- } else {
- gf_log (this->name, GF_LOG_ERROR,
- "'assert-no-child-down' takes only boolean arguments");
- }
+ GF_OPTION_INIT ("assert-no-child-down", conf->assert_no_child_down,
+ bool, err);
ret = dht_init_subvolumes (this, conf);
if (ret == -1) {
@@ -598,7 +473,8 @@ struct volume_options options[] = {
{ .key = {"lookup-unhashed"},
.value = {"auto", "yes", "no", "enable", "disable", "1", "0",
"on", "off"},
- .type = GF_OPTION_TYPE_STR
+ .type = GF_OPTION_TYPE_STR,
+ .default_value = "on",
},
{ .key = {"min-free-disk"},
.type = GF_OPTION_TYPE_PERCENT_OR_SIZET,
@@ -607,13 +483,16 @@ struct volume_options options[] = {
"kept free."
},
{ .key = {"unhashed-sticky-bit"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
},
{ .key = {"use-readdirp"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"assert-no-child-down"},
- .type = GF_OPTION_TYPE_BOOL
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
},
{ .key = {"directory-layout-spread"},
.type = GF_OPTION_TYPE_INT,
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index 529111ba718..9c41c405cf1 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3984,63 +3984,20 @@ mem_acct_init (xlator_t *this)
out:
return ret;
}
-int
-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;
- }
-
- 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;
-}
int
reconfigure (xlator_t *this, dict_t *options)
{
stripe_private_t *priv = NULL;
- data_t *data = NULL;
- int ret = 0;
+ int ret = -1;
priv = this->private;
- data = dict_get (options, "block-size");
- if (data) {
- gf_log (this->name, GF_LOG_TRACE,"Reconfiguring Stripe"
- " Block-size");
- ret = set_stripe_block_size (this, priv, data->data);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Reconfigue: Block-Size reconfiguration failed");
- ret = -1;
- goto out;
- }
- gf_log (this->name, GF_LOG_TRACE,
- "Reconfigue: Block-Size reconfigured Successfully");
- }
- else {
- priv->block_size = (128 * GF_UNIT_KB);
- }
+ GF_OPTION_RECONF ("block-size", priv->block_size, options, size, out);
+ ret = 0;
out:
return ret;
@@ -4057,7 +4014,6 @@ init (xlator_t *this)
stripe_private_t *priv = NULL;
xlator_list_t *trav = NULL;
data_t *data = NULL;
- char *def_blk_size = NULL;
int32_t count = 0;
int ret = -1;
@@ -4121,65 +4077,18 @@ init (xlator_t *this)
goto out;
}
- if (xlator_get_volopt_info (&this->volume_options, "block-size",
- &def_blk_size, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of stripe "
- "block-size corrupt");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_blk_size, &priv->block_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "stripe block-size corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("block-size", priv->block_size, size, out);
/* option stripe-pattern *avi:1GB,*pdf:4096 */
data = dict_get (this->options, "block-size");
- if (!data) {
- gf_log (this->name, GF_LOG_DEBUG,
- "No \"option block-size <x>\" given, defaulting "
- "to %s", def_blk_size);
- } else {
+ if (data) {
ret = set_stripe_block_size (this, priv, data->data);
if (ret)
goto out;
}
- if (xlator_get_volopt_info (&this->volume_options, "use-xattr",
- &def_blk_size, NULL)) {
- ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
- "error setting(default) hard check for extended"
- " attribute");
- goto out;
-
- }
- else {
- if (gf_string2boolean (def_blk_size,
- &priv->xattr_supported)) {
- ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
- "error setting(default) hard check for extended"
- " attribute");
- goto out;
- }
- }
-
-
- data = dict_get (this->options, "use-xattr");
- if (data) {
- if (gf_string2boolean (data->data,
- &priv->xattr_supported) == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "error setting hard check for extended "
- "attribute");
- //return -1;
- }
- }
+ GF_OPTION_INIT ("use-xattr", priv->xattr_supported, bool, out);
/* notify related */
priv->nodes_down = priv->child_count;
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 6c5563cad86..7b334baa636 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -121,7 +121,7 @@ struct ios_conf {
struct ios_global_stats incremental;
gf_boolean_t dump_fd_stats;
gf_boolean_t count_fop_hits;
- int measure_latency;
+ gf_boolean_t measure_latency;
struct ios_stat_head list[IOS_STATS_TYPE_MAX];
struct ios_stat_head thru_list[IOS_STATS_THRU_MAX];
};
@@ -2327,140 +2327,41 @@ io_stats_forget (xlator_t *this, inode_t *inode)
return 0;
}
+
int
-iostats_configure_options (xlator_t *this, dict_t *xl_options,
- struct ios_conf *conf)
+reconfigure (xlator_t *this, dict_t *options)
{
- int ret = 0;
- int sys_log_level = -1;
+ struct ios_conf *conf = NULL;
+ int ret = -1;
char *sys_log_str = NULL;
- char *log_str = NULL;
- char *def_val = NULL;
- gf_boolean_t def_bool = _gf_false;
-
- GF_ASSERT (this);
- GF_ASSERT (xl_options);
- GF_ASSERT (conf);
+ int sys_log_level = -1;
- if (xlator_get_volopt_info (&this->volume_options, "dump-fd-stats", &def_val,
- NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- " dump-fd-stats not found");
- ret = -1;
+ if (!this || !this->private)
goto out;
- } else {
- if (gf_string2boolean (def_val, &def_bool)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "dump-fd-stats corrupt");
- ret = -1;
- goto out;
- }
- }
-
- ret = dict_get_str_boolean (xl_options, "dump-fd-stats", def_bool);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'dump-fd-stats' takes only boolean arguments");
- } else {
- conf->dump_fd_stats = ret;
- if (conf->dump_fd_stats)
- gf_log (this->name, GF_LOG_DEBUG, "enabling dump-fd-stats");
- else
- gf_log (this->name, GF_LOG_DEBUG, "disabling dump-fd-stats");
- }
- ret = dict_get_str_boolean (xl_options, "count-fop-hits", _gf_false);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'count-fop-hits' takes only boolean arguments");
- } else {
- conf->count_fop_hits = ret;
- if (conf->count_fop_hits)
- gf_log (this->name, GF_LOG_DEBUG,
- "enabling count-fop-hits");
- else
- gf_log (this->name, GF_LOG_DEBUG,
- "disabling count-fop-hits");
- }
+ conf = this->private;
- if (xlator_get_volopt_info (&this->volume_options, "latency-measurement",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "latency-measurement not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2boolean (def_val, &def_bool)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "latency-measurement corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_RECONF ("dump-fd-stats", conf->dump_fd_stats, options, bool,
+ out);
- ret = dict_get_str_boolean (xl_options, "latency-measurement",
- def_bool);
- if (ret != -1) {
- if (conf->measure_latency != ret) {
- gf_log (this->name, GF_LOG_DEBUG,
- "changing latency measurement from %d to %d",
- conf->measure_latency, ret);
- }
- conf->measure_latency = ret;
- } else {
- gf_log (this->name, GF_LOG_ERROR,
- "'latency-measurement' takes only boolean arguments");
- }
+ GF_OPTION_RECONF ("count-fop-hits", conf->count_fop_hits, options, bool,
+ out);
- ret = dict_get_str (xl_options, "log-level", &log_str);
- if (!ret) {
- if (!is_gf_log_command(this, "trusted.glusterfs.set-log-level",
- log_str)) {
- gf_log (this->name, GF_LOG_INFO,
- "changing log-level to %s", log_str);
- }
- }
+ GF_OPTION_RECONF ("latency-measurement", conf->measure_latency,
+ options, bool, out);
- ret = dict_get_str (xl_options, "sys-log-level", &sys_log_str);
- if (!ret) {
+ GF_OPTION_RECONF ("sys-log-level", sys_log_str, options, str, out);
+ if (sys_log_str) {
sys_log_level = glusterd_check_log_level (sys_log_str);
+ set_sys_log_level (sys_log_level);
}
- if (ret < 0 || sys_log_level == -1) {
- sys_log_level = glusterd_check_log_level ("CRITICAL");
- gf_log (this->name, GF_LOG_WARNING,
- "setting sys-log-level to CRITICAL");
- } else {
- gf_log (this->name, GF_LOG_WARNING,
- "setting sys-log-level to %s", sys_log_str);
- }
-
- set_sys_log_level (sys_log_level);
-
ret = 0;
- out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+out:
+ gf_log (this->name, GF_LOG_DEBUG, "reconfigure returning %d", ret);
return ret;
}
-int
-reconfigure (xlator_t *this, dict_t *options)
-{
- struct ios_conf *conf = NULL;
- glusterfs_ctx_t *ctx = NULL;
-
- if (!this || !this->private)
- return -1;
-
- conf = this->private;
-
- iostats_configure_options (this, options, conf);
- ctx = glusterfs_ctx_get ();
- if (!ctx)
- return -1;
-
- return 0;
-}
int32_t
mem_acct_init (xlator_t *this)
@@ -2487,6 +2388,9 @@ init (xlator_t *this)
dict_t *options = NULL;
struct ios_conf *conf = NULL;
int i = 0;
+ char *sys_log_str = NULL;
+ int sys_log_level = -1;
+ int ret = -1;
if (!this)
return -1;
@@ -2550,10 +2454,23 @@ init (xlator_t *this)
LOCK_INIT (&conf->thru_list[i].lock);
}
- iostats_configure_options (this, options, conf);
- this->private = conf;
+ GF_OPTION_INIT ("dump-fd-stats", conf->dump_fd_stats, bool, out);
- return 0;
+ GF_OPTION_INIT ("count-fop-hits", conf->count_fop_hits, bool, out);
+
+ GF_OPTION_INIT ("latency-measurement", conf->measure_latency,
+ bool, out);
+
+ GF_OPTION_INIT ("sys-log-level", sys_log_str, str, out);
+ if (sys_log_str) {
+ sys_log_level = glusterd_check_log_level (sys_log_str);
+ set_sys_log_level (sys_log_level);
+ }
+
+ this->private = conf;
+ ret = 0;
+out:
+ return ret;
}
@@ -2578,34 +2495,7 @@ fini (xlator_t *this)
return;
}
-int
-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;
- }
-
- 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;
-}
int
notify (xlator_t *this, int32_t event, void *data, ...)
{
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 2790672a7ce..392717c55ce 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -2597,37 +2597,9 @@ quota_forget (xlator_t *this, inode_t *inode)
return 0;
}
-int
-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;
- }
-
- 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;
-}
-
-int32_t
-quota_parse_options (quota_priv_t *priv, xlator_t *this, dict_t *xl_options)
+int
+quota_parse_limits (quota_priv_t *priv, xlator_t *this, dict_t *xl_options)
{
int32_t ret = -1;
char *str = NULL;
@@ -2635,7 +2607,6 @@ quota_parse_options (quota_priv_t *priv, xlator_t *this, dict_t *xl_options)
char *path = NULL;
uint64_t value = 0;
limits_t *quota_lim = NULL;
- char *def_val = NULL;
ret = dict_get_str (xl_options, "limit-set", &str);
@@ -2668,37 +2639,6 @@ quota_parse_options (quota_priv_t *priv, xlator_t *this, dict_t *xl_options)
"no \"limit-set\" option provided");
}
- if (xlator_get_volopt_info (&this->volume_options, "timeout", &def_val,
- NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of timeout"
- "not found");
- ret = -1;
- goto err;
- } else {
- if (gf_string2bytesize (def_val,(uint64_t *) &priv->timeout )) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- " timeout corrupt");
- ret = -1;
- goto err;
- }
- }
-
- ret = dict_get_str (xl_options, "timeout", &str);
- if (str) {
- ret = gf_string2bytesize (str, &value);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_INFO,
- "Invalid quota timout value.");
- ret = -1;
- goto err;
- } else {
- priv->timeout = (int64_t) value;
- gf_log (this->name, GF_LOG_INFO,
- "quota timeout value = %"PRId64,
- priv->timeout);
- }
- }
-
list_for_each_entry (quota_lim, &priv->limit_head, limit_list) {
gf_log (this->name, GF_LOG_INFO, "%s:%"PRId64, quota_lim->path,
quota_lim->value);
@@ -2735,12 +2675,14 @@ init (xlator_t *this)
this->private = priv;
- ret = quota_parse_options (priv, this, this->options);
+ ret = quota_parse_limits (priv, this, this->options);
if (ret) {
goto err;
}
+ GF_OPTION_INIT ("timeout", priv->timeout, int64, err);
+
ret = 0;
err:
return ret;
@@ -2763,15 +2705,19 @@ reconfigure (xlator_t *this, dict_t *options)
GF_FREE (limit);
}
- ret = quota_parse_options (priv, this, options);
+ ret = quota_parse_limits (priv, this, options);
if (ret == -1) {
gf_log ("quota", GF_LOG_WARNING,
"quota reconfigure failed, "
"new changes will not take effect");
goto out;
}
+
+ GF_OPTION_RECONF ("timeout", priv->timeout, options, int64, out);
+
+ ret = 0;
out:
- return 0;
+ return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 557bd81a293..3722bdae708 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1789,12 +1789,12 @@ glusterd_get_volopt_content (gf_boolean_t xml_out)
ret = xlator_volopt_dynload (vme->voltype,
&dl_handle,
&vol_opt_handle);
- if (ret)
+ if (ret)
continue;
}
- ret = xlator_get_volopt_info (&vol_opt_handle.list, key,
- &def_val, &descr);
+ ret = xlator_option_info_list (&vol_opt_handle, key,
+ &def_val, &descr);
if (ret) /*Swallow Error i.e if option not found*/
continue;
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 50c1bc4c2bd..40685fa9b92 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -688,35 +688,6 @@ free_rpcsvc:
return nfs;
}
-int
-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;
- }
-
- 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;
-
-}
-
int
init (xlator_t *this) {
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 0a5ca0a7cb3..90c14ea7d6c 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1513,47 +1513,13 @@ mem_acct_init (xlator_t *this)
return ret;
}
-int
-validate_options (xlator_t *this, char **op_errstr)
-{
- int ret = 0;
- volume_opt_list_t *vol_opt = NULL;
- volume_opt_list_t *tmp = NULL;
-
- 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:
-
- return ret;
-}
int
reconfigure (xlator_t *this, dict_t *options)
{
data_t *data = NULL;
ioc_table_t *table = NULL;
- int32_t cache_timeout = 0;
- int64_t min_file_size = 0;
- int64_t max_file_size = 0;
- char *tmp = NULL;
- uint64_t cache_size = 0;
- char *cache_size_string = NULL;
- int ret = 0;
+ int ret = -1;
if (!this || !this->private)
goto out;
@@ -1562,72 +1528,11 @@ reconfigure (xlator_t *this, dict_t *options)
ioc_table_lock (table);
{
- data = dict_get (options, "cache-timeout");
- if (data) {
- cache_timeout = data_to_uint32 (data);
- if (cache_timeout < 0){
- gf_log (this->name, GF_LOG_WARNING,
- "cache-timeout %d seconds invalid,"
- " has to be >=0", cache_timeout);
- goto out;
- }
-
-
- if (cache_timeout > 60){
- gf_log (this->name, GF_LOG_WARNING,
- "cache-timeout %d seconds invalid,"
- " has to be <=60", cache_timeout);
- goto out;
- }
-
- table->cache_timeout = cache_timeout;
-
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring %d seconds to"
- " revalidate cache", table->cache_timeout);
- } else
- table->cache_timeout = 1;
-
- data = dict_get (options, "cache-size");
- if (data)
- cache_size_string = data_to_str (data);
-
- 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);
- goto out;
- }
-
- if (cache_size < (4 * GF_UNIT_MB)) {
- gf_log(this->name, GF_LOG_ERROR,
- "Reconfiguration"
- "'option cache-size %s' failed , "
- "Max value can be 4MiB, Defaulting to "
- "old value (%"PRIu64")",
- cache_size_string, table->cache_size);
- goto out;
- }
-
- if (cache_size > (6 * GF_UNIT_GB)) {
- gf_log (this->name, GF_LOG_ERROR,
- "Reconfiguration"
- "'option cache-size %s' failed , "
- "Max value can be 6GiB, Defaulting to "
- "old value (%"PRIu64")",
- cache_size_string, table->cache_size);
- goto out;
- }
-
+ GF_OPTION_RECONF ("cache-timeout", table->cache_timeout,
+ options, int32, unlock);
- gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring "
- " cache-size %"PRIu64"", cache_size);
- table->cache_size = cache_size;
- } else
- table->cache_size = IOC_CACHE_SIZE;
+ GF_OPTION_RECONF ("cache-size", table->cache_size,
+ options, size, unlock);
data = dict_get (options, "priority");
if (data) {
@@ -1640,80 +1545,36 @@ reconfigure (xlator_t *this, dict_t *options)
&table->priority_list);
if (table->max_pri == -1) {
- ret = -1;
- goto out;
+ goto unlock;
}
table->max_pri ++;
}
- min_file_size = table->min_file_size;
- data = dict_get (options, "min-file-size");
- if (data) {
- tmp = data_to_str (data);
- if (tmp != NULL) {
- if (gf_string2bytesize (tmp,
- (uint64_t *)&min_file_size)
- != 0) {
- gf_log ("io-cache", GF_LOG_ERROR,
- "invalid number format \"%s\" of "
- "\"option min-file-size\"", tmp);
- ret = -1;
- goto out;
- }
-
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring min-file-size %"PRIu64"",
- table->min_file_size);
- }
- }
-
- max_file_size = table->max_file_size;
- data = dict_get (options, "max-file-size");
- if (data) {
- tmp = data_to_str (data);
- if (tmp != NULL) {
- if (gf_string2bytesize (tmp,
- (uint64_t *)&max_file_size)
- != 0) {
- gf_log ("io-cache", GF_LOG_ERROR,
- "invalid number format \"%s\" of "
- "\"option max-file-size\"", tmp);
- ret = -1;
- goto out;
- }
+ GF_OPTION_RECONF ("max-file-size", table->max_file_size,
+ options, size, unlock);
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring max-file-size %"PRIu64"",
- table->max_file_size);
- }
- }
+ GF_OPTION_RECONF ("min-file-size", table->min_file_size,
+ options, size, unlock);
- if ((max_file_size >= 0) && (min_file_size > max_file_size)) {
- gf_log ("io-cache", GF_LOG_ERROR, "minimum size (%"
+ if ((table->max_file_size >= 0) &&
+ (table->min_file_size > table->max_file_size)) {
+ gf_log (this->name, GF_LOG_ERROR, "minimum size (%"
PRIu64") of a file that can be cached is "
"greater than maximum size (%"PRIu64"). "
"Hence Defaulting to old value",
table->min_file_size, table->max_file_size);
- goto out;
+ goto unlock;
}
- table->min_file_size = min_file_size;
- table->max_file_size = max_file_size;
- data = dict_get (options, "min-file-size");
- if (data && !data_to_str (data))
- table->min_file_size = 0;
-
- data = dict_get (options, "max-file-size");
- if (data && !data_to_str (data))
- table->max_file_size = 0;
+ ret = 0;
}
-
+unlock:
ioc_table_unlock (table);
out:
return ret;
-
}
+
/*
* init -
* @this:
@@ -1725,11 +1586,9 @@ init (xlator_t *this)
ioc_table_t *table = NULL;
dict_t *xl_options = NULL;
uint32_t index = 0;
- char *cache_size_string = NULL, *tmp = NULL;
int32_t ret = -1;
glusterfs_ctx_t *ctx = NULL;
data_t *data = 0;
- char *def_val = NULL;
xl_options = this->options;
@@ -1754,61 +1613,13 @@ init (xlator_t *this)
table->xl = this;
table->page_size = this->ctx->page_size;
- if (xlator_get_volopt_info (&this->volume_options, "cache-size",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of cache-size "
- "not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_val, &table->cache_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size corrupt");
- ret = -1;
- goto out;
- }
- }
-
- data = dict_get (xl_options, "cache-size");
- if (data)
- cache_size_string = data_to_str (data);
-
- if (cache_size_string) {
- if (gf_string2bytesize (cache_size_string,
- &table->cache_size) != 0) {
- gf_log ("io-cache", GF_LOG_ERROR,
- "invalid number format \"%s\" of "
- "\"option cache-size\"",
- cache_size_string);
- goto out;
- }
+ GF_OPTION_INIT ("cache-size", table->cache_size, size, out);
- gf_log (this->name, GF_LOG_TRACE,
- "using cache-size %"PRIu64"", table->cache_size);
- }
+ GF_OPTION_INIT ("cache-timeout", table->cache_timeout, int32, out);
- if (xlator_get_volopt_info (&this->volume_options, "cache-timeout",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-timeout not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2int32 (def_val, &table->cache_timeout)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-timeout corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("min-file-size", table->min_file_size, size, out);
- data = dict_get (xl_options, "cache-timeout");
- if (data) {
- table->cache_timeout = data_to_uint32 (data);
- gf_log (this->name, GF_LOG_TRACE,
- "Using %d seconds to revalidate cache",
- table->cache_timeout);
- }
+ GF_OPTION_INIT ("max-file-size", table->max_file_size, size, out);
INIT_LIST_HEAD (&table->priority_list);
table->max_pri = 1;
@@ -1827,74 +1638,6 @@ init (xlator_t *this)
}
table->max_pri ++;
- if (xlator_get_volopt_info (&this->volume_options, "min-file-size",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "min-file-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_val,
- (uint64_t *) &table->min_file_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "min-file-size corrupt");
- ret = -1;
- goto out;
- }
- }
-
- data = dict_get (xl_options, "min-file-size");
- if (data)
- tmp = data_to_str (data);
-
- if (tmp != NULL) {
- if (gf_string2bytesize (tmp,
- (uint64_t *)&table->min_file_size)
- != 0) {
- gf_log ("io-cache", GF_LOG_ERROR,
- "invalid number format \"%s\" of "
- "\"option min-file-size\"", tmp);
- goto out;
- }
-
- gf_log (this->name, GF_LOG_TRACE,
- "using min-file-size %"PRIu64"", table->min_file_size);
- }
-
- if (xlator_get_volopt_info (&this->volume_options, "max-file-size",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "max-file-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_val,
- (uint64_t *) &table->max_file_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "max-file-size corrupt");
- ret = -1;
- goto out;
- }
- }
-
- tmp = NULL;
- data = dict_get (xl_options, "max-file-size");
- if (data)
- tmp = data_to_str (data);
-
- if (tmp != NULL) {
- if (gf_string2bytesize (tmp,
- (uint64_t *)&table->max_file_size)
- != 0) {
- gf_log ("io-cache", GF_LOG_ERROR,
- "invalid number format \"%s\" of "
- "\"option max-file-size\"", tmp);
- goto out;
- }
-
- gf_log (this->name, GF_LOG_TRACE,
- "using max-file-size %"PRIu64"", table->max_file_size);
- }
INIT_LIST_HEAD (&table->inodes);
if ((table->max_file_size >= 0)
diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h
index 01ae462e445..eec24f143ba 100644
--- a/xlators/performance/io-cache/src/io-cache.h
+++ b/xlators/performance/io-cache/src/io-cache.h
@@ -164,8 +164,8 @@ struct ioc_table {
uint64_t page_size;
uint64_t cache_size;
uint64_t cache_used;
- int64_t min_file_size;
- int64_t max_file_size;
+ uint64_t min_file_size;
+ uint64_t max_file_size;
struct list_head inodes; /* list of inodes cached */
struct list_head active;
struct list_head *inode_lru;
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index ffe71c8d721..03ebc66f2e3 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -2081,73 +2081,18 @@ mem_acct_init (xlator_t *this)
int
-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;
- }
-
- 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;
-}
-
-
-int
-reconfigure ( xlator_t *this, dict_t *options)
+reconfigure (xlator_t *this, dict_t *options)
{
iot_conf_t *conf = NULL;
- int ret = 0;
- int thread_count;
+ int ret = -1;
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,
- "thread-count"));
-
- if (thread_count < IOT_MIN_THREADS) {
- gf_log ("io-threads", GF_LOG_WARNING,
- "Number of threads opted (%d) is less than "
- "min (%d). Restoring it to previous value (%d)",
- thread_count, IOT_MIN_THREADS, conf->max_count);
- goto out;
- }
-
- if (thread_count > IOT_MAX_THREADS) {
- gf_log ("io-threads", GF_LOG_WARNING,
- "Number of threads opted (%d) is greater than "
- "max (%d). Restoring it to previous value (%d)",
- thread_count, IOT_MAX_THREADS, conf->max_count);
- goto out;
- }
-
- conf->max_count = thread_count;
- } else
- conf->max_count = thread_count;
+ GF_OPTION_RECONF ("thread-count", conf->max_count, options, int32, out);
ret = 0;
-
out:
return ret;
}
@@ -2157,12 +2102,8 @@ int
init (xlator_t *this)
{
iot_conf_t *conf = NULL;
- dict_t *xl_options = this->options;
- int thread_count = IOT_DEFAULT_THREADS;
- int idle_time = IOT_DEFAULT_IDLE;
int ret = -1;
int i = 0;
- char *def_val = NULL;
if (!this->children || this->children->next) {
gf_log ("io-threads", GF_LOG_ERROR,
@@ -2197,46 +2138,9 @@ init (xlator_t *this)
set_stack_size (conf);
- if (xlator_get_volopt_info (&this->volume_options, "thread-count",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "thread-count not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2int32 (def_val, &conf->max_count)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "thread corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("thread-count", conf->max_count, int32, out);
- if (dict_get (xl_options, "thread-count")) {
- thread_count = data_to_int32 (dict_get (xl_options,
- "thread-count"));
- if (thread_count < IOT_MIN_THREADS) {
- gf_log ("io-threads", GF_LOG_WARNING,
- "Number of threads opted is less than min"
- "threads allowed scaling it up to min");
- thread_count = IOT_MIN_THREADS;
- }
- if (thread_count > IOT_MAX_THREADS) {
- gf_log ("io-threads", GF_LOG_WARNING,
- "Number of threads opted is more than max"
- " threads allowed scaling it down to max");
- thread_count = IOT_MAX_THREADS;
- }
- }
- conf->max_count = thread_count;
-
- if (dict_get (xl_options, "idle-time")) {
- idle_time = data_to_int32 (dict_get (xl_options,
- "idle-time"));
- if (idle_time < 0)
- idle_time = 1;
- }
- conf->idle_time = idle_time;
+ GF_OPTION_INIT ("idle-time", conf->idle_time, int32, out);
conf->this = this;
@@ -2328,6 +2232,7 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_INT,
.min = 1,
.max = 0x7fffffff,
+ .default_value = "120",
},
{ .key = {NULL},
},
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index e17d3db23e4..e8385089f1a 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -3407,43 +3407,11 @@ mem_acct_init (xlator_t *this)
int
-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;
- }
-
- 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;
-}
-
-
-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 = 0;
- uint64_t cache_size = 0;
GF_VALIDATE_OR_GOTO ("quick-read", this, out);
GF_VALIDATE_OR_GOTO (this->name, this->private, out);
@@ -3456,40 +3424,10 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
}
- cache_timeout = conf->cache_timeout;
- ret = dict_get_str (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;
- }
-
- cache_size = conf->cache_size;
- ret = dict_get_str (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 %s(old value used)", str);
- conf->cache_size = cache_size;
- ret = -1;
- goto out;
- }
+ GF_OPTION_RECONF ("cache-timeout", conf->cache_timeout, options, int32,
+ out);
- gf_log (this->name, GF_LOG_WARNING,
- "Reconfiguring cache-siz to %"PRIu64, cache_size);
- conf->cache_size = cache_size;
- } else {
- conf->cache_size = QR_DEFAULT_CACHE_SIZE;
- }
+ GF_OPTION_RECONF ("cache-size", conf->cache_size, options, size, out);
ret = 0;
out:
@@ -3602,11 +3540,9 @@ out:
int32_t
init (xlator_t *this)
{
- char *str = NULL;
int32_t ret = -1, i = 0;
qr_private_t *priv = NULL;
qr_conf_t *conf = NULL;
- char *def_val = NULL;
if (!this->children || this->children->next) {
gf_log (this->name, GF_LOG_ERROR,
@@ -3628,59 +3564,12 @@ init (xlator_t *this)
LOCK_INIT (&priv->table.lock);
conf = &priv->conf;
- conf->max_file_size = 65536;
- ret = dict_get_str (this->options, "max-file-size",
- &str);
- if (ret == 0) {
- ret = gf_string2bytesize (str, &conf->max_file_size);
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid number format \"%s\" of \"option "
- "max-file-size\"",
- str);
- ret = -1;
- goto out;
- }
- }
- conf->cache_timeout = 1;
- 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;
- }
- }
+ GF_OPTION_INIT ("max-file-size", conf->max_file_size, size, out);
- if (xlator_get_volopt_info (&this->volume_options, "cache-size",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_val, &conf->cache_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("cache-timeout", conf->cache_timeout, int32, out);
- ret = dict_get_str (this->options, "cache-size", &str);
- if (ret == 0) {
- ret = gf_string2bytesize (str, &conf->cache_size);
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid cache-size value %s", str);
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("cache-size", conf->cache_size, size, out);
INIT_LIST_HEAD (&conf->priority_list);
conf->max_pri = 1;
@@ -3770,11 +3659,13 @@ struct volume_options options[] = {
{ .key = {"cache-timeout"},
.type = GF_OPTION_TYPE_INT,
.min = 1,
- .max = 60
+ .max = 60,
+ .default_value = "1",
},
{ .key = {"max-file-size"},
.type = GF_OPTION_TYPE_SIZET,
.min = 0,
.max = 1 * GF_UNIT_KB * 1000,
+ .default_value = "64KB",
},
};
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 20991308374..1eff4385ae3 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2882,100 +2882,21 @@ out:
int
-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;
- }
-
- 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;
-}
-
-int
reconfigure (xlator_t *this, dict_t *options)
{
- char *str = NULL;
- uint64_t window_size = 0;
- wb_conf_t *conf = NULL;
- int ret = 0;
+ wb_conf_t *conf = NULL;
+ int ret = -1;
conf = this->private;
- 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_ERROR, "Reconfiguration"
- "'option cache-size %s failed , Invalid"
- " number format, Defaulting to old value "
- "(%"PRIu64")", str, conf->window_size);
- goto out;
- }
+ GF_OPTION_RECONF ("cache-size", conf->window_size, options, size, out);
- 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 "
- "(%"PRIu64")", str, conf->window_size);
- goto out;
- }
-
- 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 "
- "(%"PRIu64")", str, conf->window_size);
- goto out;
- }
-
- conf->window_size = window_size;
- gf_log(this->name, GF_LOG_WARNING, "Reconfiguring "
- "'option cache-size %s ' to %"PRIu64, str,
- conf->window_size);
- } else {
- conf->window_size = WB_WINDOW_SIZE;
- }
-
- ret = dict_get_str (options, "flush-behind", &str);
- if (ret == 0) {
- ret = gf_string2boolean (str, &conf->flush_behind);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'flush-behind' takes only boolean arguments");
- conf->flush_behind = 1;
- goto out;
- }
-
- if (conf->flush_behind) {
- gf_log (this->name, GF_LOG_WARNING,
- "enabling flush-behind");
- } else {
- gf_log (this->name, GF_LOG_WARNING,
- "disabling flush-behind");
- }
- }
+ GF_OPTION_RECONF ("flush-behind", conf->flush_behind, options, bool,
+ out);
+ ret = 0;
out:
- return 0;
+ return ret;
}
@@ -2984,9 +2905,7 @@ init (xlator_t *this)
{
dict_t *options = NULL;
wb_conf_t *conf = NULL;
- char *str = NULL;
int32_t ret = -1;
- char *def_val = NULL;
if ((this->children == NULL)
|| this->children->next) {
@@ -3008,63 +2927,16 @@ init (xlator_t *this)
goto out;
}
- conf->enable_O_SYNC = _gf_false;
- ret = dict_get_str (options, "enable-O_SYNC", &str);
- if (ret == 0) {
- ret = gf_string2boolean (str, &conf->enable_O_SYNC);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'enable-O_SYNC' takes only boolean arguments");
- goto out;
- }
- }
+ GF_OPTION_INIT("enable-O_SYNC", conf->enable_O_SYNC, bool, out);
/* configure 'options aggregate-size <size>' */
conf->aggregate_size = WB_AGGREGATE_SIZE;
- conf->disable_till = 0;
- ret = dict_get_str (options, "disable-for-first-nbytes", &str);
- if (ret == 0) {
- ret = gf_string2bytesize (str, &conf->disable_till);
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid number format \"%s\" of \"option "
- "disable-for-first-nbytes\"",
- str);
- goto out;
- }
- }
- gf_log (this->name, GF_LOG_WARNING,
- "disabling write-behind for first %"PRIu64" bytes",
- conf->disable_till);
+ GF_OPTION_INIT("disable-for-first-nbytes", conf->disable_till, size,
+ out);
/* configure 'option window-size <size>' */
- if (xlator_get_volopt_info (&this->volume_options, "cache-size",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2bytesize (def_val, &conf->window_size)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size corrupt");
- ret = -1;
- goto out;
- }
- }
-
- ret = dict_get_str (options, "cache-size", &str);
- if (ret == 0) {
- ret = gf_string2bytesize (str, &conf->window_size);
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "invalid number format \"%s\" of \"option "
- "window-size\"", str);
- GF_FREE (conf);
- goto out;
- }
- }
+ GF_OPTION_INIT ("cache-size", conf->window_size, size, out);
if (!conf->window_size && conf->aggregate_size) {
gf_log (this->name, GF_LOG_WARNING,
@@ -3079,58 +2951,23 @@ init (xlator_t *this)
"aggregate-size(%"PRIu64") cannot be more than "
"window-size(%"PRIu64")", conf->aggregate_size,
conf->window_size);
- GF_FREE (conf);
goto out;
}
/* configure 'option flush-behind <on/off>' */
+ GF_OPTION_INIT ("flush-behind", conf->flush_behind, bool, out);
- if (xlator_get_volopt_info (&this->volume_options, "flush-behind",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2boolean (def_val, &conf->flush_behind)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "cache-size corrupt");
- ret = -1;
- goto out;
- }
- }
-
- ret = dict_get_str (options, "flush-behind", &str);
- if (ret == 0) {
- ret = gf_string2boolean (str, &conf->flush_behind);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'flush-behind' takes only boolean arguments");
- goto out;
- }
-
- if (conf->flush_behind) {
- gf_log (this->name, GF_LOG_WARNING,
- "enabling flush-behind");
- }
- }
-
- conf->enable_trickling_writes = _gf_true;
- ret = dict_get_str (options, "enable-trickling-writes", &str);
- if (ret == 0) {
- ret = gf_string2boolean (str, &conf->enable_trickling_writes);
- if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "'enable-trickling_writes' takes only boolean"
- " arguments");
- goto out;
- }
- }
+ GF_OPTION_INIT ("enable-trickling-writes", conf->enable_trickling_writes,
+ bool, out);
this->private = conf;
ret = 0;
out:
+ if (ret) {
+ if (conf)
+ GF_FREE (conf);
+ }
return ret;
}
@@ -3200,12 +3037,15 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_SIZET,
.min = 1,
.max = 1 * GF_UNIT_MB,
+ .default_value = "0",
},
{ .key = {"enable-O_SYNC"},
.type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {"enable-trickling-writes"},
.type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
},
{ .key = {NULL} },
};
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 7f8301be886..355b0d16043 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -1954,73 +1954,24 @@ int
build_client_config (xlator_t *this, clnt_conf_t *conf)
{
int ret = -1;
- char *def_val = NULL;
if (!conf)
goto out;
- if (xlator_get_volopt_info (&this->volume_options, "frame-timeout",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "frame-timeout not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2int32 (def_val, &conf->rpc_conf.rpc_timeout)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "frame-timeout corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("frame-timeout", conf->rpc_conf.rpc_timeout,
+ int32, out);
- ret = dict_get_int32 (this->options, "frame-timeout",
- &conf->rpc_conf.rpc_timeout);
- if (ret >= 0) {
- gf_log (this->name, GF_LOG_INFO,
- "setting frame-timeout to %d",
- conf->rpc_conf.rpc_timeout);
- }
-
- ret = dict_get_int32 (this->options, "remote-port",
- &conf->rpc_conf.remote_port);
- if (ret >= 0) {
- gf_log (this->name, GF_LOG_INFO,
- "remote-port is %d", conf->rpc_conf.remote_port);
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "defaulting remote-port to 'auto'");
- }
-
- if (xlator_get_volopt_info (&this->volume_options, "ping-timeout",
- &def_val, NULL)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "ping-timeout not found");
- ret = -1;
- goto out;
- } else {
- if (gf_string2int32 (def_val, &conf->opt.ping_timeout)) {
- gf_log (this->name, GF_LOG_ERROR, "Default value of "
- "ping-timeout corrupt");
- ret = -1;
- goto out;
- }
- }
+ GF_OPTION_INIT ("remote-port", conf->rpc_conf.remote_port,
+ int32, out);
- ret = dict_get_int32 (this->options, "ping-timeout",
- &conf->opt.ping_timeout);
- if (ret >= 0) {
- gf_log (this->name, GF_LOG_INFO,
- "setting ping-timeout to %d", conf->opt.ping_timeout);
- }
+ GF_OPTION_INIT ("ping-timeout", conf->opt.ping_timeout,
+ int32, out);
- ret = dict_get_str (this->options, "remote-subvolume",
- &conf->opt.remote_subvolume);
- if (ret) {
- /* This is valid only if 'cluster/pump' is the parent */
- gf_log (this->name, GF_LOG_WARNING,
+ GF_OPTION_INIT ("remote-subvolume", conf->opt.remote_subvolume,
+ path, out);
+ if (!conf->opt.remote_subvolume) {
+ gf_log (this->name, GF_LOG_ERROR,
"option 'remote-subvolume' not given");
- ret = 1;
goto out;
}
@@ -2119,43 +2070,12 @@ out:
return ret;
}
-int
-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;
- }
-
- 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;
-}
int
reconfigure (xlator_t *this, dict_t *options)
{
clnt_conf_t *conf = NULL;
- int ret = 0;
- int timeout_ret = 0;
- int ping_timeout = 0;
- int frame_timeout = 0;
+ int ret = -1;
int subvol_ret = 0;
char *old_remote_subvol = NULL;
char *new_remote_subvol = NULL;
@@ -2164,70 +2084,18 @@ reconfigure (xlator_t *this, dict_t *options)
conf = this->private;
- timeout_ret = dict_get_int32 (options, "frame-timeout",
- &frame_timeout);
- if (timeout_ret == 0) {
- if (frame_timeout < 5 ) {
- gf_log (this->name, GF_LOG_ERROR, "Reconfiguration"
- "'option frame-timeout %d failed , Min value"
- " can be 5, Defaulting to old value (%d)"
- , frame_timeout, conf->rpc_conf.rpc_timeout);
- goto out;
- }
-
- if (frame_timeout > 3600 ) {
- gf_log (this->name, GF_LOG_ERROR, "Reconfiguration"
- "'option frame-timeout %d failed , Max value"
- "can be 3600, Defaulting to old value (%d)"
- , frame_timeout, conf->rpc_conf.rpc_timeout);
- goto out;
- }
+ GF_OPTION_RECONF ("frame-timeout", conf->rpc_conf.rpc_timeout,
+ options, int32, out);
-
- gf_log (this->name, GF_LOG_DEBUG,
- "Reconfiguring otion frame-timeout to %d",
- frame_timeout);
-
- conf->rpc_conf.rpc_timeout = frame_timeout;
- }
- else
- conf->rpc_conf.rpc_timeout = 1800;
-
- 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, Defaulting to old value (%d)"
- , ping_timeout, conf->opt.ping_timeout);
- goto out;
- }
-
- if (ping_timeout > 1013 ) {
- gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
- "'option ping-timeout %d failed , Max value"
- "can be 1013, Defaulting to old value (%d)"
- , ping_timeout, conf->opt.ping_timeout);
- goto out;
- }
-
- gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring "
- "'option ping-timeout' to %d", ping_timeout);
- conf->opt.ping_timeout = ping_timeout;
- }
- else
- conf->opt.ping_timeout = GF_UNIVERSAL_ANSWER;
+ GF_OPTION_RECONF ("ping-timeout", conf->opt.ping_timeout,
+ options, int32, out);
subvol_ret = dict_get_str (this->options, "remote-host",
&old_remote_host);
if (subvol_ret == 0) {
-
subvol_ret = dict_get_str (options, "remote-host",
&new_remote_host);
-
if (subvol_ret == 0) {
if (strcmp (old_remote_host, new_remote_host)) {
ret = 1;
@@ -2240,10 +2108,8 @@ reconfigure (xlator_t *this, dict_t *options)
&old_remote_subvol);
if (subvol_ret == 0) {
-
subvol_ret = dict_get_str (options, "remote-subvolume",
&new_remote_subvol);
-
if (subvol_ret == 0) {
if (strcmp (old_remote_subvol, new_remote_subvol)) {
ret = 1;
@@ -2252,11 +2118,13 @@ reconfigure (xlator_t *this, dict_t *options)
}
}
+ ret = 0;
out:
return ret;
}
+
int
init (xlator_t *this)
{
diff --git a/xlators/protocol/server/src/authenticate.c b/xlators/protocol/server/src/authenticate.c
index 00ec3ef7b3d..de5bf9f437b 100644
--- a/xlators/protocol/server/src/authenticate.c
+++ b/xlators/protocol/server/src/authenticate.c
@@ -134,8 +134,9 @@ gf_auth_init (xlator_t *xl, dict_t *auth_modules)
list_add_tail (&(handle->vol_opt->list),
&(xl->volume_options));
- ret = validate_xlator_volume_options (xl,
- handle->vol_opt->given_opt);
+ ret = xlator_options_validate_list (xl, xl->options,
+ handle->vol_opt, NULL);
+
if (ret)
gf_log ("authenticate", GF_LOG_ERROR,
"volume option validation failed");
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index df6d31a7c33..28df5c5dcc8 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -471,34 +471,6 @@ out:
return ret;
}
-int
-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;
- }
-
- 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;
-}
static void
_delete_auth_opt (dict_t *this,