Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move vnode member v_mntvnodes as vi_mntvnodes to vnode_impl.h.
details: https://anonhg.NetBSD.org/src/rev/297fd5a986e0
branches: trunk
changeset: 350410:297fd5a986e0
user: hannken <hannken%NetBSD.org@localhost>
date: Wed Jan 11 09:07:57 2017 +0000
description:
Move vnode member v_mntvnodes as vi_mntvnodes to vnode_impl.h.
Add an ugly hack so pstat.c may still traverse the list.
diffstat:
share/man/man9/vnode.9 | 3 +-
sys/kern/vfs_mount.c | 61 +++++++++++++++++++++++++++++--------------------
sys/kern/vfs_subr.c | 26 +++++++++++++--------
sys/sys/mount.h | 5 ++-
sys/sys/vnode.h | 4 +--
sys/sys/vnode_impl.h | 4 ++-
usr.sbin/pstat/pstat.c | 25 +++++++++++++-------
7 files changed, 76 insertions(+), 52 deletions(-)
diffs (truncated from 415 to 300 lines):
diff -r 6bcb5c40923a -r 297fd5a986e0 share/man/man9/vnode.9
--- a/share/man/man9/vnode.9 Wed Jan 11 09:06:57 2017 +0000
+++ b/share/man/man9/vnode.9 Wed Jan 11 09:07:57 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnode.9,v 1.76 2017/01/11 09:06:57 hannken Exp $
+.\" $NetBSD: vnode.9,v 1.77 2017/01/11 09:07:57 hannken Exp $
.\"
.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -169,7 +169,6 @@
int v_holdcnt; /* page & buffer refs */
struct mount *v_mount; /* ptr to vfs we are in */
int (**v_op)(void *); /* vnode operations vector */
- TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */
struct buflists v_cleanblkhd; /* clean blocklist head */
struct buflists v_dirtyblkhd; /* dirty blocklist head */
union {
diff -r 6bcb5c40923a -r 297fd5a986e0 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c Wed Jan 11 09:06:57 2017 +0000
+++ b/sys/kern/vfs_mount.c Wed Jan 11 09:07:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -99,6 +99,8 @@
/* Mounted filesystem list. */
struct mntlist mountlist;
kmutex_t mountlist_lock;
+int vnode_offset_next_by_mount /* XXX: ugly hack for pstat.c */
+ = offsetof(vnode_impl_t, vi_mntvnodes.tqe_next);
kmutex_t mntvnode_lock;
kmutex_t vfs_list_lock;
@@ -336,33 +338,36 @@
}
struct vnode_iterator {
- struct vnode vi_vnode;
+ vnode_impl_t vi_vnode;
};
void
-vfs_vnode_iterator_init(struct mount *mp, struct vnode_iterator **vip)
+vfs_vnode_iterator_init(struct mount *mp, struct vnode_iterator **vnip)
{
- struct vnode *vp;
+ vnode_t *vp;
+ vnode_impl_t *vip;
vp = vnalloc_marker(mp);
+ vip = VNODE_TO_VIMPL(vp);
mutex_enter(&mntvnode_lock);
- TAILQ_INSERT_HEAD(&mp->mnt_vnodelist, vp, v_mntvnodes);
+ TAILQ_INSERT_HEAD(&mp->mnt_vnodelist, vip, vi_mntvnodes);
vp->v_usecount = 1;
mutex_exit(&mntvnode_lock);
- *vip = (struct vnode_iterator *)vp;
+ *vnip = (struct vnode_iterator *)vip;
}
void
-vfs_vnode_iterator_destroy(struct vnode_iterator *vi)
+vfs_vnode_iterator_destroy(struct vnode_iterator *vni)
{
- struct vnode *mvp = &vi->vi_vnode;
+ vnode_impl_t *mvip = &vni->vi_vnode;
+ vnode_t *mvp = VIMPL_TO_VNODE(mvip);
mutex_enter(&mntvnode_lock);
KASSERT(vnis_marker(mvp));
if (mvp->v_usecount != 0) {
- TAILQ_REMOVE(&mvp->v_mount->mnt_vnodelist, mvp, v_mntvnodes);
+ TAILQ_REMOVE(&mvp->v_mount->mnt_vnodelist, mvip, vi_mntvnodes);
mvp->v_usecount = 0;
}
mutex_exit(&mntvnode_lock);
@@ -370,22 +375,24 @@
}
struct vnode *
-vfs_vnode_iterator_next(struct vnode_iterator *vi,
+vfs_vnode_iterator_next(struct vnode_iterator *vni,
bool (*f)(void *, struct vnode *), void *cl)
{
- struct vnode *mvp = &vi->vi_vnode;
- struct mount *mp = mvp->v_mount;
- struct vnode *vp;
+ vnode_impl_t *mvip = &vni->vi_vnode;
+ struct mount *mp = VIMPL_TO_VNODE(mvip)->v_mount;
+ vnode_t *vp;
+ vnode_impl_t *vip;
int error;
- KASSERT(vnis_marker(mvp));
+ KASSERT(vnis_marker(VIMPL_TO_VNODE(mvip)));
do {
mutex_enter(&mntvnode_lock);
- vp = TAILQ_NEXT(mvp, v_mntvnodes);
- TAILQ_REMOVE(&mp->mnt_vnodelist, mvp, v_mntvnodes);
- mvp->v_usecount = 0;
+ vip = TAILQ_NEXT(mvip, vi_mntvnodes);
+ TAILQ_REMOVE(&mp->mnt_vnodelist, mvip, vi_mntvnodes);
+ VIMPL_TO_VNODE(mvip)->v_usecount = 0;
again:
+ vp = VIMPL_TO_VNODE(vip);
if (vp == NULL) {
mutex_exit(&mntvnode_lock);
return NULL;
@@ -395,12 +402,12 @@
vdead_check(vp, VDEAD_NOWAIT) ||
(f && !(*f)(cl, vp))) {
mutex_exit(vp->v_interlock);
- vp = TAILQ_NEXT(vp, v_mntvnodes);
+ vip = TAILQ_NEXT(vip, vi_mntvnodes);
goto again;
}
- TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vp, mvp, v_mntvnodes);
- mvp->v_usecount = 1;
+ TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vip, mvip, vi_mntvnodes);
+ VIMPL_TO_VNODE(mvip)->v_usecount = 1;
mutex_exit(&mntvnode_lock);
error = vcache_vget(vp);
KASSERT(error == 0 || error == ENOENT);
@@ -415,6 +422,7 @@
void
vfs_insmntque(vnode_t *vp, struct mount *mp)
{
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
struct mount *omp;
KASSERT(mp == NULL || (mp->mnt_iflag & IMNT_UNMOUNT) == 0 ||
@@ -425,14 +433,14 @@
* Delete from old mount point vnode list, if on one.
*/
if ((omp = vp->v_mount) != NULL)
- TAILQ_REMOVE(&vp->v_mount->mnt_vnodelist, vp, v_mntvnodes);
+ TAILQ_REMOVE(&vp->v_mount->mnt_vnodelist, vip, vi_mntvnodes);
/*
* Insert into list of vnodes for the new mount point, if
* available. The caller must take a reference on the mount
* structure and donate to the vnode.
*/
if ((vp->v_mount = mp) != NULL)
- TAILQ_INSERT_TAIL(&mp->mnt_vnodelist, vp, v_mntvnodes);
+ TAILQ_INSERT_TAIL(&mp->mnt_vnodelist, vip, vi_mntvnodes);
mutex_exit(&mntvnode_lock);
if (omp != NULL) {
@@ -505,6 +513,7 @@
vflush(struct mount *mp, vnode_t *skipvp, int flags)
{
vnode_t *vp;
+ vnode_impl_t *vip;
struct vnode_iterator *marker;
int error, busy = 0, when = 0;
struct vflush_ctx ctx;
@@ -543,14 +552,16 @@
/* Wait for all vnodes to be reclaimed. */
for (;;) {
mutex_enter(&mntvnode_lock);
- TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
+ TAILQ_FOREACH(vip, &mp->mnt_vnodelist, vi_mntvnodes) {
+ vp = VIMPL_TO_VNODE(vip);
if (vp == skipvp)
continue;
if ((flags & SKIPSYSTEM) && (vp->v_vflag & VV_SYSTEM))
continue;
break;
}
- if (vp != NULL) {
+ if (vip != NULL) {
+ KASSERT(vp == VIMPL_TO_VNODE(vip));
mutex_enter(vp->v_interlock);
mutex_exit(&mntvnode_lock);
error = vcache_vget(vp);
diff -r 6bcb5c40923a -r 297fd5a986e0 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Wed Jan 11 09:06:57 2017 +0000
+++ b/sys/kern/vfs_subr.c Wed Jan 11 09:07:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.455 2017/01/11 09:06:57 hannken Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 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.455 2017/01/11 09:06:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1594,9 +1594,11 @@
{
int cnt = 0;
- struct vnode *vp;
+ vnode_t *vp;
+ vnode_impl_t *vip;
(*pr)("locked vnodes =");
- TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
+ TAILQ_FOREACH(vip, &mp->mnt_vnodelist, vi_mntvnodes) {
+ vp = VIMPL_TO_VNODE(vip);
if (VOP_ISLOCKED(vp)) {
if ((++cnt % 6) == 0) {
(*pr)(" %p,\n\t", vp);
@@ -1610,10 +1612,12 @@
if (full) {
int cnt = 0;
- struct vnode *vp;
+ vnode_t *vp;
+ vnode_impl_t *vip;
(*pr)("all vnodes =");
- TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
- if (!TAILQ_NEXT(vp, v_mntvnodes)) {
+ TAILQ_FOREACH(vip, &mp->mnt_vnodelist, vi_mntvnodes) {
+ vp = VIMPL_TO_VNODE(vip);
+ if (!TAILQ_NEXT(vip, vi_mntvnodes)) {
(*pr)(" %p", vp);
} else if ((++cnt % 6) == 0) {
(*pr)(" %p,\n\t", vp);
@@ -1621,7 +1625,7 @@
(*pr)(" %p,", vp);
}
}
- (*pr)("\n", vp);
+ (*pr)("\n");
}
}
@@ -1634,7 +1638,8 @@
printlockedvnodes(void)
{
struct mount *mp, *nmp;
- struct vnode *vp;
+ vnode_t *vp;
+ vnode_impl_t *vip;
printf("Locked vnodes\n");
mutex_enter(&mountlist_lock);
@@ -1642,7 +1647,8 @@
if (vfs_busy(mp, &nmp)) {
continue;
}
- TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
+ TAILQ_FOREACH(vip, &mp->mnt_vnodelist, vi_mntvnodes) {
+ vp = VIMPL_TO_VNODE(vip);
if (VOP_ISLOCKED(vp))
vprint(NULL, vp);
}
diff -r 6bcb5c40923a -r 297fd5a986e0 sys/sys/mount.h
--- a/sys/sys/mount.h Wed Jan 11 09:06:57 2017 +0000
+++ b/sys/sys/mount.h Wed Jan 11 09:07:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mount.h,v 1.219 2016/07/07 06:55:44 msaitoh Exp $ */
+/* $NetBSD: mount.h,v 1.220 2017/01/11 09:07:57 hannken Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -100,6 +100,7 @@
#ifndef _STANDALONE
struct vnode;
+struct vnode_impl;
struct vattr;
/*
@@ -109,7 +110,7 @@
*/
struct mount {
TAILQ_ENTRY(mount) mnt_list; /* mount list */
- TAILQ_HEAD(, vnode) mnt_vnodelist; /* list of vnodes this mount */
+ TAILQ_HEAD(, vnode_impl) mnt_vnodelist; /* list of vnodes this mount */
struct vfsops *mnt_op; /* operations on fs */
struct vnode *mnt_vnodecovered; /* vnode we mounted on */
int mnt_synclist_slot; /* synclist slot index */
diff -r 6bcb5c40923a -r 297fd5a986e0 sys/sys/vnode.h
--- a/sys/sys/vnode.h Wed Jan 11 09:06:57 2017 +0000
+++ b/sys/sys/vnode.h Wed Jan 11 09:07:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.270 2017/01/11 09:06:57 hannken Exp $ */
+/* $NetBSD: vnode.h,v 1.271 2017/01/11 09:07:57 hannken Exp $ */
Home |
Main Index |
Thread Index |
Old Index