Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a vfs_newvnode() method to deadfs and use it to create
details: https://anonhg.NetBSD.org/src/rev/52f1e8de08fa
branches: trunk
changeset: 339043:52f1e8de08fa
user: hannken <hannken%NetBSD.org@localhost>
date: Tue Jun 23 10:42:34 2015 +0000
description:
Add a vfs_newvnode() method to deadfs and use it to create
anonymous device vnodes with bdevvp() and cdevvp().
Implement spec_inactive() and spec_reclaim() to handle these nodes.
diffstat:
sys/kern/vfs_subr.c | 51 ++++++++++++----------------------------
sys/miscfs/deadfs/dead_vfsops.c | 33 ++++++++++++++++++++++++-
sys/miscfs/specfs/spec_vnops.c | 27 +++++++++++++++++----
sys/miscfs/specfs/specdev.h | 4 +-
4 files changed, 71 insertions(+), 44 deletions(-)
diffs (233 lines):
diff -r 91b9be5a71f6 -r 52f1e8de08fa sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Tue Jun 23 10:41:59 2015 +0000
+++ b/sys/kern/vfs_subr.c Tue Jun 23 10:42:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.446 2015/05/06 15:57:08 hannken Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.447 2015/06/23 10:42:34 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.446 2015/05/06 15:57:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.447 2015/06/23 10:42:34 hannken Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -117,11 +117,12 @@
int doforce = 1; /* 1 => permit forcible unmounting */
int prtactive = 0; /* 1 => print out reclaim of active vnodes */
+extern struct mount *dead_rootmount;
+
/*
* Local declarations.
*/
-static int getdevvp(dev_t, vnode_t **, enum vtype);
static void vn_initialize_syncerd(void);
/*
@@ -342,8 +343,13 @@
int
bdevvp(dev_t dev, vnode_t **vpp)
{
+ struct vattr va;
- return (getdevvp(dev, vpp, VBLK));
+ vattr_null(&va);
+ va.va_type = VBLK;
+ va.va_rdev = dev;
+
+ return vcache_new(dead_rootmount, NULL, &va, NOCRED, vpp);
}
/*
@@ -353,8 +359,13 @@
int
cdevvp(dev_t dev, vnode_t **vpp)
{
+ struct vattr va;
- return (getdevvp(dev, vpp, VCHR));
+ vattr_null(&va);
+ va.va_type = VCHR;
+ va.va_rdev = dev;
+
+ return vcache_new(dead_rootmount, NULL, &va, NOCRED, vpp);
}
/*
@@ -479,36 +490,6 @@
}
/*
- * Create a vnode for a device.
- * Used by bdevvp (block device) for root file system etc.,
- * and by cdevvp (character device) for console and kernfs.
- */
-static int
-getdevvp(dev_t dev, vnode_t **vpp, enum vtype type)
-{
- vnode_t *vp;
- vnode_t *nvp;
- int error;
-
- if (dev == NODEV) {
- *vpp = NULL;
- return (0);
- }
- error = getnewvnode(VT_NON, NULL, spec_vnodeop_p, NULL, &nvp);
- if (error) {
- *vpp = NULL;
- return (error);
- }
- vp = nvp;
- vp->v_type = type;
- vp->v_vflag |= VV_MPSAFE;
- uvm_vnp_setsize(vp, 0);
- spec_node_init(vp, dev);
- *vpp = vp;
- return (0);
-}
-
-/*
* Lookup a vnode by device number and return it referenced.
*/
int
diff -r 91b9be5a71f6 -r 52f1e8de08fa sys/miscfs/deadfs/dead_vfsops.c
--- a/sys/miscfs/deadfs/dead_vfsops.c Tue Jun 23 10:41:59 2015 +0000
+++ b/sys/miscfs/deadfs/dead_vfsops.c Tue Jun 23 10:42:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dead_vfsops.c,v 1.3 2015/06/23 10:41:59 hannken Exp $ */
+/* $NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.3 2015/06/23 10:41:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -63,6 +63,8 @@
.vfs_statvfs = (void *)dead_panic,
.vfs_sync = (void *)dead_panic,
.vfs_vget = (void *)dead_panic,
+ .vfs_loadvnode = (void *)dead_panic,
+ .vfs_newvnode = dead_newvnode,
.vfs_fhtovp = (void *)dead_panic,
.vfs_vptofh = (void *)dead_panic,
.vfs_init = (void *)dead_panic,
@@ -84,3 +86,30 @@
panic("dead fs operation used");
}
+
+/*
+ * Create a new anonymous device vnode.
+ */
+int
+dead_newvnode(struct mount *mp, struct vnode *dvp, struct vnode *vp,
+ struct vattr *vap, kauth_cred_t cred,
+ size_t *key_len, const void **new_key)
+{
+
+ KASSERT(mp == dead_rootmount);
+ KASSERT(dvp == NULL);
+ KASSERT(vap->va_type == VCHR || vap->va_type == VBLK);
+ KASSERT(vap->va_rdev != VNOVAL);
+
+ vp->v_tag = VT_NON;
+ vp->v_type = vap->va_type;
+ vp->v_op = spec_vnodeop_p;
+ vp->v_vflag |= VV_MPSAFE;
+ uvm_vnp_setsize(vp, 0);
+ spec_node_init(vp, vap->va_rdev);
+
+ *key_len = sizeof(struct vnode *);
+ *new_key = vp;
+
+ return 0;
+}
diff -r 91b9be5a71f6 -r 52f1e8de08fa sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c Tue Jun 23 10:41:59 2015 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c Tue Jun 23 10:42:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spec_vnops.c,v 1.147 2015/04/20 13:44:16 riastradh Exp $ */
+/* $NetBSD: spec_vnops.c,v 1.148 2015/06/23 10:42:34 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.147 2015/04/20 13:44:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.148 2015/06/23 10:42:34 hannken Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -101,6 +101,7 @@
#endif
static vnode_t *specfs_hash[SPECHSZ];
+extern struct mount *dead_rootmount;
/*
* This vnode operations vector is used for special device nodes
@@ -1077,11 +1078,27 @@
{
struct vop_inactive_args /* {
struct vnode *a_vp;
- struct proc *a_l;
+ struct bool *a_recycle;
} */ *ap = v;
+ struct vnode *vp = ap->a_vp;
+
+ KASSERT(vp->v_mount == dead_rootmount);
+ *ap->a_recycle = true;
+ VOP_UNLOCK(vp);
+ return 0;
+}
- VOP_UNLOCK(ap->a_vp);
- return (0);
+int
+spec_reclaim(void *v)
+{
+ struct vop_reclaim_args /* {
+ struct vnode *a_vp;
+ } */ *ap = v;
+ struct vnode *vp = ap->a_vp;
+
+ KASSERT(vp->v_mount == dead_rootmount);
+ vcache_remove(vp->v_mount, vp, sizeof(vp));
+ return 0;
}
/*
diff -r 91b9be5a71f6 -r 52f1e8de08fa sys/miscfs/specfs/specdev.h
--- a/sys/miscfs/specfs/specdev.h Tue Jun 23 10:41:59 2015 +0000
+++ b/sys/miscfs/specfs/specdev.h Tue Jun 23 10:42:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: specdev.h,v 1.43 2014/07/25 08:19:19 dholland Exp $ */
+/* $NetBSD: specdev.h,v 1.44 2015/06/23 10:42:35 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,8 +138,8 @@
#define spec_readdir genfs_badop
#define spec_readlink genfs_badop
#define spec_abortop genfs_badop
-#define spec_reclaim genfs_nullop
int spec_inactive(void *);
+int spec_reclaim(void *);
#define spec_lock genfs_nolock
#define spec_unlock genfs_nounlock
int spec_bmap(void *);
Home |
Main Index |
Thread Index |
Old Index