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.4 diff -u -p -r1.4.2.3 -r1.13.2.4 --- 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/07/15 13:28:20 1.13.2.4 @@ -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.4 2007/07/15 13:28:20 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. */ @@ -76,8 +73,6 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); -static struct pool ufsdirhash_pool; - #define DIRHASHLIST_LOCK() mutex_enter(&ufsdirhash_lock) #define DIRHASHLIST_UNLOCK() mutex_exit(&ufsdirhash_lock) #define DIRHASH_LOCK(dh) mutex_enter(&(dh)->dh_lock) @@ -216,7 +211,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 +221,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 +238,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 +407,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 +416,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 +427,7 @@ restart: prevoff = ufsdirhash_getprev(dp, offset, dirblksiz); if (prevoff == -1) { - brelse(bp); + brelse(bp, 0); return (EJUSTRETURN); } } else @@ -454,7 +449,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 +464,7 @@ restart: } DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp); + brelse(bp, 0); return (ENOENT); } @@ -529,7 +524,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 +533,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 +545,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); } @@ -938,6 +933,8 @@ 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); @@ -962,6 +959,8 @@ 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; @@ -1072,21 +1071,17 @@ ufsdirhash_recycle(int wanted) void 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); + mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE); TAILQ_INIT(&ufsdirhash_list); } void ufsdirhash_done(void) { - KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); pool_destroy(&ufsdirhash_pool); - malloc_type_detach(M_DIRHASH); mutex_destroy(&ufsdirhash_lock); }