1.\" $NetBSD: vnode.9,v 1.28 2005/08/05 13:37:25 jmmv Exp $ 2.\" 3.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Gregory McGarry. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd August 5, 2005 38.Dt VNODE 9 39.Os 40.Sh NAME 41.Nm vnode , 42.Nm vcount , 43.Nm vref , 44.Nm VREF , 45.Nm vrele , 46.Nm vget , 47.Nm vput , 48.Nm vhold , 49.Nm VHOLD , 50.Nm holdrele , 51.Nm HOLDRELE , 52.Nm getnewvnode , 53.Nm ungetnewvnode , 54.Nm vrecycle , 55.Nm vgone , 56.Nm vgonel , 57.Nm vflush , 58.Nm vaccess , 59.Nm checkalias , 60.Nm bdevvp , 61.Nm cdevvp , 62.Nm vfinddev , 63.Nm vdevgone , 64.Nm vwakeup , 65.Nm vflushbuf , 66.Nm vinvalbuf , 67.Nm vtruncbuf , 68.Nm vprint 69.Nd kernel representation of a file or directory 70.Sh SYNOPSIS 71.In sys/param.h 72.In sys/vnode.h 73.Ft int 74.Fn vcount "struct vnode *vp" 75.Ft void 76.Fn vref "struct vnode *vp" 77.Ft void 78.Fn VREF "struct vnode *vp" 79.Ft void 80.Fn vrele "struct vnode *vp" 81.Ft int 82.Fn vget "struct vnode *vp" "int lockflag" 83.Ft void 84.Fn vput "struct vnode *vp" 85.Ft void 86.Fn vhold "struct vnode *vp" 87.Ft void 88.Fn VHOLD "struct vnode *vp" 89.Ft void 90.Fn holdrele "struct vnode *vp" 91.Ft void 92.Fn HOLDRELE "struct vnode *vp" 93.Ft int 94.Fn getnewvnode "enum vtagtype tag" "struct mount *mp" "int (**vops)(void *)" "struct vnode **vpp" 95.Ft void 96.Fn ungetnewvnode "struct vnode *vp" 97.Ft int 98.Fn vrecycle "struct vnode *vp" "struct simplelock *inter_lkp" "struct proc *p" 99.Ft void 100.Fn vgone "struct vnode *vp" 101.Ft void 102.Fn vgonel "struct vnode *vp" "struct proc *p" 103.Ft int 104.Fn vflush "struct mount *mp" "struct vnode *skipvp" "int flags" 105.Ft int 106.Fn vaccess "enum vtype type" "mode_t file_mode" "uid_t uid" "gid_t gid" "mode_t acc_mode" "struct ucred *cred" 107.Ft struct vnode * 108.Fn checkalias "struct vnode *vp" "dev_t nvp_rdev" "struct mount *mp" 109.Ft int 110.Fn bdevvp "dev_t dev" "struct vnode **vpp" 111.Ft int 112.Fn cdevvp "dev_t dev" "struct vnode **vpp" 113.Ft int 114.Fn vfinddev "dev_t dev" "enum vtype" "struct vnode **vpp" 115.Ft void 116.Fn vdevgone "int maj" "int minl" "int minh" "enum vtype type" 117.Ft void 118.Fn vwakeup "struct buf *bp" 119.Ft void 120.Fn vflushbuf "struct vnode *vp" "int sync" 121.Ft int 122.Fn vinvalbuf "struct vnode *vp" "int flags" "struct ucred *cred" "struct proc *p" "int slpflag" "int slptimeo" 123.Ft int 124.Fn vtruncbuf "struct vnode *vp" "daddr_t lbn" "int slpflag" "int slptimeo" 125.Ft void 126.Fn vprint "char *label" "struct vnode *vp" 127.Sh DESCRIPTION 128The vnode is the focus of all file activity in 129.Nx . 130There is a unique vnode allocated for each active file, directory, 131mounted-on file, fifo, domain socket, symbolic link and device. 132The kernel has no concept of a file's underlying structure and so it 133relies on the information stored in the vnode to describe the file. 134Thus, the vnode associated with a file holds all the administration 135information pertaining to it. 136.Pp 137When a process requests an operation on a file, the 138.Xr vfs 9 139interface passes control to a file system type dependent function to carry 140out the operation. 141If the file system type dependent function finds that a vnode 142representing the file is not in main memory, it dynamically allocates 143a new vnode from the system main memory pool. 144Once allocated, the vnode is attached to the data structure pointer 145associated with the cause of the vnode allocation and it remains 146resident in the main memory until the system decides that it is no 147longer needed and can be recycled. 148.Pp 149The vnode has the following structure: 150.Bd -literal 151struct vnode { 152 struct uvm_object v_uobj; /* uvm object */ 153#define v_usecount v_uobj.uo_refs 154#define v_interlock v_uobj.vmobjlock 155 voff_t v_size; /* size of file */ 156 int v_flag; /* flags */ 157 int v_numoutput; /* num pending writes */ 158 long v_writecount; /* ref count of writers */ 159 long v_holdcnt; /* page \*[Am] buffer refs */ 160 struct mount *v_mount; /* ptr to vfs we are in */ 161 int (**v_op)(void *); /* vnode ops vector */ 162 TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ 163 LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount pt */ 164 struct buflists v_cleanblkhd; /* clean blocklist head */ 165 struct buflists v_dirtyblkhd; /* dirty blocklist head */ 166 LIST_ENTRY(vnode) v_synclist; /* dirty vnodes */ 167 LIST_HEAD(, namecache) v_dnclist; /* namecaches for children */ 168 LIST_HEAD(, namecache) v_nclist; /* namecaches for our parent */ 169 union { 170 struct mount *vu_mountedhere;/* ptr to mounted vfs */ 171 struct socket *vu_socket; /* unix ipc (VSOCK) */ 172 struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */ 173 struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ 174 } v_un; 175#define v_mountedhere v_un.vu_mountedhere 176#define v_socket v_un.vu_socket 177#define v_specinfo v_un.vu_specinfo 178#define v_fifoinfo v_un.vu_fifoinfo 179 struct nqlease *v_lease; /* Soft ref to lease */ 180 enum vtype v_type; /* vnode type */ 181 enum vtagtype v_tag; /* underlying data type */ 182 struct lock v_lock; /* lock for this vnode */ 183 struct lock *v_vnlock; /* ptr to vnode lock */ 184 void *v_data; /* private data for fs */ 185 struct klist v_klist; /* knotes attached to vnode */ 186#ifdef VERIFIED_EXEC 187 char fp_status; /* fingerprint status */ 188#endif 189}; 190.Ed 191.Pp 192Most members of the vnode structure should be treated as opaque and 193only manipulated using the proper functions. 194There are some rather common exceptions detailed throughout this page. 195.Pp 196Files and file systems are inextricably linked with the virtual memory 197system and 198.Em v_uobj 199contains the data maintained by the virtual memory system. 200For compatibility with code written before the integration of 201.Xr uvm 9 202into 203.Nx , 204C-preprocessor directives are used to alias the members of 205.Em v_uobj . 206.Pp 207Vnode flags are recorded by 208.Em v_flag . 209Valid flags are: 210.Pp 211.Bl -tag -offset indent -width VONWORKLST -compact 212.It VROOT 213This vnode is the root of its file system. 214.It VTEXT 215This vnode is a pure text prototype. 216.It VEXECMAP 217This vnode has executable mappings. 218.It VSYSTEM 219This vnode is being used by the kernel; only used to skip quota files in 220.Fn vflush . 221.It VISTTY 222This vnode represents a tty; used when reading dead vnodes. 223.It VXLOCK 224This vnode is currently locked to change underlying type. 225.It VXWANT 226A process is waiting for this vnode. 227.It VBWAIT 228Waiting for output associated with this vnode to complete. 229.It VALIASED 230This vnode has an alias. 231.It VDIROP 232This vnode is involved in a directory operation. 233This flag is used exclusively by LFS. 234.It VLAYER 235This vnode is on a layered file system. 236.It VONWORKLST 237This vnode is on syncer work-list. 238.El 239.Pp 240The VXLOCK flag is used to prevent multiple processes from entering 241the vnode reclamation code. 242It is also used as a flag to indicate that reclamation is in progress. 243The VXWANT flag is set by threads that wish to be awaken when 244reclamation is finished. 245Before 246.Em v_flag 247can be modified, the 248.Em v_interlock 249simplelock must be acquired. 250See 251.Xr lock 9 252for details on the kernel locking API. 253.Pp 254Each vnode has three reference counts: 255.Em v_usecount , 256.Em v_writecount 257and 258.Em v_holdcnt . 259The first is the number of active references within the 260kernel to the vnode. 261This count is maintained by 262.Fn vref , 263.Fn vrele , 264and 265.Fn vput . 266The second is the number of active references within the kernel to the 267vnode performing write access to the file. 268It is maintained by the 269.Xr open 2 270and 271.Xr close 2 272system calls. 273The third is the number of references within the kernel 274requiring the vnode to remain active and not be recycled. 275This count is maintained by 276.Fn vhold 277and 278.Fn holdrele . 279When both the 280.Em v_usecount 281and 282.Em v_holdcnt 283reach zero, the vnode is recycled to the freelist and may be reused 284for another file. 285The transition to and from the freelist is handled by 286.Fn getnewvnode , 287.Fn ungetnewvnode 288and 289.Fn vrecycle . 290Access to 291.Em v_usecount , 292.Em v_writecount 293and 294.Em v_holdcnt 295is also protected by the 296.Em v_interlock 297simplelock. 298.Pp 299The number of pending synchronous and asynchronous writes on the 300vnode are recorded in 301.Em v_numoutput . 302It is used by 303.Xr fsync 2 304to wait for all writes to complete before returning to the user. 305Its value must only be modified at splbio (see 306.Xr spl 9 ) . 307It does not track the number of dirty buffers attached to the 308vnode. 309.Pp 310.Em v_dnclist 311and 312.Em v_nclist 313are used by 314.Xr namecache 9 315to maintain the list of associated entries so that 316.Xr cache_purge 9 317can purge them. 318.Pp 319The link to the file system which owns the vnode is recorded by 320.Em v_mount . 321See 322.Xr vfsops 9 323for further information of file system mount status. 324.Pp 325The 326.Em v_op 327pointer points to its vnode operations vector. 328This vector describes what operations can be done to the file associated 329with the vnode. 330The system maintains one vnode operations vector for each file system 331type configured into the kernel. 332The vnode operations vector contains a pointer to a function for 333each operation supported by the file system. 334See 335.Xr vnodeops 9 336for a description of vnode operations. 337.Pp 338When not in use, vnodes are kept on the freelist through 339.Em v_freelist . 340The vnodes still reference valid files but may be reused to refer to a 341new file at any time. 342When a valid vnode which is on the freelist is used again, the user 343must call 344.Fn vget 345to increment the reference count and retrieve it from the freelist. 346When a user wants a new vnode for another file, 347.Fn getnewvnode 348is invoked to remove a vnode from the freelist and initialize it for 349the new file. 350.Pp 351The type of object the vnode represents is recorded by 352.Em v_type . 353It is used by generic code to perform checks to ensure operations are 354performed on valid file system objects. 355Valid types are: 356.Pp 357.Bl -tag -offset indent -width VFIFO -compact 358.It VNON 359The vnode has no type. 360.It VREG 361The vnode represents a regular file. 362.It VDIR 363The vnode represents a directory. 364.It VBLK 365The vnode represents a block special device. 366.It VCHR 367The vnode represents a character special device. 368.It VLNK 369The vnode represents a symbolic link. 370.It VSOCK 371The vnode represents a socket. 372.It VFIFO 373The vnode represents a pipe. 374.It VBAD 375The vnode represents a bad file (not currently used). 376.El 377.Pp 378Vnode tag types are used by external programs only (e.g., 379.Xr pstat 8 ) , 380and should never be inspected by the kernel. 381Its use is deprecated 382since new 383.Em v_tag 384values cannot be defined for loadable file systems. 385The 386.Em v_tag 387member is read-only. 388Valid tag types are: 389.Pp 390.Bl -tag -offset indent -width "VT_FILECORE " -compact 391.It VT_NON 392non file system 393.It VT_UFS 394universal file system 395.It VT_NFS 396network file system 397.It VT_MFS 398memory file system 399.It VT_MSDOSFS 400FAT file system 401.It VT_LFS 402log-structured file system 403.It VT_LOFS 404loopback file system 405.It VT_FDESC 406file descriptor file system 407.It VT_PORTAL 408portal daemon 409.It VT_NULL 410null file system layer 411.It VT_UMAP 412uid/gid remapping file system layer 413.It VT_KERNFS 414kernel interface file system 415.It VT_PROCFS 416process interface file system 417.It VT_AFS 418AFS file system 419.It VT_ISOFS 420ISO 9660 file system(s) 421.It VT_UNION 422union file system 423.It VT_ADOSFS 424Amiga file system 425.It VT_EXT2FS 426Linux's EXT2 file system 427.It VT_CODA 428Coda file system 429.It VT_FILECORE 430filecore file system 431.It VT_NTFS 432Microsoft NT's file system 433.It VT_VFS 434virtual file system 435.It VT_OVERLAY 436overlay file system 437.It VT_SMBFS 438SMB file system 439.It VT_PTYFS 440pseudo-terminal device file system 441.It VT_TMPFS 442efficient memory file system 443.El 444.Pp 445All vnode locking operations use 446.Em v_vnlock . 447This lock is acquired by calling 448.Xr vn_lock 9 449and released by calling 450.Xr VOP_UNLOCK 9 . 451The reason for this asymmetry is that 452.Xr vn_lock 9 453is a wrapper for 454.Xr VOP_LOCK 9 455with extra checks, while the unlocking step usually does not need 456additional checks and thus has no wrapper. 457.Pp 458The vnode locking operation is complicated because it is used for many 459purposes. 460Sometimes it is used to bundle a series of vnode operations (see 461.Xr vnodeops 9 ) 462into an atomic group. 463Many file systems rely on it to prevent race conditions in updating 464file system type specific data structures rather than using their 465own private locks. 466The vnode lock can operate as a multiple-reader (shared-access lock) 467or single-writer lock (exclusive access lock), however many current file 468system implementations were written assuming only single-writer 469locking. 470Multiple-reader locking functions equivalently only in the presence 471of big-lock SMP locking or a uni-processor machine. 472The lock may be held while sleeping. 473While the 474.Em v_vnlock 475is acquired, the holder is guaranteed that the vnode will not be 476reclaimed or invalidated. 477Most file system functions require that you hold the vnode lock on entry. 478See 479.Xr lock 9 480for details on the kernel locking API. 481.Pp 482For leaf file systems (such as ffs, lfs, msdosfs, etc), 483.Em v_vnlock 484will point to 485.Em v_lock . 486For stacked file systems, 487.Em v_vnlock 488will generally point to 489.Em v_vlock 490of the lowest file system. 491Additionally, the implementation of the vnode lock is the 492responsibility of the individual file systems and 493.Em v_vnlock 494may also be NULL indicating that a leaf node does not export a lock 495for vnode locking. 496In this case, stacked file systems (such as nullfs) must call the 497underlying file system directly for locking. 498.Pp 499Each file system underlying a vnode allocates its own private area and 500hangs it from 501.Em v_data . 502.Pp 503Most functions discussed in this page that operate on vnodes cannot be 504called from interrupt context. 505The members 506.Em v_numoutput , 507.Em v_holdcnt , 508.Em v_dirtyblkhd , 509.Em v_cleanblkhd , 510.Em v_freelist , 511and 512.Em v_synclist 513are modified in interrupt context and must be protected by 514.Xr splbio 9 515unless it is certain that there is no chance an interrupt handler will 516modify them. 517The vnode lock must not be acquired within interrupt context. 518.Sh FUNCTIONS 519.Bl -tag -width compact 520.It Fn vcount "vp" 521Calculate the total number of reference counts to a special device 522with vnode 523.Fa vp . 524.It Fn vref "vp" 525Increment 526.Em v_usecount 527of the vnode 528.Em vp . 529Any kernel thread system which uses a vnode (e.g., during the operation 530of some algorithm or to store in a data structure) should call 531.Fn vref . 532.It Fn VREF "vp" 533This function is an alias for 534.Fn vref . 535.It Fn vrele "vp" 536Decrement 537.Em v_usecount 538of unlocked vnode 539.Em vp . 540Any code in the system which is using a vnode should call 541.Fn vrele 542when it is finished with the vnode. 543If 544.Em v_usecount 545of the vnode reaches zero and 546.Em v_holdcnt 547is greater than zero, the vnode is placed on the holdlist. 548If both 549.Em v_usecount 550and 551.Em v_holdcnt 552are zero, the vnode is placed on the freelist. 553.It Fn vget "vp" "lockflags" 554Reclaim vnode 555.Fa vp 556from the freelist, increment its reference count and lock it. 557The argument 558.Fa lockflags 559specifies the 560.Xr lockmgr 9 561flags used to lock the vnode. 562If the VXLOCK is set in 563.Fa vp Ns 's 564.Em v_flag , 565vnode 566.Fa vp 567is being recycled in 568.Fn vgone 569and the calling thread sleeps until the transition is complete. 570When it is awakened, an error is returned to indicate that the vnode is 571no longer usable (possibly having been recycled to a new file system type). 572.It Fn vput "vp" 573Unlock vnode 574.Fa vp 575and decrement its 576.Em v_usecount . 577Depending of the reference counts, move the vnode to the holdlist or 578the freelist. 579This operation is functionally equivalent to calling 580.Xr VOP_UNLOCK 9 581followed by 582.Fn vrele . 583.It Fn vhold "vp" 584Mark the vnode 585.Fa vp 586as active by incrementing 587.Em vp-\*[Gt]v_holdcnt 588and moving the vnode from the freelist to the holdlist. 589Once on the holdlist, the vnode will not be recycled until it is 590released with 591.Fn holdrele . 592.It Fn VHOLD "vp" 593This function is an alias for 594.Fn vhold . 595.It Fn holdrele "vp" 596Mark the vnode 597.Fa vp 598as inactive by decrementing 599.Em vp-\*[Gt]v_holdcnt 600and moving the vnode from the holdlist to the freelist. 601.It Fn HOLDRELE "vp" 602This function is an alias for 603.Fn holdrele . 604.It Fn getnewvnode "tag" "mp" "vops" "vpp" 605Retrieve the next vnode from the freelist. 606.Fn getnewvnode 607must choose whether to allocate a new vnode or recycle an existing 608one. 609The criterion for allocating a new one is that the total number of 610vnodes is less than the number desired or there are no vnodes on either 611free list. 612Generally only vnodes that have no buffers associated with them are 613recycled and the next vnode from the freelist is retrieved. 614If the freelist is empty, vnodes on the holdlist are considered. 615The new vnode is returned in the address specified by 616.Fa vpp . 617.Pp 618The argument 619.Fa mp 620is the mount point for the file system requested the new vnode. 621Before retrieving the new vnode, the file system is checked if it is 622busy (such as currently unmounting). 623An error is returned if the file system is unmounted. 624.Pp 625The argument 626.Fa tag 627is the vnode tag assigned to 628.Fa *vpp-\*[Gt]v_tag . 629The argument 630.Fa vops 631is the vnode operations vector of the file system requesting the new 632vnode. 633If a vnode is successfully retrieved zero is returned, otherwise an 634appropriate error code is returned. 635.It Fn ungetnewvnode "vp" 636Undo the operation of 637.Fn getnewvnode . 638The argument 639.Fa vp 640is the vnode to return to the freelist. 641This function is needed for 642.Xr VFS_VGET 9 643which may need to push back a vnode in case of a locking race 644condition. 645.It Fn vrecycle "vp" "inter_lkp" "p" 646Recycle the unused vnode 647.Fa vp 648to the front of the freelist. 649.Fn vrecycle 650is a null operation if the reference count is greater than zero. 651.It Fn vgone "vp" 652Eliminate all activity associated with the unlocked vnode 653.Fa vp 654in preparation for recycling. 655.It Fn vgonel "vp" "p" 656Eliminate all activity associated with the locked vnode 657.Fa vp 658in preparation for recycling. 659.It Fn vflush "mp" "skipvp" "flags" 660Remove any vnodes in the vnode table belonging to mount point 661.Fa mp . 662If 663.Fa skipvp 664is not NULL it is exempt from being flushed. 665The argument 666.Fa flags 667is a set of flags modifying the operation of 668.Fn vflush . 669If FORCECLOSE is not specified, there should not be any active vnodes and 670the error 671.Er EBUSY 672is returned if any are found (this is a user error, not a system error). 673If FORCECLOSE is specified, active vnodes that are found are detached. 674If WRITECLOSE is set, only flush out regular file vnodes open for 675writing. 676SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped. 677.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 678Do access checking by comparing the file's permissions to the caller's 679desired access type 680.Fa acc_mode 681and credentials 682.Fa cred . 683.It Fn checkalias "vp" "nvp_rdev" "mp" 684Check to see if the new vnode 685.Fa vp 686represents a special device for which another vnode represents the 687same device. 688If such an aliases exists the existing contents and the aliased vnode 689are deallocated. 690The caller is responsible for filling the new vnode with its new contents. 691.It Fn bdevvp "dev" "vpp" 692Create a vnode for a block device. 693.Fn bdevvp 694is used for root file systems, swap areas and for memory file system 695special devices. 696.It Fn cdevvp "dev" "vpp" 697Create a vnode for a character device. 698.Fn cdevvp 699is used for the console and kernfs special devices. 700.It Fn vfinddev "dev" "vtype" "vpp" 701Lookup a vnode by device number. 702The vnode is returned in the address specified by 703.Fa vpp . 704.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 705Reclaim all vnodes that correspond to the specified minor number range 706.Fa minl 707to 708.Fa minh 709(endpoints inclusive) of the specified major 710.Fa maj . 711.It Fn vwakeup "bp" 712Update outstanding I/O count 713.Em vp-\*[Gt]v_numoutput 714for the vnode 715.Em bp-\*[Gt]b_vp 716and do a wakeup if requested and 717.Em vp-\*[Gt]vflag 718has VBWAIT set. 719.It Fn vflushbuf "vp" "sync" 720Flush all dirty buffers to disk for the file with the locked vnode 721.Fa vp . 722The argument 723.Fa sync 724specifies whether the I/O should be synchronous and 725.Fn vflushbuf 726will sleep until 727.Em vp-\*[Gt]v_numoutput 728is zero and 729.Em vp-\*[Gt]v_dirtyblkhd 730is empty. 731.It Fn vinvalbuf "vp" "flags" "cred" "p" "slpflag" "slptimeo" 732Flush out and invalidate all buffers associated with locked vnode 733.Fa vp . 734The argument 735.Fa p 736and 737.Fa cred 738specified the calling process and its credentials. 739The 740.Xr ltsleep 9 741flag and timeout are specified by the arguments 742.Fa slpflag 743and 744.Fa slptimeo 745respectively. 746If the operation is successful zero is returned, otherwise an 747appropriate error code is returned. 748.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 749Destroy any in-core buffers past the file truncation length for the 750locked vnode 751.Fa vp . 752The truncation length is specified by 753.Fa lbn . 754.Fn vtruncbuf 755will sleep while the I/O is performed, The 756.Xr ltsleep 9 757flag and timeout are specified by the arguments 758.Fa slpflag 759and 760.Fa slptimeo 761respectively. 762If the operation is successful zero is returned, otherwise an 763appropriate error code is returned. 764.It Fn vprint "label" "vp" 765This function is used by the kernel to dump vnode information during a 766panic. 767It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 768The argument 769.Fa label 770is a string to prefix the information dump of vnode 771.Fa vp . 772.El 773.Sh CODE REFERENCES 774This section describes places within the 775.Nx 776source tree where actual code implementing or using the vnode 777framework can be found. 778All pathnames are relative to 779.Pa /usr/src . 780.Pp 781The vnode framework is implemented within the file 782.Pa sys/kern/vfs_subr.c . 783.Sh SEE ALSO 784.Xr intro 9 , 785.Xr lock 9 , 786.Xr namecache 9 , 787.Xr namei 9 , 788.Xr uvm 9 , 789.Xr vattr 9 , 790.Xr vfs 9 , 791.Xr vfsops 9 , 792.Xr vnodeops 9 , 793.Xr vnsubr 9 794.Sh BUGS 795The locking protocol is inconsistent. 796Many vnode operations are passed locked vnodes on entry but release 797the lock before they exit. 798The locking protocol is used in some places to attempt to make a 799series of operations atomic (e.g., access check then operation). 800This does not work for non-local file systems that do not support locking 801(e.g., NFS). 802The 803.Nm 804interface would benefit from a simpler locking protocol. 805