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