Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_dirhash.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_dirhash.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.13.2.4 retrieving revision 1.21.6.1 diff -u -p -r1.13.2.4 -r1.21.6.1 --- src/sys/ufs/ufs/ufs_dirhash.c 2007/07/15 13:28:20 1.13.2.4 +++ src/sys/ufs/ufs/ufs_dirhash.c 2008/06/02 13:24:37 1.21.6.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.13.2.4 2007/07/15 13:28:20 ad Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.21.6.1 2008/06/02 13:24:37 mjf Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -27,6 +27,9 @@ * $FreeBSD: src/sys/ufs/ufs/ufs_dirhash.c,v 1.3.2.8 2004/12/08 11:54:13 dwmalone Exp $ */ +#include +__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.21.6.1 2008/06/02 13:24:37 mjf Exp $"); + /* * This implements a hash-based lookup scheme for UFS directories. */ @@ -73,12 +76,16 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); +static pool_cache_t ufsdirhash_cache; + #define DIRHASHLIST_LOCK() mutex_enter(&ufsdirhash_lock) #define DIRHASHLIST_UNLOCK() mutex_exit(&ufsdirhash_lock) #define DIRHASH_LOCK(dh) mutex_enter(&(dh)->dh_lock) #define DIRHASH_UNLOCK(dh) mutex_exit(&(dh)->dh_lock) -#define DIRHASH_BLKALLOC_WAITOK() pool_get(&ufsdirhash_pool, PR_WAITOK) -#define DIRHASH_BLKFREE(ptr) pool_put(&ufsdirhash_pool, ptr) +#define DIRHASH_BLKALLOC_WAITOK() \ + pool_cache_get(ufsdirhash_cache, PR_WAITOK) +#define DIRHASH_BLKFREE(ptr) \ + pool_cache_put(ufsdirhash_cache, ptr) /* Dirhash list; recently-used entries are near the tail. */ static TAILQ_HEAD(, dirhash) ufsdirhash_list; @@ -212,7 +219,7 @@ ufsdirhash_build(struct inode *ip) if ((pos & bmask) == 0) { if (bp != NULL) brelse(bp, 0); - if (ufs_blkatoff(vp, (off_t)pos, NULL, &bp) != 0) + if (ufs_blkatoff(vp, (off_t)pos, NULL, &bp, false) != 0) goto fail; } @@ -409,7 +416,8 @@ restart: if (bp != NULL) brelse(bp, 0); blkoff = offset & ~bmask; - if (ufs_blkatoff(vp, (off_t)blkoff, NULL, &bp) != 0) + if (ufs_blkatoff(vp, (off_t)blkoff, + NULL, &bp, true) != 0) return (EJUSTRETURN); } dp = (struct direct *)((char *)bp->b_data + (offset & bmask)); @@ -518,7 +526,7 @@ ufsdirhash_findfree(struct inode *ip, in dh->dh_blkfree[dirblock] >= howmany(slotneeded, DIRALIGN)); DIRHASH_UNLOCK(dh); pos = dirblock * dirblksiz; - error = ufs_blkatoff(ip->i_vnode, (off_t)pos, (void *)&dp, &bp); + error = ufs_blkatoff(ip->i_vnode, (off_t)pos, (void *)&dp, &bp, false); if (error) return (-1); /* Find the first entry with free space. */ @@ -933,8 +941,6 @@ ufsdirhash_findslot(struct dirhash *dh, KASSERT(mutex_owned(&dh->dh_lock)); - KASSERT(mutex_owned(&dh->dh_lock)); - /* Find the entry. */ KASSERT(dh->dh_hused < dh->dh_hlen); slot = ufsdirhash_hash(dh, name, namelen); @@ -959,8 +965,6 @@ ufsdirhash_delslot(struct dirhash *dh, i KASSERT(mutex_owned(&dh->dh_lock)); - KASSERT(mutex_owned(&dh->dh_lock)); - /* Mark the entry as deleted. */ DH_ENTRY(dh, slot) = DIRHASH_DEL; @@ -1071,17 +1075,21 @@ ufsdirhash_recycle(int wanted) void ufsdirhash_init() { - pool_init(&ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, - "ufsdirhash", &pool_allocator_nointr, IPL_NONE); + mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE); + malloc_type_attach(M_DIRHASH); + ufsdirhash_cache = pool_cache_init(DH_NBLKOFF * sizeof(daddr_t), 0, + 0, 0, "ufsdirhash", NULL, IPL_NONE, NULL, NULL, NULL); TAILQ_INIT(&ufsdirhash_list); } void ufsdirhash_done(void) { + KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); - pool_destroy(&ufsdirhash_pool); + pool_cache_destroy(ufsdirhash_cache); + malloc_type_detach(M_DIRHASH); mutex_destroy(&ufsdirhash_lock); }