nfsport.h revision 207170
1148330Snetchild/*- 2148330Snetchild * Copyright (c) 1989, 1993 3148330Snetchild * The Regents of the University of California. All rights reserved. 4148330Snetchild * 5148330Snetchild * This code is derived from software contributed to Berkeley by 6148330Snetchild * Rick Macklem at The University of Guelph. 7148330Snetchild * 8148330Snetchild * Redistribution and use in source and binary forms, with or without 9148330Snetchild * modification, are permitted provided that the following conditions 10148330Snetchild * are met: 11148330Snetchild * 1. Redistributions of source code must retain the above copyright 12148330Snetchild * notice, this list of conditions and the following disclaimer. 13148330Snetchild * 2. Redistributions in binary form must reproduce the above copyright 14148543Snetchild * notice, this list of conditions and the following disclaimer in the 15148543Snetchild * documentation and/or other materials provided with the distribution. 16148330Snetchild * 4. Neither the name of the University nor the names of its contributors 17172390Sbushman * may be used to endorse or promote products derived from this software 18172390Sbushman * without specific prior written permission. 19172390Sbushman * 20172390Sbushman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21172390Sbushman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22171786Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23171786Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24171786Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25171786Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26171696Sbz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27171696Sbz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28171461Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29171461Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30171461Srwatson * SUCH DAMAGE. 31171461Srwatson * 32171461Srwatson * $FreeBSD: head/sys/fs/nfs/nfsport.h 207170 2010-04-24 22:52:14Z rmacklem $ 33171461Srwatson */ 34171461Srwatson 35171461Srwatson#ifndef _NFS_NFSPORT_H_ 36171461Srwatson#define _NFSPORT_NFS_H_ 37171461Srwatson 38171461Srwatson/* 39171461Srwatson * In general, I'm not fond of #includes in .h files, but this seems 40171461Srwatson * to be the cleanest way to handle #include files for the ports. 41171461Srwatson */ 42171461Srwatson#ifdef _KERNEL 43171461Srwatson#include <sys/unistd.h> 44171461Srwatson#include <sys/param.h> 45171461Srwatson#include <sys/systm.h> 46171461Srwatson#include <sys/conf.h> 47171461Srwatson#include <sys/dirent.h> 48171461Srwatson#include <sys/domain.h> 49171461Srwatson#include <sys/fcntl.h> 50171461Srwatson#include <sys/file.h> 51171461Srwatson#include <sys/filedesc.h> 52171461Srwatson#include <sys/jail.h> 53171461Srwatson#include <sys/kernel.h> 54171461Srwatson#include <sys/lockf.h> 55171461Srwatson#include <sys/malloc.h> 56171461Srwatson#include <sys/mbuf.h> 57171461Srwatson#include <sys/mount.h> 58171461Srwatson#include <sys/namei.h> 59171461Srwatson#include <sys/proc.h> 60171461Srwatson#include <sys/protosw.h> 61171461Srwatson#include <sys/reboot.h> 62171461Srwatson#include <sys/resourcevar.h> 63171461Srwatson#include <sys/signalvar.h> 64171461Srwatson#include <sys/socket.h> 65171461Srwatson#include <sys/socketvar.h> 66171461Srwatson#include <sys/stat.h> 67171461Srwatson#include <sys/syslog.h> 68171461Srwatson#include <sys/sysproto.h> 69171461Srwatson#include <sys/time.h> 70171461Srwatson#include <sys/uio.h> 71171461Srwatson#include <sys/vnode.h> 72171461Srwatson#include <sys/bio.h> 73171461Srwatson#include <sys/buf.h> 74171461Srwatson#include <sys/acl.h> 75171461Srwatson#include <sys/module.h> 76171461Srwatson#include <sys/sysent.h> 77171461Srwatson#include <sys/syscall.h> 78171461Srwatson#include <sys/priv.h> 79171461Srwatson#include <sys/kthread.h> 80171461Srwatson#include <sys/syscallsubr.h> 81171461Srwatson#include <fs/fifofs/fifo.h> 82171461Srwatson#include <net/if.h> 83171461Srwatson#include <net/radix.h> 84171461Srwatson#include <net/route.h> 85171461Srwatson#include <net/if_dl.h> 86171461Srwatson#include <netinet/in.h> 87171461Srwatson#include <netinet/in_pcb.h> 88171461Srwatson#include <netinet/in_systm.h> 89171461Srwatson#include <netinet/in_var.h> 90171461Srwatson#include <netinet/ip.h> 91171461Srwatson#include <netinet/ip_var.h> 92171461Srwatson#include <netinet/tcp.h> 93171461Srwatson#include <netinet/tcp_fsm.h> 94171461Srwatson#include <netinet/tcp_seq.h> 95171461Srwatson#include <netinet/tcp_timer.h> 96171461Srwatson#include <netinet/tcp_var.h> 97171461Srwatson#include <machine/in_cksum.h> 98171461Srwatson#include <crypto/des/des.h> 99171461Srwatson#include <sys/md5.h> 100171461Srwatson#include <rpc/rpc.h> 101171274Sbz#include <rpc/rpcsec_gss.h> 102171274Sbz 103171274Sbz/* 104171274Sbz * For Darwin, these functions should be "static" when built in a kext. 105171274Sbz * (This is always defined as nil otherwise.) 106171274Sbz */ 107171274Sbz#define APPLESTATIC 108171274Sbz#include <ufs/ufs/dir.h> 109171274Sbz#include <ufs/ufs/quota.h> 110171205Sbz#include <ufs/ufs/inode.h> 111171205Sbz#include <ufs/ufs/extattr.h> 112171205Sbz#include <ufs/ufs/ufsmount.h> 113171205Sbz#include <vm/uma.h> 114171205Sbz#include <vm/vm.h> 115171205Sbz#include <vm/vm_object.h> 116171175Smlaier#include <vm/vm_extern.h> 117171175Smlaier#include <nfs/nfssvc.h> 118171137Sbz#include "opt_nfs.h" 119171137Sbz#include "opt_ufs.h" 120171137Sbz 121171137Sbz/* 122171137Sbz * These types must be defined before the nfs includes. 123171137Sbz */ 124171137Sbz#define NFSSOCKADDR_T struct sockaddr * 125171137Sbz#define NFSPROC_T struct thread 126171137Sbz#define NFSDEV_T dev_t 127171137Sbz#define NFSSVCARGS nfssvc_args 128171137Sbz#define NFSACL_T struct acl 129171137Sbz 130171137Sbz/* 131171137Sbz * These should be defined as the types used for the corresponding VOP's 132171137Sbz * argument type. 133171137Sbz */ 134171137Sbz#define NFS_ACCESS_ARGS struct vop_access_args 135171137Sbz#define NFS_OPEN_ARGS struct vop_open_args 136171137Sbz#define NFS_GETATTR_ARGS struct vop_getattr_args 137171131Sthompsa#define NFS_LOOKUP_ARGS struct vop_lookup_args 138171131Sthompsa#define NFS_READDIR_ARGS struct vop_readdir_args 139171143Sthompsa 140171023Srafan/* 141171023Srafan * Allocate mbufs. Must succeed and never set the mbuf ptr to NULL. 142171023Srafan */ 143171023Srafan#define NFSMGET(m) do { \ 144171023Srafan MGET((m), M_TRYWAIT, MT_DATA); \ 145171023Srafan while ((m) == NULL ) { \ 146171388Sdougb (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 147171388Sdougb MGET((m), M_TRYWAIT, MT_DATA); \ 148171388Sdougb } \ 149171388Sdougb } while (0) 150170926Srafan#define NFSMGETHDR(m) do { \ 151170926Srafan MGETHDR((m), M_TRYWAIT, MT_DATA); \ 152170926Srafan while ((m) == NULL ) { \ 153170926Srafan (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 154170926Srafan MGETHDR((m), M_TRYWAIT, MT_DATA); \ 155170926Srafan } \ 156170926Srafan } while (0) 157170926Srafan#define NFSMCLGET(m, w) do { \ 158170926Srafan MGET((m), M_TRYWAIT, MT_DATA); \ 159170926Srafan while ((m) == NULL ) { \ 160170926Srafan (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 161170926Srafan MGET((m), M_TRYWAIT, MT_DATA); \ 162170926Srafan } \ 163170926Srafan MCLGET((m), (w)); \ 164170926Srafan } while (0) 165170926Srafan#define NFSMCLGETHDR(m, w) do { \ 166170926Srafan MGETHDR((m), M_TRYWAIT, MT_DATA); \ 167170926Srafan while ((m) == NULL ) { \ 168170926Srafan (void) nfs_catnap(PZERO, 0, "nfsmget"); \ 169170926Srafan MGETHDR((m), M_TRYWAIT, MT_DATA); \ 170170926Srafan } \ 171170926Srafan } while (0) 172170926Srafan#define NFSMTOD mtod 173170926Srafan 174170926Srafan/* 175170926Srafan * Client side constant for size of a lockowner name. 176170926Srafan */ 177170926Srafan#define NFSV4CL_LOCKNAMELEN 12 178170926Srafan 179170926Srafan/* 180170926Srafan * Type for a mutex lock. 181170926Srafan */ 182170926Srafan#define NFSMUTEX_T struct mtx 183170926Srafan 184170926Srafan#endif /* _KERNEL */ 185170926Srafan 186170926Srafan/* 187170926Srafan * NFSv4 Operation numbers. 188170926Srafan */ 189170926Srafan#define NFSV4OP_ACCESS 3 190170926Srafan#define NFSV4OP_CLOSE 4 191171476Sdelphij#define NFSV4OP_COMMIT 5 192171476Sdelphij#define NFSV4OP_CREATE 6 193170312Sdelphij#define NFSV4OP_DELEGPURGE 7 194170312Sdelphij#define NFSV4OP_DELEGRETURN 8 195170926Srafan#define NFSV4OP_GETATTR 9 196170926Srafan#define NFSV4OP_GETFH 10 197169815Sdelphij#define NFSV4OP_LINK 11 198169815Sdelphij#define NFSV4OP_LOCK 12 199169815Sdelphij#define NFSV4OP_LOCKT 13 200169815Sdelphij#define NFSV4OP_LOCKU 14 201169815Sdelphij#define NFSV4OP_LOOKUP 15 202169815Sdelphij#define NFSV4OP_LOOKUPP 16 203169815Sdelphij#define NFSV4OP_NVERIFY 17 204169815Sdelphij#define NFSV4OP_OPEN 18 205169815Sdelphij#define NFSV4OP_OPENATTR 19 206169815Sdelphij#define NFSV4OP_OPENCONFIRM 20 207169815Sdelphij#define NFSV4OP_OPENDOWNGRADE 21 208169815Sdelphij#define NFSV4OP_PUTFH 22 209170204Sru#define NFSV4OP_PUTPUBFH 23 210169815Sdelphij#define NFSV4OP_PUTROOTFH 24 211169815Sdelphij#define NFSV4OP_READ 25 212169815Sdelphij#define NFSV4OP_READDIR 26 213169815Sdelphij#define NFSV4OP_READLINK 27 214170204Sru#define NFSV4OP_REMOVE 28 215169815Sdelphij#define NFSV4OP_RENAME 29 216169815Sdelphij#define NFSV4OP_RENEW 30 217169815Sdelphij#define NFSV4OP_RESTOREFH 31 218169815Sdelphij#define NFSV4OP_SAVEFH 32 219169815Sdelphij#define NFSV4OP_SECINFO 33 220169815Sdelphij#define NFSV4OP_SETATTR 34 221169815Sdelphij#define NFSV4OP_SETCLIENTID 35 222169815Sdelphij#define NFSV4OP_SETCLIENTIDCFRM 36 223169815Sdelphij#define NFSV4OP_VERIFY 37 224169815Sdelphij#define NFSV4OP_WRITE 38 225169815Sdelphij#define NFSV4OP_RELEASELCKOWN 39 226169815Sdelphij 227169815Sdelphij/* 228169815Sdelphij * Must be one greater than the last Operation#. 229169815Sdelphij */ 230169815Sdelphij#define NFSV4OP_NOPS 40 231169815Sdelphij 232169815Sdelphij/* Quirky case if the illegal op code */ 233169815Sdelphij#define NFSV4OP_OPILLEGAL 10044 234169815Sdelphij 235169815Sdelphij/* 236169815Sdelphij * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. 237169815Sdelphij */ 238169815Sdelphij#define NFSV4OP_SYMLINK (NFSV4OP_NOPS) 239169815Sdelphij#define NFSV4OP_MKDIR (NFSV4OP_NOPS + 1) 240169815Sdelphij#define NFSV4OP_RMDIR (NFSV4OP_NOPS + 2) 241169815Sdelphij#define NFSV4OP_READDIRPLUS (NFSV4OP_NOPS + 3) 242169815Sdelphij#define NFSV4OP_MKNOD (NFSV4OP_NOPS + 4) 243169815Sdelphij#define NFSV4OP_FSSTAT (NFSV4OP_NOPS + 5) 244169815Sdelphij#define NFSV4OP_FSINFO (NFSV4OP_NOPS + 6) 245169815Sdelphij#define NFSV4OP_PATHCONF (NFSV4OP_NOPS + 7) 246169815Sdelphij#define NFSV4OP_V3CREATE (NFSV4OP_NOPS + 8) 247169815Sdelphij 248169815Sdelphij/* 249169815Sdelphij * This is the count of the fake operations listed above. 250169815Sdelphij */ 251170204Sru#define NFSV4OP_FAKENOPS 9 252169815Sdelphij 253169815Sdelphij/* 254169815Sdelphij * and the Callback OPs 255170917Srafan */ 256169815Sdelphij#define NFSV4OP_CBGETATTR 3 257169815Sdelphij#define NFSV4OP_CBRECALL 4 258169815Sdelphij 259169815Sdelphij/* 260169815Sdelphij * Must be one greater than the last Callback Operation#. 261169815Sdelphij */ 262169815Sdelphij#define NFSV4OP_CBNOPS 5 263169815Sdelphij 264169815Sdelphij/* 265169815Sdelphij * The lower numbers -> 21 are used by NFSv2 and v3. These define higher 266169815Sdelphij * numbers used by NFSv4. 267169815Sdelphij * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is 268169815Sdelphij * one greater than the last number. 269169815Sdelphij */ 270169815Sdelphij#define NFS_V3NPROCS 22 271169815Sdelphij 272169815Sdelphij#define NFSPROC_LOOKUPP 22 273169815Sdelphij#define NFSPROC_SETCLIENTID 23 274169815Sdelphij#define NFSPROC_SETCLIENTIDCFRM 24 275169815Sdelphij#define NFSPROC_LOCK 25 276169815Sdelphij#define NFSPROC_LOCKU 26 277169815Sdelphij#define NFSPROC_OPEN 27 278169815Sdelphij#define NFSPROC_CLOSE 28 279169815Sdelphij#define NFSPROC_OPENCONFIRM 29 280169815Sdelphij#define NFSPROC_LOCKT 30 281169815Sdelphij#define NFSPROC_OPENDOWNGRADE 31 282169815Sdelphij#define NFSPROC_RENEW 32 283169815Sdelphij#define NFSPROC_PUTROOTFH 33 284169815Sdelphij#define NFSPROC_RELEASELCKOWN 34 285169815Sdelphij#define NFSPROC_DELEGRETURN 35 286169815Sdelphij#define NFSPROC_RETDELEGREMOVE 36 287169815Sdelphij#define NFSPROC_RETDELEGRENAME1 37 288169815Sdelphij#define NFSPROC_RETDELEGRENAME2 38 289169815Sdelphij#define NFSPROC_GETACL 39 290169815Sdelphij#define NFSPROC_SETACL 40 291169815Sdelphij 292169815Sdelphij/* 293169815Sdelphij * Must be defined as one higher than the last Proc# above. 294169815Sdelphij */ 295169815Sdelphij#define NFSV4_NPROCS 41 296169815Sdelphij 297169815Sdelphij/* 298169815Sdelphij * Stats structure 299169815Sdelphij */ 300169815Sdelphijstruct ext_nfsstats { 301169815Sdelphij int attrcache_hits; 302169815Sdelphij int attrcache_misses; 303169815Sdelphij int lookupcache_hits; 304169815Sdelphij int lookupcache_misses; 305170204Sru int direofcache_hits; 306169815Sdelphij int direofcache_misses; 307169815Sdelphij int accesscache_hits; 308169815Sdelphij int accesscache_misses; 309169815Sdelphij int biocache_reads; 310169815Sdelphij int read_bios; 311170190Sru int read_physios; 312169815Sdelphij int biocache_writes; 313169815Sdelphij int write_bios; 314169815Sdelphij int write_physios; 315169815Sdelphij int biocache_readlinks; 316169815Sdelphij int readlink_bios; 317169815Sdelphij int biocache_readdirs; 318169815Sdelphij int readdir_bios; 319169815Sdelphij int rpccnt[NFSV4_NPROCS]; 320169815Sdelphij int rpcretries; 321169815Sdelphij int srvrpccnt[NFSV4OP_NOPS + NFSV4OP_FAKENOPS]; 322169815Sdelphij int srvrpc_errs; 323169815Sdelphij int srv_errs; 324170190Sru int rpcrequests; 325170190Sru int rpctimeouts; 326170190Sru int rpcunexpected; 327170190Sru int rpcinvalid; 328170190Sru int srvcache_inproghits; 329170190Sru int srvcache_idemdonehits; 330170190Sru int srvcache_nonidemdonehits; 331171476Sdelphij int srvcache_misses; 332171476Sdelphij int srvcache_tcppeak; 333171476Sdelphij int srvcache_size; 334171476Sdelphij int srvclients; 335171476Sdelphij int srvopenowners; 336171476Sdelphij int srvopens; 337171476Sdelphij int srvlockowners; 338171476Sdelphij int srvlocks; 339171476Sdelphij int srvdelegates; 340171476Sdelphij int cbrpccnt[NFSV4OP_CBNOPS]; 341171476Sdelphij int clopenowners; 342171476Sdelphij int clopens; 343171476Sdelphij int cllockowners; 344171476Sdelphij int cllocks; 345171476Sdelphij int cldelegates; 346171476Sdelphij int cllocalopenowners; 347171476Sdelphij int cllocalopens; 348171476Sdelphij int cllocallockowners; 349171476Sdelphij int cllocallocks; 350171476Sdelphij}; 351171476Sdelphij 352171476Sdelphij#ifdef _KERNEL 353171476Sdelphij/* 354171476Sdelphij * Define the ext_nfsstats as nfsstats for the kernel code. 355171476Sdelphij */ 356171476Sdelphij#define nfsstats ext_nfsstats 357171476Sdelphij 358171476Sdelphij/* 359171476Sdelphij * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. 360171476Sdelphij */ 361171476Sdelphij#define NFS_NPROCS NFSV4_NPROCS 362171476Sdelphij 363171476Sdelphij#include <fs/nfs/nfskpiport.h> 364171476Sdelphij#include <fs/nfs/nfsdport.h> 365171476Sdelphij#include <fs/nfs/rpcv2.h> 366171476Sdelphij#include <fs/nfs/nfsproto.h> 367171476Sdelphij#include <fs/nfs/nfs.h> 368171476Sdelphij#include <fs/nfs/nfs_var.h> 369171476Sdelphij#include <fs/nfs/nfsm_subs.h> 370171476Sdelphij#include <fs/nfs/nfsrvcache.h> 371171476Sdelphij#include <fs/nfs/nfsrvstate.h> 372171476Sdelphij#include <fs/nfs/xdr_subs.h> 373171476Sdelphij#include <fs/nfs/nfscl.h> 374171476Sdelphij#include <fs/nfs/nfsclstate.h> 375171476Sdelphij#include <fs/nfsclient/nfsargs.h> 376171476Sdelphij#include <fs/nfsclient/nfsmount.h> 377171476Sdelphij 378171476Sdelphij/* 379171476Sdelphij * Just to keep nfs_var.h happy. 380171476Sdelphij */ 381171476Sdelphijstruct nfs_vattr { 382171476Sdelphij int junk; 383171476Sdelphij}; 384171476Sdelphij 385171476Sdelphijstruct nfsvattr { 386171476Sdelphij struct vattr na_vattr; 387171476Sdelphij nfsattrbit_t na_suppattr; 388171476Sdelphij u_int32_t na_mntonfileno; 389171476Sdelphij u_int64_t na_filesid[2]; 390171476Sdelphij}; 391171476Sdelphij 392171476Sdelphij#define na_type na_vattr.va_type 393171476Sdelphij#define na_mode na_vattr.va_mode 394171476Sdelphij#define na_nlink na_vattr.va_nlink 395171476Sdelphij#define na_uid na_vattr.va_uid 396171476Sdelphij#define na_gid na_vattr.va_gid 397171476Sdelphij#define na_fsid na_vattr.va_fsid 398171476Sdelphij#define na_fileid na_vattr.va_fileid 399171476Sdelphij#define na_size na_vattr.va_size 400171476Sdelphij#define na_blocksize na_vattr.va_blocksize 401171476Sdelphij#define na_atime na_vattr.va_atime 402171476Sdelphij#define na_mtime na_vattr.va_mtime 403171476Sdelphij#define na_ctime na_vattr.va_ctime 404171476Sdelphij#define na_gen na_vattr.va_gen 405171476Sdelphij#define na_flags na_vattr.va_flags 406171476Sdelphij#define na_rdev na_vattr.va_rdev 407171476Sdelphij#define na_bytes na_vattr.va_bytes 408171476Sdelphij#define na_filerev na_vattr.va_filerev 409171476Sdelphij#define na_vaflags na_vattr.va_vaflags 410171476Sdelphij 411171476Sdelphij#include <fs/nfsclient/nfsnode.h> 412171476Sdelphij 413171476Sdelphij/* 414171476Sdelphij * This is the header structure used for the lists, etc. (It has the 415171476Sdelphij * above record in it. 416171476Sdelphij */ 417171476Sdelphijstruct nfsrv_stablefirst { 418171476Sdelphij LIST_HEAD(, nfsrv_stable) nsf_head; /* Head of nfsrv_stable list */ 419171476Sdelphij time_t nsf_eograce; /* Time grace period ends */ 420171476Sdelphij time_t *nsf_bootvals; /* Previous boottime values */ 421171476Sdelphij struct file *nsf_fp; /* File table pointer */ 422171476Sdelphij u_char nsf_flags; /* NFSNSF_ flags */ 423171476Sdelphij struct nfsf_rec nsf_rec; /* and above first record */ 424171476Sdelphij}; 425171476Sdelphij#define nsf_lease nsf_rec.lease 426171476Sdelphij#define nsf_numboots nsf_rec.numboots 427171476Sdelphij 428171476Sdelphij/* NFSNSF_xxx flags */ 429171476Sdelphij#define NFSNSF_UPDATEDONE 0x01 430171476Sdelphij#define NFSNSF_GRACEOVER 0x02 431171476Sdelphij#define NFSNSF_NEEDLOCK 0x04 432171476Sdelphij#define NFSNSF_EXPIREDCLIENT 0x08 433171476Sdelphij#define NFSNSF_NOOPENS 0x10 434171476Sdelphij#define NFSNSF_OK 0x20 435171476Sdelphij 436171476Sdelphij/* 437171476Sdelphij * Maximum number of boot times allowed in record. Although there is 438171476Sdelphij * really no need for a fixed upper bound, this serves as a sanity check 439171476Sdelphij * for a corrupted file. 440171476Sdelphij */ 441171476Sdelphij#define NFSNSF_MAXNUMBOOTS 10000 442171476Sdelphij 443171476Sdelphij/* 444171476Sdelphij * This structure defines the other records in the file. The 445171476Sdelphij * nst_client array is actually the size of the client string name. 446171476Sdelphij */ 447171476Sdelphijstruct nfst_rec { 448171476Sdelphij u_int16_t len; 449171476Sdelphij u_char flag; 450171476Sdelphij u_char client[1]; 451171476Sdelphij}; 452171476Sdelphij/* and the values for flag */ 453171476Sdelphij#define NFSNST_NEWSTATE 0x1 454171476Sdelphij#define NFSNST_REVOKE 0x2 455171476Sdelphij#define NFSNST_GOTSTATE 0x4 456171476Sdelphij 457171476Sdelphij/* 458171476Sdelphij * This structure is linked onto nfsrv_stablefirst for the duration of 459171476Sdelphij * reclaim. 460171476Sdelphij */ 461171476Sdelphijstruct nfsrv_stable { 462171476Sdelphij LIST_ENTRY(nfsrv_stable) nst_list; 463171476Sdelphij struct nfsclient *nst_clp; 464171476Sdelphij struct nfst_rec nst_rec; 465171476Sdelphij}; 466171476Sdelphij#define nst_timestamp nst_rec.timestamp 467171476Sdelphij#define nst_len nst_rec.len 468171476Sdelphij#define nst_flag nst_rec.flag 469171476Sdelphij#define nst_client nst_rec.client 470171476Sdelphij 471171476Sdelphij/* 472171476Sdelphij * At some point the server will run out of kernel storage for 473171476Sdelphij * state structures. For FreeBSD5.2, this results in a panic 474171476Sdelphij * kmem_map is full. It happens at well over 1000000 opens plus 475171476Sdelphij * locks on a PIII-800 with 256Mbytes, so that is where I've set 476171476Sdelphij * the limit. If your server panics due to too many opens/locks, 477171476Sdelphij * decrease the size of NFSRV_V4STATELIMIT. If you find the server 478171476Sdelphij * returning NFS4ERR_RESOURCE a lot and have lots of memory, try 479171476Sdelphij * increasing it. 480171476Sdelphij */ 481171476Sdelphij#define NFSRV_V4STATELIMIT 500000 /* Max # of Opens + Locks */ 482171476Sdelphij 483171476Sdelphij/* 484171476Sdelphij * The type required differs with BSDen (just the second arg). 485171476Sdelphij */ 486171476Sdelphijvoid nfsrvd_rcv(struct socket *, void *, int); 487171476Sdelphij 488171476Sdelphij/* 489171476Sdelphij * Macros for handling socket addresses. (Hopefully this makes the code 490171476Sdelphij * more portable, since I've noticed some 'BSD don't have sockaddrs in 491171476Sdelphij * mbufs any more.) 492171476Sdelphij */ 493171476Sdelphij#define NFSSOCKADDR(a, t) ((t)(a)) 494171476Sdelphij#define NFSSOCKADDRALLOC(a) \ 495171476Sdelphij do { \ 496171476Sdelphij MALLOC((a), struct sockaddr *, sizeof (struct sockaddr), \ 497171476Sdelphij M_SONAME, M_WAITOK); \ 498171476Sdelphij NFSBZERO((a), sizeof (struct sockaddr)); \ 499171476Sdelphij } while (0) 500171476Sdelphij#define NFSSOCKADDRSIZE(a, s) ((a)->sa_len = (s)) 501171476Sdelphij#define NFSSOCKADDRFREE(a) \ 502171476Sdelphij do { \ 503171476Sdelphij if (a) \ 504171476Sdelphij FREE((caddr_t)(a), M_SONAME); \ 505171476Sdelphij } while (0) 506171476Sdelphij 507171476Sdelphij/* 508171476Sdelphij * These should be defined as a process or thread structure, as required 509171476Sdelphij * for signal handling, etc. 510171476Sdelphij */ 511171476Sdelphij#define NFSNEWCRED(c) (crdup(c)) 512171476Sdelphij#define NFSPROCCRED(p) ((p)->td_ucred) 513171476Sdelphij#define NFSFREECRED(c) (crfree(c)) 514171476Sdelphij#define NFSUIOPROC(u, p) ((u)->uio_td = NULL) 515171476Sdelphij#define NFSPROCP(p) ((p)->td_proc) 516171476Sdelphij 517171476Sdelphij/* 518171476Sdelphij * Define these so that cn_hash and its length is ignored. 519171476Sdelphij */ 520171476Sdelphij#define NFSCNHASHZERO(c) 521171476Sdelphij#define NFSCNHASH(c, v) 522171476Sdelphij#define NCHNAMLEN 9999999 523171476Sdelphij 524171476Sdelphij/* 525171476Sdelphij * Define these to use the time of day clock. 526171476Sdelphij */ 527171476Sdelphij#define NFSGETTIME(t) (getmicrotime(t)) 528171476Sdelphij#define NFSGETNANOTIME(t) (getnanotime(t)) 529171476Sdelphij 530171476Sdelphij/* 531171476Sdelphij * These macros are defined to initialize and set the timer routine. 532171476Sdelphij */ 533171476Sdelphij#define NFS_TIMERINIT \ 534171476Sdelphij newnfs_timer(NULL) 535171476Sdelphij 536171476Sdelphij/* 537171476Sdelphij * Handle SMP stuff: 538171476Sdelphij */ 539171476Sdelphij#define NFSSTATESPINLOCK extern struct mtx nfs_state_mutex 540171476Sdelphij#define NFSLOCKSTATE() mtx_lock(&nfs_state_mutex) 541171476Sdelphij#define NFSUNLOCKSTATE() mtx_unlock(&nfs_state_mutex) 542171476Sdelphij#define NFSSTATEMUTEXPTR (&nfs_state_mutex) 543171476Sdelphij#define NFSREQSPINLOCK extern struct mtx nfs_req_mutex 544171476Sdelphij#define NFSLOCKREQ() mtx_lock(&nfs_req_mutex) 545171476Sdelphij#define NFSUNLOCKREQ() mtx_unlock(&nfs_req_mutex) 546171476Sdelphij#define NFSCACHEMUTEX extern struct mtx nfs_cache_mutex 547171476Sdelphij#define NFSCACHEMUTEXPTR (&nfs_cache_mutex) 548171476Sdelphij#define NFSLOCKCACHE() mtx_lock(&nfs_cache_mutex) 549171476Sdelphij#define NFSUNLOCKCACHE() mtx_unlock(&nfs_cache_mutex) 550171476Sdelphij#define NFSCACHELOCKREQUIRED() mtx_assert(&nfs_cache_mutex, MA_OWNED) 551171476Sdelphij#define NFSSOCKMUTEX extern struct mtx nfs_slock_mutex 552171476Sdelphij#define NFSSOCKMUTEXPTR (&nfs_slock_mutex) 553171476Sdelphij#define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) 554171476Sdelphij#define NFSUNLOCKSOCK() mtx_unlock(&nfs_slock_mutex) 555169445Sroberto#define NFSNAMEIDMUTEX extern struct mtx nfs_nameid_mutex 556169445Sroberto#define NFSLOCKNAMEID() mtx_lock(&nfs_nameid_mutex) 557169445Sroberto#define NFSUNLOCKNAMEID() mtx_unlock(&nfs_nameid_mutex) 558169026Semax#define NFSNAMEIDREQUIRED() mtx_assert(&nfs_nameid_mutex, MA_OWNED) 559169026Semax#define NFSCLSTATEMUTEX extern struct mtx nfs_clstate_mutex 560168916Sbrueffer#define NFSCLSTATEMUTEXPTR (&nfs_clstate_mutex) 561168916Sbrueffer#define NFSLOCKCLSTATE() mtx_lock(&nfs_clstate_mutex) 562168796Sthompsa#define NFSUNLOCKCLSTATE() mtx_unlock(&nfs_clstate_mutex) 563168796Sthompsa#define NFSDLOCKMUTEX extern struct mtx newnfsd_mtx 564168544Spjd#define NFSDLOCKMUTEXPTR (&newnfsd_mtx) 565168544Spjd#define NFSD_LOCK() mtx_lock(&newnfsd_mtx) 566167980Sdelphij#define NFSD_UNLOCK() mtx_unlock(&newnfsd_mtx) 567167980Sdelphij#define NFSD_LOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_OWNED) 568167699Sdelphij#define NFSD_UNLOCK_ASSERT() mtx_assert(&newnfsd_mtx, MA_NOTOWNED) 569167699Sdelphij#define NFSV4ROOTLOCKMUTEX extern struct mtx nfs_v4root_mutex 570167137Sbms#define NFSV4ROOTLOCKMUTEXPTR (&nfs_v4root_mutex) 571167137Sbms#define NFSLOCKV4ROOTMUTEX() mtx_lock(&nfs_v4root_mutex) 572170190Sru#define NFSUNLOCKV4ROOTMUTEX() mtx_unlock(&nfs_v4root_mutex) 573166981Sru#define NFSLOCKNODE(n) mtx_lock(&((n)->n_mtx)) 574166981Sru#define NFSUNLOCKNODE(n) mtx_unlock(&((n)->n_mtx)) 575170192Sru#define NFSLOCKMNT(m) mtx_lock(&((m)->nm_mtx)) 576170218Struckman#define NFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx)) 577166668Sbrueffer#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) 578166668Sbrueffer#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) 579166389Srafan#define NFSPROCLISTLOCK() sx_slock(&allproc_lock) 580166389Srafan#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock) 581166389Srafan#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) 582169821Sru#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx)) 583170190Sru 584170190Sru/* 585170190Sru * Use these macros to initialize/free a mutex. 586170190Sru */ 587170190Sru#define NFSINITSOCKMUTEX(m) mtx_init((m), "nfssock", NULL, MTX_DEF) 588166308Sphk#define NFSFREEMUTEX(m) mtx_destroy((m)) 589166308Sphk 590170192Sruint nfsmsleep(void *, void *, int, const char *, struct timespec *); 591170192Sru 592166246Speter/* 593166246Speter * And weird vm stuff in the nfs server. 594166246Speter */ 595166246Speter#define PDIRUNLOCK 0x0 596166246Speter#define MAX_COMMIT_COUNT (1024 * 1024) 597164796Spiso 598164796Spiso/* 599164796Spiso * These macros are called at the start and end of operations that 600164796Spiso * might modify the underlying file system. 601164796Spiso */ 602164796Spiso#define NFS_STARTWRITE(v, m) vn_start_write((v), (m), V_WAIT) 603164796Spiso#define NFS_ENDWRITE(m) vn_finished_write(m) 604164796Spiso 605164796Spiso/* 606166672Sbrueffer * Define these to handle the type of va_rdev. 607164796Spiso */ 608164796Spiso#define NFSMAKEDEV(m, n) makedev((m), (n)) 609164796Spiso#define NFSMAJOR(d) major(d) 610164796Spiso#define NFSMINOR(d) minor(d) 611164796Spiso 612164796Spiso/* 613164796Spiso * Define this to be the macro that returns the minimum size required 614164796Spiso * for a directory entry. 615165726Skientzle */ 616165726Skientzle#define DIRENT_SIZE(dp) GENERIC_DIRSIZ(dp) 617164610Simp 618164610Simp/* 619164537Srodrigc * The vnode tag for nfsv4root. 620164537Srodrigc */ 621164537Srodrigc#define VT_NFSV4ROOT "nfsv4root" 622164537Srodrigc 623164537Srodrigc/* 624164537Srodrigc * Define whatever it takes to do a vn_rdwr(). 625164537Srodrigc */ 626170190Sru#define NFSD_RDWR(r, v, b, l, o, s, i, c, a, p) \ 627170190Sru vn_rdwr((r), (v), (b), (l), (o), (s), (i), (c), NULL, (a), (p)) 628170190Sru 629170190Sru/* 630170190Sru * Macros for handling memory for different BSDen. 631170190Sru * NFSBCOPY(src, dst, len) - copies len bytes, non-overlapping 632164537Srodrigc * NFSOVBCOPY(src, dst, len) - ditto, but data areas might overlap 633164537Srodrigc * NFSBCMP(cp1, cp2, len) - compare len bytes, return 0 if same 634164537Srodrigc * NFSBZERO(cp, len) - set len bytes to 0x0 635164537Srodrigc */ 636164537Srodrigc#define NFSBCOPY(s, d, l) bcopy((s), (d), (l)) 637164537Srodrigc#define NFSOVBCOPY(s, d, l) ovbcopy((s), (d), (l)) 638164344Sbrueffer#define NFSBCMP(s, d, l) bcmp((s), (d), (l)) 639164344Sbrueffer#define NFSBZERO(s, l) bzero((s), (l)) 640170220Struckman 641170220Struckman/* 642164088Smarcel * Some queue.h files don't have these dfined in them. 643164088Smarcel */ 644164088Smarcel#define LIST_END(head) NULL 645164088Smarcel#define SLIST_END(head) NULL 646163570Sru#define TAILQ_END(head) NULL 647163570Sru 648162837Sdelphij/* 649162837Sdelphij * This must be defined to be a global variable the increments once 650162780Sbms * per second, but never stops or goes backwards, even when a "date" 651162780Sbms * command changes the tod clock. It is used for delta times for 652162780Sbms * leases, etc. 653162780Sbms */ 654162780Sbms#define NFSD_MONOSEC time_uptime 655162780Sbms 656162780Sbms/* 657162780Sbms * Declare the malloc types. 658162780Sbms */ 659162598SsimonMALLOC_DECLARE(M_NEWNFSRVCACHE); 660162598SsimonMALLOC_DECLARE(M_NEWNFSDCLIENT); 661162598SsimonMALLOC_DECLARE(M_NEWNFSDSTATE); 662162716SdelphijMALLOC_DECLARE(M_NEWNFSDLOCK); 663162716SdelphijMALLOC_DECLARE(M_NEWNFSDLOCKFILE); 664161529SflzMALLOC_DECLARE(M_NEWNFSSTRING); 665161529SflzMALLOC_DECLARE(M_NEWNFSUSERGROUP); 666161529SflzMALLOC_DECLARE(M_NEWNFSDREQ); 667170192SruMALLOC_DECLARE(M_NEWNFSFH); 668170192SruMALLOC_DECLARE(M_NEWNFSCLOWNER); 669170192SruMALLOC_DECLARE(M_NEWNFSCLOPEN); 670170192SruMALLOC_DECLARE(M_NEWNFSCLDELEG); 671170192SruMALLOC_DECLARE(M_NEWNFSCLCLIENT); 672170192SruMALLOC_DECLARE(M_NEWNFSCLLOCKOWNER); 673170192SruMALLOC_DECLARE(M_NEWNFSCLLOCK); 674170192SruMALLOC_DECLARE(M_NEWNFSDIROFF); 675170192SruMALLOC_DECLARE(M_NEWNFSV4NODE); 676170192SruMALLOC_DECLARE(M_NEWNFSDIRECTIO); 677170192SruMALLOC_DECLARE(M_NEWNFSMNT); 678170192SruMALLOC_DECLARE(M_NEWNFSDROLLBACK); 679170192Sru#define M_NFSRVCACHE M_NEWNFSRVCACHE 680160983Sbrooks#define M_NFSDCLIENT M_NEWNFSDCLIENT 681160983Sbrooks#define M_NFSDSTATE M_NEWNFSDSTATE 682170255Struckman#define M_NFSDLOCK M_NEWNFSDLOCK 683170255Struckman#define M_NFSDLOCKFILE M_NEWNFSDLOCKFILE 684170255Struckman#define M_NFSSTRING M_NEWNFSSTRING 685170255Struckman#define M_NFSUSERGROUP M_NEWNFSUSERGROUP 686158687Sphk#define M_NFSDREQ M_NEWNFSDREQ 687158687Sphk#define M_NFSFH M_NEWNFSFH 688158687Sphk#define M_NFSCLOWNER M_NEWNFSCLOWNER 689158687Sphk#define M_NFSCLOPEN M_NEWNFSCLOPEN 690158687Sphk#define M_NFSCLDELEG M_NEWNFSCLDELEG 691158687Sphk#define M_NFSCLCLIENT M_NEWNFSCLCLIENT 692158687Sphk#define M_NFSCLLOCKOWNER M_NEWNFSCLLOCKOWNER 693158687Sphk#define M_NFSCLLOCK M_NEWNFSCLLOCK 694158687Sphk#define M_NFSDIROFF M_NEWNFSDIROFF 695158687Sphk#define M_NFSV4NODE M_NEWNFSV4NODE 696158687Sphk#define M_NFSDIRECTIO M_NEWNFSDIRECTIO 697158687Sphk#define M_NFSDROLLBACK M_NEWNFSDROLLBACK 698158687Sphk 699158687Sphk#define NFSINT_SIGMASK(set) \ 700158687Sphk (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 701158687Sphk SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 702158687Sphk SIGISMEMBER(set, SIGQUIT)) 703158687Sphk 704158687Sphk/* 705158687Sphk * Convert a quota block count to byte count. 706158687Sphk */ 707158687Sphk#define NFSQUOTABLKTOBYTE(q, b) (q) *= (b) 708158687Sphk 709158687Sphk/* 710158687Sphk * Define this as the largest file size supported. (It should probably 711158687Sphk * be available via a VFS_xxx Op, but it isn't. 712158687Sphk */ 713158687Sphk#define NFSRV_MAXFILESIZE ((u_int64_t)0x800000000000) 714158687Sphk 715158687Sphk/* 716158687Sphk * Set this macro to index() or strchr(), whichever is supported. 717158687Sphk */ 718158687Sphk#define STRCHR(s, c) index((s), (c)) 719158687Sphk 720158687Sphk/* 721158687Sphk * Set the n_time in the client write rpc, as required. 722158687Sphk */ 723158687Sphk#define NFSWRITERPC_SETTIME(w, n, v4) \ 724158687Sphk do { \ 725158687Sphk if (w) { \ 726158687Sphk (n)->n_mtime = (n)->n_vattr.na_vattr.va_mtime; \ 727158687Sphk if (v4) \ 728158687Sphk (n)->n_change = (n)->n_vattr.na_vattr.va_filerev; \ 729158687Sphk } \ 730158687Sphk } while (0) 731158687Sphk 732158687Sphk/* 733158687Sphk * Fake value, just to make the client work. 734158687Sphk */ 735158687Sphk#define NFS_LATTR_NOSHRINK 1 736158687Sphk 737158687Sphk/* 738158687Sphk * Prototypes for functions where the arguments vary for different ports. 739158618Smaxim */ 740158618Smaximint nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, 741158618Smaxim int, int); 742158512Smlaiervoid newnfs_realign(struct mbuf **); 743158512Smlaier 744158512Smlaier/* 745158512Smlaier * If the port runs on an SMP box that can enforce Atomic ops with low 746158512Smlaier * overheads, define these as atomic increments/decrements. If not, 747158754Smarcel * don't worry about it, since these are used for stats that can be 748158754Smarcel * "out by one" without disastrous consequences. 749157221Ssimon */ 750157221Ssimon#define NFSINCRGLOBAL(a) ((a)++) 751156676Sharti 752156676Sharti/* 753170190Sru * Assorted funky stuff to make things work under Darwin8. 754170190Sru */ 755170190Sru/* 756170190Sru * These macros checks for a field in vattr being set. 757170190Sru */ 758170190Sru#define NFSATTRISSET(t, v, a) ((v)->a != (t)VNOVAL) 759170190Sru#define NFSATTRISSETTIME(v, a) ((v)->a.tv_sec != VNOVAL) 760170190Sru 761153662Sjhb/* 762153662Sjhb * Manipulate mount flags. 763153430Siedowse */ 764153430Siedowse#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier */ 765153430Siedowse#define NFSSTA_GOTFSINFO 0x00100000 /* Got the fsinfo */ 766153430Siedowse#define NFSSTA_TIMEO 0x10000000 /* Experiencing a timeout */ 767153430Siedowse#define NFSSTA_LOCKTIMEO 0x20000000 /* Experiencing a lockd timeout */ 768151845Syar#define NFSSTA_HASSETFSID 0x40000000 /* Has set the fsid */ 769151845Syar 770151271Spjd#define NFSHASNFSV3(n) ((n)->nm_flag & NFSMNT_NFSV3) 771151271Spjd#define NFSHASNFSV4(n) ((n)->nm_flag & NFSMNT_NFSV4) 772162025Smatusita#define NFSHASNFSV3OR4(n) ((n)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) 773162025Smatusita#define NFSHASGOTFSINFO(n) ((n)->nm_state & NFSSTA_GOTFSINFO) 774162025Smatusita#define NFSHASHASSETFSID(n) ((n)->nm_state & NFSSTA_HASSETFSID) 775162025Smatusita#define NFSHASSTRICT3530(n) ((n)->nm_flag & NFSMNT_STRICT3530) 776150676Smlaier#define NFSHASWRITEVERF(n) ((n)->nm_state & NFSSTA_HASWRITEVERF) 777150677Smlaier#define NFSHASINT(n) ((n)->nm_flag & NFSMNT_INT) 778150002Snetchild#define NFSHASSOFT(n) ((n)->nm_flag & NFSMNT_SOFT) 779150002Snetchild#define NFSHASINTORSOFT(n) ((n)->nm_flag & (NFSMNT_INT | NFSMNT_SOFT)) 780150002Snetchild#define NFSHASDUMBTIMR(n) ((n)->nm_flag & NFSMNT_DUMBTIMR) 781150002Snetchild#define NFSHASNOCONN(n) ((n)->nm_flag & NFSMNT_MNTD) 782149454Sglebius#define NFSHASKERB(n) ((n)->nm_flag & NFSMNT_KERB) 783148808Sru#define NFSHASALLGSSNAME(n) ((n)->nm_flag & NFSMNT_ALLGSSNAME) 784148808Sru#define NFSHASINTEGRITY(n) ((n)->nm_flag & NFSMNT_INTEGRITY) 785148825Snetchild#define NFSHASPRIVACY(n) ((n)->nm_flag & NFSMNT_PRIVACY) 786148825Snetchild#define NFSSETWRITEVERF(n) ((n)->nm_state |= NFSSTA_HASWRITEVERF) 787148356Sdougb#define NFSSETHASSETFSID(n) ((n)->nm_state |= NFSSTA_HASSETFSID) 788148356Sdougb#ifdef NFS4_ACL_EXTATTR_NAME 789148572Snetchild#define NFSHASNFS4ACL(m) nfs_supportsnfsv4acls(m) 790170220Struckmanint nfs_supportsnfsv4acls(struct mount *); 791170220Struckman#else 792170220Struckman#define NFSHASNFS4ACL(m) 0 793170220Struckman#endif 794170220Struckman 795148330Snetchild/* 796148330Snetchild * Gets the stats field out of the mount structure. 797148330Snetchild */ 798148330Snetchild#define vfs_statfs(m) (&((m)->mnt_stat)) 799148572Snetchild 800148572Snetchild/* 801149105Simp * Set boottime. 802148572Snetchild */ 803148572Snetchild#define NFSSETBOOTTIME(b) ((b) = boottime) 804148572Snetchild 805172026Syar/* 806172026Syar * The size of directory blocks in the buffer cache. 807172026Syar * MUST BE in the range of PAGE_SIZE <= NFS_DIRBLKSIZ <= MAXBSIZE!! 808172026Syar */ 809148572Snetchild#define NFS_DIRBLKSIZ (16 * DIRBLKSIZ) /* Must be a multiple of DIRBLKSIZ */ 810148572Snetchild 811148572Snetchild/* 812148572Snetchild * Define these macros to access mnt_flag fields. 813148572Snetchild */ 814148572Snetchild#define NFSMNT_RDONLY(m) ((m)->mnt_flag & MNT_RDONLY) 815148572Snetchild#endif /* _KERNEL */ 816148572Snetchild 817148572Snetchild/* 818148572Snetchild * Define a structure similar to ufs_args for use in exporting the V4 root. 819148572Snetchild */ 820153939Snetchildstruct nfsex_args { 821153939Snetchild char *fspec; 822153939Snetchild struct export_args export; 823153939Snetchild}; 824148330Snetchild 825148330Snetchild/* 826148423Sdougb * These export flags should be defined, but there are no bits left. 827148423Sdougb * Maybe a separate mnt_exflag field could be added or the mnt_flag 828148330Snetchild * field increased to 64 bits? 829148330Snetchild */ 830148330Snetchild#ifndef MNT_EXSTRICTACCESS 831148330Snetchild#define MNT_EXSTRICTACCESS 0x0 832148572Snetchild#endif 833148572Snetchild#ifndef MNT_EXV4ONLY 834148353Sdougb#define MNT_EXV4ONLY 0x0 835148353Sdougb#endif 836149105Simp 837149105Simp#ifdef _KERNEL 838148572Snetchild/* 839148572Snetchild * Define this to invalidate the attribute cache for the nfs node. 840172026Syar */ 841149105Simp#define NFSINVALATTRCACHE(n) ((n)->n_attrstamp = 0) 842148572Snetchild 843155813Snetchild/* Used for FreeBSD only */ 844155813Snetchildvoid nfsd_mntinit(void); 845155813Snetchild 846155813Snetchild/* 847148330Snetchild * Define these for vnode lock/unlock ops. 848148330Snetchild */ 849148330Snetchild#define NFSVOPLOCK(v, f, p) vn_lock((v), (f)) 850163991Strhodes#define NFSVOPUNLOCK(v, f, p) VOP_UNLOCK((v), (f)) 851163991Strhodes#define NFSVOPISLOCKED(v, p) VOP_ISLOCKED((v)) 852163991Strhodes 853163991Strhodes/* 854163991Strhodes * Define ncl_hash(). 855163991Strhodes */ 856163991Strhodes#define ncl_hash(f, l) (fnv_32_buf((f), (l), FNV1_32_INIT)) 857163991Strhodes 858163991Strhodesint newnfs_iosize(struct nfsmount *); 859163991Strhodes 860163991Strhodes#ifdef NFS_DEBUG 861148330Snetchild 862148330Snetchildextern int nfs_debug; 863148330Snetchild#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 864148330Snetchild#define NFS_DEBUG_WG 2 /* server write gathering */ 865155813Snetchild#define NFS_DEBUG_RC 4 /* server request caching */ 866148330Snetchild 867148330Snetchild#define NFS_DPF(cat, args) \ 868148330Snetchild do { \ 869148330Snetchild if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 870148330Snetchild } while (0) 871148330Snetchild 872148543Snetchild#else 873148543Snetchild 874148543Snetchild#define NFS_DPF(cat, args) 875148543Snetchild 876148543Snetchild#endif 877148543Snetchild 878148543Snetchildint newnfs_vncmpf(struct vnode *, void *); 879148543Snetchild 880148543Snetchild#ifndef NFS_MINDIRATTRTIMO 881148543Snetchild#define NFS_MINDIRATTRTIMO 3 /* VDIR attrib cache timeout in sec */ 882148543Snetchild#endif 883148543Snetchild#ifndef NFS_MAXDIRATTRTIMO 884148543Snetchild#define NFS_MAXDIRATTRTIMO 60 885148543Snetchild#endif 886148543Snetchild 887148543Snetchild/* 888148543Snetchild * Nfs outstanding request list element 889148543Snetchild */ 890148543Snetchildstruct nfsreq { 891148543Snetchild TAILQ_ENTRY(nfsreq) r_chain; 892148543Snetchild u_int32_t r_flags; /* flags on request, see below */ 893148572Snetchild struct nfsmount *r_nmp; /* Client mnt ptr */ 894148572Snetchild struct mtx r_mtx; /* Mutex lock for this structure */ 895148572Snetchild}; 896148572Snetchild 897148572Snetchild#ifndef NFS_MAXBSIZE 898148572Snetchild#define NFS_MAXBSIZE MAXBSIZE 899148572Snetchild#endif 900148572Snetchild 901148572Snetchild/* 902148572Snetchild * This macro checks to see if issuing of delegations is allowed for this 903148572Snetchild * vnode. 904148572Snetchild */ 905148572Snetchild#ifdef VV_DISABLEDELEG 906148572Snetchild#define NFSVNO_DELEGOK(v) \ 907148572Snetchild ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0) 908148572Snetchild#else 909148572Snetchild#define NFSVNO_DELEGOK(v) (1) 910148572Snetchild#endif 911148572Snetchild 912148572Snetchild/* 913148572Snetchild * Define this as the flags argument for msleep() when catching signals 914148572Snetchild * while holding a resource that other threads would block for, such as 915148572Snetchild * a vnode lock. 916148572Snetchild */ 917148572Snetchild#define NFS_PCATCH (PCATCH | PBDRY) 918148572Snetchild 919148572Snetchild#endif /* _KERNEL */ 920148572Snetchild 921148572Snetchild#endif /* _NFSPORT_NFS_H */ 922148572Snetchild