nfsdcld: add a daemon to track NFSv4 client names on stable storage
Subsystems (2)
v2 cover nfsdcld: add a daemon to track NFSv4 client names on stable storage
This patchset is the userspace portion of the knfsd client name tracking overhaul. See this patch series for an explanation:
nfsd: overhaul the client name tracking code (RFC)
The main changes from the last set are:
- the daemon has been renamed from clstated to nfsdcld, per Steve D's suggestion
- the client names are no longer tracked on a per-server-address basis. Chuck Lever pointed out that doing so would break the UCS migration model. This version just keeps a single clients table in the main database (which also significantly simplifies the code).
- other bugfixes and cleanups
The daemon listens for upcalls on the rpc_pipefs pipe using libevent, and handles the requests.
The data is stored using a sqlite database. The main reason for this is that it takes care of most of the fussy details and atomicity concerns of tracking the information on stable storage.
Surprisingly, there is some controversy over this, but I believe it's the right design decision. I'm willing to change that however if there are legitimate technical concerns. In that event, I'd appreciate constructive suggestions about what should replace it.
For now, the daemon is only suitable for single-host configurations. My plan is to later extend this to be suitable for clustered configurations as well.
The code is still a little rough, so be gentle. It also lacks things like a manpage. I plan to add all that before doing a "formal" patch submission, but I wanted to get some early review of the overall design before to spend a lot of time knocking off the rough edges.
Jeff Layton (7):
autoconf: fix up libevent autoconf test
nfsdcld: add client tracking daemon stub
nfsdcld: add autoconf goop for sqlite
nfsdcld: add routines for a sqlite backend database
nfsdcld: add remove functionality
nfsdcld: add check/update functionality
nfsdcld: add function to remove unreclaimed client records
aclocal/libevent.m4 | 3 +- aclocal/libsqlite3.m4 | 33 ++++ configure.ac | 23 +++ utils/Makefile.am | 4 + utils/idmapd/Makefile.am | 2 +- utils/nfsdcld/Makefile.am | 14 ++ utils/nfsdcld/nfsdcld.c | 332 ++++++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.c | 388 +++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 30 ++++ 9 files changed, 827 insertions(+), 2 deletions(-) create mode 100644 aclocal/libsqlite3.m4 create mode 100644 utils/nfsdcld/Makefile.am create mode 100644 utils/nfsdcld/nfsdcld.c create mode 100644 utils/nfsdcld/sqlite.c create mode 100644 utils/nfsdcld/sqlite.h
PATCH v2 1/7 autoconf: fix up libevent autoconf test
Have it set LIBEVENT to -levent and use that in the Makefiles instead of hardcoding it.
--- aclocal/libevent.m4 | 3 ++- utils/idmapd/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
aclocal/libevent.m4 +2 -1
@@ -2,8 +2,9 @@ dnl Checks for libevent AC_DEFUN([AC_LIBEVENT], [ dnl Check for libevent, but do not add -levent to LIBS - AC_CHECK_LIB([event], [event_dispatch], [libevent=1], + AC_CHECK_LIB([event], [event_dispatch], [LIBEVENT=-levent], [AC_MSG_ERROR([libevent not found.])]) + AC_SUBST(LIBEVENT) AC_CHECK_HEADERS([event.h], , [AC_MSG_ERROR([libevent headers not found.])])
utils/idmapd/Makefile.am +1 -1
@@ -16,7 +16,7 @@ idmapd_SOURCES = \ nfs_idmap.h \ queue.h -idmapd_LDADD = -levent -lnfsidmap ../../support/nfs/libnfs.a +idmapd_LDADD = $(LIBEVENT) -lnfsidmap ../../support/nfs/libnfs.a MAINTAINERCLEANFILES = Makefile.in
Signature · 1 line
1.7.1
PATCH v2 2/7 nfsdcld: add client tracking daemon stub
In reply to Jeff LaytonThis program opens and "listens" on the new nfsd/cld rpc_pipefs pipe. The code here doesn't actually do anything on stable storage yet. That will be added in a later patch.
--- configure.ac | 1 + utils/Makefile.am | 1 + utils/nfsdcld/Makefile.am | 14 +++ utils/nfsdcld/nfsdcld.c | 240 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 256 insertions(+), 0 deletions(-) create mode 100644 utils/nfsdcld/Makefile.am create mode 100644 utils/nfsdcld/nfsdcld.c
configure.ac +1 -0
@@ -458,6 +458,7 @@ AC_CONFIG_FILES([ tools/nfs-iostat/Makefile utils/Makefile utils/blkmapd/Makefile + utils/nfsdcld/Makefile utils/exportfs/Makefile utils/gssd/Makefile utils/idmapd/Makefile
utils/Makefile.am +1 -0
@@ -22,6 +22,7 @@ OPTDIRS += mount endif SUBDIRS = \ + nfsdcld \ exportfs \ mountd \ nfsd \
utils/nfsdcld/Makefile.am new file +14 -0
@@ -0,0 +1,14 @@ +## Process this file with automake to produce Makefile.in + +#man8_MANS = nfsdcld.man +#EXTRA_DIST = $(man8_MANS) + +AM_CFLAGS += -D_LARGEFILE64_SOURCE +sbin_PROGRAMS = nfsdcld + +nfsdcld_SOURCES = nfsdcld.c + +nfsdcld_LDADD = ../../support/nfs/libnfs.a $(LIBEVENT) + +MAINTAINERCLEANFILES = Makefile.in +
utils/nfsdcld/nfsdcld.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 3/7 nfsdcld: add autoconf goop for sqlite
In reply to Jeff LaytonMostly cribbed from Chuck Lever's new-statd rewrite a few years ago...
--- aclocal/libsqlite3.m4 | 33 +++++++++++++++++++++++++++++++++ configure.ac | 22 ++++++++++++++++++++++ utils/Makefile.am | 5 ++++- 3 files changed, 59 insertions(+), 1 deletions(-) create mode 100644 aclocal/libsqlite3.m4
aclocal/libsqlite3.m4 new file +33 -0
@@ -0,0 +1,33 @@ +dnl Checks for matching sqlite3 header and library, and +dnl sufficient sqlite3 version. +dnl +AC_DEFUN([AC_SQLITE3_VERS], [ + AC_CHECK_HEADERS([sqlite3.h], ,) + + dnl look for the library; do not add to LIBS if found + AC_CHECK_LIB([sqlite3], [sqlite3_libversion_number], [LIBSQLITE=-lsqlite3], ,) + AC_SUBST(LIBSQLITE) + + AC_MSG_CHECKING(for suitable sqlite3 version) + + AC_CACHE_VAL([libsqlite3_cv_is_recent], + [ + saved_LIBS="$LIBS" + LIBS=-lsqlite3 + AC_TRY_RUN([ + #include <stdio.h> + #include <sqlite3.h> + int main() + { + int vers = sqlite3_libversion_number(); + + return vers != SQLITE_VERSION_NUMBER || + vers < 3003000; + } + ], [libsqlite3_cv_is_recent=yes], [libsqlite3_cv_is_recent=no], + [libsqlite3_cv_is_recent=unknown]) + LIBS="$saved_LIBS"]) + + AC_MSG_RESULT($libsqlite3_cv_is_recent) + AM_CONDITIONAL(CONFIG_SQLITE3, [test "$libsqlite3_cv_is_recent" = "yes"]) +])dnl
configure.ac +22 -0
@@ -186,6 +186,12 @@ else AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mount" = "yes"]) fi +AC_ARG_ENABLE(nfsdcld, + [AC_HELP_STRING([--enable-nfsdcld], + [Create nfsdcld NFSv4 clientid tracking daemon. <:@default=yes@:>@])], + enable_nfsdcld=$enableval, + enable_nfsdcld="maybe") + dnl Check for TI-RPC library and headers AC_LIBTIRPC
@@ -259,6 +265,9 @@ if test "$enable_nfsv4" = yes; then dnl check for the keyutils libraries and headers AC_KEYUTILS + dnl Check for sqlite3 + AC_SQLITE3_VERS + dnl librpcsecgss already has a dependency on libgssapi, dnl but we need to make sure we get the right version if test "$enable_gss" = yes; then
@@ -328,6 +337,19 @@ fi dnl Check for IPv6 support AC_IPV6 +dnl Decide what to do with nfsdcld based on sqlite3 test result +if test "$enable_nfsv4" = "yes" -a "$libsqlite3_cv_is_recent" != "yes" ; then + if test "$enable_nfsdcld" = "yes"; then + AC_MSG_ERROR([nfsdcld requires sqlite3]) + elif test "$enable_nfsdcld" != "no"; then + AC_MSG_WARN([nfsdcld requires sqlite3, autodisabling it]) + enable_nfsdcld="no" + fi +fi + +dnl Now set CONFIG_NFSDCLD properly +AM_CONDITIONAL(CONFIG_NFSDCLD, [test "$enable_nfsdcld" != "no" ]) + dnl ************************************************************* dnl Check for headers dnl *************************************************************
utils/Makefile.am +4 -1
@@ -21,8 +21,11 @@ if CONFIG_MOUNT OPTDIRS += mount endif +if CONFIG_NFSDCLD +OPTDIRS += nfsdcld +endif + SUBDIRS = \ - nfsdcld \ exportfs \ mountd \ nfsd \
Signature · 1 line
1.7.1
PATCH v2 4/7 nfsdcld: add routines for a sqlite backend database
In reply to Jeff LaytonRather than roll our own "storage engine", use sqlite instead. It fits the bill nicely as it does:
- durable on-disk storage
- the ability to constrain record uniqueness
- a facility for collating and searching the host records
...it does add a build dependency to nfs-utils, but almost all modern distros provide those packages.
The current incarnation of this code dynamically links against a provided sqlite library, but we could also consider including their single-file "amalgamation" to reduce dependencies (though with all the caveats that that entails).
--- utils/nfsdcld/Makefile.am | 4 +- utils/nfsdcld/nfsdcld.c | 16 ++- utils/nfsdcld/sqlite.c | 256 +++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 27 +++++ 4 files changed, 297 insertions(+), 6 deletions(-) create mode 100644 utils/nfsdcld/sqlite.c create mode 100644 utils/nfsdcld/sqlite.h
utils/nfsdcld/Makefile.am +2 -2
@@ -6,9 +6,9 @@ AM_CFLAGS += -D_LARGEFILE64_SOURCE sbin_PROGRAMS = nfsdcld -nfsdcld_SOURCES = nfsdcld.c +nfsdcld_SOURCES = nfsdcld.c sqlite.c -nfsdcld_LDADD = ../../support/nfs/libnfs.a $(LIBEVENT) +nfsdcld_LDADD = ../../support/nfs/libnfs.a $(LIBEVENT) $(LIBSQLITE) MAINTAINERCLEANFILES = Makefile.in
utils/nfsdcld/nfsdcld.c +12 -4
@@ -36,6 +36,7 @@#include "xlog.h" #include "nfslib.h" +#include "sqlite.h" #ifndef PIPEFS_DIR #define PIPEFS_DIR NFS_STATEDIR "/rpc_pipefs"
@@ -111,18 +112,20 @@ cld_pipe_reopen(struct cld_client *clnt)static void cld_create (struct cld_client *clnt) { +int ret;ssize_t bsize, wsize;struct cld_msg *cmsg = &clnt->cl_msg; -xlog (D_GENERAL ,"%s: create client record" , __func__); +xlog (D_GENERAL ,"%s: create client record." , __func__); -/* FIXME: create client record on storage here */ + ret =sqlite_insert_client (cmsg->cm_u.cm_name.cn_id, + cmsg->cm_u.cm_name.cn_len); -/* set up reply */ - cmsg->cm_status =0 ; + cmsg->cm_status = ret ? -EREMOTEIO : ret; bsize =sizeof (*cmsg); +xlog (D_GENERAL ,"Doing downcall with status %d" , cmsg->cm_status); wsize =atomicio ((void *)write, clnt->cl_fd, cmsg, bsize);if (wsize != bsize) { xlog(L_ERROR, "%s: problem writing to cld pipe (%ld): %m",
@@ -221,6 +224,11 @@ main(int argc, char **argv) }/* set up storage db */ + rc =sqlite_maindb_init (); +if (rc) { +xlog (L_ERROR ,"Failed to open main database: %d" , rc); + goto out; + }/* set up event handler */ fd =cld_pipe_open (&clnt);
utils/nfsdcld/sqlite.c new file +256 -0
256 lines not on this page · raw message
utils/nfsdcld/sqlite.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* 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_ + +void sqlite_set_topdir (char *topdir); +int sqlite_maindb_init (void ); +int sqlite_insert_client (const unsigned char *clname,const size_t namelen); + +#endif /* _SQLITE_H */
Signature · 1 line
1.7.1
PATCH v2 5/7 nfsdcld: add remove functionality
In reply to Jeff LaytonAllow the kernel to ask for removal of a client record.
--- utils/nfsdcld/nfsdcld.c | 28 ++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.c | 35 +++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 1 + 3 files changed, 64 insertions(+), 0 deletions(-)
utils/nfsdcld/nfsdcld.c +28 -0
@@ -135,6 +135,32 @@ cld_create(struct cld_client *clnt) }static void +cld_remove (struct cld_client *clnt) +{ +int ret; +ssize_t bsize, wsize; +struct cld_msg *cmsg = &clnt->cl_msg; + +xlog (D_GENERAL ,"%s: remove client record." , __func__); + + ret =sqlite_remove_client (cmsg->cm_u.cm_name.cn_id, + cmsg->cm_u.cm_name.cn_len); + +/* set up reply */ + cmsg->cm_status = ret ? -EREMOTEIO : ret; + + bsize =sizeof (*cmsg); + +xlog (D_GENERAL ,"Doing downcall with status %d" , cmsg->cm_status); + wsize =atomicio ((void *)write, clnt->cl_fd, cmsg, bsize); +if (wsize != bsize) { +xlog (L_ERROR ,"%s: problem writing to cld pipe (%ld): %m" , + __func__, wsize); +cld_pipe_reopen (clnt); + } +} + +static void cldcb (int UNUSED (fd ),short which,void *data) {ssize_t len;
@@ -156,6 +182,8 @@ cldcb(int UNUSED(fd), short which, void *data)cld_create (clnt);break ;case Cld_Expire: +cld_remove (clnt); +break ;case Cld_NrToReclaim:case Cld_Allow:case Cld_GraceDone:
utils/nfsdcld/sqlite.c +35 -0
@@ -254,3 +254,38 @@ out_err:sqlite3_finalize (stmt);return ret; } + +/* Remove a client record */ +int +sqlite_remove_client (const unsigned char *clname,const size_t namelen) +{ +int ret; +sqlite3_stmt *stmt =NULL ; + + ret =sqlite3_prepare_v2 (dbh,"DELETE FROM clients WHERE id==?" ,-1 , + &stmt,NULL ); +if (ret !=SQLITE_OK ) { +xlog (D_GENERAL ,"Statement prepare failed: %s" , +sqlite3_errmsg (dbh)); + goto out_err; + } + + ret =sqlite3_bind_blob (stmt,1 , (const void *)clname, namelen, +SQLITE_STATIC ); +if (ret !=SQLITE_OK ) { +xlog (D_GENERAL ,"Bind blob failed: %s" ,sqlite3_errmsg (dbh)); + goto out_err; + } + + ret =sqlite3_step (stmt); +if (ret ==SQLITE_DONE ) + ret =SQLITE_OK ; +else +xlog (D_GENERAL ,"Unexpected return code from delete: %s" , +sqlite3_errmsg (dbh)); + +out_err: +xlog (D_GENERAL ,"%s: returning %d" , __func__, ret); +sqlite3_finalize (stmt); +return ret; +}
utils/nfsdcld/sqlite.h +1 -0
@@ -23,5 +23,6 @@void sqlite_set_topdir (char *topdir);int sqlite_maindb_init (void );int sqlite_insert_client (const unsigned char *clname,const size_t namelen); +int sqlite_remove_client (const unsigned char *clname,const size_t namelen);#endif /* _SQLITE_H */
Signature · 1 line
1.7.1
PATCH v2 6/7 nfsdcld: add check/update functionality
In reply to Jeff LaytonAdd functions to check whether a client is allowed to reclaim, and update its timestamp in the DB if so. We do this with an UPDATE OR FAIL SQL statement. If the update fails for any reason (like, say the record doesn't exist), then the kernel can disallow the reclaim.
--- utils/nfsdcld/nfsdcld.c | 30 +++++++++++++++++++- utils/nfsdcld/sqlite.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 1 + 3 files changed, 99 insertions(+), 1 deletions(-)
utils/nfsdcld/nfsdcld.c +29 -1
@@ -161,6 +161,32 @@ cld_remove(struct cld_client *clnt) }static void +cld_check (struct cld_client *clnt) +{ +int ret; +ssize_t bsize, wsize; +struct cld_msg *cmsg = &clnt->cl_msg; + +xlog (D_GENERAL ,"%s: check client record" , __func__); + + ret =sqlite_check_client (cmsg->cm_u.cm_name.cn_id, + cmsg->cm_u.cm_name.cn_len); + +/* set up reply */ + cmsg->cm_status = ret ? -EACCES : ret; + + bsize =sizeof (*cmsg); + +xlog (D_GENERAL ,"Doing downcall with status %d" , cmsg->cm_status); + wsize =atomicio ((void *)write, clnt->cl_fd, cmsg, bsize); +if (wsize != bsize) { +xlog (L_ERROR ,"%s: problem writing to cld pipe (%ld): %m" , + __func__, wsize); +cld_pipe_reopen (clnt); + } +} + +static void cldcb (int UNUSED (fd ),short which,void *data) {ssize_t len;
@@ -184,8 +210,10 @@ cldcb(int UNUSED(fd), short which, void *data)case Cld_Expire:cld_remove (clnt);break ; -case Cld_NrToReclaim:case Cld_Allow: +cld_check (clnt); +break ; +case Cld_NrToReclaim:case Cld_GraceDone:xlog_warn ("%s: command %u is not yet implemented" , __func__, cmsg->cm_cmd);
utils/nfsdcld/sqlite.c +69 -0
72 lines not on this page · raw message
utils/nfsdcld/sqlite.h +1 -0
@@ -24,5 +24,6 @@ void sqlite_set_topdir(char *topdir);int sqlite_maindb_init (void );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);#endif /* _SQLITE_H */
Signature · 1 line
1.7.1
PATCH v2 7/7 nfsdcld: add function to remove unreclaimed client records
In reply to Jeff LaytonThis should remove any client record that has a timestamp prior to the given time.
Eventually, this call will need to be made cluster aware when this is run in a clustered configuration. For now, this is only suitable for single-host configurations.
--- utils/nfsdcld/nfsdcld.c | 30 +++++++++++++++++++++++++++++- utils/nfsdcld/sqlite.c | 28 ++++++++++++++++++++++++++++ utils/nfsdcld/sqlite.h | 1 + 3 files changed, 58 insertions(+), 1 deletions(-)
utils/nfsdcld/nfsdcld.c +29 -1
@@ -187,6 +187,32 @@ cld_check(struct cld_client *clnt) }static void +cld_gracedone (struct cld_client *clnt) +{ +int ret; +ssize_t bsize, wsize; +struct cld_msg *cmsg = &clnt->cl_msg; + +xlog (D_GENERAL ,"%s: grace done. cm_gracetime=%ld" , __func__, + cmsg->cm_u.cm_gracetime); + + ret =sqlite_remove_unreclaimed (cmsg->cm_u.cm_gracetime); + +/* set up reply: downcall with 0 status */ + cmsg->cm_status = ret ? -EREMOTEIO : ret; + + bsize =sizeof (*cmsg); + +xlog (D_GENERAL ,"Doing downcall with status %d" , cmsg->cm_status); + wsize =atomicio ((void *)write, clnt->cl_fd, cmsg, bsize); +if (wsize != bsize) { +xlog (L_ERROR ,"%s: problem writing to cld pipe (%ld): %m" , + __func__, wsize); +cld_pipe_reopen (clnt); + } +} + +static void cldcb (int UNUSED (fd ),short which,void *data) {ssize_t len;
@@ -213,8 +239,10 @@ cldcb(int UNUSED(fd), short which, void *data)case Cld_Allow:cld_check (clnt);break ; -case Cld_NrToReclaim:case Cld_GraceDone: +cld_gracedone (clnt); +break ; +case Cld_NrToReclaim:xlog_warn ("%s: command %u is not yet implemented" , __func__, cmsg->cm_cmd);break ;
utils/nfsdcld/sqlite.c +28 -0
@@ -38,6 +38,7 @@#include "config.h" #endif /* HAVE_CONFIG_H */ +#include <dirent.h> #include <errno.h> #include <event.h> #include <stdbool.h>
@@ -358,3 +359,30 @@ out_err:sqlite3_finalize (stmt);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 (D_GENERAL ,"Delete failed: %s" , err); + +xlog (D_GENERAL ,"%s: returning %d" , __func__, ret); +sqlite3_free (err); +return ret; +}
utils/nfsdcld/sqlite.h +1 -0
@@ -25,5 +25,6 @@ int sqlite_maindb_init(void);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);#endif /* _SQLITE_H */
Signature · 1 line
1.7.1
Re: [PATCH v2 3/7] nfsdcld: add autoconf goop for sqlite
In reply to Jeff LaytonQuoted 2 lines · On Thu, 15 Dec 2011 13:43:57 -0500 Jeff Layton <[email protected]> wrote:
Mostly cribbed from Chuck Lever's new-statd rewrite a few years ago...
Sending this to Bruce and Steve, but cc'ing the list in case other people have thoughts...
I have a couple of questions about configure/build behavior when the dependencies aren't present on the build system. The patch below autodisables the building of nfsdcld when sqlite isn't there or isn't functional, etc.
This is probably fine initially, but eventually I'd like to see the old state tracking code go away. At that point, this daemon will be required for NFSv4 serving.
Some questions:
1) does anyone have a problem with deprecating the old state tracking code? I'd prefer we not maintain it in perpetuity, but maybe there's an argument for keeping it around?
2) assuming we do want to eventually deprecate the old code. When should we plan to do this. Assuming that this goes into 3.3 and we add sufficient printk warnings when the old tracker is used, the earliest we could remove it is 3.5. Is that too aggressive?
3) again, assuming that we want to deprecate the old code eventually, does it make sense to autodisable the daemon when the build deps aren't sufficient for it? With it be better to make the build error out when --enable-nfsv4 is "yes" and not bother with a new --enable option for this daemon?
I probably will also need to add a autoconf test for inotify too. Having an answer to these questions may save me from a lot of complex autoconf hacking....
Thanks,
Quoted 111 lines
Signed-off-by Jeff Layton <[email protected]>--- aclocal/libsqlite3.m4 | 33 +++++++++++++++++++++++++++++++++ configure.ac | 22 ++++++++++++++++++++++ utils/Makefile.am | 5 ++++- 3 files changed, 59 insertions(+), 1 deletions(-) create mode 100644 aclocal/libsqlite3.m4aclocal/libsqlite3.m4 new file +33
-0@@ -0,0 +1,33 @@ +dnl Checks for matching sqlite3 header and library, and +dnl sufficient sqlite3 version. +dnl +AC_DEFUN([AC_SQLITE3_VERS], [ + AC_CHECK_HEADERS([sqlite3.h], ,) + + dnl look for the library; do not add to LIBS if found + AC_CHECK_LIB([sqlite3], [sqlite3_libversion_number], [LIBSQLITE=-lsqlite3], ,) + AC_SUBST(LIBSQLITE) + + AC_MSG_CHECKING(for suitable sqlite3 version) + + AC_CACHE_VAL([libsqlite3_cv_is_recent], + [ + saved_LIBS="$LIBS" + LIBS=-lsqlite3 + AC_TRY_RUN([ + #include <stdio.h> + #include <sqlite3.h> + int main() + { + int vers = sqlite3_libversion_number(); + + return vers != SQLITE_VERSION_NUMBER || + vers < 3003000; + } + ], [libsqlite3_cv_is_recent=yes], [libsqlite3_cv_is_recent=no], + [libsqlite3_cv_is_recent=unknown]) + LIBS="$saved_LIBS"]) + + AC_MSG_RESULT($libsqlite3_cv_is_recent) + AM_CONDITIONAL(CONFIG_SQLITE3, [test "$libsqlite3_cv_is_recent" = "yes"]) +])dnlconfigure.ac +22
-0@@ -186,6 +186,12 @@ else AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mount" = "yes"]) fi +AC_ARG_ENABLE(nfsdcld, + [AC_HELP_STRING([--enable-nfsdcld], + [Create nfsdcld NFSv4 clientid tracking daemon. <:@default=yes@:>@])], + enable_nfsdcld=$enableval, + enable_nfsdcld="maybe") + dnl Check for TI-RPC library and headers AC_LIBTIRPC@@ -259,6 +265,9 @@ if test "$enable_nfsv4" = yes; then dnl check for the keyutils libraries and headers AC_KEYUTILS + dnl Check for sqlite3 + AC_SQLITE3_VERS + dnl librpcsecgss already has a dependency on libgssapi, dnl but we need to make sure we get the right version if test "$enable_gss" = yes; then@@ -328,6 +337,19 @@ fi dnl Check for IPv6 support AC_IPV6 +dnl Decide what to do with nfsdcld based on sqlite3 test result +if test "$enable_nfsv4" = "yes" -a "$libsqlite3_cv_is_recent" != "yes" ; then + if test "$enable_nfsdcld" = "yes"; then + AC_MSG_ERROR([nfsdcld requires sqlite3]) + elif test "$enable_nfsdcld" != "no"; then + AC_MSG_WARN([nfsdcld requires sqlite3, autodisabling it]) + enable_nfsdcld="no" + fi +fi + +dnl Now set CONFIG_NFSDCLD properly +AM_CONDITIONAL(CONFIG_NFSDCLD, [test "$enable_nfsdcld" != "no" ]) + dnl ************************************************************* dnl Check for headers dnl *************************************************************utils/Makefile.am +4
-1@@ -21,8 +21,11 @@ if CONFIG_MOUNT OPTDIRS += mount endif +if CONFIG_NFSDCLD +OPTDIRS += nfsdcld +endif + SUBDIRS = \ - nfsdcld \ exportfs \ mountd \ nfsd \
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v2 3/7] nfsdcld: add autoconf goop for sqlite
Quoted 18 lines · Jeff Layton
Quoted 2 lines · On Thu, 15 Dec 2011 13:43:57 -0500 Jeff Layton <[email protected]> wrote:
Mostly cribbed from Chuck Lever's new-statd rewrite a few years ago...
Sending this to Bruce and Steve, but cc'ing the list in case other people have thoughts...
I have a couple of questions about configure/build behavior when the dependencies aren't present on the build system. The patch below autodisables the building of nfsdcld when sqlite isn't there or isn't functional, etc.
This is probably fine initially, but eventually I'd like to see the old state tracking code go away. At that point, this daemon will be required for NFSv4 serving.
Quoted 5 lines
Some questions:
1) does anyone have a problem with deprecating the old state tracking code? I'd prefer we not maintain it in perpetuity, but maybe there's an argument for keeping it around?
Just the usual: the kernel community depends for some of its testing on people being willing to upgrade to the latest kernel. So we try to ensure they can just drop in a new kernel without breaking a random subsystem that (as non-NFS specialists) they don't ordinarily have to think about....
Quoted 4 lines
2) assuming we do want to eventually deprecate the old code. When should we plan to do this. Assuming that this goes into 3.3 and we add sufficient printk warnings when the old tracker is used, the earliest we could remove it is 3.5. Is that too aggressive?
That sounds a little aggressive. It may depend on how much trouble we find it is to keep it up to date.
Then again I guess it depends how obnoxiously we fail in the case the new daemon isn't running.
Quoted 5 lines
3) again, assuming that we want to deprecate the old code eventually, does it make sense to autodisable the daemon when the build deps aren't sufficient for it? With it be better to make the build error out when --enable-nfsv4 is "yes" and not bother with a new --enable option for this daemon?
Could be. Steved gets to maintain this, so I guess it's his call....
--b.
Quoted 122 lines
I probably will also need to add a autoconf test for inotify too. Having an answer to these questions may save me from a lot of complex autoconf hacking....
Thanks,
Quoted 111 lines
Signed-off-by Jeff Layton <[email protected]>--- aclocal/libsqlite3.m4 | 33 +++++++++++++++++++++++++++++++++ configure.ac | 22 ++++++++++++++++++++++ utils/Makefile.am | 5 ++++- 3 files changed, 59 insertions(+), 1 deletions(-) create mode 100644 aclocal/libsqlite3.m4aclocal/libsqlite3.m4 new file +33
-0@@ -0,0 +1,33 @@ +dnl Checks for matching sqlite3 header and library, and +dnl sufficient sqlite3 version. +dnl +AC_DEFUN([AC_SQLITE3_VERS], [ + AC_CHECK_HEADERS([sqlite3.h], ,) + + dnl look for the library; do not add to LIBS if found + AC_CHECK_LIB([sqlite3], [sqlite3_libversion_number], [LIBSQLITE=-lsqlite3], ,) + AC_SUBST(LIBSQLITE) + + AC_MSG_CHECKING(for suitable sqlite3 version) + + AC_CACHE_VAL([libsqlite3_cv_is_recent], + [ + saved_LIBS="$LIBS" + LIBS=-lsqlite3 + AC_TRY_RUN([ + #include <stdio.h> + #include <sqlite3.h> + int main() + { + int vers = sqlite3_libversion_number(); + + return vers != SQLITE_VERSION_NUMBER || + vers < 3003000; + } + ], [libsqlite3_cv_is_recent=yes], [libsqlite3_cv_is_recent=no], + [libsqlite3_cv_is_recent=unknown]) + LIBS="$saved_LIBS"]) + + AC_MSG_RESULT($libsqlite3_cv_is_recent) + AM_CONDITIONAL(CONFIG_SQLITE3, [test "$libsqlite3_cv_is_recent" = "yes"]) +])dnlconfigure.ac +22
-0@@ -186,6 +186,12 @@ else AM_CONDITIONAL(MOUNT_CONFIG, [test "$enable_mount" = "yes"]) fi +AC_ARG_ENABLE(nfsdcld, + [AC_HELP_STRING([--enable-nfsdcld], + [Create nfsdcld NFSv4 clientid tracking daemon. <:@default=yes@:>@])], + enable_nfsdcld=$enableval, + enable_nfsdcld="maybe") + dnl Check for TI-RPC library and headers AC_LIBTIRPC@@ -259,6 +265,9 @@ if test "$enable_nfsv4" = yes; then dnl check for the keyutils libraries and headers AC_KEYUTILS + dnl Check for sqlite3 + AC_SQLITE3_VERS + dnl librpcsecgss already has a dependency on libgssapi, dnl but we need to make sure we get the right version if test "$enable_gss" = yes; then@@ -328,6 +337,19 @@ fi dnl Check for IPv6 support AC_IPV6 +dnl Decide what to do with nfsdcld based on sqlite3 test result +if test "$enable_nfsv4" = "yes" -a "$libsqlite3_cv_is_recent" != "yes" ; then + if test "$enable_nfsdcld" = "yes"; then + AC_MSG_ERROR([nfsdcld requires sqlite3]) + elif test "$enable_nfsdcld" != "no"; then + AC_MSG_WARN([nfsdcld requires sqlite3, autodisabling it]) + enable_nfsdcld="no" + fi +fi + +dnl Now set CONFIG_NFSDCLD properly +AM_CONDITIONAL(CONFIG_NFSDCLD, [test "$enable_nfsdcld" != "no" ]) + dnl ************************************************************* dnl Check for headers dnl *************************************************************utils/Makefile.am +4
-1@@ -21,8 +21,11 @@ if CONFIG_MOUNT OPTDIRS += mount endif +if CONFIG_NFSDCLD +OPTDIRS += nfsdcld +endif + SUBDIRS = \ - nfsdcld \ exportfs \ mountd \ nfsd \Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v2 3/7] nfsdcld: add autoconf goop for sqlite
Quoted 25 lines · On Tue, 20 Dec 2011 16:18:38 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 18 lines · Jeff Layton
Quoted 2 lines · On Thu, 15 Dec 2011 13:43:57 -0500 Jeff Layton <[email protected]> wrote:
Mostly cribbed from Chuck Lever's new-statd rewrite a few years ago...
Sending this to Bruce and Steve, but cc'ing the list in case other people have thoughts...
I have a couple of questions about configure/build behavior when the dependencies aren't present on the build system. The patch below autodisables the building of nfsdcld when sqlite isn't there or isn't functional, etc.
This is probably fine initially, but eventually I'd like to see the old state tracking code go away. At that point, this daemon will be required for NFSv4 serving.
Quoted 5 lines
Some questions:
1) does anyone have a problem with deprecating the old state tracking code? I'd prefer we not maintain it in perpetuity, but maybe there's an argument for keeping it around?
Quoted 6 lines
Just the usual: the kernel community depends for some of its testing on people being willing to upgrade to the latest kernel. So we try to ensure they can just drop in a new kernel without breaking a random subsystem that (as non-NFS specialists) they don't ordinarily have to think about....
There's the rub. The legacy scheme is completely transparent for most users. There's no daemon involved, so they don't need to set anything up. That's not the case with the new scheme.
If we do want to eventually deprecate the old code, what I think we'd do is add printk's that say we're deprecating the old code in release 3.x, and to ensure that nfsdcld is running. We'd want to do that for at least 2 releases before removing anything, but could do so for longer too.
Quoted 11 lines
Quoted 4 lines
2) assuming we do want to eventually deprecate the old code. When should we plan to do this. Assuming that this goes into 3.3 and we add sufficient printk warnings when the old tracker is used, the earliest we could remove it is 3.5. Is that too aggressive?
That sounds a little aggressive. It may depend on how much trouble we find it is to keep it up to date.
Then again I guess it depends how obnoxiously we fail in the case the new daemon isn't running.
Ok, it sounds like you're leaning toward keeping the old code around for now and not forcing anyone onto the new. The only downside I can see is the maintenance hassle (which is fairly low for now), and the fact that it adds a new dimension to the testing matrix. If we can live with that, then I won't worry about deprecating anything at this point.
Signature · 1 line
Jeff Layton <[email protected]>