Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move vnode members "v_freelisthd" and "v_freelist" from "str...
details: https://anonhg.NetBSD.org/src/rev/61403ca387d5
branches: trunk
changeset: 349559:61403ca387d5
user: hannken <hannken%NetBSD.org@localhost>
date: Wed Dec 14 15:48:54 2016 +0000
description:
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
diffstat:
share/man/man9/vnode.9 | 35 +++++++----------------
sys/fs/msdosfs/msdosfs_vfsops.c | 7 +---
sys/gdbscripts/vchain | 7 ++--
sys/gdbscripts/vdump | 10 ++++--
sys/kern/vfs_subr.c | 8 ++--
sys/kern/vfs_vnode.c | 60 +++++++++++++++++++++++-----------------
sys/sys/param.h | 4 +-
sys/sys/vnode.h | 6 +---
sys/sys/vnode_impl.h | 6 +++-
9 files changed, 69 insertions(+), 74 deletions(-)
diffs (truncated from 485 to 300 lines):
diff -r e87acf74d33d -r 61403ca387d5 share/man/man9/vnode.9
--- a/share/man/man9/vnode.9 Wed Dec 14 15:46:57 2016 +0000
+++ b/share/man/man9/vnode.9 Wed Dec 14 15:48:54 2016 +0000
@@ -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 @@
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 @@
.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 @@
.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 @@
.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 @@
.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 @@
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
diff -r e87acf74d33d -r 61403ca387d5 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c Wed Dec 14 15:46:57 2016 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c Wed Dec 14 15:48:54 2016 +0000
@@ -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 @@
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,
diff -r e87acf74d33d -r 61403ca387d5 sys/gdbscripts/vchain
--- a/sys/gdbscripts/vchain Wed Dec 14 15:46:57 2016 +0000
+++ b/sys/gdbscripts/vchain Wed Dec 14 15:48:54 2016 +0000
@@ -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 @@
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
diff -r e87acf74d33d -r 61403ca387d5 sys/gdbscripts/vdump
--- a/sys/gdbscripts/vdump Wed Dec 14 15:46:57 2016 +0000
+++ b/sys/gdbscripts/vdump Wed Dec 14 15:48:54 2016 +0000
@@ -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
diff -r e87acf74d33d -r 61403ca387d5 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Wed Dec 14 15:46:57 2016 +0000
+++ b/sys/kern/vfs_subr.c Wed Dec 14 15:48:54 2016 +0000
@@ -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 @@
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 @@
while (n-- > 0)
(*pr)(" %02x", *cp++);
(*pr)("\n");
+ (*pr)("%slrulisthd %p\n", prefix, node->vi_lrulisthd);
#undef ARRAY_PRINT
#undef ARRAY_SIZE
diff -r e87acf74d33d -r 61403ca387d5 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Wed Dec 14 15:46:57 2016 +0000
+++ b/sys/kern/vfs_vnode.c Wed Dec 14 15:48:54 2016 +0000
@@ -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 @@
cleanvnode(void)
{
vnode_t *vp;
+ vnode_impl_t *vi;
vnodelst_t *listhd;
struct mount *mp;
@@ -435,7 +436,8 @@
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 @@
* 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 @@
break;
}
- if (vp == NULL) {
+ if (vi == NULL) {
if (listhd == &vnode_free_list) {
listhd = &vnode_hold_list;
goto try_nextlist;
@@ -504,6 +506,7 @@
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 @@
*/
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 @@
static void
vrelel(vnode_t *vp, int flags)
Home |
Main Index |
Thread Index |
Old Index