From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH 4/7] exportd/exportfs: Add the state-directory-path option
Date: Fri, 19 Feb 2021 15:08:12 -0500 [thread overview]
Message-ID: <20210219200815.792667-5-steved@redhat.com> (raw)
In-Reply-To: <20210219200815.792667-1-steved@redhat.com>
Ported state-directory-path option from mountd (commit a15bd948)
Signed-off-by: Steve Dickson <steved@redhat.com>
---
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 <okir@monad.swb.de>
--
2.29.2
next prev parent reply other threads:[~2021-02-19 20:08 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 20:08 [PATCH 0/7 V4] The NFSv4 only mounting daemon Steve Dickson
2021-02-19 20:08 ` [PATCH 1/7] exportd: the initial shell of the v4 export support Steve Dickson
2021-02-19 20:08 ` [PATCH 2/7] exportd: Moved cache upcalls routines into libexport.a Steve Dickson
2021-02-23 16:13 ` [PATCH] exportd: server-side gid management Daniel Kobras
2021-03-04 21:28 ` Steve Dickson
2021-02-19 20:08 ` [PATCH 3/7] exportd: multiple threads Steve Dickson
2021-02-19 20:08 ` Steve Dickson [this message]
2021-02-19 20:08 ` [PATCH 5/7] exportd: Enabled junction support Steve Dickson
2021-02-19 20:08 ` [PATCH 6/7] exportd: systemd unit files Steve Dickson
2021-02-19 20:08 ` [PATCH 7/7] exportd: Added config variable to compile in the NFSv4 only server Steve Dickson
2021-02-20 16:33 ` [PATCH 0/7 V4] The NFSv4 only mounting daemon Steve Dickson
2021-02-24 20:30 ` J. Bruce Fields
2021-03-02 22:33 ` Steve Dickson
2021-03-03 15:23 ` J. Bruce Fields
2021-03-03 21:22 ` Steve Dickson
2021-03-03 21:54 ` J. Bruce Fields
2021-03-03 22:07 ` Steve Dickson
2021-03-03 22:17 ` J. Bruce Fields
2021-03-04 13:57 ` Steve Dickson
2021-03-04 14:06 ` J. Bruce Fields
2021-03-04 16:31 ` Steve Dickson
2021-03-05 14:36 ` J. Bruce Fields
2021-03-05 15:53 ` Chuck Lever
2021-03-04 13:42 ` Steve Dickson
2021-03-04 14:01 ` J. Bruce Fields
2021-03-04 16:47 ` Steve Dickson
2021-03-04 21:31 ` Patrick Goetz
2021-03-04 13:34 ` Steve Dickson
2021-03-04 14:24 ` J. Bruce Fields
2021-03-04 16:20 ` Steve Dickson
2021-02-24 20:49 ` J. Bruce Fields
2021-03-02 22:39 ` Steve Dickson
2021-03-03 18:10 ` Chuck Lever
2021-03-03 21:24 ` Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210219200815.792667-5-steved@redhat.com \
--to=steved@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).