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 (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
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 ,
@@ -69,27 +69,27 @@ @@ -69,27 +69,27 @@
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
@@ -173,78 +173,81 @@ There are some rather common exceptions  @@ -173,78 +173,81 @@ There are some rather common exceptions
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 ,
@@ -262,38 +265,37 @@ system calls. @@ -262,38 +265,37 @@ system 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
@@ -324,28 +326,27 @@ See @@ -324,28 +326,27 @@ See
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
@@ -519,36 +520,38 @@ and @@ -519,36 +520,38 @@ and
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
@@ -558,34 +561,27 @@ as active by incrementing @@ -558,34 +561,27 @@ as active by incrementing
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
@@ -610,27 +606,27 @@ If @@ -610,27 +606,27 @@ If
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 .