xref: /netbsd/share/man/man9/vnode.9 (revision c4a72b64)
1.\"     $NetBSD: vnode.9,v 1.11 2002/10/23 06:15:59 gmcgarry Exp $
2.\"
3.\" Copyright (c) 2001 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.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd September 22, 2001
38.Dt VNODE 9
39.Os
40.Sh NAME
41.Nm vnode ,
42.Nm vcount ,
43.Nm vref ,
44.Nm VREF ,
45.Nm vrele ,
46.Nm vget ,
47.Nm vput ,
48.Nm vhold ,
49.Nm VHOLD ,
50.Nm holdrele ,
51.Nm HOLDRELE ,
52.Nm getnewvnode ,
53.Nm ungetnewvnode ,
54.Nm vrecycle ,
55.Nm vgone ,
56.Nm vgonel ,
57.Nm vflush ,
58.Nm vaccess ,
59.Nm checkalias ,
60.Nm bdevvp ,
61.Nm cdevvp ,
62.Nm vfinddev ,
63.Nm vdevgone ,
64.Nm vwakeup ,
65.Nm vflushbuf ,
66.Nm vinvalbuf ,
67.Nm vtruncbuf ,
68.Nm vprint
69.Nd kernel representation of a file or directory
70.Sh SYNOPSIS
71.Fd #include \*[Lt]sys/param.h\*[Gt]
72.Fd #include \*[Lt]sys/vnode.h\*[Gt]
73.Ft int
74.Fn vcount "struct vnode *vp"
75.Ft void
76.Fn vref "struct vnode *vp"
77.Ft void
78.Fn VREF "struct vnode *vp"
79.Ft void
80.Fn vrele "struct vnode *vp"
81.Ft int
82.Fn vget "struct vnode *vp" "int lockflag"
83.Ft void
84.Fn vput "struct vnode *vp"
85.Ft void
86.Fn vhold "struct vnode *vp"
87.Ft void
88.Fn VHOLD "struct vnode *vp"
89.Ft void
90.Fn holdrele "struct vnode *vp"
91.Ft void
92.Fn HOLDRELE "struct vnode *vp"
93.Ft int
94.Fn getnewvnode "enum vtagtype tag" "struct mount *mp" "int (**vops)(void *)" "struct vnode **vpp"
95.Ft void
96.Fn ungetnewvnode "struct vnode *vp"
97.Ft int
98.Fn vrecycle "struct vnode *vp" "struct simplelock *inter_lkp" "struct proc *p"
99.Ft void
100.Fn vgone "struct vnode *vp"
101.Ft void
102.Fn vgonel "struct vnode *vp"
103.Ft int
104.Fn vflush "struct mount *mp" "struct vnode *skipvp" "int flags"
105.Ft int
106.Fn vaccess "enum vtype type" "mode_t file_mode" "uid_t uid" "gid_t gid" "mode_t acc_mode" "struct ucred *cred"
107.Ft struct vnode *
108.Fn checkalias "struct vnode *vp" "dev_t nvp_rdev" "struct mount *mp"
109.Ft int
110.Fn bdevvp "dev_t dev" "struct vnode **vpp"
111.Ft int
112.Fn cdevvp "dev_t dev" "struct vnode **vpp"
113.Ft int
114.Fn vfinddev "dev_t dev" "enum vtype" "struct vnode **vpp"
115.Ft void
116.Fn vdevgone "int maj" "int minl" "int minh" "enum vtype type"
117.Ft void
118.Fn vwakeup "struct buf *bp"
119.Ft void
120.Fn vflushbuf "struct vnode *vp" "int sync"
121.Ft int
122.Fn vinvalbuf "struct vnode *vp" "int flags" "struct ucred *cred" "struct proc *p" "int slpflag" "int slptimeo"
123.Ft int
124.Fn vtruncbuf "struct vnode *vp" "daddr_t lbn" "int slpflag" "int slptimeo"
125.Ft void
126.Fn vprint "char *label" "struct vnode *vp"
127.Sh DESCRIPTION
128The vnode is the focus of all file activity in
129.Nx .
130There is a unique vnode allocated for each active file, directory,
131mounted-on file, fifo, domain socket, symbolic link and device.
132The kernel has no concept of a file's underlying structure and so it
133relies on the information stored in the vnode to describe the file.
134Thus, the vnode associated with a file holds all the administration
135information pertaining to it.
136.Pp
137When a process requests an operation on a file, the
138.Xr vfs 9
139interface passes control to a file system type dependent function to carry
140out the operation.
141If the file system type dependent function finds that a vnode
142representing the file is not in main memory, it dynamically allocates
143a new vnode from the system main memory pool.
144Once allocated, the vnode is attached to the data structure pointer
145associated with the cause of the vnode allocation and it remains
146resident in the main memory until the system decides that it is no
147longer needed and can be recycled.
148.Pp
149The vnode has the following structure:
150.Bd -literal
151struct vnode {
152        struct uvm_object v_uobj;               /* uvm object */
153#define v_usecount      v_uobj.uo_refs
154#define v_interlock     v_uobj.vmobjlock
155        voff_t          v_size;                 /* size of file */
156        int             v_flag;                 /* flags */
157        int             v_numoutput;            /* num pending writes */
158        long            v_writecount;           /* ref count of writers */
159        long            v_holdcnt;              /* page \*[Am] buffer refs */
160        daddr_t         v_lastr;                /* last read */
161        u_long          v_id;                   /* capability id */
162        struct mount    *v_mount;               /* ptr to vfs we are in */
163        int             (**v_op)(void *);       /* vnode ops vector */
164        TAILQ_ENTRY(vnode) v_freelist;          /* vnode freelist */
165        LIST_ENTRY(vnode) v_mntvnodes;          /* vnodes for mount pt */
166        struct buflists v_cleanblkhd;           /* clean blocklist head */
167        struct buflists v_dirtyblkhd;           /* dirty blocklist head */
168        LIST_ENTRY(vnode) v_synclist;           /* dirty vnodes */
169        union {
170                struct mount    *vu_mountedhere;/* ptr to mounted vfs */
171                struct socket   *vu_socket;     /* unix ipc (VSOCK) */
172                struct specinfo *vu_specinfo;   /* device (VCHR, VBLK) */
173                struct fifoinfo *vu_fifoinfo;   /* fifo (VFIFO) */
174        } v_un;
175#define v_mountedhere   v_un.vu_mountedhere
176#define v_socket        v_un.vu_socket
177#define v_specinfo      v_un.vu_specinfo
178#define v_fifoinfo      v_un.vu_fifoinfo
179        struct nqlease  *v_lease;               /* Soft ref to lease */
180        enum vtype      v_type;                 /* vnode type */
181        enum vtagtype   v_tag;                  /* underlying data type */
182        struct lock     v_lock;                 /* lock for this vnode */
183        struct lock     *v_vnlock;              /* ptr to vnode lock */
184        void            *v_data;                /* private data for fs */
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_flag .
205Valid flags are:
206.Pp
207.Bl -tag -offset indent -width VONWORKLST -compact
208.It VROOT
209This vnode is the root of its file system.
210.It VTEXT
211This vnode is a pure text prototype.
212.It VEXECMAP
213This vnode has executable mappings.
214.It VSYSTEM
215This vnode being used by kernel; only used to skip quota files in
216.Fn vflush .
217.It VISTTY
218This vnode represents a tty; used when reading dead vnodes.
219.It VXLOCK
220This vnode is currently locked to change underlying type.
221.It VXWANT
222A process is waiting for this vnode.
223.It VBWAIT
224Waiting for output associated with this vnode to complete.
225.It VALIASED
226This vnode has an alias.
227.It VDIROP
228This vnode is involved in a directory operation.
229This flag is used exclusively by LFS.
230.It VLAYER
231This vnode is on a layered file system.
232.It VONWORKLST
233This vnode is on syncer work-list.
234.It VDIRTY
235This vnode possibly has dirty pages.
236.El
237.Pp
238The VXLOCK flag is used to prevent multiple processes from entering
239the vnode reclamation code.
240It is also used as a flag to indicate that reclamation is in progress.
241The VXWANT flag is set by threads that wish to be awaken when
242reclamation is finished.
243Before
244.Em v_flag
245can be modified, the
246.Em v_interlock
247simplelock must be acquired.
248See
249.Xr lock 9
250for details on the kernel locking API.
251.Pp
252Each vnode has three reference counts:
253.Em v_usecount ,
254.Em v_writecount
255and
256.Em v_holdcnt .
257The first is the number of active references within the
258kernel to the vnode.
259This count is maintained by
260.Fn vref ,
261.Fn vrele ,
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
284.Fn getnewvnode ,
285.Fn ungetnewvnode
286and
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
295simplelock.
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
308Every time a vnode is reassigned to a new file, the vnode capability
309identifier
310.Em v_id
311is changed.
312It is used to maintain the name lookup cache consistency by providing
313a unique \*[Lt]vnode *,v_id\*[Gt] tuple without requiring the cache to
314hold a reference.
315The name lookup cache can later compare the vnode's capability identifier
316to its copy and see if the vnode still points to the same file.
317See
318.Xr namecache 9
319for details on the name lookup cache.
320.Pp
321The link to the file system which owns the vnode is recorded by
322.Em v_mount .
323See
324.Xr vfsops 9
325for further information of file system mount status.
326.Pp
327The
328.Em v_op
329pointer points to its vnode operations vector.
330This vector describes what operations can be done to the file associated
331with the vnode.
332The system maintains one vnode operations vector for each file system
333type configured into the kernel.
334The vnode operations vector contains a pointer to a function for
335each operation supported by the file system.
336See
337.Xr vnodeops 9
338for a description of vnode operations.
339.Pp
340When not in use, vnodes are kept on the freelist through
341.Em v_freelist .
342The vnodes still reference valid files but may be reused to refer to a
343new file at any time.
344Often, these vnodes are also held in caches in the system, such as
345the name lookup cache.
346When a valid vnode which is on the freelist is used again, the user
347must call
348.Fn vget
349to increment the reference count and retrieve it from the freelist.
350When a user wants a new vnode for another file
351.Fn getnewvnode
352is invoked to remove a vnode from the freelist and initialize it for
353the new file.
354.Pp
355The type of object the vnode represents is recorded by
356.Em v_type .
357It is used by generic code to perform checks to ensure operations are
358performed on valid file system objects.
359Valid types are:
360.Pp
361.Bl -tag -offset indent -width VFIFO -compact
362.It VNON
363The vnode has no type.
364.It VREG
365The vnode represents a regular file.
366.It VDIR
367The vnode represents a directory.
368.It VBLK
369The vnode represents a block special device.
370.It VCHR
371The vnode represents a character special device.
372.It VLNK
373The vnode represents a symbolic link.
374.It VSOCK
375The vnode represents a socket.
376.It VFIFO
377The vnode represents a pipe.
378.It VBAD
379The vnode represents a bad file (not currently used).
380.El
381.Pp
382Vnode tag types are used by external programs only (e.g.,
383.Xr pstat 8 ) ,
384and should never be inspected by the kernel.
385Its use is deprecated
386since new
387.Em v_tag
388values cannot be defined for loadable file systems.
389The
390.Em v_tag
391member is read-only.
392Valid tag types are:
393.Pp
394.Bl -tag -offset indent -width "VT_FILECORE " -compact
395.It VT_NON
396non file system
397.It VT_UFS
398universal file system
399.It VT_NFS
400network file system
401.It VT_MFS
402memory file system
403.It VT_MSDOSFS
404FAT file system
405.It VT_LFS
406log-structured file system
407.It VT_LOFS
408loopback file system
409.It VT_FDESC
410file descriptor file system
411.It VT_PORTAL
412portal daemon
413.It VT_NULL
414null file system layer
415.It VT_UMAP
416uid/gid remapping file system layer
417.It VT_KERNFS
418kernel interface file system
419.It VT_PROCFS
420process interface file system
421.It VT_AFS
422AFS file system
423.It VT_ISOFS
424ISO 9660 file system(s)
425.It VT_UNION
426union file system
427.It VT_ADOSFS
428Amiga file system
429.It VT_EXT2FS
430Linux's EXT2 file system
431.It VT_CODA
432Coda file system
433.It VT_FILECORE
434filecore file system
435.It VT_NTFS
436Microsoft NT's file system
437.It VT_VFS
438virtual file system
439.It VT_OVERLAY
440overlay file system
441.It VT_SMBFS
442SMB file system
443.El
444.Pp
445All vnode locking operations use
446.Em v_vnlock .
447This lock is acquired by calling
448.Xr vn_lock 9
449and released by calling
450.Xr VOP_UNLOCK 9 .
451The reason for this asymmetry is that
452.Xr vn_lock 9
453is a wrapper for
454.Xr VOP_LOCK 9
455with extra checks, while the unlocking step usually does not need
456additional checks and thus has no wrapper.
457.Pp
458The vnode locking operation is complicated because it is used for many
459purposes.
460Sometimes it is used to bundle a series of vnode operations (see
461.Xr vnodeops 9 )
462into an atomic group.
463Many file systems rely on it to prevent race conditions in updating
464file system type specific data structures rather than using their
465own private locks.
466The vnode lock operates as a multiple-reader (shared-access lock)
467or single-writer lock (exclusive access lock).
468The lock may be held while sleeping.
469While the
470.Em v_vnlock
471is acquired, the holder is guaranteed that the vnode will not be
472reclaimed or invalidated.
473Most file system functions require that you hold the vnode lock on entry.
474See
475.Xr lock 9
476for details on the kernel locking API.
477.Pp
478For leaf file systems (such as ffs, lfs, msdosfs, etc),
479.Em v_vnlock
480will point to
481.Em v_lock .
482For stacked file systems,
483.Em v_vnlock
484will generally point to
485.Em v_vlock
486of the lowest file system.
487Additionally, the implementation of the vnode lock is the
488responsibility of the individual file systems and
489.Em v_vnlock
490may also be NULL indicating that a leaf node does not export a lock
491for vnode locking.
492In this case, stacked file systems (such as nullfs) must call the
493underlying file system directly for locking.
494.Pp
495Each file system underlying a vnode allocates its own private area and
496hangs it from
497.Em v_data .
498.Pp
499Most functions discussed in this page that operate on vnodes cannot be
500called from interrupt context.
501The members
502.Em v_numoutput ,
503.Em v_holdcnt ,
504.Em v_dirtyblkhd ,
505.Em v_cleanblkhd ,
506.Em v_freelist ,
507and
508.Em v_synclist
509are modified in interrupt context and must be protected by
510.Xr splbio 9
511unless it is certain that there is no chance an interrupt handler will
512modify them.
513The vnode lock must not be acquired within interrupt context.
514.Sh FUNCTIONS
515.Bl -tag -width compact
516.It Fn vcount "vp"
517Calculate the total number of reference counts to a special device
518with vnode
519.Fa vp .
520.It Fn vref "vp"
521Increment
522.Em v_usecount
523of the vnode
524.Em vp .
525Any kernel thread system which uses a vnode (e.g. during the operation
526of some algorithm or to store in a data structure) should call
527.Fn vref .
528.It Fn VREF "vp"
529This function is an alias for
530.Fn vref .
531.It Fn vrele "vp"
532Decrement
533.Em v_usecount
534of unlocked vnode
535.Em vp .
536Any code in the system which is using a vnode should call
537.Fn vrele
538when it is finished with the vnode.
539If
540.Em v_usecount
541of the vnode reaches zero and
542.Em v_holdcnt
543is greater than zero, the vnode is placed on the holdlist.
544If both
545.Em v_usecount
546and
547.Em v_holdcnt
548are zero, the vnode is placed on the freelist.
549.It Fn vget "vp" "lockflags"
550Reclaim vnode
551.Fa vp
552from the freelist, increment its reference count and lock it.
553The argument
554.Fa lockflags
555specifies the
556.Xr lockmgr 9
557flags used to lock the vnode.
558If the VXLOCK is set in
559.Fa vp Ns 's
560.Em v_flag ,
561vnode
562.Fa vp
563is being recycled in
564.Fn vgone
565and the calling thread sleeps until the transition is complete.
566When it is awakened, an error is returned to indicate that the vnode is
567no longer usable (possibly having been recycled to a new file system type).
568.It Fn vput "vp"
569Unlock vnode
570.Fa vp
571and decrement its
572.Em v_usecount .
573Depending of the reference counts, move the vnode to the holdlist or
574the freelist.
575This operation is functionally equivalent to calling
576.Xr VOP_UNLOCK 9
577followed by
578.Fn vrele .
579.It Fn vhold "vp"
580Mark the vnode
581.Fa vp
582as active by incrementing
583.Em vp-\*[Gt]v_holdcnt
584and moving the vnode from the freelist to the holdlist.
585Once on the holdlist, the vnode will not be recycled until it is
586released with
587.Fn holdrele .
588.It Fn VHOLD "vp"
589This function is an alias for
590.Fn vhold .
591.It Fn holdrele "vp"
592Mark the vnode
593.Fa vp
594as inactive by decrementing
595.Em vp-\*[Gt]v_holdcnt
596and moving the vnode from the holdlist to the freelist.
597.It Fn HOLDRELE "vp"
598This function is an alias for
599.Fn holdrele .
600.It Fn getnewvnode "tag" "mp" "vops" "vpp"
601Retrieve the next vnode from the freelist.
602.Fn getnewvnode
603must choose whether to allocate a new vnode or recycle an existing
604one.
605The criterion for allocating a new one is that the total number of
606vnodes is less than the number desired or there are no vnodes on either
607free list.
608Generally only vnodes that have no buffers associated with them are
609recycled and the next vnode from the freelist is retrieved.
610If the freelist is empty, vnodes on the holdlist are considered.
611The new vnode is returned in the address specified by
612.Fa vpp .
613.Pp
614The argument
615.Fa mp
616is the mount point for the file system requested the new vnode.
617Before retrieving the new vnode, the file system is checked if it is
618busy (such as currently unmounting).
619An error is returned if the file system is unmounted.
620.Pp
621The argument
622.Fa tag
623is the vnode tag assigned to
624.Fa *vpp-\*[Gt]v_tag .
625The argument
626.Fa vops
627is the vnode operations vector of the file system requesting the new
628vnode.
629If a vnode is successfully retrieved zero is returned, otherwise an
630appropriate error code is returned.
631.It Fn ungetnewvnode "vp"
632Undo the operation of
633.Fn getnewvnode .
634The argument
635.Fa vp
636is the vnode to return to the freelist.
637This function is needed for
638.Xr VFS_VGET 9
639which may need to push back a vnode in case of a locking race
640condition.
641.It Fn vrecycle "vp" "inter_lkp" "p"
642Recycle the unused vnode
643.Fa vp
644to the front of the freelist.
645.Fn vrecycle
646is a null operation if the reference count is greater than zero.
647.It Fn vgone "vp"
648Eliminate all activity associated with the unlocked vnode
649.Fa vp
650in preparation for recycling.
651.It Fn vgonel "vp"
652Eliminate all activity associated with the locked vnode
653.Fa vp
654in preparation for recycling.
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 NULL it is exempt from being flushed.
661The argument
662.Fa flags
663is a set of flags modifying the operation of
664.Fn vflush .
665If MNT_NOFORCE is specified, there should not be any active vnodes and
666an error is returned if any are found (this is a user error, not a
667system error).
668If MNT_FORCE is specified, active vnodes that are found are detached.
669.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred"
670Do access checking by comparing the file's permissions to the caller's
671desired access type
672.Fa acc_mode
673and credentials
674.Fa cred .
675.It Fn checkalias "vp" "nvp_rdev" "mp"
676Check to see if the new vnode
677.Fa vp
678represents a special device for which another vnode represents the
679same device.
680If such an aliases exists the existing contents and the aliased vnode
681are deallocated.
682The caller is responsible for filling the new vnode with its new contents.
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 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-\*[Gt]v_numoutput
706for the vnode
707.Em bp-\*[Gt]b_vp
708and do a wakeup if requested and
709.Em vp-\*[Gt]vflag
710has VBWAIT set.
711.It Fn vflushbuf "vp" "sync"
712Flush all dirty buffers to disk for the file with the locked vnode
713.Fa vp .
714The argument
715.Fa sync
716specifies whether the I/O should be synchronous and
717.Fn vflushbuf
718will sleep until
719.Em vp-\*[Gt]v_numoutput
720is zero and
721.Em vp-\*[Gt]v_dirtyblkhd
722is empty.
723.It Fn vinvalbuf "vp" "flags" "cred" "p" "slpflag" "slptimeo"
724Flush out and invalidate all buffers associated with locked vnode
725.Fa vp .
726The argument
727.Fa p
728and
729.Fa cred
730specified the calling process and its credentials.
731The
732.Xr sleep 9
733flag and timeout are specified by the arguments
734.Fa slpflag
735and
736.Fa slptimeo
737respectively.
738If the operation is successful zero is returned, otherwise an
739appropriate error code is returned.
740.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo"
741Destroy any in-core buffers past the file truncation length for the
742locked vnode
743.Fa vp .
744The truncation length is specified by
745.Fa lbn .
746.Fn vtruncbuf
747will sleep while the I/O is performed,  The
748.Xr sleep 9
749flag and timeout are specified by the arguments
750.Fa slpflag
751and
752.Fa slptimeo
753respectively.
754If the operation is successful zero is returned, otherwise an
755appropriate error code is returned.
756.It Fn vprint "label" "vp"
757This function is used by the kernel to dump vnode information during a
758panic.
759It is only used if the kernel option DIAGNOSTIC is compiled into the kernel.
760The argument
761.Fa label
762is a string to prefix the information dump of vnode
763.Fa vp .
764.El
765.Sh CODE REFERENCES
766This section describes places within the
767.Nx
768source tree where actual code implementing or utilizing the vnode
769framework can be found.
770All pathnames are relative to
771.Pa /usr/src .
772.Pp
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