37 38/* 39 * In general, I'm not fond of #includes in .h files, but this seems 40 * to be the cleanest way to handle #include files for the ports. 41 */ 42#ifdef _KERNEL 43#include <sys/unistd.h> 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/conf.h> 47#include <sys/dirent.h> 48#include <sys/domain.h> 49#include <sys/fcntl.h> 50#include <sys/file.h> 51#include <sys/filedesc.h> 52#include <sys/jail.h> 53#include <sys/kernel.h> 54#include <sys/lockf.h> 55#include <sys/malloc.h> 56#include <sys/mbuf.h> 57#include <sys/mount.h> 58#include <sys/namei.h> 59#include <sys/proc.h> 60#include <sys/protosw.h> 61#include <sys/reboot.h> 62#include <sys/resourcevar.h> 63#include <sys/signalvar.h> 64#include <sys/socket.h> 65#include <sys/socketvar.h> 66#include <sys/stat.h> 67#include <sys/syslog.h> 68#include <sys/sysproto.h> 69#include <sys/time.h> 70#include <sys/uio.h> 71#include <sys/vnode.h> 72#include <sys/bio.h> 73#include <sys/buf.h> 74#include <sys/acl.h> 75#include <sys/module.h> 76#include <sys/sysent.h> 77#include <sys/syscall.h> 78#include <sys/priv.h> 79#include <sys/kthread.h> 80#include <sys/syscallsubr.h> 81#include <fs/fifofs/fifo.h> 82#include <net/if.h> 83#include <net/radix.h> 84#include <net/route.h> 85#include <net/if_dl.h> 86#include <netinet/in.h> 87#include <netinet/in_pcb.h> 88#include <netinet/in_systm.h> 89#include <netinet/in_var.h> 90#include <netinet/ip.h> 91#include <netinet/ip_var.h> 92#include <netinet/tcp.h> 93#include <netinet/tcp_fsm.h> 94#include <netinet/tcp_seq.h> 95#include <netinet/tcp_timer.h> 96#include <netinet/tcp_var.h> 97#include <machine/in_cksum.h> 98#include <crypto/des/des.h> 99#include <sys/md5.h> 100#include <rpc/rpc.h> 101#include <rpc/rpcsec_gss.h> 102 103/* 104 * For Darwin, these functions should be "static" when built in a kext. 105 * (This is always defined as nil otherwise.) 106 */ 107#define APPLESTATIC 108#include <ufs/ufs/dir.h> 109#include <ufs/ufs/quota.h> 110#include <ufs/ufs/inode.h> 111#include <ufs/ufs/extattr.h> 112#include <ufs/ufs/ufsmount.h> 113#include <vm/uma.h> 114#include <vm/vm.h> 115#include <vm/vm_object.h> 116#include <vm/vm_extern.h> 117#include <nfs/nfssvc.h> 118#include "opt_nfs.h" 119#include "opt_ufs.h" 120 121/* 122 * These types must be defined before the nfs includes. 123 */ 124#define NFSSOCKADDR_T struct sockaddr * 125#define NFSPROC_T struct thread 126#define NFSDEV_T dev_t 127#define NFSSVCARGS nfssvc_args 128#define NFSACL_T struct acl 129 130/* 131 * These should be defined as the types used for the corresponding VOP's 132 * argument type. 133 */ 134#define NFS_ACCESS_ARGS struct vop_access_args 135#define NFS_OPEN_ARGS struct vop_open_args 136#define NFS_GETATTR_ARGS struct vop_getattr_args 137#define NFS_LOOKUP_ARGS struct vop_lookup_args 138#define NFS_READDIR_ARGS struct vop_readdir_args 139 140/* 141 * Allocate mbufs. Must succeed and never set the mbuf ptr to NULL. 142 */ 143#define NFSMGET(m) do { \ 144 MGET((m), M_TRYWAIT, MT_DATA); \ 145 while ((m) == NULL ) { \ 146 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 147 MGET((m), M_TRYWAIT, MT_DATA); \ 148 } \ 149 } while (0) 150#define NFSMGETHDR(m) do { \ 151 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 152 while ((m) == NULL ) { \ 153 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 154 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 155 } \ 156 } while (0) 157#define NFSMCLGET(m, w) do { \ 158 MGET((m), M_TRYWAIT, MT_DATA); \ 159 while ((m) == NULL ) { \ 160 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 161 MGET((m), M_TRYWAIT, MT_DATA); \ 162 } \ 163 MCLGET((m), (w)); \ 164 } while (0) 165#define NFSMCLGETHDR(m, w) do { \ 166 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 167 while ((m) == NULL ) { \ 168 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 169 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 170 } \ 171 } while (0) 172#define NFSMTOD mtod 173 174/* 175 * Client side constant for size of a lockowner name. 176 */ 177#define NFSV4CL_LOCKNAMELEN 12 178 179/* 180 * Type for a mutex lock. 181 */ 182#define NFSMUTEX_T struct mtx 183 184#endif /* _KERNEL */ 185 186/* 187 * NFSv4 Operation numbers. 188 */ 189#define NFSV4OP_ACCESS 3 190#define NFSV4OP_CLOSE 4 191#define NFSV4OP_COMMIT 5 192#define NFSV4OP_CREATE 6 193#define NFSV4OP_DELEGPURGE 7 194#define NFSV4OP_DELEGRETURN 8 195#define NFSV4OP_GETATTR 9 196#define NFSV4OP_GETFH 10 197#define NFSV4OP_LINK 11 198#define NFSV4OP_LOCK 12 199#define NFSV4OP_LOCKT 13 200#define NFSV4OP_LOCKU 14 201#define NFSV4OP_LOOKUP 15 202#define NFSV4OP_LOOKUPP 16 203#define NFSV4OP_NVERIFY 17 204#define NFSV4OP_OPEN 18 205#define NFSV4OP_OPENATTR 19 206#define NFSV4OP_OPENCONFIRM 20 207#define NFSV4OP_OPENDOWNGRADE 21 208#define NFSV4OP_PUTFH 22 209#define NFSV4OP_PUTPUBFH 23 210#define NFSV4OP_PUTROOTFH 24 211#define NFSV4OP_READ 25 212#define NFSV4OP_READDIR 26 213#define NFSV4OP_READLINK 27 214#define NFSV4OP_REMOVE 28 215#define NFSV4OP_RENAME 29 216#define NFSV4OP_RENEW 30 217#define NFSV4OP_RESTOREFH 31 218#define NFSV4OP_SAVEFH 32 219#define NFSV4OP_SECINFO 33 220#define NFSV4OP_SETATTR 34 221#define NFSV4OP_SETCLIENTID 35 222#define NFSV4OP_SETCLIENTIDCFRM 36 223#define NFSV4OP_VERIFY 37 224#define NFSV4OP_WRITE 38 225#define NFSV4OP_RELEASELCKOWN 39 226 227/* 228 * Must be one greater than the last Operation#. 229 */ 230#define NFSV4OP_NOPS 40 231 232/* Quirky case if the illegal op code */ 233#define NFSV4OP_OPILLEGAL 10044 234 235/* 236 * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. 237 */ 238#define NFSV4OP_SYMLINK (NFSV4OP_NOPS) 239#define NFSV4OP_MKDIR (NFSV4OP_NOPS + 1) 240#define NFSV4OP_RMDIR (NFSV4OP_NOPS + 2) 241#define NFSV4OP_READDIRPLUS (NFSV4OP_NOPS + 3) 242#define NFSV4OP_MKNOD (NFSV4OP_NOPS + 4) 243#define NFSV4OP_FSSTAT (NFSV4OP_NOPS + 5) 244#define NFSV4OP_FSINFO (NFSV4OP_NOPS + 6) 245#define NFSV4OP_PATHCONF (NFSV4OP_NOPS + 7) 246#define NFSV4OP_V3CREATE (NFSV4OP_NOPS + 8) 247 248/* 249 * This is the count of the fake operations listed above. 250 */ 251#define NFSV4OP_FAKENOPS 9 252 253/* 254 * and the Callback OPs 255 */ 256#define NFSV4OP_CBGETATTR 3 257#define NFSV4OP_CBRECALL 4 258 259/* 260 * Must be one greater than the last Callback Operation#. 261 */ 262#define NFSV4OP_CBNOPS 5 263 264/* 265 * The lower numbers -> 21 are used by NFSv2 and v3. These define higher 266 * numbers used by NFSv4. 267 * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 268 * one greater than the last number. 269 */ 270#define NFS_V3NPROCS 22 271 272#define NFSPROC_LOOKUPP 22 273#define NFSPROC_SETCLIENTID 23 274#define NFSPROC_SETCLIENTIDCFRM 24 275#define NFSPROC_LOCK 25 276#define NFSPROC_LOCKU 26 277#define NFSPROC_OPEN 27 278#define NFSPROC_CLOSE 28 279#define NFSPROC_OPENCONFIRM 29 280#define NFSPROC_LOCKT 30 281#define NFSPROC_OPENDOWNGRADE 31 282#define NFSPROC_RENEW 32 283#define NFSPROC_PUTROOTFH 33 284#define NFSPROC_RELEASELCKOWN 34 285#define NFSPROC_DELEGRETURN 35 286#define NFSPROC_RETDELEGREMOVE 36 287#define NFSPROC_RETDELEGRENAME1 37 288#define NFSPROC_RETDELEGRENAME2 38 289#define NFSPROC_GETACL 39 290#define NFSPROC_SETACL 40 291 292/* 293 * Must be defined as one higher than the last Proc# above. 294 */ 295#define NFSV4_NPROCS 41 296 297/* 298 * Stats structure 299 */ 300struct ext_nfsstats { 301 int attrcache_hits; 302 int attrcache_misses; 303 int lookupcache_hits; 304 int lookupcache_misses; 305 int direofcache_hits; 306 int direofcache_misses; 307 int accesscache_hits; 308 int accesscache_misses; 309 int biocache_reads; 310 int read_bios; 311 int read_physios; 312 int biocache_writes; 313 int write_bios; 314 int write_physios; 315 int biocache_readlinks; 316 int readlink_bios; 317 int biocache_readdirs; 318 int readdir_bios; 319 int rpccnt[NFSV4_NPROCS]; 320 int rpcretries; 321 int srvrpccnt[NFSV4OP_NOPS + NFSV4OP_FAKENOPS]; 322 int srvrpc_errs; 323 int srv_errs; 324 int rpcrequests; 325 int rpctimeouts; 326 int rpcunexpected; 327 int rpcinvalid; 328 int srvcache_inproghits; 329 int srvcache_idemdonehits; 330 int srvcache_nonidemdonehits; 331 int srvcache_misses; 332 int srvcache_tcppeak; 333 int srvcache_size; 334 int srvclients; 335 int srvopenowners; 336 int srvopens; 337 int srvlockowners; 338 int srvlocks; 339 int srvdelegates; 340 int cbrpccnt[NFSV4OP_CBNOPS]; 341 int clopenowners; 342 int clopens; 343 int cllockowners; 344 int cllocks; 345 int cldelegates; 346 int cllocalopenowners; 347 int cllocalopens; 348 int cllocallockowners; 349 int cllocallocks; 350}; 351 352#ifdef _KERNEL 353/* 354 * Define the ext_nfsstats as nfsstats for the kernel code. 355 */ 356#define nfsstats ext_nfsstats 357 358/* 359 * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. 360 */ 361#define NFS_NPROCS NFSV4_NPROCS 362 363#include <fs/nfs/nfskpiport.h> 364#include <fs/nfs/nfsdport.h> 365#include <fs/nfs/rpcv2.h> 366#include <fs/nfs/nfsproto.h> 367#include <fs/nfs/nfs.h> 368#include <fs/nfs/nfs_var.h> 369#include <fs/nfs/nfsm_subs.h> 370#include <fs/nfs/nfsrvcache.h> 371#include <fs/nfs/nfsrvstate.h> 372#include <fs/nfs/xdr_subs.h> 373#include <fs/nfs/nfscl.h> 374#include <fs/nfs/nfsclstate.h> 375#include <fs/nfsclient/nfsargs.h> 376#include <fs/nfsclient/nfsmount.h> 377 378/* 379 * Just to keep nfs_var.h happy. 380 */ 381struct nfs_vattr { 382 int junk; 383}; 384 385struct nfsvattr { 386 struct vattr na_vattr; 387 nfsattrbit_t na_suppattr; 388 u_int32_t na_mntonfileno; 389 u_int64_t na_filesid[2]; 390}; 391 392#define na_type na_vattr.va_type 393#define na_mode na_vattr.va_mode 394#define na_nlink na_vattr.va_nlink 395#define na_uid na_vattr.va_uid 396#define na_gid na_vattr.va_gid 397#define na_fsid na_vattr.va_fsid 398#define na_fileid na_vattr.va_fileid 399#define na_size na_vattr.va_size 400#define na_blocksize na_vattr.va_blocksize 401#define na_atime na_vattr.va_atime 402#define na_mtime na_vattr.va_mtime 403#define na_ctime na_vattr.va_ctime 404#define na_gen na_vattr.va_gen 405#define na_flags na_vattr.va_flags 406#define na_rdev na_vattr.va_rdev 407#define na_bytes na_vattr.va_bytes 408#define na_filerev na_vattr.va_filerev 409#define na_vaflags na_vattr.va_vaflags 410 411#include <fs/nfsclient/nfsnode.h> 412 413/* 414 * This is the header structure used for the lists, etc. (It has the 415 * above record in it. 416 */ 417struct nfsrv_stablefirst { 418 LIST_HEAD(, nfsrv_stable) nsf_head; /* Head of nfsrv_stable list */ 419 time_t nsf_eograce; /* Time grace period ends */ 420 time_t *nsf_bootvals; /* Previous boottime values */ 421 struct file *nsf_fp; /* File table pointer */ 422 u_char nsf_flags; /* NFSNSF_ flags */ 423 struct nfsf_rec nsf_rec; /* and above first record */ 424}; 425#define nsf_lease nsf_rec.lease 426#define nsf_numboots nsf_rec.numboots 427 428/* NFSNSF_xxx flags */ 429#define NFSNSF_UPDATEDONE 0x01 430#define NFSNSF_GRACEOVER 0x02 431#define NFSNSF_NEEDLOCK 0x04 432#define NFSNSF_EXPIREDCLIENT 0x08 433#define NFSNSF_NOOPENS 0x10 434#define NFSNSF_OK 0x20 435 436/* 437 * Maximum number of boot times allowed in record. Although there is 438 * really no need for a fixed upper bound, this serves as a sanity check 439 * for a corrupted file. 440 */ 441#define NFSNSF_MAXNUMBOOTS 10000 442 443/* 444 * This structure defines the other records in the file. The 445 * nst_client array is actually the size of the client string name. 446 */ 447struct nfst_rec { 448 u_int16_t len; 449 u_char flag; 450 u_char client[1]; 451}; 452/* and the values for flag */ 453#define NFSNST_NEWSTATE 0x1 454#define NFSNST_REVOKE 0x2 455#define NFSNST_GOTSTATE 0x4 456 457/* 458 * This structure is linked onto nfsrv_stablefirst for the duration of 459 * reclaim. 460 */ 461struct nfsrv_stable { 462 LIST_ENTRY(nfsrv_stable) nst_list; 463 struct nfsclient *nst_clp; 464 struct nfst_rec nst_rec; 465}; 466#define nst_timestamp nst_rec.timestamp 467#define nst_len nst_rec.len 468#define nst_flag nst_rec.flag 469#define nst_client nst_rec.client 470 471/* 472 * At some point the server will run out of kernel storage for 473 * state structures. For FreeBSD5.2, this results in a panic 474 * kmem_map is full. It happens at well over 1000000 opens plus 475 * locks on a PIII-800 with 256Mbytes, so that is where I've set 476 * the limit. If your server panics due to too many opens/locks, 477 * decrease the size of NFSRV_V4STATELIMIT. If you find the server 478 * returning NFS4ERR_RESOURCE a lot and have lots of memory, try 479 * increasing it. 480 */ 481#define NFSRV_V4STATELIMIT 500000 /* Max # of Opens + Locks */ 482 483/* 484 * The type required differs with BSDen (just the second arg). 485 */ 486void nfsrvd_rcv(struct socket *, void *, int); 487 488/* 489 * Macros for handling socket addresses. (Hopefully this makes the code 490 * more portable, since I've noticed some 'BSD don't have sockaddrs in 491 * mbufs any more.) 492 */ 493#define NFSSOCKADDR(a, t) ((t)(a)) 494#define NFSSOCKADDRALLOC(a) \ 495 do { \ 496 MALLOC((a), struct sockaddr *, sizeof (struct sockaddr), \ 497 M_SONAME, M_WAITOK); \ 498 NFSBZERO((a), sizeof (struct sockaddr)); \ 499 } while (0) 500#define NFSSOCKADDRSIZE(a, s) ((a)->sa_len = (s)) 501#define NFSSOCKADDRFREE(a) \ 502 do { \ 503 if (a) \ 504 FREE((caddr_t)(a), M_SONAME); \ 505 } while (0) 506 507/* 508 * These should be defined as a process or thread structure, as required 509 * for signal handling, etc. 510 */ 511#define NFSNEWCRED(c) (crdup(c)) 512#define NFSPROCCRED(p) ((p)->td_ucred) 513#define NFSFREECRED(c) (crfree(c)) 514#define NFSUIOPROC(u, p) ((u)->uio_td = NULL) 515#define NFSPROCP(p) ((p)->td_proc) 516 517/* 518 * Define these so that cn_hash and its length is ignored. 519 */ 520#define NFSCNHASHZERO(c) 521#define NFSCNHASH(c, v) 522#define NCHNAMLEN 9999999 523 524/* 525 * Define these to use the time of day clock. 526 */ 527#define NFSGETTIME(t) (getmicrotime(t)) 528#define NFSGETNANOTIME(t) (getnanotime(t)) 529 530/* 531 * These macros are defined to initialize and set the timer routine. 532 */ 533#define NFS_TIMERINIT \ 534 newnfs_timer(NULL) 535 536/* 537 * Handle SMP stuff: 538 */ 539#define NFSSTATESPINLOCK extern struct mtx nfs_state_mutex 540#define NFSLOCKSTATE() mtx_lock(&nfs_state_mutex) 541#define NFSUNLOCKSTATE() mtx_unlock(&nfs_state_mutex) 542#define NFSSTATEMUTEXPTR (&nfs_state_mutex) 543#define NFSREQSPINLOCK extern struct mtx nfs_req_mutex 544#define NFSLOCKREQ() mtx_lock(&nfs_req_mutex) 545#define NFSUNLOCKREQ() mtx_unlock(&nfs_req_mutex) 546#define NFSCACHEMUTEX extern struct mtx nfs_cache_mutex 547#define NFSCACHEMUTEXPTR (&nfs_cache_mutex) 548#define NFSLOCKCACHE() mtx_lock(&nfs_cache_mutex) 549#define NFSUNLOCKCACHE() mtx_unlock(&nfs_cache_mutex) 550#define NFSCACHELOCKREQUIRED() mtx_assert(&nfs_cache_mutex, MA_OWNED) 551#define NFSSOCKMUTEX extern struct mtx nfs_slock_mutex 552#define NFSSOCKMUTEXPTR (&nfs_slock_mutex) 553#define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) 554#define NFSUNLOCKSOCK() mtx_unlock(&nfs_slock_mutex) 555#define NFSNAMEIDMUTEX extern struct mtx nfs_nameid_mutex 556#define NFSLOCKNAMEID() mtx_lock(&nfs_nameid_mutex) 557#define NFSUNLOCKNAMEID() mtx_unlock(&nfs_nameid_mutex) 558#define NFSNAMEIDREQUIRED() mtx_assert(&nfs_nameid_mutex, MA_OWNED) 559#define NFSCLSTATEMUTEX extern struct mtx nfs_clstate_mutex 560#define NFSCLSTATEMUTEXPTR (&nfs_clstate_mutex) 561#define NFSLOCKCLSTATE() mtx_lock(&nfs_clstate_mutex) 562#define NFSUNLOCKCLSTATE() mtx_unlock(&nfs_clstate_mutex) 563#define NFSDLOCKMUTEX extern struct mtx newnfsd_mtx 564#define NFSDLOCKMUTEXPTR (&newnfsd_mtx) 565#define NFSD_LOCK() mtx_lock(&newnfsd_mtx) 566#define NFSD_UNLOCK() mtx_unlock(&newnfsd_mtx) 567#define NFSD_LOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_OWNED) 568#define NFSD_UNLOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_NOTOWNED) 569#define NFSV4ROOTLOCKMUTEX extern struct mtx nfs_v4root_mutex 570#define NFSV4ROOTLOCKMUTEXPTR (&nfs_v4root_mutex) 571#define NFSLOCKV4ROOTMUTEX() mtx_lock(&nfs_v4root_mutex) 572#define NFSUNLOCKV4ROOTMUTEX() mtx_unlock(&nfs_v4root_mutex) 573#define NFSLOCKNODE(n) mtx_lock(&((n)->n_mtx)) 574#define NFSUNLOCKNODE(n) mtx_unlock(&((n)->n_mtx)) 575#define NFSLOCKMNT(m) mtx_lock(&((m)->nm_mtx)) 576#define NFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx)) 577#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) 578#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) 579#define NFSPROCLISTLOCK() sx_slock(&allproc_lock) 580#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock) 581#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) 582#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx)) 583 584/* 585 * Use these macros to initialize/free a mutex. 586 */ 587#define NFSINITSOCKMUTEX(m) mtx_init((m), "nfssock", NULL, MTX_DEF) 588#define NFSFREEMUTEX(m) mtx_destroy((m)) 589 590int nfsmsleep(void *, void *, int, const char *, struct timespec *); 591 592/* 593 * And weird vm stuff in the nfs server. 594 */ 595#define PDIRUNLOCK 0x0 596#define MAX_COMMIT_COUNT (1024 * 1024) 597 598/* 599 * These macros are called at the start and end of operations that 600 * might modify the underlying file system. 601 */ 602#define NFS_STARTWRITE(v, m) vn_start_write((v), (m), V_WAIT) 603#define NFS_ENDWRITE(m) vn_finished_write(m) 604 605/* 606 * Define these to handle the type of va_rdev. 607 */ 608#define NFSMAKEDEV(m, n) makedev((m), (n)) 609#define NFSMAJOR(d) major(d) 610#define NFSMINOR(d) minor(d) 611 612/* 613 * Define this to be the macro that returns the minimum size required 614 * for a directory entry. 615 */ 616#define DIRENT_SIZE(dp) GENERIC_DIRSIZ(dp) 617 618/* 619 * The vnode tag for nfsv4root. 620 */ 621#define VT_NFSV4ROOT "nfsv4root" 622 623/* 624 * Define whatever it takes to do a vn_rdwr(). 625 */ 626#define NFSD_RDWR(r, v, b, l, o, s, i, c, a, p) \ 627 vn_rdwr((r), (v), (b), (l), (o), (s), (i), (c), NULL, (a), (p)) 628 629/* 630 * Macros for handling memory for different BSDen. 631 * NFSBCOPY(src, dst, len) - copies len bytes, non-overlapping 632 * NFSOVBCOPY(src, dst, len) - ditto, but data areas might overlap 633 * NFSBCMP(cp1, cp2, len) - compare len bytes, return 0 if same 634 * NFSBZERO(cp, len) - set len bytes to 0x0 635 */ 636#define NFSBCOPY(s, d, l) bcopy((s), (d), (l)) 637#define NFSOVBCOPY(s, d, l) ovbcopy((s), (d), (l)) 638#define NFSBCMP(s, d, l) bcmp((s), (d), (l)) 639#define NFSBZERO(s, l) bzero((s), (l)) 640 641/* 642 * Some queue.h files don't have these dfined in them. 643 */ 644#define LIST_END(head) NULL 645#define SLIST_END(head) NULL 646#define TAILQ_END(head) NULL 647 648/* 649 * This must be defined to be a global variable the increments once 650 * per second, but never stops or goes backwards, even when a "date" 651 * command changes the tod clock. It is used for delta times for 652 * leases, etc. 653 */ 654#define NFSD_MONOSEC time_uptime 655 656/* 657 * Declare the malloc types. 658 */ 659MALLOC_DECLARE(M_NEWNFSRVCACHE); 660MALLOC_DECLARE(M_NEWNFSDCLIENT); 661MALLOC_DECLARE(M_NEWNFSDSTATE); 662MALLOC_DECLARE(M_NEWNFSDLOCK); 663MALLOC_DECLARE(M_NEWNFSDLOCKFILE); 664MALLOC_DECLARE(M_NEWNFSSTRING); 665MALLOC_DECLARE(M_NEWNFSUSERGROUP); 666MALLOC_DECLARE(M_NEWNFSDREQ); 667MALLOC_DECLARE(M_NEWNFSFH); 668MALLOC_DECLARE(M_NEWNFSCLOWNER); 669MALLOC_DECLARE(M_NEWNFSCLOPEN); 670MALLOC_DECLARE(M_NEWNFSCLDELEG); 671MALLOC_DECLARE(M_NEWNFSCLCLIENT); 672MALLOC_DECLARE(M_NEWNFSCLLOCKOWNER); 673MALLOC_DECLARE(M_NEWNFSCLLOCK); 674MALLOC_DECLARE(M_NEWNFSDIROFF); 675MALLOC_DECLARE(M_NEWNFSV4NODE); 676MALLOC_DECLARE(M_NEWNFSDIRECTIO); 677MALLOC_DECLARE(M_NEWNFSMNT); 678MALLOC_DECLARE(M_NEWNFSDROLLBACK); 679#define M_NFSRVCACHE M_NEWNFSRVCACHE 680#define M_NFSDCLIENT M_NEWNFSDCLIENT 681#define M_NFSDSTATE M_NEWNFSDSTATE 682#define M_NFSDLOCK M_NEWNFSDLOCK 683#define M_NFSDLOCKFILE M_NEWNFSDLOCKFILE 684#define M_NFSSTRING M_NEWNFSSTRING 685#define M_NFSUSERGROUP M_NEWNFSUSERGROUP 686#define M_NFSDREQ M_NEWNFSDREQ 687#define M_NFSFH M_NEWNFSFH 688#define M_NFSCLOWNER M_NEWNFSCLOWNER 689#define M_NFSCLOPEN M_NEWNFSCLOPEN 690#define M_NFSCLDELEG M_NEWNFSCLDELEG 691#define M_NFSCLCLIENT M_NEWNFSCLCLIENT 692#define M_NFSCLLOCKOWNER M_NEWNFSCLLOCKOWNER 693#define M_NFSCLLOCK M_NEWNFSCLLOCK 694#define M_NFSDIROFF M_NEWNFSDIROFF 695#define M_NFSV4NODE M_NEWNFSV4NODE 696#define M_NFSDIRECTIO M_NEWNFSDIRECTIO 697#define M_NFSDROLLBACK M_NEWNFSDROLLBACK 698 699#define NFSINT_SIGMASK(set) \ 700 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 701 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 702 SIGISMEMBER(set, SIGQUIT)) 703 704/* 705 * Convert a quota block count to byte count. 706 */ 707#define NFSQUOTABLKTOBYTE(q, b) (q) *= (b) 708 709/* 710 * Define this as the largest file size supported. (It should probably 711 * be available via a VFS_xxx Op, but it isn't. 712 */ 713#define NFSRV_MAXFILESIZE ((u_int64_t)0x800000000000) 714 715/* 716 * Set this macro to index() or strchr(), whichever is supported. 717 */ 718#define STRCHR(s, c) index((s), (c)) 719 720/* 721 * Set the n_time in the client write rpc, as required. 722 */ 723#define NFSWRITERPC_SETTIME(w, n, v4) \ 724 do { \ 725 if (w) { \ 726 (n)->n_mtime = (n)->n_vattr.na_vattr.va_mtime; \ 727 if (v4) \ 728 (n)->n_change = (n)->n_vattr.na_vattr.va_filerev; \ 729 } \ 730 } while (0) 731 732/* 733 * Fake value, just to make the client work. 734 */ 735#define NFS_LATTR_NOSHRINK 1 736 737/* 738 * Prototypes for functions where the arguments vary for different ports. 739 */ 740int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, 741 int, int); 742void newnfs_realign(struct mbuf **); 743 744/* 745 * If the port runs on an SMP box that can enforce Atomic ops with low 746 * overheads, define these as atomic increments/decrements. If not, 747 * don't worry about it, since these are used for stats that can be 748 * "out by one" without disastrous consequences. 749 */ 750#define NFSINCRGLOBAL(a) ((a)++) 751 752/* 753 * Assorted funky stuff to make things work under Darwin8. 754 */ 755/* 756 * These macros checks for a field in vattr being set. 757 */ 758#define NFSATTRISSET(t, v, a) ((v)->a != (t)VNOVAL) 759#define NFSATTRISSETTIME(v, a) ((v)->a.tv_sec != VNOVAL) 760 761/* 762 * Manipulate mount flags. 763 */ 764#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier */ 765#define NFSSTA_GOTFSINFO 0x00100000 /* Got the fsinfo */ 766#define NFSSTA_TIMEO 0x10000000 /* Experiencing a timeout */ 767#define NFSSTA_LOCKTIMEO 0x20000000 /* Experiencing a lockd timeout */ 768#define NFSSTA_HASSETFSID 0x40000000 /* Has set the fsid */ 769 770#define NFSHASNFSV3(n) ((n)->nm_flag & NFSMNT_NFSV3) 771#define NFSHASNFSV4(n) ((n)->nm_flag & NFSMNT_NFSV4) 772#define NFSHASNFSV3OR4(n) ((n)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) 773#define NFSHASGOTFSINFO(n) ((n)->nm_state & NFSSTA_GOTFSINFO) 774#define NFSHASHASSETFSID(n) ((n)->nm_state & NFSSTA_HASSETFSID) 775#define NFSHASSTRICT3530(n) ((n)->nm_flag & NFSMNT_STRICT3530) 776#define NFSHASWRITEVERF(n) ((n)->nm_state & NFSSTA_HASWRITEVERF) 777#define NFSHASINT(n) ((n)->nm_flag & NFSMNT_INT) 778#define NFSHASSOFT(n) ((n)->nm_flag & NFSMNT_SOFT) 779#define NFSHASINTORSOFT(n) ((n)->nm_flag & (NFSMNT_INT | NFSMNT_SOFT)) 780#define NFSHASDUMBTIMR(n) ((n)->nm_flag & NFSMNT_DUMBTIMR) 781#define NFSHASNOCONN(n) ((n)->nm_flag & NFSMNT_MNTD) 782#define NFSHASKERB(n) ((n)->nm_flag & NFSMNT_KERB) 783#define NFSHASALLGSSNAME(n) ((n)->nm_flag & NFSMNT_ALLGSSNAME) 784#define NFSHASINTEGRITY(n) ((n)->nm_flag & NFSMNT_INTEGRITY) 785#define NFSHASPRIVACY(n) ((n)->nm_flag & NFSMNT_PRIVACY) 786#define NFSSETWRITEVERF(n) ((n)->nm_state |= NFSSTA_HASWRITEVERF) 787#define NFSSETHASSETFSID(n) ((n)->nm_state |= NFSSTA_HASSETFSID) 788#ifdef NFS4_ACL_EXTATTR_NAME 789#define NFSHASNFS4ACL(m) nfs_supportsnfsv4acls(m) 790int nfs_supportsnfsv4acls(struct mount *); 791#else 792#define NFSHASNFS4ACL(m) 0 793#endif 794 795/* 796 * Gets the stats field out of the mount structure. 797 */ 798#define vfs_statfs(m) (&((m)->mnt_stat)) 799 800/* 801 * Set boottime. 802 */ 803#define NFSSETBOOTTIME(b) ((b) = boottime) 804 805/* 806 * The size of directory blocks in the buffer cache. 807 * MUST BE in the range of PAGE_SIZE <= NFS_DIRBLKSIZ <= MAXBSIZE!! 808 */ 809#define NFS_DIRBLKSIZ (16 * DIRBLKSIZ) /* Must be a multiple of DIRBLKSIZ */ 810 811/* 812 * Define these macros to access mnt_flag fields. 813 */ 814#define NFSMNT_RDONLY(m) ((m)->mnt_flag & MNT_RDONLY) 815#endif /* _KERNEL */ 816 817/* 818 * Define a structure similar to ufs_args for use in exporting the V4 root. 819 */ 820struct nfsex_args { 821 char *fspec; 822 struct export_args export; 823}; 824 825/* 826 * These export flags should be defined, but there are no bits left. 827 * Maybe a separate mnt_exflag field could be added or the mnt_flag 828 * field increased to 64 bits? 829 */ 830#ifndef MNT_EXSTRICTACCESS 831#define MNT_EXSTRICTACCESS 0x0 832#endif 833#ifndef MNT_EXV4ONLY 834#define MNT_EXV4ONLY 0x0 835#endif 836 837#ifdef _KERNEL 838/* 839 * Define this to invalidate the attribute cache for the nfs node. 840 */ 841#define NFSINVALATTRCACHE(n) ((n)->n_attrstamp = 0) 842 843/* Used for FreeBSD only */ 844void nfsd_mntinit(void); 845 846/* 847 * Define these for vnode lock/unlock ops. 848 */ 849#define NFSVOPLOCK(v, f, p) vn_lock((v), (f)) 850#define NFSVOPUNLOCK(v, f, p) VOP_UNLOCK((v), (f)) 851#define NFSVOPISLOCKED(v, p) VOP_ISLOCKED((v)) 852 853/* 854 * Define ncl_hash(). 855 */ 856#define ncl_hash(f, l) (fnv_32_buf((f), (l), FNV1_32_INIT)) 857 858int newnfs_iosize(struct nfsmount *); 859 860#ifdef NFS_DEBUG 861 862extern int nfs_debug; 863#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 864#define NFS_DEBUG_WG 2 /* server write gathering */ 865#define NFS_DEBUG_RC 4 /* server request caching */ 866 867#define NFS_DPF(cat, args) \ 868 do { \ 869 if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 870 } while (0) 871 872#else 873 874#define NFS_DPF(cat, args) 875 876#endif 877 878int newnfs_vncmpf(struct vnode *, void *); 879 880#ifndef NFS_MINDIRATTRTIMO 881#define NFS_MINDIRATTRTIMO 3 /* VDIR attrib cache timeout in sec */ 882#endif 883#ifndef NFS_MAXDIRATTRTIMO 884#define NFS_MAXDIRATTRTIMO 60 885#endif 886 887/* 888 * Nfs outstanding request list element 889 */ 890struct nfsreq { 891 TAILQ_ENTRY(nfsreq) r_chain; 892 u_int32_t r_flags; /* flags on request, see below */ 893 struct nfsmount *r_nmp; /* Client mnt ptr */ 894 struct mtx r_mtx; /* Mutex lock for this structure */ 895}; 896 897#ifndef NFS_MAXBSIZE 898#define NFS_MAXBSIZE MAXBSIZE 899#endif 900 901/* 902 * This macro checks to see if issuing of delegations is allowed for this 903 * vnode. 904 */ 905#ifdef VV_DISABLEDELEG 906#define NFSVNO_DELEGOK(v) \ 907 ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0) 908#else 909#define NFSVNO_DELEGOK(v) (1) 910#endif 911 912/* 913 * Define this as the flags argument for msleep() when catching signals 914 * while holding a resource that other threads would block for, such as 915 * a vnode lock. 916 */ 917#define NFS_PCATCH (PCATCH | PBDRY) 918 919#endif /* _KERNEL */ 920
| 37 38/* 39 * In general, I'm not fond of #includes in .h files, but this seems 40 * to be the cleanest way to handle #include files for the ports. 41 */ 42#ifdef _KERNEL 43#include <sys/unistd.h> 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/conf.h> 47#include <sys/dirent.h> 48#include <sys/domain.h> 49#include <sys/fcntl.h> 50#include <sys/file.h> 51#include <sys/filedesc.h> 52#include <sys/jail.h> 53#include <sys/kernel.h> 54#include <sys/lockf.h> 55#include <sys/malloc.h> 56#include <sys/mbuf.h> 57#include <sys/mount.h> 58#include <sys/namei.h> 59#include <sys/proc.h> 60#include <sys/protosw.h> 61#include <sys/reboot.h> 62#include <sys/resourcevar.h> 63#include <sys/signalvar.h> 64#include <sys/socket.h> 65#include <sys/socketvar.h> 66#include <sys/stat.h> 67#include <sys/syslog.h> 68#include <sys/sysproto.h> 69#include <sys/time.h> 70#include <sys/uio.h> 71#include <sys/vnode.h> 72#include <sys/bio.h> 73#include <sys/buf.h> 74#include <sys/acl.h> 75#include <sys/module.h> 76#include <sys/sysent.h> 77#include <sys/syscall.h> 78#include <sys/priv.h> 79#include <sys/kthread.h> 80#include <sys/syscallsubr.h> 81#include <fs/fifofs/fifo.h> 82#include <net/if.h> 83#include <net/radix.h> 84#include <net/route.h> 85#include <net/if_dl.h> 86#include <netinet/in.h> 87#include <netinet/in_pcb.h> 88#include <netinet/in_systm.h> 89#include <netinet/in_var.h> 90#include <netinet/ip.h> 91#include <netinet/ip_var.h> 92#include <netinet/tcp.h> 93#include <netinet/tcp_fsm.h> 94#include <netinet/tcp_seq.h> 95#include <netinet/tcp_timer.h> 96#include <netinet/tcp_var.h> 97#include <machine/in_cksum.h> 98#include <crypto/des/des.h> 99#include <sys/md5.h> 100#include <rpc/rpc.h> 101#include <rpc/rpcsec_gss.h> 102 103/* 104 * For Darwin, these functions should be "static" when built in a kext. 105 * (This is always defined as nil otherwise.) 106 */ 107#define APPLESTATIC 108#include <ufs/ufs/dir.h> 109#include <ufs/ufs/quota.h> 110#include <ufs/ufs/inode.h> 111#include <ufs/ufs/extattr.h> 112#include <ufs/ufs/ufsmount.h> 113#include <vm/uma.h> 114#include <vm/vm.h> 115#include <vm/vm_object.h> 116#include <vm/vm_extern.h> 117#include <nfs/nfssvc.h> 118#include "opt_nfs.h" 119#include "opt_ufs.h" 120 121/* 122 * These types must be defined before the nfs includes. 123 */ 124#define NFSSOCKADDR_T struct sockaddr * 125#define NFSPROC_T struct thread 126#define NFSDEV_T dev_t 127#define NFSSVCARGS nfssvc_args 128#define NFSACL_T struct acl 129 130/* 131 * These should be defined as the types used for the corresponding VOP's 132 * argument type. 133 */ 134#define NFS_ACCESS_ARGS struct vop_access_args 135#define NFS_OPEN_ARGS struct vop_open_args 136#define NFS_GETATTR_ARGS struct vop_getattr_args 137#define NFS_LOOKUP_ARGS struct vop_lookup_args 138#define NFS_READDIR_ARGS struct vop_readdir_args 139 140/* 141 * Allocate mbufs. Must succeed and never set the mbuf ptr to NULL. 142 */ 143#define NFSMGET(m) do { \ 144 MGET((m), M_TRYWAIT, MT_DATA); \ 145 while ((m) == NULL ) { \ 146 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 147 MGET((m), M_TRYWAIT, MT_DATA); \ 148 } \ 149 } while (0) 150#define NFSMGETHDR(m) do { \ 151 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 152 while ((m) == NULL ) { \ 153 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 154 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 155 } \ 156 } while (0) 157#define NFSMCLGET(m, w) do { \ 158 MGET((m), M_TRYWAIT, MT_DATA); \ 159 while ((m) == NULL ) { \ 160 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 161 MGET((m), M_TRYWAIT, MT_DATA); \ 162 } \ 163 MCLGET((m), (w)); \ 164 } while (0) 165#define NFSMCLGETHDR(m, w) do { \ 166 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 167 while ((m) == NULL ) { \ 168 (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 169 MGETHDR((m), M_TRYWAIT, MT_DATA); \ 170 } \ 171 } while (0) 172#define NFSMTOD mtod 173 174/* 175 * Client side constant for size of a lockowner name. 176 */ 177#define NFSV4CL_LOCKNAMELEN 12 178 179/* 180 * Type for a mutex lock. 181 */ 182#define NFSMUTEX_T struct mtx 183 184#endif /* _KERNEL */ 185 186/* 187 * NFSv4 Operation numbers. 188 */ 189#define NFSV4OP_ACCESS 3 190#define NFSV4OP_CLOSE 4 191#define NFSV4OP_COMMIT 5 192#define NFSV4OP_CREATE 6 193#define NFSV4OP_DELEGPURGE 7 194#define NFSV4OP_DELEGRETURN 8 195#define NFSV4OP_GETATTR 9 196#define NFSV4OP_GETFH 10 197#define NFSV4OP_LINK 11 198#define NFSV4OP_LOCK 12 199#define NFSV4OP_LOCKT 13 200#define NFSV4OP_LOCKU 14 201#define NFSV4OP_LOOKUP 15 202#define NFSV4OP_LOOKUPP 16 203#define NFSV4OP_NVERIFY 17 204#define NFSV4OP_OPEN 18 205#define NFSV4OP_OPENATTR 19 206#define NFSV4OP_OPENCONFIRM 20 207#define NFSV4OP_OPENDOWNGRADE 21 208#define NFSV4OP_PUTFH 22 209#define NFSV4OP_PUTPUBFH 23 210#define NFSV4OP_PUTROOTFH 24 211#define NFSV4OP_READ 25 212#define NFSV4OP_READDIR 26 213#define NFSV4OP_READLINK 27 214#define NFSV4OP_REMOVE 28 215#define NFSV4OP_RENAME 29 216#define NFSV4OP_RENEW 30 217#define NFSV4OP_RESTOREFH 31 218#define NFSV4OP_SAVEFH 32 219#define NFSV4OP_SECINFO 33 220#define NFSV4OP_SETATTR 34 221#define NFSV4OP_SETCLIENTID 35 222#define NFSV4OP_SETCLIENTIDCFRM 36 223#define NFSV4OP_VERIFY 37 224#define NFSV4OP_WRITE 38 225#define NFSV4OP_RELEASELCKOWN 39 226 227/* 228 * Must be one greater than the last Operation#. 229 */ 230#define NFSV4OP_NOPS 40 231 232/* Quirky case if the illegal op code */ 233#define NFSV4OP_OPILLEGAL 10044 234 235/* 236 * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. 237 */ 238#define NFSV4OP_SYMLINK (NFSV4OP_NOPS) 239#define NFSV4OP_MKDIR (NFSV4OP_NOPS + 1) 240#define NFSV4OP_RMDIR (NFSV4OP_NOPS + 2) 241#define NFSV4OP_READDIRPLUS (NFSV4OP_NOPS + 3) 242#define NFSV4OP_MKNOD (NFSV4OP_NOPS + 4) 243#define NFSV4OP_FSSTAT (NFSV4OP_NOPS + 5) 244#define NFSV4OP_FSINFO (NFSV4OP_NOPS + 6) 245#define NFSV4OP_PATHCONF (NFSV4OP_NOPS + 7) 246#define NFSV4OP_V3CREATE (NFSV4OP_NOPS + 8) 247 248/* 249 * This is the count of the fake operations listed above. 250 */ 251#define NFSV4OP_FAKENOPS 9 252 253/* 254 * and the Callback OPs 255 */ 256#define NFSV4OP_CBGETATTR 3 257#define NFSV4OP_CBRECALL 4 258 259/* 260 * Must be one greater than the last Callback Operation#. 261 */ 262#define NFSV4OP_CBNOPS 5 263 264/* 265 * The lower numbers -> 21 are used by NFSv2 and v3. These define higher 266 * numbers used by NFSv4. 267 * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 268 * one greater than the last number. 269 */ 270#define NFS_V3NPROCS 22 271 272#define NFSPROC_LOOKUPP 22 273#define NFSPROC_SETCLIENTID 23 274#define NFSPROC_SETCLIENTIDCFRM 24 275#define NFSPROC_LOCK 25 276#define NFSPROC_LOCKU 26 277#define NFSPROC_OPEN 27 278#define NFSPROC_CLOSE 28 279#define NFSPROC_OPENCONFIRM 29 280#define NFSPROC_LOCKT 30 281#define NFSPROC_OPENDOWNGRADE 31 282#define NFSPROC_RENEW 32 283#define NFSPROC_PUTROOTFH 33 284#define NFSPROC_RELEASELCKOWN 34 285#define NFSPROC_DELEGRETURN 35 286#define NFSPROC_RETDELEGREMOVE 36 287#define NFSPROC_RETDELEGRENAME1 37 288#define NFSPROC_RETDELEGRENAME2 38 289#define NFSPROC_GETACL 39 290#define NFSPROC_SETACL 40 291 292/* 293 * Must be defined as one higher than the last Proc# above. 294 */ 295#define NFSV4_NPROCS 41 296 297/* 298 * Stats structure 299 */ 300struct ext_nfsstats { 301 int attrcache_hits; 302 int attrcache_misses; 303 int lookupcache_hits; 304 int lookupcache_misses; 305 int direofcache_hits; 306 int direofcache_misses; 307 int accesscache_hits; 308 int accesscache_misses; 309 int biocache_reads; 310 int read_bios; 311 int read_physios; 312 int biocache_writes; 313 int write_bios; 314 int write_physios; 315 int biocache_readlinks; 316 int readlink_bios; 317 int biocache_readdirs; 318 int readdir_bios; 319 int rpccnt[NFSV4_NPROCS]; 320 int rpcretries; 321 int srvrpccnt[NFSV4OP_NOPS + NFSV4OP_FAKENOPS]; 322 int srvrpc_errs; 323 int srv_errs; 324 int rpcrequests; 325 int rpctimeouts; 326 int rpcunexpected; 327 int rpcinvalid; 328 int srvcache_inproghits; 329 int srvcache_idemdonehits; 330 int srvcache_nonidemdonehits; 331 int srvcache_misses; 332 int srvcache_tcppeak; 333 int srvcache_size; 334 int srvclients; 335 int srvopenowners; 336 int srvopens; 337 int srvlockowners; 338 int srvlocks; 339 int srvdelegates; 340 int cbrpccnt[NFSV4OP_CBNOPS]; 341 int clopenowners; 342 int clopens; 343 int cllockowners; 344 int cllocks; 345 int cldelegates; 346 int cllocalopenowners; 347 int cllocalopens; 348 int cllocallockowners; 349 int cllocallocks; 350}; 351 352#ifdef _KERNEL 353/* 354 * Define the ext_nfsstats as nfsstats for the kernel code. 355 */ 356#define nfsstats ext_nfsstats 357 358/* 359 * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. 360 */ 361#define NFS_NPROCS NFSV4_NPROCS 362 363#include <fs/nfs/nfskpiport.h> 364#include <fs/nfs/nfsdport.h> 365#include <fs/nfs/rpcv2.h> 366#include <fs/nfs/nfsproto.h> 367#include <fs/nfs/nfs.h> 368#include <fs/nfs/nfs_var.h> 369#include <fs/nfs/nfsm_subs.h> 370#include <fs/nfs/nfsrvcache.h> 371#include <fs/nfs/nfsrvstate.h> 372#include <fs/nfs/xdr_subs.h> 373#include <fs/nfs/nfscl.h> 374#include <fs/nfs/nfsclstate.h> 375#include <fs/nfsclient/nfsargs.h> 376#include <fs/nfsclient/nfsmount.h> 377 378/* 379 * Just to keep nfs_var.h happy. 380 */ 381struct nfs_vattr { 382 int junk; 383}; 384 385struct nfsvattr { 386 struct vattr na_vattr; 387 nfsattrbit_t na_suppattr; 388 u_int32_t na_mntonfileno; 389 u_int64_t na_filesid[2]; 390}; 391 392#define na_type na_vattr.va_type 393#define na_mode na_vattr.va_mode 394#define na_nlink na_vattr.va_nlink 395#define na_uid na_vattr.va_uid 396#define na_gid na_vattr.va_gid 397#define na_fsid na_vattr.va_fsid 398#define na_fileid na_vattr.va_fileid 399#define na_size na_vattr.va_size 400#define na_blocksize na_vattr.va_blocksize 401#define na_atime na_vattr.va_atime 402#define na_mtime na_vattr.va_mtime 403#define na_ctime na_vattr.va_ctime 404#define na_gen na_vattr.va_gen 405#define na_flags na_vattr.va_flags 406#define na_rdev na_vattr.va_rdev 407#define na_bytes na_vattr.va_bytes 408#define na_filerev na_vattr.va_filerev 409#define na_vaflags na_vattr.va_vaflags 410 411#include <fs/nfsclient/nfsnode.h> 412 413/* 414 * This is the header structure used for the lists, etc. (It has the 415 * above record in it. 416 */ 417struct nfsrv_stablefirst { 418 LIST_HEAD(, nfsrv_stable) nsf_head; /* Head of nfsrv_stable list */ 419 time_t nsf_eograce; /* Time grace period ends */ 420 time_t *nsf_bootvals; /* Previous boottime values */ 421 struct file *nsf_fp; /* File table pointer */ 422 u_char nsf_flags; /* NFSNSF_ flags */ 423 struct nfsf_rec nsf_rec; /* and above first record */ 424}; 425#define nsf_lease nsf_rec.lease 426#define nsf_numboots nsf_rec.numboots 427 428/* NFSNSF_xxx flags */ 429#define NFSNSF_UPDATEDONE 0x01 430#define NFSNSF_GRACEOVER 0x02 431#define NFSNSF_NEEDLOCK 0x04 432#define NFSNSF_EXPIREDCLIENT 0x08 433#define NFSNSF_NOOPENS 0x10 434#define NFSNSF_OK 0x20 435 436/* 437 * Maximum number of boot times allowed in record. Although there is 438 * really no need for a fixed upper bound, this serves as a sanity check 439 * for a corrupted file. 440 */ 441#define NFSNSF_MAXNUMBOOTS 10000 442 443/* 444 * This structure defines the other records in the file. The 445 * nst_client array is actually the size of the client string name. 446 */ 447struct nfst_rec { 448 u_int16_t len; 449 u_char flag; 450 u_char client[1]; 451}; 452/* and the values for flag */ 453#define NFSNST_NEWSTATE 0x1 454#define NFSNST_REVOKE 0x2 455#define NFSNST_GOTSTATE 0x4 456 457/* 458 * This structure is linked onto nfsrv_stablefirst for the duration of 459 * reclaim. 460 */ 461struct nfsrv_stable { 462 LIST_ENTRY(nfsrv_stable) nst_list; 463 struct nfsclient *nst_clp; 464 struct nfst_rec nst_rec; 465}; 466#define nst_timestamp nst_rec.timestamp 467#define nst_len nst_rec.len 468#define nst_flag nst_rec.flag 469#define nst_client nst_rec.client 470 471/* 472 * At some point the server will run out of kernel storage for 473 * state structures. For FreeBSD5.2, this results in a panic 474 * kmem_map is full. It happens at well over 1000000 opens plus 475 * locks on a PIII-800 with 256Mbytes, so that is where I've set 476 * the limit. If your server panics due to too many opens/locks, 477 * decrease the size of NFSRV_V4STATELIMIT. If you find the server 478 * returning NFS4ERR_RESOURCE a lot and have lots of memory, try 479 * increasing it. 480 */ 481#define NFSRV_V4STATELIMIT 500000 /* Max # of Opens + Locks */ 482 483/* 484 * The type required differs with BSDen (just the second arg). 485 */ 486void nfsrvd_rcv(struct socket *, void *, int); 487 488/* 489 * Macros for handling socket addresses. (Hopefully this makes the code 490 * more portable, since I've noticed some 'BSD don't have sockaddrs in 491 * mbufs any more.) 492 */ 493#define NFSSOCKADDR(a, t) ((t)(a)) 494#define NFSSOCKADDRALLOC(a) \ 495 do { \ 496 MALLOC((a), struct sockaddr *, sizeof (struct sockaddr), \ 497 M_SONAME, M_WAITOK); \ 498 NFSBZERO((a), sizeof (struct sockaddr)); \ 499 } while (0) 500#define NFSSOCKADDRSIZE(a, s) ((a)->sa_len = (s)) 501#define NFSSOCKADDRFREE(a) \ 502 do { \ 503 if (a) \ 504 FREE((caddr_t)(a), M_SONAME); \ 505 } while (0) 506 507/* 508 * These should be defined as a process or thread structure, as required 509 * for signal handling, etc. 510 */ 511#define NFSNEWCRED(c) (crdup(c)) 512#define NFSPROCCRED(p) ((p)->td_ucred) 513#define NFSFREECRED(c) (crfree(c)) 514#define NFSUIOPROC(u, p) ((u)->uio_td = NULL) 515#define NFSPROCP(p) ((p)->td_proc) 516 517/* 518 * Define these so that cn_hash and its length is ignored. 519 */ 520#define NFSCNHASHZERO(c) 521#define NFSCNHASH(c, v) 522#define NCHNAMLEN 9999999 523 524/* 525 * Define these to use the time of day clock. 526 */ 527#define NFSGETTIME(t) (getmicrotime(t)) 528#define NFSGETNANOTIME(t) (getnanotime(t)) 529 530/* 531 * These macros are defined to initialize and set the timer routine. 532 */ 533#define NFS_TIMERINIT \ 534 newnfs_timer(NULL) 535 536/* 537 * Handle SMP stuff: 538 */ 539#define NFSSTATESPINLOCK extern struct mtx nfs_state_mutex 540#define NFSLOCKSTATE() mtx_lock(&nfs_state_mutex) 541#define NFSUNLOCKSTATE() mtx_unlock(&nfs_state_mutex) 542#define NFSSTATEMUTEXPTR (&nfs_state_mutex) 543#define NFSREQSPINLOCK extern struct mtx nfs_req_mutex 544#define NFSLOCKREQ() mtx_lock(&nfs_req_mutex) 545#define NFSUNLOCKREQ() mtx_unlock(&nfs_req_mutex) 546#define NFSCACHEMUTEX extern struct mtx nfs_cache_mutex 547#define NFSCACHEMUTEXPTR (&nfs_cache_mutex) 548#define NFSLOCKCACHE() mtx_lock(&nfs_cache_mutex) 549#define NFSUNLOCKCACHE() mtx_unlock(&nfs_cache_mutex) 550#define NFSCACHELOCKREQUIRED() mtx_assert(&nfs_cache_mutex, MA_OWNED) 551#define NFSSOCKMUTEX extern struct mtx nfs_slock_mutex 552#define NFSSOCKMUTEXPTR (&nfs_slock_mutex) 553#define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) 554#define NFSUNLOCKSOCK() mtx_unlock(&nfs_slock_mutex) 555#define NFSNAMEIDMUTEX extern struct mtx nfs_nameid_mutex 556#define NFSLOCKNAMEID() mtx_lock(&nfs_nameid_mutex) 557#define NFSUNLOCKNAMEID() mtx_unlock(&nfs_nameid_mutex) 558#define NFSNAMEIDREQUIRED() mtx_assert(&nfs_nameid_mutex, MA_OWNED) 559#define NFSCLSTATEMUTEX extern struct mtx nfs_clstate_mutex 560#define NFSCLSTATEMUTEXPTR (&nfs_clstate_mutex) 561#define NFSLOCKCLSTATE() mtx_lock(&nfs_clstate_mutex) 562#define NFSUNLOCKCLSTATE() mtx_unlock(&nfs_clstate_mutex) 563#define NFSDLOCKMUTEX extern struct mtx newnfsd_mtx 564#define NFSDLOCKMUTEXPTR (&newnfsd_mtx) 565#define NFSD_LOCK() mtx_lock(&newnfsd_mtx) 566#define NFSD_UNLOCK() mtx_unlock(&newnfsd_mtx) 567#define NFSD_LOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_OWNED) 568#define NFSD_UNLOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_NOTOWNED) 569#define NFSV4ROOTLOCKMUTEX extern struct mtx nfs_v4root_mutex 570#define NFSV4ROOTLOCKMUTEXPTR (&nfs_v4root_mutex) 571#define NFSLOCKV4ROOTMUTEX() mtx_lock(&nfs_v4root_mutex) 572#define NFSUNLOCKV4ROOTMUTEX() mtx_unlock(&nfs_v4root_mutex) 573#define NFSLOCKNODE(n) mtx_lock(&((n)->n_mtx)) 574#define NFSUNLOCKNODE(n) mtx_unlock(&((n)->n_mtx)) 575#define NFSLOCKMNT(m) mtx_lock(&((m)->nm_mtx)) 576#define NFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx)) 577#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) 578#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) 579#define NFSPROCLISTLOCK() sx_slock(&allproc_lock) 580#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock) 581#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) 582#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx)) 583 584/* 585 * Use these macros to initialize/free a mutex. 586 */ 587#define NFSINITSOCKMUTEX(m) mtx_init((m), "nfssock", NULL, MTX_DEF) 588#define NFSFREEMUTEX(m) mtx_destroy((m)) 589 590int nfsmsleep(void *, void *, int, const char *, struct timespec *); 591 592/* 593 * And weird vm stuff in the nfs server. 594 */ 595#define PDIRUNLOCK 0x0 596#define MAX_COMMIT_COUNT (1024 * 1024) 597 598/* 599 * These macros are called at the start and end of operations that 600 * might modify the underlying file system. 601 */ 602#define NFS_STARTWRITE(v, m) vn_start_write((v), (m), V_WAIT) 603#define NFS_ENDWRITE(m) vn_finished_write(m) 604 605/* 606 * Define these to handle the type of va_rdev. 607 */ 608#define NFSMAKEDEV(m, n) makedev((m), (n)) 609#define NFSMAJOR(d) major(d) 610#define NFSMINOR(d) minor(d) 611 612/* 613 * Define this to be the macro that returns the minimum size required 614 * for a directory entry. 615 */ 616#define DIRENT_SIZE(dp) GENERIC_DIRSIZ(dp) 617 618/* 619 * The vnode tag for nfsv4root. 620 */ 621#define VT_NFSV4ROOT "nfsv4root" 622 623/* 624 * Define whatever it takes to do a vn_rdwr(). 625 */ 626#define NFSD_RDWR(r, v, b, l, o, s, i, c, a, p) \ 627 vn_rdwr((r), (v), (b), (l), (o), (s), (i), (c), NULL, (a), (p)) 628 629/* 630 * Macros for handling memory for different BSDen. 631 * NFSBCOPY(src, dst, len) - copies len bytes, non-overlapping 632 * NFSOVBCOPY(src, dst, len) - ditto, but data areas might overlap 633 * NFSBCMP(cp1, cp2, len) - compare len bytes, return 0 if same 634 * NFSBZERO(cp, len) - set len bytes to 0x0 635 */ 636#define NFSBCOPY(s, d, l) bcopy((s), (d), (l)) 637#define NFSOVBCOPY(s, d, l) ovbcopy((s), (d), (l)) 638#define NFSBCMP(s, d, l) bcmp((s), (d), (l)) 639#define NFSBZERO(s, l) bzero((s), (l)) 640 641/* 642 * Some queue.h files don't have these dfined in them. 643 */ 644#define LIST_END(head) NULL 645#define SLIST_END(head) NULL 646#define TAILQ_END(head) NULL 647 648/* 649 * This must be defined to be a global variable the increments once 650 * per second, but never stops or goes backwards, even when a "date" 651 * command changes the tod clock. It is used for delta times for 652 * leases, etc. 653 */ 654#define NFSD_MONOSEC time_uptime 655 656/* 657 * Declare the malloc types. 658 */ 659MALLOC_DECLARE(M_NEWNFSRVCACHE); 660MALLOC_DECLARE(M_NEWNFSDCLIENT); 661MALLOC_DECLARE(M_NEWNFSDSTATE); 662MALLOC_DECLARE(M_NEWNFSDLOCK); 663MALLOC_DECLARE(M_NEWNFSDLOCKFILE); 664MALLOC_DECLARE(M_NEWNFSSTRING); 665MALLOC_DECLARE(M_NEWNFSUSERGROUP); 666MALLOC_DECLARE(M_NEWNFSDREQ); 667MALLOC_DECLARE(M_NEWNFSFH); 668MALLOC_DECLARE(M_NEWNFSCLOWNER); 669MALLOC_DECLARE(M_NEWNFSCLOPEN); 670MALLOC_DECLARE(M_NEWNFSCLDELEG); 671MALLOC_DECLARE(M_NEWNFSCLCLIENT); 672MALLOC_DECLARE(M_NEWNFSCLLOCKOWNER); 673MALLOC_DECLARE(M_NEWNFSCLLOCK); 674MALLOC_DECLARE(M_NEWNFSDIROFF); 675MALLOC_DECLARE(M_NEWNFSV4NODE); 676MALLOC_DECLARE(M_NEWNFSDIRECTIO); 677MALLOC_DECLARE(M_NEWNFSMNT); 678MALLOC_DECLARE(M_NEWNFSDROLLBACK); 679#define M_NFSRVCACHE M_NEWNFSRVCACHE 680#define M_NFSDCLIENT M_NEWNFSDCLIENT 681#define M_NFSDSTATE M_NEWNFSDSTATE 682#define M_NFSDLOCK M_NEWNFSDLOCK 683#define M_NFSDLOCKFILE M_NEWNFSDLOCKFILE 684#define M_NFSSTRING M_NEWNFSSTRING 685#define M_NFSUSERGROUP M_NEWNFSUSERGROUP 686#define M_NFSDREQ M_NEWNFSDREQ 687#define M_NFSFH M_NEWNFSFH 688#define M_NFSCLOWNER M_NEWNFSCLOWNER 689#define M_NFSCLOPEN M_NEWNFSCLOPEN 690#define M_NFSCLDELEG M_NEWNFSCLDELEG 691#define M_NFSCLCLIENT M_NEWNFSCLCLIENT 692#define M_NFSCLLOCKOWNER M_NEWNFSCLLOCKOWNER 693#define M_NFSCLLOCK M_NEWNFSCLLOCK 694#define M_NFSDIROFF M_NEWNFSDIROFF 695#define M_NFSV4NODE M_NEWNFSV4NODE 696#define M_NFSDIRECTIO M_NEWNFSDIRECTIO 697#define M_NFSDROLLBACK M_NEWNFSDROLLBACK 698 699#define NFSINT_SIGMASK(set) \ 700 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 701 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 702 SIGISMEMBER(set, SIGQUIT)) 703 704/* 705 * Convert a quota block count to byte count. 706 */ 707#define NFSQUOTABLKTOBYTE(q, b) (q) *= (b) 708 709/* 710 * Define this as the largest file size supported. (It should probably 711 * be available via a VFS_xxx Op, but it isn't. 712 */ 713#define NFSRV_MAXFILESIZE ((u_int64_t)0x800000000000) 714 715/* 716 * Set this macro to index() or strchr(), whichever is supported. 717 */ 718#define STRCHR(s, c) index((s), (c)) 719 720/* 721 * Set the n_time in the client write rpc, as required. 722 */ 723#define NFSWRITERPC_SETTIME(w, n, v4) \ 724 do { \ 725 if (w) { \ 726 (n)->n_mtime = (n)->n_vattr.na_vattr.va_mtime; \ 727 if (v4) \ 728 (n)->n_change = (n)->n_vattr.na_vattr.va_filerev; \ 729 } \ 730 } while (0) 731 732/* 733 * Fake value, just to make the client work. 734 */ 735#define NFS_LATTR_NOSHRINK 1 736 737/* 738 * Prototypes for functions where the arguments vary for different ports. 739 */ 740int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, 741 int, int); 742void newnfs_realign(struct mbuf **); 743 744/* 745 * If the port runs on an SMP box that can enforce Atomic ops with low 746 * overheads, define these as atomic increments/decrements. If not, 747 * don't worry about it, since these are used for stats that can be 748 * "out by one" without disastrous consequences. 749 */ 750#define NFSINCRGLOBAL(a) ((a)++) 751 752/* 753 * Assorted funky stuff to make things work under Darwin8. 754 */ 755/* 756 * These macros checks for a field in vattr being set. 757 */ 758#define NFSATTRISSET(t, v, a) ((v)->a != (t)VNOVAL) 759#define NFSATTRISSETTIME(v, a) ((v)->a.tv_sec != VNOVAL) 760 761/* 762 * Manipulate mount flags. 763 */ 764#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier */ 765#define NFSSTA_GOTFSINFO 0x00100000 /* Got the fsinfo */ 766#define NFSSTA_TIMEO 0x10000000 /* Experiencing a timeout */ 767#define NFSSTA_LOCKTIMEO 0x20000000 /* Experiencing a lockd timeout */ 768#define NFSSTA_HASSETFSID 0x40000000 /* Has set the fsid */ 769 770#define NFSHASNFSV3(n) ((n)->nm_flag & NFSMNT_NFSV3) 771#define NFSHASNFSV4(n) ((n)->nm_flag & NFSMNT_NFSV4) 772#define NFSHASNFSV3OR4(n) ((n)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) 773#define NFSHASGOTFSINFO(n) ((n)->nm_state & NFSSTA_GOTFSINFO) 774#define NFSHASHASSETFSID(n) ((n)->nm_state & NFSSTA_HASSETFSID) 775#define NFSHASSTRICT3530(n) ((n)->nm_flag & NFSMNT_STRICT3530) 776#define NFSHASWRITEVERF(n) ((n)->nm_state & NFSSTA_HASWRITEVERF) 777#define NFSHASINT(n) ((n)->nm_flag & NFSMNT_INT) 778#define NFSHASSOFT(n) ((n)->nm_flag & NFSMNT_SOFT) 779#define NFSHASINTORSOFT(n) ((n)->nm_flag & (NFSMNT_INT | NFSMNT_SOFT)) 780#define NFSHASDUMBTIMR(n) ((n)->nm_flag & NFSMNT_DUMBTIMR) 781#define NFSHASNOCONN(n) ((n)->nm_flag & NFSMNT_MNTD) 782#define NFSHASKERB(n) ((n)->nm_flag & NFSMNT_KERB) 783#define NFSHASALLGSSNAME(n) ((n)->nm_flag & NFSMNT_ALLGSSNAME) 784#define NFSHASINTEGRITY(n) ((n)->nm_flag & NFSMNT_INTEGRITY) 785#define NFSHASPRIVACY(n) ((n)->nm_flag & NFSMNT_PRIVACY) 786#define NFSSETWRITEVERF(n) ((n)->nm_state |= NFSSTA_HASWRITEVERF) 787#define NFSSETHASSETFSID(n) ((n)->nm_state |= NFSSTA_HASSETFSID) 788#ifdef NFS4_ACL_EXTATTR_NAME 789#define NFSHASNFS4ACL(m) nfs_supportsnfsv4acls(m) 790int nfs_supportsnfsv4acls(struct mount *); 791#else 792#define NFSHASNFS4ACL(m) 0 793#endif 794 795/* 796 * Gets the stats field out of the mount structure. 797 */ 798#define vfs_statfs(m) (&((m)->mnt_stat)) 799 800/* 801 * Set boottime. 802 */ 803#define NFSSETBOOTTIME(b) ((b) = boottime) 804 805/* 806 * The size of directory blocks in the buffer cache. 807 * MUST BE in the range of PAGE_SIZE <= NFS_DIRBLKSIZ <= MAXBSIZE!! 808 */ 809#define NFS_DIRBLKSIZ (16 * DIRBLKSIZ) /* Must be a multiple of DIRBLKSIZ */ 810 811/* 812 * Define these macros to access mnt_flag fields. 813 */ 814#define NFSMNT_RDONLY(m) ((m)->mnt_flag & MNT_RDONLY) 815#endif /* _KERNEL */ 816 817/* 818 * Define a structure similar to ufs_args for use in exporting the V4 root. 819 */ 820struct nfsex_args { 821 char *fspec; 822 struct export_args export; 823}; 824 825/* 826 * These export flags should be defined, but there are no bits left. 827 * Maybe a separate mnt_exflag field could be added or the mnt_flag 828 * field increased to 64 bits? 829 */ 830#ifndef MNT_EXSTRICTACCESS 831#define MNT_EXSTRICTACCESS 0x0 832#endif 833#ifndef MNT_EXV4ONLY 834#define MNT_EXV4ONLY 0x0 835#endif 836 837#ifdef _KERNEL 838/* 839 * Define this to invalidate the attribute cache for the nfs node. 840 */ 841#define NFSINVALATTRCACHE(n) ((n)->n_attrstamp = 0) 842 843/* Used for FreeBSD only */ 844void nfsd_mntinit(void); 845 846/* 847 * Define these for vnode lock/unlock ops. 848 */ 849#define NFSVOPLOCK(v, f, p) vn_lock((v), (f)) 850#define NFSVOPUNLOCK(v, f, p) VOP_UNLOCK((v), (f)) 851#define NFSVOPISLOCKED(v, p) VOP_ISLOCKED((v)) 852 853/* 854 * Define ncl_hash(). 855 */ 856#define ncl_hash(f, l) (fnv_32_buf((f), (l), FNV1_32_INIT)) 857 858int newnfs_iosize(struct nfsmount *); 859 860#ifdef NFS_DEBUG 861 862extern int nfs_debug; 863#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 864#define NFS_DEBUG_WG 2 /* server write gathering */ 865#define NFS_DEBUG_RC 4 /* server request caching */ 866 867#define NFS_DPF(cat, args) \ 868 do { \ 869 if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 870 } while (0) 871 872#else 873 874#define NFS_DPF(cat, args) 875 876#endif 877 878int newnfs_vncmpf(struct vnode *, void *); 879 880#ifndef NFS_MINDIRATTRTIMO 881#define NFS_MINDIRATTRTIMO 3 /* VDIR attrib cache timeout in sec */ 882#endif 883#ifndef NFS_MAXDIRATTRTIMO 884#define NFS_MAXDIRATTRTIMO 60 885#endif 886 887/* 888 * Nfs outstanding request list element 889 */ 890struct nfsreq { 891 TAILQ_ENTRY(nfsreq) r_chain; 892 u_int32_t r_flags; /* flags on request, see below */ 893 struct nfsmount *r_nmp; /* Client mnt ptr */ 894 struct mtx r_mtx; /* Mutex lock for this structure */ 895}; 896 897#ifndef NFS_MAXBSIZE 898#define NFS_MAXBSIZE MAXBSIZE 899#endif 900 901/* 902 * This macro checks to see if issuing of delegations is allowed for this 903 * vnode. 904 */ 905#ifdef VV_DISABLEDELEG 906#define NFSVNO_DELEGOK(v) \ 907 ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0) 908#else 909#define NFSVNO_DELEGOK(v) (1) 910#endif 911 912/* 913 * Define this as the flags argument for msleep() when catching signals 914 * while holding a resource that other threads would block for, such as 915 * a vnode lock. 916 */ 917#define NFS_PCATCH (PCATCH | PBDRY) 918 919#endif /* _KERNEL */ 920
|