Module Name: src Committed By: hannken Date: Wed Dec 14 15:48:55 UTC 2016
Modified Files: src/share/man/man9: vnode.9 src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/gdbscripts: vchain vdump src/sys/kern: vfs_subr.c vfs_vnode.c src/sys/sys: param.h vnode.h vnode_impl.h Log Message: Move vnode members "v_freelisthd" and "v_freelist" from "struct vnode" to "struct vnode_impl" and rename to "vi_lrulisthd" and "vi_lrulist". No functional change intended. Welcome to 7.99.48 To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/share/man/man9/vnode.9 cvs rdiff -u -r1.118 -r1.119 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.7 -r1.8 src/sys/gdbscripts/vchain cvs rdiff -u -r1.5 -r1.6 src/sys/gdbscripts/vdump cvs rdiff -u -r1.451 -r1.452 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.514 -r1.515 src/sys/sys/param.h cvs rdiff -u -r1.266 -r1.267 src/sys/sys/vnode.h cvs rdiff -u -r1.3 -r1.4 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.72 src/share/man/man9/vnode.9:1.73 --- src/share/man/man9/vnode.9:1.72 Sat Aug 20 12:41:31 2016 +++ src/share/man/man9/vnode.9 Wed Dec 14 15:48:54 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.72 2016/08/20 12:41:31 wiz Exp $ +.\" $NetBSD: vnode.9,v 1.73 2016/12/14 15:48:54 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 20, 2016 +.Dd December 14, 2016 .Dt VNODE 9 .Os .Sh NAME @@ -175,8 +175,6 @@ struct vnode { int v_synclist_slot; /* synclist slot index */ struct mount *v_mount; /* ptr to vfs we are in */ int (**v_op)(void *); /* vnode operations vector */ - TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ - struct vnodelst *v_freelisthd; /* which freelist? */ TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ @@ -300,11 +298,8 @@ When both the .Em v_usecount and .Em v_holdcnt -reach zero, the vnode is recycled to the freelist and may be reused -for another file. -The transition to and from the freelist is handled by -a kernel thread -and +reach zero, the vnode is cached. +The transition from the cache is handled by a kernel thread and .Fn vrecycle . Access to .Em v_usecount , @@ -354,14 +349,9 @@ See .Xr vnodeops 9 for a description of vnode operations. .Pp -When not in use, vnodes are kept on the freelist through -.Em v_freelist . -The vnodes still reference valid files but may be reused to refer to a -new file at any time. -When a valid vnode which is on the freelist is used again, the user -must call +When a valid vnode which is cached is used again, the user must call .Fn vget -to increment the reference count and retrieve it from the freelist. +to increment the reference count. When a user wants a new vnode for another file, .Fn vcache_get or @@ -512,7 +502,6 @@ The members .Em v_holdcnt , .Em v_dirtyblkhd , .Em v_cleanblkhd , -.Em v_freelist , and .Em v_synclist are modified in interrupt context and must be protected by @@ -547,14 +536,14 @@ If both .Em v_usecount and .Em v_holdcnt -are zero, the vnode is placed on the freelist. +are zero, the vnode is cached. .It Fn vrele_async "vp" Will asychronously release the vnode in different context than the caller, sometime after the call. .It Fn vget "vp" "lockflags" "wait" Reclaim vnode .Fa vp -from the freelist and increment its reference count. +from the cache and increment its reference count. .Pp The vnode .Fa vp @@ -628,17 +617,15 @@ directly. Mark the vnode .Fa vp as active by incrementing -.Em vp-\*[Gt]v_holdcnt -and moving the vnode from the freelist to the holdlist. -Once on the holdlist, the vnode will not be recycled until it is +.Em vp-\*[Gt]v_holdcnt . +Once held, the vnode will not be recycled until it is released with .Fn holdrele . .It Fn holdrele "vp" Mark the vnode .Fa vp as inactive by decrementing -.Em vp-\*[Gt]v_holdcnt -and moving the vnode from the holdlist to the freelist. +.Em vp-\*[Gt]v_holdcnt . .It Fn vcache_get "mp" "key" "key_len" "vpp" Allocate a new vnode. The new vnode is returned referenced in the address specified by Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.118 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.118 Sat Mar 28 19:24:05 2015 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Dec 14 15:48:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.118 2015/03/28 19:24:05 maxv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.118 2015/03/28 19:24:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -904,9 +904,6 @@ msdosfs_unmount(struct mount *mp, int mn vp->v_writecount, vp->v_holdcnt); printf("mount %p, op %p\n", vp->v_mount, vp->v_op); - printf("freef %p, freeb %p, mount %p\n", - vp->v_freelist.tqe_next, vp->v_freelist.tqe_prev, - vp->v_mount); printf("cleanblkhd %p, dirtyblkhd %p, numoutput %d, type %d\n", vp->v_cleanblkhd.lh_first, vp->v_dirtyblkhd.lh_first, Index: src/sys/gdbscripts/vchain diff -u src/sys/gdbscripts/vchain:1.7 src/sys/gdbscripts/vchain:1.8 --- src/sys/gdbscripts/vchain:1.7 Sat Nov 23 16:15:25 2013 +++ src/sys/gdbscripts/vchain Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -# $NetBSD: vchain,v 1.7 2013/11/23 16:15:25 riz Exp $ +# $NetBSD: vchain,v 1.8 2016/12/14 15:48:55 hannken Exp $ # @(#)vchain 8.1 (Berkeley) 6/10/93 # @@ -7,9 +7,10 @@ define vchain set $num = 0 set $vp=(struct vnode *)$arg0 + set $vi=(struct vnode_impl *)$arg0 while ($vp) - printf "vp: 0x%lx freelist_next: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n",\ - $vp, $vp->v_freelist.tqe_next, $vp->v_uobj.uo_refs, \ + printf "vp: 0x%lx lrulist_next: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n",\ + $vp, $vi->vi_lrulist.tqe_next, $vp->v_uobj.uo_refs, \ $vp->v_iflag, $vp->v_vflag, $vp->v_uflag set $num++ set $vp = $vp->v_mntvnodes.tqe_next Index: src/sys/gdbscripts/vdump diff -u src/sys/gdbscripts/vdump:1.5 src/sys/gdbscripts/vdump:1.6 --- src/sys/gdbscripts/vdump:1.5 Wed Nov 18 18:02:00 2009 +++ src/sys/gdbscripts/vdump Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -# $NetBSD: vdump,v 1.5 2009/11/18 18:02:00 eeh Exp $ +# $NetBSD: vdump,v 1.6 2016/12/14 15:48:55 hannken Exp $ # @(#)vdump 8.1 (Berkeley) 6/10/93 # @@ -6,12 +6,14 @@ define dumpvnodes set $vp = (struct vnode *)$arg0 + set $vi = (struct vnode_impl *)$arg0 while ($vp) - printf "vnode=0x%x freef=0x%x mountf=0x%x usecount=%d\n", $vp, $vp->v_freelist.tqe_next, $vp->v_mntvnodes.tqe_next, $vp->v_uobj.uo_refs - set $vp = (struct vnode *)$vp->v_freelist.tqe_next + printf "vnode=0x%x lruf=0x%x mountf=0x%x usecount=%d\n", $vp, $vi->vi_lrulist.tqe_next, $vp->v_mntvnodes.tqe_next, $vp->v_uobj.uo_refs + set $vi = (struct vnode_impl *)$vi->vi_lrulist.tqe_next + set $vp = (struct vnode *)$vi end end document dumpvnodes dump the vnode list -end \ No newline at end of file +end Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.451 src/sys/kern/vfs_subr.c:1.452 --- src/sys/kern/vfs_subr.c:1.451 Thu Nov 3 11:04:21 2016 +++ src/sys/kern/vfs_subr.c Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.452 2016/12/14 15:48:55 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.452 2016/12/14 15:48:55 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1114,8 +1114,7 @@ vprint_common(struct vnode *vp, const ch vp->v_usecount, vp->v_writecount, vp->v_holdcnt); (*pr)("%ssize %" PRIx64 " writesize %" PRIx64 " numoutput %d\n", prefix, vp->v_size, vp->v_writesize, vp->v_numoutput); - (*pr)("%sfreelisthd %p data %p lock %p\n", prefix, - vp->v_freelisthd, vp->v_data, &vp->v_lock); + (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, &vp->v_lock); (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(node->vi_state), node->vi_key.vk_mount, node->vi_key.vk_key_len); @@ -1124,6 +1123,7 @@ vprint_common(struct vnode *vp, const ch while (n-- > 0) (*pr)(" %02x", *cp++); (*pr)("\n"); + (*pr)("%slrulisthd %p\n", prefix, node->vi_lrulisthd); #undef ARRAY_PRINT #undef ARRAY_SIZE Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.61 src/sys/kern/vfs_vnode.c:1.62 --- src/sys/kern/vfs_vnode.c:1.61 Wed Dec 14 15:46:57 2016 +++ src/sys/kern/vfs_vnode.c Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.61 2016/12/14 15:46:57 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.62 2016/12/14 15:48:55 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.61 2016/12/14 15:46:57 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.62 2016/12/14 15:48:55 hannken Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -428,6 +428,7 @@ static int cleanvnode(void) { vnode_t *vp; + vnode_impl_t *vi; vnodelst_t *listhd; struct mount *mp; @@ -435,7 +436,8 @@ cleanvnode(void) listhd = &vnode_free_list; try_nextlist: - TAILQ_FOREACH(vp, listhd, v_freelist) { + TAILQ_FOREACH(vi, listhd, vi_lrulist) { + vp = VIMPL_TO_VNODE(vi); /* * It's safe to test v_usecount and v_iflag * without holding the interlock here, since @@ -443,7 +445,7 @@ try_nextlist: * lists. */ KASSERT(vp->v_usecount == 0); - KASSERT(vp->v_freelisthd == listhd); + KASSERT(vi->vi_lrulisthd == listhd); if (!mutex_tryenter(vp->v_interlock)) continue; @@ -455,7 +457,7 @@ try_nextlist: break; } - if (vp == NULL) { + if (vi == NULL) { if (listhd == &vnode_free_list) { listhd = &vnode_hold_list; goto try_nextlist; @@ -504,6 +506,7 @@ vdrain_thread(void *cookie) void vremfree(vnode_t *vp) { + vnode_impl_t *vi = VNODE_TO_VIMPL(vp); KASSERT(mutex_owned(vp->v_interlock)); KASSERT(vp->v_usecount == 0); @@ -514,12 +517,12 @@ vremfree(vnode_t *vp) */ mutex_enter(&vnode_free_list_lock); if (vp->v_holdcnt > 0) { - KASSERT(vp->v_freelisthd == &vnode_hold_list); + KASSERT(vi->vi_lrulisthd == &vnode_hold_list); } else { - KASSERT(vp->v_freelisthd == &vnode_free_list); + KASSERT(vi->vi_lrulisthd == &vnode_free_list); } - TAILQ_REMOVE(vp->v_freelisthd, vp, v_freelist); - vp->v_freelisthd = NULL; + TAILQ_REMOVE(vi->vi_lrulisthd, vi, vi_lrulist); + vi->vi_lrulisthd = NULL; mutex_exit(&vnode_free_list_lock); } @@ -620,11 +623,12 @@ vtryrele(vnode_t *vp) static void vrelel(vnode_t *vp, int flags) { + vnode_impl_t *vi = VNODE_TO_VIMPL(vp); bool recycle, defer; int error; KASSERT(mutex_owned(vp->v_interlock)); - KASSERT(vp->v_freelisthd == NULL); + KASSERT(vi->vi_lrulisthd == NULL); if (__predict_false(vp->v_op == dead_vnodeop_p && VSTATE_GET(vp) != VS_RECLAIMED)) { @@ -694,7 +698,7 @@ vrelel(vnode_t *vp, int flags) * clean it here. We donate it our last reference. */ mutex_enter(&vrele_lock); - TAILQ_INSERT_TAIL(&vrele_list, vp, v_freelist); + TAILQ_INSERT_TAIL(&vrele_list, vi, vi_lrulist); if (++vrele_pending > (desiredvnodes >> 8)) cv_signal(&vrele_cv); mutex_exit(&vrele_lock); @@ -785,11 +789,11 @@ vrelel(vnode_t *vp, int flags) */ mutex_enter(&vnode_free_list_lock); if (vp->v_holdcnt > 0) { - vp->v_freelisthd = &vnode_hold_list; + vi->vi_lrulisthd = &vnode_hold_list; } else { - vp->v_freelisthd = &vnode_free_list; + vi->vi_lrulisthd = &vnode_free_list; } - TAILQ_INSERT_TAIL(vp->v_freelisthd, vp, v_freelist); + TAILQ_INSERT_TAIL(vi->vi_lrulisthd, vi, vi_lrulist); mutex_exit(&vnode_free_list_lock); mutex_exit(vp->v_interlock); } @@ -825,6 +829,7 @@ vrele_thread(void *cookie) { vnodelst_t skip_list; vnode_t *vp; + vnode_impl_t *vi; struct mount *mp; TAILQ_INIT(&skip_list); @@ -835,13 +840,14 @@ vrele_thread(void *cookie) vrele_gen++; cv_broadcast(&vrele_cv); cv_timedwait(&vrele_cv, &vrele_lock, hz); - TAILQ_CONCAT(&vrele_list, &skip_list, v_freelist); + TAILQ_CONCAT(&vrele_list, &skip_list, vi_lrulist); } - vp = TAILQ_FIRST(&vrele_list); + vi = TAILQ_FIRST(&vrele_list); + vp = VIMPL_TO_VNODE(vi); mp = vp->v_mount; - TAILQ_REMOVE(&vrele_list, vp, v_freelist); + TAILQ_REMOVE(&vrele_list, vi, vi_lrulist); if (fstrans_start_nowait(mp, FSTRANS_LAZY) != 0) { - TAILQ_INSERT_TAIL(&skip_list, vp, v_freelist); + TAILQ_INSERT_TAIL(&skip_list, vi, vi_lrulist); continue; } vrele_pending--; @@ -878,15 +884,16 @@ vref(vnode_t *vp) void vholdl(vnode_t *vp) { + vnode_impl_t *vi = VNODE_TO_VIMPL(vp); KASSERT(mutex_owned(vp->v_interlock)); if (vp->v_holdcnt++ == 0 && vp->v_usecount == 0) { mutex_enter(&vnode_free_list_lock); - KASSERT(vp->v_freelisthd == &vnode_free_list); - TAILQ_REMOVE(vp->v_freelisthd, vp, v_freelist); - vp->v_freelisthd = &vnode_hold_list; - TAILQ_INSERT_TAIL(vp->v_freelisthd, vp, v_freelist); + KASSERT(vi->vi_lrulisthd == &vnode_free_list); + TAILQ_REMOVE(vi->vi_lrulisthd, vi, vi_lrulist); + vi->vi_lrulisthd = &vnode_hold_list; + TAILQ_INSERT_TAIL(vi->vi_lrulisthd, vi, vi_lrulist); mutex_exit(&vnode_free_list_lock); } } @@ -898,6 +905,7 @@ vholdl(vnode_t *vp) void holdrelel(vnode_t *vp) { + vnode_impl_t *vi = VNODE_TO_VIMPL(vp); KASSERT(mutex_owned(vp->v_interlock)); @@ -908,10 +916,10 @@ holdrelel(vnode_t *vp) vp->v_holdcnt--; if (vp->v_holdcnt == 0 && vp->v_usecount == 0) { mutex_enter(&vnode_free_list_lock); - KASSERT(vp->v_freelisthd == &vnode_hold_list); - TAILQ_REMOVE(vp->v_freelisthd, vp, v_freelist); - vp->v_freelisthd = &vnode_free_list; - TAILQ_INSERT_TAIL(vp->v_freelisthd, vp, v_freelist); + KASSERT(vi->vi_lrulisthd == &vnode_hold_list); + TAILQ_REMOVE(vi->vi_lrulisthd, vi, vi_lrulist); + vi->vi_lrulisthd = &vnode_free_list; + TAILQ_INSERT_TAIL(vi->vi_lrulisthd, vi, vi_lrulist); mutex_exit(&vnode_free_list_lock); } } Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.514 src/sys/sys/param.h:1.515 --- src/sys/sys/param.h:1.514 Mon Dec 12 21:56:00 2016 +++ src/sys/sys/param.h Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.514 2016/12/12 21:56:00 maya Exp $ */ +/* $NetBSD: param.h,v 1.515 2016/12/14 15:48:55 hannken Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 799004700 /* NetBSD 7.99.47 */ +#define __NetBSD_Version__ 799004800 /* NetBSD 7.99.48 */ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.266 src/sys/sys/vnode.h:1.267 --- src/sys/sys/vnode.h:1.266 Wed Dec 14 15:46:57 2016 +++ src/sys/sys/vnode.h Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.266 2016/12/14 15:46:57 hannken Exp $ */ +/* $NetBSD: vnode.h,v 1.267 2016/12/14 15:48:55 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -119,7 +119,6 @@ struct vnode; struct buf; LIST_HEAD(buflists, buf); -TAILQ_HEAD(vnodelst, vnode); /* * Reading or writing any of these items requires holding the appropriate @@ -152,8 +151,6 @@ struct vnode { int v_synclist_slot; /* s: synclist slot index */ struct mount *v_mount; /* v: ptr to vfs we are in */ int (**v_op)(void *); /* :: vnode operations vector */ - TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */ - struct vnodelst *v_freelisthd; /* f: which freelist? */ TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */ struct buflists v_cleanblkhd; /* x: clean blocklist head */ struct buflists v_dirtyblkhd; /* x: dirty blocklist head */ @@ -181,7 +178,6 @@ struct vnode { #define v_fifoinfo v_un.vu_fifoinfo #define v_ractx v_un.vu_ractx -typedef struct vnodelst vnodelst_t; typedef struct vnode vnode_t; #endif Index: src/sys/sys/vnode_impl.h diff -u src/sys/sys/vnode_impl.h:1.3 src/sys/sys/vnode_impl.h:1.4 --- src/sys/sys/vnode_impl.h:1.3 Wed Dec 14 15:46:57 2016 +++ src/sys/sys/vnode_impl.h Wed Dec 14 15:48:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode_impl.h,v 1.3 2016/12/14 15:46:57 hannken Exp $ */ +/* $NetBSD: vnode_impl.h,v 1.4 2016/12/14 15:48:55 hannken Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -42,6 +42,8 @@ enum vnode_state { VS_RECLAIMING, /* Intermediate, detaching the fs node. */ VS_RECLAIMED /* Stable, no fs node attached. */ }; +TAILQ_HEAD(vnodelst, vnode_impl); +typedef struct vnodelst vnodelst_t; struct vcache_key { struct mount *vk_mount; const void *vk_key; @@ -50,6 +52,8 @@ struct vcache_key { struct vnode_impl { struct vnode vi_vnode; enum vnode_state vi_state; + struct vnodelst *vi_lrulisthd; + TAILQ_ENTRY(vnode_impl) vi_lrulist; SLIST_ENTRY(vnode_impl) vi_hash; struct vcache_key vi_key; };