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