Use vfs_subr.c from sys/kern. This brings differences in the vnode
life cycle between rump and a real kernel to a minimum.
This commit is contained in:
parent
4c26b5ddf3
commit
fb3107360b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: p2k.c,v 1.37 2008/01/14 13:57:27 pooka Exp $ */
|
||||
/* $NetBSD: p2k.c,v 1.38 2008/01/27 19:07:20 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -27,6 +27,21 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* puffs 2k, i.e. puffs 2 kernel. Converts the puffs protocol to
|
||||
* the kernel vfs protocol and vice versa.
|
||||
*
|
||||
* A word about reference counting: puffs in the kernel is the king of
|
||||
* reference counting. We must maintain a vnode alive and kicking
|
||||
* until the kernel tells us to reclaim it. Therefore we make sure
|
||||
* we never accidentally lose a vnode. Before calling operations which
|
||||
* decrease the refcount we always bump the refcount up to compensate.
|
||||
* Come inactive, if the file system thinks that the vnode should be
|
||||
* put out of its misery, it will set the recycle flag. We use this
|
||||
* to tell the kernel to reclaim the vnode. Only in reclaim do we
|
||||
* really nuke the last reference.
|
||||
*/
|
||||
|
||||
#define __VFSOPS_EXPOSE
|
||||
|
||||
#include <sys/mount.h>
|
||||
|
@ -113,6 +128,7 @@ p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
|
|||
struct puffs_ops *pops;
|
||||
struct puffs_usermount *pu;
|
||||
struct puffs_node *pn_root;
|
||||
struct vnode *rvp;
|
||||
struct ukfs *ukfs;
|
||||
extern int puffs_usethreads;
|
||||
int rv, sverrno;
|
||||
|
@ -171,7 +187,8 @@ p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
|
|||
if (pu == NULL)
|
||||
goto out;
|
||||
|
||||
pn_root = puffs_pn_new(pu, ukfs_getrvp(ukfs));
|
||||
rvp = ukfs_getrvp(ukfs);
|
||||
pn_root = puffs_pn_new(pu, rvp);
|
||||
puffs_setroot(pu, pn_root);
|
||||
puffs_setfhsize(pu, 0, PUFFS_FHFLAG_PASSTHROUGH);
|
||||
puffs_setstacksize(pu, PUFFS_STACKSIZE_MIN);
|
||||
|
@ -179,7 +196,7 @@ p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
|
|||
|
||||
puffs_set_prepost(pu, makelwp, clearlwp);
|
||||
|
||||
if ((rv = puffs_mount(pu, mountpath, mntflags, ukfs_getrvp(ukfs)))== -1)
|
||||
if ((rv = puffs_mount(pu, mountpath, mntflags, rvp))== -1)
|
||||
goto out;
|
||||
rv = puffs_mainloop(pu);
|
||||
|
||||
|
@ -206,8 +223,34 @@ int
|
|||
p2k_fs_unmount(struct puffs_usermount *pu, int flags)
|
||||
{
|
||||
struct mount *mp = puffs_getspecific(pu);
|
||||
struct puffs_node *pn_root = puffs_getroot(pu);
|
||||
struct vnode *rvp = pn_root->pn_data, *rvp2;
|
||||
int rv;
|
||||
|
||||
return VFS_UNMOUNT(mp, flags);
|
||||
/*
|
||||
* This makes the reference count of the root vnode drop
|
||||
* to 0 so that vflush() typically present in unmount can
|
||||
* succeed. If unmount fails, we try to rescue ourselves
|
||||
* if we can.
|
||||
*
|
||||
* Theoretically we're going south, sinking fast & dying
|
||||
* out here because the old vnode will probably have been
|
||||
* completely nuked by vflush(). But as this shouldn't
|
||||
* likely fail, worth an attempt.
|
||||
*
|
||||
* XXX: reallyfixmesomeday. either introduce VFS_ROOT to
|
||||
* puffs (blah) or check the cookie in every routine
|
||||
* against the root cookie, which might change (blah2).
|
||||
*/
|
||||
rump_vp_rele(rvp);
|
||||
rv = VFS_UNMOUNT(mp, flags);
|
||||
if (rv) {
|
||||
int rv2;
|
||||
|
||||
rv2 = VFS_ROOT(mp, &rvp2);
|
||||
assert(rv2 == 0 && rvp == rvp2);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -258,7 +301,7 @@ p2k_fs_nodetofh(struct puffs_usermount *pu, void *cookie, void *fid, size_t *fid
|
|||
return VFS_VPTOFH(vp, fid, fidsize);
|
||||
}
|
||||
|
||||
/* don't need vn_lock(), since we don't have VXLOCK */
|
||||
/* XXX: vn_lock() */
|
||||
#define VLE(a) RUMP_VOP_LOCK(a, LK_EXCLUSIVE)
|
||||
#define VLS(a) RUMP_VOP_LOCK(a, LK_SHARED)
|
||||
#define VUL(a) RUMP_VOP_UNLOCK(a, 0);
|
||||
|
@ -306,6 +349,7 @@ p2k_node_create(struct puffs_usermount *pu, void *opc, struct puffs_newinfo *pni
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
rv = RUMP_VOP_CREATE(opc, &vp, cn, __UNCONST(vap));
|
||||
AUL(opc);
|
||||
freecn(cn, 0);
|
||||
|
@ -327,6 +371,7 @@ p2k_node_mknod(struct puffs_usermount *pu, void *opc, struct puffs_newinfo *pni,
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
rv = RUMP_VOP_MKNOD(opc, &vp, cn, __UNCONST(vap));
|
||||
AUL(opc);
|
||||
freecn(cn, 0);
|
||||
|
@ -473,7 +518,9 @@ p2k_node_remove(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
VLE(targ);
|
||||
rump_vp_incref(targ);
|
||||
rv = RUMP_VOP_REMOVE(opc, targ, cn);
|
||||
AUL(opc);
|
||||
AUL(targ);
|
||||
|
@ -491,6 +538,7 @@ p2k_node_link(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
rv = RUMP_VOP_LINK(opc, targ, cn);
|
||||
freecn(cn, 0);
|
||||
|
||||
|
@ -507,9 +555,14 @@ p2k_node_rename(struct puffs_usermount *pu, void *src_dir, void *src,
|
|||
|
||||
cn_src = makecn(pcn_src);
|
||||
cn_targ = makecn(pcn_targ);
|
||||
rump_vp_incref(src_dir);
|
||||
rump_vp_incref(src);
|
||||
VLE(targ_dir);
|
||||
if (targ)
|
||||
rump_vp_incref(targ_dir);
|
||||
if (targ) {
|
||||
VLE(targ);
|
||||
rump_vp_incref(targ);
|
||||
}
|
||||
rv = RUMP_VOP_RENAME(src_dir, src, cn_src, targ_dir, targ, cn_targ);
|
||||
AUL(targ_dir);
|
||||
if (targ)
|
||||
|
@ -530,6 +583,7 @@ p2k_node_mkdir(struct puffs_usermount *pu, void *opc, struct puffs_newinfo *pni,
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
rv = RUMP_VOP_MKDIR(opc, &vp, cn, __UNCONST(vap));
|
||||
AUL(opc);
|
||||
freecn(cn, 0);
|
||||
|
@ -550,7 +604,9 @@ p2k_node_rmdir(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
|
||||
cn = makecn(pcn);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
VLE(targ);
|
||||
rump_vp_incref(targ);
|
||||
rv = RUMP_VOP_RMDIR(opc, targ, cn);
|
||||
AUL(targ);
|
||||
AUL(opc);
|
||||
|
@ -570,6 +626,7 @@ p2k_node_symlink(struct puffs_usermount *pu, void *opc,
|
|||
|
||||
cn = makecn(pcn_src);
|
||||
VLE(opc);
|
||||
rump_vp_incref(opc);
|
||||
rv = RUMP_VOP_SYMLINK(opc, &vp, cn,
|
||||
__UNCONST(vap), __UNCONST(link_target));
|
||||
AUL(opc);
|
||||
|
@ -675,16 +732,6 @@ p2k_node_write(struct puffs_usermount *pu, void *opc,
|
|||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
p2k_node_reclaim(struct puffs_usermount *pu, void *opc)
|
||||
{
|
||||
|
||||
rump_recyclenode(opc);
|
||||
rump_putnode(opc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
p2k_node_inactive(struct puffs_usermount *pu, void *opc)
|
||||
{
|
||||
|
@ -696,8 +743,16 @@ p2k_node_inactive(struct puffs_usermount *pu, void *opc)
|
|||
(void) RUMP_VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES);
|
||||
VLE(vp);
|
||||
rv = RUMP_VOP_INACTIVE(vp, &recycle);
|
||||
if (vp->v_usecount == 0)
|
||||
if (recycle)
|
||||
puffs_setback(puffs_cc_getcc(pu), PUFFS_SETBACK_NOREF_N1);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
p2k_node_reclaim(struct puffs_usermount *pu, void *opc)
|
||||
{
|
||||
|
||||
rump_vp_recycle(opc);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: puffs_rumpglue.c,v 1.1 2008/01/02 18:15:13 pooka Exp $ */
|
||||
/* $NetBSD: puffs_rumpglue.c,v 1.2 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
|
||||
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.1 2008/01/02 18:15:13 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.2 2008/01/27 19:07:21 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/conf.h>
|
||||
|
@ -45,14 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.1 2008/01/02 18:15:13 pooka Exp
|
|||
|
||||
#include "puffs_rumpglue.h"
|
||||
|
||||
int
|
||||
dounmount(struct mount *mp, int flags, struct lwp *l)
|
||||
{
|
||||
|
||||
VFS_UNMOUNT(mp, MNT_FORCE);
|
||||
panic("control fd is dead");
|
||||
}
|
||||
|
||||
void putterattach(void); /* XXX: from autoconf */
|
||||
dev_type_open(puttercdopen);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ukfs.c,v 1.16 2008/01/02 11:49:05 ad Exp $ */
|
||||
/* $NetBSD: ukfs.c,v 1.17 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -164,8 +164,8 @@ ukfs_ll_recycle(struct vnode *vp)
|
|||
VLE(vp);
|
||||
RUMP_VOP_FSYNC(vp, NULL, 0, 0, 0);
|
||||
RUMP_VOP_INACTIVE(vp, &recycle);
|
||||
rump_recyclenode(vp);
|
||||
rump_putnode(vp);
|
||||
rump_vp_incref(vp); /* XXX */
|
||||
rump_vp_recycle(vp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: intr.h,v 1.8 2008/01/02 11:49:05 ad Exp $ */
|
||||
/* $NetBSD: intr.h,v 1.9 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -45,6 +45,7 @@ void rump_splx(int);
|
|||
#define splsched() rump_splfoo()
|
||||
#define splvm() rump_splfoo()
|
||||
#define splx(x) rump_splx(x)
|
||||
#define spl0() ((void)0)
|
||||
|
||||
#define IPL_NONE 0
|
||||
#define IPL_SOFTBIO 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.27 2008/01/25 06:42:29 pooka Exp $
|
||||
# $NetBSD: Makefile,v 1.28 2008/01/27 19:07:21 pooka Exp $
|
||||
#
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
@ -22,8 +22,8 @@ SRCS+= fstrans_stub.c misc_stub.c pmap_stub.c vfsops_stub.c
|
|||
SRCS+= clock_subr.c kern_descrip.c kern_lock.c kern_stub.c param.c \
|
||||
subr_bufq.c subr_hash.c subr_prf2.c subr_specificdata.c \
|
||||
subr_time.c subr_workqueue.c sys_generic.c vfs_bio.c \
|
||||
vfs_cache.c vfs_getcwd.c vfs_vnops.c vfs_init.c vfs_lookup.c \
|
||||
vfs_subr2.c vfs_getcwd.c vnode_if.c
|
||||
vfs_cache.c vfs_getcwd.c vfs_init.c vfs_lookup.c vfs_subr.c \
|
||||
vfs_subr2.c vfs_vnops.c vnode_if.c
|
||||
|
||||
# sys/miscfs
|
||||
SRCS+= genfs_vnops.c sync_subr.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: emul.c,v 1.26 2008/01/24 22:41:08 pooka Exp $ */
|
||||
/* $NetBSD: emul.c,v 1.27 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -67,12 +67,12 @@ int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */
|
|||
int doing_shutdown;
|
||||
int ncpu = 1;
|
||||
const int schedppq = 1;
|
||||
int dovfsusermount = 1;
|
||||
|
||||
MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount struct");
|
||||
MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
|
||||
MALLOC_DEFINE(M_TEMP, "temp", "misc. temporary data buffers");
|
||||
MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
|
||||
MALLOC_DEFINE(M_VNODE, "vnodes", "Dynamically allocated vnodes");
|
||||
MALLOC_DEFINE(M_KEVENT, "kevent", "kevents/knotes");
|
||||
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
|
@ -136,6 +136,16 @@ printf_nolog(const char *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
aprint_normal(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int
|
||||
copyin(const void *uaddr, void *kaddr, size_t len)
|
||||
{
|
||||
|
@ -353,6 +363,10 @@ kthread_create(pri_t pri, int flags, struct cpu_info *ci,
|
|||
int rv;
|
||||
|
||||
#ifdef RUMP_WITHOUT_THREADS
|
||||
/* XXX: fake it */
|
||||
if (strcmp(fmt, "vrele") == 0)
|
||||
return 0;
|
||||
else
|
||||
panic("threads not available, undef RUMP_WITHOUT_THREADS");
|
||||
#endif
|
||||
|
||||
|
@ -474,3 +488,10 @@ kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
suspendsched()
|
||||
{
|
||||
|
||||
panic("%s: not implemented", __func__);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ltsleep.c,v 1.5 2008/01/05 04:03:01 riz Exp $ */
|
||||
/* $NetBSD: ltsleep.c,v 1.6 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -45,6 +45,8 @@ struct ltsleeper {
|
|||
static LIST_HEAD(, ltsleeper) sleepers = LIST_HEAD_INITIALIZER(sleepers);
|
||||
static kmutex_t sleepermtx;
|
||||
|
||||
kcondvar_t lbolt; /* Oh Kath Ra */
|
||||
|
||||
int
|
||||
ltsleep(wchan_t ident, pri_t prio, const char *wmesg, int timo,
|
||||
volatile struct simplelock *slock)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/* $NetBSD: opt_compat_43.h,v 1.1 2008/01/27 19:07:22 pooka Exp $ */
|
|
@ -0,0 +1 @@
|
|||
/* $NetBSD: opt_compat_netbsd.h,v 1.1 2008/01/27 19:07:22 pooka Exp $ */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rump.c,v 1.31 2008/01/24 22:41:08 pooka Exp $ */
|
||||
/* $NetBSD: rump.c,v 1.32 2008/01/27 19:07:21 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -150,6 +150,7 @@ rump_mnt_init(struct vfsops *vfsops, int mntflags)
|
|||
mp->mnt_op = vfsops;
|
||||
mp->mnt_flag = mntflags;
|
||||
TAILQ_INIT(&mp->mnt_vnodelist);
|
||||
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, 0);
|
||||
|
||||
mount_initspecific(mp);
|
||||
|
||||
|
@ -220,13 +221,6 @@ rump_freecn(struct componentname *cnp, int flags)
|
|||
kmem_free(cnp, sizeof(*cnp));
|
||||
}
|
||||
|
||||
int
|
||||
rump_recyclenode(struct vnode *vp)
|
||||
{
|
||||
|
||||
return vrecycle(vp, NULL, curlwp);
|
||||
}
|
||||
|
||||
static struct fakeblk *
|
||||
_rump_fakeblk_find(const char *path)
|
||||
{
|
||||
|
@ -359,7 +353,9 @@ void
|
|||
rump_vp_incref(struct vnode *vp)
|
||||
{
|
||||
|
||||
mutex_enter(&vp->v_interlock);
|
||||
++vp->v_usecount;
|
||||
mutex_exit(&vp->v_interlock);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -373,7 +369,25 @@ void
|
|||
rump_vp_decref(struct vnode *vp)
|
||||
{
|
||||
|
||||
mutex_enter(&vp->v_interlock);
|
||||
--vp->v_usecount;
|
||||
mutex_exit(&vp->v_interlock);
|
||||
}
|
||||
|
||||
void
|
||||
rump_vp_recycle(struct vnode *vp)
|
||||
{
|
||||
|
||||
mutex_enter(&vp->v_interlock);
|
||||
vclean(vp, DOCLOSE);
|
||||
vrelel(vp, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
rump_vp_rele(struct vnode *vp)
|
||||
{
|
||||
|
||||
vrele(vp);
|
||||
}
|
||||
|
||||
struct uio *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rump.h,v 1.21 2008/01/24 22:41:08 pooka Exp $ */
|
||||
/* $NetBSD: rump.h,v 1.22 2008/01/27 19:07:22 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -65,9 +65,6 @@ void rump_freecn(struct componentname *, int);
|
|||
#define RUMPCN_ISLOOKUP 0x01
|
||||
#define RUMPCN_FREECRED 0x02
|
||||
|
||||
void rump_putnode(struct vnode *);
|
||||
int rump_recyclenode(struct vnode *);
|
||||
|
||||
void rump_getvninfo(struct vnode *, enum vtype *, off_t * /*XXX*/, dev_t *);
|
||||
|
||||
int rump_fakeblk_register(const char *);
|
||||
|
@ -86,6 +83,8 @@ void rump_vattr_free(struct vattr *);
|
|||
void rump_vp_incref(struct vnode *);
|
||||
int rump_vp_getref(struct vnode *);
|
||||
void rump_vp_decref(struct vnode *);
|
||||
void rump_vp_recycle(struct vnode *);
|
||||
void rump_vp_rele(struct vnode *);
|
||||
|
||||
enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE };
|
||||
struct uio *rump_uio_setup(void *, size_t, off_t, enum rump_uiorw);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: specfs.c,v 1.18 2008/01/22 09:23:39 pooka Exp $ */
|
||||
/* $NetBSD: specfs.c,v 1.19 2008/01/27 19:07:22 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -35,6 +35,7 @@
|
|||
#include <sys/disklabel.h>
|
||||
|
||||
#include <miscfs/genfs/genfs.h>
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
|
@ -306,3 +307,37 @@ rump_specsimpleul(void *v)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spec_node_init(struct vnode *nvp, dev_t nvp_rdev)
|
||||
{
|
||||
specdev_t *sd;
|
||||
|
||||
sd = kmem_zalloc(sizeof(specdev_t), KM_SLEEP);
|
||||
sd->sd_rdev = nvp_rdev;
|
||||
sd->sd_refcnt = 1;
|
||||
nvp->v_specnode = kmem_alloc(sizeof(specnode_t), KM_SLEEP);
|
||||
nvp->v_specnode->sn_dev = sd;
|
||||
nvp->v_rdev = nvp_rdev;
|
||||
}
|
||||
|
||||
void
|
||||
spec_node_destroy(vnode_t *vp)
|
||||
{
|
||||
specnode_t *sn;
|
||||
specdev_t *sd;
|
||||
|
||||
sn = vp->v_specnode;
|
||||
sd = sn->sn_dev;
|
||||
|
||||
KASSERT(sd->sd_refcnt == 1);
|
||||
kmem_free(sd, sizeof(*sd));
|
||||
kmem_free(sn, sizeof(*sn));
|
||||
}
|
||||
|
||||
void
|
||||
spec_node_revoke(vnode_t *vp)
|
||||
{
|
||||
|
||||
panic("spec_node_revoke: should not be called");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs.c,v 1.33 2008/01/25 06:43:30 pooka Exp $ */
|
||||
/* $NetBSD: vfs.c,v 1.34 2008/01/27 19:07:22 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
|
@ -38,6 +38,7 @@
|
|||
#include <sys/namei.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <miscfs/fifofs/fifo.h>
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
@ -89,204 +90,23 @@ const struct vnodeopv_desc * const rump_opv_descs[] = {
|
|||
};
|
||||
|
||||
vnode_t *specfs_hash[SPECHSZ];
|
||||
int (*mountroot)(void);
|
||||
|
||||
int
|
||||
getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *),
|
||||
struct vnode **vpp)
|
||||
{
|
||||
struct vnode *vp;
|
||||
|
||||
vp = kmem_zalloc(sizeof(struct vnode), KM_SLEEP);
|
||||
vp->v_mount = mp;
|
||||
vp->v_tag = tag;
|
||||
vp->v_op = vops;
|
||||
vp->v_vnlock = &vp->v_lock;
|
||||
vp->v_usecount = 1;
|
||||
cv_init(&vp->v_cv, "vnode");
|
||||
lockinit(&vp->v_lock, PVFS, "vnlock", 0, 0);
|
||||
|
||||
UVM_OBJ_INIT(&vp->v_uobj, &uvm_vnodeops, 1);
|
||||
|
||||
if (mp) {
|
||||
TAILQ_INSERT_TAIL(&mp->mnt_vnodelist, vp, v_mntvnodes);
|
||||
}
|
||||
|
||||
*vpp = vp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rump_putnode(struct vnode *vp)
|
||||
{
|
||||
|
||||
if (vp->v_specnode)
|
||||
kmem_free(vp->v_specnode, sizeof(*vp->v_specnode));
|
||||
UVM_OBJ_DESTROY(&vp->v_uobj);
|
||||
kmem_free(vp, sizeof(*vp));
|
||||
}
|
||||
|
||||
void
|
||||
ungetnewvnode(struct vnode *vp)
|
||||
{
|
||||
|
||||
rump_putnode(vp);
|
||||
}
|
||||
|
||||
void
|
||||
vn_init1(void)
|
||||
sys_sync(struct lwp *l, const void *v, register_t *rv)
|
||||
{
|
||||
|
||||
panic("%s: unimplemented", __func__);
|
||||
}
|
||||
|
||||
int
|
||||
vflush(struct mount *mp, struct vnode *skipvp, int flags)
|
||||
dounmount(struct mount *mp, int flags, struct lwp *l)
|
||||
{
|
||||
|
||||
return 0;
|
||||
VFS_UNMOUNT(mp, MNT_FORCE);
|
||||
panic("control fd is dead");
|
||||
}
|
||||
|
||||
void
|
||||
vref(struct vnode *vp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
vget(struct vnode *vp, int lockflag)
|
||||
{
|
||||
|
||||
if ((lockflag & LK_INTERLOCK) == 0)
|
||||
mutex_enter(&vp->v_interlock);
|
||||
|
||||
if (lockflag & LK_TYPE_MASK) {
|
||||
vn_lock(vp, (lockflag&LK_TYPE_MASK) | (lockflag&LK_INTERLOCK));
|
||||
return 0;
|
||||
}
|
||||
|
||||
mutex_exit(&vp->v_interlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vrele(struct vnode *vp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
vrelel(struct vnode *vp, int doinactive, int onhead)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
vrele2(struct vnode *vp, bool onhead)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
vnode_t *
|
||||
vnalloc(struct mount *mp)
|
||||
{
|
||||
struct vnode *vp;
|
||||
|
||||
/* assuming mp != NULL */
|
||||
|
||||
vp = kmem_zalloc(sizeof(struct vnode), KM_SLEEP);
|
||||
vp->v_type = VBAD;
|
||||
vp->v_iflag = VI_MARKER;
|
||||
vp->v_mount = mp;
|
||||
UVM_OBJ_INIT(&vp->v_uobj, &uvm_vnodeops, 1);
|
||||
cv_init(&vp->v_cv, "vnode");
|
||||
|
||||
return vp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vnfree(vnode_t *vp)
|
||||
{
|
||||
|
||||
UVM_OBJ_DESTROY(&vp->v_uobj);
|
||||
kmem_free(vp, sizeof(struct vnode));
|
||||
}
|
||||
|
||||
void
|
||||
vput(struct vnode *vp)
|
||||
{
|
||||
|
||||
VOP_UNLOCK(vp, 0);
|
||||
}
|
||||
|
||||
void
|
||||
vgone(struct vnode *vp)
|
||||
{
|
||||
|
||||
vgonel(vp, curlwp);
|
||||
}
|
||||
|
||||
void
|
||||
vclean(struct vnode *vp, int flags)
|
||||
{
|
||||
|
||||
vgonel(vp, curlwp);
|
||||
}
|
||||
|
||||
void
|
||||
vgonel(struct vnode *vp, struct lwp *l)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
vholdl(struct vnode *vp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
holdrelel(struct vnode *vp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
vrevoke(vnode_t *vp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
vrecycle(struct vnode *vp, kmutex_t *inter_lkp, struct lwp *l)
|
||||
{
|
||||
struct mount *mp = vp->v_mount;
|
||||
bool recycle;
|
||||
|
||||
if (vp->v_usecount == 1) {
|
||||
vp->v_usecount = 0;
|
||||
mutex_enter(&vp->v_interlock);
|
||||
if (inter_lkp)
|
||||
mutex_exit(inter_lkp);
|
||||
VOP_LOCK(vp, LK_EXCLUSIVE | LK_INTERLOCK);
|
||||
vinvalbuf(vp, V_SAVE, NOCRED, l, 0, 0);
|
||||
VOP_INACTIVE(vp, &recycle);
|
||||
|
||||
VOP_RECLAIM(vp);
|
||||
TAILQ_REMOVE(&mp->mnt_vnodelist, vp, v_mntvnodes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
vcount(struct vnode *vp)
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vfs_stdextattrctl(struct mount *mp, int cmt, struct vnode *vp,
|
||||
int attrnamespace, const char *attrname)
|
||||
|
@ -326,6 +146,7 @@ rump_makevnode(const char *path, size_t size, enum vtype vt, dev_t rdev)
|
|||
}
|
||||
vp->v_mount = &mnt_dummy;
|
||||
vp->v_vnlock = &vp->v_lock;
|
||||
vp->v_usecount = 1;
|
||||
mutex_init(&vp->v_interlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
lockinit(&vp->v_lock, PVFS, "vnlock", 0, 0);
|
||||
cv_init(&vp->v_cv, "vnode");
|
||||
|
@ -401,41 +222,6 @@ lf_advlock(struct vop_advlock_args *ap, struct lockf **head, off_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
vfs_rootmountalloc(const char *fstypename, const char *devname,
|
||||
struct mount **mpp)
|
||||
{
|
||||
|
||||
panic("%s: not supported", __func__);
|
||||
}
|
||||
|
||||
int
|
||||
vfs_busy(struct mount *mp, int flags, kmutex_t *interlck)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vfs_unbusy(struct mount *mp)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
spec_node_init(struct vnode *nvp, dev_t nvp_rdev)
|
||||
{
|
||||
specdev_t *sd;
|
||||
|
||||
sd = kmem_zalloc(sizeof(specdev_t), KM_SLEEP);
|
||||
sd->sd_rdev = nvp_rdev;
|
||||
sd->sd_refcnt = 1;
|
||||
nvp->v_specnode = kmem_alloc(sizeof(specnode_t), KM_SLEEP);
|
||||
nvp->v_specnode->sn_dev = sd;
|
||||
nvp->v_rdev = nvp_rdev;
|
||||
}
|
||||
|
||||
void
|
||||
fifo_printinfo(struct vnode *vp)
|
||||
{
|
||||
|
@ -443,13 +229,6 @@ fifo_printinfo(struct vnode *vp)
|
|||
return;
|
||||
}
|
||||
|
||||
int
|
||||
vfs_mountedon(struct vnode *vp)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rumpvfs_init()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue