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