summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-ganesha.c
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2016-07-13 11:38:10 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2016-08-26 04:47:51 -0700
commit4786150ebe36154ec0762a951612f66f68a7e95c (patch)
tree5c9811ef5ad2cf762b433aac87229672c6fc2a0b /xlators/mgmt/glusterd/src/glusterd-ganesha.c
parent2f44a979132a43c1cf12ed2b9e9e94dbe1311c9e (diff)
glusterd/ganesha : create export configuration file in shared storage
This is the second patch which moves export related configuration for a volume into shared storage. The main change includes in scripts create-export-ganesha.sh, dbus-send.sh and the handling of volume set command "ganesha.enable". The manipulation of EXPORT_ID move from dbus-send.sh to create-export-ganesha.sh. In volume set handling following has performed stage | commit ---------------------------------------------------------- 1.) gluster v set <volname> ganesha.enable on None | create export file | in node where cli executed, | thne export volume via dbus 2.) gluster v set <volname> ganesha.enable off unexport volume via dbus | remove export file from the | shared storage ----------------------------------------------------------- More details can be found at http://review.gluster.org/#/c/15105/ Change-Id: Ia8b0e89bc8fff24b0bc5d20a538a89212894a8e4 BUG: 1355956 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14908 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: soumya k <skoduri@redhat.com> Smoke: Gluster 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.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index 728bfc627b0..3af2c79cafc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -180,17 +180,22 @@ glusterd_check_ganesha_export (glusterd_volinfo_t *volinfo) {
return is_exported;
}
-
+/* *
+ * The below function is called as part of commit phase for volume set option
+ * "ganesha.enable". If the value is "on", it creates export configuration file
+ * and then export the volume via dbus command. Incase of "off", the volume
+ * will be already unexported during stage phase, so it will remove the conf
+ * file from shared storage
+ */
int
glusterd_check_ganesha_cmd (char *key, char *value, char **errstr, dict_t *dict)
{
int ret = 0;
- xlator_t *this = NULL;
+ char *volname = NULL;
- this = THIS;
- GF_ASSERT (this);
GF_ASSERT (key);
GF_ASSERT (value);
+ GF_ASSERT (dict);
if ((strcmp (key, "ganesha.enable") == 0)) {
if ((strcmp (value, "on")) && (strcmp (value, "off"))) {
@@ -199,15 +204,28 @@ glusterd_check_ganesha_cmd (char *key, char *value, char **errstr, dict_t *dict)
ret = -1;
goto out;
}
- ret = glusterd_handle_ganesha_op (dict, errstr, key, value);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- GD_MSG_NFS_GNS_OP_HANDLE_FAIL,
- "Handling NFS-Ganesha"
- " op failed.");
- }
+ if (strcmp (value, "on") == 0) {
+ ret = glusterd_handle_ganesha_op (dict, errstr, key,
+ value);
+
+ } else if (is_origin_glusterd (dict)) {
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_msg ("glusterd-ganesha", GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to get volume name");
+ goto out;
+ }
+ ret = create_export_config (volname, "off", errstr);
+ }
}
out:
+ if (ret) {
+ gf_msg ("glusterd-ganesha", GF_LOG_ERROR, 0,
+ GD_MSG_NFS_GNS_OP_HANDLE_FAIL,
+ "Handling NFS-Ganesha"
+ " op failed.");
+ }
return ret;
}
@@ -415,7 +433,7 @@ check_host_list (void)
}
int
-create_export_config (char *volname, char **op_errstr)
+create_export_config (char *volname, char *value, char **op_errstr)
{
runner_t runner = {0,};
int ret = -1;
@@ -424,7 +442,7 @@ create_export_config (char *volname, char **op_errstr)
runinit (&runner);
runner_add_args (&runner, "sh",
GANESHA_PREFIX"/create-export-ganesha.sh",
- CONFDIR, volname, NULL);
+ CONFDIR, value, volname, NULL);
ret = runner_run(&runner);
if (ret)
@@ -513,9 +531,12 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
goto out;
}
- /* Create the export file only when ganesha.enable "on" is executed */
+ /* *
+ * Create the export file from the node where ganesha.enable "on"
+ * is executed
+ * */
if (option) {
- ret = create_export_config (volname, op_errstr);
+ ret = create_export_config (volname, "on", op_errstr);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_EXPORT_FILE_CREATE_FAIL,
@@ -811,11 +832,7 @@ glusterd_handle_ganesha_op (dict_t *dict, char **op_errstr,
{
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);