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