Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpvfs Change rumpfs to vcache.
details: https://anonhg.NetBSD.org/src/rev/405a6affdaa8
branches: trunk
changeset: 335279:405a6affdaa8
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Jan 01 16:02:50 2015 +0000
description:
Change rumpfs to vcache.
diffstat:
sys/rump/librump/rumpvfs/rumpfs.c | 121 ++++++++++++++++++-------------------
1 files changed, 59 insertions(+), 62 deletions(-)
diffs (222 lines):
diff -r 13b2ff967e0f -r 405a6affdaa8 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Thu Jan 01 15:28:30 2015 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Thu Jan 01 16:02:50 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpfs.c,v 1.130 2014/08/17 19:28:46 justin Exp $ */
+/* $NetBSD: rumpfs.c,v 1.131 2015/01/01 16:02:50 hannken Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.130 2014/08/17 19:28:46 justin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.131 2015/01/01 16:02:50 hannken Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -474,12 +474,19 @@
vdevgone(RUMPBLK_DEVMAJOR, et->et_blkmin, et->et_blkmin, VBLK);
} else {
struct vnode *vp;
+ struct mount *mp;
+ struct rumpfs_node *rn;
mutex_enter(&reclock);
- if ((vp = et->et_rn->rn_vp) != NULL)
- mutex_enter(vp->v_interlock);
+ if ((vp = et->et_rn->rn_vp) != NULL) {
+ mp = vp->v_mount;
+ rn = vp->v_data;
+ KASSERT(rn == et->et_rn);
+ } else {
+ mp = NULL;
+ }
mutex_exit(&reclock);
- if (vp && vget(vp, 0) == 0)
+ if (mp && vcache_get(mp, rn, sizeof(rn), &vp) == 0)
vgone(vp);
}
@@ -548,45 +555,6 @@
return rn;
}
-static int
-makevnode(struct mount *mp, struct rumpfs_node *rn, struct vnode **vpp)
-{
- struct vnode *vp;
- int (**vpops)(void *);
- struct vattr *va = &rn->rn_va;
- int rv;
-
- KASSERT(!mutex_owned(&reclock));
-
- if (va->va_type == VCHR || va->va_type == VBLK) {
- vpops = rump_specop_p;
- } else {
- vpops = rump_vnodeop_p;
- }
-
- rv = getnewvnode(VT_RUMP, mp, vpops, NULL, &vp);
- if (rv)
- return rv;
-
- vp->v_size = vp->v_writesize = va->va_size;
- vp->v_type = va->va_type;
-
- if (vpops == rump_specop_p) {
- spec_node_init(vp, va->va_rdev);
- }
- vp->v_data = rn;
-
- genfs_node_init(vp, &rumpfs_genfsops);
- mutex_enter(&reclock);
- rn->rn_vp = vp;
- mutex_exit(&reclock);
-
- *vpp = vp;
-
- return 0;
-}
-
-
static void
makedir(struct rumpfs_node *rnd,
struct componentname *cnp, struct rumpfs_node *rn)
@@ -645,7 +613,6 @@
struct componentname *cnp = ap->a_cnp;
struct vnode *dvp = ap->a_dvp;
struct vnode **vpp = ap->a_vpp;
- struct vnode *vp;
struct rumpfs_node *rnd = dvp->v_data, *rn;
struct rumpfs_dent *rd = NULL;
struct etfs *et;
@@ -781,18 +748,7 @@
getvnode:
KASSERT(rn);
- mutex_enter(&reclock);
- if ((vp = rn->rn_vp)) {
- mutex_enter(vp->v_interlock);
- mutex_exit(&reclock);
- if (vget(vp, 0)) {
- goto getvnode;
- }
- *vpp = vp;
- } else {
- mutex_exit(&reclock);
- rv = makevnode(dvp->v_mount, rn, vpp);
- }
+ rv = vcache_get(dvp->v_mount, &rn, sizeof(rn), vpp);
return rv;
}
@@ -991,7 +947,7 @@
if ((cnp->cn_flags & ISWHITEOUT) != 0)
rn->rn_va.va_flags |= UF_OPAQUE;
rn->rn_parent = rnd;
- rv = makevnode(dvp->v_mount, rn, vpp);
+ rv = vcache_get(dvp->v_mount, &rn, sizeof(rn), vpp);
if (rv)
return rv;
@@ -1087,7 +1043,7 @@
DEV_BSIZE, false);
if ((cnp->cn_flags & ISWHITEOUT) != 0)
rn->rn_va.va_flags |= UF_OPAQUE;
- rv = makevnode(dvp->v_mount, rn, vpp);
+ rv = vcache_get(dvp->v_mount, &rn, sizeof(rn), vpp);
if (rv)
return rv;
@@ -1118,7 +1074,7 @@
newsize, false);
if ((cnp->cn_flags & ISWHITEOUT) != 0)
rn->rn_va.va_flags |= UF_OPAQUE;
- rv = makevnode(dvp->v_mount, rn, vpp);
+ rv = vcache_get(dvp->v_mount, &rn, sizeof(rn), vpp);
if (rv)
return rv;
@@ -1151,7 +1107,7 @@
rn = makeprivate(VLNK, va->va_mode & ALLPERMS, NODEV, linklen, false);
if ((cnp->cn_flags & ISWHITEOUT) != 0)
rn->rn_va.va_flags |= UF_OPAQUE;
- rv = makevnode(dvp->v_mount, rn, vpp);
+ rv = vcache_get(dvp->v_mount, &rn, sizeof(rn), vpp);
if (rv)
return rv;
@@ -1632,6 +1588,7 @@
struct vnode *vp = ap->a_vp;
struct rumpfs_node *rn = vp->v_data;
+ vcache_remove(vp->v_mount, &vp->v_data, sizeof(vp->v_data));
mutex_enter(&reclock);
rn->rn_vp = NULL;
mutex_exit(&reclock);
@@ -1713,6 +1670,7 @@
.vfs_statvfs = genfs_statvfs,
.vfs_sync = (void *)nullop,
.vfs_vget = rumpfs_vget,
+ .vfs_loadvnode = rumpfs_loadvnode,
.vfs_fhtovp = (void *)eopnotsupp,
.vfs_vptofh = (void *)eopnotsupp,
.vfs_init = rumpfs_init,
@@ -1740,7 +1698,7 @@
rn = makeprivate(VDIR, RUMPFS_DEFAULTMODE, NODEV, DEV_BSIZE, false);
rn->rn_parent = rn;
- if ((error = makevnode(mp, rn, &rfsmp->rfsmp_rvp)) != 0) {
+ if ((error = vcache_get(mp, &rn, sizeof(rn), &rfsmp->rfsmp_rvp)) != 0) {
kmem_free(rfsmp, sizeof(*rfsmp));
return error;
}
@@ -1814,6 +1772,45 @@
return EOPNOTSUPP;
}
+int
+rumpfs_loadvnode(struct mount *mp, struct vnode *vp,
+ const void *key, size_t key_len, const void **new_key)
+{
+ struct rumpfs_node *rn;
+ struct vattr *va;
+
+ KASSERT(!mutex_owned(&reclock));
+
+ KASSERT(key_len == sizeof(rn));
+ memcpy(&rn, key, key_len);
+
+ va = &rn->rn_va;
+
+ vp->v_tag = VT_RUMP;
+ vp->v_type = va->va_type;
+ switch (vp->v_type) {
+ case VCHR:
+ case VBLK:
+ vp->v_op = rump_specop_p;
+ spec_node_init(vp, va->va_rdev);
+ break;
+ default:
+ vp->v_op = rump_vnodeop_p;
+ break;
+ }
+ vp->v_size = vp->v_writesize = va->va_size;
+ vp->v_data = rn;
+
+ genfs_node_init(vp, &rumpfs_genfsops);
+ mutex_enter(&reclock);
+ rn->rn_vp = vp;
+ mutex_exit(&reclock);
+
+ *new_key = &vp->v_data;
+
+ return 0;
+}
+
void
rumpfs_init()
{
Home |
Main Index |
Thread Index |
Old Index