Commit | Line | Data |
---|---|---|
a2907882 | 1 | /* |
4acac3d6 | 2 | * Copyright (c) 1989, 1993, 1995 |
99315dca | 3 | * The Regents of the University of California. All rights reserved. |
a2907882 KM |
4 | * |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Rick Macklem at The University of Guelph. | |
7 | * | |
ad787160 C |
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. | |
a2907882 | 23 | * |
ad787160 C |
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 | * | |
fd88f5c5 | 36 | * @(#)nfs.h 8.4 (Berkeley) 5/1/95 |
a2907882 KM |
37 | */ |
38 | ||
4acac3d6 KM |
39 | #ifndef _NFS_NFS_H_ |
40 | #define _NFS_NFS_H_ | |
41 | ||
a2907882 KM |
42 | /* |
43 | * Tunable constants for nfs | |
44 | */ | |
b143b1f4 | 45 | |
170bfd05 | 46 | #define NFS_MAXIOVEC 34 |
4acac3d6 KM |
47 | #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ |
48 | #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ | |
49 | #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ | |
50 | #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ | |
51 | #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ | |
52 | #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ | |
b143b1f4 KM |
53 | #define NFS_MAXREXMIT 100 /* Stop counting after this many */ |
54 | #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ | |
55 | #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ | |
0d515be6 | 56 | #define NFS_MAXGRPS 16 /* Max. size of groups list */ |
4acac3d6 | 57 | #ifndef NFS_MINATTRTIMO |
41f343df | 58 | #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ |
4acac3d6 KM |
59 | #endif |
60 | #ifndef NFS_MAXATTRTIMO | |
41f343df | 61 | #define NFS_MAXATTRTIMO 60 |
4acac3d6 | 62 | #endif |
170bfd05 KM |
63 | #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ |
64 | #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ | |
4acac3d6 | 65 | #define NFS_READDIRSIZE 8192 /* Def. readdir size */ |
0d515be6 KM |
66 | #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ |
67 | #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ | |
0d515be6 | 68 | #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ |
4acac3d6 KM |
69 | #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ |
70 | #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ | |
71 | #ifndef NFS_GATHERDELAY | |
72 | #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ | |
73 | #endif | |
74 | #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ | |
75 | ||
76 | /* | |
77 | * Oddballs | |
78 | */ | |
ffe6f482 | 79 | #define NMOD(a) ((a) % nfs_asyncdaemons) |
4acac3d6 KM |
80 | #define NFS_CMPFH(n, f, s) \ |
81 | ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) | |
82 | #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) | |
83 | #define NFS_SRVMAXDATA(n) \ | |
84 | (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ | |
85 | NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) | |
86 | ||
87 | /* | |
88 | * XXX | |
89 | * The B_INVAFTERWRITE flag should be set to whatever is required by the | |
90 | * buffer cache code to say "Invalidate the block after it is written back". | |
91 | */ | |
92 | #define B_INVAFTERWRITE B_INVAL | |
93 | ||
94 | /* | |
95 | * The IO_METASYNC flag should be implemented for local file systems. | |
96 | * (Until then, it is nothin at all.) | |
97 | */ | |
98 | #ifndef IO_METASYNC | |
99 | #define IO_METASYNC 0 | |
100 | #endif | |
a2907882 | 101 | |
41f343df KM |
102 | /* |
103 | * Set the attribute timeout based on how recently the file has been modified. | |
104 | */ | |
105 | #define NFS_ATTRTIMEO(np) \ | |
106 | ((((np)->n_flag & NMODIFIED) || \ | |
20edda0a KM |
107 | (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ |
108 | ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ | |
109 | (time.tv_sec - (np)->n_mtime) / 10)) | |
41f343df | 110 | |
4acac3d6 KM |
111 | /* |
112 | * Expected allocation sizes for major data structures. If the actual size | |
113 | * of the structure exceeds these sizes, then malloc() will be allocating | |
114 | * almost twice the memory required. This is used in nfs_init() to warn | |
115 | * the sysadmin that the size of a structure should be reduced. | |
116 | * (These sizes are always a power of 2. If the kernel malloc() changes | |
117 | * to one that does not allocate space in powers of 2 size, then this all | |
118 | * becomes bunk!) | |
119 | */ | |
120 | #define NFS_NODEALLOC 256 | |
121 | #define NFS_MNTALLOC 512 | |
122 | #define NFS_SVCALLOC 256 | |
123 | #define NFS_UIDALLOC 128 | |
124 | ||
125 | /* | |
126 | * Arguments to mount NFS | |
127 | */ | |
95fb0766 | 128 | #define NFS_ARGSVERSION 3 /* change when nfs_args changes */ |
4acac3d6 | 129 | struct nfs_args { |
95fb0766 | 130 | int version; /* args structure version number */ |
4acac3d6 KM |
131 | struct sockaddr *addr; /* file server address */ |
132 | int addrlen; /* length of address */ | |
133 | int sotype; /* Socket type */ | |
134 | int proto; /* and Protocol */ | |
135 | u_char *fh; /* File handle to be mounted */ | |
136 | int fhsize; /* Size, in bytes, of fh */ | |
137 | int flags; /* flags */ | |
138 | int wsize; /* write size in bytes */ | |
139 | int rsize; /* read size in bytes */ | |
140 | int readdirsize; /* readdir size in bytes */ | |
141 | int timeo; /* initial timeout in .1 secs */ | |
142 | int retrans; /* times to retry send */ | |
143 | int maxgrouplist; /* Max. size of group list */ | |
144 | int readahead; /* # of blocks to readahead */ | |
145 | int leaseterm; /* Term (sec) of lease */ | |
146 | int deadthresh; /* Retrans threshold */ | |
147 | char *hostname; /* server's name */ | |
148 | }; | |
149 | ||
150 | /* | |
151 | * NFS mount option flags | |
152 | */ | |
153 | #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ | |
154 | #define NFSMNT_WSIZE 0x00000002 /* set write size */ | |
155 | #define NFSMNT_RSIZE 0x00000004 /* set read size */ | |
156 | #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ | |
157 | #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ | |
158 | #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ | |
159 | #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ | |
160 | #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ | |
161 | #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ | |
162 | #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ | |
163 | #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ | |
164 | #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ | |
165 | #define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ | |
166 | #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ | |
167 | #define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ | |
168 | #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ | |
169 | #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ | |
170 | #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ | |
171 | #define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ | |
172 | #define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ | |
173 | #define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ | |
174 | #define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ | |
175 | #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ | |
176 | #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ | |
177 | #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ | |
178 | #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ | |
179 | #define NFSMNT_WANTSND 0x02000000 /* Want above */ | |
180 | #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ | |
181 | #define NFSMNT_WANTRCV 0x08000000 /* Want above */ | |
182 | #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ | |
183 | #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ | |
184 | #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ | |
185 | #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ | |
186 | ||
0d515be6 KM |
187 | /* |
188 | * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs | |
189 | * should ever try and use it. | |
190 | */ | |
191 | struct nfsd_args { | |
192 | int sock; /* Socket to serve */ | |
4acac3d6 | 193 | caddr_t name; /* Client addr for connection based sockets */ |
0d515be6 KM |
194 | int namelen; /* Length of name */ |
195 | }; | |
196 | ||
197 | struct nfsd_srvargs { | |
198 | struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ | |
199 | uid_t nsd_uid; /* Effective uid mapped to cred */ | |
200 | u_long nsd_haddr; /* Ip address of client */ | |
201 | struct ucred nsd_cr; /* Cred. uid maps to */ | |
202 | int nsd_authlen; /* Length of auth string (ret) */ | |
4acac3d6 KM |
203 | u_char *nsd_authstr; /* Auth string (ret) */ |
204 | int nsd_verflen; /* and the verfier */ | |
205 | u_char *nsd_verfstr; | |
206 | struct timeval nsd_timestamp; /* timestamp from verifier */ | |
207 | u_long nsd_ttl; /* credential ttl (sec) */ | |
208 | NFSKERBKEY_T nsd_key; /* Session key */ | |
0d515be6 KM |
209 | }; |
210 | ||
211 | struct nfsd_cargs { | |
212 | char *ncd_dirp; /* Mount dir path */ | |
213 | uid_t ncd_authuid; /* Effective uid */ | |
214 | int ncd_authtype; /* Type of authenticator */ | |
215 | int ncd_authlen; /* Length of authenticator string */ | |
4acac3d6 KM |
216 | u_char *ncd_authstr; /* Authenticator string */ |
217 | int ncd_verflen; /* and the verifier */ | |
218 | u_char *ncd_verfstr; | |
219 | NFSKERBKEY_T ncd_key; /* Session key */ | |
0d515be6 KM |
220 | }; |
221 | ||
222 | /* | |
223 | * Stats structure | |
224 | */ | |
225 | struct nfsstats { | |
226 | int attrcache_hits; | |
227 | int attrcache_misses; | |
228 | int lookupcache_hits; | |
229 | int lookupcache_misses; | |
230 | int direofcache_hits; | |
231 | int direofcache_misses; | |
232 | int biocache_reads; | |
233 | int read_bios; | |
234 | int read_physios; | |
235 | int biocache_writes; | |
236 | int write_bios; | |
237 | int write_physios; | |
238 | int biocache_readlinks; | |
239 | int readlink_bios; | |
240 | int biocache_readdirs; | |
241 | int readdir_bios; | |
242 | int rpccnt[NFS_NPROCS]; | |
243 | int rpcretries; | |
244 | int srvrpccnt[NFS_NPROCS]; | |
245 | int srvrpc_errs; | |
246 | int srv_errs; | |
247 | int rpcrequests; | |
248 | int rpctimeouts; | |
249 | int rpcunexpected; | |
250 | int rpcinvalid; | |
251 | int srvcache_inproghits; | |
252 | int srvcache_idemdonehits; | |
253 | int srvcache_nonidemdonehits; | |
254 | int srvcache_misses; | |
255 | int srvnqnfs_leases; | |
256 | int srvnqnfs_maxleases; | |
257 | int srvnqnfs_getleases; | |
4acac3d6 | 258 | int srvvop_writes; |
0d515be6 KM |
259 | }; |
260 | ||
261 | /* | |
262 | * Flags for nfssvc() system call. | |
263 | */ | |
264 | #define NFSSVC_BIOD 0x002 | |
265 | #define NFSSVC_NFSD 0x004 | |
266 | #define NFSSVC_ADDSOCK 0x008 | |
267 | #define NFSSVC_AUTHIN 0x010 | |
268 | #define NFSSVC_GOTAUTH 0x040 | |
269 | #define NFSSVC_AUTHINFAIL 0x080 | |
270 | #define NFSSVC_MNTD 0x100 | |
271 | ||
4acac3d6 KM |
272 | /* |
273 | * fs.nfs sysctl(3) identifiers | |
274 | */ | |
275 | #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ | |
276 | ||
277 | #define FS_NFS_NAMES { \ | |
278 | { 0, 0 }, \ | |
279 | { "nfsstats", CTLTYPE_STRUCT }, \ | |
280 | } | |
281 | ||
f0f1cbaa KM |
282 | /* |
283 | * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. | |
284 | * What should be in this set is open to debate, but I believe that since | |
285 | * I/O system calls on ufs are never interrupted by signals the set should | |
286 | * be minimal. My reasoning is that many current programs that use signals | |
287 | * such as SIGALRM will not expect file I/O system calls to be interrupted | |
288 | * by them and break. | |
289 | */ | |
0d515be6 | 290 | #ifdef KERNEL |
4acac3d6 KM |
291 | |
292 | struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ | |
293 | ||
f0f1cbaa KM |
294 | #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ |
295 | sigmask(SIGHUP)|sigmask(SIGQUIT)) | |
296 | ||
297 | /* | |
298 | * Socket errors ignored for connectionless sockets?? | |
299 | * For now, ignore them all | |
300 | */ | |
301 | #define NFSIGNORE_SOERROR(s, e) \ | |
302 | ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ | |
303 | ((s) & PR_CONNREQUIRED) == 0) | |
b143b1f4 | 304 | |
a2907882 KM |
305 | /* |
306 | * Nfs outstanding request list element | |
307 | */ | |
308 | struct nfsreq { | |
0bb2c2fc | 309 | TAILQ_ENTRY(nfsreq) r_chain; |
a2907882 KM |
310 | struct mbuf *r_mreq; |
311 | struct mbuf *r_mrep; | |
0d515be6 KM |
312 | struct mbuf *r_md; |
313 | caddr_t r_dpos; | |
f0f1cbaa | 314 | struct nfsmount *r_nmp; |
a2907882 | 315 | struct vnode *r_vp; |
a2907882 | 316 | u_long r_xid; |
0d515be6 KM |
317 | int r_flags; /* flags on request, see below */ |
318 | int r_retry; /* max retransmission count */ | |
319 | int r_rexmit; /* current retrans count */ | |
320 | int r_timer; /* tick counter on reply */ | |
321 | int r_procnum; /* NFS procedure number */ | |
322 | int r_rtt; /* RTT for rpc */ | |
f0f1cbaa | 323 | struct proc *r_procp; /* Proc that did I/O system call */ |
a2907882 KM |
324 | }; |
325 | ||
0bb2c2fc KM |
326 | /* |
327 | * Queue head for nfsreq's | |
328 | */ | |
4acac3d6 | 329 | TAILQ_HEAD(, nfsreq) nfs_reqq; |
0bb2c2fc | 330 | |
b143b1f4 KM |
331 | /* Flag values for r_flags */ |
332 | #define R_TIMING 0x01 /* timing request (in mntp) */ | |
333 | #define R_SENT 0x02 /* request has been sent */ | |
f0f1cbaa KM |
334 | #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ |
335 | #define R_INTR 0x08 /* intr mnt, signal pending */ | |
336 | #define R_SOCKERR 0x10 /* Fatal error on socket */ | |
337 | #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ | |
338 | #define R_MUSTRESEND 0x40 /* Must resend request */ | |
02bde142 | 339 | #define R_GETONEREP 0x80 /* Probe for one reply only */ |
b143b1f4 | 340 | |
a2907882 | 341 | /* |
0d515be6 KM |
342 | * A list of nfssvc_sock structures is maintained with all the sockets |
343 | * that require service by the nfsd. | |
344 | * The nfsuid structs hang off of the nfssvc_sock structs in both lru | |
345 | * and uid hash lists. | |
a2907882 | 346 | */ |
4acac3d6 KM |
347 | #ifndef NFS_UIDHASHSIZ |
348 | #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ | |
349 | #endif | |
0bb2c2fc | 350 | #define NUIDHASH(sock, uid) \ |
4acac3d6 KM |
351 | (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) |
352 | #ifndef NFS_WDELAYHASHSIZ | |
353 | #define NFS_WDELAYHASHSIZ 16 /* and with this */ | |
354 | #endif | |
355 | #define NWDELAYHASH(sock, f) \ | |
356 | (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) | |
357 | #ifndef NFS_MUIDHASHSIZ | |
358 | #define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */ | |
359 | #endif | |
360 | #define NMUIDHASH(nmp, uid) \ | |
361 | (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) | |
362 | #define NFSNOHASH(fhsum) \ | |
363 | (&nfsnodehashtbl[(fhsum) & nfsnodehash]) | |
0d515be6 | 364 | |
92efa438 KM |
365 | /* |
366 | * Network address hash list element | |
367 | */ | |
368 | union nethostaddr { | |
369 | u_long had_inetaddr; | |
370 | struct mbuf *had_nam; | |
371 | }; | |
372 | ||
0d515be6 | 373 | struct nfsuid { |
0bb2c2fc KM |
374 | TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ |
375 | LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ | |
0d515be6 | 376 | int nu_flag; /* Flags */ |
0d515be6 KM |
377 | union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ |
378 | struct ucred nu_cr; /* Cred uid mapped to */ | |
4acac3d6 KM |
379 | int nu_expire; /* Expiry time (sec) */ |
380 | struct timeval nu_timestamp; /* Kerb. timestamp */ | |
381 | u_long nu_nickname; /* Nickname on server */ | |
382 | NFSKERBKEY_T nu_key; /* and session key */ | |
a2907882 KM |
383 | }; |
384 | ||
0d515be6 KM |
385 | #define nu_inetaddr nu_haddr.had_inetaddr |
386 | #define nu_nam nu_haddr.had_nam | |
387 | /* Bits for nu_flag */ | |
388 | #define NU_INETADDR 0x1 | |
4acac3d6 KM |
389 | #define NU_NAM 0x2 |
390 | #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) | |
0d515be6 KM |
391 | |
392 | struct nfssvc_sock { | |
0bb2c2fc | 393 | TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ |
4acac3d6 | 394 | TAILQ_HEAD(, nfsuid) ns_uidlruhead; |
0d515be6 KM |
395 | struct file *ns_fp; |
396 | struct socket *ns_so; | |
0d515be6 | 397 | struct mbuf *ns_nam; |
0d515be6 KM |
398 | struct mbuf *ns_raw; |
399 | struct mbuf *ns_rawend; | |
0d515be6 KM |
400 | struct mbuf *ns_rec; |
401 | struct mbuf *ns_recend; | |
4acac3d6 KM |
402 | struct mbuf *ns_frag; |
403 | int ns_flag; | |
404 | int ns_solock; | |
405 | int ns_cc; | |
406 | int ns_reclen; | |
0d515be6 | 407 | int ns_numuids; |
4acac3d6 KM |
408 | u_long ns_sref; |
409 | LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ | |
410 | LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; | |
411 | LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; | |
0d515be6 KM |
412 | }; |
413 | ||
414 | /* Bits for "ns_flag" */ | |
415 | #define SLP_VALID 0x01 | |
a5a4c300 | 416 | #define SLP_DOREC 0x02 |
0d515be6 KM |
417 | #define SLP_NEEDQ 0x04 |
418 | #define SLP_DISCONN 0x08 | |
419 | #define SLP_GETSTREAM 0x10 | |
4acac3d6 | 420 | #define SLP_LASTFRAG 0x20 |
fe893626 | 421 | #define SLP_ALLFLAGS 0xff |
a2907882 | 422 | |
4acac3d6 | 423 | TAILQ_HEAD(, nfssvc_sock) nfssvc_sockhead; |
0bb2c2fc KM |
424 | int nfssvc_sockhead_flag; |
425 | #define SLP_INIT 0x01 | |
426 | #define SLP_WANTINIT 0x02 | |
427 | ||
a2907882 | 428 | /* |
0d515be6 | 429 | * One of these structures is allocated for each nfsd. |
a2907882 | 430 | */ |
0d515be6 | 431 | struct nfsd { |
4acac3d6 KM |
432 | TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ |
433 | int nfsd_flag; /* NFSD_ flags */ | |
434 | struct nfssvc_sock *nfsd_slp; /* Current socket */ | |
435 | int nfsd_authlen; /* Authenticator len */ | |
436 | u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ | |
437 | int nfsd_verflen; /* and the Verifier */ | |
438 | u_char nfsd_verfstr[RPCVERF_MAXSIZ]; | |
439 | struct proc *nfsd_procp; /* Proc ptr */ | |
440 | struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ | |
a2907882 KM |
441 | }; |
442 | ||
4acac3d6 | 443 | /* Bits for "nfsd_flag" */ |
0d515be6 | 444 | #define NFSD_WAITING 0x01 |
0bb2c2fc KM |
445 | #define NFSD_REQINPROG 0x02 |
446 | #define NFSD_NEEDAUTH 0x04 | |
447 | #define NFSD_AUTHFAIL 0x08 | |
448 | ||
4acac3d6 KM |
449 | /* |
450 | * This structure is used by the server for describing each request. | |
451 | * Some fields are used only when write request gathering is performed. | |
452 | */ | |
453 | struct nfsrv_descript { | |
454 | u_quad_t nd_time; /* Write deadline (usec) */ | |
455 | off_t nd_off; /* Start byte offset */ | |
456 | off_t nd_eoff; /* and end byte offset */ | |
457 | LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ | |
458 | LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ | |
459 | LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ | |
460 | struct mbuf *nd_mrep; /* Request mbuf list */ | |
461 | struct mbuf *nd_md; /* Current dissect mbuf */ | |
462 | struct mbuf *nd_mreq; /* Reply mbuf list */ | |
463 | struct mbuf *nd_nam; /* and socket addr */ | |
464 | struct mbuf *nd_nam2; /* return socket addr */ | |
465 | caddr_t nd_dpos; /* Current dissect pos */ | |
466 | int nd_procnum; /* RPC # */ | |
467 | int nd_stable; /* storage type */ | |
468 | int nd_flag; /* nd_flag */ | |
469 | int nd_len; /* Length of this write */ | |
470 | int nd_repstat; /* Reply status */ | |
471 | u_long nd_retxid; /* Reply xid */ | |
472 | u_long nd_duration; /* Lease duration */ | |
473 | struct timeval nd_starttime; /* Time RPC initiated */ | |
474 | fhandle_t nd_fh; /* File handle */ | |
475 | struct ucred nd_cr; /* Credentials */ | |
476 | }; | |
477 | ||
478 | /* Bits for "nd_flag" */ | |
479 | #define ND_READ LEASE_READ | |
480 | #define ND_WRITE LEASE_WRITE | |
481 | #define ND_CHECK 0x04 | |
482 | #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) | |
483 | #define ND_NFSV3 0x08 | |
484 | #define ND_NQNFS 0x10 | |
485 | #define ND_KERBNICK 0x20 | |
486 | #define ND_KERBFULL 0x40 | |
487 | #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) | |
488 | ||
489 | TAILQ_HEAD(, nfsd) nfsd_head; | |
0bb2c2fc KM |
490 | int nfsd_head_flag; |
491 | #define NFSD_CHECKSLP 0x01 | |
492 | ||
4acac3d6 KM |
493 | /* |
494 | * These macros compare nfsrv_descript structures. | |
495 | */ | |
496 | #define NFSW_CONTIG(o, n) \ | |
497 | ((o)->nd_eoff >= (n)->nd_off && \ | |
498 | !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) | |
499 | ||
500 | #define NFSW_SAMECRED(o, n) \ | |
501 | (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ | |
502 | !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ | |
503 | sizeof (struct ucred))) | |
504 | ||
505 | int nfs_reply __P((struct nfsreq *)); | |
506 | int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); | |
507 | int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); | |
508 | int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); | |
509 | int nfs_sndlock __P((int *,struct nfsreq *)); | |
510 | int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); | |
511 | int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); | |
512 | int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); | |
513 | int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); | |
514 | int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); | |
515 | int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); | |
516 | int nfs_asyncio __P((struct buf *,struct ucred *)); | |
517 | int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); | |
518 | int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); | |
519 | int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); | |
520 | int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); | |
521 | int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); | |
522 | void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); | |
523 | void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); | |
524 | void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); | |
525 | int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *,int)); | |
526 | int nfsrv_access __P((struct vnode *,int,struct ucred *,int,struct proc *)); | |
527 | int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); | |
528 | int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); | |
529 | int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); | |
530 | int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); | |
531 | void nfsm_adj __P((struct mbuf *,int,int)); | |
532 | int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); | |
533 | void nfsrv_initcache __P((void)); | |
534 | int nfs_rcvlock __P((struct nfsreq *)); | |
535 | int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); | |
536 | int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); | |
537 | int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); | |
538 | int nfs_msg __P((struct proc *,char *,char *)); | |
539 | int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); | |
540 | int nfsrv_getstream __P((struct nfssvc_sock *,int)); | |
541 | void nfs_nhinit __P((void)); | |
542 | void nfs_timer __P((void*)); | |
543 | u_long nfs_hash __P((nfsfh_t *,int)); | |
544 | int nfssvc_iod __P((struct proc *)); | |
545 | int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); | |
546 | int nfssvc_addsock __P((struct file *,struct mbuf *)); | |
547 | int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); | |
548 | int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); | |
549 | void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); | |
550 | int mountnfs __P((struct nfs_args *,struct mount *,struct mbuf *,char *,char *,struct vnode **)); | |
551 | int nfs_connect __P((struct nfsmount *,struct nfsreq *)); | |
552 | int nfs_getattrcache __P((struct vnode *,struct vattr *)); | |
553 | int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); | |
554 | int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); | |
555 | int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); | |
556 | void nfsrv_init __P((int)); | |
557 | void nfs_clearcommit __P((struct mount *)); | |
558 | int nfsrv_errmap __P((struct nfsrv_descript *, int)); | |
559 | void nfsrvw_coalesce __P((struct nfsrv_descript *,struct nfsrv_descript *)); | |
560 | void nfsrvw_sort __P((gid_t [],int)); | |
561 | void nfsrv_setcred __P((struct ucred *,struct ucred *)); | |
562 | int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); | |
563 | int nfs_writebp __P((struct buf *,int)); | |
0d515be6 | 564 | #endif /* KERNEL */ |
4acac3d6 KM |
565 | |
566 | #endif |