d1681e
From 787e1e865ba4b9680c95ae78a11a4d84714cc9a3 Mon Sep 17 00:00:00 2001
d1681e
From: Ravishankar N <ravishankar@redhat.com>
d1681e
Date: Wed, 7 Mar 2018 11:03:50 +0530
d1681e
Subject: [PATCH 176/180] glusterd: volume get fixes for client-io-threads &
d1681e
 quorum-type
d1681e
d1681e
Backport of: https://review.gluster.org/#/c/19567/
d1681e
d1681e
1. If a replica volume created on glusterfs-3.8 was upgraded to
d1681e
glusterfs-3.12, `gluster vol get volname client-io-threads` displayed
d1681e
'on' even though it wasn't and the xlator wasn't loaded on
d1681e
the client-graph. This was due to removing certain checks in
d1681e
glusterd_get_default_val_for_volopt as a part of commit
d1681e
47604fad4c2a3951077e41e0c007ceb979bb2c24. Fix it.
d1681e
d1681e
2. Also, as a part of op-version bump-up, client-io-threads was being
d1681e
loaded on the clients  during volfile regeneration. Prevent it.
d1681e
d1681e
3. AFR assumes quorum-type to be auto in newly created replic 3 (odd
d1681e
replica in general) volumes but `gluster vol get quorum-type` displays
d1681e
'none'. Fix it.
d1681e
d1681e
Change-Id: I4a6099e50f2f10f2bd76f304b1e3bc0795e07a9d
d1681e
BUG: 1543068
d1681e
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/131964
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
---
d1681e
 xlators/mgmt/glusterd/src/glusterd-handler.c |  6 +++---
d1681e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c   | 13 +++++++++++++
d1681e
 xlators/mgmt/glusterd/src/glusterd-utils.c   | 27 ++++++++++++++++++++++++++-
d1681e
 xlators/mgmt/glusterd/src/glusterd-utils.h   |  3 ++-
d1681e
 xlators/mgmt/glusterd/src/glusterd-volgen.c  |  8 +++++++-
d1681e
 5 files changed, 51 insertions(+), 6 deletions(-)
d1681e
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
d1681e
index 8fc665d..cf280a7 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
d1681e
@@ -4913,7 +4913,7 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
d1681e
                                                                (dict,
d1681e
                                                                 _gf_false,
d1681e
                                                                 key, orig_key,
d1681e
-                                                                volinfo->dict,
d1681e
+                                                                volinfo,
d1681e
                                                                 &rsp.op_errstr);
d1681e
                                         if (ret && !rsp.op_errstr) {
d1681e
                                                 snprintf (err_str,
d1681e
@@ -4939,7 +4939,7 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
d1681e
         } else {
d1681e
                 /* Handle the "all" volume option request */
d1681e
                 ret = glusterd_get_default_val_for_volopt (dict, _gf_true, NULL,
d1681e
-                                                           NULL, volinfo->dict,
d1681e
+                                                           NULL, volinfo,
d1681e
                                                            &rsp.op_errstr);
d1681e
                 if (ret && !rsp.op_errstr) {
d1681e
                         snprintf (err_str, sizeof(err_str),
d1681e
@@ -5530,7 +5530,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
d1681e
                         vol_all_opts = dict_new ();
d1681e
 
d1681e
                         ret = glusterd_get_default_val_for_volopt (vol_all_opts,
d1681e
-                                        _gf_true, NULL, NULL, volinfo->dict,
d1681e
+                                        _gf_true, NULL, NULL, volinfo,
d1681e
                                         &rsp.op_errstr);
d1681e
                         if (ret) {
d1681e
                                 gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
index 0cf76dd..0a21e02 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
@@ -2542,6 +2542,15 @@ out:
d1681e
         return ret;
d1681e
 }
d1681e
 
d1681e
+/* This is a hack to prevent client-io-threads from being loaded in the graph
d1681e
+ * when the cluster-op-version is bumped up from 3.8.x to 3.13.x. The key is
d1681e
+ * deleted subsequently in glusterd_create_volfiles(). */
d1681e
+static int
d1681e
+glusterd_dict_set_skip_cliot_key (glusterd_volinfo_t *volinfo)
d1681e
+{
d1681e
+        return  dict_set_int32 (volinfo->dict, "skip-CLIOT", 1);
d1681e
+}
d1681e
+
d1681e
 static int
d1681e
 glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
d1681e
                                     char **op_errstr)
d1681e
@@ -2633,6 +2642,10 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
d1681e
                                                 (volinfo, &start_nfs_svc);
d1681e
                                 if (ret)
d1681e
                                         goto out;
d1681e
+
d1681e
+                                if (glusterd_dict_set_skip_cliot_key (volinfo))
d1681e
+                                        goto out;
d1681e
+
d1681e
                                 if (!volinfo->is_snap_volume) {
d1681e
                                         svc = &(volinfo->snapd.svc);
d1681e
                                         ret = svc->manager (svc, volinfo,
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
index 9a67cfd..49605cc 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
@@ -12842,10 +12842,30 @@ out:
d1681e
         return ret;
d1681e
 }
d1681e
 
d1681e
+char *
d1681e
+glusterd_get_option_value (glusterd_volinfo_t *volinfo, char *key)
d1681e
+{
d1681e
+        char *value = NULL;
d1681e
+
d1681e
+        if (!glusterd_is_volume_replicate(volinfo))
d1681e
+                goto ret;
d1681e
+
d1681e
+        if (!strcmp (key, "performance.client-io-threads")) {
d1681e
+                value = "off";
d1681e
+        } else if (!strcmp (key, "cluster.quorum-type")) {
d1681e
+                if (volinfo->replica_count%2) {
d1681e
+                        value = "auto";
d1681e
+                }
d1681e
+        }
d1681e
+ret:
d1681e
+        return value;
d1681e
+}
d1681e
+
d1681e
 int
d1681e
 glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
d1681e
                                      char *input_key, char *orig_key,
d1681e
-                                     dict_t *vol_dict, char **op_errstr)
d1681e
+                                     glusterd_volinfo_t *volinfo,
d1681e
+                                     char **op_errstr)
d1681e
 {
d1681e
         struct volopt_map_entry *vme = NULL;
d1681e
         int                      ret = -1;
d1681e
@@ -12856,6 +12876,7 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
d1681e
         char                     dict_key[50] = {0,};
d1681e
         gf_boolean_t             key_found = _gf_false;
d1681e
         glusterd_conf_t         *priv = NULL;
d1681e
+        dict_t                  *vol_dict = NULL;
d1681e
 
d1681e
         this = THIS;
d1681e
         GF_ASSERT (this);
d1681e
@@ -12863,6 +12884,7 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
d1681e
         priv = this->private;
d1681e
         GF_VALIDATE_OR_GOTO (this->name, priv, out);
d1681e
 
d1681e
+        vol_dict = volinfo->dict;
d1681e
         GF_VALIDATE_OR_GOTO (this->name, vol_dict, out);
d1681e
 
d1681e
         /* Check whether key is passed for a single option */
d1681e
@@ -12883,6 +12905,9 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
d1681e
                 ret = dict_get_str (priv->opts, vme->key, &def_val);
d1681e
                 if (!def_val) {
d1681e
                         ret = dict_get_str (vol_dict, vme->key, &def_val);
d1681e
+                        if (ret == -ENOENT)
d1681e
+                                def_val = glusterd_get_option_value (volinfo,
d1681e
+                                                                     vme->key);
d1681e
                         if (!def_val) {
d1681e
                                 if (vme->value) {
d1681e
                                         def_val = vme->value;
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
d1681e
index 6c525e5..e69a779 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
d1681e
@@ -730,7 +730,8 @@ glusterd_get_global_options_for_all_vols (rpcsvc_request_t *req, dict_t *dict,
d1681e
 int
d1681e
 glusterd_get_default_val_for_volopt (dict_t *dict, gf_boolean_t all_opts,
d1681e
                                      char *key, char *orig_key,
d1681e
-                                     dict_t *vol_dict, char **err_str);
d1681e
+                                     glusterd_volinfo_t *volinfo,
d1681e
+                                     char **err_str);
d1681e
 
d1681e
 int
d1681e
 glusterd_check_client_op_version_support (char *volname, uint32_t op_version,
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
d1681e
index 8ff76d6..0e287b6 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
d1681e
@@ -263,7 +263,6 @@ first_of (volgen_graph_t *graph)
d1681e
  *
d1681e
  *************************/
d1681e
 
d1681e
-
d1681e
 static int
d1681e
 volopt_selector (int lvl, char **patt, void *param,
d1681e
                      int (*optcbk)(char *word, void *param))
d1681e
@@ -514,6 +513,11 @@ volgen_graph_set_options_generic (volgen_graph_t *graph, dict_t *dict,
d1681e
                 odt.data_t_fake = _gf_false;
d1681e
 
d1681e
                 data = dict_get (dict, vme->key);
d1681e
+                if (!strcmp (vme->key, "performance.client-io-threads") &&
d1681e
+                    dict_get_str_boolean (dict, "skip-CLIOT",
d1681e
+                                          _gf_false) == _gf_true) {
d1681e
+                        continue;
d1681e
+                }
d1681e
 
d1681e
                 if (data)
d1681e
                         process_option (vme->key, data, &odt;;
d1681e
@@ -6393,6 +6397,8 @@ glusterd_create_volfiles (glusterd_volinfo_t *volinfo)
d1681e
                         GD_MSG_VOLFILE_CREATE_FAIL,
d1681e
                         "Could not generate client volfiles");
d1681e
 
d1681e
+        dict_del (volinfo->dict, "skip-CLIOT");
d1681e
+
d1681e
 out:
d1681e
         return ret;
d1681e
 }
d1681e
-- 
d1681e
1.8.3.1
d1681e