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