xref: /netbsd-src/share/man/man9/vnode.9 (revision 9ea3b23dafd978027b28369eda07bf00fb169b23)
1.\"     $NetBSD: vnode.9,v 1.84 2022/03/19 13:53:32 hannken 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 March 19, 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 VI_TEXT
220This vnode is a pure text prototype.
221.It Dv VI_EXECMAP
222This vnode has executable mappings.
223.It Dv VI_WRMAP
224This vnode might have PROT_WRITE user mappings.
225.It Dv VI_WRMAPDIRTY
226This vnode might have dirty pages due to
227.Dv VWRITEMAP .
228.It Dv VI_XLOCK
229This vnode is currently locked to change underlying type.
230.It Dv VI_ONWORKLST
231This vnode is on syncer work-list.
232.It Dv VI_MARKER
233A dummy marker vnode.
234.It Dv VI_CLEAN
235This vnode has been reclaimed and is no longer attached to a file system.
236.It Dv VU_DIROP
237This vnode is involved in a directory operation.
238This flag is used exclusively by LFS.
239.El
240.Pp
241The
242.Dv VI_XLOCK
243flag is used to prevent multiple processes from entering
244the vnode reclamation code.
245It is also used as a flag to indicate that reclamation is in progress.
246Before
247.Em v_iflag
248can be modified, the
249.Em v_interlock
250mutex must be acquired.
251See
252.Xr lock 9
253for details on the kernel locking API.
254.Pp
255Each vnode has three reference counts:
256.Em v_usecount ,
257.Em v_writecount
258and
259.Em v_holdcnt .
260The first is the number of active references within the
261kernel to the vnode.
262This count is maintained by
263.Fn vref ,
264.Fn vrele ,
265.Fn vrele_async ,
266and
267.Fn vput .
268The second is the number of active references within the kernel to the
269vnode performing write access to the file.
270It is maintained by the
271.Xr open 2
272and
273.Xr close 2
274system calls.
275The third is the number of references within the kernel
276requiring the vnode to remain active and not be recycled.
277This count is maintained by
278.Fn vhold
279and
280.Fn holdrele .
281When both the
282.Em v_usecount
283and
284.Em v_holdcnt
285reach zero, the vnode is cached.
286The transition from the cache is handled by a kernel thread and
287.Fn vrecycle .
288Access to
289.Em v_usecount ,
290.Em v_writecount
291and
292.Em v_holdcnt
293is also protected by the
294.Em v_interlock
295mutex.
296.Pp
297The number of pending synchronous and asynchronous writes on the
298vnode are recorded in
299.Em v_numoutput .
300It is used by
301.Xr fsync 2
302to wait for all writes to complete before returning to the user.
303Its value must only be modified at splbio (see
304.Xr spl 9 ) .
305It does not track the number of dirty buffers attached to the
306vnode.
307.Pp
308The link to the file system which owns the vnode is recorded by
309.Em v_mount .
310See
311.Xr vfsops 9
312for further information of file system mount status.
313.Pp
314The
315.Em v_op
316pointer points to its vnode operations vector.
317This vector describes what operations can be done to the file associated
318with the vnode.
319The system maintains one vnode operations vector for each file system
320type configured into the kernel.
321The vnode operations vector contains a pointer to a function for
322each operation supported by the file system.
323See
324.Xr vnodeops 9
325for a description of vnode operations.
326.Pp
327When a user wants a new vnode for another file or wants a valid vnode
328which is cached,
329.Fn vcache_get
330or
331.Fn vcache_new
332is invoked to allocate a vnode and initialize it for the new file.
333.Pp
334The type of object the vnode represents is recorded by
335.Em v_type .
336It is used by generic code to perform checks to ensure operations are
337performed on valid file system objects.
338Valid types are:
339.Pp
340.Bl -tag -offset indent -width VFIFO -compact
341.It Dv VNON
342The vnode has no type.
343.It Dv VREG
344The vnode represents a regular file.
345.It Dv VDIR
346The vnode represents a directory.
347.It Dv VBLK
348The vnode represents a block special device.
349.It Dv VCHR
350The vnode represents a character special device.
351.It Dv VLNK
352The vnode represents a symbolic link.
353.It Dv VSOCK
354The vnode represents a socket.
355.It Dv VFIFO
356The vnode represents a pipe.
357.It Dv VBAD
358The vnode represents a bad file (not currently used).
359.El
360.Pp
361Vnode tag types are used by external programs only (e.g.,
362.Xr pstat 8 ) ,
363and should never be inspected by the kernel.
364Its use is deprecated
365since new
366.Em v_tag
367values cannot be defined for loadable file systems.
368The
369.Em v_tag
370member is read-only.
371Valid tag types are:
372.Pp
373.Bl -tag -offset indent -width "VT_FILECORE " -compact
374.It Dv VT_NON
375non file system
376.It Dv VT_UFS
377universal file system
378.It Dv VT_NFS
379network file system
380.It Dv VT_MFS
381memory file system
382.It Dv VT_MSDOSFS
383FAT file system
384.It Dv VT_LFS
385log-structured file system
386.It Dv VT_LOFS
387loopback file system
388.It Dv VT_FDESC
389file descriptor file system
390.It Dv VT_NULL
391null file system layer
392.It Dv VT_UMAP
393uid/gid remapping file system layer
394.It Dv VT_KERNFS
395kernel interface file system
396.It Dv VT_PROCFS
397process interface file system
398.It Dv VT_AFS
399AFS file system
400.It Dv VT_ISOFS
401ISO 9660 file system(s)
402.It Dv VT_UNION
403union file system
404.It Dv VT_ADOSFS
405Amiga file system
406.It Dv VT_EXT2FS
407Linux's ext2 file system
408.It Dv VT_CODA
409Coda file system
410.It Dv VT_FILECORE
411filecore file system
412.It Dv VT_NTFS
413Microsoft NT's file system
414.It Dv VT_VFS
415virtual file system
416.It Dv VT_OVERLAY
417overlay file system
418.It Dv VT_SMBFS
419SMB file system
420.It Dv VT_PTYFS
421pseudo-terminal device file system
422.It Dv VT_TMPFS
423efficient memory file system
424.It Dv VT_UDF
425universal disk format file system
426.It Dv VT_SYSVBFS
427systemV boot file system
428.El
429.Pp
430The vnode lock is acquired by calling
431.Xr vn_lock 9
432and released by calling
433.Xr VOP_UNLOCK 9 .
434The reason for this asymmetry is that
435.Xr vn_lock 9
436is a wrapper for
437.Xr VOP_LOCK 9
438with extra checks, while the unlocking step usually does not need
439additional checks and thus has no wrapper.
440.Pp
441The vnode locking operation is complicated because it is used for many
442purposes.
443Sometimes it is used to bundle a series of vnode operations (see
444.Xr vnodeops 9 )
445into an atomic group.
446Many file systems rely on it to prevent race conditions in updating
447file system type specific data structures rather than using their
448own private locks.
449The vnode lock can operate as a multiple-reader (shared-access lock)
450or single-writer lock (exclusive access lock), however many current file
451system implementations were written assuming only single-writer
452locking.
453Multiple-reader locking functions equivalently only in the presence
454of big-lock SMP locking or a uni-processor machine.
455The lock may be held while sleeping.
456While the vnode lock is acquired, the holder is guaranteed that the
457vnode will not be reclaimed or invalidated.
458Most file system functions require that you hold the vnode lock on entry.
459See
460.Xr lock 9
461for details on the kernel locking API.
462.Pp
463Each file system underlying a vnode allocates its own private area and
464hangs it from
465.Em v_data .
466.Pp
467Most functions discussed in this page that operate on vnodes cannot be
468called from interrupt context.
469The members
470.Em v_numoutput ,
471.Em v_holdcnt ,
472.Em v_dirtyblkhd ,
473and
474.Em v_cleanblkhd
475are modified in interrupt context and must be protected by
476.Xr splbio 9
477unless it is certain that there is no chance an interrupt handler will
478modify them.
479The vnode lock must not be acquired within interrupt context.
480.Sh FUNCTIONS
481.Bl -tag -width compact
482.It Fn vref "vp"
483Increment
484.Em v_usecount
485of the vnode
486.Em vp .
487Any kernel thread system which uses a vnode (e.g., during the operation
488of some algorithm or to store in a data structure) should call
489.Fn vref .
490.It Fn vrele "vp"
491Decrement
492.Em v_usecount
493of unlocked vnode
494.Em vp .
495Any code in the system which is using a vnode should call
496.Fn vrele
497when it is finished with the vnode.
498If
499.Em v_usecount
500of the vnode reaches zero and
501.Em v_holdcnt
502is greater than zero, the vnode is placed on the holdlist.
503If both
504.Em v_usecount
505and
506.Em v_holdcnt
507are zero, the vnode is cached.
508.It Fn vrele_async "vp"
509Will asynchronously release the vnode in different context than the caller,
510sometime after the call.
511.It Fn vput "vp"
512Legacy convenience routine for unlocking and releasing
513.Fa vp .
514Equivalent to:
515.Bd -literal -offset abcd
516.No "VOP_UNLOCK(" Ns Fa vp Ns Li ");"
517.No "vrele(" Ns Fa vp Ns Li ");"
518.Ed
519.Pp
520New code should prefer using
521.Xr VOP_UNLOCK 9
522and
523.Fn vrele
524directly.
525.It Fn vhold "vp"
526Mark the vnode
527.Fa vp
528as active by incrementing
529.Em vp->v_holdcnt .
530Once held, the vnode will not be recycled until it is
531released with
532.Fn holdrele .
533.It Fn holdrele "vp"
534Mark the vnode
535.Fa vp
536as inactive by decrementing
537.Em vp->v_holdcnt .
538.It Fn vcache_get "mp" "key" "key_len" "vpp"
539Allocate a new vnode.
540The new vnode is returned referenced in the address specified by
541.Fa vpp .
542.Pp
543The argument
544.Fa mp
545is the mount point for the file system to lookup the file in.
546.Pp
547The arguments
548.Fa key
549and
550.Fa key_len
551uniquely identify the file in the file system.
552.Pp
553If a vnode is successfully retrieved zero is returned, otherwise an
554appropriate error code is returned.
555.It Fn vcache_new "mp" "dvp" "vap" "cred" "vpp"
556Allocate a new vnode with a new file.
557The new vnode is returned referenced in the address specified by
558.Fa vpp .
559.Pp
560The argument
561.Fa mp
562is the mount point for the file system to create the file in.
563.Pp
564The argument
565.Fa dvp
566points to the directory to create the file in.
567.Pp
568The argument
569.Fa vap
570points to the attributes for the file to create.
571.Pp
572The argument
573.Fa cred
574holds the credentials for the file to create.
575.Pp
576The argument
577.Fa extra
578allows the caller to pass more information about the file to create.
579.Pp
580If a vnode is successfully created zero is returned, otherwise an
581appropriate error code is returned.
582.It Fn vcache_rekey_enter "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len"
583Prepare to change the key of a cached vnode.
584.Pp
585The argument
586.Fa mp
587is the mount point for the file system the vnode
588.Fa vp
589resides in.
590.Pp
591The arguments
592.Fa old_key
593and
594.Fa old_key_len
595identify the cached vnode.
596.Pp
597The arguments
598.Fa new_key
599and
600.Fa new_key_len
601will identify the vnode after rename.
602.Pp
603If the new key already exists
604.Er EEXIST
605is returned, otherwise zero is returned.
606.It Fn vcache_rekey_exit "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len"
607Finish rename after calling
608.Fn vcache_rekey_enter .
609.It Fn vrecycle "vp"
610Recycle the referenced vnode
611.Fa vp
612if this is the last reference.
613.Fn vrecycle
614is a null operation if the reference count is greater than one.
615.It Fn vgone "vp"
616Eliminate all activity associated with the unlocked vnode
617.Fa vp
618in preparation for recycling.
619This operation is restricted to suspended file systems.
620See
621.Xr vfs_suspend 9 .
622.It Fn vgonel "vp" "p"
623Eliminate all activity associated with the locked vnode
624.Fa vp
625in preparation for recycling.
626.It Fn vdead_check "vp" "flags"
627Check the vnode
628.Fa vp
629for being or becoming dead.
630Returns
631.Er ENOENT
632for a dead vnode and zero otherwise.
633If
634.Fa flags
635is
636.Dv VDEAD_NOWAIT
637it will return
638.Er EBUSY
639if the vnode is becoming dead and the function will not sleep.
640.Pp
641Whenever this function returns a non-zero value all future calls
642for this
643.Fa vp
644will also return a non-zero value.
645.It Fn vflush "mp" "skipvp" "flags"
646Remove any vnodes in the vnode table belonging to mount point
647.Fa mp .
648If
649.Fa skipvp
650is not
651.Dv NULL
652it is exempt from being flushed.
653The argument
654.Fa flags
655is a set of flags modifying the operation of
656.Fn vflush .
657If
658.Dv FORCECLOSE
659is not specified, there should not be any active vnodes and
660the error
661.Er EBUSY
662is returned if any are found (this is a user error, not a system error).
663If
664.Dv FORCECLOSE
665is specified, active vnodes that are found are detached.
666If
667.Dv WRITECLOSE
668is set, only flush out regular file vnodes open for writing.
669SKIPSYSTEM causes any vnodes marked
670.Dv V_SYSTEM
671to be skipped.
672.It Fn bdevvp "dev" "vpp"
673Create a vnode for a block device.
674.Fn bdevvp
675is used for root file systems, swap areas and for memory file system
676special devices.
677.It Fn cdevvp "dev" "vpp"
678Create a vnode for a character device.
679.Fn cdevvp
680is used for the console and kernfs special devices.
681.It Fn vfinddev "dev" "vtype" "vpp"
682Lookup a vnode by device number.
683The vnode is referenced and returned in the address specified by
684.Fa vpp .
685.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type"
686Reclaim all vnodes that correspond to the specified minor number range
687.Fa minl
688to
689.Fa minh
690(endpoints inclusive) of the specified major
691.Fa maj .
692.It Fn vwakeup "bp"
693Update outstanding I/O count
694.Em vp->v_numoutput
695for the vnode
696.Em bp->b_vp
697and do a wakeup if requested and
698.Em vp->vflag
699has
700.Dv VBWAIT
701set.
702.It Fn vflushbuf "vp" "sync"
703Flush all dirty buffers to disk for the file with the locked vnode
704.Fa vp .
705The argument
706.Fa sync
707specifies whether the I/O should be synchronous and
708.Fn vflushbuf
709will sleep until
710.Em vp->v_numoutput
711is zero and
712.Em vp->v_dirtyblkhd
713is empty.
714.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo"
715Flush out and invalidate all buffers associated with locked vnode
716.Fa vp .
717The argument
718.Fa l
719and
720.Fa cred
721specified the calling process and its credentials.
722The
723.Xr ltsleep 9
724flag and timeout are specified by the arguments
725.Fa slpflag
726and
727.Fa slptimeo
728respectively.
729If the operation is successful zero is returned, otherwise an
730appropriate error code is returned.
731.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo"
732Destroy any in-core buffers past the file truncation length for the
733locked vnode
734.Fa vp .
735The truncation length is specified by
736.Fa lbn .
737.Fn vtruncbuf
738will sleep while the I/O is performed,  The
739.Xr ltsleep 9
740flag and timeout are specified by the arguments
741.Fa slpflag
742and
743.Fa slptimeo
744respectively.
745If the operation is successful zero is returned, otherwise an
746appropriate error code is returned.
747.It Fn vprint "label" "vp"
748This function is used by the kernel to dump vnode information during a
749panic.
750It is only used if the kernel option DIAGNOSTIC is compiled into the kernel.
751The argument
752.Fa label
753is a string to prefix the information dump of vnode
754.Fa vp .
755.El
756.Sh CODE REFERENCES
757The vnode framework is implemented within the file
758.Pa sys/kern/vfs_subr.c .
759.Sh SEE ALSO
760.Xr intro 9 ,
761.Xr lock 9 ,
762.Xr namecache 9 ,
763.Xr namei 9 ,
764.Xr uvm 9 ,
765.Xr vattr 9 ,
766.Xr vfs 9 ,
767.Xr vfsops 9 ,
768.Xr vnodeops 9 ,
769.Xr vnsubr 9
770.Sh BUGS
771The locking protocol is inconsistent.
772Many vnode operations are passed locked vnodes on entry but release
773the lock before they exit.
774The locking protocol is used in some places to attempt to make a
775series of operations atomic (e.g., access check then operation).
776This does not work for non-local file systems that do not support locking
777(e.g., NFS).
778The
779.Nm
780interface would benefit from a simpler locking protocol.
781