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