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: releng/5.1/sys/coda/coda_namecache.h 103804 2002-09-22 13:25:57Z iedowse $
   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 filesystem 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)(intptr_t)(cp)) & (coda_nc_hashsize-1))
   69 #else
   70 #define CODA_NC_HASH(name, namelen, cp) \
   71         ((name[0] + (name[namelen-1]<<4) + namelen + (((int)(intptr_t)cp)>>8)) & (coda_nc_hashsize-1))
   72 #endif
   73 
   74 #define CODA_NAMEMATCH(cp, name, namelen, dcp) \
   75         ((namelen == cp->namelen) && (dcp == cp->dcp) && \
   76                  (bcmp(cp->name,name,namelen) == 0))
   77 
   78 /*
   79  * Functions to modify the hash and lru chains.
   80  * insque and remque assume that the pointers are the first thing
   81  * in the list node, thus the trickery for lru.
   82  */
   83 
   84 #define CODA_NC_HSHINS(elem, pred)      insque(elem,pred)
   85 #define CODA_NC_HSHREM(elem)            remque(elem)
   86 #define CODA_NC_HSHNUL(elem)            (elem)->hash_next = \
   87                                         (elem)->hash_prev = (elem)
   88 
   89 #define CODA_NC_LRUINS(elem, pred)      insque(LRU_PART(elem), LRU_PART(pred))
   90 #define CODA_NC_LRUREM(elem)            remque(LRU_PART(elem));
   91 #define CODA_NC_LRUGET(lruhead)         LRU_TOP((lruhead).lru_prev)
   92 
   93 #define CODA_NC_VALID(cncp)     (cncp->dcp != (struct cnode *)0)
   94  
   95 #define LRU_PART(cncp)                  (struct coda_cache *) \
   96                                 ((char *)cncp + (2*sizeof(struct coda_cache *)))
   97 #define LRU_TOP(cncp)                           (struct coda_cache *) \
   98                         ((char *)cncp - (2*sizeof(struct coda_cache *)))
   99 #define DATA_PART(cncp)                         (struct coda_cache *) \
  100                         ((char *)cncp + (4*sizeof(struct coda_cache *)))
  101 #define DATA_SIZE       (sizeof(struct coda_cache)-(4*sizeof(struct coda_cache *)))
  102 
  103 /*
  104  * Structure for an element in the CODA Name Cache.
  105  * NOTE: I use the position of arguments and their size in the
  106  * implementation of the functions CODA_NC_LRUINS, CODA_NC_LRUREM, and
  107  * DATA_PART.
  108  */
  109 
  110 struct coda_cache {     
  111         struct coda_cache       *hash_next,*hash_prev;  /* Hash list */
  112         struct coda_cache       *lru_next, *lru_prev;   /* LRU list */
  113         struct cnode    *cp;                    /* vnode of the file */
  114         struct cnode    *dcp;                   /* parent's cnode */
  115         struct ucred    *cred;                  /* user credentials */
  116         char            name[CODA_NC_NAMELEN];  /* segment name */
  117         int             namelen;                /* length of name */
  118 };
  119 
  120 struct  coda_lru {              /* Start of LRU chain */
  121         char *dummy1, *dummy2;                  /* place holders */
  122         struct coda_cache *lru_next, *lru_prev;   /* position of pointers is important */
  123 };
  124 
  125 
  126 struct coda_hash {              /* Start of Hash chain */
  127         struct coda_cache *hash_next, *hash_prev; /* NOTE: chain pointers must be first */
  128         int length;                             /* used for tuning purposes */
  129 };
  130 
  131 
  132 /* 
  133  * Symbols to aid in debugging the namecache code. Assumes the existence
  134  * of the variable coda_nc_debug, which is defined in cfs_namecache.c
  135  */
  136 #define CODA_NC_DEBUG(N, STMT)     { if (coda_nc_debug & (1 <<N)) { STMT } }
  137 
  138 /* Prototypes of functions exported within cfs */
  139 extern void coda_nc_init(void);
  140 extern void coda_nc_enter(struct cnode *, const char *, int, struct ucred *, struct cnode *);
  141 extern struct cnode *coda_nc_lookup(struct cnode *, const char *, int, struct ucred *);
  142 
  143 extern void coda_nc_zapParentfid(ViceFid *, enum dc_status);
  144 extern void coda_nc_zapfid(ViceFid *, enum dc_status);
  145 extern void coda_nc_zapvnode(ViceFid *, struct ucred *, enum dc_status);
  146 extern void coda_nc_zapfile(struct cnode *, const char *, int);
  147 extern void coda_nc_purge_user(vuid_t, enum dc_status);
  148 extern void coda_nc_flush(enum dc_status);
  149 
  150 extern void print_coda_nc(void);
  151 extern void coda_nc_gather_stats(void);
  152 extern int  coda_nc_resize(int, int, enum dc_status);
  153 extern void coda_nc_name(struct cnode *cp);
  154 
  155 /*
  156  * Structure to contain statistics on the cache usage
  157  */
  158 
  159 struct coda_nc_statistics {
  160         unsigned        hits;
  161         unsigned        misses;
  162         unsigned        enters;
  163         unsigned        dbl_enters;
  164         unsigned        long_name_enters;
  165         unsigned        long_name_lookups;
  166         unsigned        long_remove;
  167         unsigned        lru_rm;
  168         unsigned        zapPfids;
  169         unsigned        zapFids;
  170         unsigned        zapFile;
  171         unsigned        zapUsers;
  172         unsigned        Flushes;
  173         unsigned        Sum_bucket_len;
  174         unsigned        Sum2_bucket_len;
  175         unsigned        Max_bucket_len;
  176         unsigned        Num_zero_len;
  177         unsigned        Search_len;
  178 };
  179 
  180 #define CODA_NC_FIND            ((u_long) 1)
  181 #define CODA_NC_REMOVE          ((u_long) 2)
  182 #define CODA_NC_INIT            ((u_long) 3)
  183 #define CODA_NC_ENTER           ((u_long) 4)
  184 #define CODA_NC_LOOKUP          ((u_long) 5)
  185 #define CODA_NC_ZAPPFID         ((u_long) 6)
  186 #define CODA_NC_ZAPFID          ((u_long) 7)
  187 #define CODA_NC_ZAPVNODE                ((u_long) 8)
  188 #define CODA_NC_ZAPFILE         ((u_long) 9)
  189 #define CODA_NC_PURGEUSER               ((u_long) 10)
  190 #define CODA_NC_FLUSH           ((u_long) 11)
  191 #define CODA_NC_PRINTCODA_NC    ((u_long) 12)
  192 #define CODA_NC_PRINTSTATS      ((u_long) 13)
  193 
  194 #endif

Cache object: 8d66b62c187e63eb746f229c9c243a6e


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