/* $NetBSD: coda_namecache.h,v 1.12 2009/03/18 15:14:30 cegger Exp $ */ /* * * Coda: an Experimental Distributed File System * Release 3.1 * * Copyright (c) 1987-1998 Carnegie Mellon University * All Rights Reserved * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation, and * that credit is given to Carnegie Mellon University in all documents * and publicity pertaining to direct or indirect use of this code or its * derivatives. * * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS, * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON * DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF * ANY DERIVATIVE WORK. * * Carnegie Mellon encourages users of this software to return any * improvements or extensions that they make, and to grant Carnegie * Mellon the rights to redistribute these changes without encumbrance. * * @(#) coda/coda_namecache.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $ */ /* * Mach Operating System * Copyright (c) 1990 Carnegie-Mellon University * Copyright (c) 1989 Carnegie-Mellon University * All rights reserved. The CMU software License Agreement specifies * the terms and conditions for use and redistribution. */ /* * This code was written for the Coda file system at Carnegie Mellon University. * Contributers include David Steere, James Kistler, and M. Satyanarayanan. */ #ifndef _CODA_NC_HEADER_ #define _CODA_NC_HEADER_ /* * Coda constants */ #define CODA_NC_NAMELEN 15 /* longest name stored in cache */ #define CODA_NC_CACHESIZE 256 /* Default cache size */ #define CODA_NC_HASHSIZE 64 /* Must be multiple of 2 */ /* * Hash function for the primary hash. */ /* * First try -- (first + last letters + length + (int)cp) mod size * 2nd try -- same, except dir fid.vnode instead of cp */ #ifdef oldhash #define CODA_NC_HASH(name, namelen, cp) \ ((name[0] + name[namelen-1] + namelen + (int)(long)(cp)) \ & (coda_nc_hashsize-1)) #else #define CODA_NC_HASH(name, namelen, cp) \ ((name[0] + (name[namelen-1]<<4) + namelen + (((int)(long)cp)>>8)) \ & (coda_nc_hashsize-1)) #endif #define CODA_NAMEMATCH(cp, name, namelen, dcp) \ ((namelen == cp->namelen) && (dcp == cp->dcp) && \ (memcmp(cp->name,name,namelen) == 0)) #define CODA_NC_VALID(cncp) (cncp->dcp != (struct cnode *)0) #define DATA_PART(cncp) (&((cncp)->cp)) #define DATA_SIZE (sizeof(struct coda_cache) - offsetof(struct coda_cache, cp)) /* * Structure for an element in the CODA Name Cache. */ struct coda_cache { LIST_ENTRY(coda_cache) hash; /* Hash list */ TAILQ_ENTRY(coda_cache) lru; /* LRU list */ struct cnode *cp; /* vnode of the file */ struct cnode *dcp; /* parent's cnode */ kauth_cred_t cred; /* user credentials */ char name[CODA_NC_NAMELEN]; /* segment name */ int namelen; /* length of name */ }; struct coda_lru { /* Start of LRU chain */ TAILQ_HEAD(,coda_cache) head; }; struct coda_hash { /* Start of Hash chain */ LIST_HEAD(,coda_cache) head; int length; /* used for tuning purposes */ }; /* * Symbols to aid in debugging the namecache code. Assumes the existence * of the variable coda_nc_debug, which is defined in cfs_namecache.c */ #define CODA_NC_DEBUG(N, STMT) { if (coda_nc_debug & (1 <