summaryrefslogtreecommitdiffstats
path: root/xlators/performance/io-cache
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/performance/io-cache
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/performance/io-cache')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 490d3168836..296edf23303 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1470,6 +1470,165 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+reconfigure (xlator_t *this, dict_t *options)
+{
+ ioc_table_t *table = NULL;
+ int32_t cache_timeout;
+ int64_t min_file_size = 0;
+ int64_t max_file_size = 0;
+ char *tmp = NULL;
+ uint64_t cache_size;
+ char *cache_size_string = NULL;
+ int ret = 0;
+
+ table = this->private;
+
+ ioc_table_lock (table);
+ {
+ if (dict_get (options, "cache-timeout")) {
+ cache_timeout =
+ data_to_uint32 (dict_get (options,
+ "cache-timeout"));
+ if (cache_timeout < 0){
+ gf_log (this->name, GF_LOG_WARNING,
+ "cache-timeout %d seconds invalid,"
+ " has to be >=0", cache_timeout);
+ ret = -1;
+ goto out;
+ }
+
+
+ if (cache_timeout > 60){
+ gf_log (this->name, GF_LOG_WARNING,
+ "cache-timeout %d seconds invalid,"
+ " has to be <=60", cache_timeout);
+ ret = -1;
+ goto out;
+ }
+
+ table->cache_timeout = cache_timeout;
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring %d seconds to"
+ " revalidate cache", table->cache_timeout);
+ }
+
+
+ if (dict_get (options, "cache-size"))
+ cache_size_string = data_to_str (dict_get (options,
+ "cache-size"));
+ if (cache_size_string) {
+ if (gf_string2bytesize (cache_size_string,
+ &cache_size) != 0) {
+ gf_log ("io-cache", GF_LOG_ERROR,
+ "invalid number format \"%s\" of "
+ "\"option cache-size\" Defaulting"
+ "to old value", cache_size_string);
+ ret = -1;
+ goto out;
+ }
+
+ if (cache_size < (4*(2^20))) {
+ gf_log(this->name, GF_LOG_ERROR, "Reconfiguration"
+ "'option cache-size %s' failed , Max value"
+ "can be 4MiB, Defaulting to old value (%d)"
+ , cache_size_string, table->cache_size);
+ ret = -1;
+ goto out;
+ }
+
+ if (cache_size > (6 *(2^30))) {
+ gf_log(this->name, GF_LOG_ERROR, "Reconfiguration"
+ "'option cache-size %s' failed , Max value"
+ "can be 6GiB, Defaulting to old value (%d)"
+ , cache_size_string, table->cache_size);
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring "
+ " cache-size %"PRIu64"", table->cache_size);
+ table->cache_size = cache_size;
+ }
+
+
+ if (dict_get (options, "priority")) {
+ char *option_list = data_to_str (dict_get (options,
+ "priority"));
+ gf_log (this->name, GF_LOG_TRACE,
+ "option path %s", option_list);
+ /* parse the list of pattern:priority */
+ table->max_pri = ioc_get_priority_list (option_list,
+ &table->priority_list);
+
+ if (table->max_pri == -1) {
+ ret = -1;
+ goto out;
+ }
+ table->max_pri ++;
+ }
+
+
+
+ min_file_size = table->min_file_size;
+ tmp = data_to_str (dict_get (options, "min-file-size"));
+ if (tmp != NULL) {
+ if (gf_string2bytesize (tmp,
+ (uint64_t *)&min_file_size)
+ != 0) {
+ gf_log ("io-cache", GF_LOG_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;
+ tmp = data_to_str (dict_get (options, "max-file-size"));
+ if (tmp != NULL) {
+ if (gf_string2bytesize (tmp,
+ (uint64_t *)&max_file_size)
+ != 0) {
+ gf_log ("io-cache", GF_LOG_ERROR,
+ "invalid number format \"%s\" of "
+ "\"option max-file-size\"", tmp);
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring max-file-size %"PRIu64"",
+ table->max_file_size);
+ }
+
+ if ((max_file_size >= 0) & (min_file_size > max_file_size)) {
+ gf_log ("io-cache", 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);
+ ret = -1;
+ goto out;
+ }
+
+ table->min_file_size = min_file_size;
+ table->max_file_size = max_file_size;
+ }
+
+ ioc_table_unlock (table);
+out:
+ return ret;
+
+}
+
/*
* init -
* @this: