xref: /netbsd-src/share/man/man9/vnode.9 (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1.\"     $NetBSD: vnode.9,v 1.82 2019/01/01 10:06:54 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 January 1, 2019
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" "void *extra" "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
581The argument
582.Fa extra
583allows the caller to pass more information about the file to create.
584.Pp
585If a vnode is successfully created zero is returned, otherwise an
586appropriate error code is returned.
587.It Fn vcache_rekey_enter "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len"
588Prepare to change the key of a cached vnode.
589.Pp
590The argument
591.Fa mp
592is the mount point for the file system the vnode
593.Fa vp
594resides in.
595.Pp
596The arguments
597.Fa old_key
598and
599.Fa old_key_len
600identify the cached vnode.
601.Pp
602The arguments
603.Fa new_key
604and
605.Fa new_key_len
606will identify the vnode after rename.
607.Pp
608If the new key already exists
609.Er EEXIST
610is returned, otherwise zero is returned.
611.It Fn vcache_rekey_exit "mp" "vp" "old_key" "old_key_len" "new_key" "new_key_len"
612Finish rename after calling
613.Fn vcache_rekey_enter .
614.It Fn vrecycle "vp"
615Recycle the referenced vnode
616.Fa vp
617if this is the last reference.
618.Fn vrecycle
619is a null operation if the reference count is greater than one.
620.It Fn vgone "vp"
621Eliminate all activity associated with the unlocked vnode
622.Fa vp
623in preparation for recycling.
624This operation is restricted to suspended file systems.
625See
626.Xr vfs_suspend 9 .
627.It Fn vgonel "vp" "p"
628Eliminate all activity associated with the locked vnode
629.Fa vp
630in preparation for recycling.
631.It Fn vdead_check "vp" "flags"
632Check the vnode
633.Fa vp
634for being or becoming dead.
635Returns
636.Er ENOENT
637for a dead vnode and zero otherwise.
638If
639.Fa flags
640is
641.Dv VDEAD_NOWAIT
642it will return
643.Er EBUSY
644if the vnode is becoming dead and the function will not sleep.
645.Pp
646Whenever this function returns a non-zero value all future calls
647for this
648.Fa vp
649will also return a non-zero value.
650.It Fn vflush "mp" "skipvp" "flags"
651Remove any vnodes in the vnode table belonging to mount point
652.Fa mp .
653If
654.Fa skipvp
655is not
656.Dv NULL
657it is exempt from being flushed.
658The argument
659.Fa flags
660is a set of flags modifying the operation of
661.Fn vflush .
662If
663.Dv FORCECLOSE
664is not specified, there should not be any active vnodes and
665the error
666.Er EBUSY
667is returned if any are found (this is a user error, not a system error).
668If
669.Dv FORCECLOSE
670is specified, active vnodes that are found are detached.
671If
672.Dv WRITECLOSE
673is set, only flush out regular file vnodes open for writing.
674SKIPSYSTEM causes any vnodes marked
675.Dv V_SYSTEM
676to be skipped.
677.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred"
678Do access checking by comparing the file's permissions to the caller's
679desired access type
680.Fa acc_mode
681and credentials
682.Fa cred .
683.It Fn bdevvp "dev" "vpp"
684Create a vnode for a block device.
685.Fn bdevvp
686is used for root file systems, swap areas and for memory file system
687special devices.
688.It Fn cdevvp "dev" "vpp"
689Create a vnode for a character device.
690.Fn cdevvp
691is used for the console and kernfs special devices.
692.It Fn vfinddev "dev" "vtype" "vpp"
693Lookup a vnode by device number.
694The vnode is referenced and returned in the address specified by
695.Fa vpp .
696.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type"
697Reclaim all vnodes that correspond to the specified minor number range
698.Fa minl
699to
700.Fa minh
701(endpoints inclusive) of the specified major
702.Fa maj .
703.It Fn vwakeup "bp"
704Update outstanding I/O count
705.Em vp->v_numoutput
706for the vnode
707.Em bp->b_vp
708and do a wakeup if requested and
709.Em vp->vflag
710has
711.Dv VBWAIT
712set.
713.It Fn vflushbuf "vp" "sync"
714Flush all dirty buffers to disk for the file with the locked vnode
715.Fa vp .
716The argument
717.Fa sync
718specifies whether the I/O should be synchronous and
719.Fn vflushbuf
720will sleep until
721.Em vp->v_numoutput
722is zero and
723.Em vp->v_dirtyblkhd
724is empty.
725.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo"
726Flush out and invalidate all buffers associated with locked vnode
727.Fa vp .
728The argument
729.Fa l
730and
731.Fa cred
732specified the calling process and its credentials.
733The
734.Xr ltsleep 9
735flag and timeout are specified by the arguments
736.Fa slpflag
737and
738.Fa slptimeo
739respectively.
740If the operation is successful zero is returned, otherwise an
741appropriate error code is returned.
742.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo"
743Destroy any in-core buffers past the file truncation length for the
744locked vnode
745.Fa vp .
746The truncation length is specified by
747.Fa lbn .
748.Fn vtruncbuf
749will sleep while the I/O is performed,  The
750.Xr ltsleep 9
751flag and timeout are specified by the arguments
752.Fa slpflag
753and
754.Fa slptimeo
755respectively.
756If the operation is successful zero is returned, otherwise an
757appropriate error code is returned.
758.It Fn vprint "label" "vp"
759This function is used by the kernel to dump vnode information during a
760panic.
761It is only used if the kernel option DIAGNOSTIC is compiled into the kernel.
762The argument
763.Fa label
764is a string to prefix the information dump of vnode
765.Fa vp .
766.El
767.Sh CODE REFERENCES
768The vnode framework is implemented within the file
769.Pa sys/kern/vfs_subr.c .
770.Sh SEE ALSO
771.Xr intro 9 ,
772.Xr lock 9 ,
773.Xr namecache 9 ,
774.Xr namei 9 ,
775.Xr uvm 9 ,
776.Xr vattr 9 ,
777.Xr vfs 9 ,
778.Xr vfsops 9 ,
779.Xr vnodeops 9 ,
780.Xr vnsubr 9
781.Sh BUGS
782The locking protocol is inconsistent.
783Many vnode operations are passed locked vnodes on entry but release
784the lock before they exit.
785The locking protocol is used in some places to attempt to make a
786series of operations atomic (e.g., access check then operation).
787This does not work for non-local file systems that do not support locking
788(e.g., NFS).
789The
790.Nm
791interface would benefit from a simpler locking protocol.
792