190130
From 86df0ced1cac0e3c48f6149bb2f5442f8548f89e Mon Sep 17 00:00:00 2001
190130
From: Sanju Rakonde <srakonde@redhat.com>
190130
Date: Wed, 25 Dec 2019 21:56:32 +0530
190130
Subject: [PATCH 390/449] glusterd: deafult options after volume reset
190130
190130
Problem: default option itransport.address-family is disappered
190130
in volume info output after a volume reset.
190130
190130
Cause: with 3.8.0 onwards volume option transport.address-family
190130
has default value, any volume which is created will have this
190130
option set. So, volume info will show this in its output. But,
190130
with reset volume, this option is not handled.
190130
190130
Solution: In glusterd_enable_default_options(), we should add this
190130
option along with other default options. This function is called
190130
by glusterd_options_reset() with volume reset command.
190130
190130
> upstream patch link: https://review.gluster.org/#/c/glusterfs/+/23921/
190130
> fixes: bz#1786478
190130
> Change-Id: I58f7aa24cf01f308c4efe6cae748cc3bc8b99b1d
190130
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
190130
190130
BUG: 1781710
190130
Change-Id: I58f7aa24cf01f308c4efe6cae748cc3bc8b99b1d
190130
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
190130
Reviewed-on: https://code.engineering.redhat.com/gerrit/202258
190130
Tested-by: RHGS Build Bot <nigelb@redhat.com>
190130
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
190130
---
190130
 tests/bugs/glusterd/optimized-basic-testcases.t |  5 +++++
190130
 xlators/mgmt/glusterd/src/glusterd-utils.c      | 23 +++++++++++++++++++++++
190130
 2 files changed, 28 insertions(+)
190130
190130
diff --git a/tests/bugs/glusterd/optimized-basic-testcases.t b/tests/bugs/glusterd/optimized-basic-testcases.t
190130
index d700b5e..c7e8c32 100644
190130
--- a/tests/bugs/glusterd/optimized-basic-testcases.t
190130
+++ b/tests/bugs/glusterd/optimized-basic-testcases.t
190130
@@ -69,6 +69,11 @@ TEST pidof glusterd;
190130
 TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
190130
 EXPECT 'Created' volinfo_field $V0 'Status';
190130
 
190130
+#bug-1786478 - default volume option after volume reset
190130
+addr_family=`volinfo_field $V0 'transport.address-family'`
190130
+TEST $CLI volume reset $V0
190130
+EXPECT $addr_family  volinfo_field $V0 'transport.address-family'
190130
+
190130
 #bug-955588 - uuid validation
190130
 
190130
 uuid=`grep UUID $GLUSTERD_WORKDIR/glusterd.info | cut -f2 -d=`
190130
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
190130
index c92cdf3..6654741 100644
190130
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
190130
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
190130
@@ -13032,6 +13032,11 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
190130
     int ret = 0;
190130
     xlator_t *this = NULL;
190130
     glusterd_conf_t *conf = NULL;
190130
+#ifdef IPV6_DEFAULT
190130
+    char *addr_family = "inet6";
190130
+#else
190130
+    char *addr_family = "inet";
190130
+#endif
190130
 
190130
     this = THIS;
190130
     GF_ASSERT(this);
190130
@@ -13109,6 +13114,24 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
190130
             }
190130
         }
190130
     }
190130
+
190130
+    if (conf->op_version >= GD_OP_VERSION_3_9_0) {
190130
+        if (!option || !strcmp("transport.address-family", option)) {
190130
+            if (volinfo->transport_type == GF_TRANSPORT_TCP) {
190130
+                ret = dict_set_dynstr_with_alloc(
190130
+                    volinfo->dict, "transport.address-family", addr_family);
190130
+                if (ret) {
190130
+                    gf_msg(this->name, GF_LOG_ERROR, errno,
190130
+                           GD_MSG_DICT_SET_FAILED,
190130
+                           "failed to set transport."
190130
+                           "address-family on %s",
190130
+                           volinfo->volname);
190130
+                    goto out;
190130
+                }
190130
+            }
190130
+        }
190130
+    }
190130
+
190130
     if (conf->op_version >= GD_OP_VERSION_7_0) {
190130
         ret = dict_set_dynstr_with_alloc(volinfo->dict,
190130
                                          "storage.fips-mode-rchecksum", "on");
190130
-- 
190130
1.8.3.1
190130