50dc83
From e5450c639915f4c29ae2ad480e4128b5845254cc Mon Sep 17 00:00:00 2001
50dc83
From: Jiffin Tony Thottan <jthottan@redhat.com>
50dc83
Date: Tue, 25 Apr 2017 16:36:40 +0530
50dc83
Subject: [PATCH 063/124] glusterd/ganesha : update cache invalidation properly
50dc83
 during volume stop
50dc83
50dc83
As per current code, during volume stop for ganesha enabled volume the
50dc83
feature.cache-invalidation was turned "off" in ganesha_manage_export().
50dc83
And it never turn back to "on" when volume is started. It is not desire
50dc83
to modify the volume options during stop, this patch fixes above mentioned
50dc83
issue.
50dc83
50dc83
Label: DOWNSTREAM ONLY
50dc83
50dc83
Change-Id: Iea9c62e5cda4f54805b41ea6055cf0c3652a634c
50dc83
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
50dc83
Reviewed-on: https://review.gluster.org/17111
50dc83
Smoke: Gluster Build System <jenkins@build.gluster.org>
50dc83
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
50dc83
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
50dc83
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
50dc83
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
50dc83
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/167148
50dc83
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
50dc83
---
50dc83
 xlators/mgmt/glusterd/src/glusterd-ganesha.c    | 33 ++++++++++++++-----------
50dc83
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |  4 +--
50dc83
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c |  2 +-
50dc83
 xlators/mgmt/glusterd/src/glusterd.h            |  3 ++-
50dc83
 4 files changed, 23 insertions(+), 19 deletions(-)
50dc83
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
50dc83
index b743216..1c2ba7a 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
50dc83
@@ -445,7 +445,8 @@ manage_export_config(char *volname, char *value, char **op_errstr)
50dc83
 
50dc83
 /* Exports and unexports a particular volume via NFS-Ganesha */
50dc83
 int
50dc83
-ganesha_manage_export(dict_t *dict, char *value, char **op_errstr)
50dc83
+ganesha_manage_export(dict_t *dict, char *value,
50dc83
+                      gf_boolean_t update_cache_invalidation, char **op_errstr)
50dc83
 {
50dc83
     runner_t runner = {
50dc83
         0,
50dc83
@@ -558,19 +559,21 @@ ganesha_manage_export(dict_t *dict, char *value, char **op_errstr)
50dc83
         }
50dc83
     }
50dc83
 
50dc83
-    vol_opts = volinfo->dict;
50dc83
-    ret = dict_set_dynstr_with_alloc(vol_opts, "features.cache-invalidation",
50dc83
-                                     value);
50dc83
-    if (ret)
50dc83
-        gf_asprintf(op_errstr,
50dc83
-                    "Cache-invalidation could not"
50dc83
-                    " be set to %s.",
50dc83
-                    value);
50dc83
-    ret = glusterd_store_volinfo(volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
50dc83
-    if (ret)
50dc83
-        gf_asprintf(op_errstr, "failed to store volinfo for %s",
50dc83
-                    volinfo->volname);
50dc83
-
50dc83
+    if (update_cache_invalidation) {
50dc83
+        vol_opts = volinfo->dict;
50dc83
+        ret = dict_set_dynstr_with_alloc(vol_opts,
50dc83
+                                         "features.cache-invalidation", value);
50dc83
+        if (ret)
50dc83
+            gf_asprintf(op_errstr,
50dc83
+                        "Cache-invalidation could not"
50dc83
+                        " be set to %s.",
50dc83
+                        value);
50dc83
+        ret = glusterd_store_volinfo(volinfo,
50dc83
+                                     GLUSTERD_VOLINFO_VER_AC_INCREMENT);
50dc83
+        if (ret)
50dc83
+            gf_asprintf(op_errstr, "failed to store volinfo for %s",
50dc83
+                        volinfo->volname);
50dc83
+    }
50dc83
 out:
50dc83
     return ret;
50dc83
 }
50dc83
@@ -867,7 +870,7 @@ glusterd_handle_ganesha_op(dict_t *dict, char **op_errstr, char *key,
50dc83
     GF_ASSERT(value);
50dc83
 
50dc83
     if (strcmp(key, "ganesha.enable") == 0) {
50dc83
-        ret = ganesha_manage_export(dict, value, op_errstr);
50dc83
+        ret = ganesha_manage_export(dict, value, _gf_true, op_errstr);
50dc83
         if (ret < 0)
50dc83
             goto out;
50dc83
     }
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
50dc83
index a630c48..52809a8 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
50dc83
@@ -1178,7 +1178,7 @@ glusterd_op_stage_set_volume(dict_t *dict, char **op_errstr)
50dc83
 
50dc83
         if ((strcmp(key, "ganesha.enable") == 0) &&
50dc83
             (strcmp(value, "off") == 0)) {
50dc83
-            ret = ganesha_manage_export(dict, "off", op_errstr);
50dc83
+            ret = ganesha_manage_export(dict, "off", _gf_true, op_errstr);
50dc83
             if (ret)
50dc83
                 goto out;
50dc83
         }
50dc83
@@ -1691,7 +1691,7 @@ glusterd_op_stage_reset_volume(dict_t *dict, char **op_errstr)
50dc83
      */
50dc83
     if (volinfo && (!strcmp(key, "all") || !strcmp(key, "ganesha.enable"))) {
50dc83
         if (glusterd_check_ganesha_export(volinfo)) {
50dc83
-            ret = ganesha_manage_export(dict, "off", op_errstr);
50dc83
+            ret = ganesha_manage_export(dict, "off", _gf_true, op_errstr);
50dc83
             if (ret)
50dc83
                 gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_NFS_GNS_RESET_FAIL,
50dc83
                        "Could not reset ganesha.enable key");
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
50dc83
index 81c668c..de4eccb 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
50dc83
@@ -1825,7 +1825,7 @@ glusterd_op_stage_stop_volume(dict_t *dict, char **op_errstr)
50dc83
 
50dc83
     ret = glusterd_check_ganesha_export(volinfo);
50dc83
     if (ret) {
50dc83
-        ret = ganesha_manage_export(dict, "off", op_errstr);
50dc83
+        ret = ganesha_manage_export(dict, "off", _gf_false, op_errstr);
50dc83
         if (ret) {
50dc83
             gf_msg(THIS->name, GF_LOG_WARNING, 0,
50dc83
                    GD_MSG_NFS_GNS_UNEXPRT_VOL_FAIL,
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
50dc83
index 5135181..e858ce4 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd.h
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd.h
50dc83
@@ -1368,7 +1368,8 @@ glusterd_op_stage_set_ganesha(dict_t *dict, char **op_errstr);
50dc83
 int
50dc83
 glusterd_op_set_ganesha(dict_t *dict, char **errstr);
50dc83
 int
50dc83
-ganesha_manage_export(dict_t *dict, char *value, char **op_errstr);
50dc83
+ganesha_manage_export(dict_t *dict, char *value,
50dc83
+                      gf_boolean_t update_cache_invalidation, char **op_errstr);
50dc83
 gf_boolean_t
50dc83
 glusterd_is_ganesha_cluster();
50dc83
 gf_boolean_t
50dc83
-- 
50dc83
1.8.3.1
50dc83