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.4.2.3 retrieving revision 1.13.2.3 diff -u -p -r1.4.2.3 -r1.13.2.3 --- src/sys/ufs/ufs/ufs_dirhash.c 2007/09/03 14:46:59 1.4.2.3 +++ src/sys/ufs/ufs/ufs_dirhash.c 2007/05/13 17:36:46 1.13.2.3 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.4.2.3 2007/09/03 14:46:59 yamt Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.13.2.3 2007/05/13 17:36:46 ad Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -27,9 +27,6 @@ * $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.4.2.3 2007/09/03 14:46:59 yamt Exp $"); - /* * This implements a hash-based lookup scheme for UFS directories. */ @@ -47,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_dirhash. #include #include +#include #include #include #include @@ -59,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_dirhash. #define OFSFMT(ip) ((ip)->i_ump->um_maxsymlinklen <= 0) #define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n)) -static MALLOC_JUSTDEFINE(M_DIRHASH, "UFS dirhash", "UFS directory hash tables"); +static MALLOC_DEFINE(M_DIRHASH, "UFS dirhash", "UFS directory hash tables"); static int ufs_dirhashminblks = 5; static int ufs_dirhashmaxmem = 2 * 1024 * 1024; @@ -76,7 +74,8 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); -static struct pool ufsdirhash_pool; +static POOL_INIT(ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, + "ufsdirhash", &pool_allocator_nointr, IPL_NONE); #define DIRHASHLIST_LOCK() mutex_enter(&ufsdirhash_lock) #define DIRHASHLIST_UNLOCK() mutex_exit(&ufsdirhash_lock) @@ -216,7 +215,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; } @@ -226,7 +225,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) { @@ -243,7 +242,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; @@ -412,7 +411,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); @@ -421,7 +420,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 && @@ -432,7 +431,7 @@ restart: prevoff = ufsdirhash_getprev(dp, offset, dirblksiz); if (prevoff == -1) { - brelse(bp); + brelse(bp, 0); return (EJUSTRETURN); } } else @@ -454,7 +453,7 @@ restart: if (dh->dh_hash == NULL) { DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp); + brelse(bp, 0); ufsdirhash_free(ip); return (EJUSTRETURN); } @@ -469,7 +468,7 @@ restart: } DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp); + brelse(bp, 0); return (ENOENT); } @@ -529,7 +528,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)) @@ -538,7 +537,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; @@ -550,19 +549,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); } @@ -1072,21 +1071,21 @@ ufsdirhash_recycle(int wanted) void ufsdirhash_init() { - - mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE); - malloc_type_attach(M_DIRHASH); +#ifdef _LKM pool_init(&ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, "ufsdirhash", &pool_allocator_nointr, IPL_NONE); +#endif + mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE); TAILQ_INIT(&ufsdirhash_list); } void ufsdirhash_done(void) { - KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); +#ifdef _LKM pool_destroy(&ufsdirhash_pool); - malloc_type_detach(M_DIRHASH); +#endif mutex_destroy(&ufsdirhash_lock); }