This source file includes following definitions.
- TAILQ_HEAD
- TAILQ_HEAD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #ifndef _NFS_NFS_H_
39 #define _NFS_NFS_H_
40
41
42
43
44
45 #define NFS_MAXIOVEC 34
46 #define NFS_TICKINTVL 5
47 #define NFS_HZ (hz / nfs_ticks)
48 #define NFS_TIMEO (1 * NFS_HZ)
49 #define NFS_MINTIMEO (1 * NFS_HZ)
50 #define NFS_MAXTIMEO (60 * NFS_HZ)
51 #define NFS_MINIDEMTIMEO (5 * NFS_HZ)
52 #define NFS_TIMEOUTMUL 2
53 #define NFS_MAXREXMIT 100
54 #define NFS_MAXWINDOW 1024
55 #define NFS_RETRANS 10
56 #define NFS_MAXGRPS 16
57 #ifndef NFS_MINATTRTIMO
58 #define NFS_MINATTRTIMO 5
59 #endif
60 #ifndef NFS_MAXATTRTIMO
61 #define NFS_MAXATTRTIMO 60
62 #endif
63 #define NFS_WSIZE 8192
64 #define NFS_RSIZE 8192
65 #define NFS_READDIRSIZE 8192
66 #define NFS_DEFRAHEAD 1
67 #define NFS_MAXRAHEAD 4
68 #define NFS_MAXUIDHASH 64
69 #define NFS_MAXASYNCDAEMON 20
70 #define NFS_MAXGATHERDELAY 100
71 #ifndef NFS_GATHERDELAY
72 #define NFS_GATHERDELAY 10
73 #endif
74
75
76
77
78 #define NFS_DIRBLKSIZ 1024
79 #define NFS_READDIRBLKSIZ 512
80
81
82
83
84 #define NMOD(a) ((a) % nfs_asyncdaemons)
85 #define NFS_CMPFH(n, f, s) \
86 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
87 #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
88 #define NFS_SRVMAXDATA(n) \
89 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
90 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
91
92
93
94
95
96
97 #ifndef M_NFSRVDESC
98 #define M_NFSRVDESC M_TEMP
99 #endif
100 #ifndef M_NFSDIROFF
101 #define M_NFSDIROFF M_TEMP
102 #endif
103 #ifndef M_NFSBIGFH
104 #define M_NFSBIGFH M_TEMP
105 #endif
106 #ifndef VA_EXCLUSIVE
107 #define VA_EXCLUSIVE 0
108 #endif
109
110
111
112
113
114 #define B_INVAFTERWRITE B_INVAL
115
116
117
118
119
120 #ifndef IO_METASYNC
121 #define IO_METASYNC 0
122 #endif
123
124
125
126
127 #if 0
128 #define NFS_ATTRTIMEO(np) \
129 ((((np)->n_flag & NMODIFIED) || \
130 (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
131 ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
132 (time_second - (np)->n_mtime) / 10))
133 #endif
134
135
136
137
138
139 struct nfsd_args {
140 int sock;
141 caddr_t name;
142 int namelen;
143 };
144
145 struct nfsd_srvargs {
146 struct nfsd *nsd_nfsd;
147 uid_t nsd_uid;
148 u_int32_t nsd_haddr;
149 struct ucred nsd_cr;
150 int nsd_authlen;
151 u_char *nsd_authstr;
152 int nsd_verflen;
153 u_char *nsd_verfstr;
154 struct timeval nsd_timestamp;
155 u_int32_t nsd_ttl;
156 NFSKERBKEY_T nsd_key;
157 };
158
159 struct nfsd_cargs {
160 char *ncd_dirp;
161 uid_t ncd_authuid;
162 int ncd_authtype;
163 u_int ncd_authlen;
164 u_char *ncd_authstr;
165 u_int ncd_verflen;
166 u_char *ncd_verfstr;
167 NFSKERBKEY_T ncd_key;
168 };
169
170
171
172
173 struct nfsstats {
174 uint64_t attrcache_hits;
175 uint64_t attrcache_misses;
176 uint64_t lookupcache_hits;
177 uint64_t lookupcache_misses;
178 uint64_t direofcache_hits;
179 uint64_t direofcache_misses;
180 uint64_t biocache_reads;
181 uint64_t read_bios;
182 uint64_t read_physios;
183 uint64_t biocache_writes;
184 uint64_t write_bios;
185 uint64_t write_physios;
186 uint64_t biocache_readlinks;
187 uint64_t readlink_bios;
188 uint64_t biocache_readdirs;
189 uint64_t readdir_bios;
190 uint64_t rpccnt[NFS_NPROCS];
191 uint64_t rpcretries;
192 uint64_t srvrpccnt[NFS_NPROCS];
193 uint64_t srvrpc_errs;
194 uint64_t srv_errs;
195 uint64_t rpcrequests;
196 uint64_t rpctimeouts;
197 uint64_t rpcunexpected;
198 uint64_t rpcinvalid;
199 uint64_t srvcache_inproghits;
200 uint64_t srvcache_idemdonehits;
201 uint64_t srvcache_nonidemdonehits;
202 uint64_t srvcache_misses;
203 uint64_t srvnqnfs_leases;
204 uint64_t srvnqnfs_maxleases;
205 uint64_t srvnqnfs_getleases;
206 uint64_t srvvop_writes;
207 };
208
209
210
211
212 #define NFSSVC_BIOD 0x002
213 #define NFSSVC_NFSD 0x004
214 #define NFSSVC_ADDSOCK 0x008
215 #define NFSSVC_AUTHIN 0x010
216 #define NFSSVC_GOTAUTH 0x040
217 #define NFSSVC_AUTHINFAIL 0x080
218 #define NFSSVC_MNTD 0x100
219
220
221
222
223 #define NFS_NFSSTATS 1
224 #define NFS_NIOTHREADS 2
225 #define NFS_MAXID 3
226
227 #define FS_NFS_NAMES { \
228 { 0, 0 }, \
229 { "nfsstats", CTLTYPE_STRUCT }, \
230 { "iothreads", CTLTYPE_INT } \
231 }
232
233
234
235
236
237
238
239
240
241 #ifdef _KERNEL
242 extern int nfs_niothreads;
243
244 struct uio; struct buf; struct vattr; struct nameidata;
245
246 #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
247 sigmask(SIGHUP)|sigmask(SIGQUIT))
248
249
250
251
252
253 #define NFSIGNORE_SOERROR(s, e) \
254 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
255 ((s) & PR_CONNREQUIRED) == 0)
256
257
258
259
260 struct nfsreq {
261 TAILQ_ENTRY(nfsreq) r_chain;
262 struct mbuf *r_mreq;
263 struct mbuf *r_mrep;
264 struct mbuf *r_md;
265 caddr_t r_dpos;
266 struct nfsmount *r_nmp;
267 struct vnode *r_vp;
268 u_int32_t r_xid;
269 int r_flags;
270 int r_retry;
271 int r_rexmit;
272 int r_timer;
273 int r_procnum;
274 int r_rtt;
275 struct proc *r_procp;
276 };
277
278
279
280
281 extern TAILQ_HEAD(nfsreqhead, nfsreq) nfs_reqq;
282
283
284 #define R_TIMING 0x01
285 #define R_SENT 0x02
286 #define R_SOFTTERM 0x04
287 #define R_INTR 0x08
288 #define R_SOCKERR 0x10
289 #define R_TPRINTFMSG 0x20
290 #define R_MUSTRESEND 0x40
291 #define R_GETONEREP 0x80
292
293
294
295
296
297
298
299 #ifndef NFS_UIDHASHSIZ
300 #define NFS_UIDHASHSIZ 29
301 #endif
302 #define NUIDHASH(sock, uid) \
303 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
304 #ifndef NFS_WDELAYHASHSIZ
305 #define NFS_WDELAYHASHSIZ 16
306 #endif
307 #define NWDELAYHASH(sock, f) \
308 (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
309 #ifndef NFS_MUIDHASHSIZ
310 #define NFS_MUIDHASHSIZ 67
311 #endif
312 #define NMUIDHASH(nmp, uid) \
313 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
314 #define NFSNOHASH(fhsum) \
315 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
316
317
318
319
320 union nethostaddr {
321 u_int32_t had_inetaddr;
322 struct mbuf *had_nam;
323 };
324
325 struct nfsuid {
326 TAILQ_ENTRY(nfsuid) nu_lru;
327 LIST_ENTRY(nfsuid) nu_hash;
328 int nu_flag;
329 union nethostaddr nu_haddr;
330 struct ucred nu_cr;
331 int nu_expire;
332 struct timeval nu_timestamp;
333 u_int32_t nu_nickname;
334 NFSKERBKEY_T nu_key;
335 };
336
337 #define nu_inetaddr nu_haddr.had_inetaddr
338 #define nu_nam nu_haddr.had_nam
339
340 #define NU_INETADDR 0x1
341 #define NU_NAM 0x2
342 #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
343
344 struct nfssvc_sock {
345 TAILQ_ENTRY(nfssvc_sock) ns_chain;
346 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
347 struct file *ns_fp;
348 struct socket *ns_so;
349 struct mbuf *ns_nam;
350 struct mbuf *ns_raw;
351 struct mbuf *ns_rawend;
352 struct mbuf *ns_rec;
353 struct mbuf *ns_recend;
354 struct mbuf *ns_frag;
355 int ns_flag;
356 int ns_solock;
357 int ns_cc;
358 int ns_reclen;
359 int ns_numuids;
360 u_int32_t ns_sref;
361 LIST_HEAD(, nfsrv_descript) ns_tq;
362 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
363 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
364 };
365
366
367 #define SLP_VALID 0x01
368 #define SLP_DOREC 0x02
369 #define SLP_NEEDQ 0x04
370 #define SLP_DISCONN 0x08
371 #define SLP_GETSTREAM 0x10
372 #define SLP_LASTFRAG 0x20
373 #define SLP_ALLFLAGS 0xff
374
375 extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
376 extern int nfssvc_sockhead_flag;
377 #define SLP_INIT 0x01
378 #define SLP_WANTINIT 0x02
379
380
381
382
383 struct nfsd {
384 TAILQ_ENTRY(nfsd) nfsd_chain;
385 int nfsd_flag;
386 struct nfssvc_sock *nfsd_slp;
387 int nfsd_authlen;
388 u_char nfsd_authstr[RPCAUTH_MAXSIZ];
389 int nfsd_verflen;
390 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
391 struct proc *nfsd_procp;
392 struct nfsrv_descript *nfsd_nd;
393 };
394
395
396 #define NFSD_WAITING 0x01
397 #define NFSD_REQINPROG 0x02
398 #define NFSD_NEEDAUTH 0x04
399 #define NFSD_AUTHFAIL 0x08
400
401
402
403
404
405 struct nfsrv_descript {
406 u_quad_t nd_time;
407 off_t nd_off;
408 off_t nd_eoff;
409 LIST_ENTRY(nfsrv_descript) nd_hash;
410 LIST_ENTRY(nfsrv_descript) nd_tq;
411 LIST_HEAD(,nfsrv_descript) nd_coalesce;
412 struct mbuf *nd_mrep;
413 struct mbuf *nd_md;
414 struct mbuf *nd_mreq;
415 struct mbuf *nd_nam;
416 struct mbuf *nd_nam2;
417 caddr_t nd_dpos;
418 unsigned int nd_procnum;
419 int nd_stable;
420 int nd_flag;
421 int nd_len;
422 int nd_repstat;
423 u_int32_t nd_retxid;
424 struct timeval nd_starttime;
425 fhandle_t nd_fh;
426 struct ucred nd_cr;
427 };
428
429
430 #define ND_NFSV3 0x08
431 #define ND_KERBNICK 0x20
432 #define ND_KERBFULL 0x40
433 #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
434
435 extern struct pool nfsreqpl;
436 extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
437 extern int nfsd_head_flag;
438 #define NFSD_CHECKSLP 0x01
439
440
441
442
443 #define NFSW_CONTIG(o, n) \
444 ((o)->nd_eoff >= (n)->nd_off && \
445 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
446
447 #define NFSW_SAMECRED(o, n) \
448 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
449 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
450 sizeof (struct ucred)))
451
452 #endif
453 #endif