Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * NFS internal definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include "nfs4_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/fs_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/crc32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/sunrpc/addr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/nfs_page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/wait_bit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define NFS_SB_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) extern const struct export_operations nfs_export_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct nfs_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct nfs_pageio_descriptor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	    (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	     ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (!(NFS_SB(dentry->d_sb)->flags & NFS_MOUNT_SOFTREVAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	if (!d_is_positive(dentry) || !NFS_FH(d_inode(dentry))->size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * Note: RFC 1813 doesn't limit the number of auth flavors that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * a server can return, so make something up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define NFS_MAX_SECFLAVORS	(12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * Value used if the user did not specify a port value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define NFS_UNSPEC_PORT		(-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define NFS_UNSPEC_RETRANS	(UINT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define NFS_UNSPEC_TIMEO	(UINT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * Maximum number of pages that readdir can use for creating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * a vmapped array of pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define NFS_MAX_READDIR_PAGES 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) struct nfs_client_initdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned long init_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	const char *hostname;			/* Hostname of the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	const struct sockaddr *addr;		/* Address of the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	const char *nodename;			/* Hostname of the client */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	const char *ip_addr;			/* IP address of the client */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	size_t addrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct nfs_subversion *nfs_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u32 minorversion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	unsigned int nconnect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct net *net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	const struct rpc_timeout *timeparms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	const struct cred *cred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * In-kernel mount arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) struct nfs_fs_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	bool			internal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	bool			skip_reconfig_option_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	bool			need_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	bool			sloppy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	unsigned int		flags;		/* NFS{,4}_MOUNT_* flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	unsigned int		rsize, wsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	unsigned int		timeo, retrans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	unsigned int		acregmin, acregmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	unsigned int		acdirmin, acdirmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	unsigned int		namlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	unsigned int		options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	unsigned int		bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct nfs_auth_info	auth_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	rpc_authflavor_t	selected_flavor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	char			*client_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	unsigned int		version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	unsigned int		minorversion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	char			*fscache_uniq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned short		protofamily;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	unsigned short		mountfamily;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			struct sockaddr	address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			struct sockaddr_storage	_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		size_t			addrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		char			*hostname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		u32			version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		int			port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		unsigned short		protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	} mount_server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			struct sockaddr	address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			struct sockaddr_storage	_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		size_t			addrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		char			*hostname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		char			*export_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		int			port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		unsigned short		protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		unsigned short		nconnect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		unsigned short		export_path_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	} nfs_server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	struct nfs_fh		*mntfh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct nfs_server	*server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct nfs_subversion	*nfs_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	/* Information for a cloned mount. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	struct nfs_clone_mount {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		struct super_block	*sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		struct dentry		*dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		struct nfs_fattr	*fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		unsigned int		inherited_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	} clone_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define nfs_errorf(fc, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	errorf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	({ dprintk(fmt "\n", ## __VA_ARGS__); }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define nfs_ferrorf(fc, fac, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	errorf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define nfs_invalf(fc, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	invalf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	({ dprintk(fmt "\n", ## __VA_ARGS__);  -EINVAL; }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define nfs_finvalf(fc, fac, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	invalf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	({ dfprintk(fac, fmt "\n", ## __VA_ARGS__);  -EINVAL; }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define nfs_warnf(fc, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	warnf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	({ dprintk(fmt "\n", ## __VA_ARGS__); }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define nfs_fwarnf(fc, fac, fmt, ...) ((fc)->log.log ?		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	warnf(fc, fmt, ## __VA_ARGS__) :			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); }))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	return fc->fs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* mount_clnt.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct nfs_mount_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct sockaddr		*sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	size_t			salen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	char			*hostname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	char			*dirpath;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32			version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	unsigned short		protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	struct nfs_fh		*fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	int			noresvport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	unsigned int		*auth_flav_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	rpc_authflavor_t	*auth_flavs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct net		*net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) extern int nfs_mount(struct nfs_mount_request *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) extern void nfs_umount(const struct nfs_mount_request *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /* client.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) extern const struct rpc_program nfs_program;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) extern void nfs_clients_init(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) extern void nfs_clients_exit(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int nfs_create_rpc_client(struct nfs_client *, const struct nfs_client_initdata *, rpc_authflavor_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct nfs_client *nfs_get_client(const struct nfs_client_initdata *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) void nfs_server_insert_lists(struct nfs_server *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) void nfs_server_remove_lists(struct nfs_server *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) void nfs_init_timeout_values(struct rpc_timeout *to, int proto, int timeo, int retrans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		rpc_authflavor_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct nfs_server *nfs_alloc_server(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) void nfs_server_copy_userdata(struct nfs_server *, struct nfs_server *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) extern void nfs_put_client(struct nfs_client *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) extern void nfs_free_client(struct nfs_client *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) extern struct nfs_client *nfs4_find_client_ident(struct net *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) extern struct nfs_client *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) nfs4_find_client_sessionid(struct net *, const struct sockaddr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				struct nfs4_sessionid *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) extern struct nfs_server *nfs_create_server(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) extern struct nfs_server *nfs4_create_server(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) extern struct nfs_server *nfs4_create_referral_server(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					struct sockaddr *sap, size_t salen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 					struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) extern void nfs_free_server(struct nfs_server *server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) extern struct nfs_server *nfs_clone_server(struct nfs_server *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					   struct nfs_fh *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					   struct nfs_fattr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 					   rpc_authflavor_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) extern bool nfs_client_init_is_complete(const struct nfs_client *clp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) extern int nfs_client_init_status(const struct nfs_client *clp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) extern int nfs_wait_client_init_complete(const struct nfs_client *clp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) extern void nfs_mark_client_ready(struct nfs_client *clp, int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) extern struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 					     const struct sockaddr *ds_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 					     int ds_addrlen, int ds_proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					     unsigned int ds_timeo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 					     unsigned int ds_retrans,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					     u32 minor_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) extern struct rpc_clnt *nfs4_find_or_create_ds_client(struct nfs_client *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 						struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) extern struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			const struct sockaddr *ds_addr, int ds_addrlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			int ds_proto, unsigned int ds_timeo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			unsigned int ds_retrans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) extern int __init nfs_fs_proc_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) extern void nfs_fs_proc_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) extern int nfs_fs_proc_net_init(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern void nfs_fs_proc_net_exit(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static inline int nfs_fs_proc_net_init(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static inline void nfs_fs_proc_net_exit(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static inline int nfs_fs_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static inline void nfs_fs_proc_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* callback_xdr.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) extern const struct svc_version nfs4_callback_version1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) extern const struct svc_version nfs4_callback_version4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /* fs_context.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) extern struct file_system_type nfs_fs_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* pagelist.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) extern int __init nfs_init_nfspagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) extern void nfs_destroy_nfspagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) extern int __init nfs_init_readpagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) extern void nfs_destroy_readpagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) extern int __init nfs_init_writepagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) extern void nfs_destroy_writepagecache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) extern int __init nfs_init_directcache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) extern void nfs_destroy_directcache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) extern void nfs_pgheader_init(struct nfs_pageio_descriptor *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			      struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 			      void (*release)(struct nfs_pgio_header *hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) int nfs_iocounter_wait(struct nfs_lock_context *l_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) extern const struct nfs_pageio_ops nfs_pgio_rw_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) void nfs_pgio_header_free(struct nfs_pgio_header *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		      const struct cred *cred, const struct nfs_rpc_ops *rpc_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		      const struct rpc_call_ops *call_ops, int how, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void nfs_free_request(struct nfs_page *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct nfs_pgio_mirror *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) nfs_pgio_current_mirror(struct nfs_pageio_descriptor *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) static inline bool nfs_match_open_context(const struct nfs_open_context *ctx1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		const struct nfs_open_context *ctx2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	return cred_fscmp(ctx1->cred, ctx2->cred) == 0 && ctx1->state == ctx2->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* nfs2xdr.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) extern const struct rpc_procinfo nfs_procedures[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) extern int nfs2_decode_dirent(struct xdr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 				struct nfs_entry *, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* nfs3xdr.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) extern const struct rpc_procinfo nfs3_procedures[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) extern int nfs3_decode_dirent(struct xdr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 				struct nfs_entry *, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /* nfs4xdr.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #if IS_ENABLED(CONFIG_NFS_V4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) extern int nfs4_decode_dirent(struct xdr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 				struct nfs_entry *, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #ifdef CONFIG_NFS_V4_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) extern const u32 nfs41_maxread_overhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) extern const u32 nfs41_maxwrite_overhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) extern const u32 nfs41_maxgetdevinfo_overhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* nfs4proc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #if IS_ENABLED(CONFIG_NFS_V4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) extern const struct rpc_procinfo nfs4_procedures[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #ifdef CONFIG_NFS_V4_SECURITY_LABEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) static inline struct nfs4_label *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (!dst || !src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	if (src->len > NFS4_MAXLABELLEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	dst->lfs = src->lfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	dst->pi = src->pi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	dst->len = src->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	memcpy(dst->label, src->label, src->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	return dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static inline void nfs4_label_free(struct nfs4_label *label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	if (label) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		kfree(label->label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		kfree(label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (nfs_server_capable(&nfsi->vfs_inode, NFS_CAP_SECURITY_LABEL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		nfsi->cache_validity |= NFS_INO_INVALID_LABEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static inline void nfs4_label_free(void *label) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static inline struct nfs4_label *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* proc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void nfs_close_context(struct nfs_open_context *ctx, int is_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) extern struct nfs_client *nfs_init_client(struct nfs_client *clp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			   const struct nfs_client_initdata *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) extern void nfs_advise_use_readdirplus(struct inode *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) extern void nfs_force_use_readdirplus(struct inode *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) extern unsigned long nfs_access_cache_count(struct shrinker *shrink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 					    struct shrink_control *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 					   struct shrink_control *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) int nfs_create(struct inode *, struct dentry *, umode_t, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) int nfs_mkdir(struct inode *, struct dentry *, umode_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int nfs_rmdir(struct inode *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) int nfs_unlink(struct inode *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) int nfs_symlink(struct inode *, struct dentry *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) int nfs_link(struct dentry *, struct inode *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) int nfs_rename(struct inode *, struct dentry *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	       struct inode *, struct dentry *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /* file.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) loff_t nfs_file_llseek(struct file *, loff_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) ssize_t nfs_file_read(struct kiocb *, struct iov_iter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) int nfs_file_mmap(struct file *, struct vm_area_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) ssize_t nfs_file_write(struct kiocb *, struct iov_iter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) int nfs_file_release(struct inode *, struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) int nfs_lock(struct file *, int, struct file_lock *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) int nfs_flock(struct file *, int, struct file_lock *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) int nfs_check_flags(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) extern struct workqueue_struct *nfsiod_workqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) extern struct inode *nfs_alloc_inode(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) extern void nfs_free_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) extern int nfs_write_inode(struct inode *, struct writeback_control *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) extern int nfs_drop_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) extern void nfs_clear_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) extern void nfs_evict_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) void nfs_zap_acl_cache(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) extern int nfs_wait_atomic_killable(atomic_t *p, unsigned int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) extern const struct super_operations nfs_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) int nfs_try_get_tree(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) int nfs_get_tree_common(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) void nfs_kill_super(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) extern struct rpc_stat nfs_rpcstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) extern int __init register_nfs_fs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) extern void __exit unregister_nfs_fs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) extern bool nfs_sb_active(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) extern void nfs_sb_deactive(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) extern int nfs_client_for_each_server(struct nfs_client *clp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 				      int (*fn)(struct nfs_server *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 				      void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) /* io.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) extern void nfs_start_io_read(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) extern void nfs_end_io_read(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) extern void nfs_start_io_write(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) extern void nfs_end_io_write(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) extern void nfs_start_io_direct(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) extern void nfs_end_io_direct(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static inline bool nfs_file_io_is_buffered(struct nfs_inode *nfsi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	return test_bit(NFS_INO_ODIRECT, &nfsi->flags) == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) /* namespace.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) #define NFS_PATH_CANONICAL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) extern char *nfs_path(char **p, struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		      char *buffer, ssize_t buflen, unsigned flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) extern struct vfsmount *nfs_d_automount(struct path *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int nfs_submount(struct fs_context *, struct nfs_server *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) int nfs_do_submount(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /* getroot.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) extern int nfs_get_root(struct super_block *s, struct fs_context *fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) #if IS_ENABLED(CONFIG_NFS_V4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct nfs_pgio_completion_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) /* read.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 			struct inode *inode, bool force_mds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			const struct nfs_pgio_completion_ops *compl_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) void nfs_umount_begin(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) int  nfs_statfs(struct dentry *, struct kstatfs *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) int  nfs_show_options(struct seq_file *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) int  nfs_show_devname(struct seq_file *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) int  nfs_show_path(struct seq_file *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) int  nfs_show_stats(struct seq_file *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) int  nfs_reconfigure(struct fs_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) /* write.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			struct inode *inode, int ioflags, bool force_mds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			const struct nfs_pgio_completion_ops *compl_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) extern void nfs_commit_free(struct nfs_commit_data *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) extern void nfs_write_prepare(struct rpc_task *task, void *calldata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) extern void nfs_commit_prepare(struct rpc_task *task, void *calldata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) extern int nfs_initiate_commit(struct rpc_clnt *clnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 			       struct nfs_commit_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			       const struct nfs_rpc_ops *nfs_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 			       const struct rpc_call_ops *call_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 			       int how, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) extern void nfs_init_commit(struct nfs_commit_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 			    struct list_head *head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 			    struct pnfs_layout_segment *lseg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 			    struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) int nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 			 struct nfs_commit_info *cinfo, int max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) unsigned long nfs_reqs_to_commit(struct nfs_commit_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) int nfs_scan_commit(struct inode *inode, struct list_head *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		    struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) void nfs_mark_request_commit(struct nfs_page *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 			     struct pnfs_layout_segment *lseg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			     struct nfs_commit_info *cinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 			     u32 ds_commit_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) int nfs_write_need_commit(struct nfs_pgio_header *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) void nfs_writeback_update_inode(struct nfs_pgio_header *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 			    int how, struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) void nfs_retry_commit(struct list_head *page_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		      struct pnfs_layout_segment *lseg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		      struct nfs_commit_info *cinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		      u32 ds_commit_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) void nfs_commitdata_release(struct nfs_commit_data *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) void nfs_request_add_commit_list(struct nfs_page *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 				 struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) void nfs_request_add_commit_list_locked(struct nfs_page *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		struct list_head *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) void nfs_request_remove_commit_list(struct nfs_page *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 				    struct nfs_commit_info *cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) void nfs_init_cinfo(struct nfs_commit_info *cinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		    struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		    struct nfs_direct_req *dreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) int nfs_key_timeout_notify(struct file *filp, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) bool nfs_ctx_key_to_expire(struct nfs_open_context *ctx, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) void nfs_pageio_stop_mirroring(struct nfs_pageio_descriptor *pgio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) int nfs_filemap_write_and_wait_range(struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		loff_t lstart, loff_t lend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) #ifdef CONFIG_NFS_V4_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) pnfs_bucket_clear_pnfs_ds_commit_verifiers(struct pnfs_commit_bucket *buckets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		unsigned int nbuckets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	for (i = 0; i < nbuckets; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	struct pnfs_commit_array *array;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	list_for_each_entry_rcu(array, &cinfo->commits, cinfo_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		pnfs_bucket_clear_pnfs_ds_commit_verifiers(array->buckets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 				array->nbuckets);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) #ifdef CONFIG_MIGRATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) extern int nfs_migrate_page(struct address_space *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		struct page *, struct page *, enum migrate_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) nfs_write_verifier_cmp(const struct nfs_write_verifier *v1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 		const struct nfs_write_verifier *v2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	return memcmp(v1->data, v2->data, sizeof(v1->data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) nfs_write_match_verf(const struct nfs_writeverf *verf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		struct nfs_page *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	return verf->committed > NFS_UNSTABLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 		!nfs_write_verifier_cmp(&req->wb_verf, &verf->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /* unlink.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) extern struct rpc_task *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		 struct dentry *old_dentry, struct dentry *new_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		 void (*complete)(struct rpc_task *, struct nfs_renamedata *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) extern int nfs_sillyrename(struct inode *dir, struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) /* direct.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 			      struct nfs_direct_req *dreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) /* nfs4proc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 			    const struct nfs_client_initdata *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) extern int nfs40_walk_client_list(struct nfs_client *clp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 				struct nfs_client **result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 				const struct cred *cred);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) extern int nfs41_walk_client_list(struct nfs_client *clp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 				struct nfs_client **result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 				const struct cred *cred);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) extern void nfs4_test_session_trunk(struct rpc_clnt *clnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 				struct rpc_xprt *xprt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 				void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) static inline struct inode *nfs_igrab_and_active(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	if (sb && nfs_sb_active(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 		if (igrab(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 			return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		nfs_sb_deactive(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) static inline void nfs_iput_and_deactive(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	if (inode != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		nfs_sb_deactive(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)  * Determine the device name as a string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) static inline char *nfs_devname(struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 				char *buffer, ssize_t buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	char *dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	return nfs_path(&dummy, dentry, buffer, buflen, NFS_PATH_CANONICAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)  * Determine the actual block size (and log2 thereof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	/* make sure blocksize is a power of two */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	if ((bsize & (bsize - 1)) || nrbitsp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 		unsigned char	nrbits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 		for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 			;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 		bsize = 1 << nrbits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 		if (nrbitsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 			*nrbitsp = nrbits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	return bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)  * Calculate the number of 512byte blocks used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) static inline blkcnt_t nfs_calc_block_size(u64 tsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	blkcnt_t used = (tsize + 511) >> 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	return (used > ULONG_MAX) ? ULONG_MAX : used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)  * Compute and set NFS server blocksize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	if (bsize < NFS_MIN_FILE_IO_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		bsize = NFS_DEF_FILE_IO_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	else if (bsize >= NFS_MAX_FILE_IO_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		bsize = NFS_MAX_FILE_IO_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	return nfs_block_bits(bsize, nrbitsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)  * Determine the maximum file size for a superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	sb->s_maxbytes = (loff_t)maxfilesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 		sb->s_maxbytes = MAX_LFS_FILESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)  * Record the page as unstable (an extra writeback period) and mark its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)  * inode as dirty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) void nfs_mark_page_unstable(struct page *page, struct nfs_commit_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	if (!cinfo->dreq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		struct inode *inode = page_file_mapping(page)->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 		/* This page is really still in write-back - just that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		 * writeback is happening on the server now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 		inc_node_page_state(page, NR_WRITEBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 		inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 		__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)  * Determine the number of bytes of data the page contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) unsigned int nfs_page_length(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	loff_t i_size = i_size_read(page_file_mapping(page)->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	if (i_size > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 		pgoff_t index = page_index(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 		pgoff_t end_index = (i_size - 1) >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 		if (index < end_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 			return PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 		if (index == end_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 			return ((i_size - 1) & ~PAGE_MASK) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)  * Convert a umode to a dirent->d_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) unsigned char nfs_umode_to_dtype(umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	return (mode >> 12) & 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)  * Determine the number of pages in an array of length 'len' and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)  * with a base offset of 'base'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) unsigned int nfs_page_array_len(unsigned int base, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 	return ((unsigned long)len + (unsigned long)base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 		PAGE_SIZE - 1) >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)  * Convert a struct timespec64 into a 64-bit change attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)  * This does approximately the same thing as timespec64_to_ns(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)  * but for calculation efficiency, we multiply the seconds by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)  * 1024*1024*1024.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) #ifdef CONFIG_CRC32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)  * nfs_fhandle_hash - calculate the crc32 hash for the filehandle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)  * @fh - pointer to filehandle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)  * returns a crc32 hash for the filehandle that is compatible with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)  * the one displayed by "wireshark".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 	return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 				NFS4_STATEID_OTHER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) static inline bool nfs_error_is_fatal(int err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	switch (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 	case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	case -EINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	case -EACCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	case -EDQUOT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	case -EFBIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	case -EIO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	case -ENOSPC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	case -EROFS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 	case -ESTALE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	case -E2BIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 	case -ENOMEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	case -ETIMEDOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) static inline bool nfs_error_is_fatal_on_server(int err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 	switch (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 	case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 	case -EINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	return nfs_error_is_fatal(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)  * Select between a default port value and a user-specified port value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)  * If a zero value is set, then autobind will be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) static inline void nfs_set_port(struct sockaddr *sap, int *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) 				const unsigned short default_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 	if (*port == NFS_UNSPEC_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 		*port = default_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	rpc_set_port(sap, *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }