Start reorganizing fs/nfsd/nfsd.h
Subsystems (2)
Chuck Lever
maintainercover Start reorganizing fs/nfsd/nfsd.h
fs/nfsd/nfsd.h has become a kitchen sink of unrelated declarations and definitions, including a broad swathe of headers and other detritus in NFSD source files. This organization introduces brittleness that makes it difficult to execute changes that cut across layers and internal modules that might otherwise be cleanly siloed. It also pulls in unused items into each TU, making compilation of nfsd.ko needlessly slower and more computationally- expensive.
This series begins sorting through this pile to relocate items that are obviously better placed in NFS version- or task-specific headers.
Chuck Lever (9):
NFSD: Make "stats.h" self-contained
NFSD: Explicitly include "stats.h"
NFSD: include "netns.h"
NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h
NFSD: Move the export.h include from nfsd.h to auth.c
NFSD: Move struct readdir_cd
NFSD: Relocate nfsd_user_namespace()
NFSD: Relocate nfsd4_set_netaddr()
NFSD: Relocate NFSv4 "supported attributes" to new header
fs/nfsd/attr4.h | 162 +++++++++++++++++++++++++++++++++++ fs/nfsd/auth.c | 19 +++++ fs/nfsd/auth.h | 6 ++ fs/nfsd/cache.h | 3 +- fs/nfsd/nfs4idmap.c | 1 + fs/nfsd/nfs4proc.c | 32 +++++++ fs/nfsd/nfs4state.c | 1 + fs/nfsd/nfs4xdr.c | 2 + fs/nfsd/nfscache.c | 2 + fs/nfsd/nfsctl.c | 2 + fs/nfsd/nfsd.h | 202 +------------------------------------------- fs/nfsd/nfsfh.c | 2 + fs/nfsd/nfsxdr.c | 2 + fs/nfsd/state.h | 3 + fs/nfsd/stats.c | 2 + fs/nfsd/stats.h | 3 + fs/nfsd/trace.h | 1 + fs/nfsd/vfs.c | 2 + fs/nfsd/vfs.h | 5 +- fs/nfsd/xdr.h | 1 + fs/nfsd/xdr3.h | 1 + fs/nfsd/xdr4.h | 2 +- 22 files changed, 253 insertions(+), 203 deletions(-) create mode 100644 fs/nfsd/attr4.h
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 1/9 NFSD: Make "stats.h" self-contained
The inline helpers in fs/nfsd/stats.h dereference struct nfsd_net and struct svc_export, yet the header includes neither "netns.h" nor "export.h", where those types are defined. Each helper therefore compiles only when its translation unit has already pulled in both headers ahead of "stats.h" -- a hidden ordering requirement that has to be honored at every include site.
Include "netns.h" and "export.h" from "stats.h" directly so the header stands on its own, and no consumer has to order its includes to satisfy it.
--- fs/nfsd/stats.h | 3 +++ 1 file changed, 3 insertions(+)
fs/nfsd/stats.h +3 -0
@@ -10,6 +10,9 @@#include <uapi/linux/nfsd/stats.h> #include <linux/percpu_counter.h> +#include "export.h" +#include "netns.h" +struct proc_dir_entry *nfsd_proc_stat_init (struct net *net);void nfsd_proc_stat_shutdown (struct net *net);
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 2/9 NFSD: Explicitly include "stats.h"
In reply to Chuck LeverNothing in fs/nfsd/nfsd.h needs what is defined in "stats.h", so that header can be moved out to the six translation units that actually need it.
--- fs/nfsd/nfs4state.c | 1 + fs/nfsd/nfscache.c | 1 + fs/nfsd/nfsctl.c | 1 + fs/nfsd/nfsd.h | 1 - fs/nfsd/nfsfh.c | 1 + fs/nfsd/stats.c | 1 + fs/nfsd/vfs.c | 1 + 7 files changed, 6 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -0
@@ -51,6 +51,7 @@#include "xdr4cb.h" #include "vfs.h" #include "current_stateid.h" +#include "stats.h" #include "netns.h" #include "pnfs.h"
fs/nfsd/nfscache.c +1 -0
@@ -19,6 +19,7 @@#include <net/checksum.h> #include "nfsd.h" +#include "stats.h" #include "cache.h" #include "trace.h"
fs/nfsd/nfsctl.c +1 -0
@@ -23,6 +23,7 @@#include "idmap.h" #include "nfsd.h" +#include "stats.h" #include "cache.h" #include "state.h" #include "netns.h"
fs/nfsd/nfsd.h +0 -1
@@ -41,7 +41,6 @@bool nfsd_support_version (int vers);#include "netns.h" -#include "stats.h" /* * Default and maximum payload size (NFS READ or WRITE), in bytes.
fs/nfsd/nfsfh.c +1 -0
@@ -13,6 +13,7 @@#include <linux/sunrpc/svcauth_gss.h> #include <crypto/utils.h> #include "nfsd.h" +#include "stats.h" #include "vfs.h" #include "auth.h" #include "trace.h"
fs/nfsd/stats.c +1 -0
@@ -26,6 +26,7 @@#include <net/net_namespace.h> #include "nfsd.h" +#include "stats.h" static int nfsd_show (struct seq_file *seq,void *v) {
fs/nfsd/vfs.c +1 -0
@@ -43,6 +43,7 @@#endif /* CONFIG_NFSD_V4 */ #include "nfsd.h" +#include "stats.h" #include "vfs.h" #include "filecache.h" #include "trace.h"
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 3/9 NFSD: include "netns.h"
In reply to Chuck LeverNothing in fs/nfsd/nfsd.h needs the contents of "netns.h"; the prototypes there that take a struct nfsd_net pointer need only a forward declaration of that type. Relocate the existing forward declaration ahead of the first such prototype, drop the "netns.h" include from nfsd.h, and include it directly in the translation units that operate on struct nfsd_net.
"netns.h" had also been the path by which <linux/filelock.h> reached nfsxdr.c and state.h. Both now include <linux/filelock.h> themselves.
--- fs/nfsd/nfscache.c | 1 + fs/nfsd/nfsctl.c | 1 + fs/nfsd/nfsd.h | 6 ++---- fs/nfsd/nfsfh.c | 1 + fs/nfsd/nfsxdr.c | 2 ++ fs/nfsd/state.h | 3 +++ fs/nfsd/stats.c | 1 + fs/nfsd/trace.h | 1 + fs/nfsd/vfs.c | 1 + 9 files changed, 13 insertions(+), 4 deletions(-)
fs/nfsd/nfscache.c +1 -0
@@ -19,6 +19,7 @@#include <net/checksum.h> #include "nfsd.h" +#include "netns.h" #include "stats.h" #include "cache.h" #include "trace.h"
fs/nfsd/nfsctl.c +1 -0
@@ -23,6 +23,7 @@#include "idmap.h" #include "nfsd.h" +#include "netns.h" #include "stats.h" #include "cache.h" #include "state.h"
fs/nfsd/nfsd.h +2 -4
@@ -40,8 +40,6 @@#define NFSD_SUPPORTED_MINOR_VERSION 2bool nfsd_support_version (int vers); -#include "netns.h" -/* * Default and maximum payload size (NFS READ or WRITE), in bytes. * The maximum is an implementation limit.
@@ -100,6 +98,8 @@ struct nfsdfs_client {void (*cl_release)(struct kref *kref); }; +struct nfsd_net ; +struct nfsdfs_client *get_nfsdfs_client (struct inode *); struct dentry *nfsd_client_mkdir(struct nfsd_net *nn, struct nfsdfs_client *ncl, u32 id,
@@ -125,8 +125,6 @@ extern const struct svc_version nfsd_acl_version3;extern const struct svc_version localio_version1;#endif -struct nfsd_net ; -enum vers_op {NFSD_SET ,NFSD_CLEAR ,NFSD_TEST ,NFSD_AVAIL };int nfsd_vers (struct nfsd_net *nn,int vers,enum vers_op change);int nfsd_minorversion (struct nfsd_net *nn,u32 minorversion,enum vers_op change);
fs/nfsd/nfsfh.c +1 -0
@@ -13,6 +13,7 @@#include <linux/sunrpc/svcauth_gss.h> #include <crypto/utils.h> #include "nfsd.h" +#include "netns.h" #include "stats.h" #include "vfs.h" #include "auth.h"
fs/nfsd/nfsxdr.c +2 -0
@@ -5,6 +5,8 @@* Copyright (C) 1995, 1996 Olaf Kirch <[email protected]> */ +#include <linux/filelock.h> +#include "vfs.h" #include "xdr.h" #include "auth.h"
fs/nfsd/state.h +3 -0
@@ -36,9 +36,12 @@#define _NFSD4_STATE_H#include <crypto/md5.h> + +#include <linux/filelock.h> #include <linux/idr.h> #include <linux/refcount.h> #include <linux/sunrpc/svc_xprt.h> +#include "nfsfh.h" #include "nfsd.h"
fs/nfsd/stats.c +1 -0
@@ -26,6 +26,7 @@#include <net/net_namespace.h> #include "nfsd.h" +#include "netns.h" #include "stats.h" static int nfsd_show (struct seq_file *seq,void *v)
fs/nfsd/trace.h +1 -0
@@ -19,6 +19,7 @@#include "export.h" #include "nfsfh.h" #include "xdr4.h" +#include "netns.h" #define NFSD_TRACE_PROC_CALL_FIELDS (r) \ __field(unsigned int, netns_ino) \
fs/nfsd/vfs.c +1 -0
@@ -43,6 +43,7 @@#endif /* CONFIG_NFSD_V4 */ #include "nfsd.h" +#include "netns.h" #include "stats.h" #include "vfs.h" #include "filecache.h"
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 4/9 NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h
In reply to Chuck LeverClean up: cache.h does not need the full definition of struct nfsd_net. A forward declaration suffices.
--- fs/nfsd/cache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/cache.h +2 -1
@@ -10,7 +10,8 @@#define NFSCACHE_H #include <linux/sunrpc/svc.h> -#include "nfsd.h" + +struct nfsd_net ;/* * Representation of a reply cache entry.
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 5/9 NFSD: Move the export.h include from nfsd.h to auth.c
In reply to Chuck LeverNothing declared in fs/nfsd/nfsd.h references a type, macro, or function that export.h defines. The include is present only so that source files including nfsd.h pick up export.h's definitions transitively. Of the twenty source files that include nfsd.h, only auth.c relies on that side effect: it names struct svc_export and the NFSEXP_* flags yet includes no header that supplies them.
Add the export.h include directly to auth.c, then drop it from nfsd.h so the header carries only the dependencies its own declarations require.
--- fs/nfsd/auth.c | 1 + fs/nfsd/nfsd.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/auth.c +1 -0
@@ -3,6 +3,7 @@#include <linux/sched.h> #include "nfsd.h" +#include "export.h" #include "auth.h" int nfsexp_flags (struct svc_cred *cred,struct svc_export *exp)
fs/nfsd/nfsd.h +0 -2
@@ -23,8 +23,6 @@#include <uapi/linux/nfsd/debug.h> -#include "export.h" -#undef ifdebug#ifdef CONFIG_SUNRPC_DEBUG # define ifdebug (flag) if (nfsd_debug & NFSDDBG_##flag)
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 6/9 NFSD: Move struct readdir_cd
In reply to Chuck Leverstruct readdir_cd is part of the VFS readdir API, but it lives in nfsd.h, the subsystem's catch-all header, rather than alongside that API. That forces vfs.h to include nfsd.h solely to declare readdir_cd for its nfsd_readdir() prototype, a layering inversion since vfs.h is the lower-level shim.
Relocate readdir_cd to vfs.h, just below the nfsd_filldir_t callback typedef. vfs.h then defines the struct itself and no longer includes nfsd.h. The xdr headers that embed readdir_cd by value include vfs.h to obtain the definition. This prepares the ground for dropping nfsd.h from more files.
--- fs/nfsd/nfsd.h | 4 ---- fs/nfsd/vfs.h | 5 ++++- fs/nfsd/xdr.h | 1 + fs/nfsd/xdr3.h | 1 + fs/nfsd/xdr4.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-)
fs/nfsd/nfsd.h +0 -4
@@ -47,10 +47,6 @@ enum { NFSSVC_MAXBLKSIZE = RPCSVC_MAXPAYLOAD, }; -struct readdir_cd { -__be32 err;/* 0, nfserr, or nfserr_eof */ -}; -/* Maximum number of operations per session compound */ #define NFSD_MAX_OPS_PER_COMPOUND 200
fs/nfsd/vfs.h +4 -1
@@ -9,7 +9,6 @@#include <linux/fs.h> #include <linux/posix_acl.h> #include "nfsfh.h" -#include "nfsd.h" /* * Flags for nfsd_permission
@@ -45,6 +44,10 @@ struct nfsd_file;*/ typedef int (*nfsd_filldir_t )(void *,const char *,int ,loff_t ,u64 ,unsigned ); +struct readdir_cd { +__be32 err;/* nfs_ok, nfserr, or nfserr_eof */ +}; +/* nfsd/vfs.c */ struct nfsd_attrs {struct iattr *na_iattr;/* input */
fs/nfsd/xdr.h +1 -0
@@ -7,6 +7,7 @@#include <linux/vfs.h> #include "nfsd.h" #include "nfsfh.h" +#include "vfs.h" struct nfsd_fhandle {struct svc_fh fh;
fs/nfsd/xdr3.h +1 -0
@@ -9,6 +9,7 @@#define _LINUX_NFSD_XDR3_H#include "xdr.h" +#include "vfs.h" struct nfsd3_sattrargs {struct svc_fh fh;
fs/nfsd/xdr4.h +1 -1
@@ -38,7 +38,7 @@#define _LINUX_NFSD_XDR4_H#include "state.h" -#include "nfsd.h" +#include "vfs.h" #define NFSD4_MAX_TAGLEN 128#define XDR_LEN (n) (((n) + 3) & ~3)
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 7/9 NFSD: Relocate nfsd_user_namespace()
In reply to Chuck LeverRefactor: nfsd_user_namespace() currently lives in nfsd.h, so every caller must pull in nfsd.h -- directly or transitively via state.h -- and with it the NFS protocol definitions from uapi/linux/nfs.h and friends, even when the caller uses nothing else from nfsd.h.
Since nfsd_user_namespace() is an auth-related function, move it to fs/nfsd/auth.c in preparation for removing '#include "nfsd.h"' from a few places.
--- fs/nfsd/auth.c | 18 ++++++++++++++++++ fs/nfsd/auth.h | 6 ++++++ fs/nfsd/nfs4idmap.c | 1 + fs/nfsd/nfs4xdr.c | 1 + fs/nfsd/nfsd.h | 6 ------ 5 files changed, 26 insertions(+), 6 deletions(-)
fs/nfsd/auth.c +18 -0
@@ -88,3 +88,21 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp)return -ENOMEM ; } +/** +* nfsd_user_namespace - Get user_namespace in effect for an RPC request +* @rqstp: RPC execution context +* +* xpt_cred is set once at transport creation and never modified. The +* transport itself is reference-counted during request processing, so +* no explicit reference on the namespace is necessary. +* +* Return: the user_namespace from the transport credential, or +* init_user_ns if no credential was set. The returned namespace pointer +* is valid for the duration of the RPC request. +*/ +struct user_namespace *nfsd_user_namespace (const struct svc_rqst *rqstp) +{ +const struct cred *cred = rqstp->rq_xprt->xpt_cred; + +return cred ? cred->user_ns : &init_user_ns; +}
fs/nfsd/auth.h +6 -0
@@ -8,10 +8,16 @@#ifndef LINUX_NFSD_AUTH_H #define LINUX_NFSD_AUTH_H +struct user_namespace ; +struct svc_export ; +struct svc_rqst ; +/* * Set the current process's fsuid/fsgid etc to those of the NFS * client user */ int nfsd_setuser (struct svc_cred *cred,struct svc_export *exp); +struct user_namespace *nfsd_user_namespace (const struct svc_rqst *rqstp); +#endif /* LINUX_NFSD_AUTH_H */
fs/nfsd/nfs4idmap.c +1 -0
@@ -38,6 +38,7 @@#include <linux/slab.h> #include <linux/sunrpc/svc_xprt.h> #include <net/net_namespace.h> +#include "auth.h" #include "idmap.h" #include "nfsd.h" #include "netns.h"
fs/nfsd/nfs4xdr.c +1 -0
@@ -47,6 +47,7 @@#include <uapi/linux/xattr.h> +#include "auth.h" #include "idmap.h" #include "acl.h" #include "xdr4.h"
fs/nfsd/nfsd.h +0 -6
@@ -153,12 +153,6 @@ static inline int nfsd_v4client(struct svc_rqst *rq) {return rq && rq->rq_prog ==NFS_PROGRAM && rq->rq_vers ==4 ; } -static inline struct user_namespace * -nfsd_user_namespace (const struct svc_rqst *rqstp) -{ -const struct cred *cred = rqstp->rq_xprt->xpt_cred; -return cred ? cred->user_ns : &init_user_ns; -}/* * NFSv4 State
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 8/9 NFSD: Relocate nfsd4_set_netaddr()
In reply to Chuck LeverClean up: Common practice in the Linux kernel is to avoid the use of static inline functions when there is only a single call site. The 30-line helper function is removed from a header pulled into ~25 .c files, removing <linux/sunrpc/addr.h> from that header's transitive include surface, dropping a now-redundant <linux/sunrpc/msg_prot.h> include, and reducing the function's visibility to the one translation unit that uses it.
--- fs/nfsd/nfs4proc.c | 31 +++++++++++++++++++++++++++++++ fs/nfsd/nfsd.h | 33 --------------------------------- 2 files changed, 31 insertions(+), 33 deletions(-)
fs/nfsd/nfs4proc.c +31 -0
@@ -2313,6 +2313,37 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp,return nfs_ok; } +static __be32 +nfsd4_set_netaddr (struct sockaddr *addr,struct nfs42_netaddr *netaddr) +{ +struct sockaddr_in *sin = (struct sockaddr_in *)addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; +unsigned int port; +size_t ret_addr, ret_port; + +switch (addr->sa_family) { +case AF_INET : + port =ntohs (sin->sin_port); +sprintf (netaddr->netid,"tcp" ); + netaddr->netid_len =3 ; +break ; +case AF_INET6 : + port =ntohs (sin6->sin6_port); +sprintf (netaddr->netid,"tcp6" ); + netaddr->netid_len =4 ; +break ; +default : +return nfserr_inval; + } + ret_addr =rpc_ntop (addr, netaddr->addr,sizeof (netaddr->addr)); + ret_port =snprintf (netaddr->addr + ret_addr, +RPCBIND_MAXUADDRLEN +1 - ret_addr, +".%u.%u" , port >>8 , port &0xff ); +WARN_ON (ret_port >=RPCBIND_MAXUADDRLEN +1 - ret_addr); + netaddr->addr_len = ret_addr + ret_port; +return 0 ; +} +static __be32 nfsd4_copy_notify (struct svc_rqst *rqstp,struct nfsd4_compound_state *cstate,union nfsd4_op_u *u)
fs/nfsd/nfsd.h +0 -33
@@ -18,8 +18,6 @@#include <linux/nfs4.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/svc_xprt.h> -#include <linux/sunrpc/msg_prot.h> -#include <linux/sunrpc/addr.h> #include <uapi/linux/nfsd/debug.h>
@@ -450,37 +448,6 @@ enum {extern const u32 nfsd_suppattrs[3 ][3 ]; -static inline __be32 nfsd4_set_netaddr (struct sockaddr *addr, -struct nfs42_netaddr *netaddr) -{ -struct sockaddr_in *sin = (struct sockaddr_in *)addr; -struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; -unsigned int port; -size_t ret_addr, ret_port; - -switch (addr->sa_family) { -case AF_INET : - port =ntohs (sin->sin_port); -sprintf (netaddr->netid,"tcp" ); - netaddr->netid_len =3 ; -break ; -case AF_INET6 : - port =ntohs (sin6->sin6_port); -sprintf (netaddr->netid,"tcp6" ); - netaddr->netid_len =4 ; -break ; -default : -return nfserr_inval; - } - ret_addr =rpc_ntop (addr, netaddr->addr,sizeof (netaddr->addr)); - ret_port =snprintf (netaddr->addr + ret_addr, -RPCBIND_MAXUADDRLEN +1 - ret_addr, -".%u.%u" , port >>8 , port &0xff ); -WARN_ON (ret_port >=RPCBIND_MAXUADDRLEN +1 - ret_addr); - netaddr->addr_len = ret_addr + ret_port; -return 0 ; -} -static inline bool bmval_is_subset (const u32 *bm1,const u32 *bm2) { return !((bm1[0] & ~bm2[0]) ||
Signature · 1 line
2.54.0
Chuck Lever
maintainerPATCH 9/9 NFSD: Relocate NFSv4 "supported attributes" to new header
In reply to Chuck LeverThese NFSv4 attribute bitmask definitions live in nfsd.h, which nearly every nfsd source file includes, yet only nfs4proc.c and nfs4xdr.c reference them. Move them to a dedicated header so only those two consumers pull them in.
While moving the block, correct the stale QUOTA_* annotation: the promised support never materialized, so these attributes are unlikely to be supported any time soon rather than forthcoming.
--- fs/nfsd/attr4.h | 162 +++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4proc.c | 1 + fs/nfsd/nfs4xdr.c | 1 + fs/nfsd/nfsd.h | 150 ----------------------------------------- 4 files changed, 164 insertions(+), 150 deletions(-) create mode 100644 fs/nfsd/attr4.h
fs/nfsd/attr4.h new file +162 -0
@@ -0,0 +1,162 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* NFSv4 file attributes supported by this implementation +*/ + +#ifndef _LINUX_NFSD_ATTR4_H +#define _LINUX_NFSD_ATTR4_H + +#include <linux/types.h> +#include <linux/nfs4.h> + +/* +* The following attributes are not implemented by NFSD: +* ARCHIVE (deprecated anyway) +* HIDDEN (unlikely to be supported any time soon) +* MIMETYPE (unlikely to be supported any time soon) +* QUOTA_* (unlikely to be supported any time soon) +* SYSTEM (unlikely to be supported any time soon) +* TIME_BACKUP (unlikely to be supported any time soon) +*/ +#define NFSD4_SUPPORTED_ATTRS_WORD0 \ +(FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \ + | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \ + | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \ + | FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \ + | FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \ + | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \ + | FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \ + | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS \ + | FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \ + | FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE | FATTR4_WORD0_ACL) + +#define NFSD4_SUPPORTED_ATTRS_WORD1 \ +(FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \ + | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \ + | FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \ + | FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \ + | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_CREATE \ + | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID) + +#define NFSD4_SUPPORTED_ATTRS_WORD2 0 + +/* 4.1 */ +#ifdef CONFIG_NFSD_PNFS +#define PNFSD_SUPPORTED_ATTRS_WORD1 FATTR4_WORD1_FS_LAYOUT_TYPES +#define PNFSD_SUPPORTED_ATTRS_WORD2 \ +(FATTR4_WORD2_LAYOUT_BLKSIZE | FATTR4_WORD2_LAYOUT_TYPES) +#else +#define PNFSD_SUPPORTED_ATTRS_WORD1 0 +#define PNFSD_SUPPORTED_ATTRS_WORD2 0 +#endif /* CONFIG_NFSD_PNFS */ + +#define NFSD4_1_SUPPORTED_ATTRS_WORD0 \ + NFSD4_SUPPORTED_ATTRS_WORD0 + +#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \ + (NFSD4_SUPPORTED_ATTRS_WORD1 | PNFSD_SUPPORTED_ATTRS_WORD1) + +#define NFSD4_1_SUPPORTED_ATTRS_WORD2 \ + (NFSD4_SUPPORTED_ATTRS_WORD2 | PNFSD_SUPPORTED_ATTRS_WORD2 | \ + FATTR4_WORD2_SUPPATTR_EXCLCREAT) + +/* 4.2 */ +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL +#define NFSD4_2_SECURITY_ATTRS FATTR4_WORD2_SECURITY_LABEL +#else +#define NFSD4_2_SECURITY_ATTRS 0 +#endif + +#ifdef CONFIG_NFSD_V4_POSIX_ACLS +#define NFSD4_2_POSIX_ACL_ATTRS \ + (FATTR4_WORD2_ACL_TRUEFORM | \ + FATTR4_WORD2_ACL_TRUEFORM_SCOPE | \ + FATTR4_WORD2_POSIX_DEFAULT_ACL | \ + FATTR4_WORD2_POSIX_ACCESS_ACL) +#else +#define NFSD4_2_POSIX_ACL_ATTRS 0 +#endif + +#define NFSD4_2_SUPPORTED_ATTRS_WORD2 \ + (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \ + FATTR4_WORD2_MODE_UMASK | \ + FATTR4_WORD2_CLONE_BLKSIZE | \ + NFSD4_2_SECURITY_ATTRS | \ + FATTR4_WORD2_XATTR_SUPPORT | \ + FATTR4_WORD2_TIME_DELEG_ACCESS | \ + FATTR4_WORD2_TIME_DELEG_MODIFY | \ + FATTR4_WORD2_OPEN_ARGUMENTS | \ + NFSD4_2_POSIX_ACL_ATTRS) + +/* These will return ERR_INVAL if specified in GETATTR or READDIR. */ +#define NFSD_WRITEONLY_ATTRS_WORD1 \ + (FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET) + +/* +* These are the only attrs allowed in CREATE/OPEN/SETATTR. Don't add +* a writeable attribute here without also adding code to parse it to +* nfsd4_decode_fattr4(). +*/ +#define NFSD_WRITEABLE_ATTRS_WORD0 \ + (FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL) +#define NFSD_WRITEABLE_ATTRS_WORD1 \ + (FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \ + | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_CREATE \ + | FATTR4_WORD1_TIME_MODIFY_SET) +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL +#define MAYBE_FATTR4_WORD2_SECURITY_LABEL \ + FATTR4_WORD2_SECURITY_LABEL +#else +#define MAYBE_FATTR4_WORD2_SECURITY_LABEL 0 +#endif +#ifdef CONFIG_NFSD_V4_POSIX_ACLS +#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \ + FATTR4_WORD2_POSIX_DEFAULT_ACL | FATTR4_WORD2_POSIX_ACCESS_ACL +#else +#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS 0 +#endif +#define NFSD_WRITEABLE_ATTRS_WORD2 \ + (FATTR4_WORD2_MODE_UMASK \ + | MAYBE_FATTR4_WORD2_SECURITY_LABEL \ + | FATTR4_WORD2_TIME_DELEG_ACCESS \ + | FATTR4_WORD2_TIME_DELEG_MODIFY \ + | MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \ + ) + +#define NFSD_SUPPATTR_EXCLCREAT_WORD0 \ + NFSD_WRITEABLE_ATTRS_WORD0 +/* +* we currently store the exclusive create verifier in the v_{a,m}time +* attributes so the client can't set these at create time using EXCLUSIVE4_1 +*/ +#define NFSD_SUPPATTR_EXCLCREAT_WORD1 \ + (NFSD_WRITEABLE_ATTRS_WORD1 & \ + ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)) +/* +* The FATTR4_WORD2_TIME_DELEG attributes are not to be allowed for +* OPEN(create) with EXCLUSIVE4_1. It doesn't make sense to set a +* delegated timestamp on a new file. +* +* This mask includes NFSv4.2-only attributes (e.g., POSIX ACLs). +* Version filtering occurs via nfsd_suppattrs[] before this mask +* is applied, so pre-4.2 clients never see unsupported attributes. +*/ +#define NFSD_SUPPATTR_EXCLCREAT_WORD2 \ + (NFSD_WRITEABLE_ATTRS_WORD2 & \ + ~(FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MODIFY)) + +extern const u32 nfsd_suppattrs[3 ][3 ]; + +static inline bool bmval_is_subset (const u32 *bm1,const u32 *bm2) +{ +return !((bm1[0 ] & ~bm2[0 ]) || + (bm1[1 ] & ~bm2[1 ]) || + (bm1[2 ] & ~bm2[2 ])); +} + +static inline bool nfsd_attrs_supported (u32 minorversion,const u32 *bmval) +{ +return bmval_is_subset (bmval, nfsd_suppattrs[minorversion]); +} + +#endif /* _LINUX_NFSD_ATTR4_H */
fs/nfsd/nfs4proc.c +1 -0
@@ -42,6 +42,7 @@#include <linux/sunrpc/addr.h> #include <linux/nfs_ssc.h> +#include "attr4.h" #include "idmap.h" #include "cache.h" #include "xdr4.h"
fs/nfsd/nfs4xdr.c +1 -0
@@ -47,6 +47,7 @@#include <uapi/linux/xattr.h> +#include "attr4.h" #include "auth.h" #include "idmap.h" #include "acl.h"
fs/nfsd/nfsd.h +0 -150
156 lines not on this page · raw message
Signature · 1 line
2.54.0
Quoted 40 lines · Chuck Lever
fs/nfsd/nfsd.hhas become a kitchen sink of unrelated declarations and definitions, including a broad swathe of headers and other detritus in NFSD source files. This organization introduces brittleness that makes it difficult to execute changes that cut across layers and internal modules that might otherwise be cleanly siloed. It also pulls in unused items into each TU, making compilation of nfsd.ko needlessly slower and more computationally- expensive.This series begins sorting through this pile to relocate items that are obviously better placed in NFS version- or task-specific headers.
Chuck Lever (9):
NFSD: Make "stats.h" self-contained
NFSD: Explicitly include "stats.h"
NFSD: include "netns.h"
NFSD: Remove '#include "nfsd.h"' fromfs/nfsd/cache.h
NFSD: Move theexport.hinclude fromnfsd.htoauth.c
NFSD: Move structreaddir_cd
NFSD: Relocatenfsd_user_namespace()
NFSD: Relocatenfsd4_set_netaddr()
NFSD: Relocate NFSv4 "supported attributes" to new headerfs/nfsd/attr4.h | 162 +++++++++++++++++++++++++++++++++++ fs/nfsd/auth.c | 19 +++++ fs/nfsd/auth.h | 6 ++ fs/nfsd/cache.h | 3 +- fs/nfsd/nfs4idmap.c | 1 + fs/nfsd/nfs4proc.c | 32 +++++++ fs/nfsd/nfs4state.c | 1 + fs/nfsd/nfs4xdr.c | 2 + fs/nfsd/nfscache.c | 2 + fs/nfsd/nfsctl.c | 2 + fs/nfsd/nfsd.h | 202 +------------------------------------------- fs/nfsd/nfsfh.c | 2 + fs/nfsd/nfsxdr.c | 2 + fs/nfsd/state.h | 3 + fs/nfsd/stats.c | 2 + fs/nfsd/stats.h | 3 +
Quoted 8 lines
fs/nfsd/trace.h | 1 + fs/nfsd/vfs.c | 2 + fs/nfsd/vfs.h | 5 +- fs/nfsd/xdr.h | 1 + fs/nfsd/xdr3.h | 1 + fs/nfsd/xdr4.h | 2 +- 22 files changed, 253 insertions(+), 203 deletions(-) create mode 100644 fs/nfsd/attr4.h
This all looks sane.