The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/ntfs/ntfs_ihash.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ntfs_ihash.c,v 1.5 1999/09/30 16:56:40 jdolecek Exp $  */
    2 
    3 /*
    4  * Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by the University of
   18  *      California, Berkeley and its contributors.
   19  * 4. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *      @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
   36  * $FreeBSD: releng/5.0/sys/fs/ntfs/ntfs_ihash.c 93818 2002-04-04 21:03:38Z jhb $
   37  */
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/kernel.h>
   42 #include <sys/lock.h>
   43 #include <sys/vnode.h>
   44 #include <sys/malloc.h>
   45 #include <sys/mount.h>
   46 #include <sys/mutex.h>
   47 
   48 #include <fs/ntfs/ntfs.h>
   49 #include <fs/ntfs/ntfs_inode.h>
   50 #include <fs/ntfs/ntfs_ihash.h>
   51 
   52 MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables");
   53 
   54 /*
   55  * Structures associated with inode cacheing.
   56  */
   57 static LIST_HEAD(nthashhead, ntnode) *ntfs_nthashtbl;
   58 static u_long   ntfs_nthash;            /* size of hash table - 1 */
   59 #define NTNOHASH(device, inum)  (&ntfs_nthashtbl[(minor(device) + (inum)) & ntfs_nthash])
   60 static struct mtx ntfs_nthash_mtx;
   61 struct lock ntfs_hashlock;
   62 
   63 /*
   64  * Initialize inode hash table.
   65  */
   66 void
   67 ntfs_nthashinit()
   68 {
   69         lockinit(&ntfs_hashlock, PINOD, "ntfs_nthashlock", 0, 0);
   70         ntfs_nthashtbl = hashinit(desiredvnodes, M_NTFSNTHASH, &ntfs_nthash);
   71         mtx_init(&ntfs_nthash_mtx, "ntfs nthash", NULL, MTX_DEF);
   72 }
   73 
   74 /*
   75  * Destroy inode hash table.
   76  */
   77 void
   78 ntfs_nthashdestroy(void)
   79 {
   80         lockdestroy(&ntfs_hashlock);
   81         mtx_destroy(&ntfs_nthash_mtx);
   82 }
   83 
   84 /*
   85  * Use the device/inum pair to find the incore inode, and return a pointer
   86  * to it. If it is in core, return it, even if it is locked.
   87  */
   88 struct ntnode *
   89 ntfs_nthashlookup(dev, inum)
   90         dev_t dev;
   91         ino_t inum;
   92 {
   93         struct ntnode *ip;
   94 
   95         mtx_lock(&ntfs_nthash_mtx);
   96         LIST_FOREACH(ip, NTNOHASH(dev, inum), i_hash)
   97                 if (inum == ip->i_number && dev == ip->i_dev)
   98                         break;
   99         mtx_unlock(&ntfs_nthash_mtx);
  100 
  101         return (ip);
  102 }
  103 
  104 /*
  105  * Insert the ntnode into the hash table.
  106  */
  107 void
  108 ntfs_nthashins(ip)
  109         struct ntnode *ip;
  110 {
  111         struct nthashhead *ipp;
  112 
  113         mtx_lock(&ntfs_nthash_mtx);
  114         ipp = NTNOHASH(ip->i_dev, ip->i_number);
  115         LIST_INSERT_HEAD(ipp, ip, i_hash);
  116         ip->i_flag |= IN_HASHED;
  117         mtx_unlock(&ntfs_nthash_mtx);
  118 }
  119 
  120 /*
  121  * Remove the inode from the hash table.
  122  */
  123 void
  124 ntfs_nthashrem(ip)
  125         struct ntnode *ip;
  126 {
  127         mtx_lock(&ntfs_nthash_mtx);
  128         if (ip->i_flag & IN_HASHED) {
  129                 ip->i_flag &= ~IN_HASHED;
  130                 LIST_REMOVE(ip, i_hash);
  131         }
  132         mtx_unlock(&ntfs_nthash_mtx);
  133 }

Cache object: 09631c32a182fa02362d0fc322677eda


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.