xref: /netbsd-src/share/man/man9/vnode.9 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\"     $NetBSD: vnode.9,v 1.22 2004/05/26 23:00:32 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 May 25, 2004
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.In sys/param.h
72.In sys/vnode.h
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 can operate as a multiple-reader (shared-access lock)
467or single-writer lock (exclusive access lock), however many current file
468system implementations were written assuming only single-writer
469locking.
470Multiple-reader locking functions equivalently only in the presence
471of big-lock SMP locking or a uni-processor machine.
472The lock may be held while sleeping.
473While the
474.Em v_vnlock
475is acquired, the holder is guaranteed that the vnode will not be
476reclaimed or invalidated.
477Most file system functions require that you hold the vnode lock on entry.
478See
479.Xr lock 9
480for details on the kernel locking API.
481.Pp
482For leaf file systems (such as ffs, lfs, msdosfs, etc),
483.Em v_vnlock
484will point to
485.Em v_lock .
486For stacked file systems,
487.Em v_vnlock
488will generally point to
489.Em v_vlock
490of the lowest file system.
491Additionally, the implementation of the vnode lock is the
492responsibility of the individual file systems and
493.Em v_vnlock
494may also be NULL indicating that a leaf node does not export a lock
495for vnode locking.
496In this case, stacked file systems (such as nullfs) must call the
497underlying file system directly for locking.
498.Pp
499Each file system underlying a vnode allocates its own private area and
500hangs it from
501.Em v_data .
502.Pp
503Most functions discussed in this page that operate on vnodes cannot be
504called from interrupt context.
505The members
506.Em v_numoutput ,
507.Em v_holdcnt ,
508.Em v_dirtyblkhd ,
509.Em v_cleanblkhd ,
510.Em v_freelist ,
511and
512.Em v_synclist
513are modified in interrupt context and must be protected by
514.Xr splbio 9
515unless it is certain that there is no chance an interrupt handler will
516modify them.
517The vnode lock must not be acquired within interrupt context.
518.Sh FUNCTIONS
519.Bl -tag -width compact
520.It Fn vcount "vp"
521Calculate the total number of reference counts to a special device
522with vnode
523.Fa vp .
524.It Fn vref "vp"
525Increment
526.Em v_usecount
527of the vnode
528.Em vp .
529Any kernel thread system which uses a vnode (e.g., during the operation
530of some algorithm or to store in a data structure) should call
531.Fn vref .
532.It Fn VREF "vp"
533This function is an alias for
534.Fn vref .
535.It Fn vrele "vp"
536Decrement
537.Em v_usecount
538of unlocked vnode
539.Em vp .
540Any code in the system which is using a vnode should call
541.Fn vrele
542when it is finished with the vnode.
543If
544.Em v_usecount
545of the vnode reaches zero and
546.Em v_holdcnt
547is greater than zero, the vnode is placed on the holdlist.
548If both
549.Em v_usecount
550and
551.Em v_holdcnt
552are zero, the vnode is placed on the freelist.
553.It Fn vget "vp" "lockflags"
554Reclaim vnode
555.Fa vp
556from the freelist, increment its reference count and lock it.
557The argument
558.Fa lockflags
559specifies the
560.Xr lockmgr 9
561flags used to lock the vnode.
562If the VXLOCK is set in
563.Fa vp Ns 's
564.Em v_flag ,
565vnode
566.Fa vp
567is being recycled in
568.Fn vgone
569and the calling thread sleeps until the transition is complete.
570When it is awakened, an error is returned to indicate that the vnode is
571no longer usable (possibly having been recycled to a new file system type).
572.It Fn vput "vp"
573Unlock vnode
574.Fa vp
575and decrement its
576.Em v_usecount .
577Depending of the reference counts, move the vnode to the holdlist or
578the freelist.
579This operation is functionally equivalent to calling
580.Xr VOP_UNLOCK 9
581followed by
582.Fn vrele .
583.It Fn vhold "vp"
584Mark the vnode
585.Fa vp
586as active by incrementing
587.Em vp-\*[Gt]v_holdcnt
588and moving the vnode from the freelist to the holdlist.
589Once on the holdlist, the vnode will not be recycled until it is
590released with
591.Fn holdrele .
592.It Fn VHOLD "vp"
593This function is an alias for
594.Fn vhold .
595.It Fn holdrele "vp"
596Mark the vnode
597.Fa vp
598as inactive by decrementing
599.Em vp-\*[Gt]v_holdcnt
600and moving the vnode from the holdlist to the freelist.
601.It Fn HOLDRELE "vp"
602This function is an alias for
603.Fn holdrele .
604.It Fn getnewvnode "tag" "mp" "vops" "vpp"
605Retrieve the next vnode from the freelist.
606.Fn getnewvnode
607must choose whether to allocate a new vnode or recycle an existing
608one.
609The criterion for allocating a new one is that the total number of
610vnodes is less than the number desired or there are no vnodes on either
611free list.
612Generally only vnodes that have no buffers associated with them are
613recycled and the next vnode from the freelist is retrieved.
614If the freelist is empty, vnodes on the holdlist are considered.
615The new vnode is returned in the address specified by
616.Fa vpp .
617.Pp
618The argument
619.Fa mp
620is the mount point for the file system requested the new vnode.
621Before retrieving the new vnode, the file system is checked if it is
622busy (such as currently unmounting).
623An error is returned if the file system is unmounted.
624.Pp
625The argument
626.Fa tag
627is the vnode tag assigned to
628.Fa *vpp-\*[Gt]v_tag .
629The argument
630.Fa vops
631is the vnode operations vector of the file system requesting the new
632vnode.
633If a vnode is successfully retrieved zero is returned, otherwise an
634appropriate error code is returned.
635.It Fn ungetnewvnode "vp"
636Undo the operation of
637.Fn getnewvnode .
638The argument
639.Fa vp
640is the vnode to return to the freelist.
641This function is needed for
642.Xr VFS_VGET 9
643which may need to push back a vnode in case of a locking race
644condition.
645.It Fn vrecycle "vp" "inter_lkp" "p"
646Recycle the unused vnode
647.Fa vp
648to the front of the freelist.
649.Fn vrecycle
650is a null operation if the reference count is greater than zero.
651.It Fn vgone "vp"
652Eliminate all activity associated with the unlocked vnode
653.Fa vp
654in preparation for recycling.
655.It Fn vgonel "vp"
656Eliminate all activity associated with the locked vnode
657.Fa vp
658in preparation for recycling.
659.It Fn vflush "mp" "skipvp" "flags"
660Remove any vnodes in the vnode table belonging to mount point
661.Fa mp .
662If
663.Fa skipvp
664is not NULL it is exempt from being flushed.
665The argument
666.Fa flags
667is a set of flags modifying the operation of
668.Fn vflush .
669If FORCECLOSE is not specified, there should not be any active vnodes and
670the error
671.Er EBUSY
672is returned if any are found (this is a user error, not a system error).
673If FORCECLOSE is specified, active vnodes that are found are detached.
674If WRITECLOSE is set, only flush out regular file vnodes open for
675writing.
676SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped.
677.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred"
678Do access checking by comparing the file's permissions to the caller's
679desired access type
680.Fa acc_mode
681and credentials
682.Fa cred .
683.It Fn checkalias "vp" "nvp_rdev" "mp"
684Check to see if the new vnode
685.Fa vp
686represents a special device for which another vnode represents the
687same device.
688If such an aliases exists the existing contents and the aliased vnode
689are deallocated.
690The caller is responsible for filling the new vnode with its new contents.
691.It Fn bdevvp "dev" "vpp"
692Create a vnode for a block device.
693.Fn bdevvp
694is used for root file systems, swap areas and for memory file system
695special devices.
696.It Fn cdevvp "dev" "vpp"
697Create a vnode for a character device.
698.Fn cdevvp
699is used for the console and kernfs special devices.
700.It Fn vfinddev "dev" "vtype" "vpp"
701Lookup a vnode by device number.
702The vnode is returned in the address specified by
703.Fa vpp .
704.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type"
705Reclaim all vnodes that correspond to the specified minor number range
706.Fa minl
707to
708.Fa minh
709(endpoints inclusive) of the specified major
710.Fa maj .
711.It Fn vwakeup "bp"
712Update outstanding I/O count
713.Em vp-\*[Gt]v_numoutput
714for the vnode
715.Em bp-\*[Gt]b_vp
716and do a wakeup if requested and
717.Em vp-\*[Gt]vflag
718has VBWAIT set.
719.It Fn vflushbuf "vp" "sync"
720Flush all dirty buffers to disk for the file with the locked vnode
721.Fa vp .
722The argument
723.Fa sync
724specifies whether the I/O should be synchronous and
725.Fn vflushbuf
726will sleep until
727.Em vp-\*[Gt]v_numoutput
728is zero and
729.Em vp-\*[Gt]v_dirtyblkhd
730is empty.
731.It Fn vinvalbuf "vp" "flags" "cred" "p" "slpflag" "slptimeo"
732Flush out and invalidate all buffers associated with locked vnode
733.Fa vp .
734The argument
735.Fa p
736and
737.Fa cred
738specified the calling process and its credentials.
739The
740.Xr ltsleep 9
741flag and timeout are specified by the arguments
742.Fa slpflag
743and
744.Fa slptimeo
745respectively.
746If the operation is successful zero is returned, otherwise an
747appropriate error code is returned.
748.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo"
749Destroy any in-core buffers past the file truncation length for the
750locked vnode
751.Fa vp .
752The truncation length is specified by
753.Fa lbn .
754.Fn vtruncbuf
755will sleep while the I/O is performed,  The
756.Xr ltsleep 9
757flag and timeout are specified by the arguments
758.Fa slpflag
759and
760.Fa slptimeo
761respectively.
762If the operation is successful zero is returned, otherwise an
763appropriate error code is returned.
764.It Fn vprint "label" "vp"
765This function is used by the kernel to dump vnode information during a
766panic.
767It is only used if the kernel option DIAGNOSTIC is compiled into the kernel.
768The argument
769.Fa label
770is a string to prefix the information dump of vnode
771.Fa vp .
772.El
773.Sh CODE REFERENCES
774This section describes places within the
775.Nx
776source tree where actual code implementing or using the vnode
777framework can be found.
778All pathnames are relative to
779.Pa /usr/src .
780.Pp
781The vnode framework is implemented within the file
782.Pa sys/kern/vfs_subr.c .
783.Sh SEE ALSO
784.Xr intro 9 ,
785.Xr lock 9 ,
786.Xr namecache 9 ,
787.Xr namei 9 ,
788.Xr uvm 9 ,
789.Xr vattr 9 ,
790.Xr vfs 9 ,
791.Xr vfsops 9 ,
792.Xr vnodeops 9 ,
793.Xr vnsubr 9
794.Sh BUGS
795The locking protocol is inconsistent.
796Many vnode operations are passed locked vnodes on entry but release
797the lock before they exit.
798The locking protocol is used in some places to attempt to make a
799series of operations atomic (e.g., access check then operation).
800This does not work for non-local file systems that do not support locking
801(e.g., NFS).
802The
803.Nm
804interface would benefit from a simpler locking protocol.
805