e7a346
From 2cd1f86d0bd47f93f6e278530fc76a1e44aa9333 Mon Sep 17 00:00:00 2001
e7a346
From: Jiffin Tony Thottan <jthottan@redhat.com>
e7a346
Date: Tue, 25 Apr 2017 16:36:40 +0530
e7a346
Subject: [PATCH 59/74] glusterd/ganesha : update cache invalidation properly
e7a346
 during volume stop
e7a346
e7a346
As per current code, during volume stop for ganesha enabled volume the
e7a346
feature.cache-invalidation was turned "off" in ganesha_manage_export().
e7a346
And it never turn back to "on" when volume is started. It is not desire
e7a346
to modify the volume options during stop, this patch fixes above mentioned
e7a346
issue.
e7a346
e7a346
Change-Id: Iea9c62e5cda4f54805b41ea6055cf0c3652a634c
e7a346
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e7a346
Reviewed-on: https://review.gluster.org/17111
e7a346
Smoke: Gluster Build System <jenkins@build.gluster.org>
e7a346
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
e7a346
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
e7a346
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
e7a346
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
e7a346
---
e7a346
 xlators/mgmt/glusterd/src/glusterd-ganesha.c    | 30 ++++++++++++++-----------
e7a346
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |  4 ++--
e7a346
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c |  2 +-
e7a346
 xlators/mgmt/glusterd/src/glusterd.h            |  3 ++-
e7a346
 4 files changed, 22 insertions(+), 17 deletions(-)
e7a346
e7a346
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
e7a346
index 2392341..5d6144a 100644
e7a346
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
e7a346
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
e7a346
@@ -463,7 +463,8 @@ manage_export_config (char *volname, char *value, char **op_errstr)
e7a346
 
e7a346
 /* Exports and unexports a particular volume via NFS-Ganesha */
e7a346
 int
e7a346
-ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
e7a346
+ganesha_manage_export (dict_t *dict, char *value,
e7a346
+                       gf_boolean_t update_cache_invalidation, char **op_errstr)
e7a346
 {
e7a346
         runner_t                 runner = {0,};
e7a346
         int                      ret = -1;
e7a346
@@ -573,17 +574,20 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
e7a346
                 }
e7a346
         }
e7a346
 
e7a346
-        vol_opts = volinfo->dict;
e7a346
-        ret = dict_set_dynstr_with_alloc (vol_opts,
e7a346
-                                 "features.cache-invalidation", value);
e7a346
-        if (ret)
e7a346
-                gf_asprintf (op_errstr, "Cache-invalidation could not"
e7a346
-                                        " be set to %s.", value);
e7a346
-        ret = glusterd_store_volinfo (volinfo,
e7a346
-                        GLUSTERD_VOLINFO_VER_AC_INCREMENT);
e7a346
-        if (ret)
e7a346
-                gf_asprintf (op_errstr, "failed to store volinfo for %s"
e7a346
-                             , volinfo->volname);
e7a346
+        if (update_cache_invalidation) {
e7a346
+                vol_opts = volinfo->dict;
e7a346
+                ret = dict_set_dynstr_with_alloc (vol_opts,
e7a346
+                                                  "features.cache-invalidation",
e7a346
+                                                  value);
e7a346
+                if (ret)
e7a346
+                        gf_asprintf (op_errstr, "Cache-invalidation could not"
e7a346
+                                                " be set to %s.", value);
e7a346
+                ret = glusterd_store_volinfo (volinfo,
e7a346
+                                              GLUSTERD_VOLINFO_VER_AC_INCREMENT);
e7a346
+                if (ret)
e7a346
+                        gf_asprintf (op_errstr, "failed to store volinfo for %s"
e7a346
+                                     , volinfo->volname);
e7a346
+        }
e7a346
 
e7a346
 out:
e7a346
         return ret;
e7a346
@@ -858,7 +862,7 @@ glusterd_handle_ganesha_op (dict_t *dict, char **op_errstr,
e7a346
 
e7a346
 
e7a346
         if (strcmp (key, "ganesha.enable") == 0) {
e7a346
-                ret =  ganesha_manage_export (dict, value, op_errstr);
e7a346
+                ret =  ganesha_manage_export (dict, value, _gf_true, op_errstr);
e7a346
                 if (ret < 0)
e7a346
                         goto out;
e7a346
         }
e7a346
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
e7a346
index 06e9e25..86f18f0 100644
e7a346
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
e7a346
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
e7a346
@@ -1128,7 +1128,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
e7a346
 
e7a346
                 if ((strcmp (key, "ganesha.enable") == 0) &&
e7a346
                     (strcmp (value, "off") == 0)) {
e7a346
-                        ret = ganesha_manage_export (dict, "off", op_errstr);
e7a346
+                        ret = ganesha_manage_export (dict, "off", _gf_true, op_errstr);
e7a346
                         if (ret)
e7a346
                                 goto out;
e7a346
                 }
e7a346
@@ -1655,7 +1655,7 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)
e7a346
          */
e7a346
         if (volinfo && (!strcmp (key, "all") || !strcmp(key, "ganesha.enable"))) {
e7a346
                 if (glusterd_check_ganesha_export (volinfo)) {
e7a346
-                        ret = ganesha_manage_export (dict, "off", op_errstr);
e7a346
+                        ret = ganesha_manage_export (dict, "off", _gf_true, op_errstr);
e7a346
                         if (ret)
e7a346
                                 gf_msg (this->name, GF_LOG_WARNING, 0,
e7a346
                                         GD_MSG_NFS_GNS_RESET_FAIL,
e7a346
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
e7a346
index 92db458..725d194 100644
e7a346
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
e7a346
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
e7a346
@@ -1739,7 +1739,7 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr)
e7a346
         }
e7a346
         ret = glusterd_check_ganesha_export (volinfo);
e7a346
         if (ret) {
e7a346
-                ret = ganesha_manage_export(dict, "off", op_errstr);
e7a346
+                ret = ganesha_manage_export(dict, "off", _gf_false, op_errstr);
e7a346
                 if (ret) {
e7a346
                         gf_msg (THIS->name, GF_LOG_WARNING, 0,
e7a346
                                 GD_MSG_NFS_GNS_UNEXPRT_VOL_FAIL, "Could not "
e7a346
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
e7a346
index 2d8dbb9..3ad5ed6 100644
e7a346
--- a/xlators/mgmt/glusterd/src/glusterd.h
e7a346
+++ b/xlators/mgmt/glusterd/src/glusterd.h
e7a346
@@ -1176,7 +1176,8 @@ int glusterd_check_ganesha_cmd (char *key, char *value,
e7a346
                                 char **errstr, dict_t *dict);
e7a346
 int glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr);
e7a346
 int glusterd_op_set_ganesha (dict_t *dict, char **errstr);
e7a346
-int ganesha_manage_export (dict_t *dict, char *value, char **op_errstr);
e7a346
+int ganesha_manage_export (dict_t *dict, char *value,
e7a346
+                           gf_boolean_t update_cache_invalidation, char **op_errstr);
e7a346
 int manage_export_config (char *volname, char *value, char **op_errstr);
e7a346
 
e7a346
 gf_boolean_t
e7a346
-- 
e7a346
1.8.3.1
e7a346