| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ufs_dirhash.c,v 1.30 2009/03/18 15:14:32 cegger Exp $ */ | | 1 | /* $NetBSD: ufs_dirhash.c,v 1.31 2009/05/04 20:54:25 rmind Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. | | 4 | * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -18,27 +18,27 @@ | | | @@ -18,27 +18,27 @@ |
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 | * SUCH DAMAGE. | | 25 | * SUCH DAMAGE. |
26 | * | | 26 | * |
27 | * $FreeBSD: src/sys/ufs/ufs/ufs_dirhash.c,v 1.3.2.8 2004/12/08 11:54:13 dwmalone Exp $ | | 27 | * $FreeBSD: src/sys/ufs/ufs/ufs_dirhash.c,v 1.3.2.8 2004/12/08 11:54:13 dwmalone Exp $ |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include <sys/cdefs.h> | | 30 | #include <sys/cdefs.h> |
31 | __KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.30 2009/03/18 15:14:32 cegger Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.31 2009/05/04 20:54:25 rmind Exp $"); |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * This implements a hash-based lookup scheme for UFS directories. | | 34 | * This implements a hash-based lookup scheme for UFS directories. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/types.h> | | 41 | #include <sys/types.h> |
42 | #include <sys/hash.h> | | 42 | #include <sys/hash.h> |
43 | #include <sys/proc.h> | | 43 | #include <sys/proc.h> |
44 | #include <sys/buf.h> | | 44 | #include <sys/buf.h> |
| @@ -1073,30 +1073,31 @@ ufsdirhash_recycle(int wanted) | | | @@ -1073,30 +1073,31 @@ ufsdirhash_recycle(int wanted) |
1073 | narrays = dh->dh_narrays; | | 1073 | narrays = dh->dh_narrays; |
1074 | mem = narrays * sizeof(*dh->dh_hash) + | | 1074 | mem = narrays * sizeof(*dh->dh_hash) + |
1075 | narrays * DH_NBLKOFF * sizeof(**dh->dh_hash) + | | 1075 | narrays * DH_NBLKOFF * sizeof(**dh->dh_hash) + |
1076 | dh->dh_nblk * sizeof(*dh->dh_blkfree); | | 1076 | dh->dh_nblk * sizeof(*dh->dh_blkfree); |
1077 | | | 1077 | |
1078 | /* Unlock everything, free the detached memory. */ | | 1078 | /* Unlock everything, free the detached memory. */ |
1079 | DIRHASH_UNLOCK(dh); | | 1079 | DIRHASH_UNLOCK(dh); |
1080 | DIRHASHLIST_UNLOCK(); | | 1080 | DIRHASHLIST_UNLOCK(); |
1081 | | | 1081 | |
1082 | for (i = 0; i < narrays; i++) | | 1082 | for (i = 0; i < narrays; i++) |
1083 | DIRHASH_BLKFREE(hash[i]); | | 1083 | DIRHASH_BLKFREE(hash[i]); |
1084 | kmem_free(hash, hashsz); | | 1084 | kmem_free(hash, hashsz); |
1085 | kmem_free(blkfree, blkfreesz); | | 1085 | kmem_free(blkfree, blkfreesz); |
| | | 1086 | pool_cache_put(ufsdirhash_cache, dh); |
1086 | | | 1087 | |
1087 | /* Account for the returned memory, and repeat if necessary. */ | | 1088 | /* Account for the returned memory, and repeat if necessary. */ |
1088 | DIRHASHLIST_LOCK(); | | 1089 | DIRHASHLIST_LOCK(); |
1089 | ufs_dirhashmem -= mem; | | 1090 | atomic_add_int(&ufs_dirhashmem, -mem); |
1090 | } | | 1091 | } |
1091 | /* Success. */ | | 1092 | /* Success. */ |
1092 | return (0); | | 1093 | return (0); |
1093 | } | | 1094 | } |
1094 | | | 1095 | |
1095 | static void | | 1096 | static void |
1096 | ufsdirhash_sysctl_init(void) | | 1097 | ufsdirhash_sysctl_init(void) |
1097 | { | | 1098 | { |
1098 | const struct sysctlnode *rnode, *cnode; | | 1099 | const struct sysctlnode *rnode, *cnode; |
1099 | | | 1100 | |
1100 | sysctl_createv(&ufsdirhash_sysctl_log, 0, NULL, &rnode, | | 1101 | sysctl_createv(&ufsdirhash_sysctl_log, 0, NULL, &rnode, |
1101 | CTLFLAG_PERMANENT, | | 1102 | CTLFLAG_PERMANENT, |
1102 | CTLTYPE_NODE, "vfs", NULL, | | 1103 | CTLTYPE_NODE, "vfs", NULL, |