xref: /onnv-gate/usr/src/uts/common/sys/dnlc.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*0Sstevel@tonic-gate  * The Regents of the University of California
33*0Sstevel@tonic-gate  * All Rights Reserved
34*0Sstevel@tonic-gate  *
35*0Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*0Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*0Sstevel@tonic-gate  * contributors.
38*0Sstevel@tonic-gate  */
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifndef _SYS_DNLC_H
41*0Sstevel@tonic-gate #define	_SYS_DNLC_H
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #ifdef	__cplusplus
46*0Sstevel@tonic-gate extern "C" {
47*0Sstevel@tonic-gate #endif
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #include <sys/kstat.h>
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate /*
52*0Sstevel@tonic-gate  * DNLC - Directory name lookup cache.
53*0Sstevel@tonic-gate  * There are now two sorts of name caching:
54*0Sstevel@tonic-gate  *
55*0Sstevel@tonic-gate  * Standard dnlc: This original cache holds recent mappings
56*0Sstevel@tonic-gate  *                of <directory vnode, name> to vnode mappings.
57*0Sstevel@tonic-gate  *
58*0Sstevel@tonic-gate  * Directory caches: Entire large directories can be cached, subject to
59*0Sstevel@tonic-gate  *		     memory availability and tunables. A directory cache
60*0Sstevel@tonic-gate  *		     anchor point must be provided in the xxnode for
61*0Sstevel@tonic-gate  *		     a directory.
62*0Sstevel@tonic-gate  */
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate /*
66*0Sstevel@tonic-gate  * Standard dnlc
67*0Sstevel@tonic-gate  * =============
68*0Sstevel@tonic-gate  */
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate /*
71*0Sstevel@tonic-gate  * This structure describes the elements in the cache of recent
72*0Sstevel@tonic-gate  * names looked up.
73*0Sstevel@tonic-gate  *
74*0Sstevel@tonic-gate  * Note namlen is a uchar_t to conserve space
75*0Sstevel@tonic-gate  * and alignment padding. The max length of any
76*0Sstevel@tonic-gate  * pathname component is defined as MAXNAMELEN
77*0Sstevel@tonic-gate  * which is 256 (including the terminating null).
78*0Sstevel@tonic-gate  * So provided this doesn't change, we don't include the null,
79*0Sstevel@tonic-gate  * we always use bcmp to compare strings, and we don't start
80*0Sstevel@tonic-gate  * storing full names, then we are ok. The space savings are worth it.
81*0Sstevel@tonic-gate  */
82*0Sstevel@tonic-gate typedef struct ncache {
83*0Sstevel@tonic-gate 	struct ncache *hash_next; 	/* hash chain, MUST BE FIRST */
84*0Sstevel@tonic-gate 	struct ncache *hash_prev;
85*0Sstevel@tonic-gate 	struct vnode *vp;		/* vnode the name refers to */
86*0Sstevel@tonic-gate 	struct vnode *dp;		/* vnode of parent of name */
87*0Sstevel@tonic-gate 	int hash;			/* hash signature */
88*0Sstevel@tonic-gate 	uchar_t namlen;			/* length of name */
89*0Sstevel@tonic-gate 	char name[1];			/* segment name - null terminated */
90*0Sstevel@tonic-gate } ncache_t;
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate /*
93*0Sstevel@tonic-gate  * Hash table bucket structure of name cache entries for fast lookup.
94*0Sstevel@tonic-gate  */
95*0Sstevel@tonic-gate typedef struct nc_hash	{
96*0Sstevel@tonic-gate 	ncache_t *hash_next;
97*0Sstevel@tonic-gate 	ncache_t *hash_prev;
98*0Sstevel@tonic-gate 	kmutex_t hash_lock;
99*0Sstevel@tonic-gate } nc_hash_t;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate /*
102*0Sstevel@tonic-gate  * Statistics on name cache
103*0Sstevel@tonic-gate  * Not protected by locks
104*0Sstevel@tonic-gate  */
105*0Sstevel@tonic-gate /*
106*0Sstevel@tonic-gate  * ncstats has been deprecated, due to the integer size of the counters
107*0Sstevel@tonic-gate  * which can easily overflow in the dnlc.
108*0Sstevel@tonic-gate  * It is maintained (at some expense) for compatability.
109*0Sstevel@tonic-gate  * The preferred interface is the kstat accessible nc_stats below, ehich
110*0Sstevel@tonic-gate  * is actually shared with directory caching.
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate struct ncstats {
113*0Sstevel@tonic-gate 	int	hits;		/* hits that we can really use */
114*0Sstevel@tonic-gate 	int	misses;		/* cache misses */
115*0Sstevel@tonic-gate 	int	enters;		/* number of enters done */
116*0Sstevel@tonic-gate 	int	dbl_enters;	/* number of enters tried when already cached */
117*0Sstevel@tonic-gate 	int	long_enter;	/* deprecated, no longer accounted */
118*0Sstevel@tonic-gate 	int	long_look;	/* deprecated, no longer accounted */
119*0Sstevel@tonic-gate 	int	move_to_front;	/* entry moved to front of hash chain */
120*0Sstevel@tonic-gate 	int	purges;		/* number of purges of cache */
121*0Sstevel@tonic-gate };
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate struct nc_stats {
124*0Sstevel@tonic-gate 	kstat_named_t ncs_hits;		/* cache hits */
125*0Sstevel@tonic-gate 	kstat_named_t ncs_misses;	/* cache misses */
126*0Sstevel@tonic-gate 	kstat_named_t ncs_neg_hits;	/* negative cache hits */
127*0Sstevel@tonic-gate 	kstat_named_t ncs_enters;	/* enters */
128*0Sstevel@tonic-gate 	kstat_named_t ncs_dbl_enters;	/* enters when entry already cached */
129*0Sstevel@tonic-gate 	kstat_named_t ncs_purge_total;	/* total entries prurged */
130*0Sstevel@tonic-gate 	kstat_named_t ncs_purge_all;	/* dnlc_purge() calls */
131*0Sstevel@tonic-gate 	kstat_named_t ncs_purge_vp;	/* dnlc_purge_vp() calls */
132*0Sstevel@tonic-gate 	kstat_named_t ncs_purge_vfs;	/* dnlc_purge_vfs() calls */
133*0Sstevel@tonic-gate 	kstat_named_t ncs_purge_fs1;	/* dnlc_purge_fs1() calls */
134*0Sstevel@tonic-gate 	kstat_named_t ncs_pick_free;	/* found a free ncache */
135*0Sstevel@tonic-gate 	kstat_named_t ncs_pick_heur;	/* found ncache w/ NULL vpages */
136*0Sstevel@tonic-gate 	kstat_named_t ncs_pick_last;	/* found last ncache on chain */
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate 	/* directory caching stats */
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_hits;	/* dir cache hits */
141*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_misses;	/* dir cache misses */
142*0Sstevel@tonic-gate 	kstat_named_t ncs_cur_dirs;	/* current # directories cached */
143*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_num_ents;	/* current # entries cached */
144*0Sstevel@tonic-gate 	kstat_named_t ncs_dirs_cached;	/* total # directories cached */
145*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_start_nm;	/* dir start no memory */
146*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_add_nm;	/* add entry/space - no memory */
147*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_addabort;	/* add entry/space - abort */
148*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_add_max;	/* add entry/space - max exceeded */
149*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_reme_fai;	/* remove entry fail */
150*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_rems_fai;	/* remove space fail */
151*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_upd_fail;	/* update space fail */
152*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_finipurg;	/* fini purges */
153*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_rec_last;	/* reclaim last */
154*0Sstevel@tonic-gate 	kstat_named_t ncs_dir_recl_any;	/* reclaim any */
155*0Sstevel@tonic-gate };
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate /*
158*0Sstevel@tonic-gate  * The dnlc hashing function.
159*0Sstevel@tonic-gate  * Although really a kernel macro we export it to allow validation
160*0Sstevel@tonic-gate  * of ncache_t entries by mdb. Note, mdb can handle the ASSERT.
161*0Sstevel@tonic-gate  *
162*0Sstevel@tonic-gate  * 'hash' and 'namlen' must be l-values. A check is made to ensure
163*0Sstevel@tonic-gate  * the name length fits into an unsigned char (see ncache_t).
164*0Sstevel@tonic-gate  */
165*0Sstevel@tonic-gate #define	DNLCHASH(name, dvp, hash, namlen)			\
166*0Sstevel@tonic-gate 	{							\
167*0Sstevel@tonic-gate 		char Xc, *Xcp;					\
168*0Sstevel@tonic-gate 		hash = (int)((uintptr_t)(dvp)) >> 8;		\
169*0Sstevel@tonic-gate 		for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++)	\
170*0Sstevel@tonic-gate 			(hash) = ((hash) << 4) + (hash) + Xc;	\
171*0Sstevel@tonic-gate 		ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1));	\
172*0Sstevel@tonic-gate 		(namlen) = Xcp - (name);			\
173*0Sstevel@tonic-gate 	}
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate #if defined(_KERNEL)
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate #include <sys/vfs.h>
178*0Sstevel@tonic-gate #include <sys/vnode.h>
179*0Sstevel@tonic-gate 
180*0Sstevel@tonic-gate extern int ncsize;		/* set in param_init() # of dnlc entries */
181*0Sstevel@tonic-gate extern vnode_t negative_cache_vnode;
182*0Sstevel@tonic-gate #define	DNLC_NO_VNODE &negative_cache_vnode
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate void	dnlc_init(void);
185*0Sstevel@tonic-gate void	dnlc_enter(vnode_t *, char *, vnode_t *);
186*0Sstevel@tonic-gate void	dnlc_update(vnode_t *, char *, vnode_t *);
187*0Sstevel@tonic-gate vnode_t	*dnlc_lookup(vnode_t *, char *);
188*0Sstevel@tonic-gate void	dnlc_purge(void);
189*0Sstevel@tonic-gate void	dnlc_purge_vp(vnode_t *);
190*0Sstevel@tonic-gate int	dnlc_purge_vfsp(vfs_t *, int);
191*0Sstevel@tonic-gate void	dnlc_remove(vnode_t *, char *);
192*0Sstevel@tonic-gate int	dnlc_fs_purge1(struct vnodeops *);
193*0Sstevel@tonic-gate vnode_t	*dnlc_reverse_lookup(vnode_t *, char *, size_t);
194*0Sstevel@tonic-gate 
195*0Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate /*
199*0Sstevel@tonic-gate  * Directory caching interfaces
200*0Sstevel@tonic-gate  * ============================
201*0Sstevel@tonic-gate  */
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate /*
204*0Sstevel@tonic-gate  * Typically for large directories, the file names will be the same or
205*0Sstevel@tonic-gate  * at least similar lengths. So there's no point in anything more elaborate
206*0Sstevel@tonic-gate  * than a simple unordered linked list of free space entries.
207*0Sstevel@tonic-gate  * For small directories the name length distribution doesn't really matter.
208*0Sstevel@tonic-gate  */
209*0Sstevel@tonic-gate typedef struct dcfree {
210*0Sstevel@tonic-gate 	uint64_t df_handle;		/* fs supplied handle */
211*0Sstevel@tonic-gate 	struct dcfree *df_next; 	/* link to next free entry in bucket */
212*0Sstevel@tonic-gate 	uint_t df_len;			/* length of free entry */
213*0Sstevel@tonic-gate } dcfree_t;
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate typedef struct dcentry {
216*0Sstevel@tonic-gate 	uint64_t de_handle;		/* fs supplied and returned data */
217*0Sstevel@tonic-gate 	struct dcentry *de_next;	/* link to next name entry in bucket */
218*0Sstevel@tonic-gate 	int de_hash;			/* hash signature */
219*0Sstevel@tonic-gate 	uchar_t de_namelen;		/* length of name excluding null */
220*0Sstevel@tonic-gate 	char de_name[1];		/* null terminated name */
221*0Sstevel@tonic-gate } dcentry_t;
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate typedef struct dircache {
224*0Sstevel@tonic-gate 	struct dircache *dc_next;	/* chain - for purge purposes */
225*0Sstevel@tonic-gate 	struct dircache *dc_prev;	/* chain - for purge purposes */
226*0Sstevel@tonic-gate 	int64_t dc_actime;		/* dir access time, from lbolt64 */
227*0Sstevel@tonic-gate 	dcentry_t **dc_namehash;	/* entry hash table pointer */
228*0Sstevel@tonic-gate 	dcfree_t **dc_freehash;		/* free entry hash table pointer */
229*0Sstevel@tonic-gate 	uint_t dc_num_entries;		/* no of named entries */
230*0Sstevel@tonic-gate 	uint_t dc_num_free;		/* no of free space entries */
231*0Sstevel@tonic-gate 	uint_t dc_nhash_mask;		/* name hash table size - 1 */
232*0Sstevel@tonic-gate 	uint_t dc_fhash_mask;		/* free space hash table size - 1 */
233*0Sstevel@tonic-gate 	struct dcanchor *dc_anchor;	/* back ptr to anchor */
234*0Sstevel@tonic-gate 	boolean_t dc_complete;		/* cache complete boolean */
235*0Sstevel@tonic-gate } dircache_t;
236*0Sstevel@tonic-gate 
237*0Sstevel@tonic-gate typedef struct dcanchor {
238*0Sstevel@tonic-gate 	void *dca_dircache;	/* pointer to directory cache */
239*0Sstevel@tonic-gate 	kmutex_t dca_lock;		/* protects the directory cache */
240*0Sstevel@tonic-gate } dcanchor_t;
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate /*
243*0Sstevel@tonic-gate  * Head struct for doubly linked chain of dircache_t
244*0Sstevel@tonic-gate  * The next and prev fields must match those of a dircache_t
245*0Sstevel@tonic-gate  */
246*0Sstevel@tonic-gate typedef struct {
247*0Sstevel@tonic-gate 	dircache_t *dch_next;		/* next in chain */
248*0Sstevel@tonic-gate 	dircache_t *dch_prev;		/* prev in chain */
249*0Sstevel@tonic-gate 	kmutex_t dch_lock;		/* lock for the chain */
250*0Sstevel@tonic-gate } dchead_t;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate 
253*0Sstevel@tonic-gate #if defined(_KERNEL)
254*0Sstevel@tonic-gate 
255*0Sstevel@tonic-gate /*
256*0Sstevel@tonic-gate  * Status returns from the directory cache interfaces
257*0Sstevel@tonic-gate  */
258*0Sstevel@tonic-gate typedef enum {
259*0Sstevel@tonic-gate 	DOK,		/* operation sucessful */
260*0Sstevel@tonic-gate 	DNOCACHE,	/* there is no cache */
261*0Sstevel@tonic-gate 	DFOUND,		/* entry found */
262*0Sstevel@tonic-gate 	DNOENT,		/* no entry found */
263*0Sstevel@tonic-gate 	DTOOBIG,	/* exceeds tunable dnlc_max_dir_cache */
264*0Sstevel@tonic-gate 	DNOMEM		/* no memory */
265*0Sstevel@tonic-gate } dcret_t;
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate /*
268*0Sstevel@tonic-gate  * dnlc_dir_start() requests that a directory be cached.
269*0Sstevel@tonic-gate  * This must be called initially to enable caching on a directory.
270*0Sstevel@tonic-gate  * After a successful call, directory entries and free space can be
271*0Sstevel@tonic-gate  * added (see below) until the directory is marked complete.
272*0Sstevel@tonic-gate  * "num_entries" is an estimate of the current number of
273*0Sstevel@tonic-gate  * directory entries. The request is rejected with DNOCACHE
274*0Sstevel@tonic-gate  * if num_entries falls below the tunable dnlc_dir_min_size (see
275*0Sstevel@tonic-gate  * below), and rejected with DTOOBIG if it's above dnlc_dir_max_size.
276*0Sstevel@tonic-gate  * Returns DOK, DNOCACHE, DTOOBIG, DNOMEM.
277*0Sstevel@tonic-gate  *
278*0Sstevel@tonic-gate  * Due to memory shortages, directory caches can be purged at
279*0Sstevel@tonic-gate  * any time. If the last directory cache is purged due to memory
280*0Sstevel@tonic-gate  * shortage, then the directory cache is marked internally
281*0Sstevel@tonic-gate  * as "no memory". Future returns will all be DNOCACHE until
282*0Sstevel@tonic-gate  * the next dnlc_start_dir() which will return DNOMEM once.
283*0Sstevel@tonic-gate  * This memory shortage may only be transient. It's up to the
284*0Sstevel@tonic-gate  * file system as to what to do about this condition, but an
285*0Sstevel@tonic-gate  * attempt to immediately re-build the cache will very likely
286*0Sstevel@tonic-gate  * lead to the same shortage of memory and a thrashing situation.
287*0Sstevel@tonic-gate  *
288*0Sstevel@tonic-gate  * It's file system policy as to when and what size directories to cache.
289*0Sstevel@tonic-gate  */
290*0Sstevel@tonic-gate dcret_t dnlc_dir_start(dcanchor_t *dcap, uint_t num_entries);
291*0Sstevel@tonic-gate 
292*0Sstevel@tonic-gate /*
293*0Sstevel@tonic-gate  * dnlc_dir_add_entry() adds an entry (name and handle) into a
294*0Sstevel@tonic-gate  * partial or complete cache. "handle" is a file system specific
295*0Sstevel@tonic-gate  * quantity that is returned on calls to dnlc_dir_lookup() - see below.
296*0Sstevel@tonic-gate  * For example, "handle" for ufs holds the inumber and a directory
297*0Sstevel@tonic-gate  * entry offset. Returns DOK, DNOCACHE, DTOOBIG.
298*0Sstevel@tonic-gate  */
299*0Sstevel@tonic-gate dcret_t dnlc_dir_add_entry(dcanchor_t *dcap, char *name, uint64_t handle);
300*0Sstevel@tonic-gate 
301*0Sstevel@tonic-gate /*
302*0Sstevel@tonic-gate  * dnlc_dir_add_space adds free space (length and file system specific
303*0Sstevel@tonic-gate  * handle) into a partial or complete cache. "handle" is a file
304*0Sstevel@tonic-gate  * system specific quantity that is returned on calls to
305*0Sstevel@tonic-gate  * dnlc_dir_rem_space_by_len(). For example, "handle" for ufs holds
306*0Sstevel@tonic-gate  * the directory entry offset.  Returns DOK, DNOCACHE, DTOOBIG.
307*0Sstevel@tonic-gate  */
308*0Sstevel@tonic-gate dcret_t dnlc_dir_add_space(dcanchor_t *dcap, uint_t len, uint64_t handle);
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate /*
311*0Sstevel@tonic-gate  * dnlc_dir_complete() indicates the previously partial cache is now complete.
312*0Sstevel@tonic-gate  */
313*0Sstevel@tonic-gate void dnlc_dir_complete(dcanchor_t *dcap);
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate /*
316*0Sstevel@tonic-gate  * dnlc_dir_purge() deletes a partial or complete directory cache
317*0Sstevel@tonic-gate  */
318*0Sstevel@tonic-gate void dnlc_dir_purge(dcanchor_t *dcap);
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate /*
321*0Sstevel@tonic-gate  * dnlc_dir_lookup() lookups a file name in a directory cache
322*0Sstevel@tonic-gate  * and returns the file system handle specified on dnlc_dir_add_entry()
323*0Sstevel@tonic-gate  * in "handlep". Returns DFOUND, DNOENT, DNOCACHE.
324*0Sstevel@tonic-gate  */
325*0Sstevel@tonic-gate dcret_t dnlc_dir_lookup(dcanchor_t *dcap, char *name, uint64_t *handlep);
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate /*
328*0Sstevel@tonic-gate  * dnlc_dir_update() amends the handle for an entry in a directory cache
329*0Sstevel@tonic-gate  * "handle" is the new file system specific handle for the file "name".
330*0Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
331*0Sstevel@tonic-gate  */
332*0Sstevel@tonic-gate dcret_t dnlc_dir_update(dcanchor_t *dcap, char *name, uint64_t handle);
333*0Sstevel@tonic-gate 
334*0Sstevel@tonic-gate /*
335*0Sstevel@tonic-gate  * dnlc_dir_rem_entry() removes an entry form a directory cache.
336*0Sstevel@tonic-gate  * Returns the handle if "handlep" non null.
337*0Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
338*0Sstevel@tonic-gate  */
339*0Sstevel@tonic-gate dcret_t dnlc_dir_rem_entry(dcanchor_t *dcap, char *name, uint64_t *handlep);
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate /*
342*0Sstevel@tonic-gate  * dnlc_dir_rem_space_by_len() looks up and returns free space in a
343*0Sstevel@tonic-gate  * directory cache of at least the given "len". Returns in "handlep"
344*0Sstevel@tonic-gate  * the handle supplied when adding the free space in dnlc_dir_add_space().
345*0Sstevel@tonic-gate  * Returns DFOUND, DNOENT, DNOCACHE.
346*0Sstevel@tonic-gate  */
347*0Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_len(dcanchor_t *dcap, uint_t len,
348*0Sstevel@tonic-gate     uint64_t *handlep);
349*0Sstevel@tonic-gate 
350*0Sstevel@tonic-gate /*
351*0Sstevel@tonic-gate  * dnlc_dir_rem_space_by_handle() looks up and removes the free space in
352*0Sstevel@tonic-gate  * a directory cache with the given handle. Returns DFOUND, DNOENT, DNOCACHE.
353*0Sstevel@tonic-gate  */
354*0Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_handle(dcanchor_t *dcap, uint64_t handle);
355*0Sstevel@tonic-gate 
356*0Sstevel@tonic-gate /*
357*0Sstevel@tonic-gate  * dnlc_dir_init() initialises a directory anchor
358*0Sstevel@tonic-gate  */
359*0Sstevel@tonic-gate #define	dnlc_dir_init(dcap) { \
360*0Sstevel@tonic-gate 	(dcap)->dca_dircache = NULL; \
361*0Sstevel@tonic-gate 	mutex_init(&(dcap)->dca_lock, NULL, MUTEX_DEFAULT, NULL); }
362*0Sstevel@tonic-gate 
363*0Sstevel@tonic-gate /*
364*0Sstevel@tonic-gate  * dnlc_dir_fini() is called to indicate the anchor is no longer used.
365*0Sstevel@tonic-gate  * It ensures there's no directory cache and mutex_destroys the lock
366*0Sstevel@tonic-gate  */
367*0Sstevel@tonic-gate void dnlc_dir_fini(dcanchor_t *dcap);
368*0Sstevel@tonic-gate 
369*0Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate #ifdef	__cplusplus
372*0Sstevel@tonic-gate }
373*0Sstevel@tonic-gate #endif
374*0Sstevel@tonic-gate 
375*0Sstevel@tonic-gate #endif	/* _SYS_DNLC_H */
376