xref: /onnv-gate/usr/src/uts/common/sys/dnlc.h (revision 1484:d330e98f8ed7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1484Sek110237  * Common Development and Distribution License (the "License").
6*1484Sek110237  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1484Sek110237  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
310Sstevel@tonic-gate  * The Regents of the University of California
320Sstevel@tonic-gate  * All Rights Reserved
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
350Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
360Sstevel@tonic-gate  * contributors.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifndef _SYS_DNLC_H
400Sstevel@tonic-gate #define	_SYS_DNLC_H
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #ifdef	__cplusplus
450Sstevel@tonic-gate extern "C" {
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #include <sys/kstat.h>
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
510Sstevel@tonic-gate  * DNLC - Directory name lookup cache.
520Sstevel@tonic-gate  * There are now two sorts of name caching:
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  * Standard dnlc: This original cache holds recent mappings
550Sstevel@tonic-gate  *                of <directory vnode, name> to vnode mappings.
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  * Directory caches: Entire large directories can be cached, subject to
580Sstevel@tonic-gate  *		     memory availability and tunables. A directory cache
590Sstevel@tonic-gate  *		     anchor point must be provided in the xxnode for
600Sstevel@tonic-gate  *		     a directory.
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * Standard dnlc
660Sstevel@tonic-gate  * =============
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /*
700Sstevel@tonic-gate  * This structure describes the elements in the cache of recent
710Sstevel@tonic-gate  * names looked up.
720Sstevel@tonic-gate  *
730Sstevel@tonic-gate  * Note namlen is a uchar_t to conserve space
740Sstevel@tonic-gate  * and alignment padding. The max length of any
750Sstevel@tonic-gate  * pathname component is defined as MAXNAMELEN
760Sstevel@tonic-gate  * which is 256 (including the terminating null).
770Sstevel@tonic-gate  * So provided this doesn't change, we don't include the null,
780Sstevel@tonic-gate  * we always use bcmp to compare strings, and we don't start
790Sstevel@tonic-gate  * storing full names, then we are ok. The space savings are worth it.
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate typedef struct ncache {
820Sstevel@tonic-gate 	struct ncache *hash_next; 	/* hash chain, MUST BE FIRST */
830Sstevel@tonic-gate 	struct ncache *hash_prev;
840Sstevel@tonic-gate 	struct vnode *vp;		/* vnode the name refers to */
850Sstevel@tonic-gate 	struct vnode *dp;		/* vnode of parent of name */
860Sstevel@tonic-gate 	int hash;			/* hash signature */
870Sstevel@tonic-gate 	uchar_t namlen;			/* length of name */
880Sstevel@tonic-gate 	char name[1];			/* segment name - null terminated */
890Sstevel@tonic-gate } ncache_t;
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * Hash table bucket structure of name cache entries for fast lookup.
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate typedef struct nc_hash	{
950Sstevel@tonic-gate 	ncache_t *hash_next;
960Sstevel@tonic-gate 	ncache_t *hash_prev;
970Sstevel@tonic-gate 	kmutex_t hash_lock;
980Sstevel@tonic-gate } nc_hash_t;
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * Statistics on name cache
1020Sstevel@tonic-gate  * Not protected by locks
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * ncstats has been deprecated, due to the integer size of the counters
1060Sstevel@tonic-gate  * which can easily overflow in the dnlc.
1070Sstevel@tonic-gate  * It is maintained (at some expense) for compatability.
1080Sstevel@tonic-gate  * The preferred interface is the kstat accessible nc_stats below, ehich
1090Sstevel@tonic-gate  * is actually shared with directory caching.
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate struct ncstats {
1120Sstevel@tonic-gate 	int	hits;		/* hits that we can really use */
1130Sstevel@tonic-gate 	int	misses;		/* cache misses */
1140Sstevel@tonic-gate 	int	enters;		/* number of enters done */
1150Sstevel@tonic-gate 	int	dbl_enters;	/* number of enters tried when already cached */
1160Sstevel@tonic-gate 	int	long_enter;	/* deprecated, no longer accounted */
1170Sstevel@tonic-gate 	int	long_look;	/* deprecated, no longer accounted */
1180Sstevel@tonic-gate 	int	move_to_front;	/* entry moved to front of hash chain */
1190Sstevel@tonic-gate 	int	purges;		/* number of purges of cache */
1200Sstevel@tonic-gate };
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate struct nc_stats {
1230Sstevel@tonic-gate 	kstat_named_t ncs_hits;		/* cache hits */
1240Sstevel@tonic-gate 	kstat_named_t ncs_misses;	/* cache misses */
1250Sstevel@tonic-gate 	kstat_named_t ncs_neg_hits;	/* negative cache hits */
1260Sstevel@tonic-gate 	kstat_named_t ncs_enters;	/* enters */
1270Sstevel@tonic-gate 	kstat_named_t ncs_dbl_enters;	/* enters when entry already cached */
1280Sstevel@tonic-gate 	kstat_named_t ncs_purge_total;	/* total entries prurged */
1290Sstevel@tonic-gate 	kstat_named_t ncs_purge_all;	/* dnlc_purge() calls */
1300Sstevel@tonic-gate 	kstat_named_t ncs_purge_vp;	/* dnlc_purge_vp() calls */
1310Sstevel@tonic-gate 	kstat_named_t ncs_purge_vfs;	/* dnlc_purge_vfs() calls */
1320Sstevel@tonic-gate 	kstat_named_t ncs_purge_fs1;	/* dnlc_purge_fs1() calls */
1330Sstevel@tonic-gate 	kstat_named_t ncs_pick_free;	/* found a free ncache */
1340Sstevel@tonic-gate 	kstat_named_t ncs_pick_heur;	/* found ncache w/ NULL vpages */
1350Sstevel@tonic-gate 	kstat_named_t ncs_pick_last;	/* found last ncache on chain */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 	/* directory caching stats */
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate 	kstat_named_t ncs_dir_hits;	/* dir cache hits */
1400Sstevel@tonic-gate 	kstat_named_t ncs_dir_misses;	/* dir cache misses */
1410Sstevel@tonic-gate 	kstat_named_t ncs_cur_dirs;	/* current # directories cached */
1420Sstevel@tonic-gate 	kstat_named_t ncs_dir_num_ents;	/* current # entries cached */
1430Sstevel@tonic-gate 	kstat_named_t ncs_dirs_cached;	/* total # directories cached */
1440Sstevel@tonic-gate 	kstat_named_t ncs_dir_start_nm;	/* dir start no memory */
1450Sstevel@tonic-gate 	kstat_named_t ncs_dir_add_nm;	/* add entry/space - no memory */
1460Sstevel@tonic-gate 	kstat_named_t ncs_dir_addabort;	/* add entry/space - abort */
1470Sstevel@tonic-gate 	kstat_named_t ncs_dir_add_max;	/* add entry/space - max exceeded */
1480Sstevel@tonic-gate 	kstat_named_t ncs_dir_reme_fai;	/* remove entry fail */
1490Sstevel@tonic-gate 	kstat_named_t ncs_dir_rems_fai;	/* remove space fail */
1500Sstevel@tonic-gate 	kstat_named_t ncs_dir_upd_fail;	/* update space fail */
1510Sstevel@tonic-gate 	kstat_named_t ncs_dir_finipurg;	/* fini purges */
1520Sstevel@tonic-gate 	kstat_named_t ncs_dir_rec_last;	/* reclaim last */
1530Sstevel@tonic-gate 	kstat_named_t ncs_dir_recl_any;	/* reclaim any */
1540Sstevel@tonic-gate };
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate /*
1570Sstevel@tonic-gate  * The dnlc hashing function.
1580Sstevel@tonic-gate  * Although really a kernel macro we export it to allow validation
1590Sstevel@tonic-gate  * of ncache_t entries by mdb. Note, mdb can handle the ASSERT.
1600Sstevel@tonic-gate  *
1610Sstevel@tonic-gate  * 'hash' and 'namlen' must be l-values. A check is made to ensure
1620Sstevel@tonic-gate  * the name length fits into an unsigned char (see ncache_t).
1630Sstevel@tonic-gate  */
1640Sstevel@tonic-gate #define	DNLCHASH(name, dvp, hash, namlen)			\
1650Sstevel@tonic-gate 	{							\
1660Sstevel@tonic-gate 		char Xc, *Xcp;					\
1670Sstevel@tonic-gate 		hash = (int)((uintptr_t)(dvp)) >> 8;		\
1680Sstevel@tonic-gate 		for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++)	\
1690Sstevel@tonic-gate 			(hash) = ((hash) << 4) + (hash) + Xc;	\
1700Sstevel@tonic-gate 		ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1));	\
1710Sstevel@tonic-gate 		(namlen) = Xcp - (name);			\
1720Sstevel@tonic-gate 	}
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate #if defined(_KERNEL)
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate #include <sys/vfs.h>
1770Sstevel@tonic-gate #include <sys/vnode.h>
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate extern int ncsize;		/* set in param_init() # of dnlc entries */
1800Sstevel@tonic-gate extern vnode_t negative_cache_vnode;
1810Sstevel@tonic-gate #define	DNLC_NO_VNODE &negative_cache_vnode
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate void	dnlc_init(void);
1840Sstevel@tonic-gate void	dnlc_enter(vnode_t *, char *, vnode_t *);
1850Sstevel@tonic-gate void	dnlc_update(vnode_t *, char *, vnode_t *);
1860Sstevel@tonic-gate vnode_t	*dnlc_lookup(vnode_t *, char *);
1870Sstevel@tonic-gate void	dnlc_purge(void);
1880Sstevel@tonic-gate void	dnlc_purge_vp(vnode_t *);
1890Sstevel@tonic-gate int	dnlc_purge_vfsp(vfs_t *, int);
1900Sstevel@tonic-gate void	dnlc_remove(vnode_t *, char *);
1910Sstevel@tonic-gate int	dnlc_fs_purge1(struct vnodeops *);
1920Sstevel@tonic-gate vnode_t	*dnlc_reverse_lookup(vnode_t *, char *, size_t);
193*1484Sek110237 void	dnlc_reduce_cache(void *);
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * Directory caching interfaces
2000Sstevel@tonic-gate  * ============================
2010Sstevel@tonic-gate  */
2020Sstevel@tonic-gate 
2030Sstevel@tonic-gate /*
2040Sstevel@tonic-gate  * Typically for large directories, the file names will be the same or
2050Sstevel@tonic-gate  * at least similar lengths. So there's no point in anything more elaborate
2060Sstevel@tonic-gate  * than a simple unordered linked list of free space entries.
2070Sstevel@tonic-gate  * For small directories the name length distribution doesn't really matter.
2080Sstevel@tonic-gate  */
2090Sstevel@tonic-gate typedef struct dcfree {
2100Sstevel@tonic-gate 	uint64_t df_handle;		/* fs supplied handle */
2110Sstevel@tonic-gate 	struct dcfree *df_next; 	/* link to next free entry in bucket */
2120Sstevel@tonic-gate 	uint_t df_len;			/* length of free entry */
2130Sstevel@tonic-gate } dcfree_t;
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate typedef struct dcentry {
2160Sstevel@tonic-gate 	uint64_t de_handle;		/* fs supplied and returned data */
2170Sstevel@tonic-gate 	struct dcentry *de_next;	/* link to next name entry in bucket */
2180Sstevel@tonic-gate 	int de_hash;			/* hash signature */
2190Sstevel@tonic-gate 	uchar_t de_namelen;		/* length of name excluding null */
2200Sstevel@tonic-gate 	char de_name[1];		/* null terminated name */
2210Sstevel@tonic-gate } dcentry_t;
2220Sstevel@tonic-gate 
2230Sstevel@tonic-gate typedef struct dircache {
2240Sstevel@tonic-gate 	struct dircache *dc_next;	/* chain - for purge purposes */
2250Sstevel@tonic-gate 	struct dircache *dc_prev;	/* chain - for purge purposes */
2260Sstevel@tonic-gate 	int64_t dc_actime;		/* dir access time, from lbolt64 */
2270Sstevel@tonic-gate 	dcentry_t **dc_namehash;	/* entry hash table pointer */
2280Sstevel@tonic-gate 	dcfree_t **dc_freehash;		/* free entry hash table pointer */
2290Sstevel@tonic-gate 	uint_t dc_num_entries;		/* no of named entries */
2300Sstevel@tonic-gate 	uint_t dc_num_free;		/* no of free space entries */
2310Sstevel@tonic-gate 	uint_t dc_nhash_mask;		/* name hash table size - 1 */
2320Sstevel@tonic-gate 	uint_t dc_fhash_mask;		/* free space hash table size - 1 */
2330Sstevel@tonic-gate 	struct dcanchor *dc_anchor;	/* back ptr to anchor */
2340Sstevel@tonic-gate 	boolean_t dc_complete;		/* cache complete boolean */
2350Sstevel@tonic-gate } dircache_t;
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate typedef struct dcanchor {
2380Sstevel@tonic-gate 	void *dca_dircache;	/* pointer to directory cache */
2390Sstevel@tonic-gate 	kmutex_t dca_lock;		/* protects the directory cache */
2400Sstevel@tonic-gate } dcanchor_t;
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate /*
2430Sstevel@tonic-gate  * Head struct for doubly linked chain of dircache_t
2440Sstevel@tonic-gate  * The next and prev fields must match those of a dircache_t
2450Sstevel@tonic-gate  */
2460Sstevel@tonic-gate typedef struct {
2470Sstevel@tonic-gate 	dircache_t *dch_next;		/* next in chain */
2480Sstevel@tonic-gate 	dircache_t *dch_prev;		/* prev in chain */
2490Sstevel@tonic-gate 	kmutex_t dch_lock;		/* lock for the chain */
2500Sstevel@tonic-gate } dchead_t;
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate #if defined(_KERNEL)
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate /*
2560Sstevel@tonic-gate  * Status returns from the directory cache interfaces
2570Sstevel@tonic-gate  */
2580Sstevel@tonic-gate typedef enum {
2590Sstevel@tonic-gate 	DOK,		/* operation sucessful */
2600Sstevel@tonic-gate 	DNOCACHE,	/* there is no cache */
2610Sstevel@tonic-gate 	DFOUND,		/* entry found */
2620Sstevel@tonic-gate 	DNOENT,		/* no entry found */
2630Sstevel@tonic-gate 	DTOOBIG,	/* exceeds tunable dnlc_max_dir_cache */
2640Sstevel@tonic-gate 	DNOMEM		/* no memory */
2650Sstevel@tonic-gate } dcret_t;
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate /*
2680Sstevel@tonic-gate  * dnlc_dir_start() requests that a directory be cached.
2690Sstevel@tonic-gate  * This must be called initially to enable caching on a directory.
2700Sstevel@tonic-gate  * After a successful call, directory entries and free space can be
2710Sstevel@tonic-gate  * added (see below) until the directory is marked complete.
2720Sstevel@tonic-gate  * "num_entries" is an estimate of the current number of
2730Sstevel@tonic-gate  * directory entries. The request is rejected with DNOCACHE
2740Sstevel@tonic-gate  * if num_entries falls below the tunable dnlc_dir_min_size (see
2750Sstevel@tonic-gate  * below), and rejected with DTOOBIG if it's above dnlc_dir_max_size.
2760Sstevel@tonic-gate  * Returns DOK, DNOCACHE, DTOOBIG, DNOMEM.
2770Sstevel@tonic-gate  *
2780Sstevel@tonic-gate  * Due to memory shortages, directory caches can be purged at
2790Sstevel@tonic-gate  * any time. If the last directory cache is purged due to memory
2800Sstevel@tonic-gate  * shortage, then the directory cache is marked internally
2810Sstevel@tonic-gate  * as "no memory". Future returns will all be DNOCACHE until
2820Sstevel@tonic-gate  * the next dnlc_start_dir() which will return DNOMEM once.
2830Sstevel@tonic-gate  * This memory shortage may only be transient. It's up to the
2840Sstevel@tonic-gate  * file system as to what to do about this condition, but an
2850Sstevel@tonic-gate  * attempt to immediately re-build the cache will very likely
2860Sstevel@tonic-gate  * lead to the same shortage of memory and a thrashing situation.
2870Sstevel@tonic-gate  *
2880Sstevel@tonic-gate  * It's file system policy as to when and what size directories to cache.
2890Sstevel@tonic-gate  */
2900Sstevel@tonic-gate dcret_t dnlc_dir_start(dcanchor_t *dcap, uint_t num_entries);
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate /*
2930Sstevel@tonic-gate  * dnlc_dir_add_entry() adds an entry (name and handle) into a
2940Sstevel@tonic-gate  * partial or complete cache. "handle" is a file system specific
2950Sstevel@tonic-gate  * quantity that is returned on calls to dnlc_dir_lookup() - see below.
2960Sstevel@tonic-gate  * For example, "handle" for ufs holds the inumber and a directory
2970Sstevel@tonic-gate  * entry offset. Returns DOK, DNOCACHE, DTOOBIG.
2980Sstevel@tonic-gate  */
2990Sstevel@tonic-gate dcret_t dnlc_dir_add_entry(dcanchor_t *dcap, char *name, uint64_t handle);
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * dnlc_dir_add_space adds free space (length and file system specific
3030Sstevel@tonic-gate  * handle) into a partial or complete cache. "handle" is a file
3040Sstevel@tonic-gate  * system specific quantity that is returned on calls to
3050Sstevel@tonic-gate  * dnlc_dir_rem_space_by_len(). For example, "handle" for ufs holds
3060Sstevel@tonic-gate  * the directory entry offset.  Returns DOK, DNOCACHE, DTOOBIG.
3070Sstevel@tonic-gate  */
3080Sstevel@tonic-gate dcret_t dnlc_dir_add_space(dcanchor_t *dcap, uint_t len, uint64_t handle);
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate /*
3110Sstevel@tonic-gate  * dnlc_dir_complete() indicates the previously partial cache is now complete.
3120Sstevel@tonic-gate  */
3130Sstevel@tonic-gate void dnlc_dir_complete(dcanchor_t *dcap);
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate /*
3160Sstevel@tonic-gate  * dnlc_dir_purge() deletes a partial or complete directory cache
3170Sstevel@tonic-gate  */
3180Sstevel@tonic-gate void dnlc_dir_purge(dcanchor_t *dcap);
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate /*
3210Sstevel@tonic-gate  * dnlc_dir_lookup() lookups a file name in a directory cache
3220Sstevel@tonic-gate  * and returns the file system handle specified on dnlc_dir_add_entry()
3230Sstevel@tonic-gate  * in "handlep". Returns DFOUND, DNOENT, DNOCACHE.
3240Sstevel@tonic-gate  */
3250Sstevel@tonic-gate dcret_t dnlc_dir_lookup(dcanchor_t *dcap, char *name, uint64_t *handlep);
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate /*
3280Sstevel@tonic-gate  * dnlc_dir_update() amends the handle for an entry in a directory cache
3290Sstevel@tonic-gate  * "handle" is the new file system specific handle for the file "name".
3300Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
3310Sstevel@tonic-gate  */
3320Sstevel@tonic-gate dcret_t dnlc_dir_update(dcanchor_t *dcap, char *name, uint64_t handle);
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate /*
3350Sstevel@tonic-gate  * dnlc_dir_rem_entry() removes an entry form a directory cache.
3360Sstevel@tonic-gate  * Returns the handle if "handlep" non null.
3370Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
3380Sstevel@tonic-gate  */
3390Sstevel@tonic-gate dcret_t dnlc_dir_rem_entry(dcanchor_t *dcap, char *name, uint64_t *handlep);
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate /*
3420Sstevel@tonic-gate  * dnlc_dir_rem_space_by_len() looks up and returns free space in a
3430Sstevel@tonic-gate  * directory cache of at least the given "len". Returns in "handlep"
3440Sstevel@tonic-gate  * the handle supplied when adding the free space in dnlc_dir_add_space().
3450Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
3460Sstevel@tonic-gate  */
3470Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_len(dcanchor_t *dcap, uint_t len,
3480Sstevel@tonic-gate     uint64_t *handlep);
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate /*
3510Sstevel@tonic-gate  * dnlc_dir_rem_space_by_handle() looks up and removes the free space in
3520Sstevel@tonic-gate  * a directory cache with the given handle. Returns DFOUND, DNOENT, DNOCACHE.
3530Sstevel@tonic-gate  */
3540Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_handle(dcanchor_t *dcap, uint64_t handle);
3550Sstevel@tonic-gate 
3560Sstevel@tonic-gate /*
3570Sstevel@tonic-gate  * dnlc_dir_init() initialises a directory anchor
3580Sstevel@tonic-gate  */
3590Sstevel@tonic-gate #define	dnlc_dir_init(dcap) { \
3600Sstevel@tonic-gate 	(dcap)->dca_dircache = NULL; \
3610Sstevel@tonic-gate 	mutex_init(&(dcap)->dca_lock, NULL, MUTEX_DEFAULT, NULL); }
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate /*
3640Sstevel@tonic-gate  * dnlc_dir_fini() is called to indicate the anchor is no longer used.
3650Sstevel@tonic-gate  * It ensures there's no directory cache and mutex_destroys the lock
3660Sstevel@tonic-gate  */
3670Sstevel@tonic-gate void dnlc_dir_fini(dcanchor_t *dcap);
3680Sstevel@tonic-gate 
3690Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate #ifdef	__cplusplus
3720Sstevel@tonic-gate }
3730Sstevel@tonic-gate #endif
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate #endif	/* _SYS_DNLC_H */
376