Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/v7fs Change v7fs to vcache.
details: https://anonhg.NetBSD.org/src/rev/54512a264f56
branches: trunk
changeset: 805326:54512a264f56
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Dec 29 15:29:38 2014 +0000
description:
Change v7fs to vcache.
diffstat:
sys/fs/v7fs/v7fs_extern.c | 5 +-
sys/fs/v7fs/v7fs_extern.h | 5 +-
sys/fs/v7fs/v7fs_vfsops.c | 148 +++++++++++++++++++++++----------------------
sys/fs/v7fs/v7fs_vnops.c | 11 +-
4 files changed, 85 insertions(+), 84 deletions(-)
diffs (truncated from 317 to 300 lines):
diff -r 01e6bc46b07f -r 54512a264f56 sys/fs/v7fs/v7fs_extern.c
--- a/sys/fs/v7fs/v7fs_extern.c Mon Dec 29 15:28:58 2014 +0000
+++ b/sys/fs/v7fs/v7fs_extern.c Mon Dec 29 15:29:38 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_extern.c,v 1.3 2014/07/25 08:20:52 dholland Exp $ */
+/* $NetBSD: v7fs_extern.c,v 1.4 2014/12/29 15:29:38 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_extern.c,v 1.3 2014/07/25 08:20:52 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_extern.c,v 1.4 2014/12/29 15:29:38 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
@@ -235,6 +235,7 @@
.vfs_statvfs = v7fs_statvfs,
.vfs_sync = v7fs_sync,
.vfs_vget = v7fs_vget,
+ .vfs_loadvnode = v7fs_loadvnode,
.vfs_fhtovp = v7fs_fhtovp,
.vfs_vptofh = v7fs_vptofh,
.vfs_init = v7fs_init,
diff -r 01e6bc46b07f -r 54512a264f56 sys/fs/v7fs/v7fs_extern.h
--- a/sys/fs/v7fs/v7fs_extern.h Mon Dec 29 15:28:58 2014 +0000
+++ b/sys/fs/v7fs/v7fs_extern.h Mon Dec 29 15:29:38 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_extern.h,v 1.1 2011/06/27 11:52:24 uch Exp $ */
+/* $NetBSD: v7fs_extern.h,v 1.2 2014/12/29 15:29:38 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -46,7 +46,6 @@
struct mount *mountp;
struct vnode *devvp; /* block device mounted vnode */
struct v7fs_self *core; /* filesystem dependent implementation*/
- LIST_HEAD(, v7fs_node) v7fs_node_head;
};
struct v7fs_node {
@@ -59,8 +58,6 @@
int update_ctime;
int update_atime;
int update_mtime;
-
- LIST_ENTRY(v7fs_node) link;
};
#define VFSTOV7FS(mp) ((struct v7fs_mount *)((mp)->mnt_data))
diff -r 01e6bc46b07f -r 54512a264f56 sys/fs/v7fs/v7fs_vfsops.c
--- a/sys/fs/v7fs/v7fs_vfsops.c Mon Dec 29 15:28:58 2014 +0000
+++ b/sys/fs/v7fs/v7fs_vfsops.c Mon Dec 29 15:29:38 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vfsops.c,v 1.11 2014/12/29 15:28:58 hannken Exp $ */
+/* $NetBSD: v7fs_vfsops.c,v 1.12 2014/12/29 15:29:38 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.11 2014/12/29 15:28:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.12 2014/12/29 15:29:38 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -273,8 +273,6 @@
goto err_exit;
}
- LIST_INIT(&v7fsmount->v7fs_node_head);
-
mp->mnt_data = v7fsmount;
mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)devvp->v_rdev;
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_V7FS);
@@ -368,47 +366,46 @@
return 0;
}
+static bool
+v7fs_sync_selector(void *cl, struct vnode *vp)
+{
+ struct v7fs_node *v7fs_node = vp->v_data;
+
+ if (v7fs_node == NULL)
+ return false;
+ if (!v7fs_inode_allocated(&v7fs_node->inode))
+ return false;
+
+ return true;
+}
+
int
v7fs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
{
struct v7fs_mount *v7fsmount = mp->mnt_data;
struct v7fs_self *fs = v7fsmount->core;
- struct v7fs_node *v7fs_node;
- struct v7fs_inode *inode;
- struct vnode *v;
+ struct vnode_iterator *marker;
+ struct vnode *vp;
int err, error;
- int retry_cnt;
DPRINTF("\n");
v7fs_superblock_writeback(fs);
- for (retry_cnt = 0; retry_cnt < 2; retry_cnt++) {
- error = 0;
-
- mutex_enter(&mntvnode_lock);
- for (v7fs_node = LIST_FIRST(&v7fsmount->v7fs_node_head);
- v7fs_node != NULL; v7fs_node = LIST_NEXT(v7fs_node, link)) {
- inode = &v7fs_node->inode;
- if (!v7fs_inode_allocated(inode)) {
- continue;
- }
- v = v7fs_node->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);
- }
- if (err != 0)
- error = err;
- mutex_enter(&mntvnode_lock);
+ error = 0;
+ vfs_vnode_iterator_init(mp, &marker);
+ while ((vp = vfs_vnode_iterator_next(marker,
+ v7fs_sync_selector, NULL)) != NULL) {
+ err = vn_lock(vp, LK_EXCLUSIVE);
+ if (err) {
+ vrele(vp);
+ continue;
}
- mutex_exit(&mntvnode_lock);
-
- if (error == 0)
- break;
+ err = VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0);
+ vput(vp);
+ if (err != 0)
+ error = err;
}
+ vfs_vnode_iterator_destroy(marker);
return error;
}
@@ -425,55 +422,33 @@
}
int
-v7fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
+v7fs_loadvnode(struct mount *mp, struct vnode *vp,
+ const void *key, size_t key_len, const void **new_key)
{
- struct v7fs_mount *v7fsmount = mp->mnt_data;
- struct v7fs_self *fs = v7fsmount->core;
- struct vnode *vp;
+ struct v7fs_mount *v7fsmount;
+ struct v7fs_self *fs;
struct v7fs_node *v7fs_node;
struct v7fs_inode inode;
+ v7fs_ino_t number;
int error;
+ KASSERT(key_len == sizeof(number));
+ memcpy(&number, key, key_len);
+
+ v7fsmount = mp->mnt_data;
+ fs = v7fsmount->core;
+
/* Lookup requested i-node */
- if ((error = v7fs_inode_load(fs, &inode, ino))) {
+ if ((error = v7fs_inode_load(fs, &inode, number))) {
DPRINTF("v7fs_inode_load failed.\n");
return error;
}
-retry:
- mutex_enter(&mntvnode_lock);
- for (v7fs_node = LIST_FIRST(&v7fsmount->v7fs_node_head);
- v7fs_node != NULL; v7fs_node = LIST_NEXT(v7fs_node, link)) {
- if (v7fs_node->inode.inode_number == ino) {
- vp = v7fs_node->vnode;
- mutex_enter(vp->v_interlock);
- mutex_exit(&mntvnode_lock);
- if (vget(vp, LK_EXCLUSIVE) == 0) {
- *vpp = vp;
- return 0;
- } else {
- DPRINTF("retry!\n");
- goto retry;
- }
- }
- }
- mutex_exit(&mntvnode_lock);
+ v7fs_node = pool_get(&v7fs_node_pool, PR_WAITOK);
+ memset(v7fs_node, 0, sizeof(*v7fs_node));
- /* Allocate v-node. */
- if ((error = getnewvnode(VT_V7FS, mp, v7fs_vnodeop_p, NULL, &vp))) {
- DPRINTF("getnewvnode error.\n");
- return error;
- }
- /* Lock vnode here */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-
- /* Allocate i-node */
- vp->v_data = pool_get(&v7fs_node_pool, PR_WAITOK);
- memset(vp->v_data, 0, sizeof(*v7fs_node));
- v7fs_node = vp->v_data;
- mutex_enter(&mntvnode_lock);
- LIST_INSERT_HEAD(&v7fsmount->v7fs_node_head, v7fs_node, link);
- mutex_exit(&mntvnode_lock);
+ vp->v_tag = VT_V7FS;
+ vp->v_data = v7fs_node;
v7fs_node->vnode = vp;
v7fs_node->v7fsmount = v7fsmount;
v7fs_node->inode = inode;/*structure copy */
@@ -482,9 +457,10 @@
genfs_node_init(vp, &v7fs_genfsops);
uvm_vnp_setsize(vp, v7fs_inode_filesize(&inode));
- if (ino == V7FS_ROOT_INODE) {
+ if (number == V7FS_ROOT_INODE) {
vp->v_type = VDIR;
vp->v_vflag |= VV_ROOT;
+ vp->v_op = v7fs_vnodeop_p;
} else {
vp->v_type = v7fs_mode_to_vtype(inode.mode);
@@ -494,15 +470,41 @@
spec_node_init(vp, rdev);
} else if (vp->v_type == VFIFO) {
vp->v_op = v7fs_fifoop_p;
+ } else {
+ vp->v_op = v7fs_vnodeop_p;
}
}
+ *new_key = &v7fs_node->inode.inode_number;
+
+ return 0;
+}
+
+
+int
+v7fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
+{
+ int error;
+ v7fs_ino_t number;
+ struct vnode *vp;
+
+ KASSERT(ino <= UINT16_MAX);
+ number = ino;
+
+ 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;
}
-
int
v7fs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp)
{
diff -r 01e6bc46b07f -r 54512a264f56 sys/fs/v7fs/v7fs_vnops.c
--- a/sys/fs/v7fs/v7fs_vnops.c Mon Dec 29 15:28:58 2014 +0000
+++ b/sys/fs/v7fs/v7fs_vnops.c Mon Dec 29 15:29:38 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vnops.c,v 1.19 2014/12/29 15:28:58 hannken Exp $ */
+/* $NetBSD: v7fs_vnops.c,v 1.20 2014/12/29 15:29:38 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.19 2014/12/29 15:28:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.20 2014/12/29 15:29:38 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
Home |
Main Index |
Thread Index |
Old Index