summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-10-07 06:37:12 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-07 05:43:35 -0700
commitc7b518ab85f6fbcbdbae64c8fa092e998a14d1e9 (patch)
tree4f55db97bf6e843c96637264c8d97219a5b0aa38
parentf62484f42230db9d240c9b0eaadac48d845053b1 (diff)
mgmt/Glusterd: Volume set enhancements
- performance.flush-behind, transport.keepalive added - volume info to display the options reconfigured 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
-rw-r--r--cli/src/cli3_1-cops.c54
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c1
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c10
-rw-r--r--rpc/rpc-lib/src/rpc-transport.h11
-rw-r--r--rpc/rpc-transport/socket/src/socket.c61
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c37
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c3
-rw-r--r--xlators/performance/io-cache/src/io-cache.c8
-rw-r--r--xlators/performance/quick-read/src/quick-read.c48
-rw-r--r--xlators/performance/write-behind/src/write-behind.c25
-rw-r--r--xlators/protocol/server/src/server.c36
12 files changed, 284 insertions, 18 deletions
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 81e7ed663f6..8f170b98f9f 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -319,6 +319,33 @@ out:
return ret;
}
+void
+cli_out_options ( char *substr, char *optstr, char *valstr)
+{
+ char *ptr1 = NULL;
+ char *ptr2 = NULL;
+
+ ptr1 = substr;
+ ptr2 = optstr;
+
+ while (ptr1)
+ {
+ if (*ptr1 != *ptr2)
+ break;
+ ptr1++;
+ ptr2++;
+ if (!ptr1)
+ return;
+ if (!ptr2)
+ return;
+ }
+
+ if (*ptr2 == '\0')
+ return;
+ cli_out ("%s: %s",ptr2 , valstr);
+}
+
+
int
gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
@@ -338,6 +365,11 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int32_t j = 1;
cli_local_t *local = NULL;
int32_t transport = 0;
+ data_pair_t *pairs = NULL;
+ char *ptr = NULL;
+ data_t *value = NULL;
+
+
if (-1 == req->rpc_status) {
goto out;
@@ -474,6 +506,28 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("Brick%d: %s", j, brick);
j++;
}
+ pairs = dict->members_list;
+ if (!pairs) {
+ ret = -1;
+ goto out;
+ }
+
+ snprintf (key, 256, "volume%d.option.",i);
+ cli_out ("Options Reconfigured:");
+ while (pairs) {
+ ptr = strstr (pairs->key, "option.");
+ if (ptr) {
+ value = pairs->value;
+ if (!value) {
+ ret = -1;
+ goto out;
+ }
+ cli_out_options (key, pairs->key,
+ value->data);
+ }
+ pairs = pairs->next;
+ }
+
i++;
}
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 75ba8cc64fa..dc17a2f24f9 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -375,6 +375,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
if (ret < 0) {
gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG, "Reconfigure failed !!");
+ goto out;
}
ret = glusterfs_process_volfp (ctx, tmpfp);
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index 43b2a0c18cf..2a10a3b7f80 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -804,6 +804,8 @@ err:
return NULL;
}
+
+
rpc_transport_t *
rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
{
@@ -830,7 +832,7 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
type = str;
/* Backward compatibility */
- ret = dict_get_str (options, "transport-type", &type);
+ ret = dict_get_str (options, "transport-type", &type);
if (ret < 0) {
ret = dict_set_str (options, "transport-type", "socket");
if (ret < 0)
@@ -922,6 +924,12 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
"dlsym (gf_rpc_transport_fini) on %s", dlerror ());
goto fail;
}
+
+ trans->reconfigure = dlsym (handle, "reconfigure");
+ if (trans->fini == NULL) {
+ gf_log ("rpc-transport", GF_LOG_DEBUG,
+ "dlsym (gf_rpc_transport_reconfigure) on %s", dlerror());
+ }
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
gf_common_mt_volume_opt_list_t);
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h
index 478de9ef1c4..560eae45314 100644
--- a/rpc/rpc-lib/src/rpc-transport.h
+++ b/rpc/rpc-lib/src/rpc-transport.h
@@ -25,6 +25,7 @@
#include "config.h"
#endif
+
#include <inttypes.h>
#ifdef GF_SOLARIS_HOST_OS
#include <rpc/auth.h>
@@ -34,6 +35,7 @@
#include <rpc/rpc_msg.h>
+
#ifndef MAX_IOVEC
#define MAX_IOVEC 16
#endif
@@ -172,6 +174,8 @@ typedef struct rpc_transport_pollin rpc_transport_pollin_t;
typedef int (*rpc_transport_notify_t) (rpc_transport_t *, void *mydata,
rpc_transport_event_t, void *data, ...);
+
+
struct rpc_transport {
struct rpc_transport_ops *ops;
rpc_transport_t *listener; /* listener transport to which
@@ -179,6 +183,7 @@ struct rpc_transport {
* transport came from. valid only
* on server process.
*/
+
void *private;
void *xl_private;
void *xl; /* Used for THIS */
@@ -191,8 +196,12 @@ struct rpc_transport {
char *name;
void *dnscache;
data_t *buf;
- int32_t (*init) (rpc_transport_t *this);
+ int32_t (*init) (rpc_transport_t *this);
void (*fini) (rpc_transport_t *this);
+ int32_t (*validate_options) (rpc_transport_t *this,
+ dict_t *options,
+ char **op_errstr);
+ int (*reconfigure) (rpc_transport_t *this, dict_t *options);
rpc_transport_notify_t notify;
void *notify_data;
peer_info_t peerinfo;
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 40531ad4c2a..c5246822a7c 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2422,6 +2422,67 @@ struct rpc_transport_ops tops = {
.get_myaddr = socket_getmyaddr,
};
+int
+validate_options (rpc_transport_t *this, dict_t *options, char **op_errstr)
+{
+ char *optstr = NULL;
+ int ret = -1;
+ gf_boolean_t tmp_bool = _gf_false;
+
+ if (dict_get_str (options, "transport.socket.keepalive",
+ &optstr) == 0) {
+ if (gf_string2boolean (optstr, &tmp_bool) == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "'transport.socket.keepalive' takes only "
+ "boolean options, not taking any action");
+ *op_errstr = "Value should be only boolean!!";
+ ret =-1;
+ goto out;
+ }
+ }
+
+ ret =0;
+out:
+ return ret;
+
+}
+
+int
+reconfigure (rpc_transport_t *this, dict_t *options)
+{
+ socket_private_t *priv = NULL;
+ gf_boolean_t tmp_bool = _gf_false;
+ char *optstr = NULL;
+ int ret = -1;
+
+ if (!this || !this->private) {
+ ret =-1;
+ goto out;
+ }
+
+
+ priv = this->private;
+
+ if (dict_get_str (this->options, "transport.socket.keepalive",
+ &optstr) == 0) {
+ if (gf_string2boolean (optstr, &tmp_bool) == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "'transport.socket.keepalive' takes only "
+ "boolean options, not taking any action");
+ priv->keepalive = 1;
+ goto out;
+ }
+ gf_log (this->name, GF_LOG_DEBUG, "Reconfigured transport.socket.keepalive");
+
+ priv->keepalive = tmp_bool;
+ }
+ else
+ priv->keepalive = 1;
+ ret = 0;
+out:
+ return ret;
+
+}
int
socket_init (rpc_transport_t *this)
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 448dd65348d..57239c6266d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -254,6 +254,7 @@ out:
return ret;
}
+
int
glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
dict_t *volumes, int count)
@@ -264,6 +265,11 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo = NULL;
char *buf = NULL;
int i = 1;
+ data_pair_t *pairs = NULL;
+ char reconfig_key[256] = {0, };
+ dict_t *dict = NULL;
+ data_t *value = NULL;
+
GF_ASSERT (volinfo);
GF_ASSERT (volumes);
@@ -309,6 +315,37 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
goto out;
i++;
}
+
+ dict = volinfo->dict;
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ pairs = dict->members_list;
+ if (!pairs) {
+ ret = -1;
+ goto out;
+ }
+
+ while (pairs) {
+ if (1 == glusterd_check_option_exists (pairs->key, NULL)) {
+ value = pairs->value;
+ if (!value) {
+ ret = -1;
+ goto out;
+ }
+ snprintf (reconfig_key, 256, "volume%d.option.%s", count,
+ pairs->key);
+ gf_log ("", GF_LOG_DEBUG,
+ "Setting dict with key=%s, value=%s",
+ reconfig_key, pairs->value->data);
+ ret = dict_set_str (volumes, gf_strdup (reconfig_key),
+ value->data);
+ }
+ pairs = pairs->next;
+ }
+
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index d867497ccf9..4ae7afcc39d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1087,10 +1087,10 @@ out:
static int
glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr)
{
- int ret = 0;
- dict_t *dict = NULL;
- char *volname = NULL;
- gf_boolean_t exists = _gf_false;
+ int ret = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ int exists = 0;
char *key = NULL;
char *value = NULL;
char str[100] = {0, };
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 9d3ceaf5659..cfd7a7396a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -110,6 +110,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"performance.cache-priority", "performance/io-cache", "priority",}, /* NODOC */
{"performance.cache-size", "performance/io-cache", },
{"performance.cache-size", "performance/quick-read", },
+ {"performance.flush-behind", "performance/write-behind", "flush-behind",},
{"performance.io-thread-count", "performance/io-threads", "thread-count",},
@@ -124,6 +125,8 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"auth.allow", "protocol/server", "!server-auth", "*"},
{"auth.reject", "protocol/server", "!server-auth",},
+
+ {"transport.keepalive", "protocol/server", "transport.socket.keepalive",},
{"performance.write-behind", "performance/write-behind", "!perf", "on"}, /* NODOC */
{"performance.read-ahead", "performance/read-ahead", "!perf", "on"}, /* NODOC */
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index b094f97c4ef..04b5c394e0e 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -1674,7 +1674,7 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
}
- if (cache_size < (4*(2^20))) {
+ 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 (%d)"
@@ -1683,8 +1683,8 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
}
- if (cache_size > (6 *(2^30))) {
- gf_log(this->name, GF_LOG_ERROR, "Reconfiguration"
+ 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 (%d)"
, cache_size_string, table->cache_size);
@@ -1694,7 +1694,7 @@ reconfigure (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring "
- " cache-size %"PRIu64"", table->cache_size);
+ " cache-size %"PRIu64"", cache_size);
table->cache_size = cache_size;
}
else
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 91243561e3c..965f943799b 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -2417,6 +2417,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
char *str = NULL;
int32_t ret = -1;
int32_t cache_timeout;
+ uint64_t cache_size;
if (!this)
goto out;
@@ -2442,6 +2443,32 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
goto out;
}
}
+
+ ret = dict_get_str (this->options, "cache-size", &str);
+ if (ret == 0) {
+ ret = gf_string2bytesize (str, &cache_size);
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "invalid cache-size value %s", str);
+ ret = -1;
+ goto out;
+ }
+ if (cache_size > 6 * GF_UNIT_GB) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "invalid cache-size value %s", str);
+ *op_errstr = "Range 4mb <= value <= 6gb";
+ ret = -1;
+ goto out;
+ }
+ if (cache_size < 4* GF_UNIT_MB) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "invalid cache-size value %s", str);
+ *op_errstr = "Range 4mb <= value <= 6gb";
+ ret = -1;
+ goto out;
+ }
+
+ }
ret =0;
@@ -2461,6 +2488,7 @@ reconfigure (xlator_t *this, dict_t *options)
qr_private_t *priv = NULL;
qr_conf_t *conf = NULL;
int32_t cache_timeout;
+ uint64_t cache_size;
if (!this)
goto out;
@@ -2474,7 +2502,7 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
cache_timeout = conf->cache_timeout;
- ret = dict_get_str (this->options, "cache-timeout", &str);
+ ret = dict_get_str (options, "cache-timeout", &str);
if (ret == 0) {
ret = gf_string2uint_base10 (str,
(unsigned int *)&conf->cache_timeout);
@@ -2489,6 +2517,24 @@ reconfigure (xlator_t *this, dict_t *options)
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_log (this->name, GF_LOG_DEBUG,
+ "Reconfiguring cache-siz to %d", cache_size);
+ conf->cache_size = cache_size;
+ }
+ else
+ conf->cache_size = QR_DEFAULT_CACHE_SIZE;
+
ret = 0;
out:
return ret;
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index ef596dfbeaa..8a4be0f7f99 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2751,7 +2751,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
goto out;
}
- if (window_size < (524288)) {
+ if (window_size < (512 * GF_UNIT_KB)) {
gf_log(this->name, GF_LOG_WARNING, "Validation"
"'option cache-size %s' failed , Min value"
"should be 512KiB ", str);
@@ -2760,7 +2760,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
goto out;
}
- if (window_size > (1073741824)) {
+ if (window_size > (1 * GF_UNIT_GB)) {
gf_log(this->name, GF_LOG_WARNING, "Reconfiguration"
"'option cache-size %s' failed , Max value"
"can be 1 GiB", str);
@@ -2840,6 +2840,27 @@ reconfigure (xlator_t *this, dict_t *options)
}
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;
+ return -1;
+ }
+ if (conf->flush_behind) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "enabling flush-behind");
+ }
+ else
+ gf_log (this->name, GF_LOG_DEBUG,
+ "disabling flush-behind");
+ }
+
out:
return 0;
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 4fcce6e99d2..2ff5cf5a94f 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -26,6 +26,7 @@
#include <sys/time.h>
#include <sys/resource.h>
+
#include "server.h"
#include "server-helpers.h"
#include "glusterfs3-xdr.h"
@@ -544,14 +545,20 @@ int
reconfigure (xlator_t *this, dict_t *options)
{
- server_conf_t *conf =NULL;
- int inode_lru_limit;
- gf_boolean_t trace;
- data_t *data;
- int ret;
+ server_conf_t *conf =NULL;
+ rpcsvc_t *rpc_conf;
+ rpcsvc_listener_t *listeners;
+ int inode_lru_limit;
+ gf_boolean_t trace;
+ data_t *data;
+ int ret = 0;
conf = this->private;
+ if (!conf) {
+ gf_log (this->name, GF_LOG_DEBUG, "conf == null!!!");
+ goto out;
+ }
if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){
conf->inode_lru_limit = inode_lru_limit;
gf_log (this->name, GF_LOG_TRACE, "Reconfigured inode-lru-limit"
@@ -589,8 +596,27 @@ reconfigure (xlator_t *this, dict_t *options)
dict_unref (conf->auth_modules);
goto out;
}
+
+ rpc_conf = conf->rpc;
+ if (!rpc_conf) {
+ gf_log (this->name, GF_LOG_ERROR, "No rpc_conf !!!!");
+ goto out;
+ }
+
+ list_for_each_entry (listeners, &(rpc_conf->listeners), list) {
+ if (listeners->trans != NULL) {
+ if (listeners->trans->reconfigure )
+ listeners->trans->reconfigure (listeners->trans, options);
+ else
+ gf_log (this->name, GF_LOG_ERROR,
+ "Reconfigure not found for transport" );
+ }
+ }
+
+
out:
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
return ret;
}