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