Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/sysvbfs Change sysvbfs to vcache.
details: https://anonhg.NetBSD.org/src/rev/742c8ac0a7d0
branches: trunk
changeset: 335111:742c8ac0a7d0
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Dec 26 15:23:21 2014 +0000
description:
Change sysvbfs to vcache.
diffstat:
sys/fs/sysvbfs/sysvbfs.c | 5 +-
sys/fs/sysvbfs/sysvbfs.h | 5 +-
sys/fs/sysvbfs/sysvbfs_vfsops.c | 124 ++++++++++++++++++++--------------------
sys/fs/sysvbfs/sysvbfs_vnops.c | 10 +-
4 files changed, 71 insertions(+), 73 deletions(-)
diffs (271 lines):
diff -r 2be3a92207ec -r 742c8ac0a7d0 sys/fs/sysvbfs/sysvbfs.c
--- a/sys/fs/sysvbfs/sysvbfs.c Fri Dec 26 15:22:15 2014 +0000
+++ b/sys/fs/sysvbfs/sysvbfs.c Fri Dec 26 15:23:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs.c,v 1.14 2014/07/25 08:20:52 dholland Exp $ */
+/* $NetBSD: sysvbfs.c,v 1.15 2014/12/26 15:23:21 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.14 2014/07/25 08:20:52 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.15 2014/12/26 15:23:21 hannken Exp $");
#include <sys/resource.h>
#include <sys/param.h>
@@ -121,6 +121,7 @@
.vfs_statvfs = sysvbfs_statvfs,
.vfs_sync = sysvbfs_sync,
.vfs_vget = sysvbfs_vget,
+ .vfs_loadvnode = sysvbfs_loadvnode,
.vfs_fhtovp = sysvbfs_fhtovp,
.vfs_vptofh = sysvbfs_vptofh,
.vfs_init = sysvbfs_init,
diff -r 2be3a92207ec -r 742c8ac0a7d0 sys/fs/sysvbfs/sysvbfs.h
--- a/sys/fs/sysvbfs/sysvbfs.h Fri Dec 26 15:22:15 2014 +0000
+++ b/sys/fs/sysvbfs/sysvbfs.h Fri Dec 26 15:23:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs.h,v 1.9 2010/05/27 23:40:12 pooka Exp $ */
+/* $NetBSD: sysvbfs.h,v 1.10 2014/12/26 15:23:21 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -53,15 +53,12 @@
int update_atime;
int update_mtime;
int removed;
-
- LIST_ENTRY(sysvbfs_node) link;
};
struct sysvbfs_mount {
struct mount *mountp;
struct vnode *devvp; /* block device mounted vnode */
struct bfs *bfs;
- LIST_HEAD(, sysvbfs_node) bnode_head;
};
/* v-node ops. */
diff -r 2be3a92207ec -r 742c8ac0a7d0 sys/fs/sysvbfs/sysvbfs_vfsops.c
--- a/sys/fs/sysvbfs/sysvbfs_vfsops.c Fri Dec 26 15:22:15 2014 +0000
+++ b/sys/fs/sysvbfs/sysvbfs_vfsops.c Fri Dec 26 15:23:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs_vfsops.c,v 1.44 2014/12/07 23:48:04 justin Exp $ */
+/* $NetBSD: sysvbfs_vfsops.c,v 1.45 2014/12/26 15:23:21 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.44 2014/12/07 23:48:04 justin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.45 2014/12/26 15:23:21 hannken Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -189,7 +189,6 @@
VOP_CLOSE(devvp, oflags, NOCRED);
goto out;
}
- LIST_INIT(&bmp->bnode_head);
mp->mnt_data = bmp;
mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)devvp->v_rdev;
@@ -289,89 +288,58 @@
int
sysvbfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
{
- struct sysvbfs_mount *bmp = mp->mnt_data;
- struct sysvbfs_node *bnode;
- struct vnode *v;
+ struct vnode_iterator *marker;
+ struct vnode *vp;
int err, error;
DPRINTF("%s:\n", __func__);
error = 0;
- mutex_enter(&mntvnode_lock);
- for (bnode = LIST_FIRST(&bmp->bnode_head); bnode != NULL;
- bnode = LIST_NEXT(bnode, link)) {
- v = bnode->vnode;
- mutex_enter(v->v_interlock);
- mutex_exit(&mntvnode_lock);
- err = vget(v, LK_EXCLUSIVE | LK_NOWAIT);
- if (err == 0) {
- err = VOP_FSYNC(v, cred, FSYNC_WAIT, 0, 0);
- vput(v);
+ vfs_vnode_iterator_init(mp, &marker);
+ while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL)) != NULL) {
+ err = vn_lock(vp, LK_EXCLUSIVE);
+ if (err) {
+ vrele(vp);
+ continue;
}
+ err = VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0);
+ vput(vp);
if (err != 0)
error = err;
- mutex_enter(&mntvnode_lock);
}
- mutex_exit(&mntvnode_lock);
+ vfs_vnode_iterator_destroy(marker);
return error;
}
int
-sysvbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
+sysvbfs_loadvnode(struct mount *mp, struct vnode *vp,
+ const void *key, size_t key_len, const void **new_key)
{
- struct sysvbfs_mount *bmp = mp->mnt_data;
- struct bfs *bfs = bmp->bfs;
- struct vnode *vp;
+ struct sysvbfs_mount *bmp;
+ struct bfs *bfs;
struct sysvbfs_node *bnode;
struct bfs_inode *inode;
- int error;
+ uint16_t ino;
+
+ KASSERT(key_len == sizeof(ino));
+ memcpy(&ino, key, key_len);
- DPRINTF("%s: i-node=%lld\n", __func__, (long long)ino);
+ DPRINTF("%s: i-node=%u\n", __func__, ino);
+
+ bmp = mp->mnt_data;
+ bfs = bmp->bfs;
+
/* Lookup requested i-node */
if (!bfs_inode_lookup(bfs, ino, &inode)) {
DPRINTF("%s: bfs_inode_lookup failed.\n", __func__);
return ENOENT;
}
- retry:
- mutex_enter(&mntvnode_lock);
- for (bnode = LIST_FIRST(&bmp->bnode_head); bnode != NULL;
- bnode = LIST_NEXT(bnode, link)) {
- if (bnode->inode->number == ino) {
- vp = bnode->vnode;
- mutex_enter(vp->v_interlock);
- mutex_exit(&mntvnode_lock);
- if (vget(vp, LK_EXCLUSIVE) == 0) {
- *vpp = vp;
- return 0;
- } else {
- goto retry;
- }
- }
- }
- mutex_exit(&mntvnode_lock);
+ bnode = pool_get(&sysvbfs_node_pool, PR_WAITOK);
- /* Allocate v-node. */
- error = getnewvnode(VT_SYSVBFS, mp, sysvbfs_vnodeop_p, NULL, &vp);
- if (error) {
- DPRINTF("%s: getnewvnode error.\n", __func__);
- return error;
- }
- /* Lock vnode here */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-
- /* Allocate i-node */
- vp->v_data = pool_get(&sysvbfs_node_pool, PR_WAITOK);
- memset(vp->v_data, 0, sizeof(struct sysvbfs_node));
- bnode = vp->v_data;
- mutex_enter(&mntvnode_lock);
- LIST_INSERT_HEAD(&bmp->bnode_head, bnode, link);
- mutex_exit(&mntvnode_lock);
- bnode->vnode = vp;
- bnode->bmp = bmp;
- bnode->inode = inode;
- bnode->lockf = NULL; /* advlock */
-
+ vp->v_tag = VT_SYSVBFS;
+ vp->v_op = sysvbfs_vnodeop_p;
+ vp->v_data = bnode;
if (ino == BFS_ROOT_INODE) { /* BFS is flat filesystem */
vp->v_type = VDIR;
vp->v_vflag |= VV_ROOT;
@@ -379,8 +347,40 @@
vp->v_type = VREG;
}
+ bnode->vnode = vp;
+ bnode->bmp = bmp;
+ bnode->inode = inode;
+ bnode->lockf = NULL; /* advlock */
+
genfs_node_init(vp, &sysvbfs_genfsops);
uvm_vnp_setsize(vp, bfs_file_size(inode));
+
+ *new_key = &bnode->inode->number;
+
+ return 0;
+}
+
+int
+sysvbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
+{
+ int error;
+ uint16_t number;
+ struct vnode *vp;
+
+ KASSERT(ino <= UINT16_MAX);
+ number = ino;
+
+ DPRINTF("%s: i-node=%u\n", __func__, number);
+
+ error = vcache_get(mp, &number, sizeof(number), &vp);
+ if (error)
+ return error;
+ error = vn_lock(vp, LK_EXCLUSIVE);
+ if (error) {
+ vrele(vp);
+ return error;
+ }
+
*vpp = vp;
return 0;
diff -r 2be3a92207ec -r 742c8ac0a7d0 sys/fs/sysvbfs/sysvbfs_vnops.c
--- a/sys/fs/sysvbfs/sysvbfs_vnops.c Fri Dec 26 15:22:15 2014 +0000
+++ b/sys/fs/sysvbfs/sysvbfs_vnops.c Fri Dec 26 15:23:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs_vnops.c,v 1.55 2014/12/26 15:22:15 hannken Exp $ */
+/* $NetBSD: sysvbfs_vnops.c,v 1.56 2014/12/26 15:23:21 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.55 2014/12/26 15:22:15 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.56 2014/12/26 15:23:21 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -697,13 +697,13 @@
struct bfs *bfs = bnode->bmp->bfs;
DPRINTF("%s:\n", __func__);
+
+ vcache_remove(vp->v_mount,
+ &bnode->inode->number, sizeof(bnode->inode->number));
if (bnode->removed) {
if (bfs_inode_delete(bfs, bnode->inode->number) != 0)
DPRINTF("%s: delete inode failed\n", __func__);
}
- mutex_enter(&mntvnode_lock);
- LIST_REMOVE(bnode, link);
- mutex_exit(&mntvnode_lock);
genfs_node_destroy(vp);
pool_put(&sysvbfs_node_pool, bnode);
vp->v_data = NULL;
Home |
Main Index |
Thread Index |
Old Index