From patchwork Thu Feb 18 22:54:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20A32C4332E for ; Thu, 18 Feb 2021 22:55:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6F22601FD for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbhBRWy4 (ORCPT ); Thu, 18 Feb 2021 17:54:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57665 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbhBRWy4 (ORCPT ); Thu, 18 Feb 2021 17:54:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ktjIfm0wbpWrOkylT3NrSSvWBYPpllwBUbdQgtij/Jw=; b=NbXSdcm8+YDxFLigXtXP3TlUe4dwT5Ra7JVDvVukqPCjIqbAeIwueo5p9maL/eNNpAZkg5 fjY5n/HDdubWi/BycYX24fkg0Rh87SvWCbQadxKzpyKV0LEbgNpNI2ZI+QAf5Agb5T26J4 LiSM2hZsnnmSgongI9NzM1enfPomwKU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-kB6Nb144Ogy7ahyMcSiDIg-1; Thu, 18 Feb 2021 17:53:14 -0500 X-MC-Unique: kB6Nb144Ogy7ahyMcSiDIg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D39931005501 for ; Thu, 18 Feb 2021 22:53:13 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FD6B60BE5 for ; Thu, 18 Feb 2021 22:53:13 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 1/6] exportd: the initial shell of the v4 export support Date: Thu, 18 Feb 2021 17:54:45 -0500 Message-Id: <20210218225450.674466-2-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Steve Dickson --- .gitignore | 1 + configure.ac | 1 + utils/Makefile.am | 1 + utils/exportd/Makefile.am | 58 ++++++++++++++++++ utils/exportd/exportd.c | 121 ++++++++++++++++++++++++++++++++++++++ utils/exportd/exportd.man | 74 +++++++++++++++++++++++ 6 files changed, 256 insertions(+) create mode 100644 utils/exportd/Makefile.am create mode 100644 utils/exportd/exportd.c create mode 100644 utils/exportd/exportd.man diff --git a/.gitignore b/.gitignore index e97b31f..c89d1cd 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ utils/idmapd/idmapd utils/lockd/lockd utils/mount/mount.nfs utils/mountd/mountd +utils/exportd/exportd utils/nfsd/nfsd utils/nfsstat/nfsstat utils/nhfsstone/nhfsstone diff --git a/configure.ac b/configure.ac index 50847d8..ffd6247 100644 --- a/configure.ac +++ b/configure.ac @@ -706,6 +706,7 @@ AC_CONFIG_FILES([ utils/idmapd/Makefile utils/mount/Makefile utils/mountd/Makefile + utils/exportd/Makefile utils/nfsd/Makefile utils/nfsref/Makefile utils/nfsstat/Makefile diff --git a/utils/Makefile.am b/utils/Makefile.am index 4c930a4..2a54b90 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -5,6 +5,7 @@ OPTDIRS = if CONFIG_NFSV4 OPTDIRS += idmapd OPTDIRS += nfsidmap +OPTDIRS += exportd endif if CONFIG_NFSV41 diff --git a/utils/exportd/Makefile.am b/utils/exportd/Makefile.am new file mode 100644 index 0000000..6e61267 --- /dev/null +++ b/utils/exportd/Makefile.am @@ -0,0 +1,58 @@ +## Process this file with automake to produce Makefile.in + +OPTLIBS = + +man8_MANS = exportd.man +EXTRA_DIST = $(man8_MANS) + +NFSPREFIX = nfsv4. +KPREFIX = @kprefix@ +sbin_PROGRAMS = exportd + +exportd_SOURCES = exportd.c +exportd_LDADD = ../../support/nfs/libnfs.la + +exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) + +MAINTAINERCLEANFILES = Makefile.in + +####################################################################### +# The following allows the current practice of having +# daemons renamed during the install to include NFSPREFIX +# and the KPREFIX +# This could all be done much easier with program_transform_name +# ( program_transform_name = s/^/$(NFSPREFIX)$(KPREFIX)/ ) +# but that also renames the man pages, which the current +# practice does not do. +install-exec-hook: + (cd $(DESTDIR)$(sbindir) && \ + for p in $(sbin_PROGRAMS); do \ + mv -f $$p$(EXEEXT) $(NFSPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ + done) +uninstall-hook: + (cd $(DESTDIR)$(sbindir) && \ + for p in $(sbin_PROGRAMS); do \ + rm -f $(NFSPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ + done) + + +# XXX This makes some assumptions about what automake does. +# XXX But there is no install-man-hook or install-man-local. +install-man: install-man8 install-man-links +uninstall-man: uninstall-man8 uninstall-man-links + +install-man-links: + (cd $(DESTDIR)$(man8dir) && \ + for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ + inst=`echo $$m | sed -e 's/man$$/8/'`; \ + rm -f $(NFSPREFIX)$$inst ; \ + $(LN_S) $$inst $(NFSPREFIX)$$inst ; \ + done) + +uninstall-man-links: + (cd $(DESTDIR)$(man8dir) && \ + for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ + inst=`echo $$m | sed -e 's/man$$/8/'`; \ + rm -f $(NFSPREFIX)$$inst ; \ + done) + diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c new file mode 100644 index 0000000..3a3dea6 --- /dev/null +++ b/utils/exportd/exportd.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2021 Red Hat + * + * support/exportd/exportd.c + * + * Routines used to support NFSv4 exports + * + */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "nfslib.h" +#include "conffile.h" + + +static struct option longopts[] = +{ + { "foreground", 0, 0, 'F' }, + { "debug", 1, 0, 'd' }, + { "help", 0, 0, 'h' }, + { NULL, 0, 0, 0 } +}; + +/* + * Signal handlers. + */ +inline static void set_signals(void); + +static void +killer (int sig) +{ + xlog (L_NOTICE, "Caught signal %d, un-registering and exiting.", sig); + exit(0); +} +static void +sig_hup (int UNUSED(sig)) +{ + /* don't exit on SIGHUP */ + xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n"); + return; +} +inline static void +set_signals(void) +{ + struct sigaction sa; + + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGPIPE, &sa, NULL); + /* WARNING: the following works on Linux and SysV, but not BSD! */ + sigaction(SIGCHLD, &sa, NULL); + + sa.sa_handler = killer; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + sa.sa_handler = sig_hup; + sigaction(SIGHUP, &sa, NULL); +} +static void +usage(const char *prog, int n) +{ + fprintf(stderr, + "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n", prog); + exit(n); +} + +int +main(int argc, char **argv) +{ + char *progname; + int foreground = 0; + int c; + + /* Set the basename */ + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; + else + progname = argv[0]; + + /* Initialize logging. */ + xlog_open(progname); + + conf_init_file(NFS_CONFFILE); + xlog_set_debug(progname); + + while ((c = getopt_long(argc, argv, "d:fh", longopts, NULL)) != EOF) { + switch (c) { + case 'd': + xlog_sconfig(optarg, 1); + break; + case 'f': + foreground++; + break; + case 'h': + usage(progname, 0); + break; + case '?': + default: + usage(progname, 1); + } + + } + + if (!foreground) + xlog_stderr(0); + + daemon_init(foreground); + + set_signals(); + + daemon_ready(); +} diff --git a/utils/exportd/exportd.man b/utils/exportd/exportd.man new file mode 100644 index 0000000..d786e57 --- /dev/null +++ b/utils/exportd/exportd.man @@ -0,0 +1,74 @@ +.\"@(#)nfsv4.exportd.8" +.\" +.\" Copyright (C) 2021 Red Hat +.\" +.TH nfsv4.exportd 8 "02 Feb 2021" +.SH NAME +nfsv4.exportd \- NFSv4 Server Mount Daemon +.SH SYNOPSIS +.BI "/usr/sbin/nfsv4.exportd [" options "]" +.SH DESCRIPTION +The +.B nfsv4.exportd +is used to manage NFSv4 exports. The NFSv4 server +receives a mount request from a client and pass it up to +.B nfsv4.exportd. +.B nfsv4.exportd +then uses the exports(5) export +table to verify the validity of the mount request. +.PP +An NFS server maintains a table of local physical file systems +that are accessible to NFS clients. +Each file system in this table is referred to as an +.IR "exported file system" , +or +.IR export , +for short. +.PP +Each file system in the export table has an access control list. +.B nfsv4.exportd +uses these access control lists to determine +whether an NFS client is permitted to access a given file system. +For details on how to manage your NFS server's export table, see the +.BR exports (5) +and +.BR exportfs (8) +man pages. +.SH OPTIONS +.TP +.B \-d kind " or " \-\-debug kind +Turn on debugging. Valid kinds are: all, auth, call, general and parse. +.TP +.B \-F " or " \-\-foreground +Run in foreground (do not daemonize) +.TP +.B \-h " or " \-\-help +Display usage message. +.SH CONFIGURATION FILE +Many of the options that can be set on the command line can also be +controlled through values set in the +.B [exportd] +or, in some cases, the +.B [nfsd] +sections of the +.I /etc/nfs.conf +configuration file. +Values recognized in the +.B [exportd] +section include +.B debug +which each have the same effect as the option with the same name. +.SH FILES +.TP 2.5i +.I /etc/exports +input file for +.BR exportfs , +listing exports, export options, and access control lists +.SH SEE ALSO +.BR exportfs (8), +.BR exports (5), +.BR showmount (8), +.BR nfs.conf (5), +.BR firwall-cmd (1), +.sp +RFC 3530 - "Network File System (NFS) version 4 Protocol" From patchwork Thu Feb 18 22:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB2EAC43381 for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75934601FD for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbhBRWyq (ORCPT ); Thu, 18 Feb 2021 17:54:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59421 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbhBRWyp (ORCPT ); Thu, 18 Feb 2021 17:54:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLwgB55zz6wz0rZn1ajTGbZqejrcEaFo9EnSSyYIBok=; b=jJTTTRRfRyzsLd3cAUbapSLOKR6zqrKGmlX8n76V3988Lkrsn+TEMxLaZmkyhmCKktbeyP CoMEb0goIcsjbD6Ib6wVKxvB0mJn1CxUmLlBlJtjzxO+cCPHHy7wBdX2Dd2q6f/m7rpOyP QJpphKLApTkqE5Vt+DPj6pJldDYscL0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-RYStrU0KOCeVjZxyTH6uCg-1; Thu, 18 Feb 2021 17:53:15 -0500 X-MC-Unique: RYStrU0KOCeVjZxyTH6uCg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 443BD6EE22 for ; Thu, 18 Feb 2021 22:53:14 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03DDC60BE5 for ; Thu, 18 Feb 2021 22:53:13 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 2/6] exportd: Moved cache upcalls routines into libexport.a Date: Thu, 18 Feb 2021 17:54:46 -0500 Message-Id: <20210218225450.674466-3-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Move the cache management code into libexport.a so both mountd and exportd can use it. Introduce cache_proccess_loop() which will be used by exportd, instead of my_svc_run(). Signed-off-by: Steve Dickson --- support/export/Makefile.am | 3 +- {utils/mountd => support/export}/auth.c | 4 +- {utils/mountd => support/export}/cache.c | 46 +++++++++++++++++++++-- support/export/export.h | 34 +++++++++++++++++ {utils/mountd => support/export}/v4root.c | 0 utils/exportd/Makefile.am | 8 +++- utils/exportd/exportd.c | 30 ++++++++++++++- utils/mountd/Makefile.am | 4 +- 8 files changed, 118 insertions(+), 11 deletions(-) rename {utils/mountd => support/export}/auth.c (99%) rename {utils/mountd => support/export}/cache.c (98%) create mode 100644 support/export/export.h rename {utils/mountd => support/export}/v4root.c (100%) diff --git a/support/export/Makefile.am b/support/export/Makefile.am index 13f7a49..7de82a8 100644 --- a/support/export/Makefile.am +++ b/support/export/Makefile.am @@ -11,7 +11,8 @@ EXTRA_DIST = mount.x noinst_LIBRARIES = libexport.a libexport_a_SOURCES = client.c export.c hostname.c \ - xtab.c mount_clnt.c mount_xdr.c + xtab.c mount_clnt.c mount_xdr.c \ + cache.c auth.c v4root.c BUILT_SOURCES = $(GENFILES) noinst_HEADERS = mount.h diff --git a/utils/mountd/auth.c b/support/export/auth.c similarity index 99% rename from utils/mountd/auth.c rename to support/export/auth.c index 67627f7..0bfa77d 100644 --- a/utils/mountd/auth.c +++ b/support/export/auth.c @@ -22,7 +22,7 @@ #include "misc.h" #include "nfslib.h" #include "exportfs.h" -#include "mountd.h" +#include "export.h" #include "v4root.h" enum auth_error @@ -43,11 +43,13 @@ extern int use_ipaddr; extern struct state_paths etab; +/* void auth_init(void) { auth_reload(); } +*/ /* * A client can match many different netgroups and it's tough to know diff --git a/utils/mountd/cache.c b/support/export/cache.c similarity index 98% rename from utils/mountd/cache.c rename to support/export/cache.c index a81e820..f1569af 100644 --- a/utils/mountd/cache.c +++ b/support/export/cache.c @@ -30,11 +30,14 @@ #include "nfsd_path.h" #include "nfslib.h" #include "exportfs.h" -#include "mountd.h" -#include "fsloc.h" +#include "export.h" #include "pseudoflavors.h" #include "xcommon.h" +#ifdef HAVE_JUNCTION_SUPPORT +#include "fsloc.h" +#endif + #ifdef USE_BLKID #include "blkid/blkid.h" #endif @@ -44,6 +47,7 @@ */ void cache_set_fds(fd_set *fdset); int cache_process_req(fd_set *readfds); +void cache_process_loop(void); enum nfsd_fsid { FSID_DEV = 0, @@ -909,6 +913,7 @@ out: xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL); } +#ifdef HAVE_JUNCTION_SUPPORT static void write_fsloc(char **bp, int *blen, struct exportent *ep) { struct servers *servers; @@ -931,7 +936,7 @@ static void write_fsloc(char **bp, int *blen, struct exportent *ep) qword_addint(bp, blen, servers->h_referral); release_replicas(servers); } - +#endif static void write_secinfo(char **bp, int *blen, struct exportent *ep, int flag_mask) { struct sec_entry *p; @@ -974,7 +979,10 @@ static int dump_to_cache(int f, char *buf, int blen, char *domain, qword_addint(&bp, &blen, exp->e_anonuid); qword_addint(&bp, &blen, exp->e_anongid); qword_addint(&bp, &blen, exp->e_fsid); + +#ifdef HAVE_JUNCTION_SUPPORT write_fsloc(&bp, &blen, exp); +#endif write_secinfo(&bp, &blen, exp, flag_mask); if (exp->e_uuid == NULL || different_fs) { char u[16]; @@ -1509,6 +1517,38 @@ int cache_process_req(fd_set *readfds) return cnt; } +/** + * cache_process_loop - process incoming upcalls + */ +void cache_process_loop(void) +{ + fd_set readfds; + int selret; + + FD_ZERO(&readfds); + + for (;;) { + + cache_set_fds(&readfds); + + selret = select(FD_SETSIZE, &readfds, + (void *) 0, (void *) 0, (struct timeval *) 0); + + + switch (selret) { + case -1: + if (errno == EINTR || errno == ECONNREFUSED + || errno == ENETUNREACH || errno == EHOSTUNREACH) + continue; + xlog(L_ERROR, "my_svc_run() - select: %m"); + return; + + default: + cache_process_req(&readfds); + } + } +} + /* * Give IP->domain and domain+path->options to kernel diff --git a/support/export/export.h b/support/export/export.h new file mode 100644 index 0000000..4296db1 --- /dev/null +++ b/support/export/export.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 Red Hat + * + * support/export/export.h + * + * Declarations for export support + */ + +#ifndef EXPORT_H +#define EXPORT_H + +#include "nfslib.h" + +unsigned int auth_reload(void); +nfs_export * auth_authenticate(const char *what, + const struct sockaddr *caller, + const char *path); + +void cache_open(void); +void cache_process_loop(void); + +struct nfs_fh_len * + cache_get_filehandle(nfs_export *exp, int len, char *p); +int cache_export(nfs_export *exp, char *path); + +bool ipaddr_client_matches(nfs_export *exp, struct addrinfo *ai); +bool namelist_client_matches(nfs_export *exp, char *dom); +bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai); + +static inline bool is_ipaddr_client(char *dom) +{ + return dom[0] == '$'; +} +#endif /* EXPORT__H */ diff --git a/utils/mountd/v4root.c b/support/export/v4root.c similarity index 100% rename from utils/mountd/v4root.c rename to support/export/v4root.c diff --git a/utils/exportd/Makefile.am b/utils/exportd/Makefile.am index 6e61267..eb0f0a8 100644 --- a/utils/exportd/Makefile.am +++ b/utils/exportd/Makefile.am @@ -10,9 +10,13 @@ KPREFIX = @kprefix@ sbin_PROGRAMS = exportd exportd_SOURCES = exportd.c -exportd_LDADD = ../../support/nfs/libnfs.la +exportd_LDADD = ../../support/export/libexport.a \ + ../../support/nfs/libnfs.la \ + ../../support/misc/libmisc.a \ + $(OPTLIBS) $(LIBBLKID) $(LIBPTHREAD) -exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) +exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \ + -I$(top_srcdir)/support/export MAINTAINERCLEANFILES = Makefile.in diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c index 3a3dea6..2f67e3b 100644 --- a/utils/exportd/exportd.c +++ b/utils/exportd/exportd.c @@ -18,7 +18,16 @@ #include "nfslib.h" #include "conffile.h" +#include "exportfs.h" +#include "export.h" +extern void my_svc_run(void); + +struct state_paths etab; +struct state_paths rmtab; + +int manage_gids; +int use_ipaddr = -1; static struct option longopts[] = { @@ -36,7 +45,7 @@ inline static void set_signals(void); static void killer (int sig) { - xlog (L_NOTICE, "Caught signal %d, un-registering and exiting.", sig); + xlog (L_NOTICE, "Caught signal %d, exiting.", sig); exit(0); } static void @@ -110,12 +119,29 @@ main(int argc, char **argv) } + if (!setup_state_path_names(progname, ETAB, ETABTMP, ETABLCK, &etab)) + return 1; + if (!setup_state_path_names(progname, RMTAB, RMTABTMP, RMTABLCK, &rmtab)) + return 1; + if (!foreground) xlog_stderr(0); daemon_init(foreground); set_signals(); - daemon_ready(); + + /* Open files now to avoid sharing descriptors among forked processes */ + cache_open(); + + /* Process incoming upcalls */ + cache_process_loop(); + + xlog(L_ERROR, "%s: process loop terminated unexpectedly. Exiting...\n", + progname); + + free_state_path_names(&etab); + free_state_path_names(&rmtab); + exit(1); } diff --git a/utils/mountd/Makefile.am b/utils/mountd/Makefile.am index 18610f1..cac3275 100644 --- a/utils/mountd/Makefile.am +++ b/utils/mountd/Makefile.am @@ -13,8 +13,8 @@ KPREFIX = @kprefix@ sbin_PROGRAMS = mountd noinst_HEADERS = fsloc.h -mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \ - svc_run.c fsloc.c v4root.c mountd.h +mountd_SOURCES = mountd.c mount_dispatch.c rmtab.c \ + svc_run.c fsloc.c mountd.h mountd_LDADD = ../../support/export/libexport.a \ ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ From patchwork Thu Feb 18 22:54:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C61DC433E0 for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7FA4601FD for ; Thu, 18 Feb 2021 22:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbhBRWyo (ORCPT ); Thu, 18 Feb 2021 17:54:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40453 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbhBRWyo (ORCPT ); Thu, 18 Feb 2021 17:54:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fFODysaqX4A8EM2/2WwDkgJzlhOBo7iP0CWKIr428fU=; b=P1skSsgHWt6tTYHrREdHcsZhM0lOudN6uF05SEdRQI3ggLWS1umE9fysph9pjhopZsJvm0 QPfQ/N0gbydZtaI4kCUbqxci7xsEWSjGb/JvK7geHkbxE0u4s/nYuth8/+VqdsO9n17cHf eawz16XuTTnLMLxTGlHg2mw813hva0k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-h0HM48l0NnaAv7BpJIvroQ-1; Thu, 18 Feb 2021 17:53:15 -0500 X-MC-Unique: h0HM48l0NnaAv7BpJIvroQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A69CA835E21 for ; Thu, 18 Feb 2021 22:53:14 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67CC560BE5 for ; Thu, 18 Feb 2021 22:53:14 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 3/6] exportd: multiple threads Date: Thu, 18 Feb 2021 17:54:47 -0500 Message-Id: <20210218225450.674466-4-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Ported the multiple thread code from mountd (commit 11d34d11) Signed-off-by: Steve Dickson --- nfs.conf | 3 + systemd/nfs.conf.man | 9 +++ utils/exportd/exportd.c | 118 ++++++++++++++++++++++++++++++++++++-- utils/exportd/exportd.man | 7 +++ 4 files changed, 133 insertions(+), 4 deletions(-) diff --git a/nfs.conf b/nfs.conf index 9fcf1bf..4b344fa 100644 --- a/nfs.conf +++ b/nfs.conf @@ -29,6 +29,9 @@ # port=0 # udp-port=0 # +[exportd] +# debug="all|auth|call|general|parse" +# threads=1 [mountd] # debug="all|auth|call|general|parse" # manage-gids=n diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man index 16e0ec4..a4379fd 100644 --- a/systemd/nfs.conf.man +++ b/systemd/nfs.conf.man @@ -128,6 +128,15 @@ then the client will be able to mount the path as but on the server, this will resolve to the path .BR /my/root/filesystem . +.TP +.B exportd +Recognized values: +.B threads + +See +.BR exportd (8) +for details. + .TP .B nfsdcltrack Recognized values: diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c index 2f67e3b..c814503 100644 --- a/utils/exportd/exportd.c +++ b/utils/exportd/exportd.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "nfslib.h" #include "conffile.h" @@ -26,6 +28,13 @@ extern void my_svc_run(void); struct state_paths etab; struct state_paths rmtab; +/* Number of mountd threads to start. Default is 1 and + * that's probably enough unless you need hundreds of + * clients to be able to mount at once. */ +static int num_threads = 1; +/* Arbitrary limit on number of threads */ +#define MAX_THREADS 64 + int manage_gids; int use_ipaddr = -1; @@ -34,6 +43,7 @@ static struct option longopts[] = { "foreground", 0, 0, 'F' }, { "debug", 1, 0, 'd' }, { "help", 0, 0, 'h' }, + { "num-threads", 1, 0, 't' }, { NULL, 0, 0, 0 } }; @@ -42,10 +52,85 @@ static struct option longopts[] = */ inline static void set_signals(void); +/* Wait for all worker child processes to exit and reap them */ +static void +wait_for_workers (void) +{ + int status; + pid_t pid; + + for (;;) { + + pid = waitpid(0, &status, 0); + + if (pid < 0) { + if (errno == ECHILD) + return; /* no more children */ + xlog(L_FATAL, "mountd: can't wait: %s\n", + strerror(errno)); + } + + /* Note: because we SIG_IGN'd SIGCHLD earlier, this + * does not happen on 2.6 kernels, and waitpid() blocks + * until all the children are dead then returns with + * -ECHILD. But, we don't need to do anything on the + * death of individual workers, so we don't care. */ + xlog(L_NOTICE, "mountd: reaped child %d, status %d\n", + (int)pid, status); + } +} + +/* Fork num_threads worker children and wait for them */ +static void +fork_workers(void) +{ + int i; + pid_t pid; + + xlog(L_NOTICE, "mountd: starting %d threads\n", num_threads); + + for (i = 0 ; i < num_threads ; i++) { + pid = fork(); + if (pid < 0) { + xlog(L_FATAL, "mountd: cannot fork: %s\n", + strerror(errno)); + } + if (pid == 0) { + /* worker child */ + + /* Re-enable the default action on SIGTERM et al + * so that workers die naturally when sent them. + * Only the parent unregisters with pmap and + * hence needs to do special SIGTERM handling. */ + struct sigaction sa; + sa.sa_handler = SIG_DFL; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + /* fall into my_svc_run in caller */ + return; + } + } + + /* in parent */ + wait_for_workers(); + xlog(L_NOTICE, "exportd: no more workers, exiting\n"); + exit(0); +} + static void killer (int sig) { + if (num_threads > 1) { + /* play Kronos and eat our children */ + kill(0, SIGTERM); + wait_for_workers(); + } xlog (L_NOTICE, "Caught signal %d, exiting.", sig); + exit(0); } static void @@ -78,10 +163,20 @@ static void usage(const char *prog, int n) { fprintf(stderr, - "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n", prog); + "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n" +" [-t num|--num-threads=num]\n", prog); exit(n); } +inline static void +read_exportd_conf(char *progname) +{ + conf_init_file(NFS_CONFFILE); + + xlog_set_debug(progname); + + num_threads = conf_get_num("exportd", "threads", num_threads); +} int main(int argc, char **argv) { @@ -98,10 +193,10 @@ main(int argc, char **argv) /* Initialize logging. */ xlog_open(progname); - conf_init_file(NFS_CONFFILE); - xlog_set_debug(progname); + /* Read in config setting */ + read_exportd_conf(progname); - while ((c = getopt_long(argc, argv, "d:fh", longopts, NULL)) != EOF) { + while ((c = getopt_long(argc, argv, "d:fht:", longopts, NULL)) != EOF) { switch (c) { case 'd': xlog_sconfig(optarg, 1); @@ -112,6 +207,9 @@ main(int argc, char **argv) case 'h': usage(progname, 0); break; + case 't': + num_threads = atoi (optarg); + break; case '?': default: usage(progname, 1); @@ -132,6 +230,18 @@ main(int argc, char **argv) set_signals(); daemon_ready(); + /* silently bounds check num_threads */ + if (foreground) + num_threads = 1; + else if (num_threads < 1) + num_threads = 1; + else if (num_threads > MAX_THREADS) + num_threads = MAX_THREADS; + + if (num_threads > 1) + fork_workers(); + + /* Open files now to avoid sharing descriptors among forked processes */ cache_open(); diff --git a/utils/exportd/exportd.man b/utils/exportd/exportd.man index d786e57..1d65b5e 100644 --- a/utils/exportd/exportd.man +++ b/utils/exportd/exportd.man @@ -44,6 +44,13 @@ Run in foreground (do not daemonize) .TP .B \-h " or " \-\-help Display usage message. +.TP +.BR "\-t N" " or " "\-\-num\-threads=N " or " \-\-num\-threads N " +This option specifies the number of worker threads that rpc.mountd +spawns. The default is 1 thread, which is probably enough. More +threads are usually only needed for NFS servers which need to handle +mount storms of hundreds of NFS mounts in a few seconds, or when +your DNS server is slow or unreliable. .SH CONFIGURATION FILE Many of the options that can be set on the command line can also be controlled through values set in the From patchwork Thu Feb 18 22:54:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E7AC433DB for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1A6F64DFD for ; Thu, 18 Feb 2021 22:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbhBRWyp (ORCPT ); Thu, 18 Feb 2021 17:54:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59799 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbhBRWyo (ORCPT ); Thu, 18 Feb 2021 17:54:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C852xBmX9sqhFt2KctvOtg+o/FhIV7JjeKkxhkSwoLU=; b=RvZGM0Ds/sXbMiSGbQtWa9hGNtI11jav+/VDrfspOw/aZ5NfidKVhIpfP5HOsmsusZQYfa YarsrbGzykw+s8r6A4quOqpsCS1MiBs8fYWVK5gwuPXAG14Kg767IVUw/irwgcfA/Fnard l2AeYGaWjgh66VzRx2vSIReFabrZ6GM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-j-_x9TziPHi2eCVTM1Q8IQ-1; Thu, 18 Feb 2021 17:53:16 -0500 X-MC-Unique: j-_x9TziPHi2eCVTM1Q8IQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 165371966322 for ; Thu, 18 Feb 2021 22:53:15 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF1B60BE5 for ; Thu, 18 Feb 2021 22:53:14 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 4/6] exportd/exportfs: Add the state-directory-path option Date: Thu, 18 Feb 2021 17:54:48 -0500 Message-Id: <20210218225450.674466-5-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Ported state-directory-path option from mountd (commit a15bd948) Signed-off-by: Steve Dickson --- nfs.conf | 1 + systemd/nfs.conf.man | 3 ++- utils/exportd/exportd.c | 35 +++++++++++++++++++++++++++-------- utils/exportfs/exportfs.c | 21 +++++++++++++-------- utils/exportfs/exportfs.man | 7 +++++-- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/nfs.conf b/nfs.conf index 4b344fa..bebb2e3 100644 --- a/nfs.conf +++ b/nfs.conf @@ -31,6 +31,7 @@ # [exportd] # debug="all|auth|call|general|parse" +# state-directory-path=/var/lib/nfs # threads=1 [mountd] # debug="all|auth|call|general|parse" diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man index a4379fd..d2187f8 100644 --- a/systemd/nfs.conf.man +++ b/systemd/nfs.conf.man @@ -131,7 +131,8 @@ but on the server, this will resolve to the path .TP .B exportd Recognized values: -.B threads +.BR threads , +.BR state-directory-path See .BR exportd (8) diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c index c814503..7130bcb 100644 --- a/utils/exportd/exportd.c +++ b/utils/exportd/exportd.c @@ -26,7 +26,6 @@ extern void my_svc_run(void); struct state_paths etab; -struct state_paths rmtab; /* Number of mountd threads to start. Default is 1 and * that's probably enough unless you need hundreds of @@ -80,6 +79,12 @@ wait_for_workers (void) } } +inline void +cleanup_lockfiles (void) +{ + unlink(etab.lockfn); +} + /* Fork num_threads worker children and wait for them */ static void fork_workers(void) @@ -117,6 +122,8 @@ fork_workers(void) /* in parent */ wait_for_workers(); + cleanup_lockfiles(); + free_state_path_names(&etab); xlog(L_NOTICE, "exportd: no more workers, exiting\n"); exit(0); } @@ -129,6 +136,8 @@ killer (int sig) kill(0, SIGTERM); wait_for_workers(); } + cleanup_lockfiles(); + free_state_path_names(&etab); xlog (L_NOTICE, "Caught signal %d, exiting.", sig); exit(0); @@ -159,24 +168,33 @@ set_signals(void) sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); } + static void usage(const char *prog, int n) { fprintf(stderr, "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n" +" [-s|--state-directory-path path]\n" " [-t num|--num-threads=num]\n", prog); exit(n); } inline static void -read_exportd_conf(char *progname) +read_exportd_conf(char *progname, char **argv) { + char *s; + conf_init_file(NFS_CONFFILE); xlog_set_debug(progname); num_threads = conf_get_num("exportd", "threads", num_threads); + + s = conf_get_str("exportd", "state-directory-path"); + if (s && !state_setup_basedir(argv[0], s)) + exit(1); } + int main(int argc, char **argv) { @@ -194,9 +212,9 @@ main(int argc, char **argv) xlog_open(progname); /* Read in config setting */ - read_exportd_conf(progname); + read_exportd_conf(progname, argv); - while ((c = getopt_long(argc, argv, "d:fht:", longopts, NULL)) != EOF) { + while ((c = getopt_long(argc, argv, "d:fhs:t:", longopts, NULL)) != EOF) { switch (c) { case 'd': xlog_sconfig(optarg, 1); @@ -207,6 +225,10 @@ main(int argc, char **argv) case 'h': usage(progname, 0); break; + case 's': + if (!state_setup_basedir(argv[0], optarg)) + exit(1); + break; case 't': num_threads = atoi (optarg); break; @@ -219,9 +241,7 @@ main(int argc, char **argv) if (!setup_state_path_names(progname, ETAB, ETABTMP, ETABLCK, &etab)) return 1; - if (!setup_state_path_names(progname, RMTAB, RMTABTMP, RMTABLCK, &rmtab)) - return 1; - + if (!foreground) xlog_stderr(0); @@ -252,6 +272,5 @@ main(int argc, char **argv) progname); free_state_path_names(&etab); - free_state_path_names(&rmtab); exit(1); } diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index f8b446a..262dd19 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -92,10 +92,21 @@ release_lockfile() } } inline static void -read_exportfs_conf(void) +read_exportfs_conf(char **argv) { + char *s; + conf_init_file(NFS_CONFFILE); xlog_set_debug("exportfs"); + + /* NOTE: following uses "mountd" section of nfs.conf !!!! */ + s = conf_get_str("mountd", "state-directory-path"); + /* Also look in the exportd section */ + if (s == NULL) + s = conf_get_str("exportd", "state-directory-path"); + if (s && !state_setup_basedir(argv[0], s)) + exit(1); + } int main(int argc, char **argv) @@ -110,7 +121,6 @@ main(int argc, char **argv) int f_ignore = 0; int i, c; int force_flush = 0; - char *s; if ((progname = strrchr(argv[0], '/')) != NULL) progname++; @@ -122,15 +132,10 @@ main(int argc, char **argv) xlog_syslog(0); /* Read in config setting */ - read_exportfs_conf(); + read_exportfs_conf(argv); nfsd_path_init(); - /* NOTE: following uses "mountd" section of nfs.conf !!!! */ - s = conf_get_str("mountd", "state-directory-path"); - if (s && !state_setup_basedir(argv[0], s)) - exit(1); - while ((c = getopt(argc, argv, "ad:fhio:ruvs")) != EOF) { switch(c) { case 'a': diff --git a/utils/exportfs/exportfs.man b/utils/exportfs/exportfs.man index 91d3589..6d417a7 100644 --- a/utils/exportfs/exportfs.man +++ b/utils/exportfs/exportfs.man @@ -167,9 +167,11 @@ When a list is given, the members should be comma-separated. .B exportfs will also recognize the .B state-directory-path -value from the +value from both the .B [mountd] -section. +section and the +.B [exportd] +section .SH DISCUSSION .SS Exporting Directories @@ -327,6 +329,7 @@ table of clients accessing server's exports .BR exports (5), .BR nfs.conf (5), .BR rpc.mountd (8), +.BR exportd (8), .BR netgroup (5) .SH AUTHORS Olaf Kirch From patchwork Thu Feb 18 22:54:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE6EC433E6 for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21D1F64EBA for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbhBRWyq (ORCPT ); Thu, 18 Feb 2021 17:54:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31476 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbhBRWyp (ORCPT ); Thu, 18 Feb 2021 17:54:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sgwxhz8gxuq+JNCh7YtYmopfxScAxC6V8+cRfi+fb7M=; b=MTU0BxoKUJx8S3tfM2Kw5V6L3kMs108zqCLkOq4G1RGEcfutLhuZh0E/47V+TUlc3QJ5Ax hhG2BudFbJXQqs8P7GXlgI4/iJEydQEMQtoQeresG1P1oy2oJEp0YL3Kq9gNk+vYW4Z57w 2588I9fTrsXCRk3JsC0ydQqrCE9wQCg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-1oTmy3QcOguj2extX0fuQQ-1; Thu, 18 Feb 2021 17:53:16 -0500 X-MC-Unique: 1oTmy3QcOguj2extX0fuQQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A69A1966320 for ; Thu, 18 Feb 2021 22:53:15 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A69B60BE5 for ; Thu, 18 Feb 2021 22:53:15 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 5/6] exportd: Enabled junction support Date: Thu, 18 Feb 2021 17:54:49 -0500 Message-Id: <20210218225450.674466-6-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Moved the junction support from mountd to libexport.a so both exportd and mountd can use the code. Signed-off-by: Steve Dickson --- support/export/Makefile.am | 2 +- {utils/mountd => support/export}/fsloc.c | 0 {utils/mountd => support/include}/fsloc.h | 0 utils/exportd/Makefile.am | 3 +++ utils/mountd/Makefile.am | 3 +-- 5 files changed, 5 insertions(+), 3 deletions(-) rename {utils/mountd => support/export}/fsloc.c (100%) rename {utils/mountd => support/include}/fsloc.h (100%) diff --git a/support/export/Makefile.am b/support/export/Makefile.am index 7de82a8..a9e710c 100644 --- a/support/export/Makefile.am +++ b/support/export/Makefile.am @@ -12,7 +12,7 @@ EXTRA_DIST = mount.x noinst_LIBRARIES = libexport.a libexport_a_SOURCES = client.c export.c hostname.c \ xtab.c mount_clnt.c mount_xdr.c \ - cache.c auth.c v4root.c + cache.c auth.c v4root.c fsloc.c BUILT_SOURCES = $(GENFILES) noinst_HEADERS = mount.h diff --git a/utils/mountd/fsloc.c b/support/export/fsloc.c similarity index 100% rename from utils/mountd/fsloc.c rename to support/export/fsloc.c diff --git a/utils/mountd/fsloc.h b/support/include/fsloc.h similarity index 100% rename from utils/mountd/fsloc.h rename to support/include/fsloc.h diff --git a/utils/exportd/Makefile.am b/utils/exportd/Makefile.am index eb0f0a8..eb521f1 100644 --- a/utils/exportd/Makefile.am +++ b/utils/exportd/Makefile.am @@ -1,6 +1,9 @@ ## Process this file with automake to produce Makefile.in OPTLIBS = +if CONFIG_JUNCTION +OPTLIBS += ../../support/junction/libjunction.la $(LIBXML2) +endif man8_MANS = exportd.man EXTRA_DIST = $(man8_MANS) diff --git a/utils/mountd/Makefile.am b/utils/mountd/Makefile.am index cac3275..859f28e 100644 --- a/utils/mountd/Makefile.am +++ b/utils/mountd/Makefile.am @@ -12,9 +12,8 @@ RPCPREFIX = rpc. KPREFIX = @kprefix@ sbin_PROGRAMS = mountd -noinst_HEADERS = fsloc.h mountd_SOURCES = mountd.c mount_dispatch.c rmtab.c \ - svc_run.c fsloc.c mountd.h + svc_run.c mountd.h mountd_LDADD = ../../support/export/libexport.a \ ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ From patchwork Thu Feb 18 22:54:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 12094483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D447EC433E9 for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D79464EB9 for ; Thu, 18 Feb 2021 22:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbhBRWyr (ORCPT ); Thu, 18 Feb 2021 17:54:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48637 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbhBRWyq (ORCPT ); Thu, 18 Feb 2021 17:54:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613688800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NzQQb8nP4MSONXmH6WTKRS6V21jggC4bDPddfn6VaX0=; b=YdQoosS7xzdogu2WGS6uNqqQGMOenulJuHVTTbzfsaeeroxPHunxb3EUAiluCqc1t3wido xZZqF1Do3aJOfehEhd+EfJpYXk8DmziBmTuZ62O31bTrmMEIZtsY/xluohOopEGRmhFs7P 89KVIniHS7yfKUhtZnvQPu/dd+X34f4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-dWV-bTH8M_6KfoiC0C-rYA-1; Thu, 18 Feb 2021 17:53:17 -0500 X-MC-Unique: dWV-bTH8M_6KfoiC0C-rYA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF70F801965 for ; Thu, 18 Feb 2021 22:53:15 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E0CD60BE5 for ; Thu, 18 Feb 2021 22:53:15 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 6/6] exportd: systemd unit files Date: Thu, 18 Feb 2021 17:54:50 -0500 Message-Id: <20210218225450.674466-7-steved@redhat.com> In-Reply-To: <20210218225450.674466-1-steved@redhat.com> References: <20210218225450.674466-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Created two new systemd unit services based on nfs-mountd and nfs-service Signed-off-by: Steve Dickson --- systemd/Makefile.am | 4 +++- systemd/nfsv4-exportd.service | 12 ++++++++++++ systemd/nfsv4-server.service | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 systemd/nfsv4-exportd.service create mode 100644 systemd/nfsv4-server.service diff --git a/systemd/Makefile.am b/systemd/Makefile.am index 75cdd9f..5251f23 100644 --- a/systemd/Makefile.am +++ b/systemd/Makefile.am @@ -17,7 +17,9 @@ unit_files = \ if CONFIG_NFSV4 unit_files += \ - nfs-idmapd.service + nfs-idmapd.service \ + nfsv4-exportd.service \ + nfsv4-server.service endif if CONFIG_NFSV41 diff --git a/systemd/nfsv4-exportd.service b/systemd/nfsv4-exportd.service new file mode 100644 index 0000000..11d663a --- /dev/null +++ b/systemd/nfsv4-exportd.service @@ -0,0 +1,12 @@ +[Unit] +Description=NFSv4 Mount Daemon +DefaultDependencies=no +Requires=proc-fs-nfsd.mount +Wants=network-online.target +After=proc-fs-nfsd.mount +After=network-online.target local-fs.target +BindsTo=nfsv4-server.service + +[Service] +Type=forking +ExecStart=/usr/sbin/nfsv4.exportd diff --git a/systemd/nfsv4-server.service b/systemd/nfsv4-server.service new file mode 100644 index 0000000..6497568 --- /dev/null +++ b/systemd/nfsv4-server.service @@ -0,0 +1,31 @@ +[Unit] +Description=NFSv4 server and services +DefaultDependencies=no +Requires=network.target proc-fs-nfsd.mount +Requires=nfsv4-exportd.service +Wants=network-online.target +Wants=nfs-idmapd.service +Wants=nfsdcld.service + +After=network-online.target local-fs.target +After=proc-fs-nfsd.mount nfsv4-exportd.service +After=nfs-idmapd.service +After=nfsdcld.service + +# GSS services dependencies and ordering +Wants=auth-rpcgss-module.service +After=rpc-gssd.service gssproxy.service rpc-svcgssd.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStartPre=-/usr/sbin/exportfs -r +ExecStart=/usr/sbin/rpc.nfsd -N 3 +ExecStop=/usr/sbin/rpc.nfsd 0 +ExecStopPost=/usr/sbin/exportfs -au +ExecStopPost=/usr/sbin/exportfs -f + +ExecReload=-/usr/sbin/exportfs -r + +[Install] +WantedBy=multi-user.target