17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5033f9833Sek110237 * Common Development and Distribution License (the "License"). 6033f9833Sek110237 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*744947dcSTom Erickson * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 267c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 307c478bd9Sstevel@tonic-gate * The Regents of the University of California 317c478bd9Sstevel@tonic-gate * All Rights Reserved 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 347c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 357c478bd9Sstevel@tonic-gate * contributors. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifndef _SYS_DNLC_H 397c478bd9Sstevel@tonic-gate #define _SYS_DNLC_H 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * DNLC - Directory name lookup cache. 497c478bd9Sstevel@tonic-gate * There are now two sorts of name caching: 507c478bd9Sstevel@tonic-gate * 517c478bd9Sstevel@tonic-gate * Standard dnlc: This original cache holds recent mappings 527c478bd9Sstevel@tonic-gate * of <directory vnode, name> to vnode mappings. 537c478bd9Sstevel@tonic-gate * 547c478bd9Sstevel@tonic-gate * Directory caches: Entire large directories can be cached, subject to 557c478bd9Sstevel@tonic-gate * memory availability and tunables. A directory cache 567c478bd9Sstevel@tonic-gate * anchor point must be provided in the xxnode for 577c478bd9Sstevel@tonic-gate * a directory. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Standard dnlc 637c478bd9Sstevel@tonic-gate * ============= 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * This structure describes the elements in the cache of recent 687c478bd9Sstevel@tonic-gate * names looked up. 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * Note namlen is a uchar_t to conserve space 717c478bd9Sstevel@tonic-gate * and alignment padding. The max length of any 727c478bd9Sstevel@tonic-gate * pathname component is defined as MAXNAMELEN 737c478bd9Sstevel@tonic-gate * which is 256 (including the terminating null). 747c478bd9Sstevel@tonic-gate * So provided this doesn't change, we don't include the null, 757c478bd9Sstevel@tonic-gate * we always use bcmp to compare strings, and we don't start 767c478bd9Sstevel@tonic-gate * storing full names, then we are ok. The space savings are worth it. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate typedef struct ncache { 797c478bd9Sstevel@tonic-gate struct ncache *hash_next; /* hash chain, MUST BE FIRST */ 807c478bd9Sstevel@tonic-gate struct ncache *hash_prev; 817c478bd9Sstevel@tonic-gate struct vnode *vp; /* vnode the name refers to */ 827c478bd9Sstevel@tonic-gate struct vnode *dp; /* vnode of parent of name */ 837c478bd9Sstevel@tonic-gate int hash; /* hash signature */ 847c478bd9Sstevel@tonic-gate uchar_t namlen; /* length of name */ 857c478bd9Sstevel@tonic-gate char name[1]; /* segment name - null terminated */ 867c478bd9Sstevel@tonic-gate } ncache_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * Hash table bucket structure of name cache entries for fast lookup. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate typedef struct nc_hash { 927c478bd9Sstevel@tonic-gate ncache_t *hash_next; 937c478bd9Sstevel@tonic-gate ncache_t *hash_prev; 947c478bd9Sstevel@tonic-gate kmutex_t hash_lock; 957c478bd9Sstevel@tonic-gate } nc_hash_t; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Statistics on name cache 997c478bd9Sstevel@tonic-gate * Not protected by locks 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * ncstats has been deprecated, due to the integer size of the counters 1037c478bd9Sstevel@tonic-gate * which can easily overflow in the dnlc. 1047c478bd9Sstevel@tonic-gate * It is maintained (at some expense) for compatability. 1057c478bd9Sstevel@tonic-gate * The preferred interface is the kstat accessible nc_stats below, ehich 1067c478bd9Sstevel@tonic-gate * is actually shared with directory caching. 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate struct ncstats { 1097c478bd9Sstevel@tonic-gate int hits; /* hits that we can really use */ 1107c478bd9Sstevel@tonic-gate int misses; /* cache misses */ 1117c478bd9Sstevel@tonic-gate int enters; /* number of enters done */ 1127c478bd9Sstevel@tonic-gate int dbl_enters; /* number of enters tried when already cached */ 1137c478bd9Sstevel@tonic-gate int long_enter; /* deprecated, no longer accounted */ 1147c478bd9Sstevel@tonic-gate int long_look; /* deprecated, no longer accounted */ 1157c478bd9Sstevel@tonic-gate int move_to_front; /* entry moved to front of hash chain */ 1167c478bd9Sstevel@tonic-gate int purges; /* number of purges of cache */ 1177c478bd9Sstevel@tonic-gate }; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate struct nc_stats { 1207c478bd9Sstevel@tonic-gate kstat_named_t ncs_hits; /* cache hits */ 1217c478bd9Sstevel@tonic-gate kstat_named_t ncs_misses; /* cache misses */ 1227c478bd9Sstevel@tonic-gate kstat_named_t ncs_neg_hits; /* negative cache hits */ 1237c478bd9Sstevel@tonic-gate kstat_named_t ncs_enters; /* enters */ 1247c478bd9Sstevel@tonic-gate kstat_named_t ncs_dbl_enters; /* enters when entry already cached */ 1257c478bd9Sstevel@tonic-gate kstat_named_t ncs_purge_total; /* total entries prurged */ 1267c478bd9Sstevel@tonic-gate kstat_named_t ncs_purge_all; /* dnlc_purge() calls */ 1277c478bd9Sstevel@tonic-gate kstat_named_t ncs_purge_vp; /* dnlc_purge_vp() calls */ 1287c478bd9Sstevel@tonic-gate kstat_named_t ncs_purge_vfs; /* dnlc_purge_vfs() calls */ 1297c478bd9Sstevel@tonic-gate kstat_named_t ncs_purge_fs1; /* dnlc_purge_fs1() calls */ 1307c478bd9Sstevel@tonic-gate kstat_named_t ncs_pick_free; /* found a free ncache */ 1317c478bd9Sstevel@tonic-gate kstat_named_t ncs_pick_heur; /* found ncache w/ NULL vpages */ 1327c478bd9Sstevel@tonic-gate kstat_named_t ncs_pick_last; /* found last ncache on chain */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* directory caching stats */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_hits; /* dir cache hits */ 1377c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_misses; /* dir cache misses */ 1387c478bd9Sstevel@tonic-gate kstat_named_t ncs_cur_dirs; /* current # directories cached */ 1397c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_num_ents; /* current # entries cached */ 1407c478bd9Sstevel@tonic-gate kstat_named_t ncs_dirs_cached; /* total # directories cached */ 1417c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_start_nm; /* dir start no memory */ 1427c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_add_nm; /* add entry/space - no memory */ 1437c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_addabort; /* add entry/space - abort */ 1447c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_add_max; /* add entry/space - max exceeded */ 1457c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_reme_fai; /* remove entry fail */ 1467c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_rems_fai; /* remove space fail */ 1477c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_upd_fail; /* update space fail */ 1487c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_finipurg; /* fini purges */ 1497c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_rec_last; /* reclaim last */ 1507c478bd9Sstevel@tonic-gate kstat_named_t ncs_dir_recl_any; /* reclaim any */ 1517c478bd9Sstevel@tonic-gate }; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * The dnlc hashing function. 1557c478bd9Sstevel@tonic-gate * Although really a kernel macro we export it to allow validation 1567c478bd9Sstevel@tonic-gate * of ncache_t entries by mdb. Note, mdb can handle the ASSERT. 1577c478bd9Sstevel@tonic-gate * 1587c478bd9Sstevel@tonic-gate * 'hash' and 'namlen' must be l-values. A check is made to ensure 1597c478bd9Sstevel@tonic-gate * the name length fits into an unsigned char (see ncache_t). 1607c478bd9Sstevel@tonic-gate */ 1617c478bd9Sstevel@tonic-gate #define DNLCHASH(name, dvp, hash, namlen) \ 1627c478bd9Sstevel@tonic-gate { \ 163*744947dcSTom Erickson char Xc; \ 164*744947dcSTom Erickson const char *Xcp; \ 1657c478bd9Sstevel@tonic-gate hash = (int)((uintptr_t)(dvp)) >> 8; \ 1667c478bd9Sstevel@tonic-gate for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++) \ 1677c478bd9Sstevel@tonic-gate (hash) = ((hash) << 4) + (hash) + Xc; \ 1687c478bd9Sstevel@tonic-gate ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1)); \ 1697c478bd9Sstevel@tonic-gate (namlen) = Xcp - (name); \ 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 1757c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate extern int ncsize; /* set in param_init() # of dnlc entries */ 1787c478bd9Sstevel@tonic-gate extern vnode_t negative_cache_vnode; 1797c478bd9Sstevel@tonic-gate #define DNLC_NO_VNODE &negative_cache_vnode 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate void dnlc_init(void); 182*744947dcSTom Erickson void dnlc_enter(vnode_t *, const char *, vnode_t *); 183*744947dcSTom Erickson void dnlc_update(vnode_t *, const char *, vnode_t *); 184*744947dcSTom Erickson vnode_t *dnlc_lookup(vnode_t *, const char *); 1857c478bd9Sstevel@tonic-gate void dnlc_purge(void); 1867c478bd9Sstevel@tonic-gate void dnlc_purge_vp(vnode_t *); 1877c478bd9Sstevel@tonic-gate int dnlc_purge_vfsp(vfs_t *, int); 188*744947dcSTom Erickson void dnlc_remove(vnode_t *, const char *); 1897c478bd9Sstevel@tonic-gate int dnlc_fs_purge1(struct vnodeops *); 190033f9833Sek110237 void dnlc_reduce_cache(void *); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * Directory caching interfaces 1977c478bd9Sstevel@tonic-gate * ============================ 1987c478bd9Sstevel@tonic-gate */ 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * Typically for large directories, the file names will be the same or 2027c478bd9Sstevel@tonic-gate * at least similar lengths. So there's no point in anything more elaborate 2037c478bd9Sstevel@tonic-gate * than a simple unordered linked list of free space entries. 2047c478bd9Sstevel@tonic-gate * For small directories the name length distribution doesn't really matter. 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate typedef struct dcfree { 2077c478bd9Sstevel@tonic-gate uint64_t df_handle; /* fs supplied handle */ 2087c478bd9Sstevel@tonic-gate struct dcfree *df_next; /* link to next free entry in bucket */ 2097c478bd9Sstevel@tonic-gate uint_t df_len; /* length of free entry */ 2107c478bd9Sstevel@tonic-gate } dcfree_t; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate typedef struct dcentry { 2137c478bd9Sstevel@tonic-gate uint64_t de_handle; /* fs supplied and returned data */ 2147c478bd9Sstevel@tonic-gate struct dcentry *de_next; /* link to next name entry in bucket */ 2157c478bd9Sstevel@tonic-gate int de_hash; /* hash signature */ 2167c478bd9Sstevel@tonic-gate uchar_t de_namelen; /* length of name excluding null */ 2177c478bd9Sstevel@tonic-gate char de_name[1]; /* null terminated name */ 2187c478bd9Sstevel@tonic-gate } dcentry_t; 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate typedef struct dircache { 2217c478bd9Sstevel@tonic-gate struct dircache *dc_next; /* chain - for purge purposes */ 2227c478bd9Sstevel@tonic-gate struct dircache *dc_prev; /* chain - for purge purposes */ 2237c478bd9Sstevel@tonic-gate int64_t dc_actime; /* dir access time, from lbolt64 */ 2247c478bd9Sstevel@tonic-gate dcentry_t **dc_namehash; /* entry hash table pointer */ 2257c478bd9Sstevel@tonic-gate dcfree_t **dc_freehash; /* free entry hash table pointer */ 2267c478bd9Sstevel@tonic-gate uint_t dc_num_entries; /* no of named entries */ 2277c478bd9Sstevel@tonic-gate uint_t dc_num_free; /* no of free space entries */ 2287c478bd9Sstevel@tonic-gate uint_t dc_nhash_mask; /* name hash table size - 1 */ 2297c478bd9Sstevel@tonic-gate uint_t dc_fhash_mask; /* free space hash table size - 1 */ 2307c478bd9Sstevel@tonic-gate struct dcanchor *dc_anchor; /* back ptr to anchor */ 2317c478bd9Sstevel@tonic-gate boolean_t dc_complete; /* cache complete boolean */ 2327c478bd9Sstevel@tonic-gate } dircache_t; 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate typedef struct dcanchor { 2357c478bd9Sstevel@tonic-gate void *dca_dircache; /* pointer to directory cache */ 2367c478bd9Sstevel@tonic-gate kmutex_t dca_lock; /* protects the directory cache */ 2377c478bd9Sstevel@tonic-gate } dcanchor_t; 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate /* 2407c478bd9Sstevel@tonic-gate * Head struct for doubly linked chain of dircache_t 2417c478bd9Sstevel@tonic-gate * The next and prev fields must match those of a dircache_t 2427c478bd9Sstevel@tonic-gate */ 2437c478bd9Sstevel@tonic-gate typedef struct { 2447c478bd9Sstevel@tonic-gate dircache_t *dch_next; /* next in chain */ 2457c478bd9Sstevel@tonic-gate dircache_t *dch_prev; /* prev in chain */ 2467c478bd9Sstevel@tonic-gate kmutex_t dch_lock; /* lock for the chain */ 2477c478bd9Sstevel@tonic-gate } dchead_t; 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * Status returns from the directory cache interfaces 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate typedef enum { 2567c478bd9Sstevel@tonic-gate DOK, /* operation sucessful */ 2577c478bd9Sstevel@tonic-gate DNOCACHE, /* there is no cache */ 2587c478bd9Sstevel@tonic-gate DFOUND, /* entry found */ 2597c478bd9Sstevel@tonic-gate DNOENT, /* no entry found */ 2607c478bd9Sstevel@tonic-gate DTOOBIG, /* exceeds tunable dnlc_max_dir_cache */ 2617c478bd9Sstevel@tonic-gate DNOMEM /* no memory */ 2627c478bd9Sstevel@tonic-gate } dcret_t; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate /* 2657c478bd9Sstevel@tonic-gate * dnlc_dir_start() requests that a directory be cached. 2667c478bd9Sstevel@tonic-gate * This must be called initially to enable caching on a directory. 2677c478bd9Sstevel@tonic-gate * After a successful call, directory entries and free space can be 2687c478bd9Sstevel@tonic-gate * added (see below) until the directory is marked complete. 2697c478bd9Sstevel@tonic-gate * "num_entries" is an estimate of the current number of 2707c478bd9Sstevel@tonic-gate * directory entries. The request is rejected with DNOCACHE 2717c478bd9Sstevel@tonic-gate * if num_entries falls below the tunable dnlc_dir_min_size (see 2727c478bd9Sstevel@tonic-gate * below), and rejected with DTOOBIG if it's above dnlc_dir_max_size. 2737c478bd9Sstevel@tonic-gate * Returns DOK, DNOCACHE, DTOOBIG, DNOMEM. 2747c478bd9Sstevel@tonic-gate * 2757c478bd9Sstevel@tonic-gate * Due to memory shortages, directory caches can be purged at 2767c478bd9Sstevel@tonic-gate * any time. If the last directory cache is purged due to memory 2777c478bd9Sstevel@tonic-gate * shortage, then the directory cache is marked internally 2787c478bd9Sstevel@tonic-gate * as "no memory". Future returns will all be DNOCACHE until 2797c478bd9Sstevel@tonic-gate * the next dnlc_start_dir() which will return DNOMEM once. 2807c478bd9Sstevel@tonic-gate * This memory shortage may only be transient. It's up to the 2817c478bd9Sstevel@tonic-gate * file system as to what to do about this condition, but an 2827c478bd9Sstevel@tonic-gate * attempt to immediately re-build the cache will very likely 2837c478bd9Sstevel@tonic-gate * lead to the same shortage of memory and a thrashing situation. 2847c478bd9Sstevel@tonic-gate * 2857c478bd9Sstevel@tonic-gate * It's file system policy as to when and what size directories to cache. 2867c478bd9Sstevel@tonic-gate */ 2877c478bd9Sstevel@tonic-gate dcret_t dnlc_dir_start(dcanchor_t *dcap, uint_t num_entries); 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate /* 2907c478bd9Sstevel@tonic-gate * dnlc_dir_add_entry() adds an entry (name and handle) into a 2917c478bd9Sstevel@tonic-gate * partial or complete cache. "handle" is a file system specific 2927c478bd9Sstevel@tonic-gate * quantity that is returned on calls to dnlc_dir_lookup() - see below. 2937c478bd9Sstevel@tonic-gate * For example, "handle" for ufs holds the inumber and a directory 2947c478bd9Sstevel@tonic-gate * entry offset. Returns DOK, DNOCACHE, DTOOBIG. 2957c478bd9Sstevel@tonic-gate */ 296*744947dcSTom Erickson dcret_t dnlc_dir_add_entry(dcanchor_t *dcap, const char *name, uint64_t handle); 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * dnlc_dir_add_space adds free space (length and file system specific 3007c478bd9Sstevel@tonic-gate * handle) into a partial or complete cache. "handle" is a file 3017c478bd9Sstevel@tonic-gate * system specific quantity that is returned on calls to 3027c478bd9Sstevel@tonic-gate * dnlc_dir_rem_space_by_len(). For example, "handle" for ufs holds 3037c478bd9Sstevel@tonic-gate * the directory entry offset. Returns DOK, DNOCACHE, DTOOBIG. 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate dcret_t dnlc_dir_add_space(dcanchor_t *dcap, uint_t len, uint64_t handle); 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate /* 3087c478bd9Sstevel@tonic-gate * dnlc_dir_complete() indicates the previously partial cache is now complete. 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate void dnlc_dir_complete(dcanchor_t *dcap); 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate /* 3137c478bd9Sstevel@tonic-gate * dnlc_dir_purge() deletes a partial or complete directory cache 3147c478bd9Sstevel@tonic-gate */ 3157c478bd9Sstevel@tonic-gate void dnlc_dir_purge(dcanchor_t *dcap); 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* 3187c478bd9Sstevel@tonic-gate * dnlc_dir_lookup() lookups a file name in a directory cache 3197c478bd9Sstevel@tonic-gate * and returns the file system handle specified on dnlc_dir_add_entry() 3207c478bd9Sstevel@tonic-gate * in "handlep". Returns DFOUND, DNOENT, DNOCACHE. 3217c478bd9Sstevel@tonic-gate */ 322*744947dcSTom Erickson dcret_t dnlc_dir_lookup(dcanchor_t *dcap, const char *name, uint64_t *handlep); 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate /* 3257c478bd9Sstevel@tonic-gate * dnlc_dir_update() amends the handle for an entry in a directory cache 3267c478bd9Sstevel@tonic-gate * "handle" is the new file system specific handle for the file "name". 3277c478bd9Sstevel@tonic-gate * Returns DFOUND, DNOENT, DNOCACHE. 3287c478bd9Sstevel@tonic-gate */ 329*744947dcSTom Erickson dcret_t dnlc_dir_update(dcanchor_t *dcap, const char *name, uint64_t handle); 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * dnlc_dir_rem_entry() removes an entry form a directory cache. 3337c478bd9Sstevel@tonic-gate * Returns the handle if "handlep" non null. 3347c478bd9Sstevel@tonic-gate * Returns DFOUND, DNOENT, DNOCACHE. 3357c478bd9Sstevel@tonic-gate */ 336*744947dcSTom Erickson dcret_t dnlc_dir_rem_entry(dcanchor_t *dcap, const char *name, 337*744947dcSTom Erickson uint64_t *handlep); 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * dnlc_dir_rem_space_by_len() looks up and returns free space in a 3417c478bd9Sstevel@tonic-gate * directory cache of at least the given "len". Returns in "handlep" 3427c478bd9Sstevel@tonic-gate * the handle supplied when adding the free space in dnlc_dir_add_space(). 3437c478bd9Sstevel@tonic-gate * Returns DFOUND, DNOENT, DNOCACHE. 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_len(dcanchor_t *dcap, uint_t len, 3467c478bd9Sstevel@tonic-gate uint64_t *handlep); 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate /* 3497c478bd9Sstevel@tonic-gate * dnlc_dir_rem_space_by_handle() looks up and removes the free space in 3507c478bd9Sstevel@tonic-gate * a directory cache with the given handle. Returns DFOUND, DNOENT, DNOCACHE. 3517c478bd9Sstevel@tonic-gate */ 3527c478bd9Sstevel@tonic-gate dcret_t dnlc_dir_rem_space_by_handle(dcanchor_t *dcap, uint64_t handle); 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate /* 3557c478bd9Sstevel@tonic-gate * dnlc_dir_init() initialises a directory anchor 3567c478bd9Sstevel@tonic-gate */ 3577c478bd9Sstevel@tonic-gate #define dnlc_dir_init(dcap) { \ 3587c478bd9Sstevel@tonic-gate (dcap)->dca_dircache = NULL; \ 3597c478bd9Sstevel@tonic-gate mutex_init(&(dcap)->dca_lock, NULL, MUTEX_DEFAULT, NULL); } 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate /* 3627c478bd9Sstevel@tonic-gate * dnlc_dir_fini() is called to indicate the anchor is no longer used. 3637c478bd9Sstevel@tonic-gate * It ensures there's no directory cache and mutex_destroys the lock 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate void dnlc_dir_fini(dcanchor_t *dcap); 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate #endif 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate #endif /* _SYS_DNLC_H */ 374