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