3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
27
28 /*
29 * University Copyright- Copyright (c) 1982, 1986, 1988
30 * The Regents of the University of California
31 * All Rights Reserved
32 *
33 * University Acknowledgment- Portions of this document are derived from
34 * software developed by the University of California, Berkeley, and its
35 * contributors.
36 */
37
38 #ifndef _SYS_DNLC_H
39 #define _SYS_DNLC_H
40
41 #ifdef __cplusplus
42 extern "C" {
152
153 /*
154 * The dnlc hashing function.
155 * Although really a kernel macro we export it to allow validation
156 * of ncache_t entries by mdb. Note, mdb can handle the ASSERT.
157 *
158 * 'hash' and 'namlen' must be l-values. A check is made to ensure
159 * the name length fits into an unsigned char (see ncache_t).
160 */
161 #define DNLCHASH(name, dvp, hash, namlen) \
162 { \
163 char Xc; \
164 const char *Xcp; \
165 hash = (int)((uintptr_t)(dvp)) >> 8; \
166 for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++) \
167 (hash) = ((hash) << 4) + (hash) + Xc; \
168 ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1)); \
169 (namlen) = Xcp - (name); \
170 }
171
172 #if defined(_KERNEL)
173
174 #include <sys/vfs.h>
175 #include <sys/vnode.h>
176
177 extern int ncsize; /* set in param_init() # of dnlc entries */
178 extern vnode_t negative_cache_vnode;
179 #define DNLC_NO_VNODE &negative_cache_vnode
180
181 void dnlc_init(void);
182 void dnlc_enter(vnode_t *, const char *, vnode_t *);
183 void dnlc_update(vnode_t *, const char *, vnode_t *);
184 vnode_t *dnlc_lookup(vnode_t *, const char *);
185 void dnlc_purge(void);
186 void dnlc_purge_vp(vnode_t *);
187 int dnlc_purge_vfsp(vfs_t *, int);
188 void dnlc_remove(vnode_t *, const char *);
189 int dnlc_fs_purge1(struct vnodeops *);
190 void dnlc_reduce_cache(void *);
191
192 #endif /* defined(_KERNEL) */
193
194
195 /*
196 * Directory caching interfaces
197 * ============================
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38
39 #ifndef _SYS_DNLC_H
40 #define _SYS_DNLC_H
41
42 #ifdef __cplusplus
43 extern "C" {
153
154 /*
155 * The dnlc hashing function.
156 * Although really a kernel macro we export it to allow validation
157 * of ncache_t entries by mdb. Note, mdb can handle the ASSERT.
158 *
159 * 'hash' and 'namlen' must be l-values. A check is made to ensure
160 * the name length fits into an unsigned char (see ncache_t).
161 */
162 #define DNLCHASH(name, dvp, hash, namlen) \
163 { \
164 char Xc; \
165 const char *Xcp; \
166 hash = (int)((uintptr_t)(dvp)) >> 8; \
167 for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++) \
168 (hash) = ((hash) << 4) + (hash) + Xc; \
169 ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1)); \
170 (namlen) = Xcp - (name); \
171 }
172
173 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
174
175 #include <sys/vfs.h>
176 #include <sys/vnode.h>
177
178 extern volatile int ncsize; /* set in param_init() # of dnlc entries */
179 extern vnode_t negative_cache_vnode;
180 #define DNLC_NO_VNODE &negative_cache_vnode
181
182 void dnlc_init(void);
183 void dnlc_enter(vnode_t *, const char *, vnode_t *);
184 void dnlc_update(vnode_t *, const char *, vnode_t *);
185 vnode_t *dnlc_lookup(vnode_t *, const char *);
186 void dnlc_purge(void);
187 void dnlc_purge_vp(vnode_t *);
188 int dnlc_purge_vfsp(vfs_t *, int);
189 void dnlc_remove(vnode_t *, const char *);
190 int dnlc_fs_purge1(struct vnodeops *);
191 void dnlc_reduce_cache(void *);
192
193 #endif /* defined(_KERNEL) */
194
195
196 /*
197 * Directory caching interfaces
198 * ============================
|