Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Change hfs from hashlist to vcache.
details: https://anonhg.NetBSD.org/src/rev/5da6a6c6abbe
branches: trunk
changeset: 331387:5da6a6c6abbe
user: hannken <hannken%NetBSD.org@localhost>
date: Sun Aug 10 08:53:22 2014 +0000
description:
Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
diffstat:
sys/fs/hfs/files.hfs | 3 +-
sys/fs/hfs/hfs.h | 19 ++--
sys/fs/hfs/hfs_nhash.c | 173 ----------------------------------------
sys/fs/hfs/hfs_vfsops.c | 131 ++++++++++++-----------------
sys/fs/hfs/hfs_vnops.c | 23 ++---
sys/modules/hfs/Makefile | 5 +-
sys/rump/fs/lib/libhfs/Makefile | 4 +-
7 files changed, 80 insertions(+), 278 deletions(-)
diffs (truncated from 604 to 300 lines):
diff -r ab5cf538e9a0 -r 5da6a6c6abbe sys/fs/hfs/files.hfs
--- a/sys/fs/hfs/files.hfs Sun Aug 10 08:27:42 2014 +0000
+++ b/sys/fs/hfs/files.hfs Sun Aug 10 08:53:22 2014 +0000
@@ -1,8 +1,7 @@
-# $NetBSD: files.hfs,v 1.2 2007/03/06 11:28:47 dillo Exp $
+# $NetBSD: files.hfs,v 1.3 2014/08/10 08:53:22 hannken Exp $
deffs HFS
-file fs/hfs/hfs_nhash.c hfs
file fs/hfs/hfs_subr.c hfs
file fs/hfs/hfs_vfsops.c hfs
file fs/hfs/hfs_vnops.c hfs
diff -r ab5cf538e9a0 -r 5da6a6c6abbe sys/fs/hfs/hfs.h
--- a/sys/fs/hfs/hfs.h Sun Aug 10 08:27:42 2014 +0000
+++ b/sys/fs/hfs/hfs.h Sun Aug 10 08:53:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs.h,v 1.8 2012/01/28 16:24:35 joerg Exp $ */
+/* $NetBSD: hfs.h,v 1.9 2014/08/10 08:53:22 hannken Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -65,9 +65,13 @@
hfs_volume hm_vol; /* essential volume information */
};
+struct hfsnode_key {
+ hfs_cnid_t hnk_cnid;
+ uint8_t hnk_fork;
+};
+
struct hfsnode {
struct genfs_node h_gnode;
- LIST_ENTRY(hfsnode) h_hash;/* hash chain */
struct vnode *h_vnode; /* vnode associated with this hnode */
struct hfsmount *h_hmp; /* mount point associated with this hnode */
struct vnode *h_devvp; /* vnode for block I/O */
@@ -92,7 +96,8 @@
*/
hfs_cnid_t h_parent;
- uint8_t h_fork;
+ struct hfsnode_key h_key;
+#define h_fork h_key.hnk_fork
long dummy; /* FOR DEVELOPMENT ONLY */
};
@@ -149,19 +154,13 @@
extern const struct vnodeopv_desc hfs_fifoop_opv_desc;
extern int (**hfs_specop_p) (void *);
extern int (**hfs_fifoop_p) (void *);
+extern struct pool hfs_node_pool;
/*
* Function prototypes
*/
-/* hfs_nhash.c */
-void hfs_nhashinit (void);
-void hfs_nhashdone (void);
-struct vnode *hfs_nhashget (dev_t, hfs_cnid_t, uint8_t, int);
-void hfs_nhashinsert (struct hfsnode *);
-void hfs_nhashremove (struct hfsnode *);
-
/* hfs_subr.c */
void hfs_vinit (struct mount *, int (**)(void *), int (**)(void *),
struct vnode **);
diff -r ab5cf538e9a0 -r 5da6a6c6abbe sys/fs/hfs/hfs_nhash.c
--- a/sys/fs/hfs/hfs_nhash.c Sun Aug 10 08:27:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/* $NetBSD: hfs_nhash.c,v 1.13 2014/02/27 16:51:38 hannken Exp $ */
-
-/*-
- * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Yevgeny Binder.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
- /*
- * Copyright (c) 1982, 1986, 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_nhash.c,v 1.13 2014/02/27 16:51:38 hannken Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/vmmeter.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/buf.h>
-#include <sys/dirent.h>
-#include <sys/msgbuf.h>
-
-#include <fs/hfs/hfs.h>
-
-LIST_HEAD(nhashhead, hfsnode) *nhashtbl;
-u_long nhash; /* size of hash table - 1 */
-#define HNOHASH(device, cnid, fork) (((device) + (cnid) + (fork)) & nhash)
-
-kmutex_t hfs_hashlock;
-kmutex_t hfs_nhash_lock;
-
-/*
- * Initialize hfsnode hash table.
- */
-void
-hfs_nhashinit(void)
-{
-
- nhashtbl = hashinit(desiredvnodes, HASH_LIST, true, &nhash);
- mutex_init(&hfs_nhash_lock, MUTEX_DEFAULT, IPL_NONE);
- mutex_init(&hfs_hashlock, MUTEX_DEFAULT, IPL_NONE);
-}
-
-/*
- * Free hfsnode hash table.
- */
-void
-hfs_nhashdone(void)
-{
-
- hashdone(nhashtbl, HASH_LIST, nhash);
- mutex_destroy(&hfs_nhash_lock);
- mutex_destroy(&hfs_hashlock);
-}
-
-/*
- * Use the device/inum pair to find the incore inode, and return a pointer
- * to it. If it is in core, but locked, wait for it.
- */
-struct vnode *
-hfs_nhashget(dev_t dev, hfs_cnid_t cnid, uint8_t fork, int flags)
-{
- struct hfsnode *hp;
- struct nhashhead *hpp;
- struct vnode *vp;
-
-loop:
- mutex_enter(&hfs_nhash_lock);
- hpp = &nhashtbl[HNOHASH(dev, cnid, fork)];
- LIST_FOREACH(hp, hpp, h_hash) {
- if (cnid == hp->h_rec.u.cnid && dev == hp->h_dev) {
- vp = HTOV(hp);
- if (flags == 0) {
- mutex_exit(&hfs_nhash_lock);
- } else {
- mutex_enter(vp->v_interlock);
- mutex_exit(&hfs_nhash_lock);
- if (vget(vp, flags))
- goto loop;
- }
- return vp;
- }
- }
- mutex_exit(&hfs_nhash_lock);
- return NULL;
-}
-
-/*
-* Insert the hfsnode into the hash table, and return it locked.
- */
-void
-hfs_nhashinsert(struct hfsnode *hp)
-{
- struct nhashhead *hpp;
- int error __diagused;
-
- /* lock the inode, then put it on the appropriate hash list */
- error = VOP_LOCK(HTOV(hp), LK_EXCLUSIVE);
- KASSERT(error == 0);
-
- mutex_enter(&hfs_nhash_lock);
- hpp = &nhashtbl[HNOHASH(hp->h_dev, hp->h_rec.u.cnid, hp->h_fork)];
- LIST_INSERT_HEAD(hpp, hp, h_hash);
- mutex_exit(&hfs_nhash_lock);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-void
-hfs_nhashremove(struct hfsnode *hp)
-{
-
- mutex_enter(&hfs_nhash_lock);
- LIST_REMOVE(hp, h_hash);
- mutex_exit(&hfs_nhash_lock);
-}
diff -r ab5cf538e9a0 -r 5da6a6c6abbe sys/fs/hfs/hfs_vfsops.c
--- a/sys/fs/hfs/hfs_vfsops.c Sun Aug 10 08:27:42 2014 +0000
+++ b/sys/fs/hfs/hfs_vfsops.c Sun Aug 10 08:53:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_vfsops.c,v 1.31 2014/04/16 18:55:18 maxv Exp $ */
+/* $NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.31 2014/04/16 18:55:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -139,7 +139,7 @@
MALLOC_JUSTDEFINE(M_HFSMNT, "hfs mount", "hfs mount structures");
-extern kmutex_t hfs_hashlock;
+struct pool hfs_node_pool;
const struct vnodeopv_desc * const hfs_vnodeopv_descs[] = {
&hfs_vnodeop_opv_desc,
@@ -159,6 +159,7 @@
.vfs_statvfs = hfs_statvfs,
.vfs_sync = hfs_sync,
.vfs_vget = hfs_vget,
+ .vfs_loadvnode = hfs_loadvnode,
.vfs_fhtovp = hfs_fhtovp,
.vfs_vptofh = hfs_vptofh,
.vfs_init = hfs_init,
@@ -507,7 +508,18 @@
int
hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
{
- return hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp);
+ int error;
+
+ error = hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp);
+ if (error)
+ return error;
+ error = vn_lock(*vpp, LK_EXCLUSIVE);
+ if (error) {
+ vrele(*vpp);
+ *vpp = NULL;
+ return error;
+ }
+ return 0;
}
/*
Home |
Main Index |
Thread Index |
Old Index