From 4a9a5362f0b74046b7f161d485b2ffb44c027ead Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 23 Nov 2016 16:04:26 +0530 Subject: glusterd/ganesha : handle volume reset properly for ganesha options The "gluster volume reset" should first unexport the volume and then delete export configuration file. Also reset option is not applicable for ganesha.enable if volume value is "all". This patch also changes the name of create_export_config into manange_export_config Change-Id: Ie81a49e7d3e39a88bca9fbae5002bfda5cab34af BUG: 1397795 Signed-off-by: Jiffin Tony Thottan Reviewed-on: http://review.gluster.org/15914 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: soumya k Reviewed-by: Kaleb KEITHLEY --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 57 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index b2dfcb27f5b..3d9372a5357 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1499,15 +1499,6 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) ret = glusterd_validate_volume_id (dict, volinfo); if (ret) goto out; - ret = dict_get_str_boolean (priv->opts, - GLUSTERD_STORE_KEY_GANESHA_GLOBAL, _gf_false); - if (ret) { - ret = stop_ganesha (op_errstr); - if (ret) - gf_msg (THIS->name, GF_LOG_WARNING, 0, - GD_MSG_NFS_GNS_STOP_FAIL, - "Could not stop NFS-Ganesha service"); - } } @@ -1517,7 +1508,23 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) GD_MSG_DICT_GET_FAILED, "Unable to get option key"); goto out; } - if (strcmp(key, "all")) { + + /* * + * If key ganesha.enable is set, then volume should be unexported from + * ganesha server. Also it is a volume-level option, perform only when + * volume name not equal to "all"(in other words if volinfo != NULL) + */ + if (volinfo && (!strcmp (key, "all") || !strcmp(key, "ganesha.enable"))) { + if (glusterd_check_ganesha_export (volinfo)) { + ret = ganesha_manage_export (dict, "off", op_errstr); + if (ret) + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_NFS_GNS_RESET_FAIL, + "Could not reset ganesha.enable key"); + } + } + + if (strcmp(key, "all")) { exists = glusterd_check_option_exists (key, &key_fixed); if (exists == -1) { ret = -1; @@ -2054,7 +2061,6 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) gf_boolean_t all = _gf_false; char *next_version = NULL; gf_boolean_t quorum_action = _gf_false; - gf_boolean_t option = _gf_false; conf = this->private; ret = dict_get_str (dict, "key", &key); @@ -2083,15 +2089,6 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) if (key_fixed) key = key_fixed; - option = dict_get_str_boolean (conf->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, - _gf_false); - if (option) { - ret = tear_down_cluster (is_origin_glusterd (dict)); - if (ret == -1) - gf_msg (THIS->name, GF_LOG_WARNING, errno, - GD_MSG_DICT_GET_FAILED, - "Could not tear down NFS-Ganesha cluster"); - } ret = -1; dup_opt = dict_new (); @@ -2200,16 +2197,6 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) if (glusterd_is_quorum_changed (volinfo->dict, key, NULL)) quorum_action = _gf_true; - ret = glusterd_check_ganesha_export (volinfo); - if (ret) { - ret = ganesha_manage_export (dict, "off", op_rspstr); - if (ret) { - gf_msg (THIS->name, GF_LOG_WARNING, 0, - GD_MSG_NFS_GNS_RESET_FAIL, - "Could not reset ganesha.enable key"); - ret = 0; - } - } ret = glusterd_options_reset (volinfo, key, &is_force); if (ret == -1) { @@ -2226,6 +2213,16 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) } } + if (!strcmp(key, "ganesha.enable") || !strcmp (key, "all")) { + if (glusterd_check_ganesha_export (volinfo)) { + ret = manage_export_config (volname, "off", op_rspstr); + if (ret) + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_NFS_GNS_RESET_FAIL, + "Could not reset ganesha.enable key"); + } + } + out: GF_FREE (key_fixed); if (quorum_action) -- cgit