mountd/exportfs/nfsref: netlink loose ends and bug fixes
Subsystems (4)
Jeff Layton
maintainerv2 cover mountd/exportfs/nfsref: netlink loose ends and bug fixes
There are some cases where mountd will use /proc even when netlink is available, and agentic review of this code also found some bugs.
This set fixes it to use netlink in more situations when it's available, and also throws in some bugfixes and cleanups. The last patch in the series adds a MAINTAINERS file and the machinery that allows b4 workflows to work properly with nfs-utils.
---
Changes in v2:
- Add Fixes: tag to patch that forces a path-based uuid
- Drop the currently unused max_attr field from nfsd_export_policy
- Fix default value of $output_roles in get_maintainer.pl
- Use script location to determine top of git tree
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jeff Layton (7):
mountd: accept -L for --no-netlink
mountd: prime the kernel caches over netlink on MOUNT
exports: describe the kernel's export features with struct nfsd_export_policy exportfs/mountd/exportd: get export features from the netlink policy
nfsref: flush the export caches with cache_flush() mountd/exportd: always give pseudo-root directories a path-based uuid Add MAINTAINERS file and get_maintainer.pl
MAINTAINERS | 58 +++++++ Makefile.am | 2 + configure.ac | 24 +++ scripts/get_maintainer.pl | 370 ++++++++++++++++++++++++++++++++++++++++ support/export/Makefile.am | 4 +- support/export/cache.c | 124 ++++++++++++-- support/export/export_policy.c | 258 ++++++++++++++++++++++++++++ support/export/v4root.c | 22 +-- support/include/exportfs.h | 13 +- support/include/nfs/export.h | 5 + support/junction/export-cache.c | 82 +-------- support/nfs/exports.c | 47 +++-- tests/Makefile.am | 2 +- tests/t0003-get-maintainer.sh | 140 +++++++++++++++ utils/exportfs/exportfs.c | 2 + utils/mountd/mountd.c | 2 +- utils/nfsref/Makefile.am | 4 +- utils/nfsref/nfsref.c | 5 + 18 files changed, 1034 insertions(+), 130 deletions(-)
---
base-commit: 5090e0bb662c53b4552b28b121ac2c2c434adb2e
change-id: 20261016-netlink-noproc-8e3bb540d266
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH v2 1/7 mountd: accept -L for --no-netlink
The -L short option was documented and handled but left out of shortopts, so "rpc.mountd -L" prints the usage and exits 1.
--- utils/mountd/mountd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/mountd/mountd.c +1 -1
@@ -81,7 +81,7 @@ static struct option longopts[] = { "apply-root-cred", 0, 0, 'c' }, { NULL, 0, 0, 0 } }; -static char shortopts[] ="o:nFd:p:P:hH:N:V:vurs:t:gliT:c" ; +static char shortopts[] ="o:nFd:p:P:hH:N:V:vurs:t:gliLT:c" ;#define NFSVERSBIT (vers) (0x1 << (vers - 1))#define NFSVERSBIT_ALL (NFSVERSBIT(2) | NFSVERSBIT(3) | NFSVERSBIT(4))
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 2/7 mountd: prime the kernel caches over netlink on MOUNT
In reply to Jeff Laytoncache_export() writes the ip_map and svc_export entries for a MNT request to the /proc channels even when mountd is using netlink. Any export state that only netlink can carry is then lost: the /proc write replaces the entry the netlink upcall filled.
When the netlink command sockets are open, send both entries as unsolicited SET_REQS instead. The kernel's doit handlers look up or create the entry, so they do not need a pending request.
- nl_add_ip_map() takes the expiry ttl, so the MOUNT path keeps using the export's e_ttl.
- crossmnt submounts go over netlink too.
- The /proc path is unchanged for no-netlink and fallback.
--- support/export/cache.c | 113 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 14 deletions(-)
support/export/cache.c +99 -14
@@ -2877,7 +2877,7 @@ static int cache_nl_get_ip_map_reqs(struct ip_map_req **reqs_out, }static int nl_add_ip_map (struct nl_msg *msg,char *class,char *addr, -char *domain) +char *domain,int ttl) {struct nlattr *nest;time_t now =time (0 );
@@ -2888,8 +2888,7 @@ static int nl_add_ip_map(struct nl_msg *msg, char *class, char *addr,if (nla_put_string (msg,SUNRPC_A_IP_MAP_CLASS , class) <0 ||nla_put_string (msg,SUNRPC_A_IP_MAP_ADDR , addr) <0 || -nla_put_u64 (msg,SUNRPC_A_IP_MAP_EXPIRY , - now + default_ttl) <0 ) +nla_put_u64 (msg,SUNRPC_A_IP_MAP_EXPIRY , now + ttl) <0 ) goto nla_failure;if (domain) {
@@ -2964,7 +2963,8 @@ static void cache_nl_process_ip_map(void) } } -if (nl_add_ip_map (msg, class, ipaddr, domain) <0 ) { +if (nl_add_ip_map (msg, class, ipaddr, domain, + default_ttl) <0 ) {cache_nl_flush_reqs (sunrpc_nl_cmd_sock, msg,"ip_map" );nlmsg_free (msg); msg = cache_nl_new_msg(sunrpc_nl_family,
@@ -2975,7 +2975,8 @@ static void cache_nl_process_ip_map(void)nfs_freeaddrinfo (tmp); goto out_free; } -if (nl_add_ip_map (msg, class, ipaddr, domain) <0 ) +if (nl_add_ip_map (msg, class, ipaddr, domain, + default_ttl) <0 )xlog (L_WARNING ,"%s: skipping oversized " "entry for %s" , __func__, ipaddr); }
@@ -3952,14 +3953,61 @@ int cache_process(fd_set *readfds)* % echo $domain $path $[now+DEFAULT_TTL] $options $anonuid $anongid $fsid > /proc/net/rpc/nfsd.export/channel */ +/* +* Push one positive svc_export entry over netlink. The kernel takes an entry +* it did not ask for, so a MOUNT can prime the cache without /proc. +* +* Returns 0, or -1 if the kernel refused the entry or never saw it. +*/ +static int nl_cache_export (char *domain,char *path,struct exportent *exp) +{ +struct export_attrs ea; +struct nl_msg *msg; +int ret; + +if (export_attrs_build (&ea, path, exp) <0 ) +return -1 ; + + msg =cache_nl_new_msg (nfsd_nl_family, +NFSD_CMD_SVC_EXPORT_SET_REQS ,0 ); +if (!msg) +return -1 ; + +if (nfsd_nl_add_export (msg, domain, path, exp, &ea,0 ) <0 ) { +nlmsg_free (msg); +return -1 ; + } + + ret =cache_nl_set_reqs (nfsd_nl_cmd_sock, msg,NULL ); +nlmsg_free (msg); +if (ret <0 ) +return -1 ; + +xlog (D_AUTH ,"granted access to %s for %s" , + path, *domain =='$' ? domain+1 : domain); +return 0 ; +} + +/* @f is the nfsd.export channel, or -1 when netlink is in use */ +static int export_to_kernel (int f,char *buf,int buflen,char *domain, +char *path,struct exportent *exp) +{ +if (f <0 ) +return nl_cache_export (domain, path, exp); +return dump_to_cache (f, buf, buflen, domain, path, exp,0 ); +} +static int cache_export_ent (char *buf,int buflen,char *domain,struct exportent *exp,char *path) { -int f, err; +int f =-1 , err; - f =open ("/proc/net/rpc/nfsd.export/channel" ,O_WRONLY ); -if (f <0 )return -1 ; +if (!nfsd_nl_cmd_sock) { + f =open ("/proc/net/rpc/nfsd.export/channel" ,O_WRONLY ); +if (f <0 ) +return -1 ; + } - err =dump_to_cache (f, buf, buflen, domain, exp->e_path, exp,0 ); + err =export_to_kernel (f, buf, buflen, domain, exp->e_path, exp);if (err) {xlog (L_WARNING , "Cannot export %s, possibly unsupported filesystem or"
@@ -4000,16 +4048,42 @@ static int cache_export_ent(char *buf, int buflen, char *domain, struct exportencontinue ; dev = stb.st_dev; path[l] =0 ; -dump_to_cache (f, buf, buflen, domain, path, exp,0 ); +export_to_kernel (f, buf, buflen, domain, path, exp); path[l] = c; }break ; } -close (f); +if (f >=0 ) +close (f);return err; } +/* +* Push the IP address -> domain mapping for a MOUNT over netlink. +* +* Returns 0, or -1 if the kernel refused the entry or never saw it. +*/ +static int nl_cache_ip_map (char *addr,char *domain,int ttl) +{ +struct nl_msg *msg; +int ret; + + msg =cache_nl_new_msg (sunrpc_nl_family, +SUNRPC_CMD_IP_MAP_SET_REQS ,0 ); +if (!msg) +return -1 ; + +if (nl_add_ip_map (msg,"nfsd" , addr, domain, ttl) <0 ) { +nlmsg_free (msg); +return -1 ; + } + + ret =cache_nl_set_reqs (sunrpc_nl_cmd_sock, msg,NULL ); +nlmsg_free (msg); +return ret <0 ?-1 :0 ; +} +/** * cache_export - Inform kernel of a new nfs_export * @exp: target nfs_export
@@ -4019,23 +4093,34 @@ int cache_export(nfs_export *exp, char *path) {char ip[INET6_ADDRSTRLEN ];char buf[RPC_CHAN_BUF_SIZE ], *bp; +char *domain = exp->m_client->m_hostname; +char *addr;int blen, f; + addr =host_ntop (get_addrlist (exp->m_client,0 ), ip,sizeof (ip)); + +if (sunrpc_nl_cmd_sock) { +if (nl_cache_ip_map (addr, domain, exp->m_export.e_ttl) <0 ) +return -1 ; +return cache_export_ent (buf,sizeof (buf), domain, + &exp->m_export, path); + } + f =open ("/proc/net/rpc/auth.unix.ip/channel" ,O_WRONLY );if (f <0 )return -1 ; bp = buf, blen =sizeof (buf);qword_add (&bp, &blen,"nfsd" ); -qword_add (&bp, &blen,host_ntop (get_addrlist (exp->m_client,0 ), ip,sizeof (ip))); +qword_add (&bp, &blen, addr);qword_adduint (&bp, &blen,time (0 ) + exp->m_export.e_ttl); -qword_add (&bp, &blen, exp->m_client->m_hostname); +qword_add (&bp, &blen, domain);qword_addeol (&bp, &blen);if (blen <=0 ||cache_write (f, buf, bp - buf) != bp - buf) blen =-1 ;close (f);if (blen <0 )return -1 ; -return cache_export_ent (buf,sizeof (buf), exp->m_client->m_hostname, &exp->m_export, path); +return cache_export_ent (buf,sizeof (buf), domain, &exp->m_export, path); }/**
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 3/7 exports: describe the kernel's export features with struct nfsd_export_policy
In reply to Jeff LaytonRename struct export_features, filled from /proc/fs/nfsd/export_features, to struct nfsd_export_policy, ahead of filling it from the nfsd netlink policy as well. No functional change.
--- support/export/v4root.c | 6 +++--- support/include/exportfs.h | 9 +++++---- support/nfs/exports.c | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 21 deletions(-)
support/export/v4root.c +3 -3
@@ -127,12 +127,12 @@ v4root_create(char *path, nfs_export *export)static int v4root_support (void ) { -struct export_features *ef; +struct nfsd_export_policy *pol;static int warned =0 ; - ef =get_export_features (); + pol =get_export_features (); -if (ef->flags &NFSEXP_V4ROOT ) +if (pol->flags &NFSEXP_V4ROOT )return 1 ;if (!warned) {xlog (L_WARNING ,"Kernel does not have pseudo root support." );
support/include/exportfs.h +5 -4
@@ -166,12 +166,13 @@ struct addrinfo * host_numeric_addrinfo(const struct sockaddr *sap);struct nfskey *key_lookup (char *hname); -struct export_features { -unsigned int flags; -unsigned int secinfo_flags; +/* What the kernel's export interface accepts */ +struct nfsd_export_policy { +unsigned int flags;/* export flags it knows */ +unsigned int secinfo_flags;/* flags that may vary per flavor */ }; -struct export_features *get_export_features (void ); +struct nfsd_export_policy *get_export_features (void );void fix_pseudoflavor_flags (struct exportent *ep);char *exportent_realpath (struct exportent *eep);int export_test (struct exportent *eep,int with_fsid);
support/nfs/exports.c +14 -14
@@ -235,10 +235,10 @@ static void secinfo_flags_show(FILE *fp, unsigned int flags, unsigned int mask)void secinfo_show (FILE *fp,struct exportent *ep) { -const struct export_features *ef; +const struct nfsd_export_policy *pol;struct sec_entry *p1, *p2; - ef =get_export_features (); + pol =get_export_features ();if (ep->e_secinfo[0 ].flav ==NULL )secinfo_addflavor (find_flavor ("sys" ), ep);
@@ -248,7 +248,7 @@ void secinfo_show(FILE *fp, struct exportent *ep) p2++) {fprintf (fp,":%s" , p2->flav->flavour); } -secinfo_flags_show (fp, p1->flags, ef->secinfo_flags); +secinfo_flags_show (fp, p1->flags, pol->secinfo_flags); } }
@@ -623,12 +623,12 @@ static void clearflags(int mask, unsigned int active, struct exportent *ep)*/ void fix_pseudoflavor_flags (struct exportent *ep) { -struct export_features *ef; +struct nfsd_export_policy *pol;struct sec_entry *p; - ef =get_export_features (); + pol =get_export_features ();for (p = ep->e_secinfo; p->flav; p++) - p->flags |= ep->e_flags & ~ef->secinfo_flags; + p->flags |= ep->e_flags & ~pol->secinfo_flags; }/*
@@ -962,20 +962,20 @@ syntaxerr(char *msg)xlog (L_ERROR ,"%s:%d: syntax error: %s" , efname, efp?efp->x_line:0 , msg); } -struct export_features *get_export_features (void ) +struct nfsd_export_policy *get_export_features (void ) {static char *path ="/proc/fs/nfsd/export_features" ; -static struct export_features ef; +static struct nfsd_export_policy pol;static int cached =0 ;char buf[50 ];int c;int fd;if (cached) -return &ef; +return &pol; - ef.flags =NFSEXP_OLDFLAGS ; - ef.secinfo_flags =NFSEXP_OLD_SECINFO_FLAGS ; + pol.flags =NFSEXP_OLDFLAGS ; + pol.secinfo_flags =NFSEXP_OLD_SECINFO_FLAGS ; fd =open (path,O_RDONLY );if (fd ==-1 )
@@ -985,13 +985,13 @@ struct export_features *get_export_features(void)if (c ==-1 ) goto err; buf[c] =0 ; - c =sscanf (buf,"%x %x" , &ef.flags, &ef.secinfo_flags); + c =sscanf (buf,"%x %x" , &pol.flags, &pol.secinfo_flags);if (c !=2 ) goto err; good: cached =1 ; -return &ef; +return &pol; err:xlog (L_WARNING ,"unexpected error reading %s" , path); -return &ef; +return &pol; }
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 4/7 exportfs/mountd/exportd: get export features from the netlink policy
In reply to Jeff Laytonget_export_features() reads /proc/fs/nfsd/export_features. The nfsd SET_REQS policy already says which export flags the kernel takes:NFSD_A_SVC_EXPORT_FLAGS is masked to exactly that set.
- Add nfsd_export_policy_query() in a new export_policy.c (so cache_flush.o stays free of exports.o): a CTRL_CMD_GETPOLICY dump of SET_REQS, following the op policy -> REQUESTS -> svc_export nest. It fills struct nfsd_export_policy. A good answer is cached.
- The policy cannot give the per-flavor flags (the auth-flavor FLAGS mask is the full set), so use NFSEXP_SECINFO_FLAGS; it is the same on every kernel with the netlink export interface.
- Add set_export_features(), and nfsd_nl_load_export_features() to seed it from the policy. exportfs calls it at startup, and mountd/exportd once the nfsd netlink socket opens.
- If netlink cannot answer, get_export_features() still reads /proc.
--- configure.ac | 24 ++++ support/export/Makefile.am | 4 +- support/export/cache.c | 11 +- support/export/export_policy.c | 258 +++++++++++++++++++++++++++++++++++++++++ support/include/exportfs.h | 4 + support/include/nfs/export.h | 5 + support/nfs/exports.c | 33 ++++-- utils/exportfs/exportfs.c | 2 + 8 files changed, 326 insertions(+), 15 deletions(-)
configure.ac +24 -0
@@ -255,6 +255,30 @@ AC_ARG_ENABLE(nfsdcltrack, PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1) PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1) +AC_CACHE_CHECK([for generic netlink policy dump support], + [nfsutils_cv_have_genl_policy_dump], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <linux/genetlink.h> +#include <linux/netlink.h> + ]], [[ + int policy[] = { + CTRL_CMD_GETPOLICY, + CTRL_ATTR_OP_POLICY, + CTRL_ATTR_POLICY, + CTRL_ATTR_OP, + CTRL_ATTR_POLICY_DO, + NL_POLICY_TYPE_ATTR_POLICY_IDX, + NL_POLICY_TYPE_ATTR_MASK, + }; + + return policy[0]; + ]])], + [nfsutils_cv_have_genl_policy_dump=yes], + [nfsutils_cv_have_genl_policy_dump=no])]) +AS_IF([test "x$nfsutils_cv_have_genl_policy_dump" = "xyes"], + [AC_DEFINE([HAVE_GENL_POLICY_DUMP], 1, + [Define to 1 if generic netlink policy dumps are supported])]) + AC_CHECK_HEADERS(linux/nfsd_netlink.h) # ensure the system netlink headers have the latest features
support/export/Makefile.am +2 -2
@@ -12,8 +12,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 \ - cache.c cache_flush.c auth.c v4root.c fsloc.c \ - v4clients.c + cache.c cache_flush.c export_policy.c auth.c v4root.c \ + fsloc.c v4clients.c libexport_a_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) -I$(top_srcdir)/support/reexport \ $(LIBNL3_CFLAGS) $(LIBNLGENL3_CFLAGS)
support/export/cache.c +8 -3
@@ -1375,9 +1375,14 @@ out_free_cmd:static int cache_nfsd_nl_open (void ) { -return cache_genl_open (NFSD_FAMILY_NAME ,NFSD_MCGRP_EXPORTD , - &nfsd_nl_cmd_sock, &nfsd_nl_notify_sock, - &nfsd_nl_family); +int ret; + + ret =cache_genl_open (NFSD_FAMILY_NAME ,NFSD_MCGRP_EXPORTD , + &nfsd_nl_cmd_sock, &nfsd_nl_notify_sock, + &nfsd_nl_family); +if (ret ==0 ) +nfsd_nl_load_export_features (); +return ret; }static int nl_seq_check_handler (struct nl_msg *UNUSED (msg ),void *UNUSED (arg ))
support/export/export_policy.c new file +258 -0
258 lines not on this page · raw message
support/include/exportfs.h +4 -0
@@ -173,6 +173,10 @@ struct nfsd_export_policy { };struct nfsd_export_policy *get_export_features (void ); +void set_export_features (const struct nfsd_export_policy *pol); +int nfsd_export_policy_query (struct nfsd_export_policy *pol); +void nfsd_nl_load_export_features (void ); +void fix_pseudoflavor_flags (struct exportent *ep);char *exportent_realpath (struct exportent *eep);int export_test (struct exportent *eep,int with_fsid);
support/include/nfs/export.h +5 -0
@@ -39,6 +39,11 @@*/ #define NFSEXP_OLD_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \ | NFSEXP_ALLSQUASH) +/* +* Flags that can vary per flavor on every kernel with the netlink export +* interface: +*/ +#define NFSEXP_SECINFO_FLAGS (NFSEXP_OLD_SECINFO_FLAGS | NFSEXP_INSECURE_PORT)/* * Transport layer security policies that are permitted to access
support/nfs/exports.c +23 -10
@@ -962,20 +962,33 @@ syntaxerr(char *msg)xlog (L_ERROR ,"%s:%d: syntax error: %s" , efname, efp?efp->x_line:0 , msg); } + +static struct nfsd_export_policy kernel_policy; +static int kernel_policy_cached; + +/* +* A program that can ask the kernel over netlink hands its answer in here, +* so that get_export_features() need not read /proc. +*/ +void set_export_features (const struct nfsd_export_policy *pol) +{ + kernel_policy = *pol; + kernel_policy_cached =1 ; +} +struct nfsd_export_policy *get_export_features (void ) {static char *path ="/proc/fs/nfsd/export_features" ; -static struct nfsd_export_policy pol; -static int cached =0 ; +struct nfsd_export_policy *pol = &kernel_policy;char buf[50 ];int c;int fd; -if (cached) -return &pol; +if (kernel_policy_cached) +return pol; - pol.flags =NFSEXP_OLDFLAGS ; - pol.secinfo_flags =NFSEXP_OLD_SECINFO_FLAGS ; + pol->flags =NFSEXP_OLDFLAGS ; + pol->secinfo_flags =NFSEXP_OLD_SECINFO_FLAGS ; fd =open (path,O_RDONLY );if (fd ==-1 )
@@ -985,13 +998,13 @@ struct nfsd_export_policy *get_export_features(void)if (c ==-1 ) goto err; buf[c] =0 ; - c =sscanf (buf,"%x %x" , &pol.flags, &pol.secinfo_flags); + c =sscanf (buf,"%x %x" , &pol->flags, &pol->secinfo_flags);if (c !=2 ) goto err; good: - cached =1 ; -return &pol; + kernel_policy_cached =1 ; +return pol; err:xlog (L_WARNING ,"unexpected error reading %s" , path); -return &pol; +return pol; }
utils/exportfs/exportfs.c +2 -0
@@ -218,6 +218,8 @@ main(int argc, char **argv)if (!setup_state_path_names (progname,ETAB ,ETABTMP ,ETABLCK , &etab))return 1 ; +nfsd_nl_load_export_features (); +if (optind == argc && ! f_all) {if (force_flush) {cache_flush ();
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 5/7 nfsref: flush the export caches with cache_flush()
In reply to Jeff Laytonjunction_flush_exports_cache() writes the /proc/net/rpc/*/flush files itself. Call libexport's cache_flush() instead, which flushes over netlink and falls back to the same /proc files.
- nfsref now links libexport.a and libnl, and defines no_netlink for cache_flush().
- Its callers ignore the FedFsStatus; it now always returns FEDFS_OK.
--- support/junction/export-cache.c | 82 +++-------------------------------------- utils/nfsref/Makefile.am | 4 +- utils/nfsref/nfsref.c | 5 +++ 3 files changed, 13 insertions(+), 78 deletions(-)
support/junction/export-cache.c +5 -77
@@ -23,96 +23,24 @@* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ -#include <sys/types.h> -#include <sys/stat.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <time.h> -#include "junction.h" +#include "nfslib.h" #include "xlog.h" -/** -* Ordered list of proc files to poke when requesting an NFSD cache flush -*/ -static const char *junction_proc_files[] = { -"/proc/net/rpc/auth.unix.ip/flush" , -"/proc/net/rpc/auth.unix.gid/flush" , -"/proc/net/rpc/nfsd.fh/flush" , -"/proc/net/rpc/nfsd.export/flush" , -NULL , -}; - -/** -* Write time into one file -* -* @param pathname NUL-terminated C string containing POSIX pathname of file to write -* @param flushtime NUL-terminated C string containing current time in seconds since the Epoch -* @return a FedFsStatus code -*/ -static FedFsStatus -junction_write_time (const char *pathname,const char *flushtime) -{ -FedFsStatus retval; -ssize_t len; -int fd; - - fd =open (pathname,O_RDWR ); -if (fd ==-1 ) { -xlog (D_GENERAL ,"%s: Failed to open %s: %m" , - __func__, pathname); -/* If the proc files don't exist, no server -* is running on this system */ -return FEDFS_ERR_NO_CACHE_UPDATE ; - } - - len =write (fd, flushtime,strlen (flushtime)); -if (len != (ssize_t )strlen (flushtime)) { -xlog (D_GENERAL ,"%s: Failed to write %s: %m" , - __func__, pathname); -/* If the proc files exist but the update failed, -* we don't know the state of the cache */ - retval =FEDFS_ERR_UNKNOWN_CACHE ; - }else -/* Cache flush succeeded */ - retval =FEDFS_OK ; - - (void )close (fd); -return retval; -} -/** * Flush the kernel NFSD's exports cache * +* cache_flush() uses netlink when the kernel offers it, and falls back +* to the /proc flush files otherwise. +* * @return a FedFsStatus code */ FedFsStatus junction_flush_exports_cache (void ) { -FedFsStatus retval; -char flushtime[20 ]; -unsigned int i; -time_t now; -xlog (D_CALL ,"%s: Flushing NFSD caches..." , __func__); - - now =time (NULL ); -if (now ==-1 ) { -xlog (D_GENERAL ,"%s: time(3) failed" , __func__); -return FEDFS_ERR_SVRFAULT ; - } -snprintf (flushtime,sizeof (flushtime),"%lld\n" , (long long )now); - -for (i =0 ; junction_proc_files[i] !=NULL ; i++) { - retval =junction_write_time (junction_proc_files[i], flushtime); -if (retval !=FEDFS_OK ) -return retval; - } +cache_flush ();return FEDFS_OK ; }
utils/nfsref/Makefile.am +3 -1
@@ -29,7 +29,9 @@ sbin_PROGRAMS = nfsref nfsref_SOURCES = add.c lookup.c nfsref.c remove.c LDADD = ../../support/nfs/libnfs.la \ ../../support/junction/libjunction.la \ - $(LIBXML2) $(LIBCAP) + ../../support/export/libexport.a \ + $(LIBXML2) $(LIBCAP) \ + $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS) man8_MANS = nfsref.man
utils/nfsref/nfsref.c +5 -0
@@ -43,6 +43,11 @@#include "xlog.h" #include "nfsref.h" +/** +* Lets cache_flush() try netlink before the /proc flush files +*/ +int no_netlink; +/** * Short form command line options */
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 6/7 mountd/exportd: always give pseudo-root directories a path-based uuid
In reply to Jeff Laytonc5528f40f9db ("Fix NFSv4 export of tmpfs filesystems") made v4root_create() generate a uuid from the path only when export_test() says the directory cannot be exported without one, leaving others on the filesystem's own uuid. In practice export_test() fails nearly every time, so the path-based uuid is what pseudo-root directories get:
- export_test() needs the "-test-client-" auth_domain, which only lives as long as an ip_map entry that references it.
- With netlink, nothing creates that entry: exportfs's can_test() returns before writing it. The kernel answers ENOENT.
- With /proc, can_test() creates it, but exportfs's own cache_flush() frees it before mountd rebuilds the pseudo-root.
The fs uuid is only used when mountd rebuilds the pseudo-root during the brief window in an exportfs run on a live server, and then that directory's filehandle differs from every other time.
Always use the path-based uuid below "/". That keeps what servers have done since c5528f40f9db, closes that window, and drops a write to /proc/net/rpc/nfsd.export/channel that ran even with netlink.
Also keep uuid_s in scope until export_create() has used it; eep.e_uuid pointed at it after the block that declared it had ended.
--- support/export/v4root.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
support/export/v4root.c +9 -7
@@ -85,24 +85,26 @@ v4root_create(char *path, nfs_export *export)nfs_export *exp;struct exportent eep;struct exportent *curexp = &export->m_export; +char uuid_s[UUID_STR_LEN ];dupexportent (&eep, &pseudo_root.m_export); eep.e_ttl = default_ttl; eep.e_hostname = curexp->e_hostname;strncpy (eep.e_path, path,sizeof (eep.e_path)-1 ); -if (strcmp (path,"/" ) !=0 ) - eep.e_flags &= ~NFSEXP_FSID ; -if (strcmp (path,"/" ) !=0 && - !export_test (&eep,0 )) { -/* Need a uuid - base it on path using a fixed seed that -* was generated randomly. +if (strcmp (path,"/" ) !=0 ) { +/* +* Some filesystems (tmpfs, say) cannot be exported without an +* fsid or uuid, so give every pseudo-root directory below "/" +* one. Base it on the path, using a fixed seed that was +* generated randomly, so that its filehandle never changes. */ const char seed_s[] ="39c6b5c1-3f24-4f4e-977c-7fe6546b8a25" ;uuid_t seed, uuid; -char uuid_s[UUID_STR_LEN ];unsigned int i, j; + eep.e_flags &= ~NFSEXP_FSID ; +uuid_parse (seed_s, seed);uuid_generate_sha1 (uuid, seed, path,strlen (path));uuid_unparse_upper (uuid, uuid_s);
Signature · 1 line
2.56.0
Jeff Layton
maintainerPATCH v2 7/7 Add MAINTAINERS file and get_maintainer.pl
In reply to Jeff Laytonb4 prep --auto-to-cc looks for scripts/get_maintainer.pl at the top of the tree and runs it to collect To/Cc addresses. Add a kernel-style MAINTAINERS file plus a minimal get_maintainer.pl that implements the F/X/N/K match types, ship both in make dist, and cover the b4 flag sets with a new test.
--- MAINTAINERS | 58 +++++++ Makefile.am | 2 + scripts/get_maintainer.pl | 370 ++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 2 +- tests/t0003-get-maintainer.sh | 140 ++++++++++++++++ 5 files changed, 571 insertions(+), 1 deletion(-)
MAINTAINERS new file +58 -0
@@ -0,0 +1,58 @@ +List of maintainers and how to submit nfs-utils changes +==================================================== + +Patches for nfs-utils are reviewed on the linux-nfs mailing list and +applied by the maintainer. There is no pull request workflow. + +Mailing list: [email protected] (plain text, inline patches, +typically with git send-email or b4 send). Because the list is shared +with the kernel NFS client and server code, prefix nfs-utils patch +subjects with [PATCH nfs-utils] so the target tree is obvious. + +This file uses the same section format as the Linux kernel MAINTAINERS +file. scripts/get_maintainer.pl reads it and prints the people and +lists to Cc on a patch; "b4 prep --auto-to-cc" runs that script for +you. For example: + + scripts/get_maintainer.pl <patch> + b4 prep --auto-to-cc + +Every patch must carry a Signed-off-by: trailer (Developer's +Certificate of Origin, as in the kernel). + +Descriptions of section entries +------------------------------- + + M: *Mail* patches to: FullName <address@domain> + R: Designated *Reviewer*: FullName <address@domain> + These reviewers should be Cc'd on patches. + L: *Mailing list* that is relevant to this area + S: *Status*, one of the following: + Supported: Someone is actually paid to look after this. + Maintained: Someone actually looks after it. + Odd Fixes: It has a maintainer but they don't have time to do + much other than throw the odd patch in. + Orphan: No current maintainer. + Obsolete: Old code, replaced by a better system. + T: *SCM* tree type and location. + F: *Files* and directories wildcard patterns. + A trailing slash includes all files and subdirectory files. + F: utils/mountd/ all files in and below utils/mountd + One pattern per line. Multiple F: lines acceptable. + X: *Excluded* files and directories that are NOT maintained, same + rules as F:. Exclusions are tested before file matches. + N: Files and directories *Regex* patterns. + One pattern per line. Multiple N: lines acceptable. + K: *Content regex* (perl extended) pattern match in a patch or file. + One regex pattern per line. Multiple K: lines acceptable. + +Maintainers List +---------------- + +NFS-UTILS +M: Steve Dickson <[email protected]> +L: [email protected] +S: Maintained +T: git git://git.linux-nfs.org/projects/steved/nfs-utils.git +F: * +F: */
Makefile.am +2 -0
@@ -8,6 +8,8 @@ MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = \ autogen.sh \ + MAINTAINERS \ + scripts/get_maintainer.pl \ \ aclocal/bsdsignals.m4 \ aclocal/getrandom.m4 \
scripts/get_maintainer.pl new file +370 -0
370 lines not on this page · raw message
tests/Makefile.am +1 -1
@@ -11,5 +11,5 @@ SUBDIRS = nsm_client MAINTAINERCLEANFILES = Makefile.in -TESTS = t0001-statd-basic-mon-unmon.sh +TESTS = t0001-statd-basic-mon-unmon.sh t0003-get-maintainer.sh EXTRA_DIST = test-lib.sh $(TESTS)
tests/t0003-get-maintainer.sh new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.56.0
Quoted 46 lines · Jeff Layton
There are some cases where mountd will use /proc even when netlink is available, and agentic review of this code also found some bugs.
This set fixes it to use netlink in more situations when it's available, and also throws in some bugfixes and cleanups. The last patch in the series adds a
MAINTAINERSfile and the machinery that allows b4 workflows to work properly with nfs-utils.Signed-off-by Jeff Layton <[email protected]>---
Changes in v2:
- Add Fixes: tag to patch that forces a path-based uuid
- Drop the currently unusedmax_attrfield fromnfsd_export_policy
- Fix default value of $output_roles in get_maintainer.pl
- Use script location to determine top of git tree
- Link to v1: https://lore.kernel.org/r/[email protected]---
Jeff Layton (7):
mountd: accept -L for --no-netlink
mountd: prime the kernel caches over netlink on MOUNT
exports: describe the kernel's export features with structnfsd_export_policyexportfs/mountd/exportd: get export features from the netlink policy
nfsref: flush the export caches withcache_flush()mountd/exportd: always give pseudo-root directories a path-based uuid AddMAINTAINERSfile and get_maintainer.plMAINTAINERS | 58 +++++++ Makefile.am | 2 + configure.ac | 24 +++ scripts/get_maintainer.pl | 370 ++++++++++++++++++++++++++++++++++++++++ support/export/Makefile.am | 4 +- support/export/cache.c | 124 ++++++++++++-- support/export/export_policy.c | 258 ++++++++++++++++++++++++++++ support/export/v4root.c | 22 +-- support/include/exportfs.h | 13 +- support/include/nfs/export.h | 5 + support/junction/export-cache.c | 82 +-------- support/nfs/exports.c | 47 +++-- tests/Makefile.am | 2 +- tests/t0003-get-maintainer.sh | 140 +++++++++++++++ utils/exportfs/exportfs.c | 2 + utils/mountd/mountd.c | 2 +- utils/nfsref/Makefile.am | 4 +- utils/nfsref/nfsref.c | 5 + 18 files changed, 1034 insertions(+), 130 deletions(-)
Quoted 5 lines
---
base-commit:5090e0bb662c53b4552b28b121ac2c2c434adb2e
change-id: 20261016-netlink-noproc-8e3bb540d266Best regards,
Committed... (tag: nfs-utils-3-1-2.rc2)
steved