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