Tue Jun 14 07:49:09 2011 UTC ()
Mark up NULL.


(wiz)
diff -r1.53 -r1.54 src/share/man/man9/vnode.9

cvs diff -r1.53 -r1.54 src/share/man/man9/vnode.9 (switch to unified diff)

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