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