restore nfsdcld
Subsystems (2)
v3 cover restore nfsdcld
When nfsdcld was released, it was quickly deprecated in favor of the nfsdcltrack usermodehelper, so as to not require another running daemon. The nfsdcld code was removed from nfs-utils in 2012. That prevents NFSv4 clients from reclaiming locks from nfsd's running in containers, since neither nfsdcltrack nor the legacy client tracking code work in containers. These patches restore the nfsdcld code.
These patches are intended to go alongside some kernel patches that introduce an enhancement that allows nfsd to "slurp" up the client records during client tracking initialization and store them internally in hash table. This enables nfsd to check whether an NFSv4 client is allowed to reclaim without having to do an upcall to nfsdcld. It also allows nfsd to decide to end the v4 grace period early if the number of RECLAIM_COMPLETE operations it has received from "known" clients is equal to the number of entries in the hash table. It also allows nfsd to skip the v4 grace period altogether if it knows there are no clients allowed to reclaim.
The new nfsdcld code will work with older kernels, however in that case there is no ability for nfsd to exit the grace period early or skip the grace period altogether.
v3:
- removed PathExists restriction from the nfsdcld.service file
- added the ability to do a one-time upgrade from older client tracking methods (i.e. nfsdcltrack and/or the legacy v4recovery dir)
v2:
- Use sqlite3_column_int64() instead of sqlite3_column_int() to query the current & recovery values from the grace table
- Uncommented the nfsdcld section header in nfs.conf
Scott Mayhew (8):
Revert "nfsdcltrack: remove the nfsdcld daemon"
nfsdcld: move nfsdcld to its own directory
nfsdcld: a few enhancements
nfsdcld: remove some unused functions
nfsdcld: the -p option should specify the rpc_pipefs mountpoint
nfsdcld: add /etc/nfs.conf support
systemd: add a unit file for nfsdcld
nfsdcld: add a facility for migrating from older client tracking
methods
.gitignore | 1 + configure.ac | 23 + nfs.conf | 4 + support/include/cld.h | 1 + systemd/nfs-server.service | 2 + systemd/nfsdcld.service | 10 + utils/Makefile.am | 4 + utils/nfsdcld/Makefile.am | 19 + utils/nfsdcld/cld-internal.h | 33 + utils/nfsdcld/legacy.c | 180 ++++++ utils/nfsdcld/legacy.h | 24 + utils/nfsdcld/nfsdcld.c | 774 ++++++++++++++++++++++++ utils/nfsdcld/nfsdcld.man | 199 ++++++ utils/nfsdcld/sqlite.c | 1109 ++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 35 ++ 15 files changed, 2418 insertions(+) create mode 100644 systemd/nfsdcld.service create mode 100644 utils/nfsdcld/Makefile.am create mode 100644 utils/nfsdcld/cld-internal.h create mode 100644 utils/nfsdcld/legacy.c create mode 100644 utils/nfsdcld/legacy.h create mode 100644 utils/nfsdcld/nfsdcld.c create mode 100644 utils/nfsdcld/nfsdcld.man create mode 100644 utils/nfsdcld/sqlite.c create mode 100644 utils/nfsdcld/sqlite.h
Signature · 1 line
2.17.2
RFC PATCH v3 1/8 Revert "nfsdcltrack: remove the nfsdcld daemon"
This reverts commit 2cf11ec6ed261ef56bbd0d73ff404fe69f1fefb0.
nfsdcld was originally deprecated in favor of a usermodehelper, so as to not require another running daemon. But that turned out to make namespaced nfsd's too difficult, so this commit brings back nfsdcld.
A few things have been changed since nfsdcld was removed in 2012:
- libnfs.a is now libnfs.la
- sqlite_insert_client and sqlite_check_client both take a bool has_session which is being hard-coded to false for now.
- sqlite_insert_client also takes a bool zerotime which is being hard-coded to false.
- an xlog() call whose arguments did not match the format string (and could crash nfsdcld) has been fixed
- cld_pipe_open() now calls event_initialized() rather than checking for EVLIST_INIT directly (which does not compile with newer versions of libevent).
--- .gitignore | 1 + utils/nfsdcltrack/Makefile.am | 7 +- utils/nfsdcltrack/nfsdcld.c | 611 ++++++++++++++++++++++++++++++++++ utils/nfsdcltrack/nfsdcld.man | 185 ++++++++++ 4 files changed, 802 insertions(+), 2 deletions(-) create mode 100644 utils/nfsdcltrack/nfsdcld.c create mode 100644 utils/nfsdcltrack/nfsdcld.man
.gitignore +1 -0
@@ -54,6 +54,7 @@ utils/rquotad/rquotad utils/rquotad/rquota.h utils/rquotad/rquota_xdr.c utils/showmount/showmount +utils/nfsdcltrack/nfsdcld utils/nfsdcltrack/nfsdcltrack utils/statd/statd tools/locktest/testlk
utils/nfsdcltrack/Makefile.am +5 -2
@@ -4,11 +4,14 @@ # overridden at config time. The kernel "knows" the /sbin name. sbindir = /sbin -man8_MANS = nfsdcltrack.man +man8_MANS = nfsdcld.man nfsdcltrack.man EXTRA_DIST = $(man8_MANS) AM_CFLAGS += -D_LARGEFILE64_SOURCE -sbin_PROGRAMS = nfsdcltrack +sbin_PROGRAMS = nfsdcld nfsdcltrack + +nfsdcld_SOURCES = nfsdcld.c sqlite.c +nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) noinst_HEADERS = sqlite.h
utils/nfsdcltrack/nfsdcld.c new file +611 -0
611 lines not on this page · raw message
utils/nfsdcltrack/nfsdcld.man new file +185 -0
185 lines not on this page · raw message
Signature · 1 line
2.17.2
RFC PATCH v3 2/8 nfsdcld: move nfsdcld to its own directory
In reply to Scott MayhewThe schema for the db used by nfsdcld is going to diverge quite a bit from that used by nfsdcltrack. It will be easier if the programs are kept in separate directories.
---
.gitignore | 2 +-
configure.ac | 23 +
utils/Makefile.am | 4 +
utils/nfsdcld/Makefile.am | 19 +
utils/{nfsdcltrack => nfsdcld}/nfsdcld.c | 0
utils/{nfsdcltrack => nfsdcld}/nfsdcld.man | 0
utils/nfsdcld/sqlite.c | 601 +++++++++++++++++++++
utils/nfsdcld/sqlite.h | 32 ++
utils/nfsdcltrack/Makefile.am | 7 +-
9 files changed, 682 insertions(+), 6 deletions(-)
create mode 100644 utils/nfsdcld/Makefile.am
rename utils/{nfsdcltrack => nfsdcld}/nfsdcld.c (100%)
rename utils/{nfsdcltrack => nfsdcld}/nfsdcld.man (100%)
create mode 100644 utils/nfsdcld/sqlite.c
create mode 100644 utils/nfsdcld/sqlite.h.gitignore +1 -1
@@ -54,7 +54,7 @@ utils/rquotad/rquotad utils/rquotad/rquota.h utils/rquotad/rquota_xdr.c utils/showmount/showmount -utils/nfsdcltrack/nfsdcld +utils/nfsdcld/nfsdcld utils/nfsdcltrack/nfsdcltrack utils/statd/statd tools/locktest/testlk
configure.ac +23 -0
@@ -242,6 +242,12 @@ else AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mount" = "yes"]) fi +AC_ARG_ENABLE(nfsdcld, + [AC_HELP_STRING([--disable-nfsdcld], + [disable NFSv4 clientid tracking daemon @<:@default=no@:>@])], + enable_nfsdcld=$enableval, + enable_nfsdcld="yes") + AC_ARG_ENABLE(nfsdcltrack, [AC_HELP_STRING([--disable-nfsdcltrack], [disable NFSv4 clientid tracking programs @<:@default=no@:>@])],
@@ -321,6 +327,20 @@ if test "$enable_nfsv4" = yes; then dnl Check for sqlite3 AC_SQLITE3_VERS + if test "$enable_nfsdcld" = "yes"; then + AC_CHECK_HEADERS([libgen.h sys/inotify.h], , + AC_MSG_ERROR([Cannot find header needed for nfsdcld])) + + case $libsqlite3_cv_is_recent in + yes) ;; + unknown) + dnl do not fail when cross-compiling + AC_MSG_WARN([assuming sqlite is at least v3.3]) ;; + *) + AC_MSG_ERROR([nfsdcld requires sqlite-devel]) ;; + esac + fi + if test "$enable_nfsdcltrack" = "yes"; then AC_CHECK_HEADERS([libgen.h sys/inotify.h], , AC_MSG_ERROR([Cannot find header needed for nfsdcltrack]))
@@ -336,6 +356,7 @@ if test "$enable_nfsv4" = yes; then fi else + enable_nfsdcld="no" enable_nfsdcltrack="no" fi
@@ -346,6 +367,7 @@ if test "$enable_nfsv41" = yes; then fi dnl enable nfsidmap when its support by libnfsidmap +AM_CONDITIONAL(CONFIG_NFSDCLD, [test "$enable_nfsdcld" = "yes" ]) AM_CONDITIONAL(CONFIG_NFSDCLTRACK, [test "$enable_nfsdcltrack" = "yes" ])
@@ -623,6 +645,7 @@ AC_CONFIG_FILES([ tools/nfsconf/Makefile utils/Makefile utils/blkmapd/Makefile + utils/nfsdcld/Makefile utils/nfsdcltrack/Makefile utils/exportfs/Makefile utils/gssd/Makefile
utils/Makefile.am +4 -0
@@ -19,6 +19,10 @@ if CONFIG_MOUNT OPTDIRS += mount endif +if CONFIG_NFSDCLD +OPTDIRS += nfsdcld +endif + if CONFIG_NFSDCLTRACK OPTDIRS += nfsdcltrack endif
utils/nfsdcld/Makefile.am new file +19 -0
@@ -0,0 +1,19 @@ +## Process this file with automake to produce Makefile.in + +# These binaries go in /sbin (not /usr/sbin), and that cannot be +# overridden at config time. The kernel "knows" the /sbin name. +sbindir = /sbin + +man8_MANS = nfsdcld.man +EXTRA_DIST = $(man8_MANS) + +AM_CFLAGS += -D_LARGEFILE64_SOURCE +sbin_PROGRAMS = nfsdcld + +nfsdcld_SOURCES = nfsdcld.c sqlite.c +nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) + +noinst_HEADERS = sqlite.h + +MAINTAINERCLEANFILES = Makefile.in +
utils/nfsdcld/nfsdcld.c renamed from utils/nfsdcltrack/nfsdcld.c +0 -0
utils/nfsdcld/nfsdcld.man renamed from utils/nfsdcltrack/nfsdcld.man +0 -0
utils/nfsdcld/sqlite.c new file +601 -0
601 lines not on this page · raw message
utils/nfsdcld/sqlite.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2011 Red Hat, Jeff Layton <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +*/ + +#ifndef _SQLITE_H_ +#define _SQLITE_H_ + +int sqlite_prepare_dbh (const char *topdir); +int sqlite_insert_client (const unsigned char *clname,const size_t namelen, +const bool has_session,const bool zerotime); +int sqlite_remove_client (const unsigned char *clname,const size_t namelen); +int sqlite_check_client (const unsigned char *clname,const size_t namelen, +const bool has_session); +int sqlite_remove_unreclaimed (const time_t grace_start); +int sqlite_query_reclaiming (const time_t grace_start); + +#endif /* _SQLITE_H */
utils/nfsdcltrack/Makefile.am +2 -5
@@ -4,14 +4,11 @@ # overridden at config time. The kernel "knows" the /sbin name. sbindir = /sbin -man8_MANS = nfsdcld.man nfsdcltrack.man +man8_MANS = nfsdcltrack.man EXTRA_DIST = $(man8_MANS) AM_CFLAGS += -D_LARGEFILE64_SOURCE -sbin_PROGRAMS = nfsdcld nfsdcltrack - -nfsdcld_SOURCES = nfsdcld.c sqlite.c -nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) +sbin_PROGRAMS = nfsdcltrack noinst_HEADERS = sqlite.h
Signature · 1 line
2.17.2
RFC PATCH v3 3/8 nfsdcld: a few enhancements
In reply to Scott Mayhew1) Adopt the concept of "reboot epochs" (but not coordinated grace periods via the "need" and "enforcing" flags) from Jeff Layton's "Active/Active NFS Server Recovery" presentation from the Fall 2018 NFS Bakeathon. See
http://nfsv4bat.org/Documents/BakeAThon/2018/Active_Active%20NFS%20Server%20Recovery.pdf
- add a new table "grace" which contains two integer columns representing the "current" epoch (where new client records are stored) and the "recovery" epoch (which has the records for clients that are allowed to recover)
- replace the "clients" table with table(s) named "rec-CCCCCCCCCCCCCCCC" (where C is the hex value of the epoch), containing a single column "id" which stores the client id string
- when going from normal operation into grace, the current epoch becomes the recovery epoch, the current epoch is incremented, and a new table is created for the current epoch. Clients are allowed to reclaim if they have a record in the table corresponding to the recovery epoch and new records are added to the table corresponding to the current epoch.
- when moving from grace back to normal operation, the table associated with the recovery epoch is deleted and the recovery epoch becomes zero.
- if the server restarts before exiting the previous grace period, then the epochs are not changed, and all records in the table associated with the "current" epoch are cleared out.
2) Allow knfsd to "slurp" the client records during startup.
During client tracking initialization, knfsd will do an upcall to get a list of clients from the database. nfsdcld will do one downcall with a status of -EINPROGRESS for each client record in the database, followed by a final downcall with a status of 0. This will allow 2 things
- knfsd can check whether a client is allowed to reclaim without performing an upcall to nfsdcld
- knfsd can decide to end the grace period early by tracking the number of RECLAIM_COMPLETE operations it receives from "known" clients, or it can skip the grace period altogether if no clients are allowed to reclaim.
--- support/include/cld.h | 1 + utils/nfsdcld/Makefile.am | 2 +- utils/nfsdcld/cld-internal.h | 30 +++ utils/nfsdcld/nfsdcld.c | 160 +++++++++++- utils/nfsdcld/sqlite.c | 483 ++++++++++++++++++++++++++++------- utils/nfsdcld/sqlite.h | 11 +- 6 files changed, 579 insertions(+), 108 deletions(-) create mode 100644 utils/nfsdcld/cld-internal.h
support/include/cld.h +1 -0
@@ -33,6 +33,7 @@ enum cld_command { Cld_Remove,/* remove record of this cm_id */ Cld_Check,/* is this cm_id allowed? */ Cld_GraceDone,/* grace period is complete */ + Cld_GraceStart, };/* representation of long-form NFSv4 client ID */
utils/nfsdcld/Makefile.am +1 -1
@@ -13,7 +13,7 @@ sbin_PROGRAMS = nfsdcld nfsdcld_SOURCES = nfsdcld.c sqlite.c nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) -noinst_HEADERS = sqlite.h +noinst_HEADERS = sqlite.h cld-internal.h MAINTAINERCLEANFILES = Makefile.in
utils/nfsdcld/cld-internal.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +*/ + +#ifndef _CLD_INTERNAL_H_ +#define _CLD_INTERNAL_H_ + +struct cld_client { +int cl_fd; +struct event cl_event; +struct cld_msg cl_msg; +}; + +uint64_t current_epoch; +uint64_t recovery_epoch; + +#endif /* _CLD_INTERNAL_H_ */
utils/nfsdcld/nfsdcld.c +147 -13
245 lines not on this page · raw message
utils/nfsdcld/sqlite.c +393 -90
641 lines not on this page · raw message
utils/nfsdcld/sqlite.h +7 -4
@@ -20,13 +20,16 @@#ifndef _SQLITE_H_#define _SQLITE_H_ +struct cld_client ; +int sqlite_prepare_dbh (const char *topdir); -int sqlite_insert_client (const unsigned char *clname,const size_t namelen, -const bool has_session,const bool zerotime); +int sqlite_insert_client (const unsigned char *clname,const size_t namelen);int sqlite_remove_client (const unsigned char *clname,const size_t namelen); -int sqlite_check_client (const unsigned char *clname,const size_t namelen, -const bool has_session); +int sqlite_check_client (const unsigned char *clname,const size_t namelen);int sqlite_remove_unreclaimed (const time_t grace_start);int sqlite_query_reclaiming (const time_t grace_start); +int sqlite_grace_start (void ); +int sqlite_grace_done (void ); +int sqlite_iterate_recovery (int (*cb)(struct cld_client *clnt),struct cld_client *clnt);#endif /* _SQLITE_H */
Signature · 1 line
2.17.2
RFC PATCH v3 4/8 nfsdcld: remove some unused functions
In reply to Scott MayhewGet rid of sqlite_query_reclaiming() and sqlite_remove_unreclaimed(), which are not used.
--- utils/nfsdcld/sqlite.c | 67 ------------------------------------------ utils/nfsdcld/sqlite.h | 2 -- 2 files changed, 69 deletions(-)
utils/nfsdcld/sqlite.c +0 -67
@@ -628,73 +628,6 @@ out_err:return ret; } -/* -* remove any client records that were not reclaimed since grace_start. -*/ -int -sqlite_remove_unreclaimed (time_t grace_start) -{ -int ret; -char *err =NULL ; - - ret =snprintf (buf,sizeof (buf),"DELETE FROM clients WHERE time < %ld" , - grace_start); -if (ret <0 ) { -return ret; - }else if ((size_t )ret >=sizeof (buf)) { - ret = -EINVAL ; -return ret; - } - - ret =sqlite3_exec (dbh, buf,NULL ,NULL , &err); -if (ret !=SQLITE_OK ) -xlog (L_ERROR ,"%s: delete failed: %s" , __func__, err); - -xlog (D_GENERAL ,"%s: returning %d" , __func__, ret); -sqlite3_free (err); -return ret; -} - -/* -* Are there any clients that are possibly still reclaiming? Return a positive -* integer (usually number of clients) if so. If not, then return 0. On any -* error, return non-zero. -*/ -int -sqlite_query_reclaiming (const time_t grace_start) -{ -int ret; -sqlite3_stmt *stmt =NULL ; - - ret =sqlite3_prepare_v2 (dbh,"SELECT count(*) FROM clients WHERE " -"time < ? OR has_session != 1" ,-1 , &stmt,NULL ); -if (ret !=SQLITE_OK ) { -xlog (L_ERROR ,"%s: unable to prepare select statement: %s" , - __func__,sqlite3_errmsg (dbh)); -return ret; - } - - ret =sqlite3_bind_int64 (stmt,1 , (sqlite3_int64 )grace_start); -if (ret !=SQLITE_OK ) { -xlog (L_ERROR ,"%s: bind int64 failed: %s" , - __func__,sqlite3_errmsg (dbh)); -return ret; - } - - ret =sqlite3_step (stmt); -if (ret !=SQLITE_ROW ) { -xlog (L_ERROR ,"%s: unexpected return code from select: %s" , - __func__,sqlite3_errmsg (dbh)); -return ret; - } - - ret =sqlite3_column_int (stmt,0 ); -sqlite3_finalize (stmt); -xlog (D_GENERAL ,"%s: there are %d clients that have not completed " -"reclaim" , __func__, ret); -return ret; -} -int sqlite_grace_start (void ) {
utils/nfsdcld/sqlite.h +0 -2
@@ -26,8 +26,6 @@ int sqlite_prepare_dbh(const char *topdir);int sqlite_insert_client (const unsigned char *clname,const size_t namelen);int sqlite_remove_client (const unsigned char *clname,const size_t namelen);int sqlite_check_client (const unsigned char *clname,const size_t namelen); -int sqlite_remove_unreclaimed (const time_t grace_start); -int sqlite_query_reclaiming (const time_t grace_start);int sqlite_grace_start (void );int sqlite_grace_done (void );int sqlite_iterate_recovery (int (*cb)(struct cld_client *clnt),struct cld_client *clnt);
Signature · 1 line
2.17.2
RFC PATCH v3 5/8 nfsdcld: the -p option should specify the rpc_pipefs mountpoint
In reply to Scott MayhewChange the -p option to specify the rpc_pipefs mountpoint rather than the full path to the cld pipe file. This is consistent with other daemons that use the rpc_pipefs filesystem.
--- utils/nfsdcld/nfsdcld.c | 17 ++++++++++------- utils/nfsdcld/nfsdcld.man | 9 ++++----- 2 files changed, 14 insertions(+), 12 deletions(-)
utils/nfsdcld/nfsdcld.c +10 -7
@@ -46,11 +46,11 @@#include "sqlite.h" #include "../mount/version.h" -#ifndef PIPEFS_DIR -#define PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs" +#ifndef DEFAULT_PIPEFS_DIR +#define DEFAULT_PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs"#endif -#define DEFAULT_CLD_PATH PIPEFS_DIR "/nfsd/cld" +#define DEFAULT_CLD_PATH "/nfsd/cld"#ifndef CLD_DEFAULT_STORAGEDIR #define CLD_DEFAULT_STORAGEDIR NFS_STATEDIR "/nfsdcld"
@@ -63,7 +63,8 @@/* private data structures */ /* global variables */ -static char *pipepath =DEFAULT_CLD_PATH ; +static char pipefs_dir[PATH_MAX ] =DEFAULT_PIPEFS_DIR ; +static char pipepath[PATH_MAX ];static int inotify_fd =-1 ;static struct event pipedir_event;static bool old_kernel = false;
@@ -73,7 +74,7 @@ static struct option longopts[] = { "help", 0, NULL, 'h' }, { "foreground", 0, NULL, 'F' }, { "debug", 0, NULL, 'd' }, - { "pipe", 1, NULL, 'p' }, + { "pipefsdir", 1, NULL, 'p' }, { "storagedir", 1, NULL, 's' }, { NULL, 0, 0, 0 }, };
@@ -84,7 +85,7 @@ static void cldcb(int UNUSED(fd), short which, void *data);static void usage (char *progname) { -printf ("%s [ -hFd ] [ -p pipe ] [ -s dir ]\n" , progname); +printf ("%s [ -hFd ] [ -p pipefsdir ] [ -s storagedir ]\n" , progname); } static int
@@ -663,7 +664,7 @@ main(int argc, char **argv) foreground = true;break ;case 'p' : - pipepath = optarg; +strlcpy (pipefs_dir, optarg,sizeof (pipefs_dir));break ;case 's' : storagedir = optarg;
@@ -674,6 +675,8 @@ main(int argc, char **argv) } } +strlcpy (pipepath, pipefs_dir,sizeof (pipepath)); +strlcat (pipepath,DEFAULT_CLD_PATH ,sizeof (pipepath));xlog_open (progname);if (!foreground) {
utils/nfsdcld/nfsdcld.man +4 -5
@@ -155,11 +155,10 @@ Enable debug level logging. .IP "\fB\-F\fR, \fB\-\-foreground\fR" 4 .IX Item "-F, --foreground" Runs the daemon in the foreground and prints all output to stderr -.IP "\fB\-p\fR \fIpipe\fR, \fB\-\-pipe\fR=\fIpipe\fR" 4 -.IX Item "-p pipe, --pipe=pipe" -Location of the \*(L"cld\*(R" upcall pipe. The default value is -\&\fI/var/lib/nfs/rpc_pipefs/nfsd/cld\fR. If the pipe does not exist when the -daemon starts then it will wait for it to be created. +.IP "\fB\-p\fR \fIpath\fR, \fB\-\-pipefsdir\fR=\fIpath\fR" 4 +.IX Item "-p path, --pipefsdir=path" +Location of the rpc_pipefs filesystem. The default value is +\&\fI/var/lib/nfs/rpc_pipefs\fR. .IP "\fB\-s\fR \fIstorage_dir\fR, \fB\-\-storagedir\fR=\fIstorage_dir\fR" 4 .IX Item "-s storagedir, --storagedir=storage_dir" Directory where stable storage information should be kept. The default
Signature · 1 line
2.17.2
RFC PATCH v3 6/8 nfsdcld: add /etc/nfs.conf support
In reply to Scott Mayhew--- nfs.conf | 4 ++++ utils/nfsdcld/nfsdcld.c | 13 +++++++++++++ utils/nfsdcld/nfsdcld.man | 15 +++++++++++++++ 3 files changed, 32 insertions(+)
nfs.conf +4 -0
@@ -34,6 +34,10 @@ # state-directory-path=/var/lib/nfs # ha-callout= # +[nfsdcld] +# debug=0 +# storagedir=/var/lib/nfs/nfsdcld +# [nfsdcltrack] # debug=0 # storagedir=/var/lib/nfs/nfsdcltrack
utils/nfsdcld/nfsdcld.c +13 -0
@@ -45,6 +45,7 @@#include "cld-internal.h" #include "sqlite.h" #include "../mount/version.h" +#include "conffile.h" #ifndef DEFAULT_PIPEFS_DIR #define DEFAULT_PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs"
@@ -640,6 +641,7 @@ main(int argc, char **argv)char *progname;char *storagedir =CLD_DEFAULT_STORAGEDIR ;struct cld_client clnt; +char *s;memset (&clnt,0 ,sizeof (clnt));
@@ -653,6 +655,17 @@ main(int argc, char **argv)xlog_syslog (0 );xlog_stderr (1 ); +conf_init_file (NFS_CONFFILE ); + s =conf_get_str ("general" ,"pipefs-directory" ); +if (s) +strlcpy (pipefs_dir, s,sizeof (pipefs_dir)); + s =conf_get_str ("nfsdcld" ,"storagedir" ); +if (s) + storagedir = s; + rc =conf_get_num ("nfsdcld" ,"debug" ,0 ); +if (rc >0 ) +xlog_config (D_ALL ,1 ); +/* process command-line options */ while ((arg =getopt_long (argc, argv,"hdFp:s:" , longopts,NULL )) !=EOF ) {
utils/nfsdcld/nfsdcld.man +15 -0
@@ -163,6 +163,21 @@ Location of the rpc_pipefs filesystem. The default value is .IX Item "-s storagedir, --storagedir=storage_dir" Directory where stable storage information should be kept. The default value is \fI/var/lib/nfs/nfsdcld\fR. +.SH "CONFIGURATION FILE" +.IX Header "CONFIGURATION FILE" +The following values are recognized in the \fB[nfsdcld]\fR section +of the \fI/etc/nfs.conf\fR configuration file: +.IP "\fBstoragedir\fR" 4 +.IX Item "storagedir" +Equivalent to \fB\-s\fR/\fB\-\-storagedir\fR. +.IP "\fBdebug\fR" 4 +.IX Item "debug" +Setting "debug = 1" is equivalent to \fB\-d\fR/\fB\-\-debug\fR. +.LP +In addition, the following value is recognized from the \fB[general]\fR section: +.IP "\fBpipefs\-directory\fR" 4 +.IX Item "pipefs-directory" +Equivalent to \fB\-p\fR/\fB\-\-pipefsdir\fR. .SH "NOTES" .IX Header "NOTES" The Linux kernel NFSv4 server has historically tracked this information
Signature · 1 line
2.17.2
Re: [nfs-utils PATCH RFC v3 6/8] nfsdcld: add /etc/nfs.conf support
Hi Scott,
Sorry for jumping back into this thread after one year.
Maybe one another man page nfs.conf(5) (i.e. systemd/nfs.conf.man) also needs an update (just as nfsdcltrack does).
Thanks,
Yongcheng
Quoted 89 lines · Scott Mayhew
Signed-off-by Scott Mayhew <[email protected]>--- nfs.conf | 4 ++++ utils/nfsdcld/nfsdcld.c | 13 +++++++++++++ utils/nfsdcld/nfsdcld.man | 15 +++++++++++++++ 3 files changed, 32 insertions(+)nfs.conf +4
-0@@ -34,6 +34,10 @@ # state-directory-path=/var/lib/nfs # ha-callout= # +[nfsdcld] +# debug=0 +# storagedir=/var/lib/nfs/nfsdcld +# [nfsdcltrack] # debug=0 # storagedir=/var/lib/nfs/nfsdcltrackutils/nfsdcld/nfsdcld.c +13
-0@@ -45,6 +45,7 @@#include "cld-internal.h" #include "sqlite.h" #include "../mount/version.h" +#include "conffile.h" #ifndef DEFAULT_PIPEFS_DIR #define DEFAULT_PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs"@@ -640,6 +641,7 @@ main(int argc, char **argv)char *progname;char *storagedir =CLD_DEFAULT_STORAGEDIR ;struct cld_client clnt; +char *s;memset (&clnt,0 ,sizeof (clnt));@@ -653,6 +655,17 @@ main(int argc, char **argv)xlog_syslog (0 );xlog_stderr (1 ); +conf_init_file (NFS_CONFFILE ); + s =conf_get_str ("general" ,"pipefs-directory" ); +if (s) +strlcpy (pipefs_dir, s,sizeof (pipefs_dir)); + s =conf_get_str ("nfsdcld" ,"storagedir" ); +if (s) + storagedir = s; + rc =conf_get_num ("nfsdcld" ,"debug" ,0 ); +if (rc >0 ) +xlog_config (D_ALL ,1 ); +/* process command-line options */ while ((arg =getopt_long (argc, argv,"hdFp:s:" , longopts,NULL )) !=EOF ) {utils/nfsdcld/nfsdcld.man +15
-0@@ -163,6 +163,21 @@ Location of the rpc_pipefs filesystem. The default value is .IX Item "-s storagedir, --storagedir=storage_dir" Directory where stable storage information should be kept. The default value is \fI/var/lib/nfs/nfsdcld\fR. +.SH "CONFIGURATION FILE" +.IX Header "CONFIGURATION FILE" +The following values are recognized in the \fB[nfsdcld]\fR section +of the \fI/etc/nfs.conf\fR configuration file: +.IP "\fBstoragedir\fR" 4 +.IX Item "storagedir" +Equivalent to \fB\-s\fR/\fB\-\-storagedir\fR. +.IP "\fBdebug\fR" 4 +.IX Item "debug" +Setting "debug = 1" is equivalent to \fB\-d\fR/\fB\-\-debug\fR. +.LP +In addition, the following value is recognized from the \fB[general]\fR section: +.IP "\fBpipefs\-directory\fR" 4 +.IX Item "pipefs-directory" +Equivalent to \fB\-p\fR/\fB\-\-pipefsdir\fR. .SH "NOTES" .IX Header "NOTES" The Linux kernel NFSv4 server has historically tracked this informationSignature · 1 line
2.17.2
RFC PATCH v3 7/8 systemd: add a unit file for nfsdcld
In reply to Scott Mayhew--- systemd/nfs-server.service | 2 ++ systemd/nfsdcld.service | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 systemd/nfsdcld.service
systemd/nfs-server.service +2 -0
@@ -6,10 +6,12 @@ Requires= nfs-mountd.service Wants=rpcbind.socket network-online.target Wants=rpc-statd.service nfs-idmapd.service Wants=rpc-statd-notify.service +Wants=nfsdcld.service After= network-online.target local-fs.target After= proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service After= nfs-idmapd.service rpc-statd.service +After= nfsdcld.service Before= rpc-statd-notify.service # GSS services dependencies and ordering
systemd/nfsdcld.service new file +10 -0
@@ -0,0 +1,10 @@ +[Unit] +Description=NFSv4 Client Tracking Daemon +DefaultDependencies=no +Conflicts=umount.target +Requires=rpc_pipefs.target proc-fs-nfsd.mount +After=rpc_pipefs.target proc-fs-nfsd.mount + +[Service] +Type=forking +ExecStart=/usr/sbin/nfsdcld
Signature · 1 line
2.17.2
RFC PATCH v3 8/8 nfsdcld: add a facility for migrating from older client tracking methods
In reply to Scott MayhewThis patch adds a one-time "upgrade" when using nfsdcld for the first time. During initialization of the database, we try to copy records from the old nfdscltrack database and from the legacy v4recovery directory (although we don't expect to find records in both places).
nfsdcltrack stores the client name string so the handling of those records is straightforward. Legacy records are md5 hashes of the client name string, so we prefix them with "hash:" as way to let knfsd know that this is a legacy record. knfsd will need a fallback check in the event that it cannot find a reclaim record using the client name string.
Upon receipt of the first "GraceDone" upcall we clean out any records from the old nfsdcltrack database and delete any subdirectories under the v4recovery directory.
--- utils/nfsdcld/Makefile.am | 4 +- utils/nfsdcld/cld-internal.h | 3 + utils/nfsdcld/legacy.c | 180 +++++++++++++++++++++++ utils/nfsdcld/legacy.h | 24 ++++ utils/nfsdcld/nfsdcld.c | 13 ++ utils/nfsdcld/sqlite.c | 272 +++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 2 + 7 files changed, 496 insertions(+), 2 deletions(-) create mode 100644 utils/nfsdcld/legacy.c create mode 100644 utils/nfsdcld/legacy.h
utils/nfsdcld/Makefile.am +2 -2
@@ -10,10 +10,10 @@ EXTRA_DIST = $(man8_MANS) AM_CFLAGS += -D_LARGEFILE64_SOURCE sbin_PROGRAMS = nfsdcld -nfsdcld_SOURCES = nfsdcld.c sqlite.c +nfsdcld_SOURCES = nfsdcld.c sqlite.c legacy.c nfsdcld_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBSQLITE) $(LIBCAP) -noinst_HEADERS = sqlite.h cld-internal.h +noinst_HEADERS = sqlite.h cld-internal.h legacy.h MAINTAINERCLEANFILES = Makefile.in
utils/nfsdcld/cld-internal.h +3 -0
@@ -26,5 +26,8 @@ struct cld_client {uint64_t current_epoch;uint64_t recovery_epoch; +int first_time; +int num_cltrack_records; +int num_legacy_records;#endif /* _CLD_INTERNAL_H_ */
utils/nfsdcld/legacy.c new file +180 -0
180 lines not on this page · raw message
utils/nfsdcld/legacy.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +*/ + +#ifndef _LEGACY_H_ +#define _LEGACY_H_ + +void legacy_load_clients_from_recdir (int *); +void legacy_clear_recdir (void ); + +#endif /* _LEGACY_H_ */
utils/nfsdcld/nfsdcld.c +13 -0
@@ -46,6 +46,7 @@#include "sqlite.h" #include "../mount/version.h" #include "conffile.h" +#include "legacy.h" #ifndef DEFAULT_PIPEFS_DIR #define DEFAULT_PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs"
@@ -510,6 +511,15 @@ cld_gracedone(struct cld_client *clnt) ret =sqlite_grace_done (); +if (first_time) { +if (num_cltrack_records >0 ) +sqlite_delete_cltrack_records (); +if (num_legacy_records >0 ) +legacy_clear_recdir (); +sqlite_first_time_done (); + first_time =0 ; + } + reply:/* set up reply: downcall with 0 status */ cmsg->cm_status = ret ? -EREMOTEIO : ret;
@@ -642,6 +652,9 @@ main(int argc, char **argv)char *storagedir =CLD_DEFAULT_STORAGEDIR ;struct cld_client clnt;char *s; + first_time =0 ; + num_cltrack_records =0 ; + num_legacy_records =0 ;memset (&clnt,0 ,sizeof (clnt));
utils/nfsdcld/sqlite.c +272 -0
319 lines not on this page · raw message
utils/nfsdcld/sqlite.h +2 -0
@@ -29,5 +29,7 @@ int sqlite_check_client(const unsigned char *clname, const size_t namelen);int sqlite_grace_start (void );int sqlite_grace_done (void );int sqlite_iterate_recovery (int (*cb)(struct cld_client *clnt),struct cld_client *clnt); +int sqlite_delete_cltrack_records (void ); +int sqlite_first_time_done (void );#endif /* _SQLITE_H */
Signature · 1 line
2.17.2
I've really only skimmed the changelogs and documentation and such, but that all looks good to me, and I'm still expecting to commit the kernel-side patches for 5.2, so I'm favor of these nfs-utils patches instead, as long as they look good to Steve.
--b.
Quoted 70 lines · Scott Mayhew
When nfsdcld was released, it was quickly deprecated in favor of the nfsdcltrack usermodehelper, so as to not require another running daemon. The nfsdcld code was removed from nfs-utils in 2012. That prevents NFSv4 clients from reclaiming locks from nfsd's running in containers, since neither nfsdcltrack nor the legacy client tracking code work in containers. These patches restore the nfsdcld code.
These patches are intended to go alongside some kernel patches that introduce an enhancement that allows nfsd to "slurp" up the client records during client tracking initialization and store them internally in hash table. This enables nfsd to check whether an NFSv4 client is allowed to reclaim without having to do an upcall to nfsdcld. It also allows nfsd to decide to end the v4 grace period early if the number of
RECLAIM_COMPLETEoperations it has received from "known" clients is equal to the number of entries in the hash table. It also allows nfsd to skip the v4 grace period altogether if it knows there are no clients allowed to reclaim.The new nfsdcld code will work with older kernels, however in that case there is no ability for nfsd to exit the grace period early or skip the grace period altogether.
v3:
- removed PathExists restriction from the nfsdcld.service file
- added the ability to do a one-time upgrade from older client tracking methods (i.e. nfsdcltrack and/or the legacy v4recovery dir)
v2:
- Usesqlite3_column_int64()instead ofsqlite3_column_int()to query the current & recovery values from the grace table
- Uncommented the nfsdcld section header in nfs.confScott Mayhew (8):
Revert "nfsdcltrack: remove the nfsdcld daemon"
nfsdcld: move nfsdcld to its own directory
nfsdcld: a few enhancements
nfsdcld: remove some unused functions
nfsdcld: the -p option should specify therpc_pipefsmountpoint
nfsdcld: add/etc/nfs.confsupport
systemd: add a unit file for nfsdcld
nfsdcld: add a facility for migrating from older client tracking
methods.gitignore | 1 + configure.ac | 23 + nfs.conf | 4 + support/include/cld.h | 1 + systemd/nfs-server.service | 2 + systemd/nfsdcld.service | 10 + utils/Makefile.am | 4 + utils/nfsdcld/Makefile.am | 19 + utils/nfsdcld/cld-internal.h | 33 + utils/nfsdcld/legacy.c | 180 ++++++ utils/nfsdcld/legacy.h | 24 + utils/nfsdcld/nfsdcld.c | 774 ++++++++++++++++++++++++ utils/nfsdcld/nfsdcld.man | 199 ++++++ utils/nfsdcld/sqlite.c | 1109 ++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 35 ++ 15 files changed, 2418 insertions(+) create mode 100644 systemd/nfsdcld.service create mode 100644 utils/nfsdcld/Makefile.am create mode 100644 utils/nfsdcld/cld-internal.h create mode 100644 utils/nfsdcld/legacy.c create mode 100644 utils/nfsdcld/legacy.h create mode 100644 utils/nfsdcld/nfsdcld.c create mode 100644 utils/nfsdcld/nfsdcld.man create mode 100644 utils/nfsdcld/sqlite.c create mode 100644 utils/nfsdcld/sqlite.hSignature · 1 line
2.17.2
Quoted 4 lines · J. Bruce Fields
I've really only skimmed the changelogs and documentation and such, but that all looks good to me, and I'm still expecting to commit the kernel-side patches for 5.2, so I'm favor of these nfs-utils patches instead, as long as they look good to Steve.
They look reasonable to me... Committed!!
steved.
Quoted 74 lines
--b.
Quoted 70 lines · Scott Mayhew
When nfsdcld was released, it was quickly deprecated in favor of the nfsdcltrack usermodehelper, so as to not require another running daemon. The nfsdcld code was removed from nfs-utils in 2012. That prevents NFSv4 clients from reclaiming locks from nfsd's running in containers, since neither nfsdcltrack nor the legacy client tracking code work in containers. These patches restore the nfsdcld code.
These patches are intended to go alongside some kernel patches that introduce an enhancement that allows nfsd to "slurp" up the client records during client tracking initialization and store them internally in hash table. This enables nfsd to check whether an NFSv4 client is allowed to reclaim without having to do an upcall to nfsdcld. It also allows nfsd to decide to end the v4 grace period early if the number of
RECLAIM_COMPLETEoperations it has received from "known" clients is equal to the number of entries in the hash table. It also allows nfsd to skip the v4 grace period altogether if it knows there are no clients allowed to reclaim.The new nfsdcld code will work with older kernels, however in that case there is no ability for nfsd to exit the grace period early or skip the grace period altogether.
v3:
- removed PathExists restriction from the nfsdcld.service file
- added the ability to do a one-time upgrade from older client tracking methods (i.e. nfsdcltrack and/or the legacy v4recovery dir)
v2:
- Usesqlite3_column_int64()instead ofsqlite3_column_int()to query the current & recovery values from the grace table
- Uncommented the nfsdcld section header in nfs.confScott Mayhew (8):
Revert "nfsdcltrack: remove the nfsdcld daemon"
nfsdcld: move nfsdcld to its own directory
nfsdcld: a few enhancements
nfsdcld: remove some unused functions
nfsdcld: the -p option should specify therpc_pipefsmountpoint
nfsdcld: add/etc/nfs.confsupport
systemd: add a unit file for nfsdcld
nfsdcld: add a facility for migrating from older client tracking
methods.gitignore | 1 + configure.ac | 23 + nfs.conf | 4 + support/include/cld.h | 1 + systemd/nfs-server.service | 2 + systemd/nfsdcld.service | 10 + utils/Makefile.am | 4 + utils/nfsdcld/Makefile.am | 19 + utils/nfsdcld/cld-internal.h | 33 + utils/nfsdcld/legacy.c | 180 ++++++ utils/nfsdcld/legacy.h | 24 + utils/nfsdcld/nfsdcld.c | 774 ++++++++++++++++++++++++ utils/nfsdcld/nfsdcld.man | 199 ++++++ utils/nfsdcld/sqlite.c | 1109 ++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 35 ++ 15 files changed, 2418 insertions(+) create mode 100644 systemd/nfsdcld.service create mode 100644 utils/nfsdcld/Makefile.am create mode 100644 utils/nfsdcld/cld-internal.h create mode 100644 utils/nfsdcld/legacy.c create mode 100644 utils/nfsdcld/legacy.h create mode 100644 utils/nfsdcld/nfsdcld.c create mode 100644 utils/nfsdcld/nfsdcld.man create mode 100644 utils/nfsdcld/sqlite.c create mode 100644 utils/nfsdcld/sqlite.hSignature · 1 line
2.17.2