Sat Feb 22 10:08:12 2014 UTC ()
Update arguments of vrecycle(), description of getnewvnode() and
the vnode flags.


(hannken)
diff -r1.57 -r1.58 src/share/man/man9/vnode.9

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

--- src/share/man/man9/vnode.9 2013/10/29 09:53:51 1.57
+++ src/share/man/man9/vnode.9 2014/02/22 10:08:12 1.58
@@ -1,766 +1,762 @@ @@ -1,766 +1,762 @@
1.\" $NetBSD: vnode.9,v 1.57 2013/10/29 09:53:51 hannken Exp $ 1.\" $NetBSD: vnode.9,v 1.58 2014/02/22 10:08:12 hannken 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 October 29, 2013 30.Dd February 22, 2014
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" 82.Fn vrecycle "struct vnode *vp" "struct kmutex_t *inter_lkp"
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_iflag ,
 187.Em v_vflag
 188and
 189.Em v_uflag .
187Valid flags are: 190Valid flags are:
188.Pp 191.Pp
189.Bl -tag -offset indent -width VONWORKLST -compact 192.Bl -tag -offset indent -width VONWORKLST -compact
190.It VROOT 193.It VV_ROOT
191This vnode is the root of its file system. 194This vnode is the root of its file system.
192.It VTEXT 195.It VV_SYSTEM
193This vnode is a pure text prototype. 
194.It VSYSTEM 
195This vnode is being used by the kernel; only used to skip quota files in 196This vnode is being used by the kernel; only used to skip quota files in
196.Fn vflush . 197.Fn vflush .
197.It VISTTY 198.It VV_ISTTY
198This vnode represents a tty; used when reading dead vnodes. 199This vnode represents a tty; used when reading dead vnodes.
199.It VEXECMAP 200.It VV_MAPPED
 201This vnode might have user mappings.
 202.It VV_MPSAFE
 203This file system is MP safe.
 204.It VV_LOCKSWORK
 205This vnode's file system supports locking.
 206.It VI_TEXT
 207This vnode is a pure text prototype.
 208.It VI_EXECMAP
200This vnode has executable mappings. 209This vnode has executable mappings.
201.It VWRITEMAP 210.It VI_WRMAP
202This vnode might have PROT_WRITE user mappings. 211This vnode might have PROT_WRITE user mappings.
203.It VWRITEMAPDIRTY 212.It VI_WRMAPDIRTY
204This vnode might have dirty pages due to VWRITEMAP 213This vnode might have dirty pages due to VWRITEMAP
205.It VLOCKSWORK 214.It VI_XLOCK
206This vnode's file system supports locking. 
207.It VXLOCK 
208This vnode is currently locked to change underlying type. 215This vnode is currently locked to change underlying type.
209.It VXWANT 216.It VI_ONWORKLST
210A process is waiting for this vnode. 217This vnode is on syncer work-list.
211.It VBWAIT 218.It VI_MARKER
212Waiting for output associated with this vnode to complete. 219A dummy marker vnode.
213.It VALIASED 220.It VI_LAYER
214This vnode has an alias. 221This vnode is on a layered file system.
215.It VDIROP 222.It VI_LOCKSHARE
 223This vnode shares its
 224.Em v_interlock
 225with other vnodes.
 226.It VI_CLEAN
 227This vnode has been reclaimed and is no longer attached to a file system.
 228.It VU_DIROP
216This vnode is involved in a directory operation. 229This vnode is involved in a directory operation.
217This flag is used exclusively by LFS. 230This flag is used exclusively by LFS.
218.It VLAYER 
219This vnode is on a layered file system. 
220.It VONWORKLST 
221This vnode is on syncer work-list. 
222.It VFREEING 
223This vnode is being freed. 
224.It VMAPPED 
225This vnode might have user mappings. 
226.El 231.El
227.Pp 232.Pp
228The VXLOCK flag is used to prevent multiple processes from entering 233The VI_XLOCK flag is used to prevent multiple processes from entering
229the vnode reclamation code. 234the vnode reclamation code.
230It is also used as a flag to indicate that reclamation is in progress. 235It 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 
232reclamation is finished. 
233Before 236Before
234.Em v_flag 237.Em v_iflag
235can be modified, the 238can be modified, the
236.Em v_interlock 239.Em v_interlock
237simplelock must be acquired. 240mutex must be acquired.
238See 241See
239.Xr lock 9 242.Xr lock 9
240for details on the kernel locking API. 243for details on the kernel locking API.
241.Pp 244.Pp
242Each vnode has three reference counts: 245Each vnode has three reference counts:
243.Em v_usecount , 246.Em v_usecount ,
244.Em v_writecount 247.Em v_writecount
245and 248and
246.Em v_holdcnt . 249.Em v_holdcnt .
247The first is the number of active references within the 250The first is the number of active references within the
248kernel to the vnode. 251kernel to the vnode.
249This count is maintained by 252This count is maintained by
250.Fn vref , 253.Fn vref ,
251.Fn vrele , 254.Fn vrele ,
252.Fn vrele_async , 255.Fn vrele_async ,
253and 256and
254.Fn vput . 257.Fn vput .
255The second is the number of active references within the kernel to the 258The second is the number of active references within the kernel to the
256vnode performing write access to the file. 259vnode performing write access to the file.
257It is maintained by the 260It is maintained by the
258.Xr open 2 261.Xr open 2
259and 262and
260.Xr close 2 263.Xr close 2
261system calls. 264system calls.
262The third is the number of references within the kernel 265The third is the number of references within the kernel
263requiring the vnode to remain active and not be recycled. 266requiring the vnode to remain active and not be recycled.
264This count is maintained by 267This count is maintained by
265.Fn vhold 268.Fn vhold
266and 269and
267.Fn holdrele . 270.Fn holdrele .
268When both the 271When both the
269.Em v_usecount 272.Em v_usecount
270and 273and
271.Em v_holdcnt 274.Em v_holdcnt
272reach zero, the vnode is recycled to the freelist and may be reused 275reach zero, the vnode is recycled to the freelist and may be reused
273for another file. 276for another file.
274The transition to and from the freelist is handled by 277The transition to and from the freelist is handled by
275.Fn getnewvnode , 278a kernel thread
276.Fn ungetnewvnode 
277and 279and
278.Fn vrecycle . 280.Fn vrecycle .
279Access to 281Access to
280.Em v_usecount , 282.Em v_usecount ,
281.Em v_writecount 283.Em v_writecount
282and 284and
283.Em v_holdcnt 285.Em v_holdcnt
284is also protected by the 286is also protected by the
285.Em v_interlock 287.Em v_interlock
286simplelock. 288mutex.
287.Pp 289.Pp
288The number of pending synchronous and asynchronous writes on the 290The number of pending synchronous and asynchronous writes on the
289vnode are recorded in 291vnode are recorded in
290.Em v_numoutput . 292.Em v_numoutput .
291It is used by 293It is used by
292.Xr fsync 2 294.Xr fsync 2
293to wait for all writes to complete before returning to the user. 295to wait for all writes to complete before returning to the user.
294Its value must only be modified at splbio (see 296Its value must only be modified at splbio (see
295.Xr spl 9 ) . 297.Xr spl 9 ) .
296It does not track the number of dirty buffers attached to the 298It does not track the number of dirty buffers attached to the
297vnode. 299vnode.
298.Pp 300.Pp
299.Em v_dnclist 301.Em v_dnclist
300and 302and
301.Em v_nclist 303.Em v_nclist
302are used by 304are used by
303.Xr namecache 9 305.Xr namecache 9
304to maintain the list of associated entries so that 306to maintain the list of associated entries so that
305.Xr cache_purge 9 307.Xr cache_purge 9
306can purge them. 308can purge them.
307.Pp 309.Pp
308The link to the file system which owns the vnode is recorded by 310The link to the file system which owns the vnode is recorded by
309.Em v_mount . 311.Em v_mount .
310See 312See
311.Xr vfsops 9 313.Xr vfsops 9
312for further information of file system mount status. 314for further information of file system mount status.
313.Pp 315.Pp
314The 316The
315.Em v_op 317.Em v_op
316pointer points to its vnode operations vector. 318pointer points to its vnode operations vector.
317This vector describes what operations can be done to the file associated 319This vector describes what operations can be done to the file associated
318with the vnode. 320with the vnode.
319The system maintains one vnode operations vector for each file system 321The system maintains one vnode operations vector for each file system
320type configured into the kernel. 322type configured into the kernel.
321The vnode operations vector contains a pointer to a function for 323The vnode operations vector contains a pointer to a function for
322each operation supported by the file system. 324each operation supported by the file system.
323See 325See
324.Xr vnodeops 9 326.Xr vnodeops 9
325for a description of vnode operations. 327for a description of vnode operations.
326.Pp 328.Pp
327When not in use, vnodes are kept on the freelist through 329When not in use, vnodes are kept on the freelist through
328.Em v_freelist . 330.Em v_freelist .
329The vnodes still reference valid files but may be reused to refer to a 331The vnodes still reference valid files but may be reused to refer to a
330new file at any time. 332new file at any time.
331When a valid vnode which is on the freelist is used again, the user 333When a valid vnode which is on the freelist is used again, the user
332must call 334must call
333.Fn vget 335.Fn vget
334to increment the reference count and retrieve it from the freelist. 336to increment the reference count and retrieve it from the freelist.
335When a user wants a new vnode for another file, 337When a user wants a new vnode for another file,
336.Fn getnewvnode 338.Fn getnewvnode
337is invoked to remove a vnode from the freelist and initialize it for 339is invoked to allocate a vnode and initialize it for the new file.
338the new file. 
339.Pp 340.Pp
340The type of object the vnode represents is recorded by 341The type of object the vnode represents is recorded by
341.Em v_type . 342.Em v_type .
342It is used by generic code to perform checks to ensure operations are 343It is used by generic code to perform checks to ensure operations are
343performed on valid file system objects. 344performed on valid file system objects.
344Valid types are: 345Valid types are:
345.Pp 346.Pp
346.Bl -tag -offset indent -width VFIFO -compact 347.Bl -tag -offset indent -width VFIFO -compact
347.It VNON 348.It VNON
348The vnode has no type. 349The vnode has no type.
349.It VREG 350.It VREG
350The vnode represents a regular file. 351The vnode represents a regular file.
351.It VDIR 352.It VDIR
352The vnode represents a directory. 353The vnode represents a directory.
353.It VBLK 354.It VBLK
354The vnode represents a block special device. 355The vnode represents a block special device.
355.It VCHR 356.It VCHR
356The vnode represents a character special device. 357The vnode represents a character special device.
357.It VLNK 358.It VLNK
358The vnode represents a symbolic link. 359The vnode represents a symbolic link.
359.It VSOCK 360.It VSOCK
360The vnode represents a socket. 361The vnode represents a socket.
361.It VFIFO 362.It VFIFO
362The vnode represents a pipe. 363The vnode represents a pipe.
363.It VBAD 364.It VBAD
364The vnode represents a bad file (not currently used). 365The vnode represents a bad file (not currently used).
365.El 366.El
366.Pp 367.Pp
367Vnode tag types are used by external programs only (e.g., 368Vnode tag types are used by external programs only (e.g.,
368.Xr pstat 8 ) , 369.Xr pstat 8 ) ,
369and should never be inspected by the kernel. 370and should never be inspected by the kernel.
370Its use is deprecated 371Its use is deprecated
371since new 372since new
372.Em v_tag 373.Em v_tag
373values cannot be defined for loadable file systems. 374values cannot be defined for loadable file systems.
374The 375The
375.Em v_tag 376.Em v_tag
376member is read-only. 377member is read-only.
377Valid tag types are: 378Valid tag types are:
378.Pp 379.Pp
379.Bl -tag -offset indent -width "VT_FILECORE " -compact 380.Bl -tag -offset indent -width "VT_FILECORE " -compact
380.It VT_NON 381.It VT_NON
381non file system 382non file system
382.It VT_UFS 383.It VT_UFS
383universal file system 384universal file system
384.It VT_NFS 385.It VT_NFS
385network file system 386network file system
386.It VT_MFS 387.It VT_MFS
387memory file system 388memory file system
388.It VT_MSDOSFS 389.It VT_MSDOSFS
389FAT file system 390FAT file system
390.It VT_LFS 391.It VT_LFS
391log-structured file system 392log-structured file system
392.It VT_LOFS 393.It VT_LOFS
393loopback file system 394loopback file system
394.It VT_FDESC 395.It VT_FDESC
395file descriptor file system 396file descriptor file system
396.It VT_NULL 397.It VT_NULL
397null file system layer 398null file system layer
398.It VT_UMAP 399.It VT_UMAP
399uid/gid remapping file system layer 400uid/gid remapping file system layer
400.It VT_KERNFS 401.It VT_KERNFS
401kernel interface file system 402kernel interface file system
402.It VT_PROCFS 403.It VT_PROCFS
403process interface file system 404process interface file system
404.It VT_AFS 405.It VT_AFS
405AFS file system 406AFS file system
406.It VT_ISOFS 407.It VT_ISOFS
407ISO 9660 file system(s) 408ISO 9660 file system(s)
408.It VT_UNION 409.It VT_UNION
409union file system 410union file system
410.It VT_ADOSFS 411.It VT_ADOSFS
411Amiga file system 412Amiga file system
412.It VT_EXT2FS 413.It VT_EXT2FS
413Linux's ext2 file system 414Linux's ext2 file system
414.It VT_CODA 415.It VT_CODA
415Coda file system 416Coda file system
416.It VT_FILECORE 417.It VT_FILECORE
417filecore file system 418filecore file system
418.It VT_NTFS 419.It VT_NTFS
419Microsoft NT's file system 420Microsoft NT's file system
420.It VT_VFS 421.It VT_VFS
421virtual file system 422virtual file system
422.It VT_OVERLAY 423.It VT_OVERLAY
423overlay file system 424overlay file system
424.It VT_SMBFS 425.It VT_SMBFS
425SMB file system 426SMB file system
426.It VT_PTYFS 427.It VT_PTYFS
427pseudo-terminal device file system 428pseudo-terminal device file system
428.It VT_TMPFS 429.It VT_TMPFS
429efficient memory file system 430efficient memory file system
430.It VT_UDF 431.It VT_UDF
431universal disk format file system 432universal disk format file system
432.It VT_SYSVBFS 433.It VT_SYSVBFS
433systemV boot file system 434systemV boot file system
434.El 435.El
435.Pp 436.Pp
436All vnode locking operations use 437All vnode locking operations use
437.Em v_lock . 438.Em v_lock .
438This lock is acquired by calling 439This lock is acquired by calling
439.Xr vn_lock 9 440.Xr vn_lock 9
440and released by calling 441and released by calling
441.Xr VOP_UNLOCK 9 . 442.Xr VOP_UNLOCK 9 .
442The reason for this asymmetry is that 443The reason for this asymmetry is that
443.Xr vn_lock 9 444.Xr vn_lock 9
444is a wrapper for 445is a wrapper for
445.Xr VOP_LOCK 9 446.Xr VOP_LOCK 9
446with extra checks, while the unlocking step usually does not need 447with extra checks, while the unlocking step usually does not need
447additional checks and thus has no wrapper. 448additional checks and thus has no wrapper.
448.Pp 449.Pp
449The vnode locking operation is complicated because it is used for many 450The vnode locking operation is complicated because it is used for many
450purposes. 451purposes.
451Sometimes it is used to bundle a series of vnode operations (see 452Sometimes it is used to bundle a series of vnode operations (see
452.Xr vnodeops 9 ) 453.Xr vnodeops 9 )
453into an atomic group. 454into an atomic group.
454Many file systems rely on it to prevent race conditions in updating 455Many file systems rely on it to prevent race conditions in updating
455file system type specific data structures rather than using their 456file system type specific data structures rather than using their
456own private locks. 457own private locks.
457The vnode lock can operate as a multiple-reader (shared-access lock) 458The vnode lock can operate as a multiple-reader (shared-access lock)
458or single-writer lock (exclusive access lock), however many current file 459or single-writer lock (exclusive access lock), however many current file
459system implementations were written assuming only single-writer 460system implementations were written assuming only single-writer
460locking. 461locking.
461Multiple-reader locking functions equivalently only in the presence 462Multiple-reader locking functions equivalently only in the presence
462of big-lock SMP locking or a uni-processor machine. 463of big-lock SMP locking or a uni-processor machine.
463The lock may be held while sleeping. 464The lock may be held while sleeping.
464While the 465While the
465.Em v_lock 466.Em v_lock
466is acquired, the holder is guaranteed that the vnode will not be 467is acquired, the holder is guaranteed that the vnode will not be
467reclaimed or invalidated. 468reclaimed or invalidated.
468Most file system functions require that you hold the vnode lock on entry. 469Most file system functions require that you hold the vnode lock on entry.
469See 470See
470.Xr lock 9 471.Xr lock 9
471for details on the kernel locking API. 472for details on the kernel locking API.
472.Pp 473.Pp
473Each file system underlying a vnode allocates its own private area and 474Each file system underlying a vnode allocates its own private area and
474hangs it from 475hangs it from
475.Em v_data . 476.Em v_data .
476.Pp 477.Pp
477Most functions discussed in this page that operate on vnodes cannot be 478Most functions discussed in this page that operate on vnodes cannot be
478called from interrupt context. 479called from interrupt context.
479The members 480The members
480.Em v_numoutput , 481.Em v_numoutput ,
481.Em v_holdcnt , 482.Em v_holdcnt ,
482.Em v_dirtyblkhd , 483.Em v_dirtyblkhd ,
483.Em v_cleanblkhd , 484.Em v_cleanblkhd ,
484.Em v_freelist , 485.Em v_freelist ,
485and 486and
486.Em v_synclist 487.Em v_synclist
487are modified in interrupt context and must be protected by 488are modified in interrupt context and must be protected by
488.Xr splbio 9 489.Xr splbio 9
489unless it is certain that there is no chance an interrupt handler will 490unless it is certain that there is no chance an interrupt handler will
490modify them. 491modify them.
491The vnode lock must not be acquired within interrupt context. 492The vnode lock must not be acquired within interrupt context.
492.Sh FUNCTIONS 493.Sh FUNCTIONS
493.Bl -tag -width compact 494.Bl -tag -width compact
494.It Fn vref "vp" 495.It Fn vref "vp"
495Increment 496Increment
496.Em v_usecount 497.Em v_usecount
497of the vnode 498of the vnode
498.Em vp . 499.Em vp .
499Any kernel thread system which uses a vnode (e.g., during the operation 500Any kernel thread system which uses a vnode (e.g., during the operation
500of some algorithm or to store in a data structure) should call 501of some algorithm or to store in a data structure) should call
501.Fn vref . 502.Fn vref .
502.It Fn vrele "vp" 503.It Fn vrele "vp"
503Decrement 504Decrement
504.Em v_usecount 505.Em v_usecount
505of unlocked vnode 506of unlocked vnode
506.Em vp . 507.Em vp .
507Any code in the system which is using a vnode should call 508Any code in the system which is using a vnode should call
508.Fn vrele 509.Fn vrele
509when it is finished with the vnode. 510when it is finished with the vnode.
510If 511If
511.Em v_usecount 512.Em v_usecount
512of the vnode reaches zero and 513of the vnode reaches zero and
513.Em v_holdcnt 514.Em v_holdcnt
514is greater than zero, the vnode is placed on the holdlist. 515is greater than zero, the vnode is placed on the holdlist.
515If both 516If both
516.Em v_usecount 517.Em v_usecount
517and 518and
518.Em v_holdcnt 519.Em v_holdcnt
519are zero, the vnode is placed on the freelist. 520are zero, the vnode is placed on the freelist.
520.It Fn vrele_async "vp" 521.It Fn vrele_async "vp"
521Will asychronously release the vnode in different context than the caller, 522Will asychronously release the vnode in different context than the caller,
522sometime after the call. 523sometime after the call.
523.It Fn vget "vp" "lockflags" 524.It Fn vget "vp" "lockflags"
524Reclaim vnode 525Reclaim vnode
525.Fa vp 526.Fa vp
526from the freelist, increment its reference count and lock it. 527from the freelist, increment its reference count and lock it.
527The argument 528The argument
528.Fa lockflags 529.Fa lockflags
529specifies the 530specifies the
530.Xr rwlock 9 531.Xr rwlock 9
531flags used to lock the vnode. 532flags used to lock the vnode.
532If the VXLOCK is set in 533If the
 534.Em VI_XLOCK
 535is set in
533.Fa vp Ns 's 536.Fa vp Ns 's
534.Em v_flag , 537.Em v_flag ,
535vnode 538vnode
536.Fa vp 539.Fa vp
537is being recycled in 540is being recycled in
538.Fn vgone 541.Fn vgone
539and the calling thread sleeps until the transition is complete. 542and the calling thread sleeps until the transition is complete.
540When it is awakened, an error is returned to indicate that the vnode is 543When 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). 544no longer usable.
542.It Fn vput "vp" 545.It Fn vput "vp"
543Unlock vnode 546Unlock vnode
544.Fa vp 547.Fa vp
545and decrement its 548and decrement its
546.Em v_usecount . 549.Em v_usecount .
547Depending on the reference counts, move the vnode to the holdlist or 550Depending on the reference counts, move the vnode to the holdlist or
548the freelist. 551the freelist.
549This operation is functionally equivalent to calling 552This operation is functionally equivalent to calling
550.Xr VOP_UNLOCK 9 553.Xr VOP_UNLOCK 9
551followed by 554followed by
552.Fn vrele . 555.Fn vrele .
553.It Fn vhold "vp" 556.It Fn vhold "vp"
554Mark the vnode 557Mark the vnode
555.Fa vp 558.Fa vp
556as active by incrementing 559as active by incrementing
557.Em vp-\*[Gt]v_holdcnt 560.Em vp-\*[Gt]v_holdcnt
558and moving the vnode from the freelist to the holdlist. 561and moving the vnode from the freelist to the holdlist.
559Once on the holdlist, the vnode will not be recycled until it is 562Once on the holdlist, the vnode will not be recycled until it is
560released with 563released with
561.Fn holdrele . 564.Fn holdrele .
562.It Fn holdrele "vp" 565.It Fn holdrele "vp"
563Mark the vnode 566Mark the vnode
564.Fa vp 567.Fa vp
565as inactive by decrementing 568as inactive by decrementing
566.Em vp-\*[Gt]v_holdcnt 569.Em vp-\*[Gt]v_holdcnt
567and moving the vnode from the holdlist to the freelist. 570and moving the vnode from the holdlist to the freelist.
568.It Fn getnewvnode "tag" "mp" "vops" "slock" "vpp" 571.It Fn getnewvnode "tag" "mp" "vops" "slock" "vpp"
569Retrieve the next vnode from the freelist. 572Retrieve the next vnode from the freelist.
570.Fn getnewvnode 573.Fn getnewvnode
571must choose whether to allocate a new vnode or recycle an existing 574allocates a new vnode.
572one. 
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 
575free list. 
576Generally only vnodes that have no buffers associated with them are 
577recycled and the next vnode from the freelist is retrieved. 
578If the freelist is empty, vnodes on the holdlist are considered. 
579The new vnode is returned in the address specified by 575The new vnode is returned in the address specified by
580.Fa vpp . 576.Fa vpp .
581.Pp 577.Pp
582The argument 578The argument
583.Fa mp 579.Fa mp
584is the mount point for the file system requested the new vnode. 580is the mount point for the file system requested the new vnode.
585Before retrieving the new vnode, the file system is checked if it is 581Before retrieving the new vnode, the file system is checked if it is
586busy (such as currently unmounting). 582busy (such as currently unmounting).
587An error is returned if the file system is unmounted. 583An error is returned if the file system is unmounted.
588.Pp 584.Pp
589The argument 585The argument
590.Fa tag 586.Fa tag
591is the vnode tag assigned to 587is the vnode tag assigned to
592.Fa *vpp-\*[Gt]v_tag . 588.Fa *vpp-\*[Gt]v_tag .
593The argument 589The argument
594.Fa vops 590.Fa vops
595is the vnode operations vector of the file system requesting the new 591is the vnode operations vector of the file system requesting the new
596vnode. 592vnode.
597If a vnode is successfully retrieved zero is returned, otherwise an 593If a vnode is successfully retrieved zero is returned, otherwise an
598appropriate error code is returned. 594appropriate error code is returned.
599If 595If
600.Fa slock 596.Fa slock
601is not 597is not
602.Dv NULL , 598.Dv NULL ,
603it specifies the lock to share for 599it specifies the lock to share for
604.Em v_interlock . 600.Em v_interlock .
605The reference will be held on the lock and sharing noted. 601The reference will be held on the lock and sharing noted.
606Reference will be released and lock unshared when the vnode gets recycled. 602Reference will be released and lock unshared when the vnode gets recycled.
607If 603If
608.Dv NULL 604.Dv NULL
609(regular case), vnode will use its own interlock. 605(regular case), vnode will use its own interlock.
610.It Fn ungetnewvnode "vp" 606.It Fn ungetnewvnode "vp"
611Undo the operation of 607Undo the operation of
612.Fn getnewvnode . 608.Fn getnewvnode .
613The argument 609The argument
614.Fa vp 610.Fa vp
615is the vnode to return to the freelist. 611is the vnode to return to the freelist.
616This function is needed for 612This function is needed for
617.Xr VFS_VGET 9 613.Xr VFS_VGET 9
618which may need to push back a vnode in case of a locking race 614which may need to push back a vnode in case of a locking race
619condition. 615condition.
620.It Fn vrecycle "vp" "inter_lkp" 616.It Fn vrecycle "vp" "inter_lkp"
621Recycle the unused vnode 617Recycle the unused vnode
622.Fa vp 618.Fa vp
623to the front of the freelist. 619from the front of the freelist.
624.Fn vrecycle 620.Fn vrecycle
625is a null operation if the reference count is greater than zero. 621is a null operation if the reference count is greater than zero.
626.It Fn vgone "vp" 622.It Fn vgone "vp"
627Eliminate all activity associated with the unlocked vnode 623Eliminate all activity associated with the unlocked vnode
628.Fa vp 624.Fa vp
629in preparation for recycling. 625in preparation for recycling.
630.It Fn vgonel "vp" "p" 626.It Fn vgonel "vp" "p"
631Eliminate all activity associated with the locked vnode 627Eliminate all activity associated with the locked vnode
632.Fa vp 628.Fa vp
633in preparation for recycling. 629in preparation for recycling.
634.It Fn vflush "mp" "skipvp" "flags" 630.It Fn vflush "mp" "skipvp" "flags"
635Remove any vnodes in the vnode table belonging to mount point 631Remove any vnodes in the vnode table belonging to mount point
636.Fa mp . 632.Fa mp .
637If 633If
638.Fa skipvp 634.Fa skipvp
639is not 635is not
640.Dv NULL 636.Dv NULL
641it is exempt from being flushed. 637it is exempt from being flushed.
642The argument 638The argument
643.Fa flags 639.Fa flags
644is a set of flags modifying the operation of 640is a set of flags modifying the operation of
645.Fn vflush . 641.Fn vflush .
646If FORCECLOSE is not specified, there should not be any active vnodes and 642If FORCECLOSE is not specified, there should not be any active vnodes and
647the error 643the error
648.Er EBUSY 644.Er EBUSY
649is returned if any are found (this is a user error, not a system error). 645is returned if any are found (this is a user error, not a system error).
650If FORCECLOSE is specified, active vnodes that are found are detached. 646If FORCECLOSE is specified, active vnodes that are found are detached.
651If WRITECLOSE is set, only flush out regular file vnodes open for 647If WRITECLOSE is set, only flush out regular file vnodes open for
652writing. 648writing.
653SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped. 649SKIPSYSTEM causes any vnodes marked V_SYSTEM to be skipped.
654.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred" 650.It Fn vaccess "type" "file_mode" "uid" "gid" "acc_mode" "cred"
655Do access checking by comparing the file's permissions to the caller's 651Do access checking by comparing the file's permissions to the caller's
656desired access type 652desired access type
657.Fa acc_mode 653.Fa acc_mode
658and credentials 654and credentials
659.Fa cred . 655.Fa cred .
660.It Fn bdevvp "dev" "vpp" 656.It Fn bdevvp "dev" "vpp"
661Create a vnode for a block device. 657Create a vnode for a block device.
662.Fn bdevvp 658.Fn bdevvp
663is used for root file systems, swap areas and for memory file system 659is used for root file systems, swap areas and for memory file system
664special devices. 660special devices.
665.It Fn cdevvp "dev" "vpp" 661.It Fn cdevvp "dev" "vpp"
666Create a vnode for a character device. 662Create a vnode for a character device.
667.Fn cdevvp 663.Fn cdevvp
668is used for the console and kernfs special devices. 664is used for the console and kernfs special devices.
669.It Fn vfinddev "dev" "vtype" "vpp" 665.It Fn vfinddev "dev" "vtype" "vpp"
670Lookup a vnode by device number. 666Lookup a vnode by device number.
671The vnode is referenced and returned in the address specified by 667The vnode is referenced and returned in the address specified by
672.Fa vpp . 668.Fa vpp .
673.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type" 669.It Fn vdevgone "int maj" "int min" "int minh" "enum vtype type"
674Reclaim all vnodes that correspond to the specified minor number range 670Reclaim all vnodes that correspond to the specified minor number range
675.Fa minl 671.Fa minl
676to 672to
677.Fa minh 673.Fa minh
678(endpoints inclusive) of the specified major 674(endpoints inclusive) of the specified major
679.Fa maj . 675.Fa maj .
680.It Fn vwakeup "bp" 676.It Fn vwakeup "bp"
681Update outstanding I/O count 677Update outstanding I/O count
682.Em vp-\*[Gt]v_numoutput 678.Em vp-\*[Gt]v_numoutput
683for the vnode 679for the vnode
684.Em bp-\*[Gt]b_vp 680.Em bp-\*[Gt]b_vp
685and do a wakeup if requested and 681and do a wakeup if requested and
686.Em vp-\*[Gt]vflag 682.Em vp-\*[Gt]vflag
687has VBWAIT set. 683has VBWAIT set.
688.It Fn vflushbuf "vp" "sync" 684.It Fn vflushbuf "vp" "sync"
689Flush all dirty buffers to disk for the file with the locked vnode 685Flush all dirty buffers to disk for the file with the locked vnode
690.Fa vp . 686.Fa vp .
691The argument 687The argument
692.Fa sync 688.Fa sync
693specifies whether the I/O should be synchronous and 689specifies whether the I/O should be synchronous and
694.Fn vflushbuf 690.Fn vflushbuf
695will sleep until 691will sleep until
696.Em vp-\*[Gt]v_numoutput 692.Em vp-\*[Gt]v_numoutput
697is zero and 693is zero and
698.Em vp-\*[Gt]v_dirtyblkhd 694.Em vp-\*[Gt]v_dirtyblkhd
699is empty. 695is empty.
700.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo" 696.It Fn vinvalbuf "vp" "flags" "cred" "l" "slpflag" "slptimeo"
701Flush out and invalidate all buffers associated with locked vnode 697Flush out and invalidate all buffers associated with locked vnode
702.Fa vp . 698.Fa vp .
703The argument 699The argument
704.Fa l 700.Fa l
705and 701and
706.Fa cred 702.Fa cred
707specified the calling process and its credentials. 703specified the calling process and its credentials.
708The 704The
709.Xr ltsleep 9 705.Xr ltsleep 9
710flag and timeout are specified by the arguments 706flag and timeout are specified by the arguments
711.Fa slpflag 707.Fa slpflag
712and 708and
713.Fa slptimeo 709.Fa slptimeo
714respectively. 710respectively.
715If the operation is successful zero is returned, otherwise an 711If the operation is successful zero is returned, otherwise an
716appropriate error code is returned. 712appropriate error code is returned.
717.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo" 713.It Fn vtruncbuf "vp" "lbn" "slpflag" "slptimeo"
718Destroy any in-core buffers past the file truncation length for the 714Destroy any in-core buffers past the file truncation length for the
719locked vnode 715locked vnode
720.Fa vp . 716.Fa vp .
721The truncation length is specified by 717The truncation length is specified by
722.Fa lbn . 718.Fa lbn .
723.Fn vtruncbuf 719.Fn vtruncbuf
724will sleep while the I/O is performed, The 720will sleep while the I/O is performed, The
725.Xr ltsleep 9 721.Xr ltsleep 9
726flag and timeout are specified by the arguments 722flag and timeout are specified by the arguments
727.Fa slpflag 723.Fa slpflag
728and 724and
729.Fa slptimeo 725.Fa slptimeo
730respectively. 726respectively.
731If the operation is successful zero is returned, otherwise an 727If the operation is successful zero is returned, otherwise an
732appropriate error code is returned. 728appropriate error code is returned.
733.It Fn vprint "label" "vp" 729.It Fn vprint "label" "vp"
734This function is used by the kernel to dump vnode information during a 730This function is used by the kernel to dump vnode information during a
735panic. 731panic.
736It is only used if the kernel option DIAGNOSTIC is compiled into the kernel. 732It is only used if the kernel option DIAGNOSTIC is compiled into the kernel.
737The argument 733The argument
738.Fa label 734.Fa label
739is a string to prefix the information dump of vnode 735is a string to prefix the information dump of vnode
740.Fa vp . 736.Fa vp .
741.El 737.El
742.Sh CODE REFERENCES 738.Sh CODE REFERENCES
743The vnode framework is implemented within the file 739The vnode framework is implemented within the file
744.Pa sys/kern/vfs_subr.c . 740.Pa sys/kern/vfs_subr.c .
745.Sh SEE ALSO 741.Sh SEE ALSO
746.Xr intro 9 , 742.Xr intro 9 ,
747.Xr lock 9 , 743.Xr lock 9 ,
748.Xr namecache 9 , 744.Xr namecache 9 ,
749.Xr namei 9 , 745.Xr namei 9 ,
750.Xr uvm 9 , 746.Xr uvm 9 ,
751.Xr vattr 9 , 747.Xr vattr 9 ,
752.Xr vfs 9 , 748.Xr vfs 9 ,
753.Xr vfsops 9 , 749.Xr vfsops 9 ,
754.Xr vnodeops 9 , 750.Xr vnodeops 9 ,
755.Xr vnsubr 9 751.Xr vnsubr 9
756.Sh BUGS 752.Sh BUGS
757The locking protocol is inconsistent. 753The locking protocol is inconsistent.
758Many vnode operations are passed locked vnodes on entry but release 754Many vnode operations are passed locked vnodes on entry but release
759the lock before they exit. 755the lock before they exit.
760The locking protocol is used in some places to attempt to make a 756The locking protocol is used in some places to attempt to make a
761series of operations atomic (e.g., access check then operation). 757series of operations atomic (e.g., access check then operation).
762This does not work for non-local file systems that do not support locking 758This does not work for non-local file systems that do not support locking
763(e.g., NFS). 759(e.g., NFS).
764The 760The
765.Nm 761.Nm
766interface would benefit from a simpler locking protocol. 762interface would benefit from a simpler locking protocol.