Deleted Added
full compact
nfs.h (17761) nfs.h (19449)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs.h 8.1 (Berkeley) 6/10/93
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs.h 8.1 (Berkeley) 6/10/93
37 * $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
37 * $Id: nfs.h,v 1.18 1996/08/21 21:55:44 dyson Exp $
38 */
39
40#ifndef _NFS_NFS_H_
41#define _NFS_NFS_H_
42
43#include <nfs/rpcv2.h>
44
45/*
46 * Tunable constants for nfs
47 */
48
49#define NFS_MAXIOVEC 34
50#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
51#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
52#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
53#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
54#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
55#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
56#define NFS_MAXREXMIT 100 /* Stop counting after this many */
57#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
58#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
59#define NFS_MAXGRPS 16 /* Max. size of groups list */
60#ifndef NFS_MINATTRTIMO
61#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
62#endif
63#ifndef NFS_MAXATTRTIMO
64#define NFS_MAXATTRTIMO 60
65#endif
66#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
67#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
68#define NFS_READDIRSIZE 8192 /* Def. readdir size */
69#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
70#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
71#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
72#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
73#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
74#ifndef NFS_GATHERDELAY
75#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
76#endif
77#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
78
79/*
80 * Oddballs
81 */
82#define NMOD(a) ((a) % nfs_asyncdaemons)
83#define NFS_CMPFH(n, f, s) \
84 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
85#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
86#define NFS_SRVMAXDATA(n) \
87 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
88 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
89
90/*
91 * XXX
92 * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but
93 * until then...
94 * Same goes for sys/malloc.h, which needs M_NFSDIROFF,
95 * M_NFSRVDESC and M_NFSBIGFH added.
96 * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an
97 * exclusive create.
98 * The B_INVAFTERWRITE flag should be set to whatever is required by the
99 * buffer cache code to say "Invalidate the block after it is written back".
100 */
101#ifndef B_NEEDCOMMIT
102#define B_NEEDCOMMIT B_APPENDWRITE
103#endif
104#ifndef M_NFSRVDESC
105#define M_NFSRVDESC M_TEMP
106#endif
107#ifndef M_NFSDIROFF
108#define M_NFSDIROFF M_TEMP
109#endif
110#ifndef M_NFSBIGFH
111#define M_NFSBIGFH M_TEMP
112#endif
113#ifndef VA_EXCLUSIVE
114#define VA_EXCLUSIVE 0
115#endif
116#ifdef __FreeBSD__
117#define B_INVAFTERWRITE B_NOCACHE
118#else
119#define B_INVAFTERWRITE B_INVAL
120#endif
121
122/*
123 * These ifdefs try to handle the differences between the various 4.4BSD-Lite
124 * based vfs interfaces.
125 * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to
126 * differentiate between NetBSD-1.0 and NetBSD-current, so..
127 * I also don't know about BSDi's 2.0 release.
128 */
129#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
130#define HAS_VOPLEASE 1
131#endif
132#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
133#define HAS_VOPREVOKE 1
134#endif
135
136/*
137 * The IO_METASYNC flag should be implemented for local file systems.
138 * (Until then, it is nothin at all.)
139 */
140#ifndef IO_METASYNC
141#define IO_METASYNC 0
142#endif
143
144/*
145 * Set the attribute timeout based on how recently the file has been modified.
146 */
147#define NFS_ATTRTIMEO(np) \
148 ((((np)->n_flag & NMODIFIED) || \
149 (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
150 ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
151 (time.tv_sec - (np)->n_mtime) / 10))
152
153/*
154 * Expected allocation sizes for major data structures. If the actual size
155 * of the structure exceeds these sizes, then malloc() will be allocating
156 * almost twice the memory required. This is used in nfs_init() to warn
157 * the sysadmin that the size of a structure should be reduced.
158 * (These sizes are always a power of 2. If the kernel malloc() changes
159 * to one that does not allocate space in powers of 2 size, then this all
160 * becomes bunk!)
161 */
162#define NFS_NODEALLOC 256
163#define NFS_MNTALLOC 512
164#define NFS_SVCALLOC 256
165#define NFS_UIDALLOC 128
166
167/*
168 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
169 * should ever try and use it.
170 */
171struct nfsd_args {
172 int sock; /* Socket to serve */
173 caddr_t name; /* Client address for connection based sockets */
174 int namelen; /* Length of name */
175};
176
177struct nfsd_srvargs {
178 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
179 uid_t nsd_uid; /* Effective uid mapped to cred */
180 u_long nsd_haddr; /* Ip address of client */
181 struct ucred nsd_cr; /* Cred. uid maps to */
182 int nsd_authlen; /* Length of auth string (ret) */
183 u_char *nsd_authstr; /* Auth string (ret) */
184 int nsd_verflen; /* and the verfier */
185 u_char *nsd_verfstr;
186 struct timeval nsd_timestamp; /* timestamp from verifier */
187 u_long nsd_ttl; /* credential ttl (sec) */
188 NFSKERBKEY_T nsd_key; /* Session key */
189};
190
191struct nfsd_cargs {
192 char *ncd_dirp; /* Mount dir path */
193 uid_t ncd_authuid; /* Effective uid */
194 int ncd_authtype; /* Type of authenticator */
195 int ncd_authlen; /* Length of authenticator string */
196 u_char *ncd_authstr; /* Authenticator string */
197 int ncd_verflen; /* and the verifier */
198 u_char *ncd_verfstr;
199 NFSKERBKEY_T ncd_key; /* Session key */
200};
201
202/*
203 * Stats structure
204 */
205struct nfsstats {
206 int attrcache_hits;
207 int attrcache_misses;
208 int lookupcache_hits;
209 int lookupcache_misses;
210 int direofcache_hits;
211 int direofcache_misses;
212 int biocache_reads;
213 int read_bios;
214 int read_physios;
215 int biocache_writes;
216 int write_bios;
217 int write_physios;
218 int biocache_readlinks;
219 int readlink_bios;
220 int biocache_readdirs;
221 int readdir_bios;
222 int rpccnt[NFS_NPROCS];
223 int rpcretries;
224 int srvrpccnt[NFS_NPROCS];
225 int srvrpc_errs;
226 int srv_errs;
227 int rpcrequests;
228 int rpctimeouts;
229 int rpcunexpected;
230 int rpcinvalid;
231 int srvcache_inproghits;
232 int srvcache_idemdonehits;
233 int srvcache_nonidemdonehits;
234 int srvcache_misses;
235 int srvnqnfs_leases;
236 int srvnqnfs_maxleases;
237 int srvnqnfs_getleases;
238 int srvvop_writes;
239};
240
241/*
242 * Flags for nfssvc() system call.
243 */
244#define NFSSVC_BIOD 0x002
245#define NFSSVC_NFSD 0x004
246#define NFSSVC_ADDSOCK 0x008
247#define NFSSVC_AUTHIN 0x010
248#define NFSSVC_GOTAUTH 0x040
249#define NFSSVC_AUTHINFAIL 0x080
250#define NFSSVC_MNTD 0x100
251
252/*
253 * fs.nfs sysctl(3) identifiers
254 */
255#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
256
257#define FS_NFS_NAMES { \
258 { 0, 0 }, \
259 { "nfsstats", CTLTYPE_STRUCT }, \
260}
261
262/*
263 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
264 * What should be in this set is open to debate, but I believe that since
265 * I/O system calls on ufs are never interrupted by signals the set should
266 * be minimal. My reasoning is that many current programs that use signals
267 * such as SIGALRM will not expect file I/O system calls to be interrupted
268 * by them and break.
269 */
270#if defined(KERNEL) || defined(_KERNEL)
271
272struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
273
274#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
275 sigmask(SIGHUP)|sigmask(SIGQUIT))
276
277/*
278 * Socket errors ignored for connectionless sockets??
279 * For now, ignore them all
280 */
281#define NFSIGNORE_SOERROR(s, e) \
282 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
283 ((s) & PR_CONNREQUIRED) == 0)
284
285/*
286 * Nfs outstanding request list element
287 */
288struct nfsreq {
289 TAILQ_ENTRY(nfsreq) r_chain;
290 struct mbuf *r_mreq;
291 struct mbuf *r_mrep;
292 struct mbuf *r_md;
293 caddr_t r_dpos;
294 struct nfsmount *r_nmp;
295 struct vnode *r_vp;
296 u_long r_xid;
297 int r_flags; /* flags on request, see below */
298 int r_retry; /* max retransmission count */
299 int r_rexmit; /* current retrans count */
300 int r_timer; /* tick counter on reply */
301 int r_procnum; /* NFS procedure number */
302 int r_rtt; /* RTT for rpc */
303 struct proc *r_procp; /* Proc that did I/O system call */
304};
305
306/*
307 * Queue head for nfsreq's
308 */
309extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
310
311/* Flag values for r_flags */
312#define R_TIMING 0x01 /* timing request (in mntp) */
313#define R_SENT 0x02 /* request has been sent */
314#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
315#define R_INTR 0x08 /* intr mnt, signal pending */
316#define R_SOCKERR 0x10 /* Fatal error on socket */
317#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
318#define R_MUSTRESEND 0x40 /* Must resend request */
319#define R_GETONEREP 0x80 /* Probe for one reply only */
320
321/*
322 * A list of nfssvc_sock structures is maintained with all the sockets
323 * that require service by the nfsd.
324 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
325 * and uid hash lists.
326 */
327#ifndef NFS_UIDHASHSIZ
328#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
329#endif
330#define NUIDHASH(sock, uid) \
331 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
332#ifndef NFS_WDELAYHASHSIZ
333#define NFS_WDELAYHASHSIZ 16 /* and with this */
334#endif
335#define NWDELAYHASH(sock, f) \
336 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
337#ifndef NFS_MUIDHASHSIZ
38 */
39
40#ifndef _NFS_NFS_H_
41#define _NFS_NFS_H_
42
43#include <nfs/rpcv2.h>
44
45/*
46 * Tunable constants for nfs
47 */
48
49#define NFS_MAXIOVEC 34
50#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
51#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
52#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
53#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
54#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
55#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
56#define NFS_MAXREXMIT 100 /* Stop counting after this many */
57#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
58#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
59#define NFS_MAXGRPS 16 /* Max. size of groups list */
60#ifndef NFS_MINATTRTIMO
61#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
62#endif
63#ifndef NFS_MAXATTRTIMO
64#define NFS_MAXATTRTIMO 60
65#endif
66#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
67#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
68#define NFS_READDIRSIZE 8192 /* Def. readdir size */
69#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
70#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
71#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
72#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
73#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
74#ifndef NFS_GATHERDELAY
75#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
76#endif
77#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
78
79/*
80 * Oddballs
81 */
82#define NMOD(a) ((a) % nfs_asyncdaemons)
83#define NFS_CMPFH(n, f, s) \
84 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
85#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
86#define NFS_SRVMAXDATA(n) \
87 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
88 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
89
90/*
91 * XXX
92 * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but
93 * until then...
94 * Same goes for sys/malloc.h, which needs M_NFSDIROFF,
95 * M_NFSRVDESC and M_NFSBIGFH added.
96 * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an
97 * exclusive create.
98 * The B_INVAFTERWRITE flag should be set to whatever is required by the
99 * buffer cache code to say "Invalidate the block after it is written back".
100 */
101#ifndef B_NEEDCOMMIT
102#define B_NEEDCOMMIT B_APPENDWRITE
103#endif
104#ifndef M_NFSRVDESC
105#define M_NFSRVDESC M_TEMP
106#endif
107#ifndef M_NFSDIROFF
108#define M_NFSDIROFF M_TEMP
109#endif
110#ifndef M_NFSBIGFH
111#define M_NFSBIGFH M_TEMP
112#endif
113#ifndef VA_EXCLUSIVE
114#define VA_EXCLUSIVE 0
115#endif
116#ifdef __FreeBSD__
117#define B_INVAFTERWRITE B_NOCACHE
118#else
119#define B_INVAFTERWRITE B_INVAL
120#endif
121
122/*
123 * These ifdefs try to handle the differences between the various 4.4BSD-Lite
124 * based vfs interfaces.
125 * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to
126 * differentiate between NetBSD-1.0 and NetBSD-current, so..
127 * I also don't know about BSDi's 2.0 release.
128 */
129#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
130#define HAS_VOPLEASE 1
131#endif
132#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
133#define HAS_VOPREVOKE 1
134#endif
135
136/*
137 * The IO_METASYNC flag should be implemented for local file systems.
138 * (Until then, it is nothin at all.)
139 */
140#ifndef IO_METASYNC
141#define IO_METASYNC 0
142#endif
143
144/*
145 * Set the attribute timeout based on how recently the file has been modified.
146 */
147#define NFS_ATTRTIMEO(np) \
148 ((((np)->n_flag & NMODIFIED) || \
149 (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
150 ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
151 (time.tv_sec - (np)->n_mtime) / 10))
152
153/*
154 * Expected allocation sizes for major data structures. If the actual size
155 * of the structure exceeds these sizes, then malloc() will be allocating
156 * almost twice the memory required. This is used in nfs_init() to warn
157 * the sysadmin that the size of a structure should be reduced.
158 * (These sizes are always a power of 2. If the kernel malloc() changes
159 * to one that does not allocate space in powers of 2 size, then this all
160 * becomes bunk!)
161 */
162#define NFS_NODEALLOC 256
163#define NFS_MNTALLOC 512
164#define NFS_SVCALLOC 256
165#define NFS_UIDALLOC 128
166
167/*
168 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
169 * should ever try and use it.
170 */
171struct nfsd_args {
172 int sock; /* Socket to serve */
173 caddr_t name; /* Client address for connection based sockets */
174 int namelen; /* Length of name */
175};
176
177struct nfsd_srvargs {
178 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
179 uid_t nsd_uid; /* Effective uid mapped to cred */
180 u_long nsd_haddr; /* Ip address of client */
181 struct ucred nsd_cr; /* Cred. uid maps to */
182 int nsd_authlen; /* Length of auth string (ret) */
183 u_char *nsd_authstr; /* Auth string (ret) */
184 int nsd_verflen; /* and the verfier */
185 u_char *nsd_verfstr;
186 struct timeval nsd_timestamp; /* timestamp from verifier */
187 u_long nsd_ttl; /* credential ttl (sec) */
188 NFSKERBKEY_T nsd_key; /* Session key */
189};
190
191struct nfsd_cargs {
192 char *ncd_dirp; /* Mount dir path */
193 uid_t ncd_authuid; /* Effective uid */
194 int ncd_authtype; /* Type of authenticator */
195 int ncd_authlen; /* Length of authenticator string */
196 u_char *ncd_authstr; /* Authenticator string */
197 int ncd_verflen; /* and the verifier */
198 u_char *ncd_verfstr;
199 NFSKERBKEY_T ncd_key; /* Session key */
200};
201
202/*
203 * Stats structure
204 */
205struct nfsstats {
206 int attrcache_hits;
207 int attrcache_misses;
208 int lookupcache_hits;
209 int lookupcache_misses;
210 int direofcache_hits;
211 int direofcache_misses;
212 int biocache_reads;
213 int read_bios;
214 int read_physios;
215 int biocache_writes;
216 int write_bios;
217 int write_physios;
218 int biocache_readlinks;
219 int readlink_bios;
220 int biocache_readdirs;
221 int readdir_bios;
222 int rpccnt[NFS_NPROCS];
223 int rpcretries;
224 int srvrpccnt[NFS_NPROCS];
225 int srvrpc_errs;
226 int srv_errs;
227 int rpcrequests;
228 int rpctimeouts;
229 int rpcunexpected;
230 int rpcinvalid;
231 int srvcache_inproghits;
232 int srvcache_idemdonehits;
233 int srvcache_nonidemdonehits;
234 int srvcache_misses;
235 int srvnqnfs_leases;
236 int srvnqnfs_maxleases;
237 int srvnqnfs_getleases;
238 int srvvop_writes;
239};
240
241/*
242 * Flags for nfssvc() system call.
243 */
244#define NFSSVC_BIOD 0x002
245#define NFSSVC_NFSD 0x004
246#define NFSSVC_ADDSOCK 0x008
247#define NFSSVC_AUTHIN 0x010
248#define NFSSVC_GOTAUTH 0x040
249#define NFSSVC_AUTHINFAIL 0x080
250#define NFSSVC_MNTD 0x100
251
252/*
253 * fs.nfs sysctl(3) identifiers
254 */
255#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
256
257#define FS_NFS_NAMES { \
258 { 0, 0 }, \
259 { "nfsstats", CTLTYPE_STRUCT }, \
260}
261
262/*
263 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
264 * What should be in this set is open to debate, but I believe that since
265 * I/O system calls on ufs are never interrupted by signals the set should
266 * be minimal. My reasoning is that many current programs that use signals
267 * such as SIGALRM will not expect file I/O system calls to be interrupted
268 * by them and break.
269 */
270#if defined(KERNEL) || defined(_KERNEL)
271
272struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
273
274#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
275 sigmask(SIGHUP)|sigmask(SIGQUIT))
276
277/*
278 * Socket errors ignored for connectionless sockets??
279 * For now, ignore them all
280 */
281#define NFSIGNORE_SOERROR(s, e) \
282 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
283 ((s) & PR_CONNREQUIRED) == 0)
284
285/*
286 * Nfs outstanding request list element
287 */
288struct nfsreq {
289 TAILQ_ENTRY(nfsreq) r_chain;
290 struct mbuf *r_mreq;
291 struct mbuf *r_mrep;
292 struct mbuf *r_md;
293 caddr_t r_dpos;
294 struct nfsmount *r_nmp;
295 struct vnode *r_vp;
296 u_long r_xid;
297 int r_flags; /* flags on request, see below */
298 int r_retry; /* max retransmission count */
299 int r_rexmit; /* current retrans count */
300 int r_timer; /* tick counter on reply */
301 int r_procnum; /* NFS procedure number */
302 int r_rtt; /* RTT for rpc */
303 struct proc *r_procp; /* Proc that did I/O system call */
304};
305
306/*
307 * Queue head for nfsreq's
308 */
309extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
310
311/* Flag values for r_flags */
312#define R_TIMING 0x01 /* timing request (in mntp) */
313#define R_SENT 0x02 /* request has been sent */
314#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
315#define R_INTR 0x08 /* intr mnt, signal pending */
316#define R_SOCKERR 0x10 /* Fatal error on socket */
317#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
318#define R_MUSTRESEND 0x40 /* Must resend request */
319#define R_GETONEREP 0x80 /* Probe for one reply only */
320
321/*
322 * A list of nfssvc_sock structures is maintained with all the sockets
323 * that require service by the nfsd.
324 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
325 * and uid hash lists.
326 */
327#ifndef NFS_UIDHASHSIZ
328#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
329#endif
330#define NUIDHASH(sock, uid) \
331 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
332#ifndef NFS_WDELAYHASHSIZ
333#define NFS_WDELAYHASHSIZ 16 /* and with this */
334#endif
335#define NWDELAYHASH(sock, f) \
336 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
337#ifndef NFS_MUIDHASHSIZ
338#define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */
338#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
339#endif
340#define NMUIDHASH(nmp, uid) \
341 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
342#define NFSNOHASH(fhsum) \
343 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
344
345/*
346 * Network address hash list element
347 */
348union nethostaddr {
349 u_long had_inetaddr;
350 struct mbuf *had_nam;
351};
352
353struct nfsuid {
354 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
355 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
356 int nu_flag; /* Flags */
357 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
358 struct ucred nu_cr; /* Cred uid mapped to */
359 int nu_expire; /* Expiry time (sec) */
360 struct timeval nu_timestamp; /* Kerb. timestamp */
361 u_long nu_nickname; /* Nickname on server */
362 NFSKERBKEY_T nu_key; /* and session key */
363};
364
365#define nu_inetaddr nu_haddr.had_inetaddr
366#define nu_nam nu_haddr.had_nam
367/* Bits for nu_flag */
368#define NU_INETADDR 0x1
369#define NU_NAM 0x2
370#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
371
372struct nfssvc_sock {
373 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
374 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
375 struct file *ns_fp;
376 struct socket *ns_so;
377 struct mbuf *ns_nam;
378 struct mbuf *ns_raw;
379 struct mbuf *ns_rawend;
380 struct mbuf *ns_rec;
381 struct mbuf *ns_recend;
382 struct mbuf *ns_frag;
383 int ns_flag;
384 int ns_solock;
385 int ns_cc;
386 int ns_reclen;
387 int ns_numuids;
388 u_long ns_sref;
389 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
390 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
391 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
392};
393
394/* Bits for "ns_flag" */
395#define SLP_VALID 0x01
396#define SLP_DOREC 0x02
397#define SLP_NEEDQ 0x04
398#define SLP_DISCONN 0x08
399#define SLP_GETSTREAM 0x10
400#define SLP_LASTFRAG 0x20
401#define SLP_ALLFLAGS 0xff
402
403extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
404extern int nfssvc_sockhead_flag;
405#define SLP_INIT 0x01
406#define SLP_WANTINIT 0x02
407
408/*
409 * One of these structures is allocated for each nfsd.
410 */
411struct nfsd {
412 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
413 int nfsd_flag; /* NFSD_ flags */
414 struct nfssvc_sock *nfsd_slp; /* Current socket */
415 int nfsd_authlen; /* Authenticator len */
416 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
417 int nfsd_verflen; /* and the Verifier */
418 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
419 struct proc *nfsd_procp; /* Proc ptr */
420 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
421};
422
423/* Bits for "nfsd_flag" */
424#define NFSD_WAITING 0x01
425#define NFSD_REQINPROG 0x02
426#define NFSD_NEEDAUTH 0x04
427#define NFSD_AUTHFAIL 0x08
428
429/*
430 * This structure is used by the server for describing each request.
431 * Some fields are used only when write request gathering is performed.
432 */
433struct nfsrv_descript {
434 u_quad_t nd_time; /* Write deadline (usec) */
435 off_t nd_off; /* Start byte offset */
436 off_t nd_eoff; /* and end byte offset */
437 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
438 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
439 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
440 struct mbuf *nd_mrep; /* Request mbuf list */
441 struct mbuf *nd_md; /* Current dissect mbuf */
442 struct mbuf *nd_mreq; /* Reply mbuf list */
443 struct mbuf *nd_nam; /* and socket addr */
444 struct mbuf *nd_nam2; /* return socket addr */
445 caddr_t nd_dpos; /* Current dissect pos */
446 int nd_procnum; /* RPC # */
447 int nd_stable; /* storage type */
448 int nd_flag; /* nd_flag */
449 int nd_len; /* Length of this write */
450 int nd_repstat; /* Reply status */
451 u_long nd_retxid; /* Reply xid */
452 u_long nd_duration; /* Lease duration */
453 struct timeval nd_starttime; /* Time RPC initiated */
454 fhandle_t nd_fh; /* File handle */
455 struct ucred nd_cr; /* Credentials */
456};
457
458/* Bits for "nd_flag" */
459#define ND_READ LEASE_READ
460#define ND_WRITE LEASE_WRITE
461#define ND_CHECK 0x04
462#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
463#define ND_NFSV3 0x08
464#define ND_NQNFS 0x10
465#define ND_KERBNICK 0x20
466#define ND_KERBFULL 0x40
467#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
468
469extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
470extern int nfsd_head_flag;
471#define NFSD_CHECKSLP 0x01
472
473/*
474 * These macros compare nfsrv_descript structures.
475 */
476#define NFSW_CONTIG(o, n) \
477 ((o)->nd_eoff >= (n)->nd_off && \
478 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
479
480#define NFSW_SAMECRED(o, n) \
481 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
482 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
483 sizeof (struct ucred)))
484
485int nfs_reply __P((struct nfsreq *));
486int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
487int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *));
488int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));
489int nfs_sndlock __P((int *,struct nfsreq *));
490void nfs_sndunlock __P((int *flagp));
491int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
492int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int));
493int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *));
494int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *));
495int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *));
496int nfs_asyncio __P((struct buf *,struct ucred *));
497int nfs_doio __P((struct buf *,struct ucred *,struct proc *));
498int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *));
499int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *));
500int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *));
501int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
502void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *));
503void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **));
504void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **));
505int netaddr_match __P((int,union nethostaddr *,struct mbuf *));
506int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *));
507int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *));
508int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int));
509void nfsm_adj __P((struct mbuf *,int,int));
510int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *));
511void nfsrv_initcache __P((void));
512int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T));
513int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int));
514int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *));
515int nfs_adv __P((struct mbuf **,caddr_t *,int,int));
516void nfs_nhinit __P((void));
517void nfs_timer __P((void*));
518u_long nfs_hash __P((nfsfh_t *,int));
519void nfsrv_slpderef __P((struct nfssvc_sock *slp));
520int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **));
521void nfsrv_cleancache __P((void));
522int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **));
523int nfs_init __P((void));
524void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *));
525int nfs_connect __P((struct nfsmount *,struct nfsreq *));
526void nfs_disconnect __P((struct nfsmount *nmp));
527int nfs_getattrcache __P((struct vnode *,struct vattr *));
528int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long));
529int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *));
530int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *));
531void nfsrv_init __P((int));
532void nfs_clearcommit __P((struct mount *));
533int nfsrv_errmap __P((struct nfsrv_descript *, int));
534void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
535void nfsrvw_sort __P((gid_t [],int));
536void nfsrv_setcred __P((struct ucred *,struct ucred *));
537int nfs_writebp __P((struct buf *,int));
538int nfsrv_object_create __P(( struct vnode * ));
539void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
540int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
541 struct proc *, struct mbuf **));
542int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
543 struct proc *p));
544
545int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
546 struct proc *procp, struct mbuf **mrq));
547int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
548 struct proc *procp, struct mbuf **mrq));
549int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
550 struct proc *procp, struct mbuf **mrq));
551int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,
552 struct ucred *,struct nfssvc_sock *,struct mbuf *,
553 int *,int));
554int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
555 struct proc *procp, struct mbuf **mrq));
556int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
557 struct proc *procp, struct mbuf **mrq));
558int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
559 struct proc *procp, struct mbuf **mrq));
560int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
561 struct proc *procp, struct mbuf **mrq));
562int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
563 struct proc *procp, struct mbuf **mrq));
564int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
565 struct proc *procp, struct mbuf **mrq));
566int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
567 struct proc *procp, struct mbuf **mrq));
568int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
569 struct proc *procp, struct mbuf **mrq));
570int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
571 struct nfssvc_sock *slp, struct proc *procp,
572 struct mbuf **mrq));
573int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
574 struct proc *procp, struct mbuf **mrq));
575int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
576 struct proc *procp, struct mbuf **mrq));
577int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
578 struct nfssvc_sock *slp, struct proc *procp,
579 struct mbuf **mrq));
580int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
581 struct nfssvc_sock *slp, struct proc *procp,
582 struct mbuf **mrq));
583int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
584 struct proc *procp, struct mbuf **mrq));
585int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
586 struct proc *procp, struct mbuf **mrq));
587int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
588 struct proc *procp, struct mbuf **mrq));
589int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
590 struct proc *procp, struct mbuf **mrq));
591int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
592 struct proc *procp, struct mbuf **mrq));
593int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
594 struct proc *procp, struct mbuf **mrq));
595int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
596 struct proc *procp, struct mbuf **mrq));
597
598
599#endif /* KERNEL */
600
601#endif
339#endif
340#define NMUIDHASH(nmp, uid) \
341 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
342#define NFSNOHASH(fhsum) \
343 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
344
345/*
346 * Network address hash list element
347 */
348union nethostaddr {
349 u_long had_inetaddr;
350 struct mbuf *had_nam;
351};
352
353struct nfsuid {
354 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
355 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
356 int nu_flag; /* Flags */
357 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
358 struct ucred nu_cr; /* Cred uid mapped to */
359 int nu_expire; /* Expiry time (sec) */
360 struct timeval nu_timestamp; /* Kerb. timestamp */
361 u_long nu_nickname; /* Nickname on server */
362 NFSKERBKEY_T nu_key; /* and session key */
363};
364
365#define nu_inetaddr nu_haddr.had_inetaddr
366#define nu_nam nu_haddr.had_nam
367/* Bits for nu_flag */
368#define NU_INETADDR 0x1
369#define NU_NAM 0x2
370#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
371
372struct nfssvc_sock {
373 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
374 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
375 struct file *ns_fp;
376 struct socket *ns_so;
377 struct mbuf *ns_nam;
378 struct mbuf *ns_raw;
379 struct mbuf *ns_rawend;
380 struct mbuf *ns_rec;
381 struct mbuf *ns_recend;
382 struct mbuf *ns_frag;
383 int ns_flag;
384 int ns_solock;
385 int ns_cc;
386 int ns_reclen;
387 int ns_numuids;
388 u_long ns_sref;
389 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
390 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
391 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
392};
393
394/* Bits for "ns_flag" */
395#define SLP_VALID 0x01
396#define SLP_DOREC 0x02
397#define SLP_NEEDQ 0x04
398#define SLP_DISCONN 0x08
399#define SLP_GETSTREAM 0x10
400#define SLP_LASTFRAG 0x20
401#define SLP_ALLFLAGS 0xff
402
403extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
404extern int nfssvc_sockhead_flag;
405#define SLP_INIT 0x01
406#define SLP_WANTINIT 0x02
407
408/*
409 * One of these structures is allocated for each nfsd.
410 */
411struct nfsd {
412 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
413 int nfsd_flag; /* NFSD_ flags */
414 struct nfssvc_sock *nfsd_slp; /* Current socket */
415 int nfsd_authlen; /* Authenticator len */
416 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
417 int nfsd_verflen; /* and the Verifier */
418 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
419 struct proc *nfsd_procp; /* Proc ptr */
420 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
421};
422
423/* Bits for "nfsd_flag" */
424#define NFSD_WAITING 0x01
425#define NFSD_REQINPROG 0x02
426#define NFSD_NEEDAUTH 0x04
427#define NFSD_AUTHFAIL 0x08
428
429/*
430 * This structure is used by the server for describing each request.
431 * Some fields are used only when write request gathering is performed.
432 */
433struct nfsrv_descript {
434 u_quad_t nd_time; /* Write deadline (usec) */
435 off_t nd_off; /* Start byte offset */
436 off_t nd_eoff; /* and end byte offset */
437 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
438 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
439 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
440 struct mbuf *nd_mrep; /* Request mbuf list */
441 struct mbuf *nd_md; /* Current dissect mbuf */
442 struct mbuf *nd_mreq; /* Reply mbuf list */
443 struct mbuf *nd_nam; /* and socket addr */
444 struct mbuf *nd_nam2; /* return socket addr */
445 caddr_t nd_dpos; /* Current dissect pos */
446 int nd_procnum; /* RPC # */
447 int nd_stable; /* storage type */
448 int nd_flag; /* nd_flag */
449 int nd_len; /* Length of this write */
450 int nd_repstat; /* Reply status */
451 u_long nd_retxid; /* Reply xid */
452 u_long nd_duration; /* Lease duration */
453 struct timeval nd_starttime; /* Time RPC initiated */
454 fhandle_t nd_fh; /* File handle */
455 struct ucred nd_cr; /* Credentials */
456};
457
458/* Bits for "nd_flag" */
459#define ND_READ LEASE_READ
460#define ND_WRITE LEASE_WRITE
461#define ND_CHECK 0x04
462#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
463#define ND_NFSV3 0x08
464#define ND_NQNFS 0x10
465#define ND_KERBNICK 0x20
466#define ND_KERBFULL 0x40
467#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
468
469extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
470extern int nfsd_head_flag;
471#define NFSD_CHECKSLP 0x01
472
473/*
474 * These macros compare nfsrv_descript structures.
475 */
476#define NFSW_CONTIG(o, n) \
477 ((o)->nd_eoff >= (n)->nd_off && \
478 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
479
480#define NFSW_SAMECRED(o, n) \
481 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
482 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
483 sizeof (struct ucred)))
484
485int nfs_reply __P((struct nfsreq *));
486int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
487int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *));
488int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));
489int nfs_sndlock __P((int *,struct nfsreq *));
490void nfs_sndunlock __P((int *flagp));
491int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
492int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int));
493int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *));
494int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *));
495int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *));
496int nfs_asyncio __P((struct buf *,struct ucred *));
497int nfs_doio __P((struct buf *,struct ucred *,struct proc *));
498int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *));
499int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *));
500int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *));
501int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
502void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *));
503void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **));
504void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **));
505int netaddr_match __P((int,union nethostaddr *,struct mbuf *));
506int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *));
507int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *));
508int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int));
509void nfsm_adj __P((struct mbuf *,int,int));
510int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *));
511void nfsrv_initcache __P((void));
512int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T));
513int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int));
514int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *));
515int nfs_adv __P((struct mbuf **,caddr_t *,int,int));
516void nfs_nhinit __P((void));
517void nfs_timer __P((void*));
518u_long nfs_hash __P((nfsfh_t *,int));
519void nfsrv_slpderef __P((struct nfssvc_sock *slp));
520int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **));
521void nfsrv_cleancache __P((void));
522int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **));
523int nfs_init __P((void));
524void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *));
525int nfs_connect __P((struct nfsmount *,struct nfsreq *));
526void nfs_disconnect __P((struct nfsmount *nmp));
527int nfs_getattrcache __P((struct vnode *,struct vattr *));
528int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long));
529int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *));
530int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *));
531void nfsrv_init __P((int));
532void nfs_clearcommit __P((struct mount *));
533int nfsrv_errmap __P((struct nfsrv_descript *, int));
534void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
535void nfsrvw_sort __P((gid_t [],int));
536void nfsrv_setcred __P((struct ucred *,struct ucred *));
537int nfs_writebp __P((struct buf *,int));
538int nfsrv_object_create __P(( struct vnode * ));
539void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
540int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
541 struct proc *, struct mbuf **));
542int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
543 struct proc *p));
544
545int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
546 struct proc *procp, struct mbuf **mrq));
547int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
548 struct proc *procp, struct mbuf **mrq));
549int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
550 struct proc *procp, struct mbuf **mrq));
551int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,
552 struct ucred *,struct nfssvc_sock *,struct mbuf *,
553 int *,int));
554int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
555 struct proc *procp, struct mbuf **mrq));
556int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
557 struct proc *procp, struct mbuf **mrq));
558int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
559 struct proc *procp, struct mbuf **mrq));
560int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
561 struct proc *procp, struct mbuf **mrq));
562int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
563 struct proc *procp, struct mbuf **mrq));
564int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
565 struct proc *procp, struct mbuf **mrq));
566int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
567 struct proc *procp, struct mbuf **mrq));
568int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
569 struct proc *procp, struct mbuf **mrq));
570int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
571 struct nfssvc_sock *slp, struct proc *procp,
572 struct mbuf **mrq));
573int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
574 struct proc *procp, struct mbuf **mrq));
575int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
576 struct proc *procp, struct mbuf **mrq));
577int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
578 struct nfssvc_sock *slp, struct proc *procp,
579 struct mbuf **mrq));
580int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
581 struct nfssvc_sock *slp, struct proc *procp,
582 struct mbuf **mrq));
583int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
584 struct proc *procp, struct mbuf **mrq));
585int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
586 struct proc *procp, struct mbuf **mrq));
587int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
588 struct proc *procp, struct mbuf **mrq));
589int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
590 struct proc *procp, struct mbuf **mrq));
591int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
592 struct proc *procp, struct mbuf **mrq));
593int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
594 struct proc *procp, struct mbuf **mrq));
595int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
596 struct proc *procp, struct mbuf **mrq));
597
598
599#endif /* KERNEL */
600
601#endif