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.3 retrieving revision 1.17 diff -u -p -r1.13.2.3 -r1.17 --- src/sys/ufs/ufs/ufs_dirhash.c 2007/05/13 17:36:46 1.13.2.3 +++ src/sys/ufs/ufs/ufs_dirhash.c 2007/07/09 22:44:07 1.17 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.13.2.3 2007/05/13 17:36:46 ad Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.17 2007/07/09 22:44:07 ad Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -57,7 +57,7 @@ #define OFSFMT(ip) ((ip)->i_ump->um_maxsymlinklen <= 0) #define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n)) -static MALLOC_DEFINE(M_DIRHASH, "UFS dirhash", "UFS directory hash tables"); +static MALLOC_JUSTDEFINE(M_DIRHASH, "UFS dirhash", "UFS directory hash tables"); static int ufs_dirhashminblks = 5; static int ufs_dirhashmaxmem = 2 * 1024 * 1024; @@ -74,8 +74,7 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); -static POOL_INIT(ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, - "ufsdirhash", &pool_allocator_nointr, IPL_NONE); +static struct pool ufsdirhash_pool; #define DIRHASHLIST_LOCK() mutex_enter(&ufsdirhash_lock) #define DIRHASHLIST_UNLOCK() mutex_exit(&ufsdirhash_lock) @@ -215,7 +214,7 @@ ufsdirhash_build(struct inode *ip) /* If necessary, get the next directory block. */ if ((pos & bmask) == 0) { if (bp != NULL) - brelse(bp, 0); + brelse(bp); if (ufs_blkatoff(vp, (off_t)pos, NULL, &bp) != 0) goto fail; } @@ -225,7 +224,7 @@ ufsdirhash_build(struct inode *ip) if (ep->d_reclen == 0 || ep->d_reclen > dirblksiz - (pos & (dirblksiz - 1))) { /* Corrupted directory. */ - brelse(bp, 0); + brelse(bp); goto fail; } if (ep->d_ino != 0) { @@ -242,7 +241,7 @@ ufsdirhash_build(struct inode *ip) } if (bp != NULL) - brelse(bp, 0); + brelse(bp); DIRHASHLIST_LOCK(); TAILQ_INSERT_TAIL(&ufsdirhash_list, dh, dh_list); dh->dh_onlist = 1; @@ -411,7 +410,7 @@ restart: panic("ufsdirhash_lookup: bad offset in hash array"); if ((offset & ~bmask) != blkoff) { if (bp != NULL) - brelse(bp, 0); + brelse(bp); blkoff = offset & ~bmask; if (ufs_blkatoff(vp, (off_t)blkoff, NULL, &bp) != 0) return (EJUSTRETURN); @@ -420,7 +419,7 @@ restart: if (dp->d_reclen == 0 || dp->d_reclen > dirblksiz - (offset & (dirblksiz - 1))) { /* Corrupted directory. */ - brelse(bp, 0); + brelse(bp); return (EJUSTRETURN); } if (dp->d_namlen == namelen && @@ -431,7 +430,7 @@ restart: prevoff = ufsdirhash_getprev(dp, offset, dirblksiz); if (prevoff == -1) { - brelse(bp, 0); + brelse(bp); return (EJUSTRETURN); } } else @@ -453,7 +452,7 @@ restart: if (dh->dh_hash == NULL) { DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp, 0); + brelse(bp); ufsdirhash_free(ip); return (EJUSTRETURN); } @@ -468,7 +467,7 @@ restart: } DIRHASH_UNLOCK(dh); if (bp != NULL) - brelse(bp, 0); + brelse(bp); return (ENOENT); } @@ -528,7 +527,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, 0); + brelse(bp); return (-1); } if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp, needswap)) @@ -537,7 +536,7 @@ ufsdirhash_findfree(struct inode *ip, in dp = (struct direct *)((char *)dp + dp->d_reclen); } if (i > dirblksiz) { - brelse(bp, 0); + brelse(bp); return (-1); } slotstart = pos + i; @@ -549,19 +548,19 @@ ufsdirhash_findfree(struct inode *ip, in if (dp->d_ino != 0) freebytes -= DIRSIZ(0, dp, needswap); if (dp->d_reclen == 0) { - brelse(bp, 0); + brelse(bp); return (-1); } i += dp->d_reclen; dp = (struct direct *)((char *)dp + dp->d_reclen); } if (i > dirblksiz) { - brelse(bp, 0); + brelse(bp); return (-1); } if (freebytes < slotneeded) panic("ufsdirhash_findfree: free mismatch"); - brelse(bp, 0); + brelse(bp); *slotsize = pos + i - slotstart; return (slotstart); } @@ -1071,21 +1070,21 @@ ufsdirhash_recycle(int wanted) void ufsdirhash_init() { -#ifdef _LKM + + 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); -#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); -#endif + malloc_type_detach(M_DIRHASH); mutex_destroy(&ufsdirhash_lock); }