summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-ganesha.c
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2016-07-12 17:23:03 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2016-08-26 04:46:06 -0700
commita769be2c0d4227fead7348e769bd1ae49e267971 (patch)
treed4bc04f2a312eab2ecb9a0e1f6d271f606bd9048 /xlators/mgmt/glusterd/src/glusterd-ganesha.c
parentca2c94bfcf96c44abb7168a9cb9c99a40e566280 (diff)
Revert "glusterd-ganesha : copy ganesha export configuration files during reboot"
This reverts commit f71e2fa49af185779b9f43e146effd122d4e9da0. Reason: As part of sync up node reboot this patch copies ganesha export conf file from a source node. This change is no more require if the export files are available in shared storage. Change-Id: Id9c1ae78377bbd7d5d80aa1c14f534e30feaae97 BUG: 1355956 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14907 Reviewed-by: soumya k <skoduri@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-ganesha.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-ganesha.c194
1 files changed, 68 insertions, 126 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index badb4c2f067..728bfc627b0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -427,42 +427,23 @@ create_export_config (char *volname, char **op_errstr)
CONFDIR, volname, NULL);
ret = runner_run(&runner);
- if (ret && op_errstr)
+ if (ret)
gf_asprintf (op_errstr, "Failed to create"
" NFS-Ganesha export config file.");
return ret;
}
-int
-copy_export_config (char *volname, char **op_errstr)
-{
- runner_t runner = {0,};
- int ret = -1;
-
- GF_ASSERT(volname);
- runinit (&runner);
- runner_add_args (&runner, "sh",
- GANESHA_PREFIX"/copy-export-ganesha.sh",
- CONFDIR, volname, NULL);
- ret = runner_run(&runner);
-
- if (ret && op_errstr)
- gf_asprintf (op_errstr, "Failed to copy"
- " NFS-Ganesha export config file.");
-
- return ret;
-}
/* Exports and unexports a particular volume via NFS-Ganesha */
int
-ganesha_manage_export (char *volname, char *value, char **op_errstr,
- gf_boolean_t reboot)
+ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
{
runner_t runner = {0,};
int ret = -1;
char str[1024];
glusterd_volinfo_t *volinfo = NULL;
dict_t *vol_opts = NULL;
+ char *volname = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
gf_boolean_t option = _gf_false;
@@ -474,10 +455,16 @@ ganesha_manage_export (char *volname, char *value, char **op_errstr,
priv = this->private;
GF_ASSERT (value);
+ GF_ASSERT (dict);
GF_ASSERT (priv);
- GF_VALIDATE_OR_GOTO (this->name, volname, out);
-
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to get volume name");
+ goto out;
+ }
ret = gf_string2boolean (value, &option);
if (ret == -1) {
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
@@ -485,77 +472,54 @@ ganesha_manage_export (char *volname, char *value, char **op_errstr,
goto out;
}
- /* *
- * Incase of reboot, following checks are already made before calling
- * ganesha_manage_export. So it will be reductant do it again
- */
- if (!reboot) {
- ret = glusterd_volinfo_find (volname, &volinfo);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- GD_MSG_VOL_NOT_FOUND,
- FMTSTR_CHECK_VOL_EXISTS, volname);
- goto out;
- }
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
+ FMTSTR_CHECK_VOL_EXISTS, volname);
+ goto out;
+ }
- ret = glusterd_check_ganesha_export (volinfo);
- if (ret && option) {
- if (op_errstr)
- gf_asprintf (op_errstr, "ganesha.enable "
- "is already 'on'.");
- ret = -1;
- goto out;
+ ret = glusterd_check_ganesha_export (volinfo);
+ if (ret && option) {
+ gf_asprintf (op_errstr, "ganesha.enable "
+ "is already 'on'.");
+ ret = -1;
+ goto out;
- } else if (!option && !ret) {
- if (op_errstr)
- gf_asprintf (op_errstr, "ganesha.enable "
- "is already 'off'.");
- ret = -1;
- goto out;
- }
+ } else if (!option && !ret) {
+ gf_asprintf (op_errstr, "ganesha.enable "
+ "is already 'off'.");
+ ret = -1;
+ goto out;
}
- ret = 0;
-
- /* *
- * Incase of restart, there is chance that global option turned off
- * with volume set command. Still we may need to clean up the
- * configuration files.
- * Otherwise check if global option is enabled, only then proceed
- * */
- if (!(reboot && !option)) {
- ret = dict_get_str_boolean (priv->opts,
+ /* Check if global option is enabled, proceed only then */
+ ret = dict_get_str_boolean (priv->opts,
GLUSTERD_STORE_KEY_GANESHA_GLOBAL, _gf_false);
- if (ret == -1) {
- gf_msg_debug (this->name, 0, "Failed to get "
- "global option dict.");
- if (op_errstr)
- gf_asprintf (op_errstr, "The option "
- "nfs-ganesha should be "
- "enabled before setting "
- "ganesha.enable.");
- goto out;
- }
- if (!ret) {
- if (op_errstr)
- gf_asprintf (op_errstr, "The option "
- "nfs-ganesha should be "
- "enabled before setting "
- "ganesha.enable.");
- ret = -1;
- goto out;
- }
+ if (ret == -1) {
+ gf_msg_debug (this->name, 0, "Failed to get "
+ "global option dict.");
+ gf_asprintf (op_errstr, "The option "
+ "nfs-ganesha should be "
+ "enabled before setting ganesha.enable.");
+ goto out;
}
+ if (!ret) {
+ gf_asprintf (op_errstr, "The option "
+ "nfs-ganesha should be "
+ "enabled before setting ganesha.enable.");
+ ret = -1;
+ goto out;
+ }
+
/* Create the export file only when ganesha.enable "on" is executed */
if (option) {
- if (reboot)
- ret = copy_export_config (volname, op_errstr);
- else
- ret = create_export_config (volname, op_errstr);
+ ret = create_export_config (volname, op_errstr);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_EXPORT_FILE_CREATE_FAIL,
- "Failed to create/copy "
+ "Failed to create"
"export file for NFS-Ganesha\n");
goto out;
}
@@ -566,42 +530,25 @@ ganesha_manage_export (char *volname, char *value, char **op_errstr,
CONFDIR, value, volname, NULL);
ret = runner_run (&runner);
if (ret) {
- if (op_errstr)
- gf_asprintf(op_errstr, "Dynamic export"
- " addition/deletion failed."
- " Please see log file for details");
- /* *
- * Incase of reboot scenarios, we cannot guarantee
- * nfs-ganesha to be running on that node, so that
- * dynamic export may fail
- */
- if (reboot)
- ret = 0;
- else
- goto out;
+ gf_asprintf(op_errstr, "Dynamic export"
+ " addition/deletion failed."
+ " Please see log file for details");
+ goto out;
}
}
+ vol_opts = volinfo->dict;
+ ret = dict_set_dynstr_with_alloc (vol_opts,
+ "features.cache-invalidation", value);
+ if (ret)
+ gf_asprintf (op_errstr, "Cache-invalidation could not"
+ " be set to %s.", value);
+ ret = glusterd_store_volinfo (volinfo,
+ GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+ if (ret)
+ gf_asprintf (op_errstr, "failed to store volinfo for %s"
+ , volinfo->volname);
- /* *
- * cache-invalidation should be on when a volume is exported
- * and off when a volume is unexported. It is not required
- * for reboot scenarios, already it will be copied.
- * */
- if (!reboot) {
- vol_opts = volinfo->dict;
- ret = dict_set_dynstr_with_alloc (vol_opts,
- "features.cache-invalidation", value);
- if (ret && op_errstr)
- gf_asprintf (op_errstr, "Cache-invalidation could not"
- " be set to %s.", value);
- ret = glusterd_store_volinfo (volinfo,
- GLUSTERD_VOLINFO_VER_AC_INCREMENT);
- if (ret && op_errstr)
- gf_asprintf (op_errstr, "failed to store volinfo for %s"
- , volinfo->volname);
-
- }
out:
return ret;
}
@@ -863,9 +810,12 @@ glusterd_handle_ganesha_op (dict_t *dict, char **op_errstr,
char *key, char *value)
{
- int32_t ret = -1;
+ int32_t ret = -1;
char *volname = NULL;
+ xlator_t *this = NULL;
gf_boolean_t option = _gf_false;
+ static int export_id = 1;
+ glusterd_volinfo_t *volinfo = NULL;
GF_ASSERT (dict);
GF_ASSERT (op_errstr);
@@ -874,15 +824,7 @@ glusterd_handle_ganesha_op (dict_t *dict, char **op_errstr,
if (strcmp (key, "ganesha.enable") == 0) {
- ret = dict_get_str (dict, "volname", &volname);
- if (ret) {
- gf_msg (THIS->name, GF_LOG_ERROR, errno,
- GD_MSG_DICT_GET_FAILED,
- "Unable to get volume name");
- goto out;
- }
- ret = ganesha_manage_export (volname, value, op_errstr,
- _gf_false);
+ ret = ganesha_manage_export (dict, value, op_errstr);
if (ret < 0)
goto out;
}