a3470f
From 52798b6934ea584b25b1ade64cb52a7439c1b113 Mon Sep 17 00:00:00 2001
a3470f
From: Atin Mukherjee <amukherj@redhat.com>
a3470f
Date: Tue, 3 Jan 2017 18:13:29 +0530
a3470f
Subject: [PATCH 27/74] glusterd: spawn nfs daemon in op-version bump if
a3470f
 nfs.disable key is absent
a3470f
a3470f
3.2.0 onwards gNFS will be disabled by default. However any cluster
a3470f
upgraded to 3.2.0 with existing volumes exposed over gNFS should
a3470f
continue to have gNFS access and hence post upgrade gNFS service should
a3470f
come up after bumping up the op-version. Although the key nfs.disable
a3470f
was handled and managed correctly in the upgrade path but gNFS daemon
a3470f
was never spawned in this case.
a3470f
a3470f
Fix is to spawn gNFS daemon in op-version bump up code path if
a3470f
nfs.disable option is not set.
a3470f
a3470f
Label : DOWNSTREAM ONLY
a3470f
a3470f
Change-Id: Icac6f3653160f79b271f25f5df0c89690917e702
a3470f
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/94006
a3470f
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
a3470f
Reviewed-by: Samikshan Bairagya <sbairagy@redhat.com>
a3470f
---
a3470f
 xlators/mgmt/glusterd/src/glusterd-messages.h |  8 ++++++
a3470f
 xlators/mgmt/glusterd/src/glusterd-op-sm.c    | 35 ++++++++++++++++++++++++---
a3470f
 2 files changed, 40 insertions(+), 3 deletions(-)
a3470f
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
index 65d4353..8bb4c43 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
@@ -4937,6 +4937,14 @@
a3470f
  */
a3470f
 #define GD_MSG_GARBAGE_ARGS                         (GLUSTERD_COMP_BASE + 611)
a3470f
 
a3470f
+/*!
a3470f
+ * @messageid
a3470f
+ * @diagnosis
a3470f
+ * @recommendedaction
a3470f
+ *
a3470f
+ */
a3470f
+#define GD_MSG_SVC_START_FAIL                      (GLUSTERD_COMP_BASE + 590)
a3470f
+
a3470f
 /*------------*/
a3470f
 
a3470f
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
index 0557ad8..4fc719a 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
@@ -2423,7 +2423,8 @@ out:
a3470f
 }
a3470f
 
a3470f
 static int
a3470f
-glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
a3470f
+glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo,
a3470f
+                              gf_boolean_t *start_nfs_svc)
a3470f
 {
a3470f
         int              ret = -1;
a3470f
         xlator_t        *this = NULL;
a3470f
@@ -2436,6 +2437,8 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
a3470f
         conf = this->private;
a3470f
         GF_VALIDATE_OR_GOTO (this->name, conf, out);
a3470f
 
a3470f
+        ret = 0;
a3470f
+
a3470f
         /* 3.9.0 onwards gNFS will be disabled by default. In case of an upgrade
a3470f
          * from anything below than 3.9.0 to 3.9.x, the value for nfs.disable is
a3470f
          * set to 'off' for all volumes even if it is not explicitly set in the
a3470f
@@ -2458,6 +2461,12 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
a3470f
                                         "volume %s", volinfo->volname);
a3470f
                                 goto out;
a3470f
                         }
a3470f
+                        /* If the volume is started then mark start_nfs_svc to
a3470f
+                         * true such that nfs daemon can be spawned up
a3470f
+                         */
a3470f
+                        if (GLUSTERD_STATUS_STARTED == volinfo->status)
a3470f
+                                *start_nfs_svc = _gf_true;
a3470f
+
a3470f
                 }
a3470f
 
a3470f
                 ret = dict_get_str (volinfo->dict, "transport.address-family",
a3470f
@@ -2478,9 +2487,12 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
a3470f
                                 }
a3470f
                         }
a3470f
                 }
a3470f
+                ret = glusterd_store_volinfo (volinfo,
a3470f
+                                              GLUSTERD_VOLINFO_VER_AC_INCREMENT);
a3470f
+                if (ret)
a3470f
+                        goto out;
a3470f
+
a3470f
         }
a3470f
-        ret = glusterd_store_volinfo (volinfo,
a3470f
-                                      GLUSTERD_VOLINFO_VER_AC_INCREMENT);
a3470f
 
a3470f
 out:
a3470f
         return ret;
a3470f
@@ -2529,6 +2541,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
a3470f
         uint32_t             op_version             = 0;
a3470f
         glusterd_volinfo_t  *volinfo                = NULL;
a3470f
         glusterd_svc_t      *svc                    = NULL;
a3470f
+        gf_boolean_t         start_nfs_svc          = _gf_false;
a3470f
 
a3470f
         conf = this->private;
a3470f
         ret = dict_get_str (dict, "key1", &key);
a3470f
@@ -2645,6 +2658,22 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
a3470f
                                         "Failed to store op-version.");
a3470f
                         }
a3470f
                 }
a3470f
+                cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
a3470f
+                        ret = glusterd_update_volumes_dict (volinfo,
a3470f
+                                                            &start_nfs_svc);
a3470f
+                        if (ret)
a3470f
+                                goto out;
a3470f
+                }
a3470f
+                if (start_nfs_svc) {
a3470f
+                        ret = conf->nfs_svc.manager (&(conf->nfs_svc), NULL,
a3470f
+                                                     PROC_START_NO_WAIT);
a3470f
+                        if (ret) {
a3470f
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
+                                        GD_MSG_SVC_START_FAIL,
a3470f
+                                         "unable to start nfs service");
a3470f
+                                goto out;
a3470f
+                        }
a3470f
+                }
a3470f
                 /* No need to save cluster.op-version in conf->opts
a3470f
                  */
a3470f
                 goto out;
a3470f
-- 
a3470f
1.8.3.1
a3470f