Skip to content

Commit

Permalink
build: conditionally build legacy gNFS server and associated sub-pack…
Browse files Browse the repository at this point in the history
…aging

Plus some additional logic in glusterd to ensure gnfs (glusterfs)
daemons are never started if server/nfs xlator is not installed.

As a service, nfs is still initialized. The glusterfs-gnfs RPM
may be installed or uninstalled independent of anything else,
including on a system where gluster is actively running, so the
existence of the xlator is always tested before trying to start
gnfs.

Change-Id: I56743ad1cb36a84917226d7d26cb9d015d441e66
BUG: 1326219
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: https://review.gluster.org/16958
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>
  • Loading branch information
kalebskeithley committed Apr 28, 2017
1 parent ab88f65 commit 83abcba
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 65 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,17 @@ if test "x$enable_glupy" = "xyes"; then
fi
dnl end glupy section

dnl gnfs section
BUILD_GNFS="no"
AC_ARG_ENABLE([gnfs],
AC_HELP_STRING([--enable-gnfs],
[Enable legacy gnfs server xlator.]))
if test "x$enable_gnfs" = "xyes"; then
BUILD_GNFS="yes"
fi
AM_CONDITIONAL([BUILD_GNFS], [test x$BUILD_GNFS = xyes])
dnl end gnfs section

dnl Check for userspace-rcu
PKG_CHECK_MODULES([URCU], [liburcu-bp], [],
[AC_CHECK_HEADERS([urcu-bp.h],
Expand Down Expand Up @@ -1581,4 +1592,5 @@ echo "Events : $BUILD_EVENTS"
echo "EC dynamic support : $EC_DYNAMIC_SUPPORT"
echo "Use memory pools : $USE_MEMPOOL"
echo "Nanosecond m/atimes : $BUILD_NANOSECOND_TIMESTAMPS"
echo "Legacy gNFS server : $BUILD_GNFS"
echo
4 changes: 2 additions & 2 deletions extras/LinuxRPM/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ autogen:
cd ../.. && \
rm -rf autom4te.cache && \
./autogen.sh && \
./configure --with-previous-options
./configure --enable-gnfs --with-previous-options

prep:
$(MAKE) -C ../.. dist;
Expand All @@ -36,7 +36,7 @@ srcrpm:
mv rpmbuild/SRPMS/* .

rpms:
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bb rpmbuild/SPECS/glusterfs.spec
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' --with gnfs -bb rpmbuild/SPECS/glusterfs.spec
mv rpmbuild/RPMS/*/* .

# EPEL-5 does not like new versions of rpmbuild and requires some
Expand Down
59 changes: 48 additions & 11 deletions glusterfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
%global _without_georeplication --disable-georeplication
%endif

# if you wish to compile an rpm with the legacy gNFS server xlator
# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --with gnfs
%{?_with_gnfs:%global _with_gnfs --enable-gnfs}

# if you wish to compile an rpm without the OCF resource agents...
# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --without ocf
%{?_without_ocf:%global _without_ocf --without-ocf}
Expand Down Expand Up @@ -100,7 +104,7 @@
%endif

# From https://fedoraproject.org/wiki/Packaging:Python#Macros
%if ( 0%{?rhel} && 0%{?rhel} <= 5 )
%if ( 0%{?rhel} && 0%{?rhel} <= 6 )
%{!?python2_sitelib: %global python2_sitelib %(python2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(python2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif
Expand Down Expand Up @@ -401,6 +405,26 @@ is in userspace and easily manageable.
This package provides support to geo-replication.
%endif

%if ( 0%{?_with_gnfs:1} )
%package gnfs
Summary: GlusterFS gNFS server
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-client-xlators%{?_isa} = %{version}-%{release}
Requires: nfs-utils

%description gnfs
GlusterFS is a distributed file-system capable of scaling to several
petabytes. It aggregates various storage bricks over Infiniband RDMA
or TCP/IP interconnect into one large parallel network file
system. GlusterFS is one of the most sophisticated file systems in
terms of features and extensibility. It borrows a powerful concept
called Translators from GNU Hurd kernel. Much of the code in GlusterFS
is in user space and easily manageable.

This package provides the glusterfs legacy gNFS server xlator
%endif

%package libs
Summary: GlusterFS common libraries
Group: Applications/File
Expand Down Expand Up @@ -530,7 +554,6 @@ Requires: %{name}-api%{?_isa} = %{version}-%{release}
Requires: %{name}-client-xlators%{?_isa} = %{version}-%{release}
# lvm2 for snapshot, and nfs-utils and rpcbind/portmap for gnfs server
Requires: lvm2
Requires: nfs-utils
%if ( 0%{?_with_systemd:1} )
%{?systemd_requires}
%else
Expand Down Expand Up @@ -630,18 +653,19 @@ export CFLAGS
%configure \
%{?_with_cmocka} \
%{?_with_debug} \
%{?_with_valgrind} \
%{?_with_firewalld} \
%{?_with_gnfs} \
%{?_with_tmpfilesdir} \
%{?_with_valgrind} \
%{?_without_bd} \
%{?_without_epoll} \
%{?_without_events} \
%{?_without_fusermount} \
%{?_without_georeplication} \
%{?_with_firewalld} \
%{?_without_ocf} \
%{?_without_rdma} \
%{?_without_syslog} \
%{?_without_tiering} \
%{?_without_events}
%{?_without_tiering}

# fix hardening and remove rpath in shlibs
%if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
Expand Down Expand Up @@ -1059,6 +1083,16 @@ exit 0
%endif
%endif

%if ( 0%{?_with_gnfs:1} )
%files gnfs
%dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs/*
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs
%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/nfs-server.vol
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs/run
%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/run/nfs.pid
%endif

%if ( 0%{!?_without_georeplication:1} )
%files geo-replication
%config(noreplace) %{_sysconfdir}/logrotate.d/glusterfs-georep
Expand Down Expand Up @@ -1126,6 +1160,11 @@ exit 0
# sysconf
%config(noreplace) %{_sysconfdir}/glusterfs
%exclude %{_sysconfdir}/glusterfs/eventsconfig.json
%exclude %{_sharedstatedir}/glusterd/nfs/nfs-server.vol
%exclude %{_sharedstatedir}/glusterd/nfs/run/nfs.pid
%if ( 0%{?_with_gnfs:1} )
%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs/*
%endif
%config(noreplace) %{_sysconfdir}/sysconfig/glusterd
%if ( 0%{_for_fedora_koji_builds} )
%config(noreplace) %{_sysconfdir}/sysconfig/glusterfsd
Expand Down Expand Up @@ -1166,7 +1205,6 @@ exit 0
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/upcall.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/leases.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mgmt*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/performance/decompounder.so
Expand Down Expand Up @@ -1227,10 +1265,6 @@ exit 0
%dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/pre
%attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S30samba-stop.sh
%attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs
%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/nfs-server.vol
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/nfs/run
%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/nfs/run/nfs.pid
%ghost %attr(0600,-,-) %{_sharedstatedir}/glusterd/options
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/peers
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/quotad
Expand Down Expand Up @@ -1272,6 +1306,9 @@ exit 0
%endif

%changelog
* Thu Apr 27 2017 Kaleb S. KEITHLEY <kkeithle@redhat.com>
- gnfs in an optional subpackage

* Wed Apr 26 2017 Kaleb S. KEITHLEY <kkeithle@redhat.com>
- /var/run/gluster owner gluster:gluster(0775) for qemu(gfapi)
statedumps (#1445569)
Expand Down
11 changes: 9 additions & 2 deletions xlators/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ if ENABLE_EXPERIMENTAL
EXPERIMENTAL = experimental
endif

SUBDIRS = cluster storage protocol performance debug features encryption mount nfs mgmt system \
playground meta $(EXPERIMENTAL)
if BUILD_GNFS
GNFS_DIR = nfs
endif

DIST_SUBDIRS = cluster storage protocol performance debug features encryption \
mount nfs mgmt system playground meta experimental

SUBDIRS = cluster storage protocol performance debug features encryption \
mount ${GNFS_DIR} mgmt system playground meta $(EXPERIMENTAL)

EXTRA_DIST = xlator.sym

Expand Down
4 changes: 3 additions & 1 deletion xlators/mgmt/glusterd/src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
xlator_LTLIBRARIES = glusterd.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mgmt
glusterd_la_CPPFLAGS = $(AM_CPPFLAGS) "-DFILTERDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/filter\""
glusterd_la_CPPFLAGS = $(AM_CPPFLAGS) \
-DFILTERDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/filter\" \
-DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\"
glusterd_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \
glusterd-op-sm.c glusterd-utils.c glusterd-rpc-ops.c \
Expand Down
11 changes: 10 additions & 1 deletion xlators/mgmt/glusterd/src/glusterd-messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD

#define GLFS_NUM_MESSAGES 599
#define GLFS_NUM_MESSAGES 600

#define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
Expand Down Expand Up @@ -4842,8 +4842,17 @@
* @recommendedaction
*
*/

#define GD_MSG_CLIENTS_GET_STATE_FAILED (GLUSTERD_COMP_BASE + 599)

/*!
* @messageid
* @diagnosis
* @recommendedaction
*
*/
#define GD_MSG_GNFS_XLATOR_NOT_INSTALLED (GLUSTERD_COMP_BASE + 600)

/*------------*/

#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
Expand Down
28 changes: 15 additions & 13 deletions xlators/mgmt/glusterd/src/glusterd-nfs-svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

#include "globals.h"
#include "run.h"
#include "syscall.h"
#include "glusterd.h"
#include "glusterd-utils.h"
#include "glusterd-volgen.h"
#include "glusterd-nfs-svc.h"
#include "glusterd-messages.h"
#include "glusterd-svc-helper.h"

static char *nfs_svc_name = "nfs";

static gf_boolean_t
glusterd_nfssvc_need_start ()
{
Expand All @@ -41,19 +40,13 @@ glusterd_nfssvc_need_start ()
return start;
}

int
glusterd_nfssvc_init (glusterd_svc_t *svc)
{
return glusterd_svc_init (svc, nfs_svc_name);
}

static int
glusterd_nfssvc_create_volfile ()
{
char filepath[PATH_MAX] = {0,};
glusterd_conf_t *conf = THIS->private;

glusterd_svc_build_volfile_path (nfs_svc_name, conf->workdir,
glusterd_svc_build_volfile_path (conf->nfs_svc.name, conf->workdir,
filepath, sizeof (filepath));
return glusterd_create_global_volfile (build_nfs_graph,
filepath, NULL);
Expand All @@ -65,22 +58,31 @@ glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags)
int ret = -1;

if (!svc->inited) {
ret = glusterd_nfssvc_init (svc);
ret = glusterd_svc_init (svc, "nfs");
if (ret) {
gf_msg (THIS->name, GF_LOG_ERROR, 0,
GD_MSG_FAILED_INIT_NFSSVC, "Failed to init nfs "
"service");
GD_MSG_FAILED_INIT_NFSSVC,
"Failed to init nfs service");
goto out;
} else {
svc->inited = _gf_true;
gf_msg_debug (THIS->name, 0, "nfs service initialized");
gf_msg_debug (THIS->name, 0,
"nfs service initialized");
}
}

ret = svc->stop (svc, SIGKILL);
if (ret)
goto out;

/* not an error, or a (very) soft error at best */
if (sys_access (XLATORDIR "/nfs/server.so", R_OK) != 0) {
gf_msg (THIS->name, GF_LOG_INFO, 0,
GD_MSG_GNFS_XLATOR_NOT_INSTALLED,
"nfs/server.so xlator is not installed");
goto out;
}

ret = glusterd_nfssvc_create_volfile ();
if (ret)
goto out;
Expand Down
1 change: 0 additions & 1 deletion xlators/mgmt/glusterd/src/glusterd-svc-mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct glusterd_svc_ {
char name[PATH_MAX];
glusterd_conn_t conn;
glusterd_proc_t proc;
glusterd_svc_build_t build;
glusterd_svc_manager_t manager;
glusterd_svc_start_t start;
glusterd_svc_stop_t stop;
Expand Down
7 changes: 2 additions & 5 deletions xlators/mgmt/glusterd/src/glusterd-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,8 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)

new_volinfo->xl = THIS;

new_volinfo->snapd.svc.build = glusterd_snapdsvc_build;
new_volinfo->snapd.svc.build (&(new_volinfo->snapd.svc));

new_volinfo->tierd.svc.build = glusterd_tierdsvc_build;
new_volinfo->tierd.svc.build (&(new_volinfo->tierd.svc));
glusterd_snapdsvc_build (&new_volinfo->snapd.svc);
glusterd_tierdsvc_build (&new_volinfo->tierd.svc);

pthread_mutex_init (&new_volinfo->reflock, NULL);
*volinfo = glusterd_volinfo_ref (new_volinfo);
Expand Down
35 changes: 6 additions & 29 deletions xlators/mgmt/glusterd/src/glusterd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,34 +1331,6 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,
return ret;
}

static void
glusterd_svcs_build ()
{
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;

this = THIS;
GF_ASSERT (this);

priv = this->private;
GF_ASSERT (priv);

priv->shd_svc.build = glusterd_shdsvc_build;
priv->shd_svc.build (&(priv->shd_svc));

priv->nfs_svc.build = glusterd_nfssvc_build;
priv->nfs_svc.build (&(priv->nfs_svc));

priv->quotad_svc.build = glusterd_quotadsvc_build;
priv->quotad_svc.build (&(priv->quotad_svc));

priv->bitd_svc.build = glusterd_bitdsvc_build;
priv->bitd_svc.build (&(priv->bitd_svc));

priv->scrub_svc.build = glusterd_scrubsvc_build;
priv->scrub_svc.build (&(priv->scrub_svc));
}

static int
is_upgrade (dict_t *options, gf_boolean_t *upgrade)
{
Expand Down Expand Up @@ -1806,7 +1778,12 @@ init (xlator_t *this)
this->private = conf;
glusterd_mgmt_v3_lock_init ();
glusterd_txn_opinfo_dict_init ();
glusterd_svcs_build ();

glusterd_shdsvc_build (&conf->shd_svc);
glusterd_nfssvc_build (&conf->nfs_svc);
glusterd_quotadsvc_build (&conf->quotad_svc);
glusterd_bitdsvc_build (&conf->bitd_svc);
glusterd_scrubsvc_build (&conf->scrub_svc);

/* Make install copies few of the hook-scripts by creating hooks
* directory. Hence purposefully not doing the check for the presence of
Expand Down

0 comments on commit 83abcba

Please sign in to comment.