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