1.\" $NetBSD: vnode.9,v 1.37 2007/06/15 11:42:11 pooka 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.\" 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 June 15, 2007 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 lwp *l" 99.Ft void 100.Fn vgone "struct vnode *vp" 101.Ft void 102.Fn vgonel "struct vnode *vp" "struct lwp *l" 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" "kauth_cred_t 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" "kauth_cred_t cred" "struct lwp *l" "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 "const 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}; 187.Ed 188.Pp 189Most members of the vnode structure should be treated as opaque and 190only manipulated using the proper functions. 191There are some rather common exceptions detailed throughout this page. 192.Pp 193Files and file systems are inextricably linked with the virtual memory 194system and 195.Em v_uobj 196contains the data maintained by the virtual memory system. 197For compatibility with code written before the integration of 198.Xr uvm 9 199into 200.Nx , 201C-preprocessor directives are used to alias the members of 202.Em v_uobj . 203.Pp 204Vnode flags are recorded by 205.Em v_flag . 206Valid flags are: 207.Pp 208.Bl -tag -offset indent -width VONWORKLST -compact 209.It VROOT 210This vnode is the root of its file system. 211.It VTEXT 212This vnode is a pure text prototype. 213.It VSYSTEM 214This vnode is being used by the kernel; only used to skip quota files in 215.Fn vflush . 216.It VISTTY 217This vnode represents a tty; used when reading dead vnodes. 218.It VEXECMAP 219This vnode has executable mappings. 220.It VWRITEMAP 221This vnode might have PROT_WRITE user mappings. 222.It VWRITEMAPDIRTY 223This vnode might have dirty pages due to VWRITEMAP 224.It VLOCKSWORK 225This vnode's file system supports locking. 226.It VXLOCK 227This vnode is currently locked to change underlying type. 228.It VXWANT 229A process is waiting for this vnode. 230.It VBWAIT 231Waiting for output associated with this vnode to complete. 232.It VALIASED 233This vnode has an alias. 234.It VDIROP 235This vnode is involved in a directory operation. 236This flag is used exclusively by LFS. 237.It VLAYER 238This vnode is on a layered file system. 239.It VONWORKLST 240This vnode is on syncer work-list. 241.It VFREEING 242This vnode is being freed. 243.It VMAPPED 244This vnode might have user mappings. 245.El 246.Pp 247The VXLOCK flag is used to prevent multiple processes from entering 248the vnode reclamation code. 249It is also used as a flag to indicate that reclamation is in progress. 250The VXWANT flag is set by threads that wish to be awakened when 251reclamation is finished. 252Before 253.Em v_flag 254can be modified, the 255.Em v_interlock 256simplelock must be acquired. 257See 258.Xr lock 9 259for details on the kernel locking API. 260.Pp 261Each vnode has three reference counts: 262.Em v_usecount , 263.Em v_writecount 264and 265.Em v_holdcnt . 266The first is the number of active references within the 267kernel to the vnode. 268This count is maintained by 269.Fn vref , 270.Fn vrele , 271and 272.Fn vput . 273The second is the number of active references within the kernel to the 274vnode performing write access to the file. 275It is maintained by the 276.Xr open 2 277and 278.Xr close 2 279system calls. 280The third is the number of references within the kernel 281requiring the vnode to remain active and not be recycled. 282This count is maintained by 283.Fn vhold 284and 285.Fn holdrele . 286When both the 287.Em v_usecount 288and 289.Em v_holdcnt 290reach zero, the vnode is recycled to the freelist and may be reused 291for another file. 292The transition to and from the freelist is handled by 293.Fn getnewvnode , 294.Fn ungetnewvnode 295and 296.Fn vrecycle . 297Access to 298.Em v_usecount , 299.Em v_writecount 300and 301.Em v_holdcnt 302is also protected by the 303.Em v_interlock 304simplelock. 305.Pp 306The number of pending synchronous and asynchronous writes on the 307vnode are recorded in 308.Em v_numoutput . 309It is used by 310.Xr fsync 2 311to wait for all writes to complete before returning to the user. 312Its value must only be modified at splbio (see 313.Xr spl 9 ) . 314It does not track the number of dirty buffers attached to the 315vnode. 316.Pp 317.Em v_dnclist 318and 319.Em v_nclist 320are used by 321.Xr namecache 9 322to maintain the list of associated entries so that 323.Xr cache_purge 9 324can purge them. 325.Pp 326The link to the file system which owns the vnode is recorded by 327.Em v_mount . 328See 329.Xr vfsops 9 330for further information of file system mount status. 331.Pp 332The 333.Em v_op 334pointer points to its vnode operations vector. 335This vector describes what operations can be done to the file associated 336with the vnode. 337The system maintains one vnode operations vector for each file system 338type configured into the kernel. 339The vnode operations vector contains a pointer to a function for 340each operation supported by the file system. 341See 342.Xr vnodeops 9 343for a description of vnode operations. 344.Pp 345When not in use, vnodes are kept on the freelist through 346.Em v_freelist . 347The vnodes still reference valid files but may be reused to refer to a 348new file at any time. 349When a valid vnode which is on the freelist is used again, the user 350must call 351.Fn vget 352to increment the reference count and retrieve it from the freelist. 353When a user wants a new vnode for another file, 354.Fn getnewvnode 355is invoked to remove a vnode from the freelist and initialize it for 356the new file. 357.Pp 358The type of object the vnode represents is recorded by 359.Em v_type . 360It is used by generic code to perform checks to ensure operations are 361performed on valid file system objects. 362Valid types are: 363.Pp 364.Bl -tag -offset indent -width VFIFO -compact 365.It VNON 366The vnode has no type. 367.It VREG 368The vnode represents a regular file. 369.It VDIR 370The vnode represents a directory. 371.It VBLK 372The vnode represents a block special device. 373.It VCHR 374The vnode represents a character special device. 375.It VLNK 376The vnode represents a symbolic link. 377.It VSOCK 378The vnode represents a socket. 379.It VFIFO 380The vnode represents a pipe. 381.It VBAD 382The vnode represents a bad file (not currently used). 383.El 384.Pp 385Vnode tag types are used by external programs only (e.g., 386.Xr pstat 8 ) , 387and should never be inspected by the kernel. 388Its use is deprecated 389since new 390.Em v_tag 391values cannot be defined for loadable file systems. 392The 393.Em v_tag 394member is read-only. 395Valid tag types are: 396.Pp 397.Bl -tag -offset indent -width "VT_FILECORE " -compact 398.It VT_NON 399non file system 400.It VT_UFS 401universal file system 402.It VT_NFS 403network file system 404.It VT_MFS 405memory file system 406.It VT_MSDOSFS 407FAT file system 408.It VT_LFS 409log-structured file system 410.It VT_LOFS 411loopback file system 412.It VT_FDESC 413file descriptor file system 414.It VT_PORTAL 415portal daemon 416.It VT_NULL 417null file system layer 418.It VT_UMAP 419uid/gid remapping file system layer 420.It VT_KERNFS 421kernel interface file system 422.It VT_PROCFS 423process interface file system 424.It VT_AFS 425AFS file system 426.It VT_ISOFS 427ISO 9660 file system(s) 428.It VT_UNION 429union file system 430.It VT_ADOSFS 431Amiga file system 432.It VT_EXT2FS 433Linux's EXT2 file system 434.It VT_CODA 435Coda file system 436.It VT_FILECORE 437filecore file system 438.It VT_NTFS 439Microsoft NT's file system 440.It VT_VFS 441virtual file system 442.It VT_OVERLAY 443overlay file system 444.It VT_SMBFS 445SMB file system 446.It VT_PTYFS 447pseudo-terminal device file system 448.It VT_TMPFS 449efficient memory file system 450.It VT_UDF 451universal disk format file system 452.It VT_SYSVBFS 453systemV boot file system 454.El 455.Pp 456All vnode locking operations use 457.Em v_vnlock . 458This lock is acquired by calling 459.Xr vn_lock 9 460and released by calling 461.Xr VOP_UNLOCK 9 . 462The reason for this asymmetry is that 463.Xr vn_lock 9 464is a wrapper for 465.Xr VOP_LOCK 9 466with extra checks, while the unlocking step usually does not need 467additional checks and thus has no wrapper. 468.Pp 469The vnode locking operation is complicated because it is used for many 470purposes. 471Sometimes it is used to bundle a series of vnode operations (see 472.Xr vnodeops 9 ) 473into an atomic group. 474Many file systems rely on it to prevent race conditions in updating 475file system type specific data structures rather than using their 476own private locks. 477The vnode lock can operate as a multiple-reader (shared-access lock) 478or single-writer lock (exclusive access lock), however many current file 479system implementations were written assuming only single-writer 480locking. 481Multiple-reader locking functions equivalently only in the presence 482of big-lock SMP locking or a uni-processor machine. 483The lock may be held while sleeping. 484While the 485.Em v_vnlock 486is acquired, the holder is guaranteed that the vnode will not be 487reclaimed or invalidated. 488Most file system functions require that you hold the vnode lock on entry. 489See 490.Xr lock 9 491for details on the kernel locking API. 492.Pp 493For leaf file systems (such as ffs, lfs, msdosfs, etc), 494.Em v_vnlock 495will point to 496.Em v_lock . 497For stacked file systems, 498.Em v_vnlock 499will generally point to 500.Em v_vlock 501of the lowest file system. 502Additionally, the implementation of the vnode lock is the 503responsibility of the individual file systems and 504.Em v_vnlock 505may also be NULL indicating that a leaf node does not export a lock 506for vnode locking. 507In this case, stacked file systems (such as nullfs) must call the 508underlying file system directly for locking. 509.Pp 510Each file system underlying a vnode allocates its own private area and 511hangs it from 512.Em v_data . 513.Pp 514Most functions discussed in this page that operate on vnodes cannot be 515called from interrupt context. 516The members 517.Em v_numoutput , 518.Em v_holdcnt , 519.Em v_dirtyblkhd , 520.Em v_cleanblkhd , 521.Em v_freelist , 522and 523.Em v_synclist 524are modified in interrupt context and must be protected by 525.Xr splbio 9 526unless it is certain that there is no chance an interrupt handler will 527modify them. 528The vnode lock must not be acquired within interrupt context. 529.Sh FUNCTIONS 530.Bl -tag -width compact 531.It Fn vcount "vp" 532Calculate the total number of reference counts to a special device 533with vnode 534.Fa vp . 535.It Fn vref "vp" 536Increment 537.Em v_usecount 538of the vnode 539.Em vp . 540Any kernel thread system which uses a vnode (e.g., during the operation 541of some algorithm or to store in a data structure) should call 542.Fn vref . 543.It Fn VREF "vp" 544This function is an alias for 545.Fn vref . 546.It Fn vrele "vp" 547Decrement 548.Em v_usecount 549of unlocked vnode 550.Em vp . 551Any code in the system which is using a vnode should call 552.Fn vrele 553when it is finished with the vnode. 554If 555.Em v_usecount 556of the vnode reaches zero and 557.Em v_holdcnt 558is greater than zero, the vnode is placed on the holdlist. 559If both 560.Em v_usecount 561and 562.Em v_holdcnt 563are zero, the vnode is placed on the freelist. 564.It Fn vget "vp" "lockflags" 565Reclaim vnode 566.Fa vp 567from the freelist, increment its reference count and lock it. 568The argument 569.Fa lockflags 570specifies the 571.Xr lockmgr 9 572flags used to lock the vnode. 573If the VXLOCK is set in 574.Fa vp Ns 's 575.Em v_flag , 576vnode 577.Fa vp 578is being recycled in 579.Fn vgone 580and the calling thread sleeps until the transition is complete. 581When it is awakened, an error is returned to indicate that the vnode is 582no longer usable (possibly having been recycled to a new file system type). 583.It Fn vput "vp" 584Unlock vnode 585.Fa vp 586and decrement its 587.Em v_usecount . 588Depending on the reference counts, move the vnode to the holdlist or 589the freelist. 590This operation is functionally equivalent to calling 591.Xr VOP_UNLOCK 9 592followed by 593.Fn vrele . 594.It Fn vhold "vp" 595Mark the vnode 596.Fa vp 597as active by incrementing 598.Em vp-\*[Gt]v_holdcnt 599and moving the vnode from the freelist to the holdlist. 600Once on the holdlist, the vnode will not be recycled until it is 601released with 602.Fn holdrele . 603.It Fn VHOLD "vp" 604This function is an alias for 605.Fn vhold . 606.It Fn holdrele "vp" 607Mark the vnode 608.Fa vp 609as inactive by decrementing 610.Em vp-\*[Gt]v_holdcnt 611and moving the vnode from the holdlist to the freelist. 612.It Fn HOLDRELE "vp" 613This function is an alias for 614.Fn holdrele . 615.It Fn getnewvnode "tag" "mp" "vops" "vpp" 616Retrieve the next vnode from the freelist. 617.Fn getnewvnode 618must choose whether to allocate a new vnode or recycle an existing 619one. 620The criterion for allocating a new one is that the total number of 621vnodes is less than the number desired or there are no vnodes on either 622free list. 623Generally only vnodes that have no buffers associated with them are 624recycled and the next vnode from the freelist is retrieved. 625If the freelist is empty, vnodes on the holdlist are considered. 626The new vnode is returned in the address specified by 627.Fa vpp . 628.Pp 629The argument 630.Fa mp 631is the mount point for the file system requested the new vnode. 632Before retrieving the new vnode, the file system is checked if it is 633busy (such as currently unmounting). 634An error is returned if the file system is unmounted. 635.Pp 636The argument 637.Fa tag 638is the vnode tag assigned to 639.Fa *vpp-\*[Gt]v_tag . 640The argument 641.Fa vops 642is the vnode operations vector of the file system requesting the new 643vnode. 644If a vnode is successfully retrieved zero is returned, otherwise an 645appropriate error code is returned. 646.It Fn ungetnewvnode "vp" 647Undo the operation of 648.Fn getnewvnode . 649The argument 650.Fa vp 651is the vnode to return to the freelist. 652This function is needed for 653.Xr VFS_VGET 9 654which may need to push back a vnode in case of a locking race 655condition. 656.It Fn vrecycle "vp" "inter_lkp" "l" 657Recycle the unused vnode 658.Fa vp 659to the front of the freelist. 660.Fn vrecycle 661is a null operation if the reference count is greater than zero. 662.It Fn vgone "vp" 663Eliminate all activity associated with the unlocked vnode 664.Fa vp 665in preparation for recycling. 666.It Fn vgonel "vp" "p" 667Eliminate all activity associated with the locked vnode 668.Fa vp 669in preparation for recycling. 670.It Fn vflush "mp" "skipvp" "flags" 671Remove any vnodes in the vnode table belonging to mount point 672.Fa mp . 673If 674.Fa skipvp 675is not NULL it is exempt from being flushed. 676The argument 677.Fa flags 678is a set of flags modifying the operation of 679.Fn vflush . 680If FORCECLOSE is not specified, there should not be any active vnodes and 681the error 682.Er EBUSY 683is returned if any are found (this is a user error, not a system error). 684If FORCECLOSE is specified, active vnodes that are found are detached. 685If WRITECLOSE is set, only flush out regular file vnodes open for 686writing. 687SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped. 688.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 689Do access checking by comparing the file's permissions to the caller's 690desired access type 691.Fa acc_mode 692and credentials 693.Fa cred . 694.It Fn checkalias "vp" "nvp_rdev" "mp" 695Check to see if the new vnode 696.Fa vp 697represents a special device for which another vnode represents the 698same device. 699If such an alias exists, the existing contents and the aliased vnode 700are deallocated. 701The caller is responsible for filling the new vnode with its new contents. 702.It Fn bdevvp "dev" "vpp" 703Create a vnode for a block device. 704.Fn bdevvp 705is used for root file systems, swap areas and for memory file system 706special devices. 707.It Fn cdevvp "dev" "vpp" 708Create a vnode for a character device. 709.Fn cdevvp 710is used for the console and kernfs special devices. 711.It Fn vfinddev "dev" "vtype" "vpp" 712Lookup a vnode by device number. 713The vnode is returned in the address specified by 714.Fa vpp . 715.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 716Reclaim all vnodes that correspond to the specified minor number range 717.Fa minl 718to 719.Fa minh 720(endpoints inclusive) of the specified major 721.Fa maj . 722.It Fn vwakeup "bp" 723Update outstanding I/O count 724.Em vp-\*[Gt]v_numoutput 725for the vnode 726.Em bp-\*[Gt]b_vp 727and do a wakeup if requested and 728.Em vp-\*[Gt]vflag 729has VBWAIT set. 730.It Fn vflushbuf "vp" "sync" 731Flush all dirty buffers to disk for the file with the locked vnode 732.Fa vp . 733The argument 734.Fa sync 735specifies whether the I/O should be synchronous and 736.Fn vflushbuf 737will sleep until 738.Em vp-\*[Gt]v_numoutput 739is zero and 740.Em vp-\*[Gt]v_dirtyblkhd 741is empty. 742.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo" 743Flush out and invalidate all buffers associated with locked vnode 744.Fa vp . 745The argument 746.Fa l 747and 748.Fa cred 749specified the calling process and its credentials. 750The 751.Xr ltsleep 9 752flag and timeout are specified by the arguments 753.Fa slpflag 754and 755.Fa slptimeo 756respectively. 757If the operation is successful zero is returned, otherwise an 758appropriate error code is returned. 759.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 760Destroy any in-core buffers past the file truncation length for the 761locked vnode 762.Fa vp . 763The truncation length is specified by 764.Fa lbn . 765.Fn vtruncbuf 766will sleep while the I/O is performed, The 767.Xr ltsleep 9 768flag and timeout are specified by the arguments 769.Fa slpflag 770and 771.Fa slptimeo 772respectively. 773If the operation is successful zero is returned, otherwise an 774appropriate error code is returned. 775.It Fn vprint "label" "vp" 776This function is used by the kernel to dump vnode information during a 777panic. 778It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 779The argument 780.Fa label 781is a string to prefix the information dump of vnode 782.Fa vp . 783.El 784.Sh CODE REFERENCES 785This section describes places within the 786.Nx 787source tree where actual code implementing or using the vnode 788framework can be found. 789All pathnames are relative to 790.Pa /usr/src . 791.Pp 792The vnode framework is implemented within the file 793.Pa sys/kern/vfs_subr.c . 794.Sh SEE ALSO 795.Xr intro 9 , 796.Xr lock 9 , 797.Xr namecache 9 , 798.Xr namei 9 , 799.Xr uvm 9 , 800.Xr vattr 9 , 801.Xr vfs 9 , 802.Xr vfsops 9 , 803.Xr vnodeops 9 , 804.Xr vnsubr 9 805.Sh BUGS 806The locking protocol is inconsistent. 807Many vnode operations are passed locked vnodes on entry but release 808the lock before they exit. 809The locking protocol is used in some places to attempt to make a 810series of operations atomic (e.g., access check then operation). 811This does not work for non-local file systems that do not support locking 812(e.g., NFS). 813The 814.Nm 815interface would benefit from a simpler locking protocol. 816