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