summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-09-18 03:31:56 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-18 07:02:03 -0700
commit5c297be9612f76dad6f970092fb6762b4ee4844a (patch)
treef65290e7f12e8d6913f3f3b8d3ffa8dc4cd06618 /xlators/cluster
parentfaa817ea9cb119c7f65fce24f03a172fa4b4ada1 (diff)
Glusterd: gluster volume set <volume> <option> <value>
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr.c225
-rw-r--r--xlators/cluster/dht/src/dht.c62
-rw-r--r--xlators/cluster/stripe/src/stripe.c36
3 files changed, 320 insertions, 3 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index e1154f9d154..a5906550d52 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -61,6 +61,231 @@ mem_acct_init (xlator_t *this)
}
+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;
+
+ 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;
+
+ 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;
+ }
+
+ 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);
+ }
+
+ 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);
+ }
+
+ 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;
+ }
+
+ priv->entry_self_heal = entry_self_heal;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring '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,
+ "Invalid 'option strict-readdir %s'. "
+ "Defaulting to old value.",
+ str_readdir);
+ ret = -1;
+ goto out;
+ }
+
+ priv->strict_readdir = strict_readdir;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring '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,
+ "Reconfiguring, Setting data self-heal window size to %d",
+ window_size);
+
+ priv->data_self_heal_window_size = window_size;
+ }
+
+ 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;
+ goto out;
+ }
+
+ priv->data_change_log = data_change_log;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring '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,
+ "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);
+ }
+
+ read_ret = dict_get_str (options, "read-subvolume", &read_subvol);
+
+ if (read_ret == -1)
+ 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;
+ ret = -1;
+ goto out;
+ }
+
+
+ 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:
+out:
+ return ret;
+
+}
+
+
static const char *favorite_child_warning_str = "You have specified subvolume '%s' "
"as the 'favorite child'. This means that if a discrepancy in the content "
"or attributes (ownership, permission, etc.) of a file is detected among "
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index c926a1cf400..bd0258eae21 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -252,6 +252,68 @@ mem_acct_init (xlator_t *this)
}
int
+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 = 0;
+
+
+ conf = this->private;
+
+ if (dict_get_str (options, "lookup-unhashed", &temp_str) == 0) {
+ /* If option is not "auto", other options _should_ be boolean*/
+ if (strcasecmp (temp_str, "auto")) {
+ if (!gf_string2boolean (temp_str, &search_unhashed)) {
+ gf_log(this->name, GF_LOG_DEBUG, "Reconfigure:"
+ " lookup-unahashed reconfigured (%s)",
+ temp_str);
+ conf->search_unhashed = search_unhashed;
+ }
+ else {
+ gf_log(this->name, GF_LOG_ERROR, "Reconfigure:"
+ " lookup-unahashed should be boolean,"
+ " not (%s), defaulting to (%d)",
+ temp_str, conf->search_unhashed);
+ //return -1;
+ ret = -1;
+ goto out;
+ }
+
+ }
+ else {
+ gf_log(this->name, GF_LOG_DEBUG, "Reconfigure:"
+ " lookup-unahashed reconfigured auto ");
+ conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_AUTO;
+ }
+ }
+
+ 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 ",
+ temp_str);
+ }
+
+out:
+ return ret;
+}
+
+int
init (xlator_t *this)
{
dht_conf_t *conf = NULL;
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index a9f62038914..00c888f68dd 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -3674,8 +3674,7 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
stripe_str = strtok_r (data, ",", &tmp_str);
while (stripe_str) {
dup_str = gf_strdup (stripe_str);
- stripe_opt = GF_CALLOC (1, sizeof (struct stripe_options),
- gf_stripe_mt_stripe_options);
+ stripe_opt = CALLOC (1, sizeof (struct stripe_options));
if (!stripe_opt) {
GF_FREE (dup_str);
goto out;
@@ -3735,6 +3734,37 @@ out:
return ret;
}
+int
+reconfigure (xlator_t *this, dict_t *options)
+{
+
+ stripe_private_t *priv = NULL;
+ data_t *data = NULL;
+ int ret = 0;
+
+
+ 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");
+ }
+
+out:
+ return ret;
+
+}
+
/**
* init - This function is called when xlator-graph gets initialized.
* The option given in volfiles are parsed here.
@@ -3873,7 +3903,7 @@ fini (xlator_t *this)
while (trav) {
prev = trav;
trav = trav->next;
- GF_FREE (prev);
+ FREE (prev);
}
LOCK_DESTROY (&priv->lock);
GF_FREE (priv);