Blob Blame History Raw
From 5534412d499c97d788d396629918a034b8ce0f03 Mon Sep 17 00:00:00 2001
From: Samikshan Bairagya <samikshan@gmail.com>
Date: Tue, 18 Jul 2017 21:33:45 +0530
Subject: [PATCH 569/569] glusterd: Set default value for
 cluster.max-bricks-per-process to 0

When brick-multiplexing is enabled, and
"cluster.max-bricks-per-process" isn't explicitly set, multiplexing
happens without any limit set. But the default value set for that
tunable is 1, which is confusing. This commit sets the default
value to 0, and prevents the user from being able to set this value
to 1 when brick-multiplexing is enbaled. The default value of 0
denotes that brick-multiplexing can happen without any limit on the
number of bricks per process.

> Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
> Reviewed-on: https://review.gluster.org/17819
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

Change-Id: I4647f7bf5837d520075dc5c19a6e75bc1bba258b
BUG: 1472289
Signed-off-by: Samikshan Bairagya <sbairagy@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/112934
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 tests/basic/mpx-compat.t                        |  1 +
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |  6 ++++--
 xlators/mgmt/glusterd/src/glusterd-utils.c      | 21 ++++++++++++---------
 xlators/mgmt/glusterd/src/glusterd-volume-set.c | 19 +++++++++++++++----
 4 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/tests/basic/mpx-compat.t b/tests/basic/mpx-compat.t
index 3de0f6f..4ca262e 100644
--- a/tests/basic/mpx-compat.t
+++ b/tests/basic/mpx-compat.t
@@ -15,6 +15,7 @@ function count_processes {
 	pgrep glusterfsd | wc -w
 }
 
+cleanup
 TEST glusterd
 TEST $CLI volume set all cluster.brick-multiplex yes
 push_trapfunc "$CLI volume set all cluster.brick-multiplex off"
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 4c8fef7..52f7505 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -78,10 +78,12 @@ glusterd_all_vol_opts valid_all_vol_opts[] = {
          * TBD: add a dynamic handler to set the appropriate value
          */
         { GLUSTERD_BRICK_MULTIPLEX_KEY,         "disable"},
-        /* Set this value to 1 by default implying non-multiplexed behaviour.
+        /* Set this value to 0 by default implying brick-multiplexing
+         * behaviour with no limit set on the number of brick instances that
+         * can be attached per process.
          * TBD: Discuss the default value for this. Maybe this should be a
          * dynamic value depending on the memory specifications per node */
-        { GLUSTERD_BRICKMUX_LIMIT_KEY,          "1"},
+        { GLUSTERD_BRICKMUX_LIMIT_KEY,          "0"},
         { NULL },
 };
 
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 0f5c148..55f7089 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -121,7 +121,7 @@ get_mux_limit_per_process (int *mux_limit)
 {
         char            *value = NULL;
         int             ret = -1;
-        int             max_bricks_per_proc = -1;
+        int             max_bricks_per_proc = 0;
         xlator_t        *this = NULL;
         glusterd_conf_t *priv = NULL;
 
@@ -139,15 +139,18 @@ get_mux_limit_per_process (int *mux_limit)
 
         ret = dict_get_str (priv->opts, GLUSTERD_BRICKMUX_LIMIT_KEY, &value);
         if (ret) {
-                gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
-                        "Can't get limit for number of bricks per brick "
-                        "process from dict");
+                gf_msg_debug (this->name, 0, "Limit for number of bricks per "
+                              "brick process not yet set in dict. Returning "
+                              "limit as 0 denoting that multiplexing can "
+                              "happen with no limit set.");
                 ret = 0;
-        } else {
-                ret = gf_string2int (value, &max_bricks_per_proc);
-                if (ret)
-                        goto out;
+                goto out;
         }
+
+        ret = gf_string2int (value, &max_bricks_per_proc);
+        if (ret)
+                goto out;
+
 out:
         *mux_limit = max_bricks_per_proc;
 
@@ -5486,7 +5489,7 @@ find_compat_brick_in_vol (glusterd_conf_t *conf,
                         continue;
                 }
 
-                if (mux_limit != -1) {
+                if (mux_limit != 0) {
                         if (brick_proc->brick_count >= mux_limit)
                                 continue;
                 } else {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 28989ea..ddda66e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -991,6 +991,14 @@ validate_mux_limit (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
                 gf_msg (this->name, GF_LOG_ERROR, 0,
                         GD_MSG_INVALID_ENTRY, "%s", *op_errstr);
         }
+
+        if (val == 1) {
+                gf_asprintf (op_errstr, "Brick-multiplexing is enabled. "
+                             "Please set this option to a value other than 1 "
+                             "to make use of the brick-multiplexing feature.");
+                ret = -1;
+                goto out;
+        }
 out:
         gf_msg_debug ("glusterd", 0, "Returning %d", ret);
 
@@ -3275,14 +3283,17 @@ struct volopt_map_entry glusterd_volopt_map[] = {
         },
         { .key         = GLUSTERD_BRICKMUX_LIMIT_KEY,
           .voltype     = "mgmt/glusterd",
-          .value       = "1",
+          .value       = "0",
           .op_version  = GD_OP_VERSION_3_11_1,
           .validate_fn = validate_mux_limit,
           .type        = GLOBAL_DOC,
           .description = "This option can be used to limit the number of brick "
-                         "instances per brick process when brick multiplexing "
-                         "is enabled. This option can be set only when brick "
-                         "multiplexing feature enabled."
+                         "instances per brick process when brick-multiplexing "
+                         "is enabled. If not explicitly set, this tunable is "
+                         "set to 0 which denotes that brick-multiplexing can "
+                         "happen without any limit on the number of bricks per "
+                         "process. Also this option can't be set when the "
+                         "brick-multiplexing feature is disabled."
         },
         { .key         = NULL
         }
-- 
1.8.3.1