7c2869
From c209e7656bc3eb80b210924a0f756eebd0befc60 Mon Sep 17 00:00:00 2001
7c2869
From: Ravishankar N <ravishankar@redhat.com>
7c2869
Date: Thu, 5 Jul 2018 14:02:34 +0530
7c2869
Subject: [PATCH 683/685] glusterd: fix client io-threads option for replicate
7c2869
 volumes
7c2869
7c2869
Backport of https://review.gluster.org/#/c/18430/5
7c2869
...but changes the op_version checks to GD_OP_VERSION_3_11_2
7c2869
7c2869
This backport is for honouring 'gluster v set <volname> client-io-threads`
7c2869
{on/off} on rhgs-3.3.1 async release. After upgrading from an older version
7c2869
of rhgs to 331 or when upgrading from this version to rhgs-3.4.0, it is
7c2869
recommended to explicity run the volume set after upgrading all nodes and
7c2869
bumping up the cluster op-version. As an additional check, please also check
7c2869
the fuse volfile to see if the io-threads xlator was loaded/unloaded depending
7c2869
on whether it you did an 'on' or 'off' respectively.
7c2869
7c2869
Change-Id: I47d5717bf137b01eea88678cca8624c3aabd8bb5
7c2869
BUG: 1598416
7c2869
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/143250
7c2869
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
7c2869
Tested-by: RHGS Build Bot <nigelb@redhat.com>
7c2869
---
7c2869
 .../replicate/bug-1498570-client-iot-graph-check.t | 49 ++++++++++++++++++++++
7c2869
 xlators/mgmt/glusterd/src/glusterd-brick-ops.c     | 34 +++++++++++++++
7c2869
 xlators/mgmt/glusterd/src/glusterd-handler.c       |  7 ++--
7c2869
 xlators/mgmt/glusterd/src/glusterd-utils.c         | 20 +--------
7c2869
 xlators/mgmt/glusterd/src/glusterd-utils.h         |  3 +-
7c2869
 xlators/mgmt/glusterd/src/glusterd-volgen.c        | 28 ++++++++-----
7c2869
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c    | 34 +++++++++++++++
7c2869
 7 files changed, 141 insertions(+), 34 deletions(-)
7c2869
 create mode 100644 tests/bugs/replicate/bug-1498570-client-iot-graph-check.t
7c2869
7c2869
diff --git a/tests/bugs/replicate/bug-1498570-client-iot-graph-check.t b/tests/bugs/replicate/bug-1498570-client-iot-graph-check.t
7c2869
new file mode 100644
7c2869
index 0000000..4574ccb
7c2869
--- /dev/null
7c2869
+++ b/tests/bugs/replicate/bug-1498570-client-iot-graph-check.t
7c2869
@@ -0,0 +1,49 @@
7c2869
+#!/bin/bash
7c2869
+. $(dirname $0)/../../include.rc
7c2869
+. $(dirname $0)/../../volume.rc
7c2869
+. $(dirname $0)/../../afr.rc
7c2869
+
7c2869
+TESTS_EXPECTED_IN_LOOP=21
7c2869
+function reset_cluster
7c2869
+{
7c2869
+        cleanup
7c2869
+        TEST glusterd
7c2869
+        TEST pidof glusterd
7c2869
+
7c2869
+}
7c2869
+function check_iot_option
7c2869
+{
7c2869
+        local enabled=$1
7c2869
+        local is_loaded_in_graph=$2
7c2869
+
7c2869
+        EXPECT "$enabled" volume_get_field $V0 client-io-threads
7c2869
+        IOT_STRING="volume\ $V0-io-threads"
7c2869
+        grep "$IOT_STRING" $GLUSTERD_WORKDIR/vols/$V0/trusted-$V0.tcp-fuse.vol
7c2869
+        TEST ret=$?
7c2869
+        EXPECT_NOT "$is_loaded_in_graph" echo $ret
7c2869
+}
7c2869
+
7c2869
+reset_cluster
7c2869
+TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1}
7c2869
+check_iot_option on 1
7c2869
+
7c2869
+reset_cluster
7c2869
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
7c2869
+check_iot_option off 0
7c2869
+
7c2869
+reset_cluster
7c2869
+TEST $CLI volume create $V0 $H0:$B0/${V0}0
7c2869
+TEST $CLI volume start $V0
7c2869
+TEST $CLI volume add-brick $V0 replica 2 $H0:$B0/${V0}1
7c2869
+check_iot_option off 0
7c2869
+TEST $CLI volume remove-brick $V0 replica 1 $H0:$B0/${V0}1 force
7c2869
+check_iot_option on 1
7c2869
+
7c2869
+reset_cluster
7c2869
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0..5}
7c2869
+TEST $CLI volume set $V0 client-io-threads on
7c2869
+check_iot_option on 1
7c2869
+TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}2 $H0:$B0/${V0}5 force
7c2869
+check_iot_option on 1
7c2869
+
7c2869
+cleanup
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
7c2869
index f4cd927..fadbc00 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
7c2869
@@ -1415,6 +1415,24 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
7c2869
         /* Gets changed only if the options are given in add-brick cli */
7c2869
         if (type)
7c2869
                 volinfo->type = type;
7c2869
+        /* performance.client-io-threads is turned on by default,
7c2869
+         * however this has adverse effects on replicate volumes due to
7c2869
+         * replication design issues, till that get addressed
7c2869
+         * performance.client-io-threads option is turned off for all
7c2869
+         * replicate volumes if not already explicitly enabled.
7c2869
+         */
7c2869
+        if (type && glusterd_is_volume_replicate (volinfo) &&
7c2869
+            conf->op_version >= GD_OP_VERSION_3_11_2) {
7c2869
+                ret = dict_set_str (volinfo->dict,
7c2869
+                                    "performance.client-io-threads",
7c2869
+                                    "off");
7c2869
+                if (ret) {
7c2869
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
7c2869
+                                GD_MSG_DICT_SET_FAILED, "Failed to set "
7c2869
+                                "performance.client-io-threads to off");
7c2869
+                        goto out;
7c2869
+                }
7c2869
+        }
7c2869
 
7c2869
         if (replica_count) {
7c2869
                 volinfo->replica_count = replica_count;
7c2869
@@ -2583,9 +2601,12 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
7c2869
         char                    *cold_shd_key  = NULL;
7c2869
         char                    *hot_shd_key   = NULL;
7c2869
         int                      delete_key    = 1;
7c2869
+        glusterd_conf_t         *conf          = NULL;
7c2869
 
7c2869
         this = THIS;
7c2869
         GF_ASSERT (this);
7c2869
+        conf = this->private;
7c2869
+        GF_VALIDATE_OR_GOTO (this->name, conf, out);
7c2869
 
7c2869
         ret = dict_get_str (dict, "volname", &volname);
7c2869
 
7c2869
@@ -2875,6 +2896,19 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
7c2869
         volinfo->subvol_count = (volinfo->brick_count /
7c2869
                                  volinfo->dist_leaf_count);
7c2869
 
7c2869
+        if (!glusterd_is_volume_replicate (volinfo) &&
7c2869
+            conf->op_version >= GD_OP_VERSION_3_11_2) {
7c2869
+                ret = dict_set_str (volinfo->dict,
7c2869
+                                    "performance.client-io-threads",
7c2869
+                                    "on");
7c2869
+                if (ret) {
7c2869
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
7c2869
+                                GD_MSG_DICT_SET_FAILED, "Failed to set "
7c2869
+                                "performance.client-io-threads to on");
7c2869
+                        goto out;
7c2869
+                }
7c2869
+        }
7c2869
+
7c2869
         ret = glusterd_create_volfiles_and_notify_services (volinfo);
7c2869
         if (ret) {
7c2869
                 gf_msg (this->name, GF_LOG_WARNING, 0,
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
7c2869
index 6d66301..6bcfc6b 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
7c2869
@@ -4886,7 +4886,7 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
7c2869
                                                                (dict,
7c2869
                                                                 _gf_false,
7c2869
                                                                 key, orig_key,
7c2869
-                                                                volinfo,
7c2869
+                                                                volinfo->dict,
7c2869
                                                                 &rsp.op_errstr);
7c2869
                                         if (ret && !rsp.op_errstr) {
7c2869
                                                 snprintf (err_str,
7c2869
@@ -4912,7 +4912,7 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
7c2869
         } else {
7c2869
                 /* Handle the "all" volume option request */
7c2869
                 ret = glusterd_get_default_val_for_volopt (dict, _gf_true, NULL,
7c2869
-                                                           NULL, volinfo,
7c2869
+                                                           NULL, volinfo->dict,
7c2869
                                                            &rsp.op_errstr);
7c2869
                 if (ret && !rsp.op_errstr) {
7c2869
                         snprintf (err_str, sizeof(err_str),
7c2869
@@ -5505,7 +5505,8 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
7c2869
                         vol_all_opts = dict_new ();
7c2869
 
7c2869
                         ret = glusterd_get_default_val_for_volopt (vol_all_opts,
7c2869
-                                        _gf_true, NULL, NULL, volinfo, &rsp.op_errstr);
7c2869
+                                        _gf_true, NULL, NULL, volinfo->dict,
7c2869
+                                        &rsp.op_errstr);
7c2869
                         if (ret) {
7c2869
                                 gf_msg (this->name, GF_LOG_ERROR, 0,
7c2869
                                         GD_MSG_VOL_OPTS_IMPORT_FAIL, "Failed to "
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
index a04ed99..f219fd5 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
@@ -12368,8 +12368,7 @@ out:
7c2869
 int
7c2869
 glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
7c2869
                                      char *input_key, char *orig_key,
7c2869
-                                     glusterd_volinfo_t *volinfo,
7c2869
-                                     char **op_errstr)
7c2869
+                                     dict_t *vol_dict, char **op_errstr)
7c2869
 {
7c2869
         struct volopt_map_entry *vme = NULL;
7c2869
         int                      ret = -1;
7c2869
@@ -12380,7 +12379,6 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
7c2869
         char                     dict_key[50] = {0,};
7c2869
         gf_boolean_t             key_found = _gf_false;
7c2869
         glusterd_conf_t         *priv = NULL;
7c2869
-        dict_t                  *vol_dict = NULL;
7c2869
 
7c2869
         this = THIS;
7c2869
         GF_ASSERT (this);
7c2869
@@ -12388,7 +12386,6 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
7c2869
         priv = this->private;
7c2869
         GF_VALIDATE_OR_GOTO (this->name, priv, out);
7c2869
 
7c2869
-        vol_dict = volinfo->dict;
7c2869
         GF_VALIDATE_OR_GOTO (this->name, vol_dict, out);
7c2869
 
7c2869
         /* Check whether key is passed for a single option */
7c2869
@@ -12410,20 +12407,6 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
7c2869
                 if (!def_val) {
7c2869
                         ret = dict_get_str (vol_dict, vme->key, &def_val);
7c2869
                         if (!def_val) {
7c2869
-                                /* For replicate volumes
7c2869
-                                 * performance.client-io-threads will be set to
7c2869
-                                 * off by default until explicitly turned on
7c2869
-                                 */
7c2869
-                                if (!strcmp (vme->key,
7c2869
-                                            "performance.client-io-threads")) {
7c2869
-                                        if (volinfo->type ==
7c2869
-                                            GF_CLUSTER_TYPE_REPLICATE ||
7c2869
-                                            volinfo->type ==
7c2869
-                                            GF_CLUSTER_TYPE_STRIPE_REPLICATE) {
7c2869
-                                                def_val = "off";
7c2869
-                                                goto set_count;
7c2869
-                                        }
7c2869
-                                }
7c2869
                                 if (vme->value) {
7c2869
                                         def_val = vme->value;
7c2869
                                 } else {
7c2869
@@ -12436,7 +12419,6 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
7c2869
                                 }
7c2869
                         }
7c2869
                 }
7c2869
-set_count:
7c2869
                 count++;
7c2869
                 sprintf (dict_key, "key%d", count);
7c2869
                 ret = dict_set_str(ctx, dict_key, vme->key);
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
7c2869
index 7a5bfd9..259088b 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
7c2869
@@ -695,8 +695,7 @@ glusterd_get_global_options_for_all_vols (dict_t *dict, char **op_errstr);
7c2869
 int
7c2869
 glusterd_get_default_val_for_volopt (dict_t *dict, gf_boolean_t all_opts,
7c2869
                                      char *key, char *orig_key,
7c2869
-                                     glusterd_volinfo_t  *volinfo,
7c2869
-                                     char **err_str);
7c2869
+                                     dict_t *vol_dict, char **err_str);
7c2869
 
7c2869
 int
7c2869
 glusterd_check_client_op_version_support (char *volname, uint32_t op_version,
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
7c2869
index 4198be8..e22c3d2 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
7c2869
@@ -2550,9 +2550,15 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
7c2869
 {
7c2869
         gf_boolean_t enabled = _gf_false;
7c2869
         glusterd_volinfo_t *volinfo = NULL;
7c2869
+        xlator_t *this = NULL;
7c2869
+        glusterd_conf_t *priv = NULL;
7c2869
 
7c2869
-        GF_ASSERT (param);
7c2869
+        GF_VALIDATE_OR_GOTO ("glusterd", param, out);
7c2869
         volinfo = param;
7c2869
+        this = THIS;
7c2869
+        GF_VALIDATE_OR_GOTO ("glusterd", this, out);
7c2869
+        priv = this->private;
7c2869
+        GF_VALIDATE_OR_GOTO ("glusterd", priv, out);
7c2869
 
7c2869
         if (strcmp (vme->option, "!perf") != 0)
7c2869
                 return 0;
7c2869
@@ -2568,13 +2574,15 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
7c2869
             (vme->op_version > volinfo->client_op_version))
7c2869
                 return 0;
7c2869
 
7c2869
-        /* For replicate volumes do not load io-threads as it affects
7c2869
-         * performance
7c2869
-         */
7c2869
-        if (!strcmp (vme->key, "performance.client-io-threads") &&
7c2869
-            (GF_CLUSTER_TYPE_STRIPE_REPLICATE == volinfo->type ||
7c2869
-             GF_CLUSTER_TYPE_REPLICATE == volinfo->type))
7c2869
-                return 0;
7c2869
+        if (priv->op_version < GD_OP_VERSION_3_11_2) {
7c2869
+                /* For replicate volumes do not load io-threads as it affects
7c2869
+                 * performance
7c2869
+                 */
7c2869
+                if (!strcmp (vme->key, "performance.client-io-threads") &&
7c2869
+                    (GF_CLUSTER_TYPE_STRIPE_REPLICATE == volinfo->type ||
7c2869
+                     GF_CLUSTER_TYPE_REPLICATE == volinfo->type))
7c2869
+                        return 0;
7c2869
+        }
7c2869
 
7c2869
         /* if VKEY_READDIR_AHEAD is enabled and parallel readdir is
7c2869
          * not enabled then load readdir-ahead here else it will be
7c2869
@@ -2585,8 +2593,8 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
7c2869
 
7c2869
         if (volgen_graph_add (graph, vme->voltype, volinfo->volname))
7c2869
                 return 0;
7c2869
-        else
7c2869
-                return -1;
7c2869
+out:
7c2869
+        return -1;
7c2869
 }
7c2869
 
7c2869
 static int
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
7c2869
index 4e410ce..f552c83 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
7c2869
@@ -2236,6 +2236,23 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
7c2869
         volinfo->stripe_count = 1;
7c2869
 
7c2869
         if (GF_CLUSTER_TYPE_REPLICATE == volinfo->type) {
7c2869
+                /* performance.client-io-threads is turned on to default,
7c2869
+                 * however this has adverse effects on replicate volumes due to
7c2869
+                 * replication design issues, till that get addressed
7c2869
+                 * performance.client-io-threads option is turned off for all
7c2869
+                 * replicate volumes
7c2869
+                 */
7c2869
+                if (priv->op_version >= GD_OP_VERSION_3_11_2) {
7c2869
+                        ret = dict_set_str (volinfo->dict,
7c2869
+                                            "performance.client-io-threads",
7c2869
+                                            "off");
7c2869
+                        if (ret) {
7c2869
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
7c2869
+                                        GD_MSG_DICT_SET_FAILED, "Failed to set "
7c2869
+                                        "performance.client-io-threads to off");
7c2869
+                                goto out;
7c2869
+                        }
7c2869
+                }
7c2869
                 ret = dict_get_int32 (dict, "replica-count",
7c2869
                                       &volinfo->replica_count);
7c2869
                 if (ret) {
7c2869
@@ -2256,6 +2273,23 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
7c2869
                         goto out;
7c2869
                 }
7c2869
         } else if (GF_CLUSTER_TYPE_STRIPE_REPLICATE == volinfo->type) {
7c2869
+                /* performance.client-io-threads is turned on to default,
7c2869
+                 * however this has adverse effects on replicate volumes due to
7c2869
+                 * replication design issues, till that get addressed
7c2869
+                 * performance.client-io-threads option is turned off for all
7c2869
+                 * replicate volumes
7c2869
+                 */
7c2869
+                if (priv->op_version >= GD_OP_VERSION_3_11_2) {
7c2869
+                        ret = dict_set_str (volinfo->dict,
7c2869
+                                            "performance.client-io-threads",
7c2869
+                                            "off");
7c2869
+                        if (ret) {
7c2869
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
7c2869
+                                        GD_MSG_DICT_SET_FAILED, "Failed to set "
7c2869
+                                        "performance.client-io-threads to off");
7c2869
+                                goto out;
7c2869
+                        }
7c2869
+                }
7c2869
                 ret = dict_get_int32 (dict, "stripe-count",
7c2869
                                       &volinfo->stripe_count);
7c2869
                 if (ret) {
7c2869
-- 
7c2869
1.8.3.1
7c2869