NFS - Remove old nfsiod, start adding new kernel thread infrastructure
[dragonfly.git] / sys / vfs / nfs / nfs.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1989, 1993, 1995
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.4 (Berkeley) 5/1/95
37 * $FreeBSD: src/sys/nfs/nfs.h,v 1.53.2.5 2002/02/20 01:35:34 iedowse Exp $
67863d04 38 * $DragonFly: src/sys/vfs/nfs/nfs.h,v 1.21 2008/09/17 21:44:24 dillon Exp $
984263bc
MD
39 */
40
41#ifndef _NFS_NFS_H_
42#define _NFS_NFS_H_
43
44#ifdef _KERNEL
45#include "opt_nfs.h"
46#endif
47
8684e6f9
MD
48#include <sys/mutex.h>
49
984263bc
MD
50/*
51 * Tunable constants for nfs
52 */
53
54#define NFS_MAXIOVEC 34
55#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
56#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
57#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
58#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
59#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
60#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
61#define NFS_MAXREXMIT 100 /* Stop counting after this many */
62#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
63#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
64#define NFS_MAXGRPS 16 /* Max. size of groups list */
65#ifndef NFS_MINATTRTIMO
66#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
97100839
MD
67#endif
68#ifndef NFS_DEFATTRTIMO
69#define NFS_DEFATTRTIMO 10 /* VREG attrib cache timeout in sec */
984263bc
MD
70#endif
71#ifndef NFS_MAXATTRTIMO
72#define NFS_MAXATTRTIMO 60
73#endif
74#ifndef NFS_MINDIRATTRTIMO
75#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
76#endif
77#ifndef NFS_MAXDIRATTRTIMO
78#define NFS_MAXDIRATTRTIMO 60
79#endif
e07fef60
MD
80#ifndef NFS_DEADTHRESH
81#define NFS_DEADTHRESH NFS_NEVERDEAD
82#endif
83#define NFS_NEVERDEAD 9
984263bc
MD
84#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
85#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
86#define NFS_READDIRSIZE 8192 /* Def. readdir size */
f88ac120
MD
87#define NFS_DEFRAHEAD 4 /* Def. read ahead # blocks */
88#define NFS_MAXRAHEAD 32 /* Max. read ahead # blocks */
984263bc 89#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
984263bc
MD
90#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
91#ifndef NFS_GATHERDELAY
2cb16efc 92#define NFS_GATHERDELAY 20 /* Default write gather delay (msec) */
984263bc
MD
93#endif
94#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
95#ifdef _KERNEL
96#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
97#endif
98
99/*
100 * Oddballs
101 */
102#define NMOD(a) ((a) % nfs_asyncdaemons)
103#define NFS_CMPFH(n, f, s) \
104 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
105#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
106#define NFS_SRVMAXDATA(n) \
107 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
108 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
109
984263bc
MD
110/*
111 * The IO_METASYNC flag should be implemented for local file systems.
112 * (Until then, it is nothin at all.)
113 */
114#ifndef IO_METASYNC
115#define IO_METASYNC 0
116#endif
117
118/*
119 * Arguments to mount NFS
120 */
121#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
122struct nfs_args {
123 int version; /* args structure version number */
124 struct sockaddr *addr; /* file server address */
125 int addrlen; /* length of address */
126 int sotype; /* Socket type */
127 int proto; /* and Protocol */
128 u_char *fh; /* File handle to be mounted */
129 int fhsize; /* Size, in bytes, of fh */
130 int flags; /* flags */
131 int wsize; /* write size in bytes */
132 int rsize; /* read size in bytes */
133 int readdirsize; /* readdir size in bytes */
134 int timeo; /* initial timeout in .1 secs */
135 int retrans; /* times to retry send */
136 int maxgrouplist; /* Max. size of group list */
137 int readahead; /* # of blocks to readahead */
e07fef60 138 int unused01; /* Term (sec) of lease */
984263bc
MD
139 int deadthresh; /* Retrans threshold */
140 char *hostname; /* server's name */
141 int acregmin; /* cache attrs for reg files min time */
142 int acregmax; /* cache attrs for reg files max time */
143 int acdirmin; /* cache attrs for dirs min time */
144 int acdirmax; /* cache attrs for dirs max time */
145};
146
147/*
148 * NFS mount option flags
149 */
150#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
151#define NFSMNT_WSIZE 0x00000002 /* set write size */
152#define NFSMNT_RSIZE 0x00000004 /* set read size */
153#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
154#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
155#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
156#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
157#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
e07fef60 158#define NFSMNT_UNUSED0100 0x00000100
984263bc
MD
159#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
160#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
161#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
e07fef60 162#define NFSMNT_UNUSED1000 0x00001000 /* set lease term (nqnfs) */
984263bc
MD
163#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
164#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
165#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
166#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
167#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
168#define NFSMNT_ACREGMIN 0x00040000
169#define NFSMNT_ACREGMAX 0x00080000
170#define NFSMNT_ACDIRMIN 0x00100000
171#define NFSMNT_ACDIRMAX 0x00200000
172
173#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
174#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
175#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
176#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
177#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
178#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
8684e6f9
MD
179#define NFSSTA_UNUSED24 0x01000000
180#define NFSSTA_UNUSED25 0x02000000
181#define NFSSTA_UNUSED26 0x04000000
182#define NFSSTA_UNUSED27 0x08000000
984263bc
MD
183#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
184#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
185#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
186#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
187
188/*
189 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
190 * should ever try and use it.
191 */
192struct nfsd_args {
193 int sock; /* Socket to serve */
194 caddr_t name; /* Client addr for connection based sockets */
195 int namelen; /* Length of name */
196};
197
198struct nfsd_srvargs {
199 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
200 uid_t nsd_uid; /* Effective uid mapped to cred */
201 u_int32_t nsd_haddr; /* Ip address of client */
202 struct ucred nsd_cr; /* Cred. uid maps to */
203 u_int nsd_authlen; /* Length of auth string (ret) */
204 u_char *nsd_authstr; /* Auth string (ret) */
205 u_int nsd_verflen; /* and the verfier */
206 u_char *nsd_verfstr;
207 struct timeval nsd_timestamp; /* timestamp from verifier */
208 u_int32_t nsd_ttl; /* credential ttl (sec) */
209 NFSKERBKEY_T nsd_key; /* Session key */
210};
211
212struct nfsd_cargs {
213 char *ncd_dirp; /* Mount dir path */
214 uid_t ncd_authuid; /* Effective uid */
215 int ncd_authtype; /* Type of authenticator */
216 u_int ncd_authlen; /* Length of authenticator string */
217 u_char *ncd_authstr; /* Authenticator string */
218 u_int ncd_verflen; /* and the verifier */
219 u_char *ncd_verfstr;
220 NFSKERBKEY_T ncd_key; /* Session key */
221};
222
223/*
224 * XXX to allow amd to include nfs.h without nfsproto.h
225 */
226#ifdef NFS_NPROCS
227/*
228 * Stats structure
229 */
230struct nfsstats {
231 int attrcache_hits;
232 int attrcache_misses;
233 int lookupcache_hits;
234 int lookupcache_misses;
235 int direofcache_hits;
236 int direofcache_misses;
237 int biocache_reads;
238 int read_bios;
239 int read_physios;
240 int biocache_writes;
241 int write_bios;
242 int write_physios;
243 int biocache_readlinks;
244 int readlink_bios;
245 int biocache_readdirs;
246 int readdir_bios;
247 int rpccnt[NFS_NPROCS];
248 int rpcretries;
249 int srvrpccnt[NFS_NPROCS];
250 int srvrpc_errs;
251 int srv_errs;
252 int rpcrequests;
253 int rpctimeouts;
254 int rpcunexpected;
255 int rpcinvalid;
256 int srvcache_inproghits;
257 int srvcache_idemdonehits;
258 int srvcache_nonidemdonehits;
259 int srvcache_misses;
260 int srvnqnfs_leases;
261 int srvnqnfs_maxleases;
262 int srvnqnfs_getleases;
263 int srvvop_writes;
264 int accesscache_hits;
265 int accesscache_misses;
266};
267#endif
268
269/*
270 * Flags for nfssvc() system call.
271 */
272#define NFSSVC_BIOD 0x002
273#define NFSSVC_NFSD 0x004
274#define NFSSVC_ADDSOCK 0x008
275#define NFSSVC_AUTHIN 0x010
276#define NFSSVC_GOTAUTH 0x040
277#define NFSSVC_AUTHINFAIL 0x080
278#define NFSSVC_MNTD 0x100
279
280/*
281 * fs.nfs sysctl(3) identifiers
282 */
283#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
284#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
285
286#define FS_NFS_NAMES { \
287 { 0, 0 }, \
288 { "nfsstats", CTLTYPE_STRUCT }, \
289 { "nfsprivport", CTLTYPE_INT }, \
290}
291
292#ifdef _KERNEL
293
294#ifdef MALLOC_DECLARE
295MALLOC_DECLARE(M_NFSREQ);
296MALLOC_DECLARE(M_NFSDIROFF);
297MALLOC_DECLARE(M_NFSRVDESC);
298MALLOC_DECLARE(M_NFSUID);
984263bc
MD
299MALLOC_DECLARE(M_NFSD);
300MALLOC_DECLARE(M_NFSBIGFH);
301MALLOC_DECLARE(M_NFSHASH);
302#endif
303
304#ifdef ZONE_INTERRUPT
305extern vm_zone_t nfsmount_zone;
306#endif
307
f786cc86 308extern struct callout nfs_timer_handle;
a482a28a 309extern int nfs_async;
984263bc 310
fad57d0e
MD
311struct uio;
312struct buf;
81b5c339 313struct bio;
fad57d0e
MD
314struct vattr;
315struct nlookupdata;
984263bc
MD
316
317/*
318 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
319 * What should be in this set is open to debate, but I believe that since
320 * I/O system calls on ufs are never interrupted by signals the set should
321 * be minimal. My reasoning is that many current programs that use signals
322 * such as SIGALRM will not expect file I/O system calls to be interrupted
323 * by them and break.
324 */
325#define NFSINT_SIGMASK(set) \
326 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
327 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
328 SIGISMEMBER(set, SIGQUIT))
329
330/*
331 * Socket errors ignored for connectionless sockets??
332 * For now, ignore them all
333 */
334#define NFSIGNORE_SOERROR(s, e) \
335 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
336 ((s) & PR_CONNREQUIRED) == 0)
337
338/*
339 * Nfs outstanding request list element
340 */
341struct nfsreq {
342 TAILQ_ENTRY(nfsreq) r_chain;
8684e6f9 343 struct mtx_link r_link;
984263bc
MD
344 struct mbuf *r_mreq;
345 struct mbuf *r_mrep;
346 struct mbuf *r_md;
347 caddr_t r_dpos;
348 struct nfsmount *r_nmp;
349 struct vnode *r_vp;
350 u_int32_t r_xid;
351 int r_flags; /* flags on request, see below */
352 int r_retry; /* max retransmission count */
353 int r_rexmit; /* current retrans count */
354 int r_timer; /* tick counter on reply */
355 u_int32_t r_procnum; /* NFS procedure number */
356 int r_rtt; /* RTT for rpc */
dadab5e9 357 struct thread *r_td; /* Thread that did I/O system call */
8684e6f9
MD
358 struct mbuf *r_mrest;
359 struct mbuf *r_mheadend;
360 struct mbuf **r_mrp;
361 struct mbuf **r_mdp;
362 caddr_t *r_dposp;
363 int r_mrest_len;
364 int r_failed_auth;
365 NFSKERBKEY_T r_key;
366 struct ucred *r_cred;
984263bc
MD
367};
368
369/*
e21aec5b 370 * Flag values for r_flags
984263bc 371 */
54938b92
MD
372#define R_TIMING 0x0001 /* timing request (in mntp) */
373#define R_SENT 0x0002 /* request has been sent */
374#define R_SOFTTERM 0x0004 /* soft mnt, too many retries */
375#define R_INTR 0x0008 /* intr mnt, signal pending */
376#define R_SOCKERR 0x0010 /* Fatal error on socket */
377#define R_TPRINTFMSG 0x0020 /* Did a tprintf msg. */
378#define R_MUSTRESEND 0x0040 /* Must resend request */
379#define R_GETONEREP 0x0080 /* Probe for one reply only */
380#define R_MASKTIMER 0x0100 /* Timer should ignore this req */
91f46891 381#define R_LOCKED 0x0200 /* Locked by the timer */
984263bc
MD
382
383/*
384 * A list of nfssvc_sock structures is maintained with all the sockets
385 * that require service by the nfsd.
386 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
387 * and uid hash lists.
388 */
389#ifndef NFS_UIDHASHSIZ
390#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
391#endif
392#define NUIDHASH(sock, uid) \
393 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
394#ifndef NFS_WDELAYHASHSIZ
395#define NFS_WDELAYHASHSIZ 16 /* and with this */
396#endif
397#define NWDELAYHASH(sock, f) \
398 (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
399#ifndef NFS_MUIDHASHSIZ
400#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
401#endif
402#define NMUIDHASH(nmp, uid) \
403 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
404#define NFSNOHASH(fhsum) \
405 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
406
407/*
408 * Network address hash list element
409 */
410union nethostaddr {
411 u_int32_t had_inetaddr;
412 struct sockaddr *had_nam;
413};
414
415struct nfsuid {
416 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
417 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
418 int nu_flag; /* Flags */
419 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
420 struct ucred nu_cr; /* Cred uid mapped to */
421 int nu_expire; /* Expiry time (sec) */
422 struct timeval nu_timestamp; /* Kerb. timestamp */
423 u_int32_t nu_nickname; /* Nickname on server */
424 NFSKERBKEY_T nu_key; /* and session key */
425};
426
427#define nu_inetaddr nu_haddr.had_inetaddr
428#define nu_nam nu_haddr.had_nam
429/* Bits for nu_flag */
430#define NU_INETADDR 0x1
431#define NU_NAM 0x2
432#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
433
434struct nfsrv_rec {
435 STAILQ_ENTRY(nfsrv_rec) nr_link;
436 struct sockaddr *nr_address;
437 struct mbuf *nr_packet;
438};
439
440struct nfssvc_sock {
441 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
442 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
443 struct file *ns_fp;
444 struct socket *ns_so;
445 struct sockaddr *ns_nam;
446 struct mbuf *ns_raw;
447 struct mbuf *ns_rawend;
448 STAILQ_HEAD(, nfsrv_rec) ns_rec;
449 struct mbuf *ns_frag;
52553028 450 int ns_numrec;
984263bc 451 int ns_flag;
8684e6f9 452 struct mtx ns_solock;
984263bc
MD
453 int ns_cc;
454 int ns_reclen;
455 int ns_numuids;
456 u_int32_t ns_sref;
457 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
458 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
459 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
460};
461
462/* Bits for "ns_flag" */
463#define SLP_VALID 0x01
464#define SLP_DOREC 0x02
465#define SLP_NEEDQ 0x04
466#define SLP_DISCONN 0x08
467#define SLP_GETSTREAM 0x10
468#define SLP_LASTFRAG 0x20
469#define SLP_ALLFLAGS 0xff
470
471extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
472extern int nfssvc_sockhead_flag;
49433307 473extern TAILQ_HEAD(nfsmount_head, nfsmount) nfs_mountq;
e21aec5b 474
984263bc
MD
475#define SLP_INIT 0x01
476#define SLP_WANTINIT 0x02
477
478/*
479 * One of these structures is allocated for each nfsd.
480 */
481struct nfsd {
482 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
483 int nfsd_flag; /* NFSD_ flags */
484 struct nfssvc_sock *nfsd_slp; /* Current socket */
485 int nfsd_authlen; /* Authenticator len */
486 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
487 int nfsd_verflen; /* and the Verifier */
488 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
dadab5e9 489 struct thread *nfsd_td; /* thread ptr */
984263bc
MD
490 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
491};
492
493/* Bits for "nfsd_flag" */
494#define NFSD_WAITING 0x01
495#define NFSD_REQINPROG 0x02
496#define NFSD_NEEDAUTH 0x04
497#define NFSD_AUTHFAIL 0x08
498
5a9187cb
MD
499/* Bits for loadattrcache */
500#define NFS_LATTR_NOSHRINK 0x01
501#define NFS_LATTR_NOMTIMECHECK 0x02
502
984263bc
MD
503/*
504 * This structure is used by the server for describing each request.
505 * Some fields are used only when write request gathering is performed.
506 */
507struct nfsrv_descript {
508 u_quad_t nd_time; /* Write deadline (usec) */
509 off_t nd_off; /* Start byte offset */
510 off_t nd_eoff; /* and end byte offset */
511 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
512 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
513 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
514 struct mbuf *nd_mrep; /* Request mbuf list */
515 struct mbuf *nd_md; /* Current dissect mbuf */
516 struct mbuf *nd_mreq; /* Reply mbuf list */
517 struct sockaddr *nd_nam; /* and socket addr */
518 struct sockaddr *nd_nam2; /* return socket addr */
519 caddr_t nd_dpos; /* Current dissect pos */
520 u_int32_t nd_procnum; /* RPC # */
521 int nd_stable; /* storage type */
522 int nd_flag; /* nd_flag */
523 int nd_len; /* Length of this write */
524 int nd_repstat; /* Reply status */
525 u_int32_t nd_retxid; /* Reply xid */
984263bc
MD
526 struct timeval nd_starttime; /* Time RPC initiated */
527 fhandle_t nd_fh; /* File handle */
528 struct ucred nd_cr; /* Credentials */
529};
530
531/* Bits for "nd_flag" */
e07fef60
MD
532#define ND_READ 0x01
533#define ND_WRITE 0x02
984263bc 534#define ND_CHECK 0x04
984263bc 535#define ND_NFSV3 0x08
e07fef60 536#define ND_UNUSED010 0x10
984263bc
MD
537#define ND_KERBNICK 0x20
538#define ND_KERBFULL 0x40
539#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
540
541extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
542extern int nfsd_head_flag;
52553028 543extern int nfsd_waiting;
984263bc
MD
544#define NFSD_CHECKSLP 0x01
545
546/*
547 * These macros compare nfsrv_descript structures.
548 */
549#define NFSW_CONTIG(o, n) \
550 ((o)->nd_eoff >= (n)->nd_off && \
551 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
552
553#define NFSW_SAMECRED(o, n) \
554 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
555 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
556 sizeof (struct ucred)))
557
558/*
559 * Defines for WebNFS
560 */
561
562#define WEBNFS_ESC_CHAR '%'
563#define WEBNFS_SPECCHAR_START 0x80
564
565#define WEBNFS_NATIVE_CHAR 0x80
566/*
567 * ..
568 * Possibly more here in the future.
569 */
570
571/*
572 * Macro for converting escape characters in WebNFS pathnames.
573 * Should really be in libkern.
574 */
575
576#define HEXTOC(c) \
577 ((c) >= 'a' ? ((c) - ('a' - 10)) : \
578 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
579#define HEXSTRTOI(p) \
580 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
581
582#ifdef NFS_DEBUG
583
584extern int nfs_debug;
585#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
586#define NFS_DEBUG_WG 2 /* server write gathering */
587#define NFS_DEBUG_RC 4 /* server request caching */
588
589#define NFS_DPF(cat, args) \
590 do { \
086c1d7e 591 if (nfs_debug & NFS_DEBUG_##cat) kprintf args; \
984263bc
MD
592 } while (0)
593
594#else
595
596#define NFS_DPF(cat, args)
597
598#endif
599
a6ee311a
RG
600u_quad_t nfs_curusec (void);
601int nfs_init (struct vfsconf *vfsp);
602int nfs_uninit (struct vfsconf *vfsp);
603int nfs_reply (struct nfsreq *);
604int nfs_getreq (struct nfsrv_descript *,struct nfsd *,int);
605int nfs_send (struct socket *, struct sockaddr *, struct mbuf *,
606 struct nfsreq *);
607int nfs_rephead (int, struct nfsrv_descript *, struct nfssvc_sock *,
e07fef60 608 int, struct mbuf **, struct mbuf **, caddr_t *);
a6ee311a
RG
609int nfs_sndlock (struct nfsreq *);
610void nfs_sndunlock (struct nfsreq *);
611int nfs_slplock (struct nfssvc_sock *, int);
612void nfs_slpunlock (struct nfssvc_sock *);
613int nfs_disct (struct mbuf **, caddr_t *, int, int, caddr_t *);
87de5057 614int nfs_vinvalbuf (struct vnode *, int, int);
a6ee311a
RG
615int nfs_readrpc (struct vnode *, struct uio *);
616int nfs_writerpc (struct vnode *, struct uio *, int *, int *);
617int nfs_commit (struct vnode *vp, u_quad_t offset, int cnt,
618 struct thread *td);
619int nfs_readdirrpc (struct vnode *, struct uio *);
81b5c339
MD
620int nfs_asyncio (struct vnode *vp, struct bio *, struct thread *);
621int nfs_doio (struct vnode *vp, struct bio *, struct thread *);
a6ee311a
RG
622int nfs_readlinkrpc (struct vnode *, struct uio *);
623int nfs_sigintr (struct nfsmount *, struct nfsreq *, struct thread *);
624int nfs_readdirplusrpc (struct vnode *, struct uio *);
625int nfsm_disct (struct mbuf **, caddr_t *, int, int, caddr_t *);
626void nfsm_srvfattr (struct nfsrv_descript *, struct vattr *,
627 struct nfs_fattr *);
628void nfsm_srvwcc (struct nfsrv_descript *, int, struct vattr *, int,
629 struct vattr *, struct mbuf **, char **);
630void nfsm_srvpostopattr (struct nfsrv_descript *, int, struct vattr *,
631 struct mbuf **, char **);
632int netaddr_match (int, union nethostaddr *, struct sockaddr *);
633int nfs_request (struct vnode *, struct mbuf *, int, struct thread *,
984263bc 634 struct ucred *, struct mbuf **, struct mbuf **,
a6ee311a 635 caddr_t *);
8684e6f9
MD
636int nfs_request_setup(struct vnode *vp, struct mbuf *mrest, int procnum,
637 struct thread *td, struct ucred *cred, struct nfsreq **repp);
638int nfs_request_auth(struct nfsreq *rep);
639int nfs_request_try(struct nfsreq *rep);
640int nfs_request_waitreply(struct nfsreq *rep);
641int nfs_request_processreply(struct nfsreq *rep, int error);
642
643
644
645
a6ee311a
RG
646int nfs_loadattrcache (struct vnode **, struct mbuf **, caddr_t *,
647 struct vattr *, int);
fad57d0e
MD
648int nfs_namei (struct nlookupdata *, struct ucred *, int,
649 struct vnode **, struct vnode **, fhandle_t *, int,
650 struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
651 caddr_t *, struct vnode **, struct thread *, int, int);
a6ee311a
RG
652void nfsm_adj (struct mbuf *, int, int);
653int nfsm_mbuftouio (struct mbuf **, struct uio *, int, caddr_t *);
654void nfsrv_initcache (void);
655int nfs_getauth (struct nfsmount *, struct nfsreq *, struct ucred *,
656 char **, int *, char *, int *, NFSKERBKEY_T);
657int nfs_getnickauth (struct nfsmount *, struct ucred *, char **,
658 int *, char *, int);
659int nfs_savenickauth (struct nfsmount *, struct ucred *, int,
984263bc 660 NFSKERBKEY_T, struct mbuf **, char **,
a6ee311a
RG
661 struct mbuf *);
662int nfs_adv (struct mbuf **, caddr_t *, int, int);
663void nfs_nhinit (void);
664int nfs_nmcancelreqs (struct nfsmount *);
665void nfs_timer (void*);
666int nfsrv_dorec (struct nfssvc_sock *, struct nfsd *,
667 struct nfsrv_descript **);
668int nfsrv_getcache (struct nfsrv_descript *, struct nfssvc_sock *,
669 struct mbuf **);
670void nfsrv_updatecache (struct nfsrv_descript *, int, struct mbuf *);
671void nfsrv_cleancache (void);
672int nfs_connect (struct nfsmount *, struct nfsreq *);
673void nfs_disconnect (struct nfsmount *);
674void nfs_safedisconnect (struct nfsmount *);
675int nfs_getattrcache (struct vnode *, struct vattr *);
676int nfsm_strtmbuf (struct mbuf **, char **, const char *, long);
677int nfs_bioread (struct vnode *, struct uio *, int);
678int nfsm_uiotombuf (struct uio *, struct mbuf **, int, caddr_t *);
679void nfsrv_init (int);
680void nfs_clearcommit (struct mount *);
681int nfsrv_errmap (struct nfsrv_descript *, int);
682void nfsrvw_sort (gid_t *, int);
683void nfsrv_setcred (struct ucred *, struct ucred *);
a6ee311a 684int nfsrv_object_create (struct vnode *);
52553028 685void nfsrv_wakenfsd (struct nfssvc_sock *slp, int nparallel);
a6ee311a
RG
686int nfsrv_writegather (struct nfsrv_descript **, struct nfssvc_sock *,
687 struct thread *, struct mbuf **);
688int nfs_fsinfo (struct nfsmount *, struct vnode *, struct thread *p);
689
690int nfsrv3_access (struct nfsrv_descript *nfsd,
984263bc 691 struct nfssvc_sock *slp,
a6ee311a
RG
692 struct thread *td, struct mbuf **mrq);
693int nfsrv_commit (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
694 struct thread *td, struct mbuf **mrq);
695int nfsrv_create (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
696 struct thread *td, struct mbuf **mrq);
67863d04
MD
697int nfsrv_fhtovp (fhandle_t *, int, struct mount **, struct vnode **,
698 struct ucred *, struct nfssvc_sock *,
699 struct sockaddr *, int *, int, int);
a6ee311a
RG
700int nfsrv_setpublicfs (struct mount *, struct netexport *,
701 struct export_args *);
702int nfs_ispublicfh (fhandle_t *);
703int nfsrv_fsinfo (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
704 struct thread *td, struct mbuf **mrq);
705int nfsrv_getattr (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
706 struct thread *td, struct mbuf **mrq);
707int nfsrv_link (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
708 struct thread *td, struct mbuf **mrq);
709int nfsrv_lookup (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
710 struct thread *td, struct mbuf **mrq);
711int nfsrv_mkdir (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
712 struct thread *td, struct mbuf **mrq);
713int nfsrv_mknod (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
714 struct thread *td, struct mbuf **mrq);
715int nfsrv_noop (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
716 struct thread *td, struct mbuf **mrq);
717int nfsrv_null (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
718 struct thread *td, struct mbuf **mrq);
719int nfsrv_pathconf (struct nfsrv_descript *nfsd,
dadab5e9 720 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
721 struct mbuf **mrq);
722int nfsrv_read (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
723 struct thread *td, struct mbuf **mrq);
724int nfsrv_readdir (struct nfsrv_descript *nfsd,
984263bc 725 struct nfssvc_sock *slp,
a6ee311a
RG
726 struct thread *td, struct mbuf **mrq);
727int nfsrv_readdirplus (struct nfsrv_descript *nfsd,
dadab5e9 728 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
729 struct mbuf **mrq);
730int nfsrv_readlink (struct nfsrv_descript *nfsd,
dadab5e9 731 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
732 struct mbuf **mrq);
733int nfsrv_remove (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
734 struct thread *td, struct mbuf **mrq);
735int nfsrv_rename (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
736 struct thread *td, struct mbuf **mrq);
737int nfsrv_rmdir (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
738 struct thread *td, struct mbuf **mrq);
739int nfsrv_setattr (struct nfsrv_descript *nfsd,
984263bc 740 struct nfssvc_sock *slp,
a6ee311a
RG
741 struct thread *td, struct mbuf **mrq);
742int nfsrv_statfs (struct nfsrv_descript *nfsd,
984263bc 743 struct nfssvc_sock *slp,
a6ee311a
RG
744 struct thread *td, struct mbuf **mrq);
745int nfsrv_symlink (struct nfsrv_descript *nfsd,
984263bc 746 struct nfssvc_sock *slp,
a6ee311a
RG
747 struct thread *td, struct mbuf **mrq);
748int nfsrv_write (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
749 struct thread *td, struct mbuf **mrq);
750void nfsrv_rcv (struct socket *so, void *arg, int waitflag);
751void nfsrv_slpderef (struct nfssvc_sock *slp);
752int nfs_meta_setsize (struct vnode *vp, struct thread *td, u_quad_t nsize);
e07fef60
MD
753int nfs_clientd(struct nfsmount *nmp, struct ucred *cred,
754 struct nfsd_cargs *ncd, int flag, caddr_t argp,
755 struct thread *td);
52e1cf57
MD
756void nfssvc_iod_reader(void *arg);
757void nfssvc_iod_writer(void *arg);
758void nfssvc_iod_stop(struct nfsmount *nmp);
759void nfssvc_iod_writer_wakeup(struct nfsmount *nmp);
984263bc
MD
760
761#endif /* _KERNEL */
762
763#endif