21ab4e
From b07b88e4c1835f793f49fc0b28f302442a351687 Mon Sep 17 00:00:00 2001
21ab4e
From: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Date: Tue, 25 Apr 2017 16:36:40 +0530
21ab4e
Subject: [PATCH 409/426] glusterd/ganesha : update cache invalidation properly
21ab4e
 during volume stop
21ab4e
21ab4e
As per current code, during volume stop for ganesha enabled volume the
21ab4e
feature.cache-invalidation was turned "off" in ganesha_manage_export().
21ab4e
And it never turn back to "on" when volume is started. It is not desire
21ab4e
to modify the volume options during stop, this patch fixes above mentioned
21ab4e
issue.
21ab4e
21ab4e
Upstream reference :
21ab4e
>Change-Id: Iea9c62e5cda4f54805b41ea6055cf0c3652a634c
21ab4e
>BUG: 1445260
21ab4e
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
>Reviewed-on: https://review.gluster.org/17111
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
21ab4e
>Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
21ab4e
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
21ab4e
Change-Id: Iea9c62e5cda4f54805b41ea6055cf0c3652a634c
21ab4e
BUG: 1443990
21ab4e
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/104974
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-ganesha.c    | 30 ++++++++++++++-----------
21ab4e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c      |  4 ++--
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c |  2 +-
21ab4e
 xlators/mgmt/glusterd/src/glusterd.h            |  3 ++-
21ab4e
 4 files changed, 22 insertions(+), 17 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
index 9c5e147..b7a6db4 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
@@ -476,7 +476,8 @@ manage_export_config (char *volname, char *value, char **op_errstr)
21ab4e
 
21ab4e
 /* Exports and unexports a particular volume via NFS-Ganesha */
21ab4e
 int
21ab4e
-ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
21ab4e
+ganesha_manage_export (dict_t *dict, char *value,
21ab4e
+                       gf_boolean_t update_cache_invalidation, char **op_errstr)
21ab4e
 {
21ab4e
         runner_t                 runner = {0,};
21ab4e
         int                      ret = -1;
21ab4e
@@ -589,17 +590,20 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
21ab4e
                 }
21ab4e
         }
21ab4e
 
21ab4e
-        vol_opts = volinfo->dict;
21ab4e
-        ret = dict_set_dynstr_with_alloc (vol_opts,
21ab4e
-                                 "features.cache-invalidation", value);
21ab4e
-        if (ret)
21ab4e
-                gf_asprintf (op_errstr, "Cache-invalidation could not"
21ab4e
-                                        " be set to %s.", value);
21ab4e
-        ret = glusterd_store_volinfo (volinfo,
21ab4e
-                        GLUSTERD_VOLINFO_VER_AC_INCREMENT);
21ab4e
-        if (ret)
21ab4e
-                gf_asprintf (op_errstr, "failed to store volinfo for %s"
21ab4e
-                             , volinfo->volname);
21ab4e
+        if (update_cache_invalidation) {
21ab4e
+                vol_opts = volinfo->dict;
21ab4e
+                ret = dict_set_dynstr_with_alloc (vol_opts,
21ab4e
+                                                  "features.cache-invalidation",
21ab4e
+                                                  value);
21ab4e
+                if (ret)
21ab4e
+                        gf_asprintf (op_errstr, "Cache-invalidation could not"
21ab4e
+                                                " be set to %s.", value);
21ab4e
+                ret = glusterd_store_volinfo (volinfo,
21ab4e
+                                              GLUSTERD_VOLINFO_VER_AC_INCREMENT);
21ab4e
+                if (ret)
21ab4e
+                        gf_asprintf (op_errstr, "failed to store volinfo for %s"
21ab4e
+                                     , volinfo->volname);
21ab4e
+        }
21ab4e
 
21ab4e
 out:
21ab4e
         return ret;
21ab4e
@@ -872,7 +876,7 @@ glusterd_handle_ganesha_op (dict_t *dict, char **op_errstr,
21ab4e
 
21ab4e
 
21ab4e
         if (strcmp (key, "ganesha.enable") == 0) {
21ab4e
-                ret =  ganesha_manage_export (dict, value, op_errstr);
21ab4e
+                ret =  ganesha_manage_export (dict, value, _gf_true, op_errstr);
21ab4e
                 if (ret < 0)
21ab4e
                         goto out;
21ab4e
         }
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
index c78a7a4..015f79c 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
@@ -1063,7 +1063,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
21ab4e
 
21ab4e
                 if ((strcmp (key, "ganesha.enable") == 0) &&
21ab4e
                     (strcmp (value, "off") == 0)) {
21ab4e
-                        ret = ganesha_manage_export (dict, "off", op_errstr);
21ab4e
+                        ret = ganesha_manage_export (dict, "off", _gf_true, op_errstr);
21ab4e
                         if (ret)
21ab4e
                                 goto out;
21ab4e
                 }
21ab4e
@@ -1581,7 +1581,7 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)
21ab4e
          */
21ab4e
         if (volinfo && (!strcmp (key, "all") || !strcmp(key, "ganesha.enable"))) {
21ab4e
                 if (glusterd_check_ganesha_export (volinfo)) {
21ab4e
-                        ret = ganesha_manage_export (dict, "off", op_errstr);
21ab4e
+                        ret = ganesha_manage_export (dict, "off", _gf_true, op_errstr);
21ab4e
                         if (ret)
21ab4e
                                 gf_msg (this->name, GF_LOG_WARNING, 0,
21ab4e
                                         GD_MSG_NFS_GNS_RESET_FAIL,
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
index 9e45f96..dd1a39a 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
@@ -1735,7 +1735,7 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr)
21ab4e
         }
21ab4e
         ret = glusterd_check_ganesha_export (volinfo);
21ab4e
         if (ret) {
21ab4e
-                ret = ganesha_manage_export(dict, "off", op_errstr);
21ab4e
+                ret = ganesha_manage_export(dict, "off", _gf_false, op_errstr);
21ab4e
                 if (ret) {
21ab4e
                         gf_msg (THIS->name, GF_LOG_WARNING, 0,
21ab4e
                                 GD_MSG_NFS_GNS_UNEXPRT_VOL_FAIL, "Could not "
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
21ab4e
index 671ec58..0a97657 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd.h
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd.h
21ab4e
@@ -1083,7 +1083,8 @@ int glusterd_check_ganesha_cmd (char *key, char *value,
21ab4e
                                 char **errstr, dict_t *dict);
21ab4e
 int glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr);
21ab4e
 int glusterd_op_set_ganesha (dict_t *dict, char **errstr);
21ab4e
-int ganesha_manage_export (dict_t *dict, char *value, char **op_errstr);
21ab4e
+int ganesha_manage_export (dict_t *dict, char *value,
21ab4e
+                           gf_boolean_t update_cache_invalidation, char **op_errstr);
21ab4e
 int manage_export_config (char *volname, char *value, char **op_errstr);
21ab4e
 
21ab4e
 gf_boolean_t
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e