1.\" $NetBSD: vnode.9,v 1.74 2017/01/02 10:33:28 hannken 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 January 2, 2017 31.Dt VNODE 9 32.Os 33.Sh NAME 34.Nm vnode , 35.Nm vref , 36.Nm vrele , 37.Nm vrele_async , 38.Nm vput , 39.Nm vhold , 40.Nm holdrele , 41.Nm vcache_get , 42.Nm vcache_new , 43.Nm vcache_rekey_enter , 44.Nm vcache_rekey_exit , 45.Nm vrecycle , 46.Nm vgone , 47.Nm vgonel , 48.Nm vdead_check , 49.Nm vflush , 50.Nm vaccess , 51.Nm bdevvp , 52.Nm cdevvp , 53.Nm vfinddev , 54.Nm vdevgone , 55.Nm vwakeup , 56.Nm vflushbuf , 57.Nm vinvalbuf , 58.Nm vtruncbuf , 59.Nm vprint 60.Nd kernel representation of a file or directory 61.Sh SYNOPSIS 62.In sys/param.h 63.In sys/vnode.h 64.Ft void 65.Fn vref "struct vnode *vp" 66.Ft void 67.Fn vrele "struct vnode *vp" 68.Ft void 69.Fn vrele_async "struct vnode *vp" 70.Ft void 71.Fn vput "struct vnode *vp" 72.Ft void 73.Fn vhold "struct vnode *vp" 74.Ft void 75.Fn holdrele "struct vnode *vp" 76.Ft int 77.Fn vcache_get "struct mount *mp" "const void *key" "size_t key_len" "struct vnode **vpp" 78.Ft int 79.Fn vcache_new "struct mount *mp" "struct vnode *dvp" "struct vattr *vap" "kauth_cred_t cred" "struct vnode **vpp" 80.Ft int 81.Fn vcache_rekey_enter "struct mount *mp" "struct vnode *vp" "const void *old_key" "size_t old_key_len" "const void *new_key" "size_t new_key_len" 82.Ft void 83.Fn vcache_rekey_exit "struct mount *mp" "struct vnode *vp" "const void *old_key" "size_t old_key_len" "const void *new_key" "size_t new_key_len" 84.Ft int 85.Fn vrecycle "struct vnode *vp" 86.Ft void 87.Fn vgone "struct vnode *vp" 88.Ft void 89.Fn vgonel "struct vnode *vp" "struct lwp *l" 90.Ft int 91.Fn vdead_check "struct vnode *vp" "int flags" 92.Ft int 93.Fn vflush "struct mount *mp" "struct vnode *skipvp" "int flags" 94.Ft int 95.Fn vaccess "enum vtype type" "mode_t file_mode" "uid_t uid" "gid_t gid" "mode_t acc_mode" "kauth_cred_t cred" 96.Ft int 97.Fn bdevvp "dev_t dev" "struct vnode **vpp" 98.Ft int 99.Fn cdevvp "dev_t dev" "struct vnode **vpp" 100.Ft int 101.Fn vfinddev "dev_t dev" "enum vtype" "struct vnode **vpp" 102.Ft void 103.Fn vdevgone "int maj" "int minl" "int minh" "enum vtype type" 104.Ft void 105.Fn vwakeup "struct buf *bp" 106.Ft int 107.Fn vflushbuf "struct vnode *vp" "int sync" 108.Ft int 109.Fn vinvalbuf "struct vnode *vp" "int flags" "kauth_cred_t cred" "struct lwp *l" "int slpflag" "int slptimeo" 110.Ft int 111.Fn vtruncbuf "struct vnode *vp" "daddr_t lbn" "int slpflag" "int slptimeo" 112.Ft void 113.Fn vprint "const char *label" "struct vnode *vp" 114.Sh DESCRIPTION 115A 116.Em vnode 117represents an on-disk file in use by the system. 118Each 119.Xr vfs 9 120file system provides a set of 121.Xr vnodeops 9 122operations on vnodes, invoked by file-system-independent system calls 123and supported by file-system-independent library routines. 124.Pp 125Each mounted file system provides a vnode for the root of the file 126system, via 127.Xr VFS_ROOT 9 . 128Other vnodes are obtained by 129.Xr VOP_LOOKUP 9 . 130Users of vnodes usually invoke these indirectly via 131.Xr namei 9 132to obtain vnodes from paths. 133.Pp 134Each file system usually maintains a cache mapping recently used inode 135numbers, or the equivalent, to vnodes, and a cache mapping recently 136used file names to vnodes. 137If memory is scarce, the system may decide to 138.Em reclaim 139an unused cached vnode, calling 140.Xr VOP_RECLAIM 9 141to remove it from the caches and to free file-system-specific memory 142associated with it. 143A file system may also choose to immediately reclaim a cached vnode 144once it is unused, in 145.Xr VOP_INACTIVE 9 , 146if the vnode has been deleted on disk. 147.Pp 148When a file system retrieves a vnode from a cache, the vnode may not 149have any users, and another thread in the system may be simultaneously 150deciding to reclaim it. 151Thus, to retrieve a vnode from a cache, one must use 152.Fn vcache_get , 153not 154.Fn vref , 155to acquire the first reference. 156.Pp 157The vnode has the following structure: 158.Bd -literal 159struct vnode { 160 struct uvm_object v_uobj; /* the VM object */ 161 kcondvar_t v_cv; /* synchronization */ 162 voff_t v_size; /* size of file */ 163 voff_t v_writesize; /* new size after write */ 164 int v_iflag; /* VI_* flags */ 165 int v_vflag; /* VV_* flags */ 166 int v_uflag; /* VU_* flags */ 167 int v_numoutput; /* # of pending writes */ 168 int v_writecount; /* ref count of writers */ 169 int v_holdcnt; /* page & buffer refs */ 170 int v_synclist_slot; /* synclist slot index */ 171 struct mount *v_mount; /* ptr to vfs we are in */ 172 int (**v_op)(void *); /* vnode operations vector */ 173 TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ 174 struct buflists v_cleanblkhd; /* clean blocklist head */ 175 struct buflists v_dirtyblkhd; /* dirty blocklist head */ 176 TAILQ_ENTRY(vnode) v_synclist; /* vnodes with dirty bufs */ 177 LIST_HEAD(, namecache) v_dnclist; /* namecaches (children) */ 178 LIST_HEAD(, namecache) v_nclist; /* namecaches (parent) */ 179 union { 180 struct mount *vu_mountedhere;/* ptr to vfs (VDIR) */ 181 struct socket *vu_socket; /* unix ipc (VSOCK) */ 182 struct specnode *vu_specnode; /* device (VCHR, VBLK) */ 183 struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ 184 struct uvm_ractx *vu_ractx; /* read-ahead ctx (VREG) */ 185 } v_un; 186 enum vtype v_type; /* vnode type */ 187 enum vtagtype v_tag; /* type of underlying data */ 188 struct vnlock v_lock; /* lock for this vnode */ 189 void *v_data; /* private data for fs */ 190 struct klist v_klist; /* notes attached to vnode */ 191}; 192.Ed 193.Pp 194Most members of the vnode structure should be treated as opaque and 195only manipulated using the proper functions. 196There are some rather common exceptions detailed throughout this page. 197.Pp 198Files and file systems are inextricably linked with the virtual memory 199system and 200.Em v_uobj 201contains the data maintained by the virtual memory system. 202For compatibility with code written before the integration of 203.Xr uvm 9 204into 205.Nx , 206C-preprocessor directives are used to alias the members of 207.Em v_uobj . 208.Pp 209Vnode flags are recorded by 210.Em v_iflag , 211.Em v_vflag 212and 213.Em v_uflag . 214Valid flags are: 215.Pp 216.Bl -tag -offset indent -width ".Dv VI_WRMAPDIRTY" -compact 217.It Dv VV_ROOT 218This vnode is the root of its file system. 219.It Dv VV_SYSTEM 220This vnode is being used by the kernel; only used to skip quota files in 221.Fn vflush . 222.It Dv VV_ISTTY 223This vnode represents a tty; used when reading dead vnodes. 224.It Dv VV_MAPPED 225This vnode might have user mappings. 226.It Dv VV_MPSAFE 227This file system is MP safe. 228.It Dv VV_LOCKSWORK 229This vnode's file system supports locking. 230.It Dv VI_TEXT 231This vnode is a pure text prototype. 232.It Dv VI_EXECMAP 233This vnode has executable mappings. 234.It Dv VI_WRMAP 235This vnode might have PROT_WRITE user mappings. 236.It Dv VI_WRMAPDIRTY 237This vnode might have dirty pages due to 238.Dv VWRITEMAP . 239.It Dv VI_XLOCK 240This vnode is currently locked to change underlying type. 241.It Dv VI_ONWORKLST 242This vnode is on syncer work-list. 243.It Dv VI_MARKER 244A dummy marker vnode. 245.It Dv VI_CLEAN 246This vnode has been reclaimed and is no longer attached to a file system. 247.It Dv VU_DIROP 248This vnode is involved in a directory operation. 249This flag is used exclusively by LFS. 250.El 251.Pp 252The 253.Dv VI_XLOCK 254flag is used to prevent multiple processes from entering 255the vnode reclamation code. 256It is also used as a flag to indicate that reclamation is in progress. 257Before 258.Em v_iflag 259can be modified, the 260.Em v_interlock 261mutex must be acquired. 262See 263.Xr lock 9 264for details on the kernel locking API. 265.Pp 266Each vnode has three reference counts: 267.Em v_usecount , 268.Em v_writecount 269and 270.Em v_holdcnt . 271The first is the number of active references within the 272kernel to the vnode. 273This count is maintained by 274.Fn vref , 275.Fn vrele , 276.Fn vrele_async , 277and 278.Fn vput . 279The second is the number of active references within the kernel to the 280vnode performing write access to the file. 281It is maintained by the 282.Xr open 2 283and 284.Xr close 2 285system calls. 286The third is the number of references within the kernel 287requiring the vnode to remain active and not be recycled. 288This count is maintained by 289.Fn vhold 290and 291.Fn holdrele . 292When both the 293.Em v_usecount 294and 295.Em v_holdcnt 296reach zero, the vnode is cached. 297The transition from the cache is handled by a kernel thread and 298.Fn vrecycle . 299Access to 300.Em v_usecount , 301.Em v_writecount 302and 303.Em v_holdcnt 304is also protected by the 305.Em v_interlock 306mutex. 307.Pp 308The number of pending synchronous and asynchronous writes on the 309vnode are recorded in 310.Em v_numoutput . 311It is used by 312.Xr fsync 2 313to wait for all writes to complete before returning to the user. 314Its value must only be modified at splbio (see 315.Xr spl 9 ) . 316It does not track the number of dirty buffers attached to the 317vnode. 318.Pp 319.Em v_dnclist 320and 321.Em v_nclist 322are used by 323.Xr namecache 9 324to maintain the list of associated entries so that 325.Xr cache_purge 9 326can purge them. 327.Pp 328The link to the file system which owns the vnode is recorded by 329.Em v_mount . 330See 331.Xr vfsops 9 332for further information of file system mount status. 333.Pp 334The 335.Em v_op 336pointer points to its vnode operations vector. 337This vector describes what operations can be done to the file associated 338with the vnode. 339The system maintains one vnode operations vector for each file system 340type configured into the kernel. 341The vnode operations vector contains a pointer to a function for 342each operation supported by the file system. 343See 344.Xr vnodeops 9 345for a description of vnode operations. 346.Pp 347When a user wants a new vnode for another file or wants a valid vnode 348which is cached, 349.Fn vcache_get 350or 351.Fn vcache_new 352is invoked to allocate a vnode and initialize it for the new file. 353.Pp 354The type of object the vnode represents is recorded by 355.Em v_type . 356It is used by generic code to perform checks to ensure operations are 357performed on valid file system objects. 358Valid types are: 359.Pp 360.Bl -tag -offset indent -width VFIFO -compact 361.It Dv VNON 362The vnode has no type. 363.It Dv VREG 364The vnode represents a regular file. 365.It Dv VDIR 366The vnode represents a directory. 367.It Dv VBLK 368The vnode represents a block special device. 369.It Dv VCHR 370The vnode represents a character special device. 371.It Dv VLNK 372The vnode represents a symbolic link. 373.It Dv VSOCK 374The vnode represents a socket. 375.It Dv VFIFO 376The vnode represents a pipe. 377.It Dv VBAD 378The vnode represents a bad file (not currently used). 379.El 380.Pp 381Vnode tag types are used by external programs only (e.g., 382.Xr pstat 8 ) , 383and should never be inspected by the kernel. 384Its use is deprecated 385since new 386.Em v_tag 387values cannot be defined for loadable file systems. 388The 389.Em v_tag 390member is read-only. 391Valid tag types are: 392.Pp 393.Bl -tag -offset indent -width "VT_FILECORE " -compact 394.It Dv VT_NON 395non file system 396.It Dv VT_UFS 397universal file system 398.It Dv VT_NFS 399network file system 400.It Dv VT_MFS 401memory file system 402.It Dv VT_MSDOSFS 403FAT file system 404.It Dv VT_LFS 405log-structured file system 406.It Dv VT_LOFS 407loopback file system 408.It Dv VT_FDESC 409file descriptor file system 410.It Dv VT_NULL 411null file system layer 412.It Dv VT_UMAP 413uid/gid remapping file system layer 414.It Dv VT_KERNFS 415kernel interface file system 416.It Dv VT_PROCFS 417process interface file system 418.It Dv VT_AFS 419AFS file system 420.It Dv VT_ISOFS 421ISO 9660 file system(s) 422.It Dv VT_UNION 423union file system 424.It Dv VT_ADOSFS 425Amiga file system 426.It Dv VT_EXT2FS 427Linux's ext2 file system 428.It Dv VT_CODA 429Coda file system 430.It Dv VT_FILECORE 431filecore file system 432.It Dv VT_NTFS 433Microsoft NT's file system 434.It Dv VT_VFS 435virtual file system 436.It Dv VT_OVERLAY 437overlay file system 438.It Dv VT_SMBFS 439SMB file system 440.It Dv VT_PTYFS 441pseudo-terminal device file system 442.It Dv VT_TMPFS 443efficient memory file system 444.It Dv VT_UDF 445universal disk format file system 446.It Dv VT_SYSVBFS 447systemV boot file system 448.El 449.Pp 450All vnode locking operations use 451.Em v_lock . 452This lock is acquired by calling 453.Xr vn_lock 9 454and released by calling 455.Xr VOP_UNLOCK 9 . 456The reason for this asymmetry is that 457.Xr vn_lock 9 458is a wrapper for 459.Xr VOP_LOCK 9 460with extra checks, while the unlocking step usually does not need 461additional checks and thus has no wrapper. 462.Pp 463The vnode locking operation is complicated because it is used for many 464purposes. 465Sometimes it is used to bundle a series of vnode operations (see 466.Xr vnodeops 9 ) 467into an atomic group. 468Many file systems rely on it to prevent race conditions in updating 469file system type specific data structures rather than using their 470own private locks. 471The vnode lock can operate as a multiple-reader (shared-access lock) 472or single-writer lock (exclusive access lock), however many current file 473system implementations were written assuming only single-writer 474locking. 475Multiple-reader locking functions equivalently only in the presence 476of big-lock SMP locking or a uni-processor machine. 477The lock may be held while sleeping. 478While the 479.Em v_lock 480is acquired, the holder is guaranteed that the vnode will not be 481reclaimed or invalidated. 482Most file system functions require that you hold the vnode lock on entry. 483See 484.Xr lock 9 485for details on the kernel locking API. 486.Pp 487Each file system underlying a vnode allocates its own private area and 488hangs it from 489.Em v_data . 490.Pp 491Most functions discussed in this page that operate on vnodes cannot be 492called from interrupt context. 493The members 494.Em v_numoutput , 495.Em v_holdcnt , 496.Em v_dirtyblkhd , 497.Em v_cleanblkhd , 498and 499.Em v_synclist 500are modified in interrupt context and must be protected by 501.Xr splbio 9 502unless it is certain that there is no chance an interrupt handler will 503modify them. 504The vnode lock must not be acquired within interrupt context. 505.Sh FUNCTIONS 506.Bl -tag -width compact 507.It Fn vref "vp" 508Increment 509.Em v_usecount 510of the vnode 511.Em vp . 512Any kernel thread system which uses a vnode (e.g., during the operation 513of some algorithm or to store in a data structure) should call 514.Fn vref . 515.It Fn vrele "vp" 516Decrement 517.Em v_usecount 518of unlocked vnode 519.Em vp . 520Any code in the system which is using a vnode should call 521.Fn vrele 522when it is finished with the vnode. 523If 524.Em v_usecount 525of the vnode reaches zero and 526.Em v_holdcnt 527is greater than zero, the vnode is placed on the holdlist. 528If both 529.Em v_usecount 530and 531.Em v_holdcnt 532are zero, the vnode is cached. 533.It Fn vrele_async "vp" 534Will asychronously release the vnode in different context than the caller, 535sometime after the call. 536.It Fn vput "vp" 537Legacy convenience routine for unlocking and releasing 538.Fa vp . 539Equivalent to: 540.Bd -literal -offset abcd 541.No "VOP_UNLOCK(" Ns Fa vp Ns Li ");" 542.No "vrele(" Ns Fa vp Ns Li ");" 543.Ed 544.Pp 545New code should prefer using 546.Xr VOP_UNLOCK 9 547and 548.Fn vrele 549directly. 550.It Fn vhold "vp" 551Mark the vnode 552.Fa vp 553as active by incrementing 554.Em vp-\*[Gt]v_holdcnt . 555Once held, the vnode will not be recycled until it is 556released with 557.Fn holdrele . 558.It Fn holdrele "vp" 559Mark the vnode 560.Fa vp 561as inactive by decrementing 562.Em vp-\*[Gt]v_holdcnt . 563.It Fn vcache_get "mp" "key" "key_len" "vpp" 564Allocate a new vnode. 565The new vnode is returned referenced in the address specified by 566.Fa vpp . 567.Pp 568The argument 569.Fa mp 570is the mount point for the file system to lookup the file in. 571.Pp 572The arguments 573.Fa key 574and 575.Fa key_len 576uniquely identify the file in the file system. 577.Pp 578If a vnode is successfully retrieved zero is returned, otherwise an 579appropriate error code is returned. 580.It Fn vcache_new "mp" "dvp" "vap" "cred" "vpp" 581Allocate a new vnode with a new file. 582The new vnode is returned referenced in the address specified by 583.Fa vpp . 584.Pp 585The argument 586.Fa mp 587is the mount point for the file system to create the file in. 588.Pp 589The argument 590.Fa dvp 591points to the directory to create the file in. 592.Pp 593The argument 594.Fa vap 595points to the attributes for the file to create. 596.Pp 597The argument 598.Fa cred 599holds the credentials for the file to create. 600.Pp 601If a vnode is successfully created zero is returned, otherwise an 602appropriate error code is returned. 603.It Fn vcache_rekey_enter "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len" 604Prepare to change the key of a cached vnode. 605.Pp 606The argument 607.Fa mp 608is the mount point for the file system the vnode 609.Fa vp 610resides in. 611.Pp 612The arguments 613.Fa old_key 614and 615.Fa old_key_len 616identify the cached vnode. 617.Pp 618The arguments 619.Fa new_key 620and 621.Fa new_key_len 622will identify the vnode after rename. 623.Pp 624If the new key already exists 625.Er EEXIST 626is returned, otherwise zero is returned. 627.It Fn vcache_rekey_exit "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len" 628Finish rename after calling 629.Fn vcache_rekey_enter . 630.It Fn vrecycle "vp" 631Recycle the referenced vnode 632.Fa vp 633if this is the last reference. 634.Fn vrecycle 635is a null operation if the reference count is greater than one. 636.It Fn vgone "vp" 637Eliminate all activity associated with the unlocked vnode 638.Fa vp 639in preparation for recycling. 640.It Fn vgonel "vp" "p" 641Eliminate all activity associated with the locked vnode 642.Fa vp 643in preparation for recycling. 644.It Fn vdead_check "vp" "flags" 645Check the vnode 646.Fa vp 647for being or becoming dead. 648Returns 649.Er ENOENT 650for a dead vnode and zero otherwise. 651If 652.Fa flags 653is 654.Dv VDEAD_NOWAIT 655it will return 656.Er EBUSY 657if the vnode is becoming dead and the function will not sleep. 658.Pp 659Whenever this function returns a non-zero value all future calls 660for this 661.Fa vp 662will also return a non-zero value. 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 669.Dv NULL 670it is exempt from being flushed. 671The argument 672.Fa flags 673is a set of flags modifying the operation of 674.Fn vflush . 675If 676.Dv FORCECLOSE 677is not specified, there should not be any active vnodes and 678the error 679.Er EBUSY 680is returned if any are found (this is a user error, not a system error). 681If 682.Dv FORCECLOSE 683is specified, active vnodes that are found are detached. 684If 685.Dv WRITECLOSE 686is set, only flush out regular file vnodes open for writing. 687SKIPSYSTEM causes any vnodes marked 688.Dv V_SYSTEM 689to be skipped. 690.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 691Do access checking by comparing the file's permissions to the caller's 692desired access type 693.Fa acc_mode 694and credentials 695.Fa cred . 696.It Fn bdevvp "dev" "vpp" 697Create a vnode for a block device. 698.Fn bdevvp 699is used for root file systems, swap areas and for memory file system 700special devices. 701.It Fn cdevvp "dev" "vpp" 702Create a vnode for a character device. 703.Fn cdevvp 704is used for the console and kernfs special devices. 705.It Fn vfinddev "dev" "vtype" "vpp" 706Lookup a vnode by device number. 707The vnode is referenced and returned in the address specified by 708.Fa vpp . 709.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 710Reclaim all vnodes that correspond to the specified minor number range 711.Fa minl 712to 713.Fa minh 714(endpoints inclusive) of the specified major 715.Fa maj . 716.It Fn vwakeup "bp" 717Update outstanding I/O count 718.Em vp-\*[Gt]v_numoutput 719for the vnode 720.Em bp-\*[Gt]b_vp 721and do a wakeup if requested and 722.Em vp-\*[Gt]vflag 723has 724.Dv VBWAIT 725set. 726.It Fn vflushbuf "vp" "sync" 727Flush all dirty buffers to disk for the file with the locked vnode 728.Fa vp . 729The argument 730.Fa sync 731specifies whether the I/O should be synchronous and 732.Fn vflushbuf 733will sleep until 734.Em vp-\*[Gt]v_numoutput 735is zero and 736.Em vp-\*[Gt]v_dirtyblkhd 737is empty. 738.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo" 739Flush out and invalidate all buffers associated with locked vnode 740.Fa vp . 741The argument 742.Fa l 743and 744.Fa cred 745specified the calling process and its credentials. 746The 747.Xr ltsleep 9 748flag and timeout are specified by the arguments 749.Fa slpflag 750and 751.Fa slptimeo 752respectively. 753If the operation is successful zero is returned, otherwise an 754appropriate error code is returned. 755.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 756Destroy any in-core buffers past the file truncation length for the 757locked vnode 758.Fa vp . 759The truncation length is specified by 760.Fa lbn . 761.Fn vtruncbuf 762will sleep while the I/O is performed, The 763.Xr ltsleep 9 764flag and timeout are specified by the arguments 765.Fa slpflag 766and 767.Fa slptimeo 768respectively. 769If the operation is successful zero is returned, otherwise an 770appropriate error code is returned. 771.It Fn vprint "label" "vp" 772This function is used by the kernel to dump vnode information during a 773panic. 774It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 775The argument 776.Fa label 777is a string to prefix the information dump of vnode 778.Fa vp . 779.El 780.Sh CODE REFERENCES 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