3604df
From a863c82fce2175fd30663f26c9273ecdc596b0ee Mon Sep 17 00:00:00 2001
3604df
From: Atin Mukherjee <amukherj@redhat.com>
3604df
Date: Tue, 3 Jan 2017 18:13:29 +0530
3604df
Subject: [PATCH 261/267] glusterd: spawn nfs daemon in op-version bump if
3604df
 nfs.disable key is absent
3604df
3604df
3.2.0 onwards gNFS will be disabled by default. However any cluster
3604df
upgraded to 3.2.0 with existing volumes exposed over gNFS should
3604df
continue to have gNFS access and hence post upgrade gNFS service should
3604df
come up after bumping up the op-version. Although the key nfs.disable
3604df
was handled and managed correctly in the upgrade path but gNFS daemon
3604df
was never spawned in this case.
3604df
3604df
Fix is to spawn gNFS daemon in op-version bump up code path if
3604df
nfs.disable option is not set.
3604df
3604df
Label : DOWNSTREAM ONLY
3604df
3604df
Change-Id: Icac6f3653160f79b271f25f5df0c89690917e702
3604df
BUG: 1409782
3604df
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/94006
3604df
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
3604df
Reviewed-by: Samikshan Bairagya <sbairagy@redhat.com>
3604df
---
3604df
 xlators/mgmt/glusterd/src/glusterd-messages.h | 10 ++++++++-
3604df
 xlators/mgmt/glusterd/src/glusterd-op-sm.c    | 32 +++++++++++++++++++++++----
3604df
 2 files changed, 37 insertions(+), 5 deletions(-)
3604df
3604df
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
3604df
index 126a583..2b77ac9 100644
3604df
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
3604df
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
3604df
@@ -41,7 +41,7 @@
3604df
 
3604df
 #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD
3604df
 
3604df
-#define GLFS_NUM_MESSAGES       589
3604df
+#define GLFS_NUM_MESSAGES       590
3604df
 
3604df
 #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
3604df
 /* Messaged with message IDs */
3604df
@@ -4762,6 +4762,14 @@
3604df
  */
3604df
 #define GD_MSG_NFS_GANESHA_DISABLED                (GLUSTERD_COMP_BASE + 589)
3604df
 
3604df
+/*!
3604df
+ * @messageid
3604df
+ * @diagnosis
3604df
+ * @recommendedaction
3604df
+ *
3604df
+ */
3604df
+#define GD_MSG_SVC_START_FAIL                      (GLUSTERD_COMP_BASE + 590)
3604df
+
3604df
 /*------------*/
3604df
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
3604df
 #endif /* !_GLUSTERD_MESSAGES_H_ */
3604df
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
index b0543fe..1293d29 100644
3604df
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
3604df
@@ -2287,7 +2287,8 @@ out:
3604df
 }
3604df
 
3604df
 static int
3604df
-glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
3604df
+glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo,
3604df
+                              gf_boolean_t *start_nfs_svc)
3604df
 {
3604df
         int              ret = -1;
3604df
         xlator_t        *this = NULL;
3604df
@@ -2300,6 +2301,8 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
3604df
         conf = this->private;
3604df
         GF_VALIDATE_OR_GOTO (this->name, conf, out);
3604df
 
3604df
+        ret = 0;
3604df
+
3604df
         /* 3.9.0 onwards gNFS will be disabled by default. In case of an upgrade
3604df
          * from anything below than 3.9.0 to 3.9.x, the value for nfs.disable is
3604df
          * set to 'off' for all volumes even if it is not explicitly set in the
3604df
@@ -2322,6 +2325,12 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
3604df
                                         "volume %s", volinfo->volname);
3604df
                                 goto out;
3604df
                         }
3604df
+                        /* If the volume is started then mark start_nfs_svc to
3604df
+                         * true such that nfs daemon can be spawned up
3604df
+                         */
3604df
+                        if (GLUSTERD_STATUS_STARTED == volinfo->status)
3604df
+                                *start_nfs_svc = _gf_true;
3604df
+
3604df
                 }
3604df
 
3604df
                 ret = dict_get_str (volinfo->dict, "transport.address-family",
3604df
@@ -2342,9 +2351,12 @@ glusterd_update_volumes_dict (glusterd_volinfo_t *volinfo)
3604df
                                 }
3604df
                         }
3604df
                 }
3604df
+                ret = glusterd_store_volinfo (volinfo,
3604df
+                                              GLUSTERD_VOLINFO_VER_AC_INCREMENT);
3604df
+                if (ret)
3604df
+                        goto out;
3604df
+
3604df
         }
3604df
-        ret = glusterd_store_volinfo (volinfo,
3604df
-                                      GLUSTERD_VOLINFO_VER_AC_INCREMENT);
3604df
 
3604df
 out:
3604df
         return ret;
3604df
@@ -2367,6 +2379,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
3604df
         glusterd_volinfo_t  *volinfo            = NULL;
3604df
         glusterd_volinfo_t  *tmp_volinfo        = NULL;
3604df
         glusterd_volinfo_t  *voliter            = NULL;
3604df
+        gf_boolean_t         start_nfs_svc      = _gf_false;
3604df
 
3604df
         conf = this->private;
3604df
         ret = dict_get_str (dict, "key1", &key);
3604df
@@ -2439,10 +2452,21 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
3604df
                         }
3604df
                 }
3604df
                 cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
3604df
-                        ret = glusterd_update_volumes_dict (volinfo);
3604df
+                        ret = glusterd_update_volumes_dict (volinfo,
3604df
+                                                            &start_nfs_svc);
3604df
                         if (ret)
3604df
                                 goto out;
3604df
                 }
3604df
+                if (start_nfs_svc) {
3604df
+                        ret = conf->nfs_svc.manager (&(conf->nfs_svc), NULL,
3604df
+                                                     PROC_START_NO_WAIT);
3604df
+                        if (ret) {
3604df
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
+                                        GD_MSG_SVC_START_FAIL,
3604df
+                                         "unable to start nfs service");
3604df
+                                goto out;
3604df
+                        }
3604df
+                }
3604df
                 /* No need to save cluster.op-version in conf->opts
3604df
                  */
3604df
                 goto out;
3604df
-- 
3604df
2.9.3
3604df