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/coda/coda_namecache.h

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  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: coda_namecache.h,v 1.11 2007/11/22 22:26:19 plunky Exp $       */
    2 
    3 /*
    4  *
    5  *             Coda: an Experimental Distributed File System
    6  *                              Release 3.1
    7  *
    8  *           Copyright (c) 1987-1998 Carnegie Mellon University
    9  *                          All Rights Reserved
   10  *
   11  * Permission  to  use, copy, modify and distribute this software and its
   12  * documentation is hereby granted,  provided  that  both  the  copyright
   13  * notice  and  this  permission  notice  appear  in  all  copies  of the
   14  * software, derivative works or  modified  versions,  and  any  portions
   15  * thereof, and that both notices appear in supporting documentation, and
   16  * that credit is given to Carnegie Mellon University  in  all  documents
   17  * and publicity pertaining to direct or indirect use of this code or its
   18  * derivatives.
   19  *
   20  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
   21  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
   22  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
   23  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
   24  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
   25  * ANY DERIVATIVE WORK.
   26  *
   27  * Carnegie  Mellon  encourages  users  of  this  software  to return any
   28  * improvements or extensions that  they  make,  and  to  grant  Carnegie
   29  * Mellon the rights to redistribute these changes without encumbrance.
   30  *
   31  *      @(#) coda/coda_namecache.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $
   32  */
   33 
   34 /*
   35  * Mach Operating System
   36  * Copyright (c) 1990 Carnegie-Mellon University
   37  * Copyright (c) 1989 Carnegie-Mellon University
   38  * All rights reserved.  The CMU software License Agreement specifies
   39  * the terms and conditions for use and redistribution.
   40  */
   41 
   42 /*
   43  * This code was written for the Coda file system at Carnegie Mellon University.
   44  * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
   45  */
   46 
   47 #ifndef _CODA_NC_HEADER_
   48 #define _CODA_NC_HEADER_
   49 
   50 /*
   51  * Coda constants
   52  */
   53 #define CODA_NC_NAMELEN         15              /* longest name stored in cache */
   54 #define CODA_NC_CACHESIZE        256            /* Default cache size */
   55 #define CODA_NC_HASHSIZE        64              /* Must be multiple of 2 */
   56 
   57 /*
   58  * Hash function for the primary hash.
   59  */
   60 
   61 /*
   62  * First try -- (first + last letters + length + (int)cp) mod size
   63  * 2nd try -- same, except dir fid.vnode instead of cp
   64  */
   65 
   66 #ifdef  oldhash
   67 #define CODA_NC_HASH(name, namelen, cp) \
   68         ((name[0] + name[namelen-1] + namelen + (int)(long)(cp)) \
   69           & (coda_nc_hashsize-1))
   70 #else
   71 #define CODA_NC_HASH(name, namelen, cp) \
   72         ((name[0] + (name[namelen-1]<<4) + namelen + (((int)(long)cp)>>8)) \
   73           & (coda_nc_hashsize-1))
   74 #endif
   75 
   76 #define CODA_NAMEMATCH(cp, name, namelen, dcp) \
   77         ((namelen == cp->namelen) && (dcp == cp->dcp) && \
   78                  (bcmp(cp->name,name,namelen) == 0))
   79 
   80 #define CODA_NC_VALID(cncp)     (cncp->dcp != (struct cnode *)0)
   81 
   82 #define DATA_PART(cncp) (&((cncp)->cp))
   83 #define DATA_SIZE       (sizeof(struct coda_cache) - offsetof(struct coda_cache, cp))
   84 
   85 /*
   86  * Structure for an element in the CODA Name Cache.
   87  */
   88 
   89 struct coda_cache {
   90         LIST_ENTRY(coda_cache)  hash;           /* Hash list */
   91         TAILQ_ENTRY(coda_cache) lru;            /* LRU list */
   92         struct cnode    *cp;                    /* vnode of the file */
   93         struct cnode    *dcp;                   /* parent's cnode */
   94         kauth_cred_t    cred;                   /* user credentials */
   95         char            name[CODA_NC_NAMELEN];  /* segment name */
   96         int             namelen;                /* length of name */
   97 };
   98 
   99 struct  coda_lru {              /* Start of LRU chain */
  100         TAILQ_HEAD(,coda_cache) head;
  101 };
  102 
  103 
  104 struct coda_hash {              /* Start of Hash chain */
  105         LIST_HEAD(,coda_cache)  head;
  106         int                     length; /* used for tuning purposes */
  107 };
  108 
  109 
  110 /*
  111  * Symbols to aid in debugging the namecache code. Assumes the existence
  112  * of the variable coda_nc_debug, which is defined in cfs_namecache.c
  113  */
  114 #define CODA_NC_DEBUG(N, STMT)     { if (coda_nc_debug & (1 <<N)) { STMT } }
  115 
  116 /* Prototypes of functions exported within cfs */
  117 extern void coda_nc_init(void);
  118 extern void coda_nc_enter(struct cnode *, const char *, int,
  119     kauth_cred_t, struct cnode *);
  120 extern struct cnode *coda_nc_lookup(struct cnode *, const char *, int, 
  121     kauth_cred_t);
  122 
  123 extern void coda_nc_zapParentfid(CodaFid *, enum dc_status);
  124 extern void coda_nc_zapfid(CodaFid *, enum dc_status);
  125 extern void coda_nc_zapvnode(CodaFid *, kauth_cred_t, enum dc_status);
  126 extern void coda_nc_zapfile(struct cnode *, const char *, int);
  127 extern void coda_nc_purge_user(uid_t, enum dc_status);
  128 extern void coda_nc_flush(enum dc_status);
  129 
  130 extern void print_coda_nc(void);
  131 extern void coda_nc_gather_stats(void);
  132 extern int  coda_nc_resize(int, int, enum dc_status);
  133 extern void coda_nc_name(struct cnode *cp);
  134 
  135 /*
  136  * Structure to contain statistics on the cache usage
  137  */
  138 
  139 struct coda_nc_statistics {
  140         unsigned        hits;
  141         unsigned        misses;
  142         unsigned        enters;
  143         unsigned        dbl_enters;
  144         unsigned        long_name_enters;
  145         unsigned        long_name_lookups;
  146         unsigned        long_remove;
  147         unsigned        lru_rm;
  148         unsigned        zapPfids;
  149         unsigned        zapFids;
  150         unsigned        zapFile;
  151         unsigned        zapUsers;
  152         unsigned        Flushes;
  153         unsigned        Sum_bucket_len;
  154         unsigned        Sum2_bucket_len;
  155         unsigned        Max_bucket_len;
  156         unsigned        Num_zero_len;
  157         unsigned        Search_len;
  158 };
  159 
  160 #define CODA_NC_FIND            ((u_long) 1)
  161 #define CODA_NC_REMOVE          ((u_long) 2)
  162 #define CODA_NC_INIT            ((u_long) 3)
  163 #define CODA_NC_ENTER           ((u_long) 4)
  164 #define CODA_NC_LOOKUP          ((u_long) 5)
  165 #define CODA_NC_ZAPPFID         ((u_long) 6)
  166 #define CODA_NC_ZAPFID          ((u_long) 7)
  167 #define CODA_NC_ZAPVNODE                ((u_long) 8)
  168 #define CODA_NC_ZAPFILE         ((u_long) 9)
  169 #define CODA_NC_PURGEUSER               ((u_long) 10)
  170 #define CODA_NC_FLUSH           ((u_long) 11)
  171 #define CODA_NC_PRINTCODA_NC    ((u_long) 12)
  172 #define CODA_NC_PRINTSTATS      ((u_long) 13)
  173 
  174 #endif /* _CFSNC_HEADER_ */

Cache object: 970bd17d1a626c252bc6b889e8072d62


[ 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.