Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/cd9660 Change cd9660 from hashlist to vcache.
details: https://anonhg.NetBSD.org/src/rev/fee034c17839
branches: trunk
changeset: 329986:fee034c17839
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Jun 16 09:55:49 2014 +0000
description:
Change cd9660 from hashlist to vcache.
diffstat:
sys/fs/cd9660/cd9660_lookup.c | 48 ++---------------
sys/fs/cd9660/cd9660_node.c | 114 ++---------------------------------------
sys/fs/cd9660/cd9660_node.h | 9 +--
sys/fs/cd9660/cd9660_vfsops.c | 76 +++++++++++----------------
4 files changed, 47 insertions(+), 200 deletions(-)
diffs (truncated from 484 to 300 lines):
diff -r 538f394493eb -r fee034c17839 sys/fs/cd9660/cd9660_lookup.c
--- a/sys/fs/cd9660/cd9660_lookup.c Mon Jun 16 09:12:30 2014 +0000
+++ b/sys/fs/cd9660/cd9660_lookup.c Mon Jun 16 09:55:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_lookup.c,v 1.28 2014/06/14 07:39:28 hannken Exp $ */
+/* $NetBSD: cd9660_lookup.c,v 1.29 2014/06/16 09:55:49 hannken Exp $ */
/*-
* Copyright (c) 1989, 1993, 1994
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.28 2014/06/14 07:39:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.29 2014/06/16 09:55:49 hannken Exp $");
#include <sys/param.h>
#include <sys/namei.h>
@@ -107,8 +107,7 @@
int saveoffset = -1; /* offset of last directory entry in dir */
int numdirpasses; /* strategy for directory search */
doff_t endsearch; /* offset to end directory search */
- struct vnode *pdp; /* saved dp during symlink work */
- struct vnode *tdp; /* returned by cd9660_vget_internal */
+ struct vnode *tdp; /* returned by vcache_get */
u_long bmask; /* block offset mask */
int error;
ino_t ino = 0;
@@ -342,6 +341,7 @@
found:
if (numdirpasses == 2)
namecache_count_pass2();
+ brelse(bp, 0);
/*
* Found component in pathname.
@@ -351,44 +351,12 @@
if ((flags & ISLASTCN) && nameiop == LOOKUP)
dp->i_diroff = dp->i_offset;
- /*
- * Step through the translation in the name. We do not `iput' the
- * directory because we may need it again if a symbolic link
- * is relative to the current directory. Instead we save it
- * unlocked as "pdp". We must get the target inode before unlocking
- * the directory to insure that the inode will not be removed
- * before we get it. We prevent deadlock by always fetching
- * inodes from the root, moving down the directory tree. Thus
- * when following backward pointers ".." we must unlock the
- * parent directory before getting the requested directory.
- * There is a potential race condition here if both the current
- * and parent directories are removed before the `iget' for the
- * inode associated with ".." returns. We hope that this occurs
- * infrequently since we cannot avoid this race condition without
- * implementing a sophisticated deadlock detection algorithm.
- * Note also that this simple deadlock detection scheme will not
- * work if the file system has any hard links other than ".."
- * that point backwards in the directory structure.
- */
- pdp = vdp;
-
- /*
- * If ino is different from dp->i_ino,
- * it's a relocated directory.
- */
- brelse(bp, 0);
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp); /* race to get the inode */
- error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp);
- vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY);
- if (error)
- return error;
- *vpp = tdp;
- } else if (dp->i_number == dp->i_ino) {
+ if (dp->i_number == dp->i_ino) {
vref(vdp); /* we want ourself, ie "." */
*vpp = vdp;
} else {
- error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp);
+ error = vcache_get(vdp->v_mount,
+ &dp->i_ino, sizeof(dp->i_ino), &tdp);
if (error)
return (error);
*vpp = tdp;
@@ -399,8 +367,6 @@
*/
cache_enter(vdp, *vpp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_flags);
- if (*vpp != vdp)
- VOP_UNLOCK(*vpp);
return 0;
}
diff -r 538f394493eb -r fee034c17839 sys/fs/cd9660/cd9660_node.c
--- a/sys/fs/cd9660/cd9660_node.c Mon Jun 16 09:12:30 2014 +0000
+++ b/sys/fs/cd9660/cd9660_node.c Mon Jun 16 09:55:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_node.c,v 1.32 2014/06/14 07:39:28 hannken Exp $ */
+/* $NetBSD: cd9660_node.c,v 1.33 2014/06/16 09:55:49 hannken Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1994
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.32 2014/06/14 07:39:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.33 2014/06/16 09:55:49 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,15 +58,6 @@
#include <fs/cd9660/cd9660_mount.h>
#include <fs/cd9660/iso_rrip.h>
-/*
- * Structures associated with iso_node caching.
- */
-LIST_HEAD(ihashhead, iso_node) *isohashtbl;
-u_long isohash;
-#define INOHASH(device, inum) (((device) + ((inum)>>12)) & isohash)
-kmutex_t cd9660_ihash_lock;
-kmutex_t cd9660_hashlock;
-
extern int prtactive; /* 1 => print out reclaim of active vnodes */
struct pool cd9660_node_pool;
@@ -74,7 +65,7 @@
static u_int cd9660_chars2ui(const u_char *, int);
/*
- * Initialize hash links for inodes and dnodes.
+ * Initialize pool for nodes.
*/
void
cd9660_init(void)
@@ -83,118 +74,29 @@
malloc_type_attach(M_ISOFSMNT);
pool_init(&cd9660_node_pool, sizeof(struct iso_node), 0, 0, 0,
"cd9660nopl", &pool_allocator_nointr, IPL_NONE);
- isohashtbl = hashinit(desiredvnodes, HASH_LIST, true, &isohash);
- mutex_init(&cd9660_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
- mutex_init(&cd9660_hashlock, MUTEX_DEFAULT, IPL_NONE);
}
/*
- * Reinitialize inode hash table.
+ * Reinitialize.
*/
void
cd9660_reinit(void)
{
- struct iso_node *ip;
- struct ihashhead *oldhash1, *hash1;
- u_long oldmask1, mask1, val;
- u_int i;
- hash1 = hashinit(desiredvnodes, HASH_LIST, true, &mask1);
-
- mutex_enter(&cd9660_ihash_lock);
- oldhash1 = isohashtbl;
- oldmask1 = isohash;
- isohashtbl = hash1;
- isohash = mask1;
- for (i = 0; i <= oldmask1; i++) {
- while ((ip = LIST_FIRST(&oldhash1[i])) != NULL) {
- LIST_REMOVE(ip, i_hash);
- val = INOHASH(ip->i_dev, ip->i_number);
- LIST_INSERT_HEAD(&hash1[val], ip, i_hash);
- }
- }
- mutex_exit(&cd9660_ihash_lock);
- hashdone(oldhash1, HASH_LIST, oldmask1);
}
/*
- * Destroy node pool and hash table.
+ * Destroy node pool.
*/
void
cd9660_done(void)
{
- hashdone(isohashtbl, HASH_LIST, isohash);
pool_destroy(&cd9660_node_pool);
- mutex_destroy(&cd9660_ihash_lock);
- mutex_destroy(&cd9660_hashlock);
malloc_type_detach(M_ISOFSMNT);
}
/*
- * 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 *
-cd9660_ihashget(dev_t dev, ino_t inum, int flags)
-{
- struct iso_node *ip;
- struct vnode *vp;
-
-loop:
- mutex_enter(&cd9660_ihash_lock);
- LIST_FOREACH(ip, &isohashtbl[INOHASH(dev, inum)], i_hash) {
- if (inum == ip->i_number && dev == ip->i_dev) {
- vp = ITOV(ip);
- if (flags == 0) {
- mutex_exit(&cd9660_ihash_lock);
- } else {
- mutex_enter(vp->v_interlock);
- mutex_exit(&cd9660_ihash_lock);
- if (vget(vp, flags))
- goto loop;
- }
- return (vp);
- }
- }
- mutex_exit(&cd9660_ihash_lock);
- return (NULL);
-}
-
-/*
- * Insert the inode into the hash table, and return it locked.
- *
- * ip->i_vnode must be initialized first.
- */
-void
-cd9660_ihashins(struct iso_node *ip)
-{
- struct ihashhead *ipp;
- int error __diagused;
-
- KASSERT(mutex_owned(&cd9660_hashlock));
-
- mutex_enter(&cd9660_ihash_lock);
- ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
- LIST_INSERT_HEAD(ipp, ip, i_hash);
- mutex_exit(&cd9660_ihash_lock);
-
- error = VOP_LOCK(ITOV(ip), LK_EXCLUSIVE);
- KASSERT(error == 0);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-void
-cd9660_ihashrem(struct iso_node *ip)
-{
- mutex_enter(&cd9660_ihash_lock);
- LIST_REMOVE(ip, i_hash);
- mutex_exit(&cd9660_ihash_lock);
-}
-
-/*
* Last reference to an inode, write the inode out and if necessary,
* truncate and deallocate the file.
*/
@@ -235,9 +137,9 @@
if (prtactive && vp->v_usecount > 1)
vprint("cd9660_reclaim: pushing active", vp);
/*
- * Remove the inode from its hash chain.
+ * Remove the inode from the vnode cache.
*/
- cd9660_ihashrem(ip);
+ vcache_remove(vp->v_mount, &ip->i_number, sizeof(ip->i_number));
/*
* Purge old data structures associated with the inode.
*/
@@ -438,7 +340,7 @@
/*
* Note there is an inverse calculation in
- * cd9660_vfsops.c:cd9660_vget_internal():
+ * cd9660_vfsops.c:cd9660_loadvnode():
* ip->iso_start = ino >> imp->im_bshift;
* and also a calculation of the isodir pointer
* from an inode in cd9660_vnops.c:cd9660_readlink()
diff -r 538f394493eb -r fee034c17839 sys/fs/cd9660/cd9660_node.h
--- a/sys/fs/cd9660/cd9660_node.h Mon Jun 16 09:12:30 2014 +0000
+++ b/sys/fs/cd9660/cd9660_node.h Mon Jun 16 09:55:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_node.h,v 1.15 2014/06/14 07:39:28 hannken Exp $ */
+/* $NetBSD: cd9660_node.h,v 1.16 2014/06/16 09:55:49 hannken Exp $ */
/*-
* Copyright (c) 1994
@@ -63,7 +63,6 @@
struct iso_node {
struct genfs_node i_gnode;
- LIST_ENTRY(iso_node) i_hash;
struct vnode *i_vnode; /* vnode associated with this inode */
struct vnode *i_devvp; /* vnode for block I/O */
u_long i_flag; /* see below */
@@ -128,14 +127,8 @@
struct iso_node *, struct buf *);
void cd9660_deftstamp(struct iso_directory_record *,
struct iso_node *, struct buf *);
-struct vnode *cd9660_ihashget(dev_t, ino_t, int);
Home |
Main Index |
Thread Index |
Old Index