summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr.c239
-rw-r--r--xlators/cluster/dht/src/dht.c39
-rw-r--r--xlators/cluster/stripe/src/stripe.c43
3 files changed, 321 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 813fbb249..b026db594 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -59,7 +59,242 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+
+
+ gf_boolean_t metadata_self_heal;
+ gf_boolean_t entry_self_heal;
+ gf_boolean_t data_self_heal;
+ gf_boolean_t data_change_log;
+ gf_boolean_t metadata_change_log;
+ gf_boolean_t entry_change_log;
+ gf_boolean_t strict_readdir;
+
+ xlator_list_t * trav = NULL;
+
+ char * read_subvol = NULL;
+ char * self_heal = NULL;
+ char * change_log = NULL;
+ char * str_readdir = NULL;
+ int32_t background_count = 0;
+ int32_t window_size = 0;
+
+ int read_ret = -1;
+ int dict_ret = -1;
+ int flag = 1;
+ int ret = 0;
+ int temp_ret = -1;
+
+
+
+ dict_ret = dict_get_int32 (options, "background-self-heal-count",
+ &background_count);
+ if (dict_ret == 0) {
+ if (background_count < 0) {
+ *op_errstr = gf_strdup ("Error, option should be >= 0");
+ ret = -1;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validated background self-heal count to %d",
+ background_count);
+ }
+
+ dict_ret = dict_get_str (options, "metadata-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &metadata_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "validation failed 'option metadata"
+ "-self-heal %s'.not correct.",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+
+ }
+
+ dict_ret = dict_get_str (options, "data-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &data_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation failed for data self heal",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring 'option data"
+ "-self-heal %s'.", self_heal);
+ }
+
+ dict_ret = dict_get_str (options, "entry-self-heal",
+ &self_heal);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (self_heal, &entry_self_heal);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for entry-self-heal",
+ self_heal);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option entry"
+ "-self-heal %s'.", self_heal);
+ }
+
+
+ dict_ret = dict_get_str (options, "strict-readdir",
+ &str_readdir);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (str_readdir, &strict_readdir);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for strict_readdir",
+ str_readdir);
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option strict"
+ "-readdir %s'.", str_readdir);
+ }
+
+ dict_ret = dict_get_int32 (options, "data-self-heal-window-size",
+ &window_size);
+ if (dict_ret == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validated data self-heal window size to %d",
+ window_size);
+
+ if (window_size < 0) {
+ *op_errstr = gf_strdup ("Error, option should be >= 0");
+ ret = -1;
+ goto out;
+ }
+
+ if (window_size > 1024) {
+ *op_errstr = gf_strdup ("Error, option should be <= 1024");
+ ret = -1;
+ goto out;
+ }
+
+
+ }
+
+ dict_ret = dict_get_str (options, "data-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log, &data_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faled for data-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option data-"
+ "change-log %s'.", change_log);
+ }
+
+ dict_ret = dict_get_str (options, "metadata-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log,
+ &metadata_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faild for metadata-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option metadata-"
+ "change-log %s'.", change_log);
+ }
+
+ dict_ret = dict_get_str (options, "entry-change-log",
+ &change_log);
+ if (dict_ret == 0) {
+ temp_ret = gf_string2boolean (change_log, &entry_change_log);
+ if (temp_ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Validation faild for entr-change-log");
+ *op_errstr = gf_strdup ("Error, option should be boolean");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated 'option entry-"
+ "change-log %s'.", change_log);
+ }
+
+ read_ret = dict_get_str (options, "read-subvolume", &read_subvol);
+
+ if (read_ret)
+ goto next;// No need to traverse, hence set the next option
+
+ trav = this->children;
+ flag = 0;
+ while (trav) {
+ if (!read_ret && !strcmp (read_subvol, trav->xlator->name)) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Validated Subvolume '%s' as read child.",
+ trav->xlator->name);
+
+ flag = 1;
+ ret = 0;
+ goto out;
+ }
+
+
+ trav = trav->next;
+ }
+
+ if (flag == 0 ) {
+
+ gf_log (this->name, GF_LOG_WARNING,
+ "Invalid 'option read-subvolume %s', no such subvolume"
+ , read_subvol);
+ *op_errstr = gf_strdup ("Error, the sub-volume is not right");
+ ret = -1;
+ goto out;
+ }
+
+next:
+out:
+ return ret;
+
+
+}
int
@@ -190,6 +425,10 @@ reconfigure (xlator_t *this, dict_t *options)
priv->data_self_heal_window_size = window_size;
}
+ else {
+ priv->data_self_heal_window_size = 16;
+ }
+
dict_ret = dict_get_str (options, "data-change-log",
&change_log);
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index 2c2f17507..2c8f2e9a2 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -250,6 +250,45 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ char *temp_str = NULL;
+ gf_boolean_t search_unhashed;
+ int ret = 0;
+
+
+
+
+
+ if (dict_get_str (options, "lookup-unhashed", &temp_str) == 0) {
+ if (strcasecmp (temp_str, "auto")) {
+ if (!gf_string2boolean (temp_str, &search_unhashed)) {
+ gf_log(this->name, GF_LOG_DEBUG, "Validated"
+ " lookup-unahashed (%s)",
+ temp_str);
+ }
+ else {
+ gf_log(this->name, GF_LOG_ERROR, "Validation:"
+ " lookup-unahashed should be boolean,"
+ " not (%s)",
+ temp_str);
+ *op_errstr = gf_strdup ("Error, lookup-"
+ "unhashed be boolean");
+ ret = -1;
+ goto out;
+ }
+
+ }
+ }
+
+
+
+
+
+out:
+ return ret;
+}
int
reconfigure (xlator_t *this, dict_t *options)
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index 4eb6aebea..a8ac55aa4 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3735,6 +3735,45 @@ mem_acct_init (xlator_t *this)
out:
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+
+
+ data_t *data = NULL;
+ int ret = 0;
+ stripe_private_t *priv = NULL;
+
+ data = dict_get (options, "block-size");
+ if (data) {
+ gf_log (this->name, GF_LOG_TRACE,"Reconfiguring Stripe"
+ " Block-size");
+ priv = GF_CALLOC (1, sizeof (stripe_private_t),
+ gf_stripe_mt_stripe_private_t);
+ if (!priv) {
+ gf_log ("",GF_LOG_ERROR, "Unable to allocate memory");
+ ret = -1;
+ goto out;
+ }
+
+ ret = set_stripe_block_size (this, priv, data->data);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfigue: Block-Size reconfiguration failed");
+ *op_errstr = gf_strdup ("Error, could not parse list");
+ ret = -1;
+ goto out;
+ }
+ gf_log (this->name, GF_LOG_TRACE,
+ "Reconfigue: Block-Size reconfigured Successfully");
+ }
+
+out:
+ if (priv)
+ GF_FREE (priv);
+ return ret;
+
+}
int
reconfigure (xlator_t *this, dict_t *options)
@@ -3761,6 +3800,10 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_TRACE,
"Reconfigue: Block-Size reconfigured Successfully");
}
+ else {
+ priv->block_size = (128 * GF_UNIT_KB);
+ }
+
out:
return ret;