xref: /linux/fs/nfsd/nfsd.h (revision ffbf5434ee57fb93f400705ea2674897ac7dc5f9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Hodge-podge collection of knfsd-related stuff.
4  * I will sort this out later.
5  *
6  * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
7  */
8 
9 #ifndef LINUX_NFSD_NFSD_H
10 #define LINUX_NFSD_NFSD_H
11 
12 #include <linux/types.h>
13 #include <linux/mount.h>
14 
15 #include <linux/sunrpc/svc.h>
16 #include <linux/sunrpc/svc_xprt.h>
17 
18 #include <uapi/linux/nfsd/debug.h>
19 
20 #undef ifdebug
21 #ifdef CONFIG_SUNRPC_DEBUG
22 # define ifdebug(flag)		if (nfsd_debug & NFSDDBG_##flag)
23 #else
24 # define ifdebug(flag)		if (0)
25 #endif
26 
27 /*
28  * nfsd version
29  */
30 #define NFSD_MINVERS			2
31 #define	NFSD_MAXVERS			4
32 #define NFSD_SUPPORTED_MINOR_VERSION	2
33 bool nfsd_support_version(int vers);
34 
35 /*
36  * Default and maximum payload size (NFS READ or WRITE), in bytes.
37  * The maximum is an implementation limit.
38  */
39 enum {
40 	NFSSVC_DEFBLKSIZE       = 4 * 1024 * 1024,
41 	NFSSVC_MAXBLKSIZE       = RPCSVC_MAXPAYLOAD,
42 };
43 
44 /* Maximum number of operations per session compound */
45 #define NFSD_MAX_OPS_PER_COMPOUND	200
46 
47 extern struct svc_program	nfsd_programs[];
48 extern const struct svc_version	nfsd_version2, nfsd_version3, nfsd_version4;
49 extern struct mutex		nfsd_mutex;
50 extern atomic_t			nfsd_th_cnt;		/* number of available threads */
51 
52 extern const struct seq_operations nfs_exports_op;
53 
54 struct nfsd_thread_local_info {
55 	struct nfs4_client	**ntli_lease_breaker;
56 	int			ntli_cachetype;
57 };
58 
59 /*
60  * Common void argument and result helpers
61  */
62 struct nfsd_voidargs { };
63 struct nfsd_voidres { };
64 bool		nfssvc_decode_voidarg(struct svc_rqst *rqstp,
65 				      struct xdr_stream *xdr);
66 bool		nfssvc_encode_voidres(struct svc_rqst *rqstp,
67 				      struct xdr_stream *xdr);
68 
69 /*
70  * Function prototypes.
71  */
72 int		nfsd_svc(int n, int *nservers, struct net *net,
73 			 const struct cred *cred, const char *scope);
74 int		nfsd_dispatch(struct svc_rqst *rqstp);
75 
76 int		nfsd_nrthreads(struct net *);
77 int		nfsd_nrpools(struct net *);
78 int		nfsd_get_nrthreads(int n, int *, struct net *);
79 int		nfsd_set_nrthreads(int n, int *, struct net *);
80 void		nfsd_shutdown_threads(struct net *net);
81 
82 struct svc_rqst *nfsd_current_rqst(void);
83 
84 struct nfsdfs_client {
85 	struct kref cl_ref;
86 	void (*cl_release)(struct kref *kref);
87 };
88 
89 struct nfsd_net;
90 
91 struct nfsdfs_client *get_nfsdfs_client(struct inode *);
92 struct dentry *nfsd_client_mkdir(struct nfsd_net *nn,
93 				 struct nfsdfs_client *ncl, u32 id,
94 				 const struct tree_descr *,
95 				 struct dentry **fdentries);
96 void nfsd_client_rmdir(struct dentry *dentry);
97 int nfsd_cache_notify(struct cache_detail *cd, struct cache_head *h, u32 cache_type);
98 
99 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
100 #ifdef CONFIG_NFSD_V2_ACL
101 extern const struct svc_version nfsd_acl_version2;
102 #else
103 #define nfsd_acl_version2 NULL
104 #endif
105 #ifdef CONFIG_NFSD_V3_ACL
106 extern const struct svc_version nfsd_acl_version3;
107 #else
108 #define nfsd_acl_version3 NULL
109 #endif
110 #endif
111 
112 #if IS_ENABLED(CONFIG_NFS_LOCALIO)
113 extern const struct svc_version localio_version1;
114 #endif
115 
116 enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
117 int nfsd_vers(struct nfsd_net *nn, int vers, enum vers_op change);
118 bool nfsd_version_registerable(struct net *net,
119 			       const struct svc_program *progp, u32 version);
120 int nfsd_minorversion(struct nfsd_net *nn, u32 minorversion, enum vers_op change);
121 void nfsd_reset_versions(struct nfsd_net *nn);
122 int nfsd_create_serv(struct net *net, bool no_rpcbind);
123 void nfsd_destroy_serv(struct net *net);
124 
125 #ifdef CONFIG_DEBUG_FS
126 void nfsd_debugfs_init(void);
127 void nfsd_debugfs_exit(void);
128 #else
129 static inline void nfsd_debugfs_init(void) {}
130 static inline void nfsd_debugfs_exit(void) {}
131 #endif
132 
133 extern bool nfsd_disable_splice_read __read_mostly;
134 extern bool nfsd_delegts_enabled __read_mostly;
135 
136 enum {
137 	/* Any new NFSD_IO enum value must be added at the end */
138 	NFSD_IO_BUFFERED,
139 	NFSD_IO_DONTCACHE,
140 	NFSD_IO_DIRECT,
141 };
142 
143 extern u64 nfsd_io_cache_read __read_mostly;
144 extern u64 nfsd_io_cache_write __read_mostly;
145 
146 extern int nfsd_max_blksize;
147 
148 bool nfsd_v4client(struct svc_rqst *rqstp);
149 
150 /*
151  * lockd binding
152  */
153 void		nfsd_lockd_init(void);
154 void		nfsd_lockd_shutdown(void);
155 
156 
157 #endif /* LINUX_NFSD_NFSD_H */
158