nfsport.h revision 192781
1191783Srmacklem/*- 2191783Srmacklem * Copyright (c) 1989, 1993 3191783Srmacklem * The Regents of the University of California. All rights reserved. 4191783Srmacklem * 5191783Srmacklem * This code is derived from software contributed to Berkeley by 6191783Srmacklem * Rick Macklem at The University of Guelph. 7191783Srmacklem * 8191783Srmacklem * Redistribution and use in source and binary forms, with or without 9191783Srmacklem * modification, are permitted provided that the following conditions 10191783Srmacklem * are met: 11191783Srmacklem * 1. Redistributions of source code must retain the above copyright 12191783Srmacklem * notice, this list of conditions and the following disclaimer. 13191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright 14191783Srmacklem * notice, this list of conditions and the following disclaimer in the 15191783Srmacklem * documentation and/or other materials provided with the distribution. 16191783Srmacklem * 4. Neither the name of the University nor the names of its contributors 17191783Srmacklem * may be used to endorse or promote products derived from this software 18191783Srmacklem * without specific prior written permission. 19191783Srmacklem * 20191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23191783Srmacklem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30191783Srmacklem * SUCH DAMAGE. 31191783Srmacklem * 32191783Srmacklem * $FreeBSD: head/sys/fs/nfs/nfsport.h 192781 2009-05-26 01:16:09Z rmacklem $ 33191783Srmacklem */ 34191783Srmacklem 35191783Srmacklem#ifndef _NFS_NFSPORT_H_ 36191783Srmacklem#define _NFSPORT_NFS_H_ 37191783Srmacklem 38191783Srmacklem/* 39191783Srmacklem * In general, I'm not fond of #includes in .h files, but this seems 40191783Srmacklem * to be the cleanest way to handle #include files for the ports. 41191783Srmacklem */ 42191783Srmacklem#ifdef _KERNEL 43191783Srmacklem#include <sys/unistd.h> 44191783Srmacklem#include <sys/param.h> 45191783Srmacklem#include <sys/systm.h> 46191783Srmacklem#include <sys/conf.h> 47191783Srmacklem#include <sys/dirent.h> 48191783Srmacklem#include <sys/domain.h> 49191783Srmacklem#include <sys/fcntl.h> 50191783Srmacklem#include <sys/file.h> 51191783Srmacklem#include <sys/filedesc.h> 52191783Srmacklem#include <sys/kernel.h> 53191783Srmacklem#include <sys/lockf.h> 54191783Srmacklem#include <sys/malloc.h> 55191783Srmacklem#include <sys/mbuf.h> 56191783Srmacklem#include <sys/mount.h> 57191783Srmacklem#include <sys/namei.h> 58191783Srmacklem#include <sys/proc.h> 59191783Srmacklem#include <sys/protosw.h> 60191783Srmacklem#include <sys/reboot.h> 61191783Srmacklem#include <sys/resourcevar.h> 62191783Srmacklem#include <sys/signalvar.h> 63191783Srmacklem#include <sys/socket.h> 64191783Srmacklem#include <sys/socketvar.h> 65191783Srmacklem#include <sys/stat.h> 66191783Srmacklem#include <sys/syslog.h> 67191783Srmacklem#include <sys/sysproto.h> 68191783Srmacklem#include <sys/time.h> 69191783Srmacklem#include <sys/uio.h> 70191783Srmacklem#include <sys/vnode.h> 71191783Srmacklem#include <sys/bio.h> 72191783Srmacklem#include <sys/buf.h> 73191783Srmacklem#include <sys/acl.h> 74192705Srmacklem/* until the nfsv4 acl stuff is all committed, undef NFS4_ACL_EXTATTR_NAME */ 75192705Srmacklem#undef NFS4_ACL_EXTATTR_NAME 76191783Srmacklem#include <sys/module.h> 77191783Srmacklem#include <sys/sysent.h> 78191783Srmacklem#include <sys/syscall.h> 79191783Srmacklem#include <sys/priv.h> 80191783Srmacklem#include <sys/kthread.h> 81191783Srmacklem#include <sys/syscallsubr.h> 82191783Srmacklem#include <fs/fifofs/fifo.h> 83191783Srmacklem#include <net/if.h> 84191783Srmacklem#include <net/radix.h> 85191783Srmacklem#include <net/route.h> 86191783Srmacklem#include <net/if_dl.h> 87191783Srmacklem#include <netinet/in.h> 88191783Srmacklem#include <netinet/in_pcb.h> 89191783Srmacklem#include <netinet/in_systm.h> 90191783Srmacklem#include <netinet/in_var.h> 91191783Srmacklem#include <netinet/ip.h> 92191783Srmacklem#include <netinet/ip_var.h> 93191783Srmacklem#include <netinet/tcp.h> 94191783Srmacklem#include <netinet/tcp_fsm.h> 95191783Srmacklem#include <netinet/tcp_seq.h> 96191783Srmacklem#include <netinet/tcp_timer.h> 97191783Srmacklem#include <netinet/tcp_var.h> 98191783Srmacklem#include <netinet/vinet.h> 99191783Srmacklem#include <machine/in_cksum.h> 100191783Srmacklem#include <crypto/des/des.h> 101191783Srmacklem#include <sys/md5.h> 102191783Srmacklem#include <rpc/rpc.h> 103191783Srmacklem#include <rpc/rpcsec_gss.h> 104191783Srmacklem 105191783Srmacklem/* 106191783Srmacklem * For Darwin, these functions should be "static" when built in a kext. 107191783Srmacklem * (This is always defined as nil otherwise.) 108191783Srmacklem */ 109191783Srmacklem#define APPLESTATIC 110191783Srmacklem#include <ufs/ufs/dir.h> 111191783Srmacklem#include <ufs/ufs/quota.h> 112191783Srmacklem#include <ufs/ufs/inode.h> 113191783Srmacklem#include <ufs/ufs/extattr.h> 114191783Srmacklem#include <ufs/ufs/ufsmount.h> 115191783Srmacklem#include <vm/uma.h> 116191783Srmacklem#include <vm/vm.h> 117191783Srmacklem#include <vm/vm_object.h> 118191783Srmacklem#include <vm/vm_extern.h> 119191783Srmacklem#include <nfs/nfssvc.h> 120191783Srmacklem#include "opt_nfs.h" 121191783Srmacklem#include "opt_ufs.h" 122191783Srmacklem 123191783Srmacklem/* 124191783Srmacklem * These types must be defined before the nfs includes. 125191783Srmacklem */ 126191783Srmacklem#define NFSSOCKADDR_T struct sockaddr * 127191783Srmacklem#define NFSPROC_T struct thread 128191783Srmacklem#define NFSDEV_T dev_t 129191783Srmacklem#define NFSSVCARGS nfssvc_args 130191783Srmacklem#ifdef NFS4_ACL_EXTATTR_NAME 131191783Srmacklem#define NFSACL_T struct acl 132191783Srmacklem#else 133191783Srmacklem#define NFSACL_T void 134191783Srmacklem#endif 135191783Srmacklem 136191783Srmacklem/* 137191783Srmacklem * These should be defined as the types used for the corresponding VOP's 138191783Srmacklem * argument type. 139191783Srmacklem */ 140191783Srmacklem#define NFS_ACCESS_ARGS struct vop_access_args 141191783Srmacklem#define NFS_OPEN_ARGS struct vop_open_args 142191783Srmacklem#define NFS_GETATTR_ARGS struct vop_getattr_args 143191783Srmacklem#define NFS_LOOKUP_ARGS struct vop_lookup_args 144191783Srmacklem#define NFS_READDIR_ARGS struct vop_readdir_args 145191783Srmacklem 146191783Srmacklem/* 147191783Srmacklem * Allocate mbufs. Must succeed and never set the mbuf ptr to NULL. 148191783Srmacklem */ 149191783Srmacklem#define NFSMGET(m) do { \ 150191783Srmacklem MGET((m), M_TRYWAIT, MT_DATA); \ 151191783Srmacklem while ((m) == NULL ) { \ 152191783Srmacklem (void) nfs_catnap(PZERO, "nfsmget"); \ 153191783Srmacklem MGET((m), M_TRYWAIT, MT_DATA); \ 154191783Srmacklem } \ 155191783Srmacklem } while (0) 156191783Srmacklem#define NFSMGETHDR(m) do { \ 157191783Srmacklem MGETHDR((m), M_TRYWAIT, MT_DATA); \ 158191783Srmacklem while ((m) == NULL ) { \ 159191783Srmacklem (void) nfs_catnap(PZERO, "nfsmget"); \ 160191783Srmacklem MGETHDR((m), M_TRYWAIT, MT_DATA); \ 161191783Srmacklem } \ 162191783Srmacklem } while (0) 163191783Srmacklem#define NFSMCLGET(m, w) do { \ 164191783Srmacklem MGET((m), M_TRYWAIT, MT_DATA); \ 165191783Srmacklem while ((m) == NULL ) { \ 166191783Srmacklem (void) nfs_catnap(PZERO, "nfsmget"); \ 167191783Srmacklem MGET((m), M_TRYWAIT, MT_DATA); \ 168191783Srmacklem } \ 169191783Srmacklem MCLGET((m), (w)); \ 170191783Srmacklem } while (0) 171191783Srmacklem#define NFSMCLGETHDR(m, w) do { \ 172191783Srmacklem MGETHDR((m), M_TRYWAIT, MT_DATA); \ 173191783Srmacklem while ((m) == NULL ) { \ 174191783Srmacklem (void) nfs_catnap(PZERO, "nfsmget"); \ 175191783Srmacklem MGETHDR((m), M_TRYWAIT, MT_DATA); \ 176191783Srmacklem } \ 177191783Srmacklem } while (0) 178191783Srmacklem#define NFSMTOD mtod 179191783Srmacklem 180191783Srmacklem/* 181191783Srmacklem * Client side constant for size of a lockowner name. 182191783Srmacklem */ 183191783Srmacklem#define NFSV4CL_LOCKNAMELEN 12 184191783Srmacklem 185191783Srmacklem/* 186191783Srmacklem * Type for a mutex lock. 187191783Srmacklem */ 188191783Srmacklem#define NFSMUTEX_T struct mtx 189191783Srmacklem 190192152Srmacklem#endif /* _KERNEL */ 191192152Srmacklem 192192152Srmacklem/* 193192152Srmacklem * NFSv4 Operation numbers. 194192152Srmacklem */ 195192152Srmacklem#define NFSV4OP_ACCESS 3 196192152Srmacklem#define NFSV4OP_CLOSE 4 197192152Srmacklem#define NFSV4OP_COMMIT 5 198192152Srmacklem#define NFSV4OP_CREATE 6 199192152Srmacklem#define NFSV4OP_DELEGPURGE 7 200192152Srmacklem#define NFSV4OP_DELEGRETURN 8 201192152Srmacklem#define NFSV4OP_GETATTR 9 202192152Srmacklem#define NFSV4OP_GETFH 10 203192152Srmacklem#define NFSV4OP_LINK 11 204192152Srmacklem#define NFSV4OP_LOCK 12 205192152Srmacklem#define NFSV4OP_LOCKT 13 206192152Srmacklem#define NFSV4OP_LOCKU 14 207192152Srmacklem#define NFSV4OP_LOOKUP 15 208192152Srmacklem#define NFSV4OP_LOOKUPP 16 209192152Srmacklem#define NFSV4OP_NVERIFY 17 210192152Srmacklem#define NFSV4OP_OPEN 18 211192152Srmacklem#define NFSV4OP_OPENATTR 19 212192152Srmacklem#define NFSV4OP_OPENCONFIRM 20 213192152Srmacklem#define NFSV4OP_OPENDOWNGRADE 21 214192152Srmacklem#define NFSV4OP_PUTFH 22 215192152Srmacklem#define NFSV4OP_PUTPUBFH 23 216192152Srmacklem#define NFSV4OP_PUTROOTFH 24 217192152Srmacklem#define NFSV4OP_READ 25 218192152Srmacklem#define NFSV4OP_READDIR 26 219192152Srmacklem#define NFSV4OP_READLINK 27 220192152Srmacklem#define NFSV4OP_REMOVE 28 221192152Srmacklem#define NFSV4OP_RENAME 29 222192152Srmacklem#define NFSV4OP_RENEW 30 223192152Srmacklem#define NFSV4OP_RESTOREFH 31 224192152Srmacklem#define NFSV4OP_SAVEFH 32 225192152Srmacklem#define NFSV4OP_SECINFO 33 226192152Srmacklem#define NFSV4OP_SETATTR 34 227192152Srmacklem#define NFSV4OP_SETCLIENTID 35 228192152Srmacklem#define NFSV4OP_SETCLIENTIDCFRM 36 229192152Srmacklem#define NFSV4OP_VERIFY 37 230192152Srmacklem#define NFSV4OP_WRITE 38 231192152Srmacklem#define NFSV4OP_RELEASELCKOWN 39 232192152Srmacklem 233192152Srmacklem/* 234192152Srmacklem * Must be one greater than the last Operation#. 235192152Srmacklem */ 236192152Srmacklem#define NFSV4OP_NOPS 40 237192152Srmacklem 238192781Srmacklem/* Quirky case if the illegal op code */ 239192781Srmacklem#define NFSV4OP_OPILLEGAL 10044 240192781Srmacklem 241192152Srmacklem/* 242192152Srmacklem * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. 243192152Srmacklem */ 244192152Srmacklem#define NFSV4OP_SYMLINK (NFSV4OP_NOPS) 245192152Srmacklem#define NFSV4OP_MKDIR (NFSV4OP_NOPS + 1) 246192152Srmacklem#define NFSV4OP_RMDIR (NFSV4OP_NOPS + 2) 247192152Srmacklem#define NFSV4OP_READDIRPLUS (NFSV4OP_NOPS + 3) 248192152Srmacklem#define NFSV4OP_MKNOD (NFSV4OP_NOPS + 4) 249192152Srmacklem#define NFSV4OP_FSSTAT (NFSV4OP_NOPS + 5) 250192152Srmacklem#define NFSV4OP_FSINFO (NFSV4OP_NOPS + 6) 251192152Srmacklem#define NFSV4OP_PATHCONF (NFSV4OP_NOPS + 7) 252192152Srmacklem#define NFSV4OP_V3CREATE (NFSV4OP_NOPS + 8) 253192152Srmacklem 254192152Srmacklem/* 255192152Srmacklem * This is the count of the fake operations listed above. 256192152Srmacklem */ 257192152Srmacklem#define NFSV4OP_FAKENOPS 9 258192152Srmacklem 259192152Srmacklem/* 260192152Srmacklem * and the Callback OPs 261192152Srmacklem */ 262192152Srmacklem#define NFSV4OP_CBGETATTR 3 263192152Srmacklem#define NFSV4OP_CBRECALL 4 264192152Srmacklem 265192152Srmacklem/* 266192152Srmacklem * Must be one greater than the last Callback Operation#. 267192152Srmacklem */ 268192152Srmacklem#define NFSV4OP_CBNOPS 5 269192152Srmacklem 270192152Srmacklem/* 271192152Srmacklem * The lower numbers -> 21 are used by NFSv2 and v3. These define higher 272192152Srmacklem * numbers used by NFSv4. 273192152Srmacklem * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 274192152Srmacklem * one greater than the last number. 275192152Srmacklem */ 276192152Srmacklem#define NFS_V3NPROCS 22 277192152Srmacklem 278192152Srmacklem#define NFSPROC_LOOKUPP 22 279192152Srmacklem#define NFSPROC_SETCLIENTID 23 280192152Srmacklem#define NFSPROC_SETCLIENTIDCFRM 24 281192152Srmacklem#define NFSPROC_LOCK 25 282192152Srmacklem#define NFSPROC_LOCKU 26 283192152Srmacklem#define NFSPROC_OPEN 27 284192152Srmacklem#define NFSPROC_CLOSE 28 285192152Srmacklem#define NFSPROC_OPENCONFIRM 29 286192152Srmacklem#define NFSPROC_LOCKT 30 287192152Srmacklem#define NFSPROC_OPENDOWNGRADE 31 288192152Srmacklem#define NFSPROC_RENEW 32 289192152Srmacklem#define NFSPROC_PUTROOTFH 33 290192152Srmacklem#define NFSPROC_RELEASELCKOWN 34 291192152Srmacklem#define NFSPROC_DELEGRETURN 35 292192152Srmacklem#define NFSPROC_RETDELEGREMOVE 36 293192152Srmacklem#define NFSPROC_RETDELEGRENAME1 37 294192152Srmacklem#define NFSPROC_RETDELEGRENAME2 38 295192152Srmacklem#define NFSPROC_GETACL 39 296192152Srmacklem#define NFSPROC_SETACL 40 297192152Srmacklem 298192152Srmacklem/* 299192152Srmacklem * Must be defined as one higher than the last Proc# above. 300192152Srmacklem */ 301192152Srmacklem#define NFSV4_NPROCS 41 302192152Srmacklem 303192152Srmacklem/* 304192152Srmacklem * Stats structure 305192152Srmacklem */ 306192152Srmacklemstruct ext_nfsstats { 307192152Srmacklem int attrcache_hits; 308192152Srmacklem int attrcache_misses; 309192152Srmacklem int lookupcache_hits; 310192152Srmacklem int lookupcache_misses; 311192152Srmacklem int direofcache_hits; 312192152Srmacklem int direofcache_misses; 313192152Srmacklem int accesscache_hits; 314192152Srmacklem int accesscache_misses; 315192152Srmacklem int biocache_reads; 316192152Srmacklem int read_bios; 317192152Srmacklem int read_physios; 318192152Srmacklem int biocache_writes; 319192152Srmacklem int write_bios; 320192152Srmacklem int write_physios; 321192152Srmacklem int biocache_readlinks; 322192152Srmacklem int readlink_bios; 323192152Srmacklem int biocache_readdirs; 324192152Srmacklem int readdir_bios; 325192152Srmacklem int rpccnt[NFSV4_NPROCS]; 326192152Srmacklem int rpcretries; 327192152Srmacklem int srvrpccnt[NFSV4OP_NOPS + NFSV4OP_FAKENOPS]; 328192152Srmacklem int srvrpc_errs; 329192152Srmacklem int srv_errs; 330192152Srmacklem int rpcrequests; 331192152Srmacklem int rpctimeouts; 332192152Srmacklem int rpcunexpected; 333192152Srmacklem int rpcinvalid; 334192152Srmacklem int srvcache_inproghits; 335192152Srmacklem int srvcache_idemdonehits; 336192152Srmacklem int srvcache_nonidemdonehits; 337192152Srmacklem int srvcache_misses; 338192152Srmacklem int srvcache_tcppeak; 339192152Srmacklem int srvcache_size; 340192152Srmacklem int srvclients; 341192152Srmacklem int srvopenowners; 342192152Srmacklem int srvopens; 343192152Srmacklem int srvlockowners; 344192152Srmacklem int srvlocks; 345192152Srmacklem int srvdelegates; 346192152Srmacklem int cbrpccnt[NFSV4OP_CBNOPS]; 347192152Srmacklem int clopenowners; 348192152Srmacklem int clopens; 349192152Srmacklem int cllockowners; 350192152Srmacklem int cllocks; 351192152Srmacklem int cldelegates; 352192152Srmacklem int cllocalopenowners; 353192152Srmacklem int cllocalopens; 354192152Srmacklem int cllocallockowners; 355192152Srmacklem int cllocallocks; 356192152Srmacklem}; 357192152Srmacklem 358192152Srmacklem#ifdef _KERNEL 359192152Srmacklem/* 360192152Srmacklem * Define the ext_nfsstats as nfsstats for the kernel code. 361192152Srmacklem */ 362192152Srmacklem#define nfsstats ext_nfsstats 363192152Srmacklem 364192152Srmacklem/* 365192152Srmacklem * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. 366192152Srmacklem */ 367192152Srmacklem#define NFS_NPROCS NFSV4_NPROCS 368192152Srmacklem 369191783Srmacklem#include <fs/nfs/nfskpiport.h> 370191783Srmacklem#include <fs/nfs/nfsdport.h> 371191783Srmacklem#include <fs/nfs/rpcv2.h> 372191783Srmacklem#include <fs/nfs/nfsproto.h> 373191783Srmacklem#include <fs/nfs/nfs.h> 374191783Srmacklem#include <fs/nfs/nfs_var.h> 375191783Srmacklem#include <fs/nfs/nfsm_subs.h> 376191783Srmacklem#include <fs/nfs/nfsrvcache.h> 377191783Srmacklem#include <fs/nfs/nfsrvstate.h> 378191783Srmacklem#include <fs/nfs/xdr_subs.h> 379191783Srmacklem#include <fs/nfs/nfscl.h> 380191783Srmacklem#include <fs/nfs/nfsclstate.h> 381191783Srmacklem#include <fs/nfsclient/nfsargs.h> 382191783Srmacklem#include <fs/nfsclient/nfsmount.h> 383191783Srmacklem 384191783Srmacklem/* 385191783Srmacklem * Just to keep nfs_var.h happy. 386191783Srmacklem */ 387191783Srmacklemstruct nfs_vattr { 388191783Srmacklem int junk; 389191783Srmacklem}; 390191783Srmacklem 391191783Srmacklemstruct nfsvattr { 392191783Srmacklem struct vattr na_vattr; 393191783Srmacklem nfsattrbit_t na_suppattr; 394191783Srmacklem u_int32_t na_mntonfileno; 395191783Srmacklem u_int64_t na_filesid[2]; 396191783Srmacklem}; 397191783Srmacklem 398191783Srmacklem#define na_type na_vattr.va_type 399191783Srmacklem#define na_mode na_vattr.va_mode 400191783Srmacklem#define na_nlink na_vattr.va_nlink 401191783Srmacklem#define na_uid na_vattr.va_uid 402191783Srmacklem#define na_gid na_vattr.va_gid 403191783Srmacklem#define na_fsid na_vattr.va_fsid 404191783Srmacklem#define na_fileid na_vattr.va_fileid 405191783Srmacklem#define na_size na_vattr.va_size 406191783Srmacklem#define na_blocksize na_vattr.va_blocksize 407191783Srmacklem#define na_atime na_vattr.va_atime 408191783Srmacklem#define na_mtime na_vattr.va_mtime 409191783Srmacklem#define na_ctime na_vattr.va_ctime 410191783Srmacklem#define na_gen na_vattr.va_gen 411191783Srmacklem#define na_flags na_vattr.va_flags 412191783Srmacklem#define na_rdev na_vattr.va_rdev 413191783Srmacklem#define na_bytes na_vattr.va_bytes 414191783Srmacklem#define na_filerev na_vattr.va_filerev 415191783Srmacklem#define na_vaflags na_vattr.va_vaflags 416191783Srmacklem 417191783Srmacklem#include <fs/nfsclient/nfsnode.h> 418191783Srmacklem 419191783Srmacklem/* 420191783Srmacklem * This is the header structure used for the lists, etc. (It has the 421191783Srmacklem * above record in it. 422191783Srmacklem */ 423191783Srmacklemstruct nfsrv_stablefirst { 424191783Srmacklem LIST_HEAD(, nfsrv_stable) nsf_head; /* Head of nfsrv_stable list */ 425191783Srmacklem time_t nsf_eograce; /* Time grace period ends */ 426191783Srmacklem time_t *nsf_bootvals; /* Previous boottime values */ 427191783Srmacklem struct file *nsf_fp; /* File table pointer */ 428191783Srmacklem u_char nsf_flags; /* NFSNSF_ flags */ 429191783Srmacklem struct nfsf_rec nsf_rec; /* and above first record */ 430191783Srmacklem}; 431191783Srmacklem#define nsf_lease nsf_rec.lease 432191783Srmacklem#define nsf_numboots nsf_rec.numboots 433191783Srmacklem 434191783Srmacklem/* NFSNSF_xxx flags */ 435191783Srmacklem#define NFSNSF_UPDATEDONE 0x01 436191783Srmacklem#define NFSNSF_GRACEOVER 0x02 437191783Srmacklem#define NFSNSF_NEEDLOCK 0x04 438191783Srmacklem#define NFSNSF_EXPIREDCLIENT 0x08 439191783Srmacklem#define NFSNSF_NOOPENS 0x10 440191783Srmacklem#define NFSNSF_OK 0x20 441191783Srmacklem 442191783Srmacklem/* 443191783Srmacklem * Maximum number of boot times allowed in record. Although there is 444191783Srmacklem * really no need for a fixed upper bound, this serves as a sanity check 445191783Srmacklem * for a corrupted file. 446191783Srmacklem */ 447191783Srmacklem#define NFSNSF_MAXNUMBOOTS 10000 448191783Srmacklem 449191783Srmacklem/* 450191783Srmacklem * This structure defines the other records in the file. The 451191783Srmacklem * nst_client array is actually the size of the client string name. 452191783Srmacklem */ 453191783Srmacklemstruct nfst_rec { 454191783Srmacklem u_int16_t len; 455191783Srmacklem u_char flag; 456191783Srmacklem u_char client[1]; 457191783Srmacklem}; 458191783Srmacklem/* and the values for flag */ 459191783Srmacklem#define NFSNST_NEWSTATE 0x1 460191783Srmacklem#define NFSNST_REVOKE 0x2 461191783Srmacklem#define NFSNST_GOTSTATE 0x4 462191783Srmacklem 463191783Srmacklem/* 464191783Srmacklem * This structure is linked onto nfsrv_stablefirst for the duration of 465191783Srmacklem * reclaim. 466191783Srmacklem */ 467191783Srmacklemstruct nfsrv_stable { 468191783Srmacklem LIST_ENTRY(nfsrv_stable) nst_list; 469191783Srmacklem struct nfsclient *nst_clp; 470191783Srmacklem struct nfst_rec nst_rec; 471191783Srmacklem}; 472191783Srmacklem#define nst_timestamp nst_rec.timestamp 473191783Srmacklem#define nst_len nst_rec.len 474191783Srmacklem#define nst_flag nst_rec.flag 475191783Srmacklem#define nst_client nst_rec.client 476191783Srmacklem 477191783Srmacklem/* 478191783Srmacklem * At some point the server will run out of kernel storage for 479191783Srmacklem * state structures. For FreeBSD5.2, this results in a panic 480191783Srmacklem * kmem_map is full. It happens at well over 1000000 opens plus 481191783Srmacklem * locks on a PIII-800 with 256Mbytes, so that is where I've set 482191783Srmacklem * the limit. If your server panics due to too many opens/locks, 483191783Srmacklem * decrease the size of NFSRV_V4STATELIMIT. If you find the server 484191783Srmacklem * returning NFS4ERR_RESOURCE a lot and have lots of memory, try 485191783Srmacklem * increasing it. 486191783Srmacklem */ 487191783Srmacklem#define NFSRV_V4STATELIMIT 500000 /* Max # of Opens + Locks */ 488191783Srmacklem 489191783Srmacklem/* 490191783Srmacklem * The type required differs with BSDen (just the second arg). 491191783Srmacklem */ 492191783Srmacklemvoid nfsrvd_rcv(struct socket *, void *, int); 493191783Srmacklem 494191783Srmacklem/* 495191783Srmacklem * Macros for handling socket addresses. (Hopefully this makes the code 496191783Srmacklem * more portable, since I've noticed some 'BSD don't have sockaddrs in 497191783Srmacklem * mbufs any more.) 498191783Srmacklem */ 499191783Srmacklem#define NFSSOCKADDR(a, t) ((t)(a)) 500191783Srmacklem#define NFSSOCKADDRALLOC(a) \ 501191783Srmacklem do { \ 502191783Srmacklem MALLOC((a), struct sockaddr *, sizeof (struct sockaddr), \ 503191783Srmacklem M_SONAME, M_WAITOK); \ 504191783Srmacklem NFSBZERO((a), sizeof (struct sockaddr)); \ 505191783Srmacklem } while (0) 506191783Srmacklem#define NFSSOCKADDRSIZE(a, s) ((a)->sa_len = (s)) 507191783Srmacklem#define NFSSOCKADDRFREE(a) \ 508191783Srmacklem do { \ 509191783Srmacklem if (a) \ 510191783Srmacklem FREE((caddr_t)(a), M_SONAME); \ 511191783Srmacklem } while (0) 512191783Srmacklem 513191783Srmacklem/* 514191783Srmacklem * These should be defined as a process or thread structure, as required 515191783Srmacklem * for signal handling, etc. 516191783Srmacklem */ 517191783Srmacklem#define NFSNEWCRED(c) (crdup(c)) 518191783Srmacklem#define NFSPROCCRED(p) ((p)->td_ucred) 519191783Srmacklem#define NFSFREECRED(c) (crfree(c)) 520191783Srmacklem#define NFSUIOPROC(u, p) ((u)->uio_td = NULL) 521191783Srmacklem#define NFSPROCP(p) ((p)->td_proc) 522191783Srmacklem 523191783Srmacklem/* 524191783Srmacklem * Define these so that cn_hash and its length is ignored. 525191783Srmacklem */ 526191783Srmacklem#define NFSCNHASHZERO(c) 527191783Srmacklem#define NFSCNHASH(c, v) 528191783Srmacklem#define NCHNAMLEN 9999999 529191783Srmacklem 530191783Srmacklem/* 531191783Srmacklem * Define these to use the time of day clock. 532191783Srmacklem */ 533191783Srmacklem#define NFSGETTIME(t) (getmicrotime(t)) 534191783Srmacklem#define NFSGETNANOTIME(t) (getnanotime(t)) 535191783Srmacklem 536191783Srmacklem/* 537191783Srmacklem * These macros are defined to initialize and set the timer routine. 538191783Srmacklem */ 539191783Srmacklem#define NFS_TIMERINIT \ 540191783Srmacklem newnfs_timer(NULL) 541191783Srmacklem 542191783Srmacklem/* 543191783Srmacklem * Handle SMP stuff: 544191783Srmacklem */ 545191783Srmacklem#define NFSSTATESPINLOCK extern struct mtx nfs_state_mutex 546191783Srmacklem#define NFSLOCKSTATE() mtx_lock(&nfs_state_mutex) 547191783Srmacklem#define NFSUNLOCKSTATE() mtx_unlock(&nfs_state_mutex) 548191783Srmacklem#define NFSREQSPINLOCK extern struct mtx nfs_req_mutex 549191783Srmacklem#define NFSLOCKREQ() mtx_lock(&nfs_req_mutex) 550191783Srmacklem#define NFSUNLOCKREQ() mtx_unlock(&nfs_req_mutex) 551191783Srmacklem#define NFSCACHEMUTEX extern struct mtx nfs_cache_mutex 552191783Srmacklem#define NFSCACHEMUTEXPTR (&nfs_cache_mutex) 553191783Srmacklem#define NFSLOCKCACHE() mtx_lock(&nfs_cache_mutex) 554191783Srmacklem#define NFSUNLOCKCACHE() mtx_unlock(&nfs_cache_mutex) 555191783Srmacklem#define NFSCACHELOCKREQUIRED() mtx_assert(&nfs_cache_mutex, MA_OWNED) 556191783Srmacklem#define NFSSOCKMUTEX extern struct mtx nfs_slock_mutex 557191783Srmacklem#define NFSSOCKMUTEXPTR (&nfs_slock_mutex) 558191783Srmacklem#define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) 559191783Srmacklem#define NFSUNLOCKSOCK() mtx_unlock(&nfs_slock_mutex) 560191783Srmacklem#define NFSNAMEIDMUTEX extern struct mtx nfs_nameid_mutex 561191783Srmacklem#define NFSLOCKNAMEID() mtx_lock(&nfs_nameid_mutex) 562191783Srmacklem#define NFSUNLOCKNAMEID() mtx_unlock(&nfs_nameid_mutex) 563191783Srmacklem#define NFSNAMEIDREQUIRED() mtx_assert(&nfs_nameid_mutex, MA_OWNED) 564191783Srmacklem#define NFSCLSTATEMUTEX extern struct mtx nfs_clstate_mutex 565191783Srmacklem#define NFSCLSTATEMUTEXPTR (&nfs_clstate_mutex) 566191783Srmacklem#define NFSLOCKCLSTATE() mtx_lock(&nfs_clstate_mutex) 567191783Srmacklem#define NFSUNLOCKCLSTATE() mtx_unlock(&nfs_clstate_mutex) 568191783Srmacklem#define NFSDLOCKMUTEX extern struct mtx newnfsd_mtx 569191783Srmacklem#define NFSDLOCKMUTEXPTR (&newnfsd_mtx) 570191783Srmacklem#define NFSD_LOCK() mtx_lock(&newnfsd_mtx) 571191783Srmacklem#define NFSD_UNLOCK() mtx_unlock(&newnfsd_mtx) 572191783Srmacklem#define NFSD_LOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_OWNED) 573191783Srmacklem#define NFSD_UNLOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_NOTOWNED) 574191783Srmacklem#define NFSV4ROOTLOCKMUTEX extern struct mtx nfs_v4root_mutex 575191783Srmacklem#define NFSV4ROOTLOCKMUTEXPTR (&nfs_v4root_mutex) 576191783Srmacklem#define NFSLOCKV4ROOTMUTEX() mtx_lock(&nfs_v4root_mutex) 577191783Srmacklem#define NFSUNLOCKV4ROOTMUTEX() mtx_unlock(&nfs_v4root_mutex) 578191783Srmacklem#define NFSLOCKNODE(n) mtx_lock(&((n)->n_mtx)) 579191783Srmacklem#define NFSUNLOCKNODE(n) mtx_unlock(&((n)->n_mtx)) 580191783Srmacklem#define NFSLOCKMNT(m) mtx_lock(&((m)->nm_mtx)) 581191783Srmacklem#define NFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx)) 582191783Srmacklem#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) 583191783Srmacklem#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) 584191783Srmacklem#define NFSPROCLISTLOCK() sx_slock(&allproc_lock) 585191783Srmacklem#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock) 586191783Srmacklem#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) 587191783Srmacklem#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx)) 588191783Srmacklem 589191783Srmacklem/* 590191783Srmacklem * Use these macros to initialize/free a mutex. 591191783Srmacklem */ 592191783Srmacklem#define NFSINITSOCKMUTEX(m) mtx_init((m), "nfssock", NULL, MTX_DEF) 593191783Srmacklem#define NFSFREEMUTEX(m) mtx_destroy((m)) 594191783Srmacklem 595191783Srmacklemint nfsmsleep(void *, void *, int, const char *, struct timespec *); 596191783Srmacklem 597191783Srmacklem/* 598191783Srmacklem * And weird vm stuff in the nfs server. 599191783Srmacklem */ 600191783Srmacklem#define PDIRUNLOCK 0x0 601191783Srmacklem#define MAX_COMMIT_COUNT (1024 * 1024) 602191783Srmacklem 603191783Srmacklem/* 604191783Srmacklem * These macros are called at the start and end of operations that 605191783Srmacklem * might modify the underlying file system. 606191783Srmacklem */ 607191783Srmacklem#define NFS_STARTWRITE(v, m) vn_start_write((v), (m), V_WAIT) 608191783Srmacklem#define NFS_ENDWRITE(m) vn_finished_write(m) 609191783Srmacklem 610191783Srmacklem/* 611191783Srmacklem * Define these to handle the type of va_rdev. 612191783Srmacklem */ 613191783Srmacklem#define NFSMAKEDEV(m, n) makedev((m), (n)) 614191783Srmacklem#define NFSMAJOR(d) major(d) 615191783Srmacklem#define NFSMINOR(d) minor(d) 616191783Srmacklem 617191783Srmacklem/* 618191783Srmacklem * Define this to be the macro that returns the minimum size required 619191783Srmacklem * for a directory entry. 620191783Srmacklem */ 621191783Srmacklem#define DIRENT_SIZE(dp) GENERIC_DIRSIZ(dp) 622191783Srmacklem 623191783Srmacklem/* 624191783Srmacklem * The vnode tag for nfsv4root. 625191783Srmacklem */ 626191783Srmacklem#define VT_NFSV4ROOT "nfsv4root" 627191783Srmacklem 628191783Srmacklem/* 629191783Srmacklem * Define whatever it takes to do a vn_rdwr(). 630191783Srmacklem */ 631191783Srmacklem#define NFSD_RDWR(r, v, b, l, o, s, i, c, a, p) \ 632191783Srmacklem vn_rdwr((r), (v), (b), (l), (o), (s), (i), (c), NULL, (int *)(a), (p)) 633191783Srmacklem 634191783Srmacklem/* 635191783Srmacklem * Macros for handling memory for different BSDen. 636191783Srmacklem * NFSBCOPY(src, dst, len) - copies len bytes, non-overlapping 637191783Srmacklem * NFSOVBCOPY(src, dst, len) - ditto, but data areas might overlap 638191783Srmacklem * NFSBCMP(cp1, cp2, len) - compare len bytes, return 0 if same 639191783Srmacklem * NFSBZERO(cp, len) - set len bytes to 0x0 640191783Srmacklem */ 641191783Srmacklem#define NFSBCOPY(s, d, l) bcopy((s), (d), (l)) 642191783Srmacklem#define NFSOVBCOPY(s, d, l) ovbcopy((s), (d), (l)) 643191783Srmacklem#define NFSBCMP(s, d, l) bcmp((s), (d), (l)) 644191783Srmacklem#define NFSBZERO(s, l) bzero((s), (l)) 645191783Srmacklem 646191783Srmacklem/* 647191783Srmacklem * Some queue.h files don't have these dfined in them. 648191783Srmacklem */ 649191783Srmacklem#define LIST_END(head) NULL 650191783Srmacklem#define SLIST_END(head) NULL 651191783Srmacklem#define TAILQ_END(head) NULL 652191783Srmacklem 653191783Srmacklem/* 654191783Srmacklem * This must be defined to be a global variable the increments once 655191783Srmacklem * per second, but never stops or goes backwards, even when a "date" 656191783Srmacklem * command changes the tod clock. It is used for delta times for 657191783Srmacklem * leases, etc. 658191783Srmacklem */ 659191783Srmacklem#define NFSD_MONOSEC time_uptime 660191783Srmacklem 661191783Srmacklem/* 662191783Srmacklem * Declare the malloc types. 663191783Srmacklem */ 664191783SrmacklemMALLOC_DECLARE(M_NEWNFSRVCACHE); 665191783SrmacklemMALLOC_DECLARE(M_NEWNFSDCLIENT); 666191783SrmacklemMALLOC_DECLARE(M_NEWNFSDSTATE); 667191783SrmacklemMALLOC_DECLARE(M_NEWNFSDLOCK); 668191783SrmacklemMALLOC_DECLARE(M_NEWNFSDLOCKFILE); 669191783SrmacklemMALLOC_DECLARE(M_NEWNFSSTRING); 670191783SrmacklemMALLOC_DECLARE(M_NEWNFSUSERGROUP); 671191783SrmacklemMALLOC_DECLARE(M_NEWNFSDREQ); 672191783SrmacklemMALLOC_DECLARE(M_NEWNFSFH); 673191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLOWNER); 674191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLOPEN); 675191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLDELEG); 676191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLCLIENT); 677191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLLOCKOWNER); 678191783SrmacklemMALLOC_DECLARE(M_NEWNFSCLLOCK); 679191783SrmacklemMALLOC_DECLARE(M_NEWNFSDIROFF); 680191783SrmacklemMALLOC_DECLARE(M_NEWNFSV4NODE); 681191783SrmacklemMALLOC_DECLARE(M_NEWNFSDIRECTIO); 682191783SrmacklemMALLOC_DECLARE(M_NEWNFSMNT); 683191783Srmacklem#define M_NFSRVCACHE M_NEWNFSRVCACHE 684191783Srmacklem#define M_NFSDCLIENT M_NEWNFSDCLIENT 685191783Srmacklem#define M_NFSDSTATE M_NEWNFSDSTATE 686191783Srmacklem#define M_NFSDLOCK M_NEWNFSDLOCK 687191783Srmacklem#define M_NFSDLOCKFILE M_NEWNFSDLOCKFILE 688191783Srmacklem#define M_NFSSTRING M_NEWNFSSTRING 689191783Srmacklem#define M_NFSUSERGROUP M_NEWNFSUSERGROUP 690191783Srmacklem#define M_NFSDREQ M_NEWNFSDREQ 691191783Srmacklem#define M_NFSFH M_NEWNFSFH 692191783Srmacklem#define M_NFSCLOWNER M_NEWNFSCLOWNER 693191783Srmacklem#define M_NFSCLOPEN M_NEWNFSCLOPEN 694191783Srmacklem#define M_NFSCLDELEG M_NEWNFSCLDELEG 695191783Srmacklem#define M_NFSCLCLIENT M_NEWNFSCLCLIENT 696191783Srmacklem#define M_NFSCLLOCKOWNER M_NEWNFSCLLOCKOWNER 697191783Srmacklem#define M_NFSCLLOCK M_NEWNFSCLLOCK 698191783Srmacklem#define M_NFSDIROFF M_NEWNFSDIROFF 699191783Srmacklem#define M_NFSV4NODE M_NEWNFSV4NODE 700191783Srmacklem#define M_NFSDIRECTIO M_NEWNFSDIRECTIO 701191783Srmacklem 702191783Srmacklem#define NFSINT_SIGMASK(set) \ 703191783Srmacklem (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 704191783Srmacklem SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 705191783Srmacklem SIGISMEMBER(set, SIGQUIT)) 706191783Srmacklem 707191783Srmacklem/* 708191783Srmacklem * Convert a quota block count to byte count. 709191783Srmacklem */ 710191783Srmacklem#define NFSQUOTABLKTOBYTE(q, b) (q) *= (b) 711191783Srmacklem 712191783Srmacklem/* 713191783Srmacklem * Define this as the largest file size supported. (It should probably 714191783Srmacklem * be available via a VFS_xxx Op, but it isn't. 715191783Srmacklem */ 716191783Srmacklem#define NFSRV_MAXFILESIZE ((u_int64_t)0x800000000000) 717191783Srmacklem 718191783Srmacklem/* 719191783Srmacklem * Set this macro to index() or strchr(), whichever is supported. 720191783Srmacklem */ 721191783Srmacklem#define STRCHR(s, c) index((s), (c)) 722191783Srmacklem 723191783Srmacklem/* 724191783Srmacklem * Set the n_time in the client write rpc, as required. 725191783Srmacklem */ 726191783Srmacklem#define NFSWRITERPC_SETTIME(w, n, v4) \ 727191783Srmacklem do { \ 728191783Srmacklem if (w) { \ 729191783Srmacklem (n)->n_mtime = (n)->n_vattr.na_vattr.va_mtime; \ 730191783Srmacklem if (v4) \ 731191783Srmacklem (n)->n_change = (n)->n_vattr.na_vattr.va_filerev; \ 732191783Srmacklem } \ 733191783Srmacklem } while (0) 734191783Srmacklem 735191783Srmacklem/* 736191783Srmacklem * Fake value, just to make the client work. 737191783Srmacklem */ 738191783Srmacklem#define NFS_LATTR_NOSHRINK 1 739191783Srmacklem 740191783Srmacklem/* 741191783Srmacklem * Prototypes for functions where the arguments vary for different ports. 742191783Srmacklem */ 743191783Srmacklemint nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, 744191783Srmacklem int, int); 745191783Srmacklemvoid newnfs_realign(struct mbuf **); 746191783Srmacklem 747191783Srmacklem/* 748191783Srmacklem * If the port runs on an SMP box that can enforce Atomic ops with low 749191783Srmacklem * overheads, define these as atomic increments/decrements. If not, 750191783Srmacklem * don't worry about it, since these are used for stats that can be 751191783Srmacklem * "out by one" without disastrous consequences. 752191783Srmacklem */ 753191783Srmacklem#define NFSINCRGLOBAL(a) ((a)++) 754191783Srmacklem 755191783Srmacklem/* 756191783Srmacklem * Assorted funky stuff to make things work under Darwin8. 757191783Srmacklem */ 758191783Srmacklem/* 759191783Srmacklem * These macros checks for a field in vattr being set. 760191783Srmacklem */ 761191783Srmacklem#define NFSATTRISSET(t, v, a) ((v)->a != (t)VNOVAL) 762191783Srmacklem#define NFSATTRISSETTIME(v, a) ((v)->a.tv_sec != VNOVAL) 763191783Srmacklem 764191783Srmacklem/* 765191783Srmacklem * Manipulate mount flags. 766191783Srmacklem */ 767191783Srmacklem#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier */ 768191783Srmacklem#define NFSSTA_GOTFSINFO 0x00100000 /* Got the fsinfo */ 769191783Srmacklem#define NFSSTA_TIMEO 0x10000000 /* Experiencing a timeout */ 770191783Srmacklem#define NFSSTA_LOCKTIMEO 0x20000000 /* Experiencing a lockd timeout */ 771191783Srmacklem#define NFSSTA_HASSETFSID 0x40000000 /* Has set the fsid */ 772191783Srmacklem 773191783Srmacklem#define NFSHASNFSV3(n) ((n)->nm_flag & NFSMNT_NFSV3) 774191783Srmacklem#define NFSHASNFSV4(n) ((n)->nm_flag & NFSMNT_NFSV4) 775191783Srmacklem#define NFSHASNFSV3OR4(n) ((n)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) 776191783Srmacklem#define NFSHASGOTFSINFO(n) ((n)->nm_state & NFSSTA_GOTFSINFO) 777191783Srmacklem#define NFSHASHASSETFSID(n) ((n)->nm_state & NFSSTA_HASSETFSID) 778191783Srmacklem#define NFSHASSTRICT3530(n) ((n)->nm_flag & NFSMNT_STRICT3530) 779191783Srmacklem#define NFSHASWRITEVERF(n) ((n)->nm_state & NFSSTA_HASWRITEVERF) 780191783Srmacklem#define NFSHASINT(n) ((n)->nm_flag & NFSMNT_INT) 781191783Srmacklem#define NFSHASSOFT(n) ((n)->nm_flag & NFSMNT_SOFT) 782191783Srmacklem#define NFSHASINTORSOFT(n) ((n)->nm_flag & (NFSMNT_INT | NFSMNT_SOFT)) 783191783Srmacklem#define NFSHASDUMBTIMR(n) ((n)->nm_flag & NFSMNT_DUMBTIMR) 784191783Srmacklem#define NFSHASNOCONN(n) ((n)->nm_flag & NFSMNT_MNTD) 785191783Srmacklem#define NFSHASKERB(n) ((n)->nm_flag & NFSMNT_KERB) 786191783Srmacklem#define NFSHASALLGSSNAME(n) ((n)->nm_flag & NFSMNT_ALLGSSNAME) 787191783Srmacklem#define NFSHASINTEGRITY(n) ((n)->nm_flag & NFSMNT_INTEGRITY) 788191783Srmacklem#define NFSHASPRIVACY(n) ((n)->nm_flag & NFSMNT_PRIVACY) 789191783Srmacklem#define NFSSETWRITEVERF(n) ((n)->nm_state |= NFSSTA_HASWRITEVERF) 790191783Srmacklem#define NFSSETHASSETFSID(n) ((n)->nm_state |= NFSSTA_HASSETFSID) 791191783Srmacklem#ifdef NFS4_ACL_EXTATTR_NAME 792191783Srmacklem#define NFSHASNFS4ACL(m) ((m)->mnt_flag & MNT_NFS4ACLS) 793191783Srmacklem#else 794191783Srmacklem#define NFSHASNFS4ACL(m) 0 795191783Srmacklem#endif 796191783Srmacklem 797191783Srmacklem/* 798191783Srmacklem * Gets the stats field out of the mount structure. 799191783Srmacklem */ 800191783Srmacklem#define vfs_statfs(m) (&((m)->mnt_stat)) 801191783Srmacklem 802191783Srmacklem/* 803191783Srmacklem * Set boottime. 804191783Srmacklem */ 805191783Srmacklem#define NFSSETBOOTTIME(b) ((b) = boottime) 806191783Srmacklem 807191783Srmacklem/* 808191783Srmacklem * The size of directory blocks in the buffer cache. 809191783Srmacklem * MUST BE in the range of PAGE_SIZE <= NFS_DIRBLKSIZ <= MAXBSIZE!! 810191783Srmacklem */ 811191783Srmacklem#define NFS_DIRBLKSIZ (16 * DIRBLKSIZ) /* Must be a multiple of DIRBLKSIZ */ 812191783Srmacklem 813191783Srmacklem/* 814191783Srmacklem * Define these macros to access mnt_flag fields. 815191783Srmacklem */ 816191783Srmacklem#define NFSMNT_RDONLY(m) ((m)->mnt_flag & MNT_RDONLY) 817191783Srmacklem#endif /* _KERNEL */ 818191783Srmacklem 819191783Srmacklem/* 820191783Srmacklem * Define a structure similar to ufs_args for use in exporting the V4 root. 821191783Srmacklem */ 822191783Srmacklemstruct nfsex_args { 823191783Srmacklem char *fspec; 824191783Srmacklem struct export_args export; 825191783Srmacklem}; 826191783Srmacklem 827191783Srmacklem/* 828191783Srmacklem * These export flags should be defined, but there are no bits left. 829191783Srmacklem * Maybe a separate mnt_exflag field could be added or the mnt_flag 830191783Srmacklem * field increased to 64 bits? 831191783Srmacklem */ 832191783Srmacklem#ifndef MNT_EXSTRICTACCESS 833191783Srmacklem#define MNT_EXSTRICTACCESS 0x0 834191783Srmacklem#endif 835191783Srmacklem#ifndef MNT_EXV4ONLY 836191783Srmacklem#define MNT_EXV4ONLY 0x0 837191783Srmacklem#endif 838191783Srmacklem 839191783Srmacklem#ifdef _KERNEL 840191783Srmacklem/* 841191783Srmacklem * Define this to invalidate the attribute cache for the nfs node. 842191783Srmacklem */ 843191783Srmacklem#define NFSINVALATTRCACHE(n) ((n)->n_attrstamp = 0) 844191783Srmacklem 845191783Srmacklem/* Used for FreeBSD only */ 846191783Srmacklemvoid nfsd_mntinit(void); 847191783Srmacklem 848191783Srmacklem/* 849191783Srmacklem * Define these for vnode lock/unlock ops. 850191783Srmacklem */ 851191783Srmacklem#define NFSVOPLOCK(v, f, p) vn_lock((v), (f)) 852191783Srmacklem#define NFSVOPUNLOCK(v, f, p) VOP_UNLOCK((v), (f)) 853191783Srmacklem#define NFSVOPISLOCKED(v, p) VOP_ISLOCKED((v)) 854191783Srmacklem 855191783Srmacklem/* 856191783Srmacklem * Define ncl_hash(). 857191783Srmacklem */ 858191783Srmacklem#define ncl_hash(f, l) (fnv_32_buf((f), (l), FNV1_32_INIT)) 859191783Srmacklem 860191783Srmacklemint newnfs_iosize(struct nfsmount *); 861191783Srmacklem 862191783Srmacklem#ifdef NFS_DEBUG 863191783Srmacklem 864191783Srmacklemextern int nfs_debug; 865191783Srmacklem#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 866191783Srmacklem#define NFS_DEBUG_WG 2 /* server write gathering */ 867191783Srmacklem#define NFS_DEBUG_RC 4 /* server request caching */ 868191783Srmacklem 869191783Srmacklem#define NFS_DPF(cat, args) \ 870191783Srmacklem do { \ 871191783Srmacklem if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 872191783Srmacklem } while (0) 873191783Srmacklem 874191783Srmacklem#else 875191783Srmacklem 876191783Srmacklem#define NFS_DPF(cat, args) 877191783Srmacklem 878191783Srmacklem#endif 879191783Srmacklem 880191783Srmacklemint newnfs_vncmpf(struct vnode *, void *); 881191783Srmacklem 882191783Srmacklem#ifndef NFS_MINDIRATTRTIMO 883191783Srmacklem#define NFS_MINDIRATTRTIMO 3 /* VDIR attrib cache timeout in sec */ 884191783Srmacklem#endif 885191783Srmacklem#ifndef NFS_MAXDIRATTRTIMO 886191783Srmacklem#define NFS_MAXDIRATTRTIMO 60 887191783Srmacklem#endif 888191783Srmacklem 889191783Srmacklem/* 890191783Srmacklem * Nfs outstanding request list element 891191783Srmacklem */ 892191783Srmacklemstruct nfsreq { 893191783Srmacklem TAILQ_ENTRY(nfsreq) r_chain; 894191783Srmacklem u_int32_t r_flags; /* flags on request, see below */ 895191783Srmacklem struct nfsmount *r_nmp; /* Client mnt ptr */ 896191783Srmacklem struct mtx r_mtx; /* Mutex lock for this structure */ 897191783Srmacklem}; 898191783Srmacklem 899191783Srmacklem#ifndef NFS_MAXBSIZE 900191783Srmacklem#define NFS_MAXBSIZE MAXBSIZE 901191783Srmacklem#endif 902191783Srmacklem 903191783Srmacklem/* 904191783Srmacklem * This macro checks to see if issuing of delegations is allowed for this 905191783Srmacklem * vnode. 906191783Srmacklem */ 907191783Srmacklem#ifdef VV_DISABLEDELEG 908191783Srmacklem#define NFSVNO_DELEGOK(v) \ 909191783Srmacklem ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0) 910191783Srmacklem#else 911191783Srmacklem#define NFSVNO_DELEGOK(v) (1) 912191783Srmacklem#endif 913191783Srmacklem 914191783Srmacklem#endif /* _KERNEL */ 915191783Srmacklem 916191783Srmacklem#endif /* _NFSPORT_NFS_H */ 917