1.\" $NetBSD: vnode.9,v 1.26 2005/01/01 04:06:48 wiz 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 December 31, 2004 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" 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 being used by 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.El 440.Pp 441All vnode locking operations use 442.Em v_vnlock . 443This lock is acquired by calling 444.Xr vn_lock 9 445and released by calling 446.Xr VOP_UNLOCK 9 . 447The reason for this asymmetry is that 448.Xr vn_lock 9 449is a wrapper for 450.Xr VOP_LOCK 9 451with extra checks, while the unlocking step usually does not need 452additional checks and thus has no wrapper. 453.Pp 454The vnode locking operation is complicated because it is used for many 455purposes. 456Sometimes it is used to bundle a series of vnode operations (see 457.Xr vnodeops 9 ) 458into an atomic group. 459Many file systems rely on it to prevent race conditions in updating 460file system type specific data structures rather than using their 461own private locks. 462The vnode lock can operate as a multiple-reader (shared-access lock) 463or single-writer lock (exclusive access lock), however many current file 464system implementations were written assuming only single-writer 465locking. 466Multiple-reader locking functions equivalently only in the presence 467of big-lock SMP locking or a uni-processor machine. 468The lock may be held while sleeping. 469While the 470.Em v_vnlock 471is acquired, the holder is guaranteed that the vnode will not be 472reclaimed or invalidated. 473Most file system functions require that you hold the vnode lock on entry. 474See 475.Xr lock 9 476for details on the kernel locking API. 477.Pp 478For leaf file systems (such as ffs, lfs, msdosfs, etc), 479.Em v_vnlock 480will point to 481.Em v_lock . 482For stacked file systems, 483.Em v_vnlock 484will generally point to 485.Em v_vlock 486of the lowest file system. 487Additionally, the implementation of the vnode lock is the 488responsibility of the individual file systems and 489.Em v_vnlock 490may also be NULL indicating that a leaf node does not export a lock 491for vnode locking. 492In this case, stacked file systems (such as nullfs) must call the 493underlying file system directly for locking. 494.Pp 495Each file system underlying a vnode allocates its own private area and 496hangs it from 497.Em v_data . 498.Pp 499Most functions discussed in this page that operate on vnodes cannot be 500called from interrupt context. 501The members 502.Em v_numoutput , 503.Em v_holdcnt , 504.Em v_dirtyblkhd , 505.Em v_cleanblkhd , 506.Em v_freelist , 507and 508.Em v_synclist 509are modified in interrupt context and must be protected by 510.Xr splbio 9 511unless it is certain that there is no chance an interrupt handler will 512modify them. 513The vnode lock must not be acquired within interrupt context. 514.Sh FUNCTIONS 515.Bl -tag -width compact 516.It Fn vcount "vp" 517Calculate the total number of reference counts to a special device 518with vnode 519.Fa vp . 520.It Fn vref "vp" 521Increment 522.Em v_usecount 523of the vnode 524.Em vp . 525Any kernel thread system which uses a vnode (e.g., during the operation 526of some algorithm or to store in a data structure) should call 527.Fn vref . 528.It Fn VREF "vp" 529This function is an alias for 530.Fn vref . 531.It Fn vrele "vp" 532Decrement 533.Em v_usecount 534of unlocked vnode 535.Em vp . 536Any code in the system which is using a vnode should call 537.Fn vrele 538when it is finished with the vnode. 539If 540.Em v_usecount 541of the vnode reaches zero and 542.Em v_holdcnt 543is greater than zero, the vnode is placed on the holdlist. 544If both 545.Em v_usecount 546and 547.Em v_holdcnt 548are zero, the vnode is placed on the freelist. 549.It Fn vget "vp" "lockflags" 550Reclaim vnode 551.Fa vp 552from the freelist, increment its reference count and lock it. 553The argument 554.Fa lockflags 555specifies the 556.Xr lockmgr 9 557flags used to lock the vnode. 558If the VXLOCK is set in 559.Fa vp Ns 's 560.Em v_flag , 561vnode 562.Fa vp 563is being recycled in 564.Fn vgone 565and the calling thread sleeps until the transition is complete. 566When it is awakened, an error is returned to indicate that the vnode is 567no longer usable (possibly having been recycled to a new file system type). 568.It Fn vput "vp" 569Unlock vnode 570.Fa vp 571and decrement its 572.Em v_usecount . 573Depending of the reference counts, move the vnode to the holdlist or 574the freelist. 575This operation is functionally equivalent to calling 576.Xr VOP_UNLOCK 9 577followed by 578.Fn vrele . 579.It Fn vhold "vp" 580Mark the vnode 581.Fa vp 582as active by incrementing 583.Em vp-\*[Gt]v_holdcnt 584and moving the vnode from the freelist to the holdlist. 585Once on the holdlist, the vnode will not be recycled until it is 586released with 587.Fn holdrele . 588.It Fn VHOLD "vp" 589This function is an alias for 590.Fn vhold . 591.It Fn holdrele "vp" 592Mark the vnode 593.Fa vp 594as inactive by decrementing 595.Em vp-\*[Gt]v_holdcnt 596and moving the vnode from the holdlist to the freelist. 597.It Fn HOLDRELE "vp" 598This function is an alias for 599.Fn holdrele . 600.It Fn getnewvnode "tag" "mp" "vops" "vpp" 601Retrieve the next vnode from the freelist. 602.Fn getnewvnode 603must choose whether to allocate a new vnode or recycle an existing 604one. 605The criterion for allocating a new one is that the total number of 606vnodes is less than the number desired or there are no vnodes on either 607free list. 608Generally only vnodes that have no buffers associated with them are 609recycled and the next vnode from the freelist is retrieved. 610If the freelist is empty, vnodes on the holdlist are considered. 611The new vnode is returned in the address specified by 612.Fa vpp . 613.Pp 614The argument 615.Fa mp 616is the mount point for the file system requested the new vnode. 617Before retrieving the new vnode, the file system is checked if it is 618busy (such as currently unmounting). 619An error is returned if the file system is unmounted. 620.Pp 621The argument 622.Fa tag 623is the vnode tag assigned to 624.Fa *vpp-\*[Gt]v_tag . 625The argument 626.Fa vops 627is the vnode operations vector of the file system requesting the new 628vnode. 629If a vnode is successfully retrieved zero is returned, otherwise an 630appropriate error code is returned. 631.It Fn ungetnewvnode "vp" 632Undo the operation of 633.Fn getnewvnode . 634The argument 635.Fa vp 636is the vnode to return to the freelist. 637This function is needed for 638.Xr VFS_VGET 9 639which may need to push back a vnode in case of a locking race 640condition. 641.It Fn vrecycle "vp" "inter_lkp" "p" 642Recycle the unused vnode 643.Fa vp 644to the front of the freelist. 645.Fn vrecycle 646is a null operation if the reference count is greater than zero. 647.It Fn vgone "vp" 648Eliminate all activity associated with the unlocked vnode 649.Fa vp 650in preparation for recycling. 651.It Fn vgonel "vp" 652Eliminate all activity associated with the locked vnode 653.Fa vp 654in preparation for recycling. 655.It Fn vflush "mp" "skipvp" "flags" 656Remove any vnodes in the vnode table belonging to mount point 657.Fa mp . 658If 659.Fa skipvp 660is not NULL it is exempt from being flushed. 661The argument 662.Fa flags 663is a set of flags modifying the operation of 664.Fn vflush . 665If FORCECLOSE is not specified, there should not be any active vnodes and 666the error 667.Er EBUSY 668is returned if any are found (this is a user error, not a system error). 669If FORCECLOSE is specified, active vnodes that are found are detached. 670If WRITECLOSE is set, only flush out regular file vnodes open for 671writing. 672SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped. 673.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 674Do access checking by comparing the file's permissions to the caller's 675desired access type 676.Fa acc_mode 677and credentials 678.Fa cred . 679.It Fn checkalias "vp" "nvp_rdev" "mp" 680Check to see if the new vnode 681.Fa vp 682represents a special device for which another vnode represents the 683same device. 684If such an aliases exists the existing contents and the aliased vnode 685are deallocated. 686The caller is responsible for filling the new vnode with its new contents. 687.It Fn bdevvp "dev" "vpp" 688Create a vnode for a block device. 689.Fn bdevvp 690is used for root file systems, swap areas and for memory file system 691special devices. 692.It Fn cdevvp "dev" "vpp" 693Create a vnode for a character device. 694.Fn cdevvp 695is used for the console and kernfs special devices. 696.It Fn vfinddev "dev" "vtype" "vpp" 697Lookup a vnode by device number. 698The vnode is returned in the address specified by 699.Fa vpp . 700.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 701Reclaim all vnodes that correspond to the specified minor number range 702.Fa minl 703to 704.Fa minh 705(endpoints inclusive) of the specified major 706.Fa maj . 707.It Fn vwakeup "bp" 708Update outstanding I/O count 709.Em vp-\*[Gt]v_numoutput 710for the vnode 711.Em bp-\*[Gt]b_vp 712and do a wakeup if requested and 713.Em vp-\*[Gt]vflag 714has VBWAIT set. 715.It Fn vflushbuf "vp" "sync" 716Flush all dirty buffers to disk for the file with the locked vnode 717.Fa vp . 718The argument 719.Fa sync 720specifies whether the I/O should be synchronous and 721.Fn vflushbuf 722will sleep until 723.Em vp-\*[Gt]v_numoutput 724is zero and 725.Em vp-\*[Gt]v_dirtyblkhd 726is empty. 727.It Fn vinvalbuf "vp" "flags" "cred" "p" "slpflag" "slptimeo" 728Flush out and invalidate all buffers associated with locked vnode 729.Fa vp . 730The argument 731.Fa p 732and 733.Fa cred 734specified the calling process and its credentials. 735The 736.Xr ltsleep 9 737flag and timeout are specified by the arguments 738.Fa slpflag 739and 740.Fa slptimeo 741respectively. 742If the operation is successful zero is returned, otherwise an 743appropriate error code is returned. 744.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 745Destroy any in-core buffers past the file truncation length for the 746locked vnode 747.Fa vp . 748The truncation length is specified by 749.Fa lbn . 750.Fn vtruncbuf 751will sleep while the I/O is performed, The 752.Xr ltsleep 9 753flag and timeout are specified by the arguments 754.Fa slpflag 755and 756.Fa slptimeo 757respectively. 758If the operation is successful zero is returned, otherwise an 759appropriate error code is returned. 760.It Fn vprint "label" "vp" 761This function is used by the kernel to dump vnode information during a 762panic. 763It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 764The argument 765.Fa label 766is a string to prefix the information dump of vnode 767.Fa vp . 768.El 769.Sh CODE REFERENCES 770This section describes places within the 771.Nx 772source tree where actual code implementing or using the vnode 773framework can be found. 774All pathnames are relative to 775.Pa /usr/src . 776.Pp 777The vnode framework is implemented within the file 778.Pa sys/kern/vfs_subr.c . 779.Sh SEE ALSO 780.Xr intro 9 , 781.Xr lock 9 , 782.Xr namecache 9 , 783.Xr namei 9 , 784.Xr uvm 9 , 785.Xr vattr 9 , 786.Xr vfs 9 , 787.Xr vfsops 9 , 788.Xr vnodeops 9 , 789.Xr vnsubr 9 790.Sh BUGS 791The locking protocol is inconsistent. 792Many vnode operations are passed locked vnodes on entry but release 793the lock before they exit. 794The locking protocol is used in some places to attempt to make a 795series of operations atomic (e.g., access check then operation). 796This does not work for non-local file systems that do not support locking 797(e.g., NFS). 798The 799.Nm 800interface would benefit from a simpler locking protocol. 801