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