summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-05-27 03:37:14 +0000
committerAnand Avati <avati@gluster.com>2011-05-31 22:52:26 -0700
commita3bd6682c3ca9e083ed0de8da8ef42bbaa86416f (patch)
treed5a65c6d9a9cc8062102307b0a42f34b41bde99b /xlators/mgmt
parentef39bf9d233b39ea616e62b52ee6de69d06f9c8d (diff)
glusterd: add upgrade/downgrade xlator options
If started with upgrade-option, the current behavior is to recreate brick volfiles, as from 3.2 marker xlator is default. downgrade option is not functionally supported. Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2904 (glusterd should have upgrade/downgrade xlator options) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2904
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c64
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c10
5 files changed, 80 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index beb7b0d3fd1..8cb8f8f830e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3361,3 +3361,67 @@ out:
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
+
+int32_t
+glusterd_recreate_bricks (glusterd_conf_t *conf)
+{
+
+ glusterd_volinfo_t *volinfo = NULL;
+ int ret = 0;
+
+ GF_ASSERT (conf);
+ list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ ret = generate_brick_volfiles (volinfo);
+ }
+ return ret;
+}
+
+int32_t
+glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf)
+{
+ int ret = 0;
+ char *type = NULL;
+ gf_boolean_t upgrade = _gf_false;
+ gf_boolean_t downgrade = _gf_false;
+ gf_boolean_t regenerate_brick_volfiles = _gf_false;
+
+ ret = dict_get_str (options, "upgrade", &type);
+ if (!ret) {
+ ret = gf_string2boolean (type, &upgrade);
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "upgrade option "
+ "%s is not a valid boolean type", type);
+ ret = -1;
+ goto out;
+ }
+ if (_gf_true == upgrade)
+ regenerate_brick_volfiles = _gf_true;
+ }
+
+ ret = dict_get_str (options, "downgrade", &type);
+
+ if (!ret) {
+ ret = gf_string2boolean (type, &downgrade);
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "downgrade option "
+ "%s is not a valid boolean type", type);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ if (upgrade && downgrade) {
+ gf_log ("glusterd", GF_LOG_ERROR, "Both upgrade and downgrade"
+ " options are set. Only one should be on");
+ ret = -1;
+ goto out;
+ }
+
+ if (!upgrade && !downgrade)
+ ret = 0;
+ if (regenerate_brick_volfiles) {
+ ret = glusterd_recreate_bricks (conf);
+ }
+out:
+ return ret;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 7cf06f7ae1f..e28ad27ae25 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -276,4 +276,8 @@ glusterd_restart_gsyncds (glusterd_conf_t *conf);
int
glusterd_start_gsync (char *master, char *slave, char *uuid_str,
char **op_errstr);
+int32_t
+glusterd_recreate_bricks (glusterd_conf_t *conf);
+int32_t
+glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index f7f3ddd11a5..159ddae517f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1901,7 +1901,7 @@ get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo)
PATH_MAX - strlen(filename) - 1);
}
-static int
+int
generate_brick_volfiles (glusterd_volinfo_t *volinfo)
{
glusterd_brickinfo_t *brickinfo = NULL;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index 518ae94ad8c..3cf2e87b9bb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -63,5 +63,5 @@ gf_boolean_t glusterd_check_globaloption (char *key);
gf_boolean_t
glusterd_check_voloption_flags (char *key, int32_t flags);
-
+int generate_brick_volfiles (glusterd_volinfo_t *volinfo);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 670cda00f4e..53f1460bfba 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -714,6 +714,10 @@ init (xlator_t *this)
glusterd_op_sm_init ();
glusterd_opinfo_init ();
+ ret = glusterd_handle_upgrade_downgrade (this->options, conf);
+ if (ret)
+ goto out;
+
glusterd_restart_bricks (conf);
ret = glusterd_restart_gsyncds (conf);
if (ret)
@@ -818,6 +822,12 @@ struct volume_options options[] = {
{ .key = {"rpc-auth-allow-insecure"},
.type = GF_OPTION_TYPE_BOOL,
},
+ { .key = {"upgrade"},
+ .type = GF_OPTION_TYPE_BOOL,
+ },
+ { .key = {"downgrade"},
+ .type = GF_OPTION_TYPE_BOOL,
+ },
{ .key = {NULL} },
};