21ab4e
From 5534412d499c97d788d396629918a034b8ce0f03 Mon Sep 17 00:00:00 2001
21ab4e
From: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
Date: Tue, 18 Jul 2017 21:33:45 +0530
21ab4e
Subject: [PATCH 569/569] glusterd: Set default value for
21ab4e
 cluster.max-bricks-per-process to 0
21ab4e
21ab4e
When brick-multiplexing is enabled, and
21ab4e
"cluster.max-bricks-per-process" isn't explicitly set, multiplexing
21ab4e
happens without any limit set. But the default value set for that
21ab4e
tunable is 1, which is confusing. This commit sets the default
21ab4e
value to 0, and prevents the user from being able to set this value
21ab4e
to 1 when brick-multiplexing is enbaled. The default value of 0
21ab4e
denotes that brick-multiplexing can happen without any limit on the
21ab4e
number of bricks per process.
21ab4e
21ab4e
> Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17819
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
21ab4e
Change-Id: I4647f7bf5837d520075dc5c19a6e75bc1bba258b
21ab4e
BUG: 1472289
21ab4e
Signed-off-by: Samikshan Bairagya <sbairagy@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/112934
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 tests/basic/mpx-compat.t                        |  1 +
21ab4e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |  6 ++++--
21ab4e
 xlators/mgmt/glusterd/src/glusterd-utils.c      | 21 ++++++++++++---------
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-set.c | 19 +++++++++++++++----
21ab4e
 4 files changed, 32 insertions(+), 15 deletions(-)
21ab4e
21ab4e
diff --git a/tests/basic/mpx-compat.t b/tests/basic/mpx-compat.t
21ab4e
index 3de0f6f..4ca262e 100644
21ab4e
--- a/tests/basic/mpx-compat.t
21ab4e
+++ b/tests/basic/mpx-compat.t
21ab4e
@@ -15,6 +15,7 @@ function count_processes {
21ab4e
 	pgrep glusterfsd | wc -w
21ab4e
 }
21ab4e
 
21ab4e
+cleanup
21ab4e
 TEST glusterd
21ab4e
 TEST $CLI volume set all cluster.brick-multiplex yes
21ab4e
 push_trapfunc "$CLI volume set all cluster.brick-multiplex off"
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
index 4c8fef7..52f7505 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
@@ -78,10 +78,12 @@ glusterd_all_vol_opts valid_all_vol_opts[] = {
21ab4e
          * TBD: add a dynamic handler to set the appropriate value
21ab4e
          */
21ab4e
         { GLUSTERD_BRICK_MULTIPLEX_KEY,         "disable"},
21ab4e
-        /* Set this value to 1 by default implying non-multiplexed behaviour.
21ab4e
+        /* Set this value to 0 by default implying brick-multiplexing
21ab4e
+         * behaviour with no limit set on the number of brick instances that
21ab4e
+         * can be attached per process.
21ab4e
          * TBD: Discuss the default value for this. Maybe this should be a
21ab4e
          * dynamic value depending on the memory specifications per node */
21ab4e
-        { GLUSTERD_BRICKMUX_LIMIT_KEY,          "1"},
21ab4e
+        { GLUSTERD_BRICKMUX_LIMIT_KEY,          "0"},
21ab4e
         { NULL },
21ab4e
 };
21ab4e
 
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
index 0f5c148..55f7089 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
@@ -121,7 +121,7 @@ get_mux_limit_per_process (int *mux_limit)
21ab4e
 {
21ab4e
         char            *value = NULL;
21ab4e
         int             ret = -1;
21ab4e
-        int             max_bricks_per_proc = -1;
21ab4e
+        int             max_bricks_per_proc = 0;
21ab4e
         xlator_t        *this = NULL;
21ab4e
         glusterd_conf_t *priv = NULL;
21ab4e
 
21ab4e
@@ -139,15 +139,18 @@ get_mux_limit_per_process (int *mux_limit)
21ab4e
 
21ab4e
         ret = dict_get_str (priv->opts, GLUSTERD_BRICKMUX_LIMIT_KEY, &value);
21ab4e
         if (ret) {
21ab4e
-                gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
21ab4e
-                        "Can't get limit for number of bricks per brick "
21ab4e
-                        "process from dict");
21ab4e
+                gf_msg_debug (this->name, 0, "Limit for number of bricks per "
21ab4e
+                              "brick process not yet set in dict. Returning "
21ab4e
+                              "limit as 0 denoting that multiplexing can "
21ab4e
+                              "happen with no limit set.");
21ab4e
                 ret = 0;
21ab4e
-        } else {
21ab4e
-                ret = gf_string2int (value, &max_bricks_per_proc);
21ab4e
-                if (ret)
21ab4e
-                        goto out;
21ab4e
+                goto out;
21ab4e
         }
21ab4e
+
21ab4e
+        ret = gf_string2int (value, &max_bricks_per_proc);
21ab4e
+        if (ret)
21ab4e
+                goto out;
21ab4e
+
21ab4e
 out:
21ab4e
         *mux_limit = max_bricks_per_proc;
21ab4e
 
21ab4e
@@ -5486,7 +5489,7 @@ find_compat_brick_in_vol (glusterd_conf_t *conf,
21ab4e
                         continue;
21ab4e
                 }
21ab4e
 
21ab4e
-                if (mux_limit != -1) {
21ab4e
+                if (mux_limit != 0) {
21ab4e
                         if (brick_proc->brick_count >= mux_limit)
21ab4e
                                 continue;
21ab4e
                 } else {
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
index 28989ea..ddda66e 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
@@ -991,6 +991,14 @@ validate_mux_limit (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
21ab4e
                 gf_msg (this->name, GF_LOG_ERROR, 0,
21ab4e
                         GD_MSG_INVALID_ENTRY, "%s", *op_errstr);
21ab4e
         }
21ab4e
+
21ab4e
+        if (val == 1) {
21ab4e
+                gf_asprintf (op_errstr, "Brick-multiplexing is enabled. "
21ab4e
+                             "Please set this option to a value other than 1 "
21ab4e
+                             "to make use of the brick-multiplexing feature.");
21ab4e
+                ret = -1;
21ab4e
+                goto out;
21ab4e
+        }
21ab4e
 out:
21ab4e
         gf_msg_debug ("glusterd", 0, "Returning %d", ret);
21ab4e
 
21ab4e
@@ -3275,14 +3283,17 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
         },
21ab4e
         { .key         = GLUSTERD_BRICKMUX_LIMIT_KEY,
21ab4e
           .voltype     = "mgmt/glusterd",
21ab4e
-          .value       = "1",
21ab4e
+          .value       = "0",
21ab4e
           .op_version  = GD_OP_VERSION_3_11_1,
21ab4e
           .validate_fn = validate_mux_limit,
21ab4e
           .type        = GLOBAL_DOC,
21ab4e
           .description = "This option can be used to limit the number of brick "
21ab4e
-                         "instances per brick process when brick multiplexing "
21ab4e
-                         "is enabled. This option can be set only when brick "
21ab4e
-                         "multiplexing feature enabled."
21ab4e
+                         "instances per brick process when brick-multiplexing "
21ab4e
+                         "is enabled. If not explicitly set, this tunable is "
21ab4e
+                         "set to 0 which denotes that brick-multiplexing can "
21ab4e
+                         "happen without any limit on the number of bricks per "
21ab4e
+                         "process. Also this option can't be set when the "
21ab4e
+                         "brick-multiplexing feature is disabled."
21ab4e
         },
21ab4e
         { .key         = NULL
21ab4e
         }
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e