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  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * 
    3  *             Coda: an Experimental Distributed File System
    4  *                              Release 3.1
    5  * 
    6  *           Copyright (c) 1987-1998 Carnegie Mellon University
    7  *                          All Rights Reserved
    8  * 
    9  * Permission  to  use, copy, modify and distribute this software and its
   10  * documentation is hereby granted,  provided  that  both  the  copyright
   11  * notice  and  this  permission  notice  appear  in  all  copies  of the
   12  * software, derivative works or  modified  versions,  and  any  portions
   13  * thereof, and that both notices appear in supporting documentation, and
   14  * that credit is given to Carnegie Mellon University  in  all  documents
   15  * and publicity pertaining to direct or indirect use of this code or its
   16  * derivatives.
   17  * 
   18  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
   19  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
   20  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
   21  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
   22  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
   23  * ANY DERIVATIVE WORK.
   24  * 
   25  * Carnegie  Mellon  encourages  users  of  this  software  to return any
   26  * improvements or extensions that  they  make,  and  to  grant  Carnegie
   27  * Mellon the rights to redistribute these changes without encumbrance.
   28  * 
   29  *      @(#) src/sys/coda/coda_namecache.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ 
   30  * $FreeBSD$
   31  * 
   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 /* 
   48  * HISTORY
   49  * $Log: coda_namecache.h,v $
   50  * Revision 1.4  1998/09/13 13:57:59  rvb
   51  * Finish conversion of cfs -> coda
   52  *
   53  * Revision 1.3  1998/09/11 18:50:17  rvb
   54  * All the references to cfs, in symbols, structs, and strings
   55  * have been changed to coda.  (Same for CFS.)
   56  *
   57  * Revision 1.2  1998/09/02 19:09:53  rvb
   58  * Pass2 complete
   59  *
   60  * Revision 1.1.1.1  1998/08/29 21:14:52  rvb
   61  * Very Preliminary Coda
   62  *
   63  * Revision 1.8  1998/08/28 18:12:25  rvb
   64  * Now it also works on FreeBSD -current.  This code will be
   65  * committed to the FreeBSD -current and NetBSD -current
   66  * trees.  It will then be tailored to the particular platform
   67  * by flushing conditional code.
   68  *
   69  * Revision 1.7  1998/08/18 17:05:24  rvb
   70  * Don't use __RCSID now
   71  *
   72  * Revision 1.6  1998/08/18 16:31:49  rvb
   73  * Sync the code for NetBSD -current; test on 1.3 later
   74  *
   75  * Revision 1.5  98/01/23  11:53:51  rvb
   76  * Bring RVB_CODA1_1 to HEAD
   77  * 
   78  * Revision 1.4.2.1  97/12/16  12:40:23  rvb
   79  * Sync with 1.3
   80  * 
   81  * Revision 1.4  97/12/05  10:39:29  rvb
   82  * Read CHANGES
   83  * 
   84  * Revision 1.3.4.3  97/11/24  15:44:51  rvb
   85  * Final cfs_venus.c w/o macros, but one locking bug
   86  * 
   87  * Revision 1.3.4.2  97/11/12  12:09:44  rvb
   88  * reorg pass1
   89  * 
   90  * Revision 1.3.4.1  97/11/06  21:06:05  rvb
   91  * don't include headers in headers
   92  * 
   93  * Revision 1.3  97/08/05  11:08:19  lily
   94  * Removed cfsnc_replace, replaced it with a coda_find, unhash, and
   95  * rehash.  This fixes a cnode leak and a bug in which the fid is
   96  * not actually replaced.  (cfs_namecache.c, cfsnc.h, cfs_subr.c)
   97  * 
   98  * Revision 1.2  96/01/02  16:57:19  bnoble
   99  * Added support for Coda MiniCache and raw inode calls (final commit)
  100  * 
  101  * Revision 1.1.2.1  1995/12/20 01:57:45  bnoble
  102  * Added CODA-specific files
  103  *
  104  * Revision 3.1.1.1  1995/03/04  19:08:22  bnoble
  105  * Branch for NetBSD port revisions
  106  *
  107  * Revision 3.1  1995/03/04  19:08:21  bnoble
  108  * Bump to major revision 3 to prepare for NetBSD port
  109  *
  110  * Revision 2.2  1994/08/28  19:37:39  luqi
  111  * Add a new CODA_REPLACE call to allow venus to replace a ViceFid in the
  112  * mini-cache.
  113  *
  114  * In "cfs.h":
  115  * Add CODA_REPLACE decl.
  116  *
  117  * In "cfs_namecache.c":
  118  * Add routine cfsnc_replace.
  119  *
  120  * In "cfs_subr.c":
  121  * Add case-statement to process CODA_REPLACE.
  122  *
  123  * In "cfsnc.h":
  124  * Add decl for CODA_NC_REPLACE.
  125  *
  126  * Revision 2.1  94/07/21  16:25:27  satya
  127  * Conversion to C++ 3.0; start of Coda Release 2.0
  128  *
  129  * Revision 1.2  92/10/27  17:58:34  lily
  130  * merge kernel/latest and alpha/src/cfs
  131  * 
  132  * Revision 2.2  90/07/05  11:27:04  mrt
  133  *      Created for the Coda File System.
  134  *      [90/05/23            dcs]
  135  * 
  136  * Revision 1.4  90/05/31  17:02:12  dcs
  137  * Prepare for merge with facilities kernel.
  138  * 
  139  * 
  140  */
  141 #ifndef _CODA_NC_HEADER_
  142 #define _CODA_NC_HEADER_
  143 
  144 /*
  145  * Coda constants
  146  */
  147 #define CODA_NC_NAMELEN 15              /* longest name stored in cache */
  148 #define CODA_NC_CACHESIZE 256           /* Default cache size */
  149 #define CODA_NC_HASHSIZE        64              /* Must be multiple of 2 */
  150 
  151 /*
  152  * Hash function for the primary hash.
  153  */
  154 
  155 /* 
  156  * First try -- (first + last letters + length + (int)cp) mod size
  157  * 2nd try -- same, except dir fid.vnode instead of cp
  158  */
  159 
  160 #ifdef  oldhash
  161 #define CODA_NC_HASH(name, namelen, cp) \
  162         ((name[0] + name[namelen-1] + namelen + (int)(cp)) & (coda_nc_hashsize-1))
  163 #else
  164 #define CODA_NC_HASH(name, namelen, cp) \
  165         ((name[0] + (name[namelen-1]<<4) + namelen + (((int)cp)>>8)) & (coda_nc_hashsize-1))
  166 #endif
  167 
  168 #define CODA_NAMEMATCH(cp, name, namelen, dcp) \
  169         ((namelen == cp->namelen) && (dcp == cp->dcp) && \
  170                  (bcmp(cp->name,name,namelen) == 0))
  171 
  172 /*
  173  * Functions to modify the hash and lru chains.
  174  * insque and remque assume that the pointers are the first thing
  175  * in the list node, thus the trickery for lru.
  176  */
  177 
  178 #define CODA_NC_HSHINS(elem, pred)      insque(elem,pred)
  179 #define CODA_NC_HSHREM(elem)            remque(elem)
  180 #define CODA_NC_HSHNUL(elem)            (elem)->hash_next = \
  181                                         (elem)->hash_prev = (elem)
  182 
  183 #define CODA_NC_LRUINS(elem, pred)      insque(LRU_PART(elem), LRU_PART(pred))
  184 #define CODA_NC_LRUREM(elem)            remque(LRU_PART(elem));
  185 #define CODA_NC_LRUGET(lruhead)         LRU_TOP((lruhead).lru_prev)
  186 
  187 #define CODA_NC_VALID(cncp)     (cncp->dcp != (struct cnode *)0)
  188  
  189 #define LRU_PART(cncp)                  (struct coda_cache *) \
  190                                 ((char *)cncp + (2*sizeof(struct coda_cache *)))
  191 #define LRU_TOP(cncp)                           (struct coda_cache *) \
  192                         ((char *)cncp - (2*sizeof(struct coda_cache *)))
  193 #define DATA_PART(cncp)                         (struct coda_cache *) \
  194                         ((char *)cncp + (4*sizeof(struct coda_cache *)))
  195 #define DATA_SIZE       (sizeof(struct coda_cache)-(4*sizeof(struct coda_cache *)))
  196 
  197 /*
  198  * Structure for an element in the CODA Name Cache.
  199  * NOTE: I use the position of arguments and their size in the
  200  * implementation of the functions CODA_NC_LRUINS, CODA_NC_LRUREM, and
  201  * DATA_PART.
  202  */
  203 
  204 struct coda_cache {     
  205         struct coda_cache       *hash_next,*hash_prev;  /* Hash list */
  206         struct coda_cache       *lru_next, *lru_prev;   /* LRU list */
  207         struct cnode    *cp;                    /* vnode of the file */
  208         struct cnode    *dcp;                   /* parent's cnode */
  209         struct ucred    *cred;                  /* user credentials */
  210         char            name[CODA_NC_NAMELEN];  /* segment name */
  211         int             namelen;                /* length of name */
  212 };
  213 
  214 struct  coda_lru {              /* Start of LRU chain */
  215         char *dummy1, *dummy2;                  /* place holders */
  216         struct coda_cache *lru_next, *lru_prev;   /* position of pointers is important */
  217 };
  218 
  219 
  220 struct coda_hash {              /* Start of Hash chain */
  221         struct coda_cache *hash_next, *hash_prev; /* NOTE: chain pointers must be first */
  222         int length;                             /* used for tuning purposes */
  223 };
  224 
  225 
  226 /* 
  227  * Symbols to aid in debugging the namecache code. Assumes the existence
  228  * of the variable coda_nc_debug, which is defined in cfs_namecache.c
  229  */
  230 #define CODA_NC_DEBUG(N, STMT)     { if (coda_nc_debug & (1 <<N)) { STMT } }
  231 
  232 /* Prototypes of functions exported within cfs */
  233 extern void coda_nc_init(void);
  234 extern void coda_nc_enter(struct cnode *, const char *, int, struct ucred *, struct cnode *);
  235 extern struct cnode *coda_nc_lookup(struct cnode *, const char *, int, struct ucred *);
  236 
  237 extern void coda_nc_zapParentfid(ViceFid *, enum dc_status);
  238 extern void coda_nc_zapfid(ViceFid *, enum dc_status);
  239 extern void coda_nc_zapvnode(ViceFid *, struct ucred *, enum dc_status);
  240 extern void coda_nc_zapfile(struct cnode *, const char *, int);
  241 extern void coda_nc_purge_user(vuid_t, enum dc_status);
  242 extern void coda_nc_flush(enum dc_status);
  243 
  244 extern void print_coda_nc(void);
  245 extern void coda_nc_gather_stats(void);
  246 extern int  coda_nc_resize(int, int, enum dc_status);
  247 extern void coda_nc_name(struct cnode *cp);
  248 
  249 /*
  250  * Structure to contain statistics on the cache usage
  251  */
  252 
  253 struct coda_nc_statistics {
  254         unsigned        hits;
  255         unsigned        misses;
  256         unsigned        enters;
  257         unsigned        dbl_enters;
  258         unsigned        long_name_enters;
  259         unsigned        long_name_lookups;
  260         unsigned        long_remove;
  261         unsigned        lru_rm;
  262         unsigned        zapPfids;
  263         unsigned        zapFids;
  264         unsigned        zapFile;
  265         unsigned        zapUsers;
  266         unsigned        Flushes;
  267         unsigned        Sum_bucket_len;
  268         unsigned        Sum2_bucket_len;
  269         unsigned        Max_bucket_len;
  270         unsigned        Num_zero_len;
  271         unsigned        Search_len;
  272 };
  273 
  274 #define CODA_NC_FIND            ((u_long) 1)
  275 #define CODA_NC_REMOVE          ((u_long) 2)
  276 #define CODA_NC_INIT            ((u_long) 3)
  277 #define CODA_NC_ENTER           ((u_long) 4)
  278 #define CODA_NC_LOOKUP          ((u_long) 5)
  279 #define CODA_NC_ZAPPFID         ((u_long) 6)
  280 #define CODA_NC_ZAPFID          ((u_long) 7)
  281 #define CODA_NC_ZAPVNODE                ((u_long) 8)
  282 #define CODA_NC_ZAPFILE         ((u_long) 9)
  283 #define CODA_NC_PURGEUSER               ((u_long) 10)
  284 #define CODA_NC_FLUSH           ((u_long) 11)
  285 #define CODA_NC_PRINTCODA_NC    ((u_long) 12)
  286 #define CODA_NC_PRINTSTATS      ((u_long) 13)
  287 
  288 #endif

Cache object: 6a7d7ef9f8b0ece6c892ef97915e86ae


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