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.17 retrieving revision 1.21 diff -u -p -r1.17 -r1.21 --- src/sys/ufs/ufs/ufs_dirhash.c 2007/07/09 22:44:07 1.17 +++ src/sys/ufs/ufs/ufs_dirhash.c 2008/01/03 19:28:50 1.21 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.17 2007/07/09 22:44:07 ad Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.21 2008/01/03 19:28:50 ad 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 2008/01/03 19:28:50 ad Exp $"); + /* * This implements a hash-based lookup scheme for UFS directories. */ @@ -44,7 +47,6 @@ #include #include -#include #include #include #include @@ -74,14 +76,16 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); -static struct pool ufsdirhash_pool; +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; @@ -214,7 +218,7 @@ ufsdirhash_build(struct inode *ip) /* If necessary, get the next directory block. */ if ((pos & bmask) == 0) { if (bp != NULL) - brelse(bp); + brelse(bp, 0); if (ufs_blkatoff(vp, (off_t)pos, NULL, &bp) != 0) goto fail; } @@ -224,7 +228,7 @@ ufsdirhash_build(struct inode *ip) if (ep->d_reclen == 0 || ep->d_reclen > dirblksiz - (pos & (dirblksiz - 1))) { /* Corrupted directory. */ - brelse(bp); + brelse(bp, 0); goto fail; } if (ep->d_ino != 0) { @@ -241,7 +245,7 @@ ufsdirhash_build(struct inode *ip) } if (bp != NULL) - brelse(bp); + brelse(bp, 0); DIRHASHLIST_LOCK(); TAILQ_INSERT_TAIL(&ufsdirhash_list, dh, dh_list); dh->dh_onlist = 1; @@ -410,7 +414,7 @@ restart: panic("ufsdirhash_lookup: bad offset in hash array"); if ((offset & ~bmask) != blkoff) { if (bp != NULL) - brelse(bp); + brelse(bp, 0); blkoff = offset & ~bmask; if (ufs_blkatoff(vp, (off_t)blkoff, NULL, &bp) != 0) return (EJUSTRETURN); @@ -419,7 +423,7 @@ restart: if (dp->d_reclen == 0 || dp->d_reclen > dirblksiz - (offset & (dirblksiz - 1))) { /* Corrupted directory. */ - brelse(bp); + brelse(bp, 0); return (EJUSTRETURN); } if (dp->d_namlen == namelen && @@ -430,7 +434,7 @@ restart: prevoff = ufsdirhash_getprev(dp, offset, dirblksiz); if (prevoff == -1) { - brelse(bp); + brelse(bp, 0); return (EJUSTRETURN); } } else @@ -452,7 +456,7 @@ restart: if (dh->dh_hash == NULL) { DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp); + brelse(bp, 0); ufsdirhash_free(ip); return (EJUSTRETURN); } @@ -467,7 +471,7 @@ restart: } DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp); + brelse(bp, 0); return (ENOENT); } @@ -527,7 +531,7 @@ ufsdirhash_findfree(struct inode *ip, in /* Find the first entry with free space. */ for (i = 0; i < dirblksiz; ) { if (dp->d_reclen == 0) { - brelse(bp); + brelse(bp, 0); return (-1); } if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp, needswap)) @@ -536,7 +540,7 @@ ufsdirhash_findfree(struct inode *ip, in dp = (struct direct *)((char *)dp + dp->d_reclen); } if (i > dirblksiz) { - brelse(bp); + brelse(bp, 0); return (-1); } slotstart = pos + i; @@ -548,19 +552,19 @@ ufsdirhash_findfree(struct inode *ip, in if (dp->d_ino != 0) freebytes -= DIRSIZ(0, dp, needswap); if (dp->d_reclen == 0) { - brelse(bp); + brelse(bp, 0); return (-1); } i += dp->d_reclen; dp = (struct direct *)((char *)dp + dp->d_reclen); } if (i > dirblksiz) { - brelse(bp); + brelse(bp, 0); return (-1); } if (freebytes < slotneeded) panic("ufsdirhash_findfree: free mismatch"); - brelse(bp); + brelse(bp, 0); *slotsize = pos + i - slotstart; return (slotstart); } @@ -1073,8 +1077,8 @@ ufsdirhash_init() mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE); malloc_type_attach(M_DIRHASH); - pool_init(&ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, - "ufsdirhash", &pool_allocator_nointr, IPL_NONE); + ufsdirhash_cache = pool_cache_init(DH_NBLKOFF * sizeof(daddr_t), 0, + 0, 0, "ufsdirhash", NULL, IPL_NONE, NULL, NULL, NULL); TAILQ_INIT(&ufsdirhash_list); } @@ -1083,7 +1087,7 @@ 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); }