FreeBSD/Linux Kernel Cross Reference
sys/nfsclient/nfs.h
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: releng/5.2/sys/nfsclient/nfs.h 122953 2003-11-22 02:21:49Z alfred $
38 */
39
40 #ifndef _NFSCLIENT_NFS_H_
41 #define _NFSCLIENT_NFS_H_
42
43 #ifdef _KERNEL
44 #include "opt_nfs.h"
45 #endif
46
47 #include <nfsclient/nfsargs.h>
48
49 /*
50 * Tunable constants for nfs
51 */
52
53 #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
54 #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
55 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
56 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
57 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
58 #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
59 #define NFS_MAXREXMIT 100 /* Stop counting after this many */
60 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */
61 #define NFS_MAXGRPS 16 /* Max. size of groups list */
62 #ifndef NFS_MINATTRTIMO
63 #define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
64 #endif
65 #ifndef NFS_MAXATTRTIMO
66 #define NFS_MAXATTRTIMO 60
67 #endif
68 #ifndef NFS_MINDIRATTRTIMO
69 #define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
70 #endif
71 #ifndef NFS_MAXDIRATTRTIMO
72 #define NFS_MAXDIRATTRTIMO 60
73 #endif
74 #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
75 #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
76 #define NFS_READDIRSIZE 8192 /* Def. readdir size */
77 #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
78 #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
79 #define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */
80 #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
81 #ifdef _KERNEL
82 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
83 #endif
84 #define NFS_MAXDEADTHRESH 9 /* How long till we say 'server not responding' */
85
86 /*
87 * Oddballs
88 */
89 #define NFS_CMPFH(n, f, s) \
90 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
91 #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
92
93 #define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
94 #define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
95 #define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
96 #define NFSSTA_WANTSND 0x02000000 /* Want above */
97 #define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
98 #define NFSSTA_WANTRCV 0x08000000 /* Want above */
99
100 /*
101 * XXX to allow amd to include nfs.h without nfsproto.h
102 */
103 #ifdef NFS_NPROCS
104 #include <nfsclient/nfsstats.h>
105 #endif
106 /*
107 * Flags for nfsclnt() system call.
108 */
109 #define NFSCLNT_LOCKDANS 0x200
110
111 /*
112 * vfs.nfs sysctl(3) identifiers
113 */
114 #define NFS_NFSSTATS 1 /* struct: struct nfsstats */
115
116 /*
117 * File context information for nfsv4. Currently, there is only one
118 * lockowner for the whole machine "0."
119 */
120 struct nfs4_fctx {
121 TAILQ_ENTRY(nfs4_fstate) next;
122
123 pid_t pid;
124 uint32_t refcnt;
125 struct nfs4_lowner *lop;
126 struct nfsnode *np;
127 char stateid[NFSX_V4STATEID];
128 };
129
130 #ifdef _KERNEL
131
132 #ifdef MALLOC_DECLARE
133 MALLOC_DECLARE(M_NFSREQ);
134 MALLOC_DECLARE(M_NFSDIROFF);
135 MALLOC_DECLARE(M_NFSBIGFH);
136 MALLOC_DECLARE(M_NFSHASH);
137 #endif
138
139 extern struct uma_zone *nfsmount_zone;
140
141 extern struct callout_handle nfs_timer_handle;
142 extern struct nfsstats nfsstats;
143
144 extern int nfs_numasync;
145 extern int nfs_pbuf_freecnt;
146 extern int nfs_ticks;
147
148 /* Data constants in XDR form */
149 extern u_int32_t nfs_true, nfs_false, nfs_xdrneg1;
150 extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers;
151 extern u_int32_t rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr;
152
153 extern int nfsv3_procid[NFS_NPROCS];
154
155 struct uio;
156 struct buf;
157 struct vattr;
158 struct nameidata;
159
160 /*
161 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
162 * What should be in this set is open to debate, but I believe that since
163 * I/O system calls on ufs are never interrupted by signals the set should
164 * be minimal. My reasoning is that many current programs that use signals
165 * such as SIGALRM will not expect file I/O system calls to be interrupted
166 * by them and break.
167 */
168 #define NFSINT_SIGMASK(set) \
169 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
170 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
171 SIGISMEMBER(set, SIGQUIT))
172
173 /*
174 * Socket errors ignored for connectionless sockets??
175 * For now, ignore them all
176 */
177 #define NFSIGNORE_SOERROR(s, e) \
178 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
179 ((s) & PR_CONNREQUIRED) == 0)
180
181 /*
182 * Nfs outstanding request list element
183 */
184 struct nfsreq {
185 TAILQ_ENTRY(nfsreq) r_chain;
186 struct mbuf *r_mreq;
187 struct mbuf *r_mrep;
188 struct mbuf *r_md;
189 caddr_t r_dpos;
190 struct nfsmount *r_nmp;
191 struct vnode *r_vp;
192 u_int32_t r_xid;
193 int r_flags; /* flags on request, see below */
194 int r_retry; /* max retransmission count */
195 int r_rexmit; /* current retrans count */
196 int r_timer; /* tick counter on reply */
197 u_int32_t r_procnum; /* NFS procedure number */
198 int r_rtt; /* RTT for rpc */
199 struct thread *r_td; /* Proc that did I/O system call */
200 };
201
202 /*
203 * Queue head for nfsreq's
204 */
205 extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
206
207 /* Flag values for r_flags */
208 #define R_TIMING 0x01 /* timing request (in mntp) */
209 #define R_SENT 0x02 /* request has been sent */
210 #define R_SOFTTERM 0x04 /* soft mnt, too many retries */
211 #define R_INTR 0x08 /* intr mnt, signal pending */
212 #define R_SOCKERR 0x10 /* Fatal error on socket */
213 #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
214 #define R_MUSTRESEND 0x40 /* Must resend request */
215 #define R_GETONEREP 0x80 /* Probe for one reply only */
216
217 /*
218 * Pointers to ops that differ from v3 to v4
219 */
220 struct nfs_rpcops {
221 int (*nr_readrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
222 int (*nr_writerpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred,
223 int *iomode, int *must_commit);
224 int (*nr_writebp)(struct buf *bp, int force, struct thread *td);
225 int (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop, struct ucred *cred);
226 void (*nr_invaldir)(struct vnode *vp);
227 int (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt,
228 struct ucred *cred, struct thread *td);
229 };
230
231 /*
232 * Defines for WebNFS
233 */
234
235 #define WEBNFS_ESC_CHAR '%'
236 #define WEBNFS_SPECCHAR_START 0x80
237
238 #define WEBNFS_NATIVE_CHAR 0x80
239 /*
240 * ..
241 * Possibly more here in the future.
242 */
243
244 /*
245 * Macro for converting escape characters in WebNFS pathnames.
246 * Should really be in libkern.
247 */
248
249 #define HEXTOC(c) \
250 ((c) >= 'a' ? ((c) - ('a' - 10)) : \
251 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '')))
252 #define HEXSTRTOI(p) \
253 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
254
255 #ifdef NFS_DEBUG
256
257 extern int nfs_debug;
258 #define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
259 #define NFS_DEBUG_WG 2 /* server write gathering */
260 #define NFS_DEBUG_RC 4 /* server request caching */
261
262 #define NFS_DPF(cat, args) \
263 do { \
264 if (nfs_debug & NFS_DEBUG_##cat) printf args; \
265 } while (0)
266
267 #else
268
269 #define NFS_DPF(cat, args)
270
271 #endif
272
273 vfs_init_t nfs_init;
274 vfs_uninit_t nfs_uninit;
275 int nfs_mountroot(struct mount *mp, struct thread *td);
276
277 #ifndef NFS4_USE_RPCCLNT
278 int nfs_send(struct socket *, struct sockaddr *, struct mbuf *,
279 struct nfsreq *);
280 int nfs_sndlock(struct nfsreq *);
281 void nfs_sndunlock(struct nfsreq *);
282 #endif /* ! NFS4_USE_RPCCLNT */
283
284 int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct thread *,
285 int);
286 int nfs_readrpc(struct vnode *, struct uio *, struct ucred *);
287 int nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *,
288 int *);
289 int nfs_commit(struct vnode *vp, u_quad_t offset, int cnt,
290 struct ucred *cred, struct thread *td);
291 int nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *);
292 int nfs_nfsiodnew(void);
293 int nfs_asyncio(struct buf *, struct ucred *, struct thread *);
294 int nfs_doio(struct buf *, struct ucred *, struct thread *);
295 int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
296 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *);
297 int nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *);
298 int nfs_request(struct vnode *, struct mbuf *, int, struct thread *,
299 struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
300 int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
301 struct vattr *, int);
302 int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
303 void nfs_nhinit(void);
304 int nfs_nmcancelreqs(struct nfsmount *);
305 void nfs_timer(void*);
306
307 int nfs_connect(struct nfsmount *, struct nfsreq *);
308 void nfs_disconnect(struct nfsmount *);
309 void nfs_safedisconnect(struct nfsmount *);
310 int nfs_getattrcache(struct vnode *, struct vattr *);
311 int nfsm_strtmbuf(struct mbuf **, char **, const char *, long);
312 int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
313 int nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *);
314 void nfs_clearcommit(struct mount *);
315 int nfs_writebp(struct buf *, int, struct thread *);
316 int nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
317 struct thread *);
318 int nfs_meta_setsize (struct vnode *, struct ucred *,
319 struct thread *, u_quad_t);
320
321 #endif /* _KERNEL */
322
323 #endif
Cache object: 1a3fa783e11a81fe8c1877bf70d68c84
|