Tue Jul 22 21:39:08 2008 UTC ()
No use walking empty hashtables when purging.


(reinoud)
diff -r1.66 -r1.67 src/sys/fs/udf/udf_subr.c

cvs diff -r1.66 -r1.67 src/sys/fs/udf/udf_subr.c (expand / switch to unified diff)

--- src/sys/fs/udf/udf_subr.c 2008/07/22 19:06:55 1.66
+++ src/sys/fs/udf/udf_subr.c 2008/07/22 21:39:08 1.67
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: udf_subr.c,v 1.66 2008/07/22 19:06:55 reinoud Exp $ */ 1/* $NetBSD: udf_subr.c,v 1.67 2008/07/22 21:39:08 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006, 2008 Reinoud Zandijk 4 * Copyright (c) 2006, 2008 Reinoud Zandijk
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *  26 *
27 */ 27 */
28 28
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifndef lint 31#ifndef lint
32__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.66 2008/07/22 19:06:55 reinoud Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.67 2008/07/22 21:39:08 reinoud Exp $");
33#endif /* not lint */ 33#endif /* not lint */
34 34
35 35
36#if defined(_KERNEL_OPT) 36#if defined(_KERNEL_OPT)
37#include "opt_quota.h" 37#include "opt_quota.h"
38#include "opt_compat_netbsd.h" 38#include "opt_compat_netbsd.h"
39#endif 39#endif
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/sysctl.h> 43#include <sys/sysctl.h>
44#include <sys/namei.h> 44#include <sys/namei.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
@@ -3878,26 +3878,29 @@ udf_dirhash_hash(const char *str, int na @@ -3878,26 +3878,29 @@ udf_dirhash_hash(const char *str, int na
3878 return hash; 3878 return hash;
3879} 3879}
3880 3880
3881 3881
3882static void 3882static void
3883udf_dirhash_purge(struct udf_dirhash *dirh) 3883udf_dirhash_purge(struct udf_dirhash *dirh)
3884{ 3884{
3885 struct udf_dirhash_entry *dirh_e; 3885 struct udf_dirhash_entry *dirh_e;
3886 uint32_t hashline; 3886 uint32_t hashline;
3887 3887
3888 if (dirh == NULL) 3888 if (dirh == NULL)
3889 return; 3889 return;
3890 3890
 3891 if (dirh->size == 0)
 3892 return;
 3893
3891 for (hashline = 0; hashline < UDF_DIRHASH_HASHSIZE; hashline++) { 3894 for (hashline = 0; hashline < UDF_DIRHASH_HASHSIZE; hashline++) {
3892 dirh_e = LIST_FIRST(&dirh->entries[hashline]); 3895 dirh_e = LIST_FIRST(&dirh->entries[hashline]);
3893 while (dirh_e) { 3896 while (dirh_e) {
3894 LIST_REMOVE(dirh_e, next); 3897 LIST_REMOVE(dirh_e, next);
3895 pool_put(&udf_dirhash_entry_pool, dirh_e); 3898 pool_put(&udf_dirhash_entry_pool, dirh_e);
3896 dirh_e = LIST_FIRST(&dirh->entries[hashline]); 3899 dirh_e = LIST_FIRST(&dirh->entries[hashline]);
3897 } 3900 }
3898 } 3901 }
3899 dirh_e = LIST_FIRST(&dirh->free_entries); 3902 dirh_e = LIST_FIRST(&dirh->free_entries);
3900 3903
3901 while (dirh_e) { 3904 while (dirh_e) {
3902 LIST_REMOVE(dirh_e, next); 3905 LIST_REMOVE(dirh_e, next);
3903 pool_put(&udf_dirhash_entry_pool, dirh_e); 3906 pool_put(&udf_dirhash_entry_pool, dirh_e);