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