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