Blob Blame History Raw
From aec05dcb188287df2961631f7c7f32e7d4f7ee1f Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Sat, 24 Sep 2016 13:18:24 +0530
Subject: [PATCH 106/141] glusterd: enable default configurations post upgrade to >= 3.9.0 versions

With 3.8.0 onwards volume options like nfs.disable, transport.address-family
have some default configuration value. If a volume was created pre upgrade to
3.8.0 or higher the default options are not set post upgrade. This patch takes
care of putting the default values in the op-version bump up workflow. However
these changes will only reflect from 3.9.0 onwards

>Reviewed-on: http://review.gluster.org/15568
>Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: soumya k <skoduri@redhat.com>
>Reviewed-by: Kaushal M <kaushal@redhat.com>

>Reviewed-on: http://review.gluster.org/15652
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>

This also fixes BZ 1378342 & BZ 1378676

Change-Id: I9a8d848cd08d87ddcb80dbeac27eaae097d9cbeb
BUG: 1378677
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/87434
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |   65 ++++++++++++++++++++++-
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c |   25 ++++++---
 2 files changed, 80 insertions(+), 10 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 1b50038..2b6814b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2252,6 +2252,68 @@ out:
 }
 
 static int
+glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
+{
+        int              ret = -1;
+        xlator_t        *this = NULL;
+        glusterd_conf_t *conf = NULL;
+        char            *address_family_str = NULL;
+
+        this = THIS;
+        GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+
+        conf = this->private;
+        GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+        /* 3.9.0 onwards gNFS will be disabled by default. In case of an upgrade
+         * from anything below than 3.9.0 to 3.9.x the volume's dictionary will
+         * not have 'nfs.disable' key set which means the same will not be set
+         * to on until explicitly done. setnfs.disable to 'on' at op-version
+         * bump up flow is the ideal way here. The same is also applicable for
+         * transport.address-family where if the transport type is set to tcp
+         * then transport.address-family is defaulted to 'inet'.
+         */
+        if (conf->op_version >= GD_OP_VERSION_3_9_0) {
+                if (dict_get_str_boolean (volinfo->dict, NFS_DISABLE_MAP_KEY,
+                                          1)) {
+                        ret = dict_set_dynstr_with_alloc (volinfo->dict,
+                                                          NFS_DISABLE_MAP_KEY,
+                                                          "on");
+                        if (ret) {
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        GD_MSG_DICT_SET_FAILED, "Failed to set "
+                                        "option ' NFS_DISABLE_MAP_KEY ' on "
+                                        "volume %s", volinfo->volname);
+                                goto out;
+                        }
+                }
+                ret = dict_get_str (volinfo->dict, "transport.address-family",
+                                    &address_family_str);
+                if (ret) {
+                        if (volinfo->transport_type == GF_TRANSPORT_TCP) {
+                                ret = dict_set_dynstr_with_alloc
+                                        (volinfo->dict,
+                                         "transport.address-family",
+                                         "inet");
+                                if (ret) {
+                                        gf_msg (this->name, GF_LOG_ERROR,
+                                                errno, GD_MSG_DICT_SET_FAILED,
+                                                "failed to set transport."
+                                                "address-family on %s",
+                                                volinfo->volname);
+                                        goto out;
+                                }
+                        }
+                }
+        }
+        ret = glusterd_store_volinfo (volinfo,
+                                      GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+
+out:
+        return ret;
+}
+
+static int
 glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
                                     char **op_errstr)
 {
@@ -2319,8 +2381,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
                         }
                 }
                 cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
-                        ret = glusterd_store_volinfo
-                                (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+                        ret = glusterd_update_volumes_dict (volinfo);
                         if (ret)
                                 goto out;
                 }
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index fcb4b3e..95dbafa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -278,6 +278,7 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
         char                    err_str[2048] = {0,};
         gf_cli_rsp              rsp         = {0,};
         xlator_t               *this        = NULL;
+        glusterd_conf_t        *conf        = NULL;
         char                   *free_ptr    = NULL;
         char                   *trans_type  = NULL;
         char                   *address_family_str  = NULL;
@@ -292,6 +293,9 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
         this = THIS;
         GF_ASSERT(this);
 
+        conf = this->private;
+        GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
         ret = -1;
         ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req);
         if (ret < 0) {
@@ -385,14 +389,19 @@ __glusterd_handle_create_volume (rpcsvc_request_t *req)
                         goto out;
                 }
         } else if (!strcmp(trans_type, "tcp")) {
-                /* Setting default as inet for trans_type tcp */
-                ret = dict_set_dynstr_with_alloc (dict,
-                                "transport.address-family",
-                                "inet");
-                if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "failed to set transport.address-family");
-                        goto out;
+                /* Setting default as inet for trans_type tcp if the op-version
+                 * is >= 3.8.0
+                 */
+                if (conf->op_version >= GD_OP_VERSION_3_8_0) {
+                        ret = dict_set_dynstr_with_alloc (dict,
+                                        "transport.address-family",
+                                        "inet");
+                        if (ret) {
+                                gf_log (this->name, GF_LOG_ERROR,
+                                        "failed to set "
+                                        "transport.address-family");
+                                goto out;
+                        }
                 }
         }
         ret = dict_get_str (dict, "bricks", &bricks);
-- 
1.7.1