1.\" $NetBSD: vnode.9,v 1.40 2009/04/22 20:53:44 elad Exp $ 2.\" 3.\" Copyright (c) 2001, 2005, 2006 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd April 22, 2009 31.Dt VNODE 9 32.Os 33.Sh NAME 34.Nm vnode , 35.Nm vcount , 36.Nm vref , 37.Nm VREF , 38.Nm vrele , 39.Nm vget , 40.Nm vput , 41.Nm vhold , 42.Nm VHOLD , 43.Nm holdrele , 44.Nm HOLDRELE , 45.Nm getnewvnode , 46.Nm ungetnewvnode , 47.Nm vrecycle , 48.Nm vgone , 49.Nm vgonel , 50.Nm vflush , 51.Nm vaccess , 52.Nm checkalias , 53.Nm bdevvp , 54.Nm cdevvp , 55.Nm vfinddev , 56.Nm vdevgone , 57.Nm vwakeup , 58.Nm vflushbuf , 59.Nm vinvalbuf , 60.Nm vtruncbuf , 61.Nm vprint 62.Nd kernel representation of a file or directory 63.Sh SYNOPSIS 64.In sys/param.h 65.In sys/vnode.h 66.Ft int 67.Fn vcount "struct vnode *vp" 68.Ft void 69.Fn vref "struct vnode *vp" 70.Ft void 71.Fn VREF "struct vnode *vp" 72.Ft void 73.Fn vrele "struct vnode *vp" 74.Ft int 75.Fn vget "struct vnode *vp" "int lockflag" 76.Ft void 77.Fn vput "struct vnode *vp" 78.Ft void 79.Fn vhold "struct vnode *vp" 80.Ft void 81.Fn VHOLD "struct vnode *vp" 82.Ft void 83.Fn holdrele "struct vnode *vp" 84.Ft void 85.Fn HOLDRELE "struct vnode *vp" 86.Ft int 87.Fn getnewvnode "enum vtagtype tag" "struct mount *mp" "int (**vops)(void *)" "struct vnode **vpp" 88.Ft void 89.Fn ungetnewvnode "struct vnode *vp" 90.Ft int 91.Fn vrecycle "struct vnode *vp" "struct simplelock *inter_lkp" "struct lwp *l" 92.Ft void 93.Fn vgone "struct vnode *vp" 94.Ft void 95.Fn vgonel "struct vnode *vp" "struct lwp *l" 96.Ft int 97.Fn vflush "struct mount *mp" "struct vnode *skipvp" "int flags" 98.Ft int 99.Fn vaccess "enum vtype type" "mode_t file_mode" "uid_t uid" "gid_t gid" "mode_t acc_mode" "kauth_cred_t cred" 100.Ft struct vnode * 101.Fn checkalias "struct vnode *vp" "dev_t nvp_rdev" "struct mount *mp" 102.Ft int 103.Fn bdevvp "dev_t dev" "struct vnode **vpp" 104.Ft int 105.Fn cdevvp "dev_t dev" "struct vnode **vpp" 106.Ft int 107.Fn vfinddev "dev_t dev" "enum vtype" "struct vnode **vpp" 108.Ft void 109.Fn vdevgone "int maj" "int minl" "int minh" "enum vtype type" 110.Ft void 111.Fn vwakeup "struct buf *bp" 112.Ft void 113.Fn vflushbuf "struct vnode *vp" "int sync" 114.Ft int 115.Fn vinvalbuf "struct vnode *vp" "int flags" "kauth_cred_t cred" "struct lwp *l" "int slpflag" "int slptimeo" 116.Ft int 117.Fn vtruncbuf "struct vnode *vp" "daddr_t lbn" "int slpflag" "int slptimeo" 118.Ft void 119.Fn vprint "const char *label" "struct vnode *vp" 120.Sh DESCRIPTION 121The vnode is the focus of all file activity in 122.Nx . 123There is a unique vnode allocated for each active file, directory, 124mounted-on file, fifo, domain socket, symbolic link and device. 125The kernel has no concept of a file's underlying structure and so it 126relies on the information stored in the vnode to describe the file. 127Thus, the vnode associated with a file holds all the administration 128information pertaining to it. 129.Pp 130When a process requests an operation on a file, the 131.Xr vfs 9 132interface passes control to a file system type dependent function to carry 133out the operation. 134If the file system type dependent function finds that a vnode 135representing the file is not in main memory, it dynamically allocates 136a new vnode from the system main memory pool. 137Once allocated, the vnode is attached to the data structure pointer 138associated with the cause of the vnode allocation and it remains 139resident in the main memory until the system decides that it is no 140longer needed and can be recycled. 141.Pp 142The vnode has the following structure: 143.Bd -literal 144struct vnode { 145 struct uvm_object v_uobj; /* uvm object */ 146#define v_usecount v_uobj.uo_refs 147#define v_interlock v_uobj.vmobjlock 148 voff_t v_size; /* size of file */ 149 int v_flag; /* flags */ 150 int v_numoutput; /* num pending writes */ 151 long v_writecount; /* ref count of writers */ 152 long v_holdcnt; /* page \*[Am] buffer refs */ 153 struct mount *v_mount; /* ptr to vfs we are in */ 154 int (**v_op)(void *); /* vnode ops vector */ 155 TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ 156 LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount pt */ 157 struct buflists v_cleanblkhd; /* clean blocklist head */ 158 struct buflists v_dirtyblkhd; /* dirty blocklist head */ 159 LIST_ENTRY(vnode) v_synclist; /* dirty vnodes */ 160 LIST_HEAD(, namecache) v_dnclist; /* namecaches for children */ 161 LIST_HEAD(, namecache) v_nclist; /* namecaches for our parent */ 162 union { 163 struct mount *vu_mountedhere;/* ptr to mounted vfs */ 164 struct socket *vu_socket; /* unix ipc (VSOCK) */ 165 struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */ 166 struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ 167 } v_un; 168#define v_mountedhere v_un.vu_mountedhere 169#define v_socket v_un.vu_socket 170#define v_specinfo v_un.vu_specinfo 171#define v_fifoinfo v_un.vu_fifoinfo 172 struct nqlease *v_lease; /* Soft ref to lease */ 173 enum vtype v_type; /* vnode type */ 174 enum vtagtype v_tag; /* underlying data type */ 175 struct lock v_lock; /* lock for this vnode */ 176 struct lock *v_vnlock; /* ptr to vnode lock */ 177 void *v_data; /* private data for fs */ 178 struct klist v_klist; /* knotes attached to vnode */ 179}; 180.Ed 181.Pp 182Most members of the vnode structure should be treated as opaque and 183only manipulated using the proper functions. 184There are some rather common exceptions detailed throughout this page. 185.Pp 186Files and file systems are inextricably linked with the virtual memory 187system and 188.Em v_uobj 189contains the data maintained by the virtual memory system. 190For compatibility with code written before the integration of 191.Xr uvm 9 192into 193.Nx , 194C-preprocessor directives are used to alias the members of 195.Em v_uobj . 196.Pp 197Vnode flags are recorded by 198.Em v_flag . 199Valid flags are: 200.Pp 201.Bl -tag -offset indent -width VONWORKLST -compact 202.It VROOT 203This vnode is the root of its file system. 204.It VTEXT 205This vnode is a pure text prototype. 206.It VSYSTEM 207This vnode is being used by the kernel; only used to skip quota files in 208.Fn vflush . 209.It VISTTY 210This vnode represents a tty; used when reading dead vnodes. 211.It VEXECMAP 212This vnode has executable mappings. 213.It VWRITEMAP 214This vnode might have PROT_WRITE user mappings. 215.It VWRITEMAPDIRTY 216This vnode might have dirty pages due to VWRITEMAP 217.It VLOCKSWORK 218This vnode's file system supports locking. 219.It VXLOCK 220This vnode is currently locked to change underlying type. 221.It VXWANT 222A process is waiting for this vnode. 223.It VBWAIT 224Waiting for output associated with this vnode to complete. 225.It VALIASED 226This vnode has an alias. 227.It VDIROP 228This vnode is involved in a directory operation. 229This flag is used exclusively by LFS. 230.It VLAYER 231This vnode is on a layered file system. 232.It VONWORKLST 233This vnode is on syncer work-list. 234.It VFREEING 235This vnode is being freed. 236.It VMAPPED 237This vnode might have user mappings. 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 awakened 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.It VT_UDF 444universal disk format file system 445.It VT_SYSVBFS 446systemV boot file system 447.El 448.Pp 449All vnode locking operations use 450.Em v_vnlock . 451This lock is acquired by calling 452.Xr vn_lock 9 453and released by calling 454.Xr VOP_UNLOCK 9 . 455The reason for this asymmetry is that 456.Xr vn_lock 9 457is a wrapper for 458.Xr VOP_LOCK 9 459with extra checks, while the unlocking step usually does not need 460additional checks and thus has no wrapper. 461.Pp 462The vnode locking operation is complicated because it is used for many 463purposes. 464Sometimes it is used to bundle a series of vnode operations (see 465.Xr vnodeops 9 ) 466into an atomic group. 467Many file systems rely on it to prevent race conditions in updating 468file system type specific data structures rather than using their 469own private locks. 470The vnode lock can operate as a multiple-reader (shared-access lock) 471or single-writer lock (exclusive access lock), however many current file 472system implementations were written assuming only single-writer 473locking. 474Multiple-reader locking functions equivalently only in the presence 475of big-lock SMP locking or a uni-processor machine. 476The lock may be held while sleeping. 477While the 478.Em v_vnlock 479is acquired, the holder is guaranteed that the vnode will not be 480reclaimed or invalidated. 481Most file system functions require that you hold the vnode lock on entry. 482See 483.Xr lock 9 484for details on the kernel locking API. 485.Pp 486For leaf file systems (such as ffs, lfs, msdosfs, etc), 487.Em v_vnlock 488will point to 489.Em v_lock . 490For stacked file systems, 491.Em v_vnlock 492will generally point to 493.Em v_vlock 494of the lowest file system. 495Additionally, the implementation of the vnode lock is the 496responsibility of the individual file systems and 497.Em v_vnlock 498may also be NULL indicating that a leaf node does not export a lock 499for vnode locking. 500In this case, stacked file systems (such as nullfs) must call the 501underlying file system directly for locking. 502.Pp 503Each file system underlying a vnode allocates its own private area and 504hangs it from 505.Em v_data . 506.Pp 507Most functions discussed in this page that operate on vnodes cannot be 508called from interrupt context. 509The members 510.Em v_numoutput , 511.Em v_holdcnt , 512.Em v_dirtyblkhd , 513.Em v_cleanblkhd , 514.Em v_freelist , 515and 516.Em v_synclist 517are modified in interrupt context and must be protected by 518.Xr splbio 9 519unless it is certain that there is no chance an interrupt handler will 520modify them. 521The vnode lock must not be acquired within interrupt context. 522.Sh FUNCTIONS 523.Bl -tag -width compact 524.It Fn vcount "vp" 525Calculate the total number of reference counts to a special device 526with vnode 527.Fa vp . 528.It Fn vref "vp" 529Increment 530.Em v_usecount 531of the vnode 532.Em vp . 533Any kernel thread system which uses a vnode (e.g., during the operation 534of some algorithm or to store in a data structure) should call 535.Fn vref . 536.It Fn VREF "vp" 537This function is an alias for 538.Fn vref . 539.It Fn vrele "vp" 540Decrement 541.Em v_usecount 542of unlocked vnode 543.Em vp . 544Any code in the system which is using a vnode should call 545.Fn vrele 546when it is finished with the vnode. 547If 548.Em v_usecount 549of the vnode reaches zero and 550.Em v_holdcnt 551is greater than zero, the vnode is placed on the holdlist. 552If both 553.Em v_usecount 554and 555.Em v_holdcnt 556are zero, the vnode is placed on the freelist. 557.It Fn vget "vp" "lockflags" 558Reclaim vnode 559.Fa vp 560from the freelist, increment its reference count and lock it. 561The argument 562.Fa lockflags 563specifies the 564.Xr lockmgr 9 565flags used to lock the vnode. 566If the VXLOCK is set in 567.Fa vp Ns 's 568.Em v_flag , 569vnode 570.Fa vp 571is being recycled in 572.Fn vgone 573and the calling thread sleeps until the transition is complete. 574When it is awakened, an error is returned to indicate that the vnode is 575no longer usable (possibly having been recycled to a new file system type). 576.It Fn vput "vp" 577Unlock vnode 578.Fa vp 579and decrement its 580.Em v_usecount . 581Depending on the reference counts, move the vnode to the holdlist or 582the freelist. 583This operation is functionally equivalent to calling 584.Xr VOP_UNLOCK 9 585followed by 586.Fn vrele . 587.It Fn vhold "vp" 588Mark the vnode 589.Fa vp 590as active by incrementing 591.Em vp-\*[Gt]v_holdcnt 592and moving the vnode from the freelist to the holdlist. 593Once on the holdlist, the vnode will not be recycled until it is 594released with 595.Fn holdrele . 596.It Fn VHOLD "vp" 597This function is an alias for 598.Fn vhold . 599.It Fn holdrele "vp" 600Mark the vnode 601.Fa vp 602as inactive by decrementing 603.Em vp-\*[Gt]v_holdcnt 604and moving the vnode from the holdlist to the freelist. 605.It Fn HOLDRELE "vp" 606This function is an alias for 607.Fn holdrele . 608.It Fn getnewvnode "tag" "mp" "vops" "vpp" 609Retrieve the next vnode from the freelist. 610.Fn getnewvnode 611must choose whether to allocate a new vnode or recycle an existing 612one. 613The criterion for allocating a new one is that the total number of 614vnodes is less than the number desired or there are no vnodes on either 615free list. 616Generally only vnodes that have no buffers associated with them are 617recycled and the next vnode from the freelist is retrieved. 618If the freelist is empty, vnodes on the holdlist are considered. 619The new vnode is returned in the address specified by 620.Fa vpp . 621.Pp 622The argument 623.Fa mp 624is the mount point for the file system requested the new vnode. 625Before retrieving the new vnode, the file system is checked if it is 626busy (such as currently unmounting). 627An error is returned if the file system is unmounted. 628.Pp 629The argument 630.Fa tag 631is the vnode tag assigned to 632.Fa *vpp-\*[Gt]v_tag . 633The argument 634.Fa vops 635is the vnode operations vector of the file system requesting the new 636vnode. 637If a vnode is successfully retrieved zero is returned, otherwise an 638appropriate error code is returned. 639.It Fn ungetnewvnode "vp" 640Undo the operation of 641.Fn getnewvnode . 642The argument 643.Fa vp 644is the vnode to return to the freelist. 645This function is needed for 646.Xr VFS_VGET 9 647which may need to push back a vnode in case of a locking race 648condition. 649.It Fn vrecycle "vp" "inter_lkp" "l" 650Recycle the unused vnode 651.Fa vp 652to the front of the freelist. 653.Fn vrecycle 654is a null operation if the reference count is greater than zero. 655.It Fn vgone "vp" 656Eliminate all activity associated with the unlocked vnode 657.Fa vp 658in preparation for recycling. 659.It Fn vgonel "vp" "p" 660Eliminate all activity associated with the locked vnode 661.Fa vp 662in preparation for recycling. 663.It Fn vflush "mp" "skipvp" "flags" 664Remove any vnodes in the vnode table belonging to mount point 665.Fa mp . 666If 667.Fa skipvp 668is not NULL it is exempt from being flushed. 669The argument 670.Fa flags 671is a set of flags modifying the operation of 672.Fn vflush . 673If FORCECLOSE is not specified, there should not be any active vnodes and 674the error 675.Er EBUSY 676is returned if any are found (this is a user error, not a system error). 677If FORCECLOSE is specified, active vnodes that are found are detached. 678If WRITECLOSE is set, only flush out regular file vnodes open for 679writing. 680SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped. 681.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 682Do access checking by comparing the file's permissions to the caller's 683desired access type 684.Fa acc_mode 685and credentials 686.Fa cred . 687.It Fn checkalias "vp" "nvp_rdev" "mp" 688Check to see if the new vnode 689.Fa vp 690represents a special device for which another vnode represents the 691same device. 692If such an alias exists, the existing contents and the aliased vnode 693are deallocated. 694The caller is responsible for filling the new vnode with its new contents. 695.It Fn bdevvp "dev" "vpp" 696Create a vnode for a block device. 697.Fn bdevvp 698is used for root file systems, swap areas and for memory file system 699special devices. 700.It Fn cdevvp "dev" "vpp" 701Create a vnode for a character device. 702.Fn cdevvp 703is used for the console and kernfs special devices. 704.It Fn vfinddev "dev" "vtype" "vpp" 705Lookup a vnode by device number. 706The vnode is returned in the address specified by 707.Fa vpp . 708.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 709Reclaim all vnodes that correspond to the specified minor number range 710.Fa minl 711to 712.Fa minh 713(endpoints inclusive) of the specified major 714.Fa maj . 715.It Fn vwakeup "bp" 716Update outstanding I/O count 717.Em vp-\*[Gt]v_numoutput 718for the vnode 719.Em bp-\*[Gt]b_vp 720and do a wakeup if requested and 721.Em vp-\*[Gt]vflag 722has VBWAIT set. 723.It Fn vflushbuf "vp" "sync" 724Flush all dirty buffers to disk for the file with the locked vnode 725.Fa vp . 726The argument 727.Fa sync 728specifies whether the I/O should be synchronous and 729.Fn vflushbuf 730will sleep until 731.Em vp-\*[Gt]v_numoutput 732is zero and 733.Em vp-\*[Gt]v_dirtyblkhd 734is empty. 735.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo" 736Flush out and invalidate all buffers associated with locked vnode 737.Fa vp . 738The argument 739.Fa l 740and 741.Fa cred 742specified the calling process and its credentials. 743The 744.Xr ltsleep 9 745flag and timeout are specified by the arguments 746.Fa slpflag 747and 748.Fa slptimeo 749respectively. 750If the operation is successful zero is returned, otherwise an 751appropriate error code is returned. 752.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 753Destroy any in-core buffers past the file truncation length for the 754locked vnode 755.Fa vp . 756The truncation length is specified by 757.Fa lbn . 758.Fn vtruncbuf 759will sleep while the I/O is performed, The 760.Xr ltsleep 9 761flag and timeout are specified by the arguments 762.Fa slpflag 763and 764.Fa slptimeo 765respectively. 766If the operation is successful zero is returned, otherwise an 767appropriate error code is returned. 768.It Fn vprint "label" "vp" 769This function is used by the kernel to dump vnode information during a 770panic. 771It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 772The argument 773.Fa label 774is a string to prefix the information dump of vnode 775.Fa vp . 776.El 777.Sh CODE REFERENCES 778This section describes places within the 779.Nx 780source tree where actual code implementing or using the vnode 781framework can be found. 782All pathnames are relative to 783.Pa /usr/src . 784.Pp 785The vnode framework is implemented within the file 786.Pa sys/kern/vfs_subr.c . 787.Sh SEE ALSO 788.Xr intro 9 , 789.Xr lock 9 , 790.Xr namecache 9 , 791.Xr namei 9 , 792.Xr uvm 9 , 793.Xr vattr 9 , 794.Xr vfs 9 , 795.Xr vfsops 9 , 796.Xr vnodeops 9 , 797.Xr vnsubr 9 798.Sh BUGS 799The locking protocol is inconsistent. 800Many vnode operations are passed locked vnodes on entry but release 801the lock before they exit. 802The locking protocol is used in some places to attempt to make a 803series of operations atomic (e.g., access check then operation). 804This does not work for non-local file systems that do not support locking 805(e.g., NFS). 806The 807.Nm 808interface would benefit from a simpler locking protocol. 809