Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Change efs from hashlist to vcache.



details:   https://anonhg.NetBSD.org/src/rev/1a02cd87d54a
branches:  trunk
changeset: 331279:1a02cd87d54a
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Aug 07 08:24:23 2014 +0000

description:
Change efs from hashlist to vcache.

diffstat:

 sys/fs/efs/efs_ihash.c          |  209 ----------------------------------------
 sys/fs/efs/efs_ihash.h          |   31 -----
 sys/fs/efs/efs_vfsops.c         |  117 +++++++++-------------
 sys/fs/efs/efs_vnops.c          |   34 +----
 sys/fs/efs/files.efs            |    3 +-
 sys/modules/efs/Makefile        |    4 +-
 sys/rump/fs/lib/libefs/Makefile |    4 +-
 7 files changed, 62 insertions(+), 340 deletions(-)

diffs (truncated from 611 to 300 lines):

diff -r 43272648008c -r 1a02cd87d54a sys/fs/efs/efs_ihash.c
--- a/sys/fs/efs/efs_ihash.c    Thu Aug 07 07:51:28 2014 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*     $NetBSD: efs_ihash.c,v 1.10 2014/02/27 16:51:38 hannken Exp $   */
-
-/*
- * 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.
- *
- *     @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
- */
-
-/*
- * This code shamelessly stolen from ufs/ufs/ufs_ihash.c.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_ihash.c,v 1.10 2014/02/27 16:51:38 hannken Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/proc.h>
-#include <sys/mutex.h>
-
-#include <miscfs/genfs/genfs_node.h>
-
-#include <fs/efs/efs.h>
-#include <fs/efs/efs_sb.h>
-#include <fs/efs/efs_dir.h>
-#include <fs/efs/efs_genfs.h>
-#include <fs/efs/efs_mount.h>
-#include <fs/efs/efs_extent.h>
-#include <fs/efs/efs_dinode.h>
-#include <fs/efs/efs_inode.h>
-#include <fs/efs/efs_subr.h>
-#include <fs/efs/efs_ihash.h>
-
-MALLOC_DECLARE(M_EFSINO);
-
-/*
- * Structures associated with inode caching.
- */
-static LIST_HEAD(ihashhead, efs_inode) *ihashtbl;
-static u_long  ihash;          /* size of hash table - 1 */
-#define INOHASH(device, inum)  (((device) + (inum)) & ihash)
-
-static kmutex_t        efs_ihash_lock;
-static kmutex_t        efs_hashlock;
-
-/*
- * Initialize inode hash table.
- */
-void
-efs_ihashinit(void)
-{
-
-       mutex_init(&efs_hashlock, MUTEX_DEFAULT, IPL_NONE);
-       mutex_init(&efs_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
-       ihashtbl = hashinit(desiredvnodes, HASH_LIST, true, &ihash);
-}
-
-/*
- * Reinitialize inode hash table.
- */
-
-void
-efs_ihashreinit(void)
-{
-       struct efs_inode *eip;
-       struct ihashhead *oldhash, *hash;
-       u_long oldmask, mask, val;
-       int i;
-
-       hash = hashinit(desiredvnodes, HASH_LIST, true, &mask);
-       mutex_enter(&efs_ihash_lock);
-       oldhash = ihashtbl;
-       oldmask = ihash;
-       ihashtbl = hash;
-       ihash = mask;
-       for (i = 0; i <= oldmask; i++) {
-               while ((eip = LIST_FIRST(&oldhash[i])) != NULL) {
-                       LIST_REMOVE(eip, ei_hash);
-                       val = INOHASH(eip->ei_dev, eip->ei_number);
-                       LIST_INSERT_HEAD(&hash[val], eip, ei_hash);
-               }
-       }
-       mutex_exit(&efs_ihash_lock);
-       hashdone(oldhash, HASH_LIST, oldmask);
-}
-
-/*
- * Free inode hash table.
- */
-void
-efs_ihashdone(void)
-{
-
-       hashdone(ihashtbl, HASH_LIST, ihash);
-       mutex_destroy(&efs_hashlock);
-       mutex_destroy(&efs_ihash_lock);
-}
-
-/*
- * 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 *
-efs_ihashget(dev_t dev, ino_t inum, int flags)
-{
-       struct ihashhead *ipp;
-       struct efs_inode *eip;
-       struct vnode *vp;
-
- loop:
-       mutex_enter(&efs_ihash_lock);
-       ipp = &ihashtbl[INOHASH(dev, inum)];
-       LIST_FOREACH(eip, ipp, ei_hash) {
-               if (inum == eip->ei_number && dev == eip->ei_dev) {
-                       vp = EFS_ITOV(eip);
-                       if (flags == 0) {
-                               mutex_exit(&efs_ihash_lock);
-                       } else {
-                               mutex_enter(vp->v_interlock);
-                               mutex_exit(&efs_ihash_lock);
-                               if (vget(vp, flags))
-                                       goto loop;
-                       }
-                       return (vp);
-               }
-       }
-       mutex_exit(&efs_ihash_lock);
-       return (NULL);
-}
-
-/*
- * Insert the inode into the hash table, and return it locked.
- */
-void
-efs_ihashins(struct efs_inode *eip)
-{
-       struct ihashhead *ipp;
-       int error __diagused;
-
-       KASSERT(mutex_owned(&efs_hashlock));
-
-       /* lock the inode, then put it on the appropriate hash list */
-       error = VOP_LOCK(EFS_ITOV(eip), LK_EXCLUSIVE);
-       KASSERT(error == 0);
-
-       mutex_enter(&efs_ihash_lock);
-       ipp = &ihashtbl[INOHASH(eip->ei_dev, eip->ei_number)];
-       LIST_INSERT_HEAD(ipp, eip, ei_hash);
-       mutex_exit(&efs_ihash_lock);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-void
-efs_ihashrem(struct efs_inode *eip)
-{
-
-       mutex_enter(&efs_ihash_lock);
-       LIST_REMOVE(eip, ei_hash);
-       mutex_exit(&efs_ihash_lock);
-}
-
-/*
- * Grab the global inode hash lock.
- */
-void
-efs_ihashlock(void)
-{
-
-       mutex_enter(&efs_hashlock);
-}
-
-/*
- * Release the global inode hash lock.
- */
-void
-efs_ihashunlock(void)
-{
-
-       mutex_exit(&efs_hashlock);
-}
diff -r 43272648008c -r 1a02cd87d54a sys/fs/efs/efs_ihash.h
--- a/sys/fs/efs/efs_ihash.h    Thu Aug 07 07:51:28 2014 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*     $NetBSD: efs_ihash.h,v 1.1 2007/06/29 23:30:29 rumble Exp $     */
-
-/*
- * Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _FS_EFS_EFS_IHASH_H_
-#define _FS_EFS_EFS_IHASH_H_
-
-void           efs_ihashinit(void);
-void           efs_ihashreinit(void);
-void           efs_ihashdone(void);
-struct vnode   *efs_ihashget(dev_t, ino_t, int);
-void           efs_ihashins(struct efs_inode *);
-void           efs_ihashrem(struct efs_inode *);
-void           efs_ihashlock(void);
-void           efs_ihashunlock(void);
-
-#endif /* !_FS_EFS_EFS_IHASH_H_ */
diff -r 43272648008c -r 1a02cd87d54a sys/fs/efs/efs_vfsops.c
--- a/sys/fs/efs/efs_vfsops.c   Thu Aug 07 07:51:28 2014 +0000
+++ b/sys/fs/efs/efs_vfsops.c   Thu Aug 07 08:24:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efs_vfsops.c,v 1.25 2014/04/16 18:55:18 maxv Exp $     */
+/*     $NetBSD: efs_vfsops.c,v 1.26 2014/08/07 08:24:23 hannken Exp $  */
 
 /*
  * Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.25 2014/04/16 18:55:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.26 2014/08/07 08:24:23 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -47,7 +47,6 @@
 #include <fs/efs/efs_dinode.h>
 #include <fs/efs/efs_inode.h>
 #include <fs/efs/efs_subr.h>
-#include <fs/efs/efs_ihash.h>
 
 MODULE(MODULE_CLASS_VFS, efs, NULL);
 
@@ -341,74 +340,53 @@
 /*
  * Obtain a locked vnode for the given on-disk inode number.
  *
- * We currently allocate a new vnode from getnewnode(), tack it with
- * our in-core inode structure (efs_inode), and read in the inode from
- * disk. The returned inode must be locked.
- *
  * Returns 0 on success.
  */
 static int
 efs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
 {
-       int err;
-       struct vnode *vp;
+       int error;
+
+       error = vcache_get(mp, &ino, sizeof(ino), vpp);
+       if (error)
+               return error;
+       error = vn_lock(*vpp, LK_EXCLUSIVE);
+       if (error) {
+               vrele(*vpp);
+               *vpp = NULL;
+               return error;
+       }



Home | Main Index | Thread Index | Old Index