From 368dfd695928e8fc40988b8f2de86c3b469172d2 Mon Sep 17 00:00:00 2001 From: Meghana Madhusudhan Date: Wed, 18 Mar 2015 11:33:50 +0530 Subject: NFS-Ganesha: Volume set option for managing NFS-Ganesha exports. A dummy translator has been introduced as a place holder for functions related to managing NFS-Ganesha exports. A volume set option is introduced to manage volume level exports. gluster vol set ganesha.enable ON/OFF 1. gluster volume set ganesha.enable ON It creates the export config file with a unique export ID. Sends a DBus signal to export this volume dynamically. 2. gluster vol set ganesha.enable OFF Unexports the specific volume. Deletes the specfic config file related to the volume. This change also removes the handling of the older keys "nfs-ganesha.enable" and "nfs-ganesha.host" Change-Id: I8d4a0b542326a6a0c8e4711600b106274d666587 BUG: 1188184 Signed-off-by: Meghana Madhusudhan Reviewed-on: http://review.gluster.org/9585 Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- xlators/features/Makefile.am | 2 +- xlators/features/ganesha/Makefile.am | 3 + xlators/features/ganesha/src/Makefile.am | 18 +++++ xlators/features/ganesha/src/ganesha-mem-types.h | 21 ++++++ xlators/features/ganesha/src/ganesha.c | 85 ++++++++++++++++++++++++ xlators/features/ganesha/src/ganesha.h | 23 +++++++ 6 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 xlators/features/ganesha/Makefile.am create mode 100644 xlators/features/ganesha/src/Makefile.am create mode 100644 xlators/features/ganesha/src/ganesha-mem-types.h create mode 100644 xlators/features/ganesha/src/ganesha.c create mode 100644 xlators/features/ganesha/src/ganesha.h (limited to 'xlators/features') diff --git a/xlators/features/Makefile.am b/xlators/features/Makefile.am index 096f0e04bb2..4a332555ffc 100644 --- a/xlators/features/Makefile.am +++ b/xlators/features/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = locks quota read-only mac-compat quiesce marker index barrier \ - protect compress changelog gfid-access $(GLUPY_SUBDIR) qemu-block \ + protect compress changelog ganesha gfid-access $(GLUPY_SUBDIR) qemu-block \ upcall snapview-client snapview-server trash # path-converter # filter CLEANFILES = diff --git a/xlators/features/ganesha/Makefile.am b/xlators/features/ganesha/Makefile.am new file mode 100644 index 00000000000..a985f42a877 --- /dev/null +++ b/xlators/features/ganesha/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = src + +CLEANFILES = diff --git a/xlators/features/ganesha/src/Makefile.am b/xlators/features/ganesha/src/Makefile.am new file mode 100644 index 00000000000..d42b68f8440 --- /dev/null +++ b/xlators/features/ganesha/src/Makefile.am @@ -0,0 +1,18 @@ +xlator_LTLIBRARIES = ganesha.la + +xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features + +noinst_HEADERS = ganesha.h ganesha-mem-types.h + +ganesha_la_LDFLAGS = -module -avoid-version + +ganesha_la_SOURCES = ganesha.c + +AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\ + -DGANESHA_DIR=\"$(sysconfdir)/ganesha\" \ + -DGYSNCD_PREFIX=\"$(libexecdir)/glusterfs\" + +AM_CFLAGS = -Wall $(GF_CFLAGS) + +CLEANFILES = diff --git a/xlators/features/ganesha/src/ganesha-mem-types.h b/xlators/features/ganesha/src/ganesha-mem-types.h new file mode 100644 index 00000000000..c4976c01afc --- /dev/null +++ b/xlators/features/ganesha/src/ganesha-mem-types.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ +#ifndef __GANESHA_MEM_TYPES_H__ +#define __GANESHA_MEM_TYPES_H__ + + +#include "mem-types.h" + +enum gf_ganesha_mem_types_ { + gf_ganesha_mt_priv_t = gf_common_mt_end + 1, + gf_ganesha_mt_end +}; + +#endif diff --git a/xlators/features/ganesha/src/ganesha.c b/xlators/features/ganesha/src/ganesha.c new file mode 100644 index 00000000000..f034fc00d46 --- /dev/null +++ b/xlators/features/ganesha/src/ganesha.c @@ -0,0 +1,85 @@ +/* + Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "ganesha.h" +#include "ganesha-mem-types.h" + + + +int32_t +init (xlator_t *this) +{ + int ret = -1; + ganesha_priv_t *priv = NULL; + + if (!this->children || this->children->next) { + gf_log (this->name, GF_LOG_ERROR, + "Need subvolume == 1"); + goto err; + } + + if (!this->parents) { + gf_log (this->name, GF_LOG_WARNING, + "Dangling volume. Check volfile"); + goto err; + } + + priv = GF_CALLOC (1, sizeof (*priv), gf_ganesha_mt_priv_t); + if (!priv) + goto err; + + this->private = priv; + ret = 0; + +err: + return ret; +} + + +void +fini (xlator_t *this) +{ + ganesha_priv_t *priv = this->private; + + this->private = NULL; + if (priv) + GF_FREE (priv); + + return; +} + +struct xlator_fops fops = { +}; + +struct xlator_cbks cbks = { +}; + +struct volume_options options[] = { + { + .key = {"features.ganesha"}, + .default_value = "disable", + .type = GF_OPTION_TYPE_BOOL, + .description = "enable translator" + + }, + { .key = {"ganesha.enable"}, + .default_value = "off", + .type = GF_OPTION_TYPE_BOOL, + .description = "export volume via NFS-Ganesha" + }, + { .key = {NULL} + }, +}; diff --git a/xlators/features/ganesha/src/ganesha.h b/xlators/features/ganesha/src/ganesha.h new file mode 100644 index 00000000000..f30723da46d --- /dev/null +++ b/xlators/features/ganesha/src/ganesha.h @@ -0,0 +1,23 @@ +/* + Copyright (c) 2015 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "xlator.h" +#include "ganesha-mem-types.h" + +typedef struct { + char *host_name; +} ganesha_priv_t; + + -- cgit