summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c59
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c257
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c292
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c8
8 files changed, 598 insertions, 33 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 2c99a60e2..bc015293f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1641,6 +1641,42 @@ out:
}
int
+glusterd_handle_set_volume (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_set_vol_req cli_req = {0,};
+ dict_t *dict = NULL;
+
+ GF_ASSERT (req);
+
+ if (!gf_xdr_to_cli_set_vol_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+
+ ret = glusterd_set_volume (req, dict);
+
+out:
+ return ret;
+}
+
+int
glusterd_handle_remove_brick (rpcsvc_request_t *req)
{
int32_t ret = -1;
@@ -2970,6 +3006,29 @@ glusterd_replace_brick (rpcsvc_request_t *req, dict_t *dict)
}
int32_t
+glusterd_set_volume (rpcsvc_request_t *req, dict_t *dict)
+{
+ int32_t ret = -1;
+
+ GF_ASSERT (req);
+ GF_ASSERT (dict);
+
+ glusterd_op_set_op (GD_OP_SET_VOLUME);
+
+ glusterd_op_set_ctx (GD_OP_SET_VOLUME, dict);
+
+ glusterd_op_set_ctx_free (GD_OP_SET_VOLUME, _gf_true);
+
+ glusterd_op_set_cli_op (GD_MGMT_CLI_SET_VOLUME);
+
+ glusterd_op_set_req (req);
+
+ ret = glusterd_op_txn_begin ();
+
+ return ret;
+}
+
+int32_t
glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict)
{
int32_t ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 1497ae4ad..651cb22e0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -118,6 +118,7 @@ glusterd_op_get_len (glusterd_op_t op)
case GD_OP_START_BRICK:
break;
+ case GD_OP_SET_VOLUME:
case GD_OP_REPLACE_BRICK:
case GD_OP_ADD_BRICK:
{
@@ -125,7 +126,6 @@ glusterd_op_get_len (glusterd_op_t op)
ret = dict_serialized_length (dict);
return ret;
}
-
case GD_OP_REMOVE_BRICK:
{
dict_t *dict = glusterd_op_get_ctx (op);
@@ -266,6 +266,20 @@ glusterd_op_build_payload (glusterd_op_t op, gd1_mgmt_stage_op_req **req)
}
break;
+ case GD_OP_SET_VOLUME:
+ {
+ dict_t *dict = NULL;
+ dict = glusterd_op_get_ctx (op);
+ GF_ASSERT (dict);
+ ret = dict_allocate_and_serialize (dict,
+ &stage_req->buf.buf_val,
+ (size_t *)&stage_req->buf.buf_len);
+ if (ret) {
+ goto out;
+ }
+ }
+ break;
+
case GD_OP_REMOVE_BRICK:
{
dict_t *dict = NULL;
@@ -996,6 +1010,128 @@ out:
}
static int
+glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ gf_boolean_t exists = _gf_false;
+ char *key = NULL;
+ char str[100] = {0, };
+ int count = 0;
+
+ GF_ASSERT (req);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ goto out;
+ }
+
+ exists = glusterd_check_volume_exists (volname);
+
+ if (!exists) {
+ gf_log ("", GF_LOG_ERROR, "Volume with name: %s "
+ "does not exist",
+ volname);
+ ret = -1;
+ goto out;
+ }
+
+
+ for ( count = 1; ret != -1 ; count++ ) {
+
+ sprintf (str, "key%d", count);
+ ret = dict_get_str (dict, str, &key);
+
+
+ if (ret)
+ break;
+
+ exists = glusterd_check_option_exists(key);
+
+ if (!exists) {
+ gf_log ("", GF_LOG_ERROR, "Option with name: %s "
+ "does not exist", key);
+ ret = -1;
+ goto out;
+ }
+
+
+ }
+
+ if ( count == 1 ) {
+ gf_log ("", GF_LOG_ERROR, "No options received ");
+ ret = -1;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
+
+char *set_option_list[] = {
+ "max-file-size",
+ "min-file-size",
+ "cache-timeout",
+ "priority",
+ "entry-change-log",
+ "read-subvolume",
+ "background-self-heal-count",
+ "metadata-self-heal",
+ "data-self-heal",
+ "entry-self-heal",
+ "strict-readdir",
+ "data-self-heal-window-size",
+ "data-change-log",
+ "metadata-change-log",
+ "frame-timeout",
+ "ping-timeout",
+ "cache-size",
+ "disk-usage-limit",
+ "min-free-disk-limit",
+ "block-size",
+ "inode-lru-limit",
+ "thread-count" ,
+ "lookup-unhashed",
+ "min-free-disk"
+};
+
+
+gf_boolean_t
+glusterd_check_option_exists(char *optstring)
+{
+ //struct set_option_list *list;
+ char **list = NULL;
+
+
+ for (list = &set_option_list[0]; *list ;list++)
+ if (!strcmp (optstring, *list))
+ return _gf_true;
+
+
+ return _gf_false;
+
+}
+
+static int
glusterd_op_stage_remove_brick (gd1_mgmt_stage_op_req *req)
{
int ret = 0;
@@ -2231,6 +2367,106 @@ out:
}
static int
+glusterd_op_set_volume (gd1_mgmt_stage_op_req *req)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ char *volname = NULL;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ int count = 1;
+ char *key = NULL;
+ char *value = NULL;
+ char str[50] = {0, };
+ GF_ASSERT (req);
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+
+ ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ goto out;
+ }
+
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to allocate memory");
+ goto out;
+ }
+
+ for ( count = 1; ret != -1 ; count++ ) {
+
+ sprintf (str, "key%d", count);
+ ret = dict_get_str (dict, str, &key);
+
+
+ if (ret)
+ break;
+
+ sprintf (str, "value%d", count);
+ ret = dict_get_str (dict, str, &value);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "invalid key,value pair"
+ "in 'volume set'");
+ ret = -1;
+ goto out;
+ }
+
+ ret = set_xlator_option (volinfo->dict, key, value);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to set the options"
+ "in 'volume set'");
+ ret = -1;
+ goto out;
+ }
+ }
+
+ if ( count == 1 ) {
+ gf_log ("", GF_LOG_ERROR, "No options received ");
+ ret = -1;
+ goto out;
+ }
+
+ ret = glusterd_create_volfiles (volinfo);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to create volfile for"
+ " 'volume set'");
+ ret = -1;
+ goto out;
+ }
+
+
+
+
+ gf_log ("", GF_LOG_DEBUG, "Received set volume command");
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
{
int ret = 0;
@@ -3208,6 +3444,17 @@ glusterd_op_send_cli_response (int32_t op, int32_t op_ret,
break;
}
+ case GD_MGMT_CLI_SET_VOLUME:
+ {
+ gf1_cli_set_vol_rsp rsp = {0,};
+ rsp.op_ret = op_ret;
+ rsp.op_errno = op_errno;
+ rsp.volname = "";
+ cli_rsp = &rsp;
+ sfunc = gf_xdr_serialize_cli_set_vol_rsp;
+ break;
+ }
+
case GD_MGMT_CLI_LOG_FILENAME:
{
gf1_cli_log_filename_rsp rsp = {0,};
@@ -3460,6 +3707,10 @@ glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req, char **op_errstr)
ret = glusterd_op_stage_replace_brick (req);
break;
+ case GD_OP_SET_VOLUME:
+ ret = glusterd_op_stage_set_volume (req);
+ break;
+
case GD_OP_REMOVE_BRICK:
ret = glusterd_op_stage_remove_brick (req);
break;
@@ -3515,6 +3766,10 @@ glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req, char **op_errstr)
ret = glusterd_op_replace_brick (req);
break;
+ case GD_OP_SET_VOLUME:
+ ret = glusterd_op_set_volume (req);
+ break;
+
case GD_OP_REMOVE_BRICK:
ret = glusterd_op_remove_brick (req);
break;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 66435c8d2..e14f00759 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -96,6 +96,7 @@ typedef enum glusterd_op_ {
GD_OP_ADD_BRICK,
GD_OP_REMOVE_BRICK,
GD_OP_REPLACE_BRICK,
+ GD_OP_SET_VOLUME,
GD_OP_SYNC_VOLUME,
GD_OP_LOG_FILENAME,
GD_OP_LOG_LOCATE,
@@ -237,6 +238,9 @@ glusterd_op_clear_ctx_free (glusterd_op_t op);
gf_boolean_t
glusterd_op_get_ctx_free (glusterd_op_t op);
+gf_boolean_t
+glusterd_check_option_exists(char *optstring);
+
int
set_xlator_option (dict_t *dict, char *key, char *value);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 30ba51416..017ab6873 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -886,6 +886,8 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
"--brick-port %d -l %s", GFS_PREFIX, volinfo->volname,
port, volfile, pidfile, brickinfo->path, port,
brickinfo->logfile);
+
+ gf_log ("",GF_LOG_DEBUG,"Starting GlusterFS Command Executed: \n %s \n", cmd_str);
ret = gf_system (cmd_str);
if (ret == 0) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 3998a0190..28b814500 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -468,13 +468,18 @@ __write_client_xlator (FILE *file, dict_t *dict,
char *opt_transtype = NULL;
char *opt_nodelay = NULL;
int ret = 0;
-
+ char *ping = NULL;
+ char *frame = NULL;
+ char ping_timeout[100] = {0, };
+ char frame_timeout[100] = {0, };
const char *client_str = "volume %s-%s-%d\n"
" type protocol/client\n"
" option transport-type %s\n"
" option remote-host %s\n"
" option transport.socket.nodelay %s\n"
+ "%s" //for frame-timeout
+ "%s" //for ping-timeout
" option remote-subvolume %s\n"
"end-volume\n\n";
@@ -495,6 +500,26 @@ __write_client_xlator (FILE *file, dict_t *dict,
goto out;
}
+ if (dict_get (dict, "frame-timeout")) {
+ ret = dict_get_str (dict, "frame-timeout", &frame);
+ if (ret) {
+ goto out;
+ }
+ gf_log ("", GF_LOG_DEBUG, "Reconfiguring frame-timeout %s",
+ frame);
+ sprintf(frame_timeout, " option frame-timeout %s\n",frame);
+ }
+
+ if (dict_get (dict, "ping-timeout")) {
+ ret = dict_get_str (dict, "ping-timeout", &ping);
+ if (ret) {
+ goto out;
+ }
+ gf_log ("", GF_LOG_DEBUG, "Reconfiguring ping-timeout %s",
+ ping);
+ sprintf(ping_timeout, " option ping-timeout %s\n",ping);
+ }
+
fprintf (file, client_str,
volname,
"client",
@@ -502,6 +527,8 @@ __write_client_xlator (FILE *file, dict_t *dict,
opt_transtype,
remote_host,
opt_nodelay,
+ frame_timeout,
+ ping_timeout,
remote_subvol);
ret = 0;
@@ -608,8 +635,14 @@ __write_iothreads_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOT_OPTION_THREADCOUNT,
- &opt_threadcount);
+ if (dict_get (dict, "thread-count")) {
+ gf_log("", GF_LOG_DEBUG, "Resetting the thread-count value");
+ ret = dict_get_str (dict, "thread-count", &opt_threadcount);
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOT_OPTION_THREADCOUNT,
+ &opt_threadcount);
+
if (ret) {
goto out;
}
@@ -675,16 +708,19 @@ static int
__write_server_xlator (FILE *file, dict_t *dict,
char *subvolume)
{
- char *volname = NULL;
- char *opt_transtype = NULL;
- char *opt_nodelay = NULL;
- int ret = -1;
+ char *volname = NULL;
+ char *opt_transtype = NULL;
+ char *opt_nodelay = NULL;
+ int ret = -1;
+ char *lru_count = NULL;
+ char inode_lru_count[100] = {0,};
const char *server_str = "volume %s-%s\n"
" type protocol/server\n"
" option transport-type %s\n"
" option auth.addr.%s.allow *\n"
" option transport.socket.nodelay %s\n"
+ "%s"//for inode-lru-limit
" subvolumes %s\n"
"end-volume\n\n";
@@ -705,12 +741,25 @@ __write_server_xlator (FILE *file, dict_t *dict,
goto out;
}
+ if (dict_get (dict, "inode-lru-limit")) {
+ ret = dict_get_str (dict, "inode-lru-limit", &lru_count);
+ if (ret) {
+ goto out;
+ }
+ gf_log ("", GF_LOG_DEBUG, "Reconfiguring inode-lru-limit %s",
+ lru_count);
+ sprintf (inode_lru_count, " option inode-lru-limit %s\n",
+ lru_count);
+ }
+
fprintf (file, server_str,
volname, "server",
opt_transtype,
subvolume,
opt_nodelay,
- subvolume);
+ inode_lru_count,
+ subvolume
+ );
ret = 0;
@@ -747,7 +796,7 @@ __write_replicate_xlator (FILE *file, dict_t *dict,
int subvol_len = 0;
- const char *replicate_str = "volume %s-%s-%d\n"
+ char replicate_str[] = "volume %s-%s-%d\n"
" type cluster/replicate\n"
"# option read-subvolume %s\n"
"# option favorite-child %s\n"
@@ -771,7 +820,15 @@ __write_replicate_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_READSUBVOL,
+ if (dict_get (dict, "read-subvolume")) {
+ ret = dict_get_str (dict, "read-subvolume", &opt_readsubvol);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring read-subvolume: %s",
+ &opt_readsubvol);
+ uncomment_option (replicate_str,
+ (char *) "# option read-subvolume %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_READSUBVOL,
&opt_readsubvol);
if (ret) {
goto out;
@@ -783,14 +840,32 @@ __write_replicate_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_BCKSHCOUNT,
+ if (dict_get (dict, "background-self-heal-count")) {
+ ret = dict_get_str (dict,"background-self-heal-count",
+ &opt_bckshcount);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring background-self-heal-"
+ "count: %s", &opt_bckshcount);
+ uncomment_option (replicate_str,
+ (char *) "# option background-self-heal-count %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_BCKSHCOUNT,
&opt_bckshcount);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_DATASH,
- &opt_datash);
+ if (dict_get (dict, "data-self-heal")) {
+ ret = dict_get_str (dict,"data-self-heal",
+ &opt_datash);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring data-self-heal"
+ "count: %s", &opt_datash);
+ uncomment_option (replicate_str,
+ (char *) "# option data-self-heal %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_DATASH,
+ &opt_datash);
if (ret) {
goto out;
}
@@ -801,43 +876,106 @@ __write_replicate_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_SHWINDOWSIZE,
+ if (dict_get (dict, "data-self-heal-window-size")) {
+ ret = dict_get_str (dict,"data-self-heal-window-size",
+ &opt_shwindowsize);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring data-self-heal"
+ "window-size: %s", &opt_shwindowsize);
+ uncomment_option (replicate_str,
+ (char *) "# option data-self-heal-window-size %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_SHWINDOWSIZE,
&opt_shwindowsize);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_METASH,
+ if (dict_get (dict, "metadata-self-heal")) {
+ ret = dict_get_str (dict,"metadata-self-heal",
+ &opt_metash);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring metadata-self-heal"
+ "count: %s", &opt_metash);
+ uncomment_option (replicate_str,
+ (char *) "# option metadata-self-heal %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_METASH,
&opt_metash);
if (ret) {
goto out;
}
-
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_ENTRYSH,
+
+ if (dict_get (dict, "entry-self-heal")) {
+ ret = dict_get_str (dict,"entry-self-heal",
+ &opt_entrysh);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring entry-self-heal"
+ "count: %s", &opt_entrysh);
+ uncomment_option (replicate_str,
+ (char *) "# option entry-self-heal %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_ENTRYSH,
&opt_entrysh);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_DATACHANGELOG,
+ if (dict_get (dict, "data-change-log")) {
+ ret = dict_get_str (dict,"data-change-log",
+ &opt_datachangelog);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring data-change-log"
+ "count: %s", &opt_datachangelog);
+ uncomment_option (replicate_str,
+ (char *) "# option data-change-log %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_DATACHANGELOG,
&opt_datachangelog);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_METADATACHANGELOG,
+ if (dict_get (dict, "metadata-change-log")) {
+ ret = dict_get_str (dict,"metadata-change-log",
+ &opt_metadatachangelog);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring metadata-change-log"
+ "count: %s", &opt_metadatachangelog);
+ uncomment_option (replicate_str,
+ (char *) "# option metadata-change-log %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_METADATACHANGELOG,
&opt_metadatachangelog);
if (ret) {
goto out;
}
+ if (dict_get (dict, "entry-change-log")) {
+ ret = dict_get_str (dict, "entry-change-log", &opt_entrychangelog);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring entry-change-log: %s",
+ &opt_entrychangelog);
+ uncomment_option (replicate_str,
+ (char *) "# option entry-change-log %s\n");
+ }
+ else
+
ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_ENTRYCHANGELOG,
&opt_entrychangelog);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_STRICTREADDIR,
+ if (dict_get (dict, "strict-readdir")) {
+ ret = dict_get_str (dict,"strict-readdir",
+ &opt_strictreaddir);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring sstrict-readdir"
+ "count: %s", &opt_strictreaddir);
+ uncomment_option (replicate_str,
+ (char *) "# option strict-readdir %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_REPLICATE_OPTION_STRICTREADDIR,
&opt_strictreaddir);
if (ret) {
goto out;
@@ -914,7 +1052,7 @@ __write_stripe_xlator (FILE *file, dict_t *dict,
int subvol_len = 0;
int len = 0;
- const char *stripe_str = "volume %s-%s-%d\n"
+ char stripe_str[] = "volume %s-%s-%d\n"
" type cluster/stripe\n"
"# option block-size %s\n"
"# option use-xattr %s\n"
@@ -928,7 +1066,15 @@ __write_stripe_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_STRIPE_OPTION_BLOCKSIZE,
+ if (dict_get (dict, "block-size")) {
+ ret = dict_get_str (dict, "block-size", &opt_blocksize);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring Stripe Count %s",
+ opt_blocksize);
+ uncomment_option (stripe_str,
+ (char *) "# option block-size %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_STRIPE_OPTION_BLOCKSIZE,
&opt_blocksize);
if (ret) {
goto out;
@@ -999,7 +1145,7 @@ __write_distribute_xlator (FILE *file, dict_t *dict,
int subvol_len = 0;
int len = 0;
- const char *dht_str = "volume %s-%s\n"
+ char dht_str[] = "volume %s-%s\n"
"type cluster/distribute\n"
"# option lookup-unhashed %s\n"
"# option min-free-disk %s\n"
@@ -1012,12 +1158,28 @@ __write_distribute_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_DHT_OPTION_LOOKUPUNHASH,
+ if (dict_get (dict, "lookup-unhashed")) {
+ ret = dict_get_str (dict, "lookup-unhashed", &opt_lookupunhash);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring lookup-unhashed %s",
+ opt_lookupunhash);
+ uncomment_option (dht_str,
+ (char *) "# option lookup-unhashed %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_DHT_OPTION_LOOKUPUNHASH,
&opt_lookupunhash);
if (ret) {
goto out;
}
+ if (dict_get (dict, "min-free-disk")) {
+ ret = dict_get_str (dict, "min-free-disk", &opt_minfreedisk);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring min-free-disk",
+ opt_minfreedisk);
+ uncomment_option (dht_str,
+ (char *) "# option min-free-disk %s\n");
+ }
+ else
ret = dict_get_str (dict, VOLGEN_DHT_OPTION_MINFREEDISK,
&opt_minfreedisk);
if (ret) {
@@ -1067,6 +1229,24 @@ out:
return ret;
}
+
+int
+uncomment_option( char *opt_str,char *comment_str)
+{
+ char *ptr;
+
+ ptr = strstr (opt_str,comment_str);
+ if (!ptr)
+ return -1;
+
+ if (*ptr != '#')
+ return -1;
+
+ *ptr = ' ';
+
+ return 0;
+}
+
static int
__write_wb_xlator (FILE *file, dict_t *dict,
char *subvolume)
@@ -1079,7 +1259,7 @@ __write_wb_xlator (FILE *file, dict_t *dict,
char *opt_tricklingwrites = NULL;
int ret = -1;
- const char *dht_str = "volume %s-%s\n"
+ char dht_str[] = "volume %s-%s\n"
" type performance/write-behind\n"
"# option flush-behind %s\n"
"# option cache-size %s\n"
@@ -1100,7 +1280,13 @@ __write_wb_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_WB_OPTION_CACHESIZE,
+ if (dict_get (dict, "cache-size")) {
+ gf_log("",GF_LOG_DEBUG, "Uncommenting option cache-size");
+ uncomment_option (dht_str,(char *) "# option cache-size %s\n");
+ ret = dict_get_str (dict, "cache-size", &opt_cachesize);
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_WB_OPTION_CACHESIZE,
&opt_cachesize);
if (ret) {
goto out;
@@ -1200,7 +1386,7 @@ __write_iocache_xlator (FILE *file, dict_t *dict,
char *opt_maxfilesize = NULL;
int ret = -1;
- const char *iocache_str = "volume %s-%s\n"
+ char iocache_str[] = "volume %s-%s\n"
" type performance/io-cache\n"
"# option priority %s\n"
"# option cache-timeout %s\n"
@@ -1215,31 +1401,71 @@ __write_iocache_xlator (FILE *file, dict_t *dict,
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_PRIORITY,
+ if (dict_get (dict, "priority")) {
+ ret = dict_get_str (dict, "priority", &opt_priority);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring priority",
+ opt_priority);
+ uncomment_option (iocache_str,
+ (char *) "# option priority %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_PRIORITY,
&opt_priority);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_TIMEOUT,
+ if (dict_get (dict, "cache-timeout")) {
+ ret = dict_get_str (dict, "cache-timeout", &opt_timeout);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring cache-timeout",
+ opt_timeout);
+ uncomment_option (iocache_str,
+ (char *) "# option cache-timeout %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_TIMEOUT,
&opt_timeout);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_CACHESIZE,
+ if (dict_get (dict, "cache-size")) {
+ ret = dict_get_str (dict, "cache-size", &opt_cachesize);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring cache-size :%s",
+ opt_cachesize);
+ uncomment_option (iocache_str,
+ (char *) "# option cache-size %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_CACHESIZE,
&opt_cachesize);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_MINFILESIZE,
+ if (dict_get (dict, "min-file-size")) {
+ ret = dict_get_str (dict, "min-file-size", &opt_minfilesize);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring min-file-size: %s",
+ opt_minfilesize);
+ uncomment_option (iocache_str,
+ (char *) "# option min-file-size %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_MINFILESIZE,
&opt_minfilesize);
if (ret) {
goto out;
}
- ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_MAXFILESIZE,
+ if (dict_get (dict, "max-file-size")) {
+ ret = dict_get_str (dict, "max-file-size", &opt_maxfilesize);
+ gf_log("", GF_LOG_DEBUG, "Reconfiguring max-file-size: %s",
+ opt_maxfilesize);
+ uncomment_option (iocache_str,
+ (char *) "# option max-file-size %s\n");
+ }
+ else
+ ret = dict_get_str (dict, VOLGEN_IOCACHE_OPTION_MAXFILESIZE,
&opt_maxfilesize);
if (ret) {
goto out;
@@ -2016,6 +2242,8 @@ glusterd_create_volfiles (glusterd_volinfo_t *volinfo)
{
int ret = -1;
+ gf_log ("", GF_LOG_DEBUG, "Inside Create Volfiles");
+
if(volinfo->transport_type == GF_TRANSPORT_RDMA) {
ret = set_xlator_option (volinfo->dict, VOLGEN_CLIENT_OPTION_TRANSTYPE,
"rdma");
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index bee572646..a93bac675 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -141,4 +141,7 @@ glusterd_get_nfs_filepath ();
int
volgen_generate_nfs_volfile (glusterd_volinfo_t *volinfo);
+
+int
+uncomment_option( char *opt_str,char *comment_str);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 947f1c23a..cfa229301 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -373,6 +373,12 @@ glusterd_log_rotate (rpcsvc_request_t *req, dict_t *dict);
int32_t
glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict);
+int32_t
+glusterd_set_volume (rpcsvc_request_t *req, dict_t *dict);
+
+int
+glusterd_handle_set_volume (rpcsvc_request_t *req);
+
int
glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret,
int32_t op_errno, char *hostname);
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index 5f0ab79ca..244b71009 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -1335,7 +1335,13 @@ glusterd_handle_rpc_msg (rpcsvc_request_t *req)
ret = glusterd_handle_log_rotate (req);
break;
+ case GD_MGMT_CLI_SET_VOLUME:
+ ret = glusterd_handle_set_volume (req);
+ break;
+
default:
+ gf_log("", GF_LOG_ERROR, "Recieved Invalid procnum:%d",
+ req->procnum);
GF_ASSERT (0);
}
@@ -1386,6 +1392,8 @@ rpcsvc_actor_t glusterd1_mgmt_actors[] = {
[GD_MGMT_CLI_LOG_FILENAME] = { "LOG FILENAME", GD_MGMT_CLI_LOG_FILENAME, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_LOG_LOCATE] = { "LOG LOCATE", GD_MGMT_CLI_LOG_LOCATE, glusterd_handle_log_locate, NULL, NULL},
[GD_MGMT_CLI_LOG_ROTATE] = { "LOG FILENAME", GD_MGMT_CLI_LOG_ROTATE, glusterd_handle_rpc_msg, NULL, NULL},
+ [GD_MGMT_CLI_SET_VOLUME] = { "SET_VOLUME", GD_MGMT_CLI_SET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
+
};
/*rpcsvc_actor_t glusterd1_mgmt_actors[] = {