summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-messages.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c9
5 files changed, 83 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
index c465633c9d9..d9d4c173980 100644
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
@@ -41,7 +41,7 @@
*/
#define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD
-#define GLFS_NUM_MESSAGES 18
+#define GLFS_NUM_MESSAGES 19
#define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
@@ -61,8 +61,6 @@
#define GD_MSG_REBALANCE_DISCONNECTED (GLUSTERD_COMP_BASE + 7)
-/* 4 to 7 is reserved for brick disconnection messages */
-
#define GD_MSG_VOL_CLEANUP_FAIL (GLUSTERD_COMP_BASE + 8)
#define GD_MSG_VOL_VERS_MISMATCH (GLUSTERD_COMP_BASE + 9)
@@ -84,6 +82,8 @@
#define GD_MSG_UNIX_OP_BUILD_FAIL (GLUSTERD_COMP_BASE + 17)
#define GD_MSG_RPC_CREATE_FAIL (GLUSTERD_COMP_BASE + 18)
+
+#define GD_MSG_FAIL_DEFAULT_OPT_SET (GLUSTERD_COMP_BASE + 19)
/*------------*/
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index edafb5469ae..8b9ddf32259 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1509,9 +1509,17 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,
GF_ASSERT (volinfo->dict);
GF_ASSERT (key);
- if (!strncmp(key, "all", 3))
+ if (!strncmp(key, "all", 3)) {
dict_foreach (volinfo->dict, _delete_reconfig_opt, is_force);
- else {
+ ret = glusterd_enable_default_options (volinfo, NULL);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FAIL_DEFAULT_OPT_SET, "Failed to set "
+ "default options on reset for volume %s",
+ volinfo->volname);
+ goto out;
+ }
+ } else {
value = dict_get (volinfo->dict, key);
if (!value) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -1519,6 +1527,14 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,
goto out;
}
_delete_reconfig_opt (volinfo->dict, key, value, is_force);
+ ret = glusterd_enable_default_options (volinfo, key);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FAIL_DEFAULT_OPT_SET, "Failed to set "
+ "default value for option '%s' on reset for "
+ "volume %s", key, volinfo->volname);
+ goto out;
+ }
}
gd_update_volume_op_versions (volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 32761d8fe88..9923ffd0617 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -12797,3 +12797,52 @@ glusterd_launch_synctask (synctask_fn_t fn, void *opaque)
" and other volume related services");
}
+/*
+ * glusterd_enable_default_options enable certain options by default on the
+ * given volume based on the cluster op-version. This is called only during
+ * volume create or during volume reset
+ *
+ * @volinfo - volume on which to enable the default options
+ * @option - option to be set to default. If NULL, all possible options will be
+ * set to default
+ *
+ * Returns 0 on sucess and -1 on failure. If @option is given, but doesn't match
+ * any of the options that could be set, it is a success.
+ */
+/*
+ * TODO: Make this able to parse the volume-set table to set options
+ * Currently, the check and set for any option which wants to make use of this
+ * 'framework' needs to be done here manually. This would mean more work for the
+ * developer. This little extra work can be avoided if we make it possible to
+ * parse the volume-set table to get the options which could be set and their
+ * default values
+ */
+int
+glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option)
+{
+ int ret = 0;
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
+
+ conf = this->private;
+ GF_ASSERT (conf);
+
+ if (conf->op_version >= 4) {
+ /* Set needed volume options in volinfo->dict
+ * For ex.,
+ *
+ * if (!option || !strcmp("someoption", option) {
+ * ret = dict_set_str(volinfo->dict, "someoption", "on");
+ * ...
+ * }
+ * */
+
+ }
+out:
+ return ret;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 6d65b1ffab5..26895fd904d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -825,4 +825,8 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
void
glusterd_launch_synctask (synctask_fn_t fn, void *opaque);
+
+int
+glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option);
+
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 6cce4a89f08..fd19b78b912 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -25,6 +25,7 @@
#include "glusterd-store.h"
#include "glusterd-utils.h"
#include "glusterd-volgen.h"
+#include "glusterd-messages.h"
#include "run.h"
#define glusterd_op_start_volume_args_get(dict, volname, flags) \
@@ -1798,6 +1799,14 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
i++;
}
+ ret = glusterd_enable_default_options (volinfo, NULL);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FAIL_DEFAULT_OPT_SET, "Failed to set default "
+ "options on create for volume %s", volinfo->volname);
+ goto out;
+ }
+
gd_update_volume_op_versions (volinfo);
volinfo->caps = caps;